draw nibbles with offsets instead of conditionals

This commit is contained in:
sejo 2021-07-14 13:05:11 -05:00
parent 19339fd863
commit 840042c52a
2 changed files with 25 additions and 36 deletions

View File

@ -400,7 +400,7 @@ RTN
&normal-mode
#00 ( mode )
&draw
;draw-byte JSR2
,draw-byte JSR
#0010 ADD2 ( increment y )
STHr ( recover counter )
#01 ADD DUP column-size ,&offset LDR ADD NEQ ,&loop JCN
@ -422,17 +422,18 @@ RTN
STHr DUP STH ( restore, duplicate, stash byte )
#04 SFT #0f AND ( get high nibble )
,&high-nibble-mode LDR
;draw-nibble JSR2 ( draw high nibble )
,draw-nibble JSR ( draw high nibble )
SWP2 #0010 ADD2 SWP2 ( increment x )
STHr ( restore byte )
#0f AND ( get low nibble )
,&low-nibble-mode LDR
;draw-nibble JSR2 ( draw low nibble )
,draw-nibble JSR ( draw low nibble )
RTN
@draw-nibble ( x2 y2 num mode -- )
,&set-invert JCN ( check mode: 0 is normal, nonzero is inverted )
&set-normal
@ -448,50 +449,39 @@ RTN
.Screen/y DEO2
.Screen/x DEO2
STHkr
#03 SFT #01 AND ,&bit-3-on JCN
&bit-3-off
;nibble-dice-empty/tl .Screen/addr DEO2
,&bit-3-draw JMP
&bit-3-on
;nibble-dice-dot/tl .Screen/addr DEO2
&bit-3-draw
.die-color LDZ .Screen/color DEO
#03 SFT ( get bit )
;nibble-dice-empty/tl
,draw-bit JSR
( bit 2 )
STHkr
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 ( increment x )
#02 SFT #01 AND ,&bit-2-on JCN
&bit-2-off
;nibble-dice-empty/tr .Screen/addr DEO2
,&bit-2-draw JMP
&bit-2-on
;nibble-dice-dot/tr .Screen/addr DEO2
&bit-2-draw
.die-color LDZ .Screen/color DEO
#02 SFT ( get bit )
;nibble-dice-empty/tr
,draw-bit JSR
( bit 0 )
STHkr
.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 ( increment y )
#01 AND ,&bit-0-on JCN
&bit-0-off
;nibble-dice-empty/br .Screen/addr DEO2
,&bit-0-draw JMP
&bit-0-on
;nibble-dice-dot/br .Screen/addr DEO2
&bit-0-draw
.die-color LDZ .Screen/color DEO
;nibble-dice-empty/br
,draw-bit JSR
( bit 1 )
STHr
.Screen/x DEI2 #0008 SUB2 .Screen/x DEO2 ( decrement x )
#01 SFT #01 AND ,&bit-1-on JCN
&bit-1-off
;nibble-dice-empty/bl .Screen/addr DEO2
,&bit-1-draw JMP
&bit-1-on
;nibble-dice-dot/bl .Screen/addr DEO2
&bit-1-draw
.die-color LDZ .Screen/color DEO
#01 SFT ( get bit )
;nibble-dice-empty/bl
,draw-bit JSR
RTN
@draw-bit ( number empty-tile-addr -- )
STH2 ( stash address )
#01 AND ( get lsb from number )
#40 MUL #00 SWP ( convert to offset )
STH2r ( retrieve address )
ADD2 ( add offset to address )
.Screen/addr DEO2
.die-color LDZ .Screen/color DEO
RTN
( sprites )
@ -511,7 +501,6 @@ ffff ffff ffff ffff
&br fe fe fe fe fe fc f8 00 fe ce 86 86 ce fc f8 00
( samples )
( from the audio.channels.tal uxn example )

Binary file not shown.