Locate entire game sequentially in memory (except boss key)

This commit is contained in:
Jeremy Penner 2021-01-07 20:14:51 -05:00
parent 19691a2d09
commit 7baf9ffeaf
8 changed files with 17 additions and 13 deletions

View file

@ -204,9 +204,13 @@
(error (.. op.opcode " doesn't support mode " op.mode)))) (error (.. op.opcode " doesn't support mode " op.mode))))
"")) ""))
(fn pdat-processor.var.bytes [d env] (fn pdat-processor.var.bytes [d env]
(local init (match (type d.init)
:number d.init
:nil 0
:function (d.init env)))
(match d.size (match d.size
1 (int8-to-bytes (or d.init 0)) 1 (int8-to-bytes init)
2 (int16-to-bytes (or d.init 0)) 2 (int16-to-bytes init)
n (string.rep "\0" n))) n (string.rep "\0" n)))
(fn pdat-processor.ref.bytes [ref env] (fn pdat-processor.ref.bytes [ref env]
(int16-to-bytes (env:lookup-addr ref.target))) (int16-to-bytes (env:lookup-addr ref.target)))

View file

@ -54,7 +54,7 @@
block)) block))
(fn mk-vm [prg options] (fn mk-vm [prg options]
(local code1 (prg:org 0xc00)) (local code1 (prg:org 0x4000))
(install-vm-parser prg) (install-vm-parser prg)
(local vm { (local vm {
:IP :0x60 :IP :0x60

View file

@ -17,9 +17,7 @@
}) })
(local org { (local org {
:tiles (prg:org 0x4000) ; :level (prg:org 0x5100)
:font (prg:org 0x4f00)
:level (prg:org 0x5100)
:code vm.code :code vm.code
}) })
@ -116,7 +114,7 @@
(fn deflevel [mapfile label] (fn deflevel [mapfile label]
(local level prg) ; todo: (asm.new prg) - if we want to load levels as an overlay (local level prg) ; todo: (asm.new prg) - if we want to load levels as an overlay
(local org (level:org org.level.org)) (local org level.vm.code) ; (level:org org.level.org) - if we want to give level data a stable loxation
(local map (readjson mapfile)) (local map (readjson mapfile))
(local entity (require :game.entity)) (local entity (require :game.entity))
(append-map map org label) (append-map map org label)

View file

@ -23,7 +23,7 @@
[:asl vm.TOP :x] [:rol :a] ;x2 [:asl vm.TOP :x] [:rol :a] ;x2
[:asl vm.TOP :x] [:rol :a] ;x4 [:asl vm.TOP :x] [:rol :a] ;x4
[:asl vm.TOP :x] [:rol :a] ;x8 [:asl vm.TOP :x] [:rol :a] ;x8
[:adc #(hi org.font.org)] [:adc #(hi ($1:lookup-addr :font))]
[:sta vm.TOPH :x]) [:sta vm.TOPH :x])
(vm:word :draw-char ; pscreen c -- (vm:word :draw-char ; pscreen c --

View file

@ -127,7 +127,7 @@
:<rot :drawmaprow :swap :<rot :drawmaprow :swap
:dup :not) :drop :drop :player-redraw) :dup :not) :drop :drop :player-redraw)
(vm.code:append :tilepage [:db (hi org.tiles.org)]) (vm.code:append :tilepage [:db #(hi ($1:lookup-addr :jaye-tileset))])
(vm:def :lookup-tile ; itile -- ptile (vm:def :lookup-tile ; itile -- ptile
; each tile is 32 bytes; 2^5 ; each tile is 32 bytes; 2^5
; we save some cycles by storing the indices as lllhhhhh, so we don't need to shift them' ; we save some cycles by storing the indices as lllhhhhh, so we don't need to shift them'
@ -138,7 +138,7 @@
[:tya] [:and 0xe0] [:tya] [:and 0xe0]
[:sta vm.TOP :x]) [:sta vm.TOP :x])
(vm:def :set-human-tileset (vm:def :set-human-tileset
[:lda #(hi org.tiles.org)] [:lda #(hi ($1:lookup-addr :jaye-tileset))]
[:sta :tilepage]) [:sta :tilepage])
(vm:def :set-prog-tileset (vm:def :set-prog-tileset
[:lda #(hi ($1:lookup-addr :neut-tileset))] [:lda #(hi ($1:lookup-addr :neut-tileset))]

View file

@ -9,8 +9,9 @@
(util.reload :game.entity) (util.reload :game.entity)
(util.reload :game.player) (util.reload :game.player)
(tile.appendtiles org.tiles) (tile.appendtiles org.code)
(tile.appendgfx org.font (tile.loadgfx tile.fn-font)) (org.code:append [:align 0x100] :font)
(tile.appendgfx org.code (tile.loadgfx tile.fn-font))
(util.reload :game.level1) (util.reload :game.level1)
(util.reload :game.level2) (util.reload :game.level2)

View file

@ -38,6 +38,7 @@
(fn appendtiles [org] (fn appendtiles [org]
(local tiles (loadgfx fn-tiles)) (local tiles (loadgfx fn-tiles))
(org:append [:align 0x100] :jaye-tileset)
(appendgfx org tiles) (appendgfx org tiles)
(org:append [:align 0x100] :neut-tileset) (org:append [:align 0x100] :neut-tileset)
(appendgfx org tiles :neut true) (appendgfx org tiles :neut true)