From 56c2eb1b947c682a78c5909fee6cf4285683dc51 Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Sat, 14 Nov 2020 22:54:43 -0500 Subject: [PATCH] fix redrawing map tile --- game/init.fnl | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/game/init.fnl b/game/init.fnl index 05dbd49..287076d 100644 --- a/game/init.fnl +++ b/game/init.fnl @@ -148,8 +148,29 @@ [:tya] [:and 0xe0] [:sta vm.TOP :x]) -(vm:word :drawtile-at ; xy -- - :drop) ; todo +(vm:def :itile-at ; yx -- itile + [:lda (- maph 1)] + [:sec] + [:sbc vm.TOPH :x] + [:asl :a] ; x2 + [:asl :a] ; x4 + [:sta vm.TOPH :x] + [:asl :a] ; x8 + [:asl :a] ; x16 + [:clc] [:adc vm.TOPH :x] ; x20 + [:adc vm.TOP :x] + [:sta vm.TOP :x] + [:lda #(hi ($1:lookup-addr :map))] + [:sta vm.TOPH :x] + [:lda [vm.TOP :x]] + [:sta vm.TOP :x] + [:lda 0] + [:sta vm.TOPH :x]) + +(vm:word :drawtile-at ; yx -- + :dup :yx>screen :swap + :itile-at :lookup-tile + :drawtile) (vm:def :last-key ; -- key (vm:reserve)