commit a15a2c15b83695d0bcfc2926765f45f5ae9c1dd3
parent b05209ea0c8669e46b23037ef3f6bb69e8c897e1
Author: Luxferre <lux@ferre>
Date: Fri, 29 Jul 2022 23:42:27 +0300
started sprite output debugging
Diffstat:
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/tal-lib/esop-lib.tal b/tal-lib/esop-lib.tal
@@ -56,9 +56,11 @@
( decrement )
%DEC { #01 SUB }
-( get the bit of a specific number )
+( get the bit or the nibble of a specific number )
( val bitnum -- bit )
%GETBIT { SFT #01 AND }
( val* bitnum -- bit )
%GETBIT2 { SFT2 #0001 AND2 NIP }
+( val* nibnum -- nibble )
+%GETNIBBLE { #20 SFT SFT2 #000f AND2 NIP }
diff --git a/tal-lib/font.tal b/tal-lib/font.tal
@@ -6,7 +6,7 @@
BRK
@on-frame
- #0b ;line4 JSR2
+ LIT 'O ;drawc JSR2
;&adv KP-A JMPKEY
;&back KP-B JMPKEY
BRK
@@ -21,8 +21,8 @@ BRK
( sprite and text drawing routines )
-( subtract #20 from the ASCII code and you get the offset from the nanofont label )
-%CHAR-TO-NF { #20 SUB ;nanofont ADD }
+( subtract #20 from the ASCII code and get the absolute offset from the nanofont label )
+%CHAR-TO-NF { #20 SUB BTS ;nanofont ADD2 }
( 4x1 scanline output from the nibble )
( x y nibble -- x y )
@@ -46,15 +46,37 @@ BRK
JMP2r
( 4x4 sprite output from the memory )
-( addr* x y -- )
+( x y addr* -- x y )
@sprite4
( get sprite contents )
- SWP2 LDA2 ( x y sprval* -- )
-
+ LDA2 ( x y sprval* -- )
+ SWP2 OVR2 ( sprval* x y sprval* -- )
+ #04 ( sprval* x y sprval* counter -- )
+ &lp
+ DEC ( first effective counter value is 3 )
+ DUP SWP2 ROT ( sprval* x y counter sprval* counter -- )
+ GETNIBBLE ( sprval* x y counter nibble -- )
+ SWP ( sprval* x y nibble counter -- )
+ DBGBYTE
+ STH ( sprval* x y nibble -- ) ( stash counter into return stack )
+ ;line4 JSR2 ( sprval* x y -- )
+ INC ( increment y coord )
+ STHr ( sprval* x y counter -- ) ( restore counter from return stack )
+ DBGBYTE
+ DUP ,&lp JCN
+ POP SWP2 POP2 ( sprval* x y counter -- x y )
+ #04 SUB ( restore y coord )
JMP2r
+( nanofont character sprite output )
+( x y char -- x y )
+@drawc
+ CHAR-TO-NF DBGSHORT ;sprite4 JSR2
+ JMP2r
+( same as drawc but auto increment x coord )
@putc
-
+ ;drawc JSR2
+ SWP #04 ADD SWP
JMP2r
@draw-str ( s* -> )