make alloc-load-pattern more flexible

This commit is contained in:
Nico 2021-06-10 19:46:21 +01:00
parent 730e29ac42
commit e2a22c7789
1 changed files with 10 additions and 9 deletions

View File

@ -72,7 +72,7 @@
#00 .Channel0/pattern-index STZ
.Channel0/pattern-index LDZ ;alloc-load-pattern JSR2
.Channel0/pattern-index LDZ .Channel0/pattern-addr ;alloc-load-pattern JSR2
( display/audio init )
;on-frame .Screen/vector DEO2
@ -102,23 +102,24 @@ RTN
( TODO make these relative to the channel alloc/loading to )
@alloc-load-pattern ( index -- ) ( alloc a pattern and load it )
STHk ( leave the index number on the stack )
@alloc-load-pattern ( index addr -- ) ( alloc a pattern and load it )
STH ( stash target addr )
DUP ( leave the index number on the stack )
#02 MUL #00 SWP ( convert index into index into the table )
;pattern_table ADD2 ( get the address of it in the table )
LDA2 #0000 NEQ2 ,&load JCN ( if it's not 0000, load it )
STHrk ;alloc-pattern JSR2
DUP ;alloc-pattern JSR2
&load
STHr .Channel0/pattern-addr ;load-pattern JSR2
STHr ;load-pattern JSR2
RTN
@load-pattern ( index addr -- ) ( loads a pattern from the table into zero-page address addr )
STH ( stash address )
STH ( stash target addr )
#02 MUL #00 SWP ( convert index to an actual index into the table )
;pattern_table ADD2 ( add to the table )
LDA2 ( load the address )
STHr STZ2 ( store in addr )
STHr STZ2 ( store in target addr )
RTN
@alloc-pattern ( index -- ) ( allocates a pattern in the table )
@ -224,12 +225,12 @@ RTN
&next
POP
.Channel0/pattern-index LDZ #01 ADD .Channel0/pattern-index STZ
.Channel0/pattern-index LDZ ;alloc-load-pattern JSR2
.Channel0/pattern-index LDZ .Channel0/pattern-addr ;alloc-load-pattern JSR2
BRK
&prev
POP
.Channel0/pattern-index LDZ #01 SUB .Channel0/pattern-index STZ
.Channel0/pattern-index LDZ ;alloc-load-pattern JSR2
.Channel0/pattern-index LDZ .Channel0/pattern-addr ;alloc-load-pattern JSR2
BRK
&pause
POP