2020-11-27 02:34:05 +00:00
|
|
|
(local util (require :lib.util))
|
|
|
|
(local {: lo : hi : readjson} util)
|
2020-10-15 03:40:01 +00:00
|
|
|
(local lume (require :lib.lume))
|
2020-11-27 04:33:14 +00:00
|
|
|
(local tile (util.reload :game.tiles))
|
2020-11-27 04:46:36 +00:00
|
|
|
(local {: prg : vm : org : mapw : maph} (util.reload :game.defs))
|
|
|
|
|
2020-11-27 04:33:14 +00:00
|
|
|
(util.reload :game.gfx)
|
|
|
|
(util.reload :game.map)
|
|
|
|
(util.reload :game.entity)
|
2020-11-15 02:55:50 +00:00
|
|
|
|
2020-11-27 04:33:14 +00:00
|
|
|
(local {: walkable} tile.flag-to-bit)
|
2020-11-15 02:55:50 +00:00
|
|
|
|
|
|
|
(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 0x090a)
|
|
|
|
(vm:var :jaye-dir 0xff00)
|
|
|
|
|
|
|
|
(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 :draw-jaye-yx ; yx --
|
|
|
|
:yx>screen :jaye-tile :drawtile)
|
|
|
|
|
|
|
|
(vm:word :handle-key :read-key :move-jaye)
|
2020-11-27 02:34:05 +00:00
|
|
|
(vm:word :bump-jaye ; dir yx --
|
|
|
|
:yx+ ; yxnew
|
2020-11-24 04:41:00 +00:00
|
|
|
:dup :touch-entity :not
|
2020-11-27 02:34:05 +00:00
|
|
|
(vm:if
|
|
|
|
[:dup :itile-at :lookup-flags ; yxnew flags
|
|
|
|
walkable :& (vm:if [:move-player-to] [:drop])]
|
|
|
|
[:drop]))
|
|
|
|
|
|
|
|
(vm:word :move-player-to ; yx --
|
|
|
|
:jaye-yx :get :drawtile-at
|
|
|
|
:dup :jaye-yx :set
|
|
|
|
:yx>screen :jaye-tile :drawtile)
|
|
|
|
|
|
|
|
(vm:word :move-player ; --
|
|
|
|
:jaye-dir :get :jaye-yx :get :yx+ :move-player-to)
|
2020-11-16 16:09:14 +00:00
|
|
|
|
2020-11-15 02:55:50 +00:00
|
|
|
(vm:word :move-jaye ; key --
|
|
|
|
:movement-dir :dup (vm:if [
|
|
|
|
:dup :jaye-dir :set ; dir
|
|
|
|
:jaye-yx :get ; dir yx
|
2020-11-27 02:34:05 +00:00
|
|
|
:bump-jaye
|
2020-11-15 02:55:50 +00:00
|
|
|
] [:drop]))
|
|
|
|
|
2020-11-22 19:24:46 +00:00
|
|
|
(vm:word :full-redraw :drawmap :object-redraw)
|
|
|
|
(vm:word :object-redraw :jaye-yx :get :draw-jaye-yx)
|
2020-11-22 03:50:11 +00:00
|
|
|
|
2020-11-23 00:44:56 +00:00
|
|
|
(vm:def :draw-pchar ; pscreen pchar --
|
|
|
|
[:block
|
|
|
|
[:ldy 7] [:clc]
|
|
|
|
:loop
|
|
|
|
[:lda [vm.TOP :x]]
|
|
|
|
[:sta [vm.ST1 :x]]
|
|
|
|
[:inc vm.TOP :x]
|
|
|
|
[:lda vm.ST1H :x] [:adc 4] [:sta vm.ST1H :x]
|
|
|
|
[:dey]
|
|
|
|
[:bne :loop]
|
|
|
|
]
|
|
|
|
(vm:drop) (vm:drop))
|
|
|
|
|
|
|
|
(vm:def :lookup-pchar ; c -- pchar
|
|
|
|
[:sec]
|
|
|
|
[:lda vm.TOP :x]
|
|
|
|
[:sbc 0x20]
|
|
|
|
[:sta vm.TOP :x]
|
|
|
|
[:lda 0]
|
|
|
|
[:asl vm.TOP :x] [:rol :a] ;x2
|
|
|
|
[:asl vm.TOP :x] [:rol :a] ;x4
|
|
|
|
[:asl vm.TOP :x] [:rol :a] ;x8
|
2020-11-27 04:33:14 +00:00
|
|
|
[:adc #(hi org.font.org)]
|
2020-11-23 00:44:56 +00:00
|
|
|
[:sta vm.TOPH :x])
|
|
|
|
|
|
|
|
(vm:word :draw-char ; pscreen c --
|
|
|
|
:lookup-pchar :draw-pchar)
|
|
|
|
|
2020-11-23 03:13:16 +00:00
|
|
|
(vm:word :snooze (vm:for))
|
|
|
|
(vm:word :textsnooze 0x40 :snooze)
|
|
|
|
(vm:word :draw-text1 0x2257 :draw-text)
|
|
|
|
(vm:word :draw-text2 0x22d7 :draw-text)
|
|
|
|
(vm:word :draw-text3 0x2357 :draw-text)
|
|
|
|
(vm:word :draw-text4 0x23d7 :draw-text)
|
|
|
|
(vm:word :draw-text ; st pscreen --
|
|
|
|
(vm:while [:over :bget :dup] ; st pscreen c
|
2020-11-23 00:44:56 +00:00
|
|
|
:over :swap :draw-char ; st pscreen
|
2020-11-23 03:13:16 +00:00
|
|
|
:textsnooze
|
2020-11-23 00:44:56 +00:00
|
|
|
:inc :swap :inc :swap)
|
2020-11-23 03:13:16 +00:00
|
|
|
:drop :drop :drop)
|
|
|
|
(vm:word :cleartext
|
|
|
|
0x2257 :clearline 0x22d7 :clearline 0x2357 :clearline 0x23d7 :clearline)
|
|
|
|
|
|
|
|
(vm:word :wait-for-return (vm:until :read-key (string.byte "\r") :=))
|
|
|
|
(vm:word :dismiss-dialog :wait-for-return :cleartext)
|
|
|
|
|
2020-11-27 04:33:14 +00:00
|
|
|
(tile.appendtiles org.tiles)
|
|
|
|
(tile.appendgfx org.font (tile.loadgfx tile.fn-font))
|
2020-10-15 03:40:01 +00:00
|
|
|
|
|
|
|
; thought:
|
|
|
|
; hotswap-safe debug stub at root of call stack
|
|
|
|
; but REPL debug stub should be very available as a task
|
2020-10-12 15:48:14 +00:00
|
|
|
|
2020-10-19 00:13:26 +00:00
|
|
|
; 20x12 means full map is 240 bytes - we have an extra 16 bytes at the end to mess with?
|
2020-11-23 00:44:56 +00:00
|
|
|
|
2020-11-27 04:33:14 +00:00
|
|
|
(vm.code:append :main
|
2020-10-06 03:47:25 +00:00
|
|
|
[:jsr :reset]
|
|
|
|
[:jsr :interpret]
|
2020-11-15 02:55:50 +00:00
|
|
|
[:vm :hires
|
|
|
|
:full-redraw
|
2020-10-15 03:40:01 +00:00
|
|
|
(vm:forever
|
2020-11-16 16:27:34 +00:00
|
|
|
(vm:hotswap-sync :full-redraw)
|
2020-11-17 20:35:41 +00:00
|
|
|
:interactive-eval-checkpoint
|
2020-11-16 16:27:34 +00:00
|
|
|
:handle-key
|
2020-10-15 03:40:01 +00:00
|
|
|
)
|
2020-10-06 03:47:25 +00:00
|
|
|
:quit])
|
|
|
|
|
2020-11-27 04:33:14 +00:00
|
|
|
(util.reload :game.level1)
|
|
|
|
|
2020-10-06 03:47:25 +00:00
|
|
|
(prg:assemble)
|
2020-11-02 00:39:31 +00:00
|
|
|
|