This commit is contained in:
Jeremy Penner 2020-12-31 11:49:52 -05:00
parent d6e32d9f6a
commit 264ce5d269
5 changed files with 80 additions and 5 deletions

64
game/bosskey.fnl Normal file
View file

@ -0,0 +1,64 @@
(local util (require :lib.util))
(local {: vm : prg : astr : style} (util.require :game.defs))
(vm:word :boss-key :textmode :page2 (vm:until :read-key) :hires :page1)
; if we upload to page 2 we don't have to worry about clobbering screen holes
(local textorg (prg:org 0x0800))
(fn padding [s w style]
(string.rep (astr " " style) (- w (length s))))
(fn pad [s w style]
(.. s (padding s w style)))
(fn rpad [s w style]
(.. (padding s w style) s))
(fn cellpad [s ?style]
(local textstyle (or ?style style.normal))
(match (type s)
:nil (pad "" 9 textstyle)
:string (pad (astr s textstyle) 9 textstyle)
:number (rpad (astr (.. s " ") textstyle) 9 textstyle)
:table (cellpad (. s 1) (. s 2))))
(fn cells [r a b c d]
(.. (rpad (.. r "") 3 style.inverse)
(cellpad a) (cellpad b) (cellpad c) (cellpad d)))
(fn generate-boss-screen-lines []
[(-> (astr "A16 (L) TOTAL" style.inverse)
(pad 38 style.inverse)
(.. (astr "C!" style.inverse)))
(.. (pad "" 38 style.inverse) (astr "24"))
""
(cells "" [" A" style.inverse] [" B" style.inverse] [" C" style.inverse] [" D" style.inverse])
(cells 1 "DEFINITEL" "Y REAL WO" "RK" "")
(cells 2 "(NOT PLAY" "ING COMPU" "TER GAMES" ")")
(cells 3)
(cells 4 "" "HAMMERS" "BILLS" "SANDWICH")
(cells 5 "JANUARY" 23 "$1" "CLUB")
(cells 6 "FEBRUARY" 121 "$2" "REUBEN")
(cells 7 "MARCH" 38 "$5" "BLT")
(cells 8 "SMARCH" 97 "$10" "HOT DOG")
(cells 9 "APRIL" 555 "$20" "I SAID IT")
(cells 10 "WEDNESDAY" 246 "$50" "EGG SALAD")
(cells 11 "KEYCODE" 1337 2757 9876)
(cells 12 "NUMBERS" 12345 "$100" "IF I HAD")
(cells 13 "LETTERS" "MARMOTS" "BENJAMIN" "100 I'D")
(cells 14 "SYMBOLS" "^!@#%&?" "$$$$$" "EAT THEM")
(cells 15)
(cells 16 ["TOTAL" style.inverse] "TOO MANY" ["* MAGIC *" style.flashing] "ALL@ONCE")
(cells 17) (cells 18) (cells 19) (cells 20)])
(fn splice [bytes offset str]
(.. (bytes:sub 1 offset)
str
(bytes:sub (+ (length str) offset 1))))
(fn bytes-from-lines [lines]
(var bytes (string.rep (astr " ") 0x400))
(each [y line (ipairs lines)]
(local offset (+ (* (math.floor (/ (- y 1) 8)) 0x28)
(* (% (- y 1) 8) 0x80)))
(set bytes (splice bytes offset line)))
bytes)
(textorg:append [:bytes (bytes-from-lines (generate-boss-screen-lines))])

View file

@ -34,11 +34,17 @@
:count 5 :count 5
}) })
(fn achar [c] (bit.bor (string.byte c) 0x80)) (local style {
(fn astr [s] :normal 0x80
:inverse 0x00
:flashing 0x40
})
(fn str-with-style [s stylebits]
(-> [(string.byte s 1 -1)] (-> [(string.byte s 1 -1)]
(lume.map #(bit.bor $1 0x80)) (lume.map #(bit.bor (bit.band $1 0x3f) stylebits))
(-> (table.unpack) (string.char)))) (-> (table.unpack) (string.char))))
(fn achar [c] (bit.bor (string.byte c) style.normal))
(fn astr [s ?style] (str-with-style s (or ?style style.normal)))
(fn rot8l [n] ; clears carry (fn rot8l [n] ; clears carry
(local block [:block [:clc]]) (local block [:block [:clc]])
@ -118,5 +124,5 @@
(let [tilelist (tiles.loadgfx tiles.fn-tiles)] (let [tilelist (tiles.loadgfx tiles.fn-tiles)]
(fn [label] (tiles.find-itile tilelist label)))) (fn [label] (tiles.find-itile tilelist label))))
{: vm : prg : mapw : maph : mon : org : achar : astr : rot8l : deflevel : say : say-runon : itile : controlstate} {: vm : prg : mapw : maph : mon : org : achar : astr : style : rot8l : deflevel : say : say-runon : itile : controlstate}

View file

@ -8,6 +8,9 @@
[:sta :0xc052]) [:sta :0xc052])
(vm:def :mixed [:sta :0xc053]) (vm:def :mixed [:sta :0xc053])
(vm:def :textmode [:sta :0xc051])
(vm:def :page1 [:sta :0xc054])
(vm:def :page2 [:sta :0xc055])
; starting address: ; starting address:
; 0x2000 + (x*2) + (y%4 * 0x100) + ((y/4) * 0x28) ; 0x2000 + (x*2) + (y%4 * 0x100) + ((y/4) * 0x28)

View file

@ -8,6 +8,7 @@
(util.reload :game.map) (util.reload :game.map)
(util.reload :game.entity) (util.reload :game.entity)
(util.reload :game.player) (util.reload :game.player)
(util.reload :game.bosskey)
(tile.appendtiles org.tiles) (tile.appendtiles org.tiles)
(tile.appendgfx org.font (tile.loadgfx tile.fn-font)) (tile.appendgfx org.font (tile.loadgfx tile.fn-font))

View file

@ -157,6 +157,7 @@
(vm:ifchain (vm:ifchain
[:dup (string.byte " ") :=] [:drop :toggle-player] [:dup (string.byte " ") :=] [:drop :toggle-player]
[:dup (string.byte "Z") :=] [:drop :trigger-sidekick] [:dup (string.byte "Z") :=] [:drop :trigger-sidekick]
[:dup 2 :=] [:drop :boss-key]
[:movement-dir :dup] [:movement-dir :dup]
[:player-yx :get :swap ; oldyx dir [:player-yx :get :swap ; oldyx dir
:try-move-player :try-move-player