x and y positions in zero page

This commit is contained in:
sejo 2021-07-14 11:23:42 -05:00
parent 8ccdd842c7
commit a2c7738a77
2 changed files with 43 additions and 34 deletions

View File

@ -53,6 +53,13 @@
@ptr-register-nibbles $1
@framecount $2
@pos-x-devsep 0000
@pos-y-dev $2
@pos-x-dev
&dev00 $2 &dev01 $2 ( short pos x of each column )
&dev10 $2 &dev11 $2
&dev20 $2 &dev21 $2
( temp variables )
@die-color $1
@ -87,12 +94,29 @@
( center y axis )
.Screen/height DEI2
col-height SUB2 #0002 DIV2
;pos-y-dev STA2
.pos-y-dev STZ2
.Screen/width DEI2
dev-total-width
SUB2 #0004 DIV2 ( calculate separation between devices )
;pos-x-devsep STA2
DUP2
.pos-x-devsep STZ2
( assign x positions )
( pos-x-devsep is in the stack )
STH2k
DUP2 .pos-x-dev/dev00 STZ2
DUP2 #0024 ADD2 .pos-x-dev/dev01 STZ2
DUP2 ADD2 ( 2* pos-x-devsep )
DUP2 #0044 ADD2 .pos-x-dev/dev10 STZ2
DUP2 #0068 ADD2 .pos-x-dev/dev11 STZ2
STH2r ADD2 ( 3* pos-x-devsep )
DUP2 #0088 ADD2 .pos-x-dev/dev20 STZ2
#00ac ADD2 .pos-x-dev/dev21 STZ2
( set initial values )
@ -122,8 +146,7 @@ BRK
&dev2 10 55 08 1121 77 18ff 4541 3e45 413e 4541
00
@pos-x-devsep 0000
@pos-y-dev 0020
@samples
:saw ( 0 )
@ -137,45 +160,31 @@ BRK
#01 ;update-dev JSR2
#02 ;update-dev JSR2
,draw-registers JSR
,draw-columns JSR
( inc framecount )
.framecount LDZ2 #0001 ADD2 .framecount STZ2
BRK
@draw-registers ( -- )
,&start JMP
&pos-x $2
&offset $1
&start
#00
@draw-columns ( -- )
#00
&loop
STHk ( stash but keep counter )
#00 SWP ( make short )
#0001 ADD2 ( add 1 )
;pos-x-devsep LDA2 ( load x separation )
MUL2 ( get amount of separation )
STHkr #00 SWP
dev-width MUL2 ( get amount of previous devices )
ADD2 ( calculate x )
DUP2 ,&pos-x STR2
;pos-y-dev LDA2 ( load y coordinate )
STHkr ( retrieve but keep counter )
#10 MUL STHk ( calculate, stash but keep byte offset )
;draw-bytes JSR2
,&pos-x LDR2
col-sep ADD2 ( add separation to x )
;pos-y-dev LDA2 ( load y coordinate )
STHr ( retrieve offset )
#08 ADD
;draw-bytes JSR2
STHr #01 ADD DUP ( retrieve and increment counter )
#03 LTH ,&loop JCN
STHk
,draw-column JSR
STHr #01 ADD DUP
#06 LTH ,&loop JCN
POP
RTN
@draw-column ( num -- )
STHk
#02 MUL ( create offset for x position )
.pos-x-dev ADD LDZ2
.pos-y-dev LDZ2
STHr #08 MUL ( calculate pointer offset )
;draw-bytes JSR2
RTN
@update-dev ( devnum -- )
( transform devnum to offsets )
DUP #01 ADD .offset STZ

Binary file not shown.