make load-pattern more flexible
This commit is contained in:
parent
62a2d7307a
commit
730e29ac42
45
main.tal
45
main.tal
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
( a blank file )
|
( a blank file )
|
||||||
|
|
||||||
( macros )
|
( macros )
|
||||||
|
@ -41,12 +42,19 @@
|
||||||
|
|
||||||
|0000
|
|0000
|
||||||
|
|
||||||
@Playback [ &position $2 &pattern-addr $2 &tick $1 &speed $1 &playing $1 &pattern-index $1 ] ( pattern-index = 0-127 which pattern is selected from the pattern table )
|
@Playback [ &position $2 &tick $1 &speed $1 &playing $1 ]
|
||||||
|
( pattern-index = 0-127 which pattern is selected from the pattern table
|
||||||
|
pattern-addr = address of pattern currently loaded )
|
||||||
|
( pattern-index and pattern-addr HAVE to stay in the same positions relative to their channel! )
|
||||||
|
@Channel0 [ &pattern-addr $2 &pattern-index $1 ]
|
||||||
|
@Channel1 [ &pattern-addr $2 &pattern-index $1 ]
|
||||||
|
@Channel2 [ &pattern-addr $2 &pattern-index $1 ]
|
||||||
|
@Channel3 [ &pattern-addr $2 &pattern-index $1 ]
|
||||||
@Draw [ &row $1 &col $1
|
@Draw [ &row $1 &col $1
|
||||||
&pattern-x $2 &pattern-y $2
|
&pattern-x $2 &pattern-y $2
|
||||||
&pattern-vspacing $2 &pattern-hspacing $2
|
&pattern-vspacing $2 &pattern-hspacing $2
|
||||||
&playhead-x $2 &playhead-y $2 ]
|
&playhead-x $2 &playhead-y $2 ]
|
||||||
@Edit [ &selection-x $1 &selection-y $1 ]
|
@Edit [ &pattern-addr $2 &pattern-index $1 &selection-x $1 &selection-y $1 ]
|
||||||
|
|
||||||
@Pointer [ &x $2 &y $2 ]
|
@Pointer [ &x $2 &y $2 ]
|
||||||
|
|
||||||
|
@ -62,9 +70,9 @@
|
||||||
( speed - how many ticks we play a note every )
|
( speed - how many ticks we play a note every )
|
||||||
#10 .Playback/speed STZ
|
#10 .Playback/speed STZ
|
||||||
|
|
||||||
#00 .Playback/pattern-index STZ
|
#00 .Channel0/pattern-index STZ
|
||||||
|
|
||||||
.Playback/pattern-index LDZ ;alloc-load-pattern JSR2
|
.Channel0/pattern-index LDZ ;alloc-load-pattern JSR2
|
||||||
|
|
||||||
( display/audio init )
|
( display/audio init )
|
||||||
;on-frame .Screen/vector DEO2
|
;on-frame .Screen/vector DEO2
|
||||||
|
@ -89,28 +97,31 @@
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@get-selected-addr ( -- addr* ) ( get the address of the current selection in the pattern )
|
@get-selected-addr ( -- addr* ) ( get the address of the current selection in the pattern )
|
||||||
.Playback/pattern-addr LDZ2 #00 .Edit/selection-x LDZ ADD2 #00 .Edit/selection-y LDZ PTN_WIDTH MUL2 ADD2
|
.Channel0/pattern-addr LDZ2 #00 .Edit/selection-x LDZ ADD2 #00 .Edit/selection-y LDZ PTN_WIDTH MUL2 ADD2
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
|
( TODO make these relative to the channel alloc/loading to )
|
||||||
|
|
||||||
@alloc-load-pattern ( index -- ) ( alloc a pattern and load it )
|
@alloc-load-pattern ( index -- ) ( alloc a pattern and load it )
|
||||||
STHk ( leave the index number on the stack )
|
STHk ( leave the index number on the stack )
|
||||||
#02 MUL #00 SWP ( convert index into index into the table )
|
#02 MUL #00 SWP ( convert index into index into the table )
|
||||||
;pattern_table ADD2 ( get the address of it in 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 )
|
LDA2 #0000 NEQ2 ,&load JCN ( if it's not 0000, load it )
|
||||||
STHrk ;alloc-pattern JSR2 ( TODO write the rest of this function )
|
STHrk ;alloc-pattern JSR2
|
||||||
&load
|
&load
|
||||||
STHr ;load-pattern JSR2
|
STHr .Channel0/pattern-addr ;load-pattern JSR2
|
||||||
|
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
@load-pattern ( index -- ) ( loads a pattern from the table )
|
@load-pattern ( index addr -- ) ( loads a pattern from the table into zero-page address addr )
|
||||||
|
STH ( stash address )
|
||||||
#02 MUL #00 SWP ( convert index to an actual index into the table )
|
#02 MUL #00 SWP ( convert index to an actual index into the table )
|
||||||
;pattern_table ADD2 ( add to the table )
|
;pattern_table ADD2 ( add to the table )
|
||||||
LDA2 ( load the address )
|
LDA2 ( load the address )
|
||||||
.Playback/pattern-addr STZ2 ( store in pattern index )
|
STHr STZ2 ( store in addr )
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
@alloc-pattern ( index -- ) ( allocates a pattern in the table )w
|
@alloc-pattern ( index -- ) ( allocates a pattern in the table )
|
||||||
#02 MUL #00 SWP ( convert index to an index in the table )
|
#02 MUL #00 SWP ( convert index to an index in the table )
|
||||||
;pattern_table ADD2 ( get the index in the table for this pattern )
|
;pattern_table ADD2 ( get the index in the table for this pattern )
|
||||||
;pattern_pointer LDA2 SWP2 STA2 ( store the current pointer in that place in the table )
|
;pattern_pointer LDA2 SWP2 STA2 ( store the current pointer in that place in the table )
|
||||||
|
@ -212,13 +223,13 @@ RTN
|
||||||
BRK
|
BRK
|
||||||
&next
|
&next
|
||||||
POP
|
POP
|
||||||
.Playback/pattern-index LDZ #01 ADD .Playback/pattern-index STZ
|
.Channel0/pattern-index LDZ #01 ADD .Channel0/pattern-index STZ
|
||||||
.Playback/pattern-index LDZ ;alloc-load-pattern JSR2
|
.Channel0/pattern-index LDZ ;alloc-load-pattern JSR2
|
||||||
BRK
|
BRK
|
||||||
&prev
|
&prev
|
||||||
POP
|
POP
|
||||||
.Playback/pattern-index LDZ #01 SUB .Playback/pattern-index STZ
|
.Channel0/pattern-index LDZ #01 SUB .Channel0/pattern-index STZ
|
||||||
.Playback/pattern-index LDZ ;alloc-load-pattern JSR2
|
.Channel0/pattern-index LDZ ;alloc-load-pattern JSR2
|
||||||
BRK
|
BRK
|
||||||
&pause
|
&pause
|
||||||
POP
|
POP
|
||||||
|
@ -362,10 +373,10 @@ RTN
|
||||||
;draw-playhead JSR2
|
;draw-playhead JSR2
|
||||||
#0000 .Screen/x DEO2
|
#0000 .Screen/x DEO2
|
||||||
#0000 .Screen/y DEO2
|
#0000 .Screen/y DEO2
|
||||||
.Playback/pattern-index LDZ ;draw-byte JSR2
|
.Channel0/pattern-index LDZ ;draw-byte JSR2
|
||||||
.Draw/pattern-x LDZ2 .Screen/x DEO2
|
.Draw/pattern-x LDZ2 .Screen/x DEO2
|
||||||
.Draw/pattern-y LDZ2 .Screen/y DEO2
|
.Draw/pattern-y LDZ2 .Screen/y DEO2
|
||||||
.Playback/pattern-addr LDZ2 ;draw-pattern JSR2
|
.Channel0/pattern-addr LDZ2 ;draw-pattern JSR2
|
||||||
RTN
|
RTN
|
||||||
|
|
||||||
@play-line ( addr ch ) ( plays the pattern line at addr on the channel ch )
|
@play-line ( addr ch ) ( plays the pattern line at addr on the channel ch )
|
||||||
|
@ -386,7 +397,7 @@ RTN
|
||||||
PTN_LEN .Playback/position LDZ2 NEQ2 ,&continue JCN ( if we're at the end of the pattern, reset the counter )
|
PTN_LEN .Playback/position LDZ2 NEQ2 ,&continue JCN ( if we're at the end of the pattern, reset the counter )
|
||||||
#0000 .Playback/position STZ2
|
#0000 .Playback/position STZ2
|
||||||
&continue
|
&continue
|
||||||
.Playback/position LDZ2 PTN_WIDTH MUL2 .Playback/pattern-addr LDZ2 ADD2 ( put pattern line address on the stack )
|
.Playback/position LDZ2 PTN_WIDTH MUL2 .Channel0/pattern-addr LDZ2 ADD2 ( put pattern line address on the stack )
|
||||||
.Audio0 ;play-line JSR2
|
.Audio0 ;play-line JSR2
|
||||||
#0001 .Playback/position LDZ2 ADD2 .Playback/position STZ2
|
#0001 .Playback/position LDZ2 ADD2 .Playback/position STZ2
|
||||||
;draw-playhead JSR2 ( update the playhead position )
|
;draw-playhead JSR2 ( update the playhead position )
|
||||||
|
|
Reference in New Issue