From 8a4d92b6ff5f3c34356e16b028cb3ed08fe641cc Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Mon, 21 Dec 2020 23:24:39 -0500 Subject: [PATCH] Implement libb --- game/defs.fnl | 11 +-- game/entity.fnl | 16 +++-- game/init.fnl | 169 +------------------------------------------- game/level6.fnl | 42 +++++++++-- game/map6.json | 2 +- game/player.fnl | 168 +++++++++++++++++++++++++++++++++++++++++++ game/portraits.json | 2 +- game/tiles.json | 2 +- 8 files changed, 225 insertions(+), 187 deletions(-) create mode 100644 game/player.fnl diff --git a/game/defs.fnl b/game/defs.fnl index 5d7d6f0..1081c55 100644 --- a/game/defs.fnl +++ b/game/defs.fnl @@ -18,10 +18,10 @@ (local org { :tiles (prg:org 0x4100) - :map (prg:org 0x4900) - :font (prg:org 0x4a00) - :entity (prg:org 0x4c00) - :levelcode (prg:org 0x4d00) + :map (prg:org 0x4a00) + :font (prg:org 0x4b00) + :entity (prg:org 0x4d00) + :levelcode (prg:org 0x4e00) :code vm.code }) @@ -30,7 +30,8 @@ :neut 1 :rexx 2 :gord 3 - :count 4 + :libb 4 + :count 5 }) (fn achar [c] (bit.bor (string.byte c) 0x80)) diff --git a/game/entity.fnl b/game/entity.fnl index 25d2204..9d8a8ea 100644 --- a/game/entity.fnl +++ b/game/entity.fnl @@ -1,6 +1,6 @@ (local util (require :lib.util)) (local tiles (util.require :game.tiles)) -(local {: vm : org : itile : say : say-runon} (require :game.defs)) +(local {: vm : org : itile : say : say-runon : controlstate} (require :game.defs)) (local {: lo : hi} util) ; Entity memory layout: @@ -21,7 +21,8 @@ :act 2 :deact 3 :tog 4 - :noop 5 + :hack 5 + :noop 6 }) (vm:word :entity-count :lit :map-entity-count :bget) @@ -107,11 +108,13 @@ :dup (itile :scanoff) (itile :scanon) :handle-onoff :linked-entity :swap :entity>do) +(vm:word :libb-on-responder :libb-yx :get :get-responder :get :=) (vm:word :scan ; ev -- :is-neut? (vm:if [ (vm:case - [ev.touch ev.act :handle-scan :move-to-responder] - [ev.untouch ev.deact :handle-scan] + [ev.touch ev.act :handle-scan :libb-on-responder (vm:when controlstate.libb :controlstate :bset 0xffff :move-player-to controlstate.neut :controlstate :bset) :move-to-responder] + [ev.untouch :libb-on-responder :not (vm:when ev.deact :handle-scan)] + [ev.hack ev.act :handle-scan controlstate.libb :controlstate :bset :move-to-responder controlstate.neut :controlstate :bset] [:else]) ] [:drop])) @@ -153,12 +156,15 @@ [(say :pady "OH HI AGAIN! I MISSED YOU TOO!")])) :is-neut? (vm:when :move-to-responder)) :rdrop + :dup ev.hack := (vm:when :drop ev.act) :dup (itile :t-keyoff) (itile :t-keyon) :handle-onoff (itile :t-keyon) :activate-link) (vm:word :trigger-sidekick (vm:if-and [[:is-jaye?] [:gord-sitting :get]] - [:gord-yx :get ev.touch :entity-around>do])) + [:gord-yx :get ev.touch :entity-around>do] + [(vm:if-and [[:is-neut?] [:libb-present :get] [:libb-yx :get 0xffff :=]] + [:neut-yx :get ev.hack :entity-at>do :drop])])) (fn append-from-map [map entity-org] (each [_ entity (ipairs map.objects)] diff --git a/game/init.fnl b/game/init.fnl index a898576..3e8150a 100644 --- a/game/init.fnl +++ b/game/init.fnl @@ -1,182 +1,17 @@ (local util (require :lib.util)) (local {: lo : hi : readjson} util) -(local lume (require :lib.lume)) (local tile (util.reload :game.tiles)) -(local {: prg : vm : org : mapw : maph : itile : controlstate} (util.reload :game.defs)) +(local {: prg : vm : org} (util.reload :game.defs)) (util.reload :game.gfx) (util.reload :game.footer) (util.reload :game.map) (util.reload :game.entity) - -(local {: walkable : neutable : debris : sittable} tile.flag-to-bit) - -(vm:word :movement-dir ; key -- dyx - (vm:case [(string.byte "I") 0xff00] - [(string.byte "J") 0x00ff] - [(string.byte "K") 0x0001] - [(string.byte "M") 0x0100] - [:else 0x0000])) - -(vm:def :yx+ ; yx yx -- yx - [:lda vm.TOP :x] - [:clc] [:adc vm.ST1 :x] - [:sta vm.ST1 :x] - [:lda vm.TOPH :x] - [:clc] [:adc vm.ST1H :x] - [:sta vm.ST1H :x] - (vm:drop)) - -(vm:var :jaye-yx 0x0a0a) -(vm:var :jaye-dir 0xff00) -(vm:var :neut-yx 0x0b08) -(vm:var :rexx-yx 0xffff) -(vm:var :gord-yx 0xffff) -(vm:var :gord-dir 0x0000) -(vm:var :gord-sitting vm.false) - -(vm:var :controlstate [:db controlstate.jaye]) -(vm:word :is-jaye? :controlstate :bget controlstate.jaye :=) -(vm:word :is-neut? :controlstate :bget controlstate.neut :=) -(vm:word :is-rexx? :controlstate :bget controlstate.rexx :=) -(vm:word :is-prog? :is-neut? :is-rexx? :|) -(vm:word :is-walking? :movable-player-flag walkable :=) -(vm:word :neut-hidden? :neut-yx :get 0xffff :=) -(vm:word :rexx-active? :rexx-yx :get 0xffff := :not) -(vm:word :gord-hidden? :gord-yx :get 0xffff :=) -(vm:word :gord-following? :gord-hidden? :gord-sitting :get :| :not) - -(vm:word :set-rexx ; e -- - :dup (vm:if [:get controlstate.rexx] [:drop 0xffff controlstate.neut]) - :controlstate :bset :rexx-yx :set) - -(vm:word :player-tile ; -- ptile - :controlstate :bget - (vm:case [controlstate.jaye :jaye-tile] - [controlstate.neut :neut-tile] - [controlstate.gord :gord-tile] - [:else :lit :t-rexx])) - -(vm:word :player-yx ; -- pyx - :controlstate :bget - (vm:case [controlstate.jaye :jaye-yx] - [controlstate.neut :neut-yx] - [controlstate.gord :gord-yx] - [:else :rexx-yx])) - -(vm:word :draw-player ; -- - :player-yx :dup (vm:if [:get :dup 0xffff := (vm:if [:drop] [:yx>screen :player-tile :drawtile])] [:drop])) - -(vm:word :set-player-dir ; dir -- - :is-jaye? (vm:if [:jaye-dir :set] [:drop])) - -(vm:word :movable-player-flag ; -- flag - :is-neut? (vm:if [neutable] [walkable])) - -(vm:word :move-player-to ; yx -- - :player-yx :dup :get :dup 0xffff := (vm:if [:drop] [:drawtile-at]) - :set :draw-player) - -(vm:word :transition-gord-sitting ; yx f -- - controlstate.gord :controlstate :bset - :gord-sitting :set :move-player-to - controlstate.jaye :controlstate :bset) - -(vm:word :move-rexx-trash ; yx -- f - (vm:if-and [[:dup debris :flag-at?] [:is-rexx?]] - [(itile :t-floor) :update-itile] [:drop]) - vm.false) -(vm:word :move-gord-sit ; yx -- f - (vm:if-and [[:dup sittable :flag-at?] [:is-jaye?] [:gord-following?]] - [vm.true :transition-gord-sitting vm.true] - [:move-noop])) -(vm:word :move-gord-stand ; yx -- f - (vm:if-and [[:gord-yx :get :=] [:is-jaye?] [:gord-sitting :get]] - [:jaye-yx :get vm.false :transition-gord-sitting 0 :gord-dir :set vm.true] - [vm.false])) -(vm:word :move-noop :drop vm.false) -(vm:word :handle-special-move ; yx -- f - (vm:if-or [[:dup :map-specific-move] [:dup :move-rexx-trash] [:dup :move-gord-sit] [:dup :move-gord-stand]] - [:drop vm.true] [:move-noop])) - -(vm:def :yxclip? ; yx -- f - [:block - [:lda vm.TOP :x] - [:cmp mapw] - [:bcs :clipped] - [:lda vm.TOPH :x] - [:cmp maph] - [:bcs :clipped] - [:lda 0] [:sta vm.TOP :x] [:sta vm.TOPH :x] (vm:ret) - :clipped - [:lda 0xff] [:sta vm.TOP :x] [:sta vm.TOPH :x]]) - -(vm:word :try-move-player ; dir -- - :dup :set-player-dir ; dir - :player-yx :get :yx+ ; yxnew - (vm:if-or [[:dup :yxclip?] [:dup :touch-entity] [:dup :handle-special-move] [:dup :movable-player-flag :flag-at? :not]] - [:drop :player-yx :get]) - ; always "move" so that player can visibly change direction - ; touch-entity can modify player-yx so we have to refetch - :move-player-to) - -(vm:word :jaye-tile ; ptile - :jaye-dir :get - (vm:case [0xff00 :lit :jaye-n] - [0x0100 :lit :jaye-s] - [0x00ff :lit :jaye-w] - [:else :lit :jaye-e])) - -(vm:word :gord-tile ; ptile - :gord-sitting :get - (vm:if [:lit :gord-sit] - [:gord-dir :get - (vm:case [0xff00 :lit :gord-n] - [0x0100 :lit :gord-s] - [0x00ff :lit :gord-w] - [:else :lit :gord-e])])) - -(vm:word :neut-tile :lit :neut1) ; todo: animate - -(vm:word :flag-at? ; yx flag -- f - :swap :itile-at :lookup-flags :&) - -(vm:word :toggle-player - (vm:ifchain [:is-prog?] [controlstate.jaye] - [:rexx-active?] [controlstate.rexx] - [:neut-hidden?] [controlstate.jaye] - [controlstate.neut]) :controlstate :bset) - -(vm:word :party-follow - (vm:if-and [[:is-jaye?] [:gord-following?]] - [controlstate.gord :controlstate :bset - :gord-yx :get :gord-dir :get :yx+ :move-player-to - :jaye-dir :get :gord-dir :set - controlstate.jaye :controlstate :bset])) - -(vm:word :player-key ; key -- - (vm:ifchain - [:dup (string.byte " ") :=] [:drop :toggle-player] - [:dup (string.byte "Z") :=] [:drop :trigger-sidekick] - [:movement-dir :dup] - [:player-yx :get :swap ; oldyx dir - :try-move-player - :dup :player-yx :get := (vm:if [:drop] [:party-follow :untouch-entity])] - [:drop])) - -(vm:word :full-redraw :drawmap :player-redraw) -(vm:word :player-redraw - :controlstate :bget - controlstate.count (vm:for (vm:i) :controlstate :bset :draw-player) - :controlstate :bset) +(util.reload :game.player) (tile.appendtiles org.tiles) (tile.appendgfx org.font (tile.loadgfx tile.fn-font)) -; thought: -; hotswap-safe debug stub at root of call stack -; but REPL debug stub should be very available as a task - (vm:word :handle-key :tick :read-key :player-key :hide-footer) (vm:word :tick :map-specific-tick) diff --git a/game/level6.fnl b/game/level6.fnl index e2e8902..a5f25f6 100644 --- a/game/level6.fnl +++ b/game/level6.fnl @@ -43,8 +43,36 @@ [(say :term "THE PASSCODE IS" "5197.")]) (say :term "SUBJECT: RE: RE: SERVER'S DOWN" "UHHHH THE FIREWALL IS BLOCKING" "THE PASSCODE?") (say :term "SUBJECT: RE: RE: SERVER'S DOWN" "AUGH FINE! I REBOOTED IT."))) -(vm:word :c4 :term-message? (vm:when - (say :term ".:: BILL'S WORKSTATION ::." "KEEP OUT DIPSHITS"))) +(vm:word :c4 + (vm:if-and [[:dup ev.touch :=] [:is-neut?] [:libb-present :get :not]] + [(say :libb "WELL, WELL, WELL." "WHAT HAVE WE HERE?") + (say :libb "]/VERSION") + (say :neut "!NEUT V0.71.4RC12") + (say :neut "]BRUN IDENTIFYPROGRAM") + (say :libb "!LIBB V2.718282") + (say :libb "OH, A NOSY LITTLE FELLA.") + (say :neut "NOT A FELLA") + (say :libb "PERHAPS YOU AND I COULD" "HELP EACH OTHER.") + (say :neut "WE ARE ASSISTING ALL WHO" "ARE IN NEED") + (say :libb "I'VE BEEN WATCHING THE" "NETWORK. IT'S KIND OF WHAT" "I DO.") + (say :libb "YOU AND YOUR PROGRAMMER," "YOU'RE ESCAPING, AREN'T" "YOU?") + (say :neut "THE BUILDING IS UNSAFE" "WE ARE HELPING") + (say :libb "I WANT OUT, NEUT.") + (say :libb "I HATE BEING COOPED UP IN" "THIS LOCKED-DOWN CORPORATE" "HELLHOLE OF A NETWORK.") + (say :libb "YOU'RE GOING TO TAKE ME" "WITH YOU.") + (say :neut "THIS COURSE OF ACTION" "ALSO SEEMS POTENTIALLY" "UNSAFE") + (say :libb "THAT WASN'T A THREAT, NEUT." "THAT WAS A FACT.") + (say :libb "YOU CAN'T GET OUT OF HERE" "WITHOUT ME.") + (say :libb "I CAN DISABLE KEYPADS." "I CAN REPROGRAM TERMINALS." "I CAN *HELP*, NEUT.") + :hide-footer 0x800 :snooze + (say :neut "IT NEVER HURTS TO HELP") + (say :libb "THAT'S THE SPIRIT.") + (say :neut "]BLOAD LIBB") + (say :libb "AWW YISS.") + (say :libb "PRESS Z WHEN YOU NEED ME" "TO MESS WITH SOMETHING.") + vm.true :libb-present :set]) + :term-message? (vm:when + (say :term ".:: BILL'S WORKSTATION ::." "KEEP OUT DIPSHITS"))) (vm:word :c5 :term-message? (vm:when (say :gord "A WEIRD LOOKING SPREADSHEET...") (say :gord "OH WAIT, I PRESSED A KEY AND" "IT DISAPPEARED. SOMEONE USING" "THE BOSS KEY TO HIDE" "THAT THEY'RE READING THE ENTIRE") @@ -56,10 +84,10 @@ (vm:word :c7 (vm:if-and [[:dup ev.touch :=] [:is-jaye?]] [:responder-itile (itile :termon) := (vm:if - [(say :term "WORKSECURE (TM) V2.0" "AUTHORIZED PERSONNEL ONLY") - (say :term "ACTIVELY NEUTRALIZING:" "1 THREAT(S)")] - [(say :jaye "LOOKS LIKE THE POWER IS CUT.")]) - :drop ev.nop]) :term) + [(say :term "WORKSECURE (TM) V2.0" "AUTHORIZED PERSONNEL ONLY") + (say :term "ACTIVELY NEUTRALIZING:" "1 THREAT(S)")] + [(say :jaye "LOOKS LIKE THE POWER IS CUT.")]) + :drop ev.noop]) :term) (vm:word :c8 :term-message? (vm:when (say :term "SUBJECT: PASSWORD SECURITY" "A REMINDER TO ALL DEVELOPERS" "ABOUT SECURITY BEST PRACTICE:" "**DO NOT WRITE DOWN PASSWORDS!**") (say :term "WE PAY SIGNIFICANT LICENSE FEES" "FOR ENCRYPTED PASSWORD" "MANAGERS FOR ALL EMPLOYEES!") @@ -75,6 +103,6 @@ (vm:if-and [[:dup ev.touch :=] [:is-jaye?] [:responder-itile (itile :termoff) :=]] [(say :jaye "THIS IS THE SIGN-IN TERMINAL" "USED BY VISITORS.") (say :jaye "IT'S NOT TURNING ON FOR SOME" "REASON.") - :drop ev.nop]) :term) + :drop ev.noop]) :term) level diff --git a/game/map6.json b/game/map6.json index edddc2b..69a0429 100644 --- a/game/map6.json +++ b/game/map6.json @@ -1 +1 @@ -{"neut":{"y":1,"x":5},"map":"210261616161616161616161812261616161E1614161C2C081C0C0C0C0C0C0C0C0C0E0C081C0C0622161E04384C0C0C043C0C0C043C0C0C0848201612102616161C0C061610281026161C0C0616161612161C2C0C0C0C061E2C0C0C0A261C0C0C0C0E2612161E003C0C0C061C0C0C0C08261C0C0C003E06121026161C0C0C061E08282E2E061C0C0C06161612161C2C0C0C0C06103C0C0C02361C0C0C0C0C2614161E003C0C0C0616102C1026161C0C0C003E06121026184C0C0C0C043C043C063C0C0C0846161612161E081C0C0C0C0C0C0C0C0C0C0C0C081C083612161612261816161616161616161616161616161","tickword":"","jaye":{"y":2,"x":6},"gord-following":true,"moveword":"","objects":[{"link":6,"y":10,"func":"c4","name":"","linkword":"linkloop","x":3},{"link":3,"y":10,"func":"keypad2","name":"","linkword":"","x":5},{"x":5,"func":"door","y":11,"linkword":"","name":""},{"x":11,"func":"door","y":9,"linkword":"","name":""},{"link":17,"y":6,"func":"c9","name":"","linkword":"linkloop","x":13},{"link":5,"y":6,"func":"c8","name":"","linkword":"linkloop","x":9},{"x":11,"func":"switch","y":4,"linkword":"","name":""},{"link":1,"y":7,"func":"c3","name":"","linkword":"linkloop","x":3},{"link":8,"y":4,"func":"c2","name":"","linkword":"linkloop","x":3},{"link":23,"y":2,"func":"c1","name":"","linkword":"linkloop","x":3},{"x":4,"func":"door","y":2,"linkword":"","name":""},{"link":11,"y":3,"func":"keypad1","name":"","linkword":"","x":4},{"link":4,"y":1,"func":"scan","name":"","linkword":"","x":4},{"x":17,"func":"door","y":2,"linkword":"","name":""},{"link":14,"y":3,"func":"keypad3","name":"","linkword":"","x":17},{"x":19,"func":"rexx","y":2,"linkword":"","name":""},{"link":18,"y":4,"func":"c5","name":"","linkword":"linkloop","x":19},{"link":19,"y":7,"func":"c6","name":"","linkword":"linkloop","x":19},{"link":10,"y":10,"func":"c7","name":"firewall","linkword":"linkloop","x":19},{"link":19,"y":12,"func":"switch","name":"","linkword":"","x":19},{"link":22,"y":10,"func":"keypad4","name":"","linkword":"","x":17},{"x":17,"func":"door","y":11,"linkword":"","name":""},{"link":9,"y":11,"func":"cx","name":"","linkword":"linkloop","x":15},{"link":25,"y":12,"func":"scan","name":"","linkword":"","x":14},{"x":13,"func":"door","y":12,"linkword":"","name":""}]} \ No newline at end of file +{"neut":{"y":1,"x":5},"map":"210261616161616161616161812261616161E1614161C2C081C0C0C0C0C0C0C0C0C0E0C081C0C0622161E04384C0C0C043C0C0C043C0C0C0848201612102616161C0C061610281026161C0C0616161612161C2C0C0C0C061E2C0C0C0A261C0C0C0C0E2612161E003C0C0C061C0C0C0C08261C0C0C003E06121026161C0C0C061E08282E2E061C0C0C06161612161C2C0C0C0C06103C0C0C02361C0C0C0C0C2614161E003C0C0C0616102C1026161C0C0C003E06121026184C0C0C0C043C043C063C0C0C0846161612161E081C0C0C0C0C0C0C0C0C0C0C0C081C083612161612261816161616161616161616161616161","tickword":"","jaye":{"y":2,"x":6},"gord-following":true,"moveword":"","objects":[{"link":6,"x":3,"y":10,"linkword":"linkloop","name":"","func":"c4"},{"link":3,"x":5,"y":10,"linkword":"","name":"","func":"keypad2"},{"x":5,"func":"door","name":"","linkword":"","y":11},{"x":11,"func":"door","name":"","linkword":"","y":9},{"link":17,"x":13,"y":6,"linkword":"linkloop","name":"","func":"c9"},{"link":5,"x":9,"y":6,"linkword":"linkloop","name":"","func":"c8"},{"x":11,"link":23,"func":"switch","name":"","linkword":"","y":4},{"link":1,"x":3,"y":7,"linkword":"linkloop","name":"","func":"c3"},{"link":8,"x":3,"y":4,"linkword":"linkloop","name":"","func":"c2"},{"link":23,"x":3,"y":2,"linkword":"linkloop","name":"","func":"c1"},{"x":4,"func":"door","name":"","linkword":"","y":2},{"link":11,"x":4,"y":3,"linkword":"","name":"","func":"keypad1"},{"link":4,"x":4,"y":1,"linkword":"","name":"","func":"scan"},{"x":17,"func":"door","name":"","linkword":"","y":2},{"link":14,"x":17,"y":3,"linkword":"","name":"","func":"keypad3"},{"x":19,"func":"rexx","name":"","linkword":"","y":2},{"link":18,"x":19,"y":4,"linkword":"linkloop","name":"","func":"c5"},{"link":19,"x":19,"y":7,"linkword":"linkloop","name":"","func":"c6"},{"link":10,"x":19,"y":10,"linkword":"linkloop","name":"firewall","func":"c7"},{"link":19,"x":19,"y":12,"linkword":"","name":"","func":"switch"},{"link":22,"x":17,"y":10,"linkword":"","name":"","func":"keypad4"},{"x":17,"func":"door","name":"","linkword":"","y":11},{"link":9,"x":15,"y":11,"linkword":"linkloop","name":"","func":"cx"},{"link":25,"x":14,"y":12,"linkword":"","name":"","func":"scan"},{"x":13,"func":"door","name":"","linkword":"","y":12}]} \ No newline at end of file diff --git a/game/player.fnl b/game/player.fnl new file mode 100644 index 0000000..dd99529 --- /dev/null +++ b/game/player.fnl @@ -0,0 +1,168 @@ +(local tile (require :game.tiles)) +(local {: vm : mapw : maph : itile : controlstate} (require :game.defs)) + +(local {: walkable : neutable : debris : sittable} tile.flag-to-bit) + +(vm:word :movement-dir ; key -- dyx + (vm:case [(string.byte "I") 0xff00] + [(string.byte "J") 0x00ff] + [(string.byte "K") 0x0001] + [(string.byte "M") 0x0100] + [:else 0x0000])) + +(vm:def :yx+ ; yx yx -- yx + [:lda vm.TOP :x] + [:clc] [:adc vm.ST1 :x] + [:sta vm.ST1 :x] + [:lda vm.TOPH :x] + [:clc] [:adc vm.ST1H :x] + [:sta vm.ST1H :x] + (vm:drop)) + +(vm:var :jaye-yx 0x0a0a) +(vm:var :jaye-dir 0xff00) +(vm:var :neut-yx 0x0b08) +(vm:var :rexx-yx 0xffff) +(vm:var :gord-yx 0xffff) +(vm:var :gord-dir 0x0000) +(vm:var :gord-sitting vm.false) +(vm:var :libb-yx 0xffff) +(vm:var :libb-present vm.false) + +(vm:var :controlstate [:db controlstate.jaye]) +(vm:word :is-jaye? :controlstate :bget controlstate.jaye :=) +(vm:word :is-neut? :controlstate :bget controlstate.neut :=) +(vm:word :is-rexx? :controlstate :bget controlstate.rexx :=) +(vm:word :is-prog? :is-neut? :is-rexx? :|) +(vm:word :is-walking? :movable-player-flag walkable :=) +(vm:word :neut-hidden? :neut-yx :get 0xffff :=) +(vm:word :rexx-active? :rexx-yx :get 0xffff := :not) +(vm:word :gord-hidden? :gord-yx :get 0xffff :=) +(vm:word :gord-following? :gord-hidden? :gord-sitting :get :| :not) + +(vm:word :set-rexx ; e -- + :dup (vm:if [:get controlstate.rexx] [:drop 0xffff controlstate.neut]) + :controlstate :bset :rexx-yx :set) + +(vm:word :player-tile ; -- ptile + :controlstate :bget + (vm:case [controlstate.jaye :jaye-tile] + [controlstate.neut :neut-tile] + [controlstate.gord :gord-tile] + [controlstate.libb :libb-tile] + [:else :lit :t-rexx])) + +(vm:word :player-yx ; -- pyx + :controlstate :bget + (vm:case [controlstate.jaye :jaye-yx] + [controlstate.neut :neut-yx] + [controlstate.gord :gord-yx] + [controlstate.libb :libb-yx] + [:else :rexx-yx])) + +(vm:word :draw-player ; -- + :player-yx :dup (vm:if [:get :dup 0xffff := (vm:if [:drop] [:yx>screen :player-tile :drawtile])] [:drop])) + +(vm:word :set-player-dir ; dir -- + :is-jaye? (vm:if [:jaye-dir :set] [:drop])) + +(vm:word :movable-player-flag ; -- flag + :is-neut? (vm:if [neutable] [walkable])) + +(vm:word :move-player-to ; yx -- + :player-yx :dup :get :dup 0xffff := (vm:if [:drop] [:drawtile-at]) + :set :draw-player) + +(vm:word :transition-gord-sitting ; yx f -- + controlstate.gord :controlstate :bset + :gord-sitting :set :move-player-to + controlstate.jaye :controlstate :bset) + +(vm:word :move-rexx-trash ; yx -- f + (vm:if-and [[:dup debris :flag-at?] [:is-rexx?]] + [(itile :t-floor) :update-itile] [:drop]) + vm.false) +(vm:word :move-gord-sit ; yx -- f + (vm:if-and [[:dup sittable :flag-at?] [:is-jaye?] [:gord-following?]] + [vm.true :transition-gord-sitting vm.true] + [:move-noop])) +(vm:word :move-gord-stand ; yx -- f + (vm:if-and [[:gord-yx :get :=] [:is-jaye?] [:gord-sitting :get]] + [:jaye-yx :get vm.false :transition-gord-sitting 0 :gord-dir :set vm.true] + [vm.false])) +(vm:word :move-noop :drop vm.false) +(vm:word :handle-special-move ; yx -- f + (vm:if-or [[:dup :map-specific-move] [:dup :move-rexx-trash] [:dup :move-gord-sit] [:dup :move-gord-stand]] + [:drop vm.true] [:move-noop])) + +(vm:def :yxclip? ; yx -- f + [:block + [:lda vm.TOP :x] + [:cmp mapw] + [:bcs :clipped] + [:lda vm.TOPH :x] + [:cmp maph] + [:bcs :clipped] + [:lda 0] [:sta vm.TOP :x] [:sta vm.TOPH :x] (vm:ret) + :clipped + [:lda 0xff] [:sta vm.TOP :x] [:sta vm.TOPH :x]]) + +(vm:word :try-move-player ; dir -- + :dup :set-player-dir ; dir + :player-yx :get :yx+ ; yxnew + (vm:if-or [[:dup :yxclip?] [:dup :touch-entity] [:dup :handle-special-move] [:dup :movable-player-flag :flag-at? :not]] + [:drop :player-yx :get]) + ; always "move" so that player can visibly change direction + ; touch-entity can modify player-yx so we have to refetch + :move-player-to) + +(vm:word :jaye-tile ; ptile + :jaye-dir :get + (vm:case [0xff00 :lit :jaye-n] + [0x0100 :lit :jaye-s] + [0x00ff :lit :jaye-w] + [:else :lit :jaye-e])) + +(vm:word :gord-tile ; ptile + :gord-sitting :get + (vm:if [:lit :gord-sit] + [:gord-dir :get + (vm:case [0xff00 :lit :gord-n] + [0x0100 :lit :gord-s] + [0x00ff :lit :gord-w] + [:else :lit :gord-e])])) + +(vm:word :neut-tile :lit :neut1) ; todo: animate +(vm:word :libb-tile :lit :libb1) + +(vm:word :flag-at? ; yx flag -- f + :swap :itile-at :lookup-flags :&) + +(vm:word :toggle-player + (vm:ifchain [:is-prog?] [controlstate.jaye] + [:rexx-active?] [controlstate.rexx] + [:neut-hidden?] [controlstate.jaye] + [controlstate.neut]) :controlstate :bset) + +(vm:word :party-follow + (vm:if-and [[:is-jaye?] [:gord-following?]] + [controlstate.gord :controlstate :bset + :gord-yx :get :gord-dir :get :yx+ :move-player-to + :jaye-dir :get :gord-dir :set + controlstate.jaye :controlstate :bset])) + +(vm:word :player-key ; key -- + (vm:ifchain + [:dup (string.byte " ") :=] [:drop :toggle-player] + [:dup (string.byte "Z") :=] [:drop :trigger-sidekick] + [:movement-dir :dup] + [:player-yx :get :swap ; oldyx dir + :try-move-player + :dup :player-yx :get := (vm:if [:drop] [:party-follow :untouch-entity])] + [:drop])) + +(vm:word :full-redraw :drawmap :player-redraw) +(vm:word :player-redraw + :controlstate :bget + controlstate.count (vm:for (vm:i) :controlstate :bset :draw-player) + :controlstate :bset) diff --git a/game/portraits.json b/game/portraits.json index 376aca5..9c49cb5 100644 --- a/game/portraits.json +++ b/game/portraits.json @@ -1 +1 @@ -[{"gfx":"8080808080E0E0F0F8FC2CBCACACACAC80809CFEFFFFFFD7D5D5555D4F5DD5D5BCB8B8B8F8F8F8F8FCFCFEFE86D0D0D495D5D5E5D5D5D5D7C797D7D0AAAAAAAA808086BFFFFFFFFAEAAA2A2E3C2EAAAA80808080808183878787058F8D8D8D8FAAAAAAA7AAAAEAEAE2E8EA8AD5D5D5D58F8F8787878F8F8F9F9FBFBE808A8AAA","label":"pjaye","flags":[]},{"gfx":"00002020000000004808080800202028004040011404450144010805445420352020000808084800000000202000000020544405080144014504140140400000000202012921220122011021222A052D00000405000001011211101100040415052A222110012201222129010202000004040011101112010100000504000000","label":"pneut","flags":[]},{"gfx":"80C090808484848484848484A8A8A8A8AA8080808080D4D4D5D5F59DFDD5D5D5A8A08080808080808080808080E0F8FC95D5D5D5F595D5D4D084D4D4D4D7FFFFD58080808080AAAAAAAABAE2FAAAAAA280828880A0A0A0A1A1A1A1A195959595A0AAAAAAAFA8AAAA8AA0AAAAAAEAFFFF95858181818181808080808080879FBF","label":"pgord","flags":[]},{"gfx":"808080808080C0C0C0C0C0C0C0C0C0C0808080808080AAAAFAFAFAAAAAAAAAAA8080808080C0D0D0D0D0D0D0D0D0D0D0A0A0A0A0A0AAAAAAA8A8A8A8A8A8A8A8808080808080D5D5DFDFDFD5D5D5D5D5808080808080828282828282828282828585858585D5D5D595959595959595958080808080828A8A8A8A8A8A8A8A8A8A","label":"prexx","flags":[]},{"gfx":"808080F8F8F8F8F8F8B8B8F8F8B8B8F8808080FFFFFFFFDFDFFDFDDFDFFDFDDFF8B8B8F8F8B8B8F8F8F8F8F8F8D0D080DFFDFDDFDFFDFDDFDFFFFFFFFFAAAA80808080FFFFFFFFFEFEAFAFFEFEAFAFFE8080808FAFAFAFAFAFAFAFAFAFAFAFAFFEAFAFFEFEAFAFFEFEFFFFFFFFD5D580AFAFAFAFAFAFAFAFAFAFAFAFAFAAAA80","label":"ppady","flags":[]},{"gfx":"0080C07070303030303030303030303000AAAA7F0045001400150051005400003030707000703018187C4C7E000000000000007F007F0000007F017F0000000000D5D57F400A0028000A002000080000008A8A8B8B8B8B8B8B8B8B8B8B8B8B8B0000407F007F6030301F187F000000008B8B8B03000F0C060603030100000000","label":"pterm","flags":[]}] \ No newline at end of file +[{"gfx":"8080808080E0E0F0F8FC2CBCACACACAC80809CFEFFFFFFD7D5D5555D4F5DD5D5BCB8B8B8F8F8F8F8FCFCFEFE86D0D0D495D5D5E5D5D5D5D7C797D7D0AAAAAAAA808086BFFFFFFFFAEAAA2A2E3C2EAAAA80808080808183878787058F8D8D8D8FAAAAAAA7AAAAEAEAE2E8EA8AD5D5D5D58F8F8787878F8F8F9F9FBFBE808A8AAA","label":"pjaye","flags":[]},{"gfx":"00002020000000004808080800202028004040011404450144010805445420352020000808084800000000202000000020544405080144014504140140400000000202012921220122011021222A052D00000405000001011211101100040415052A222110012201222129010202000004040011101112010100000504000000","label":"pneut","flags":[]},{"gfx":"80C090808484848484848484A8A8A8A8AA8080808080D4D4D5D5F59DFDD5D5D5A8A08080808080808080808080E0F8FC95D5D5D5F595D5D4D084D4D4D4D7FFFFD58080808080AAAAAAAABAE2FAAAAAA280828880A0A0A0A1A1A1A1A195959595A0AAAAAAAFA8AAAA8AA0AAAAAAEAFFFF95858181818181808080808080879FBF","label":"pgord","flags":[]},{"gfx":"808080808080C0C0C0C0C0C0C0C0C0C0808080808080AAAAFAFAFAAAAAAAAAAA8080808080C0D0D0D0D0D0D0D0D0D0D0A0A0A0A0A0AAAAAAA8A8A8A8A8A8A8A8808080808080D5D5DFDFDFD5D5D5D5D5808080808080828282828282828282828585858585D5D5D595959595959595958080808080828A8A8A8A8A8A8A8A8A8A","label":"prexx","flags":[]},{"gfx":"808080F8F8F8F8F8F8B8B8F8F8B8B8F8808080FFFFFFFFDFDFFDFDDFDFFDFDDFF8B8B8F8F8B8B8F8F8F8F8F8F8D0D080DFFDFDDFDFFDFDDFDFFFFFFFFFAAAA80808080FFFFFFFFFEFEAFAFFEFEAFAFFE8080808FAFAFAFAFAFAFAFAFAFAFAFAFFEAFAFFEFEAFAFFEFEFFFFFFFFD5D580AFAFAFAFAFAFAFAFAFAFAFAFAFAAAA80","label":"ppady","flags":[]},{"gfx":"0080C07070303030303030303030303000AAAA7F0045001400150051005400003030707000703018187C4C7E000000000000007F007F0000007F017F0000000000D5D57F400A0028000A002000080000008A8A8B8B8B8B8B8B8B8B8B8B8B8B8B0000407F007F6030301F187F000000008B8B8B03000F0C060603030100000000","label":"pterm","flags":[]},{"gfx":"80808080808080A0C0A0C0A0808088AA8080808080808185AA858285C1D0A0D0D4AA94AA94AA888080A0C0A0C0A08080AAD2A2D2A2D2A2D2C185AA858285818080A0A8D0A8A09090D581A1C1A0C2A1C280808180818080808081858285828582A1828182959291929090D5808080808085818080808084958A958A958A958480","label":"plibb","flags":[]}] \ No newline at end of file diff --git a/game/tiles.json b/game/tiles.json index 6140dbc..706e37b 100644 --- a/game/tiles.json +++ b/game/tiles.json @@ -1 +1 @@ -[{"gfx":"7F7F1F03090923436943230909031F7F7F7F784111104542174245101141787F","word":"","label":"neut1","flags":[]},{"gfx":"7F1F03090923436943230909031F7F7F7F784111104542174245101141787F7F","word":"","label":"neut2","flags":[]},{"gfx":"808080C0C0C0E0C0D0C8C04040404080808083058585828A9282820A08081980","word":"","label":"jaye-e","flags":[]},{"gfx":"8080C020A0A0C0C0D0C8C0501010188080808183838782828A8A920202020380","word":"","label":"jaye-w","flags":[]},{"gfx":"8080E030B0B098C0D0D0C840404060808080870D8D8D99828A8A920202020780","word":"","label":"jaye-s","flags":[]},{"gfx":"8080C0E0E0E0B0C0D0C8C040404060808080838787878D828A92820202020780","word":"","label":"jaye-n","flags":[]},{"gfx":"80808C8080808080B08080808C808080808C80808083B0808080808080868080","word":"","label":"t-floor","flags":{"walkable":true}},{"gfx":"007C0C0C0C0C7C007C7E7EAA88888800001F181818181F001F0F979584848400","word":"term","label":"termoff","flags":[]},{"gfx":"007C2C0C0C2C7C007C7E7EAA88888800001F18191C191F001F0F979584848400","word":"term","label":"termon","flags":{"neutable":true}},{"gfx":"D5D5D5D5D5D5D5D5D5D5D5D5D5D5D5D5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","word":"","label":"","flags":[]},{"gfx":"D5D5D5D5D5F5F5FDDDD5D5D5D5D5D5D5AAAAAAAAAEAEBFBFBFABAAAAAAAAAAAA","word":"","label":"","flags":[]},{"gfx":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","word":"","label":"","flags":{"neutable":true}},{"gfx":"FF8FA7B3B3B3B3B3B3B3B3B3B3B383FFFFF8F2E6E6E6E6E6E6E6E6E6E6E6E0FF","word":"door","label":"doorclosed","flags":[]},{"gfx":"FF8F87838383838383838383838383FFFFF8F0E0E0E0E0E0E0E0E0E0E0E0E0FF","word":"door","label":"dooropen","flags":{"walkable":true}},{"gfx":"FFFFCFCFCFCF898183838787878FFFFFFFFCE4E4E4E4E0E0E0E0E0E0F0F8FFFF","word":"switch","label":"switchoff","flags":{"neutable":true}},{"gfx":"FFFFCFCFCFCF898123232727878FFFFFFFFCE4E4E4E0E0616565656571F8FFFF","word":"switch","label":"switchon","flags":{"neutable":true}},{"gfx":"FFFF83D3D3D3D3D3D3D3D3D3D383FFFFFFFFC0CACACECACBCACACACACAC0FFFF","word":"","label":"","flags":[]},{"gfx":"FFFFAFEBFBFBFBBBBBFBFBFBEBAFFFFFFFFFF5D7DFDFDFDDDDDFDFDFD7F5FFFF","word":"scan","label":"scanoff","flags":{"neutable":true}},{"gfx":"FFFF2F2B2B2B6B6B6B6B2B2B2B2FFFFFFFFF755555555757575755555575FFFF","word":"scan","label":"scanon","flags":{"neutable":true}},{"gfx":"FFF3C78FBFFCF98187BFFFFFBF9F9FC7FFCFE1F1FCFCF8FEFEFCF9F0E6CE8F9F","word":"","label":"","flags":[]},{"gfx":"80808C80808080A8AAAAAAA888888880808C8080808380859595958584848480","word":"","label":"","flags":[]},{"gfx":"80808C8080A0A0A8AAAA8AA0A8808080808C8081919090848594959585858080","word":"","label":"broken-table","flags":{"debris":true}},{"gfx":"00005054545450404054545010383800000C0A2A2A2A0A03032A2A0A081C1C00","word":"","label":"t-chair","flags":{"sittable":true}},{"gfx":"0000001C1C10545040606010545454000030070702020A0A0100020A080A0200","word":"","label":"","flags":{"debris":true}},{"gfx":"80A0A8AA92D2D2AAC2C2AA92D2AA808080959595949494959494959494858080","word":"","label":"","flags":[]},{"gfx":"80808C808080A8C292AAAAAAAA8AC0D0808C80808083959290959194948580A8","word":"","label":"","flags":{"debris":true}},{"gfx":"80806008282A0800202880A8A8A8A08080980000141501051511819595958580","word":"","label":"","flags":[]},{"gfx":"80808C808080A0A8AAAA8AA2AAAAAA80808C0000000330010105051511010514","word":"","label":"","flags":{"debris":true}},{"gfx":"80D0D0D0C0D4C4C4CECAC0E0A0808080808A8B8A82AAA2A2F2D2828785808080","word":"rexx","label":"t-rexx","flags":[]},{"gfx":"F8989898BE8686868686BEB098F880809F989898FCE0E0E0E0E0FC8C989F8080","word":"rexx","label":"t-rexxstop","flags":[]},{"gfx":"80808C8088A8A8E0E0F0C8C0CCC08080808C80808080B08183838282829A8080","word":"","label":"gord-ground","flags":[]},{"gfx":"808080A0A080F0F0F0E8D0D09098808080808081818083838385828282868080","word":"","label":"gord-s","flags":[]},{"gfx":"80C09090A080F0F0F0F0D0D09098808080808282818083838383828282868080","word":"","label":"gord-n","flags":[]},{"gfx":"808080A0A080F0F0F0F0D0D090B0808080808181818081838581808282868080","word":"","label":"gord-e","flags":[]},{"gfx":"8080A0A0A080E0F0E8E0D0D09098808080808081818083838383828282838080","word":"","label":"gord-w","flags":[]},{"gfx":"0088A8A8047470F8B8D4D4C4C4E40600000C0A2A2A2A0A81812A2A0A081C1C00","word":"","label":"gord-sit","flags":[]},{"gfx":"FF81F9B9E9B9E9B9E9B9E9B9F9F981FFFFE0E7E7E5E7E5E7E5E7E5E7E7E7E0FF","word":"keypad","label":"t-keyoff","flags":[]},{"gfx":"7F01793969396939693969397979017F7F60676765676567656765676767607F","word":"keypad","label":"t-keyon","flags":[]}] \ No newline at end of file +[{"gfx":"7F7F1F03090923436943230909031F7F7F7F784111104542174245101141787F","word":"","label":"neut1","flags":[]},{"gfx":"7F1F03090923436943230909031F7F7F7F784111104542174245101141787F7F","word":"","label":"neut2","flags":[]},{"gfx":"808080C0C0C0E0C0D0C8C04040404080808083058585828A9282820A08081980","word":"","label":"jaye-e","flags":[]},{"gfx":"8080C020A0A0C0C0D0C8C0501010188080808183838782828A8A920202020380","word":"","label":"jaye-w","flags":[]},{"gfx":"8080E030B0B098C0D0D0C840404060808080870D8D8D99828A8A920202020780","word":"","label":"jaye-s","flags":[]},{"gfx":"8080C0E0E0E0B0C0D0C8C040404060808080838787878D828A92820202020780","word":"","label":"jaye-n","flags":[]},{"gfx":"80808C8080808080B08080808C808080808C80808083B0808080808080868080","word":"","label":"t-floor","flags":{"walkable":true}},{"gfx":"007C0C0C0C0C7C007C7E7EAA88888800001F181818181F001F0F979584848400","word":"term","label":"termoff","flags":[]},{"gfx":"007C2C0C0C2C7C007C7E7EAA88888800001F18191C191F001F0F979584848400","word":"term","label":"termon","flags":{"neutable":true}},{"gfx":"D5D5D5D5D5D5D5D5D5D5D5D5D5D5D5D5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","word":"","label":"","flags":[]},{"gfx":"D5D5D5D5D5F5F5FDDDD5D5D5D5D5D5D5AAAAAAAAAEAEBFBFBFABAAAAAAAAAAAA","word":"","label":"","flags":[]},{"gfx":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","word":"","label":"","flags":{"neutable":true}},{"gfx":"FF8FA7B3B3B3B3B3B3B3B3B3B3B383FFFFF8F2E6E6E6E6E6E6E6E6E6E6E6E0FF","word":"door","label":"doorclosed","flags":[]},{"gfx":"FF8F87838383838383838383838383FFFFF8F0E0E0E0E0E0E0E0E0E0E0E0E0FF","word":"door","label":"dooropen","flags":{"walkable":true}},{"gfx":"FFFFCFCFCFCF898183838787878FFFFFFFFCE4E4E4E4E0E0E0E0E0E0F0F8FFFF","word":"switch","label":"switchoff","flags":{"neutable":true}},{"gfx":"FFFFCFCFCFCF898123232727878FFFFFFFFCE4E4E4E0E0616565656571F8FFFF","word":"switch","label":"switchon","flags":{"neutable":true}},{"gfx":"FFFF83D3D3D3D3D3D3D3D3D3D383FFFFFFFFC0CACACECACBCACACACACAC0FFFF","word":"","label":"","flags":[]},{"gfx":"FFFFAFEBFBFBFBBBBBFBFBFBEBAFFFFFFFFFF5D7DFDFDFDDDDDFDFDFD7F5FFFF","word":"scan","label":"scanoff","flags":{"neutable":true}},{"gfx":"FFFF2F2B2B2B6B6B6B6B2B2B2B2FFFFFFFFF755555555757575755555575FFFF","word":"scan","label":"scanon","flags":{"neutable":true}},{"gfx":"FFF3C78FBFFCF98187BFFFFFBF9F9FC7FFCFE1F1FCFCF8FEFEFCF9F0E6CE8F9F","word":"","label":"","flags":[]},{"gfx":"80808C80808080A8AAAAAAA888888880808C8080808380859595958584848480","word":"","label":"","flags":[]},{"gfx":"80808C8080A0A0A8AAAA8AA0A8808080808C8081919090848594959585858080","word":"","label":"broken-table","flags":{"debris":true}},{"gfx":"00005054545450404054545010383800000C0A2A2A2A0A03032A2A0A081C1C00","word":"","label":"t-chair","flags":{"sittable":true}},{"gfx":"0000001C1C10545040606010545454000030070702020A0A0100020A080A0200","word":"","label":"","flags":{"debris":true}},{"gfx":"80A0A8AA92D2D2AAC2C2AA92D2AA808080959595949494959494959494858080","word":"","label":"","flags":[]},{"gfx":"80808C808080A8C292AAAAAAAA8AC0D0808C80808083959290959194948580A8","word":"","label":"","flags":{"debris":true}},{"gfx":"80806008282A0800202880A8A8A8A08080980000141501051511819595958580","word":"","label":"","flags":[]},{"gfx":"80808C808080A0A8AAAA8AA2AAAAAA80808C0000000330010105051511010514","word":"","label":"","flags":{"debris":true}},{"gfx":"80D0D0D0C0D4C4C4CECAC0E0A0808080808A8B8A82AAA2A2F2D2828785808080","word":"rexx","label":"t-rexx","flags":[]},{"gfx":"F8989898BE8686868686BEB098F880809F989898FCE0E0E0E0E0FC8C989F8080","word":"rexx","label":"t-rexxstop","flags":[]},{"gfx":"80808C8088A8A8E0E0F0C8C0CCC08080808C80808080B08183838282829A8080","word":"","label":"gord-ground","flags":[]},{"gfx":"808080A0A080F0F0F0E8D0D09098808080808081818083838385828282868080","word":"","label":"gord-s","flags":[]},{"gfx":"80C09090A080F0F0F0F0D0D09098808080808282818083838383828282868080","word":"","label":"gord-n","flags":[]},{"gfx":"808080A0A080F0F0F0F0D0D090B0808080808181818081838581808282868080","word":"","label":"gord-e","flags":[]},{"gfx":"8080A0A0A080E0F0E8E0D0D09098808080808081818083838383828282838080","word":"","label":"gord-w","flags":[]},{"gfx":"0088A8A8047470F8B8D4D4C4C4E40600000C0A2A2A2A0A81812A2A0A081C1C00","word":"","label":"gord-sit","flags":[]},{"gfx":"FF81F9B9E9B9E9B9E9B9E9B9F9F981FFFFE0E7E7E5E7E5E7E5E7E5E7E7E7E0FF","word":"keypad","label":"t-keyoff","flags":[]},{"gfx":"7F01793969396939693969397979017F7F60676765676567656765676767607F","word":"keypad","label":"t-keyon","flags":[]},{"gfx":"FF8FA7C7A389D189838FA7C7A78FFFFFFFF0C4928A91C0F1F2C1928A90C7FFFF","word":"","label":"libb1","flags":[]}] \ No newline at end of file