multi-patterns, found a new bug
This commit is contained in:
parent
9f6d534631
commit
5376dc505a
46
main.usm
46
main.usm
|
@ -59,7 +59,9 @@
|
|||
( speed - how many ticks we play a note every )
|
||||
#10 .Playback/speed STZ
|
||||
|
||||
#00 ;load-pattern JSR2
|
||||
#00 .Playback/pattern-index STZ
|
||||
|
||||
.Playback/pattern-index LDZ ;alloc-load-pattern JSR2
|
||||
|
||||
( display/audio init )
|
||||
;on-frame .Screen/vector DEO2
|
||||
|
@ -84,6 +86,17 @@ BRK
|
|||
.Playback/pattern-addr LDZ2 #00 .Edit/selection-x LDZ ADD2 #00 .Edit/selection-y LDZ PTN_WIDTH MUL2 ADD2
|
||||
RTN
|
||||
|
||||
@alloc-load-pattern ( index -- ) ( alloc a pattern and load it )
|
||||
STHk ( 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 ( TODO write the rest of this function )
|
||||
&load
|
||||
STHr ;load-pattern JSR2
|
||||
|
||||
RTN
|
||||
|
||||
@load-pattern ( index -- ) ( loads a pattern from the table )
|
||||
#02 MUL #00 SWP ( convert index to an actual index into the table )
|
||||
;pattern_table ADD2 ( add to the table )
|
||||
|
@ -91,6 +104,13 @@ RTN
|
|||
.Playback/pattern-addr STZ2 ( store in pattern index )
|
||||
RTN
|
||||
|
||||
@alloc-pattern ( index -- ) ( allocates a pattern 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_pointer LDA2 SWP2 STA2 ( store the current pointer in that place in the table )
|
||||
;pattern_pointer LDA2 PTN_WIDTH PTN_LEN MUL2 ADD2 ;pattern_pointer STA2 ( update the pattern pointer )
|
||||
RTN
|
||||
|
||||
@handle-cursor ( controller -- ) ( handles moving the cursor around )
|
||||
DUP #10 AND #00 NEQ ,&up JCN ( check the if the four directions are pressed )
|
||||
DUP #20 AND ,&down JCN
|
||||
|
@ -133,15 +153,30 @@ RTN
|
|||
&end
|
||||
RTN
|
||||
|
||||
@on-button ( -> )
|
||||
@on-button ( -> ) ( TODO fix stack overflow when doing directional inputs )
|
||||
.Controller/button DEI ( get button )
|
||||
;handle-cursor JSR2
|
||||
.Controller/key DEI DUP
|
||||
;handle-editing JSR2
|
||||
( play/pause )
|
||||
#70 EQU ,&pause JCN
|
||||
DUP #70 EQU ,&pause JCN
|
||||
( switching patterns. TODO bounds checking. TODO move into seperate routine )
|
||||
DUP #3e EQU ,&next JCN
|
||||
DUP #3c EQU ,&prev JCN
|
||||
BRK
|
||||
&pause
|
||||
&next
|
||||
POP
|
||||
.Playback/pattern-index LDZ #01 ADD .Playback/pattern-index STZ
|
||||
.Playback/pattern-index LDZ ;alloc-load-pattern JSR2
|
||||
BRK
|
||||
&prev
|
||||
POP
|
||||
|
||||
.Playback/pattern-index LDZ #01 SUB .Playback/pattern-index STZ
|
||||
.Playback/pattern-index LDZ ;alloc-load-pattern JSR2
|
||||
BRK
|
||||
&pause
|
||||
POP
|
||||
.Playback/playing LDZ #00 EQU .Playback/playing STZ
|
||||
BRK
|
||||
BRK
|
||||
|
@ -266,6 +301,9 @@ RTN
|
|||
|
||||
@draw
|
||||
;draw-playhead JSR2
|
||||
#0000 .Screen/x DEO2
|
||||
#0000 .Screen/y DEO2
|
||||
.Playback/pattern-index LDZ ;draw-byte JSR2
|
||||
.Draw/pattern-x LDZ2 .Screen/x DEO2
|
||||
.Draw/pattern-y LDZ2 .Screen/y DEO2
|
||||
.Playback/pattern-addr LDZ2 ;draw-pattern JSR2
|
||||
|
|
Reference in New Issue