From a03c8b2865768e177d28b6ed426dbe1dc43dae68 Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Mon, 6 Sep 2021 00:19:22 -0400 Subject: [PATCH] Tiledraw rewrite for speed and size, locals bugfix --- asm/65816.fnl | 2 +- neutgs/init.fnl | 22 +++++++++++----------- ssc/init.fnl | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/asm/65816.fnl b/asm/65816.fnl index 6110ca4..65bf3f6 100644 --- a/asm/65816.fnl +++ b/asm/65816.fnl @@ -54,7 +54,7 @@ (match op (where [mvx srcbank dstbank] (= (type srcbank) :number) (= (type dstbank) :number) (= (mvx:sub 1 2) :mv)) - [:bm [srcbank dstbank]] + [:bm [dstbank srcbank]] ; encoded backwards for some reason [_ offset :s] [:sr offset] (where [_ imm] (or (= (type imm) :number) (= (type imm) :function))) [:imm imm] [_ [[addr]] :y] [:idly addr] diff --git a/neutgs/init.fnl b/neutgs/init.fnl index d184742..536d5ec 100644 --- a/neutgs/init.fnl +++ b/neutgs/init.fnl @@ -46,18 +46,16 @@ [[:lda (bit.bor (bit.lshift r 8) (bit.lshift g 4) b)] [:sta (tostring (+ addr (* icolor 2) -2))]])] (lume.concat [:block] (table.unpack writes))))]) - (fn draw-tile (tile (long addr)) + (fn draw-tile (tile addr) (asm - (lda addr) (sta [ssc.ADDR_LO]) - (lda addr 2) (sta [ssc.ADDR_HI]) - (ldy 0) (ldx 16) (clc) + (lda 16) (sta [ssc.LONG_LO]) (clc) + (lda tile) (tax) (lda addr) (tay) + (bra draw) loop - (lda (tile) :y) (sta (([ssc.ADDR_LO])) :y) (iny) (iny) - (lda (tile) :y) (sta (([ssc.ADDR_LO])) :y) (iny) (iny) - (lda (tile) :y) (sta (([ssc.ADDR_LO])) :y) (iny) (iny) - (lda (tile) :y) (sta (([ssc.ADDR_LO])) :y) (iny) (iny) - (lda [ssc.ADDR_LO]) (adc 152) (sta [ssc.ADDR_LO]) - (dex) (bne loop))) + (tya) (adc 152) (tay) + draw + (lda 7) (mvn 0 0xe1) + (dec [ssc.LONG_LO]) (bne loop))) (global word userID) @@ -68,7 +66,7 @@ (set! i (+ i 1))))) (fn draw-test-tiles () - (let (x 0 y 0 screen screen-addr) + (let (x 0 y 0 screen 0x2000) (while (< y 12) (draw-tile (ref tiles) screen) (set! x (+ x 1)) @@ -87,9 +85,11 @@ (EMStartUp 0x2000 0 0 320 0 200 userID) (GrafOn) + (ClearScreen 0) (set-palette 0 [pal]) (SetAllSCBs 0) + (wait-for-key) (draw-test-tiles) (wait-for-key) diff --git a/ssc/init.fnl b/ssc/init.fnl index 9b36f0d..ed14636 100644 --- a/ssc/init.fnl +++ b/ssc/init.fnl @@ -70,7 +70,7 @@ :word) c-setup (when opgen.setup (opgen.setup)) c-hi (when opgen.hi [(opgen.hi :lda) [:pha]]) - loc {: name :type :word} + loc {: name :type (if c-hi :word :placeholder)} _ (table.insert self.locals loc) c-lo [(opgen.lo :lda) [:pha]]] (set loc.type etype) @@ -343,7 +343,7 @@ (var stacklen 0) (for [i 1 (length self.locals)] (let [loc (. self.locals i) - size (match loc.type :word 2 :long 4 _ (error (.. "how big is this local??" (fv loc))))] + size (match loc.type :placeholder 0 :word 2 :long 4 _ (error (.. "how big is this local??" (fv loc))))] (set stacklen (+ stacklen size)) (when (or (= i name-or-index) (= loc.name name-or-index)) (set offset stacklen))))