diff --git a/main.usm b/main.usm index 92755d4..904f6d8 100644 --- a/main.usm +++ b/main.usm @@ -59,8 +59,7 @@ ( speed - how many ticks we play a note every ) #10 .Playback/speed STZ -#00 .Playback/pattern-index STZ -;load-pattern JSR2 +;pattern .Playback/pattern-addr STZ2 ( display/audio init ) ;on-frame .Screen/vector DEO2 @@ -81,28 +80,10 @@ BRK -( TODO either alloc or get-selected-addr is breaking things. Fix tomorrow. ) - -@alloc-pattern ( number -- ) ( allocates pattern n in the pattern table in a new area of memory. WILL OVERWRITE! ) - #02 MUL #00 SWP ;pattern-table ADD2 ;pattern-pointer LDA2 SWP2 STA2 ( store current position of pattern pointer in pattern table for this pattern ) - PTN_LEN PTN_WIDTH MUL2 ;pattern-pointer LDA2 ADD2 ;pattern-pointer STA2 - -RTN - @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 RTN -( loads the pattern pointed to by Playback/pattern-index. Allocs it if it doesn't exist. ) -@load-pattern ( number -- ) - .Playback/pattern-index LDZ #02 MUL #00 SWP ;pattern-table ADD2 LDA2 ( get current pattern address ) - DUP2 #0000 NEQ ,&exists JCN ( if the pattern exists, don't alloc a new one ) - .Playback/pattern-index LDZ ;alloc-pattern JSR2 - &exists - POP2 - .Playback/pattern-index LDZ #02 MUL #00 SWP ;pattern-table ADD2 LDA2 .Playback/pattern-addr STZ2 -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 @@ -151,25 +132,11 @@ RTN .Controller/key DEI DUP ;handle-editing JSR2 ( play/pause ) - DUP #70 EQU ,&pause JCN - DUP #3e EQU ,&next-pattern JCN - #3c EQU ,&prev-pattern JCN - .Playback/pattern-addr LDZ2 .Console/short DEO2 - BRK + #70 EQU ,&pause JCN + BRK &pause - POP .Playback/playing LDZ #00 EQU .Playback/playing STZ BRK - &next-pattern ( TODO bounds checking to 127 ) - POP - .Playback/pattern-index LDZ #01 ADD .Playback/pattern-index STZ - ;load-pattern JSR2 - BRK - &prev-pattern ( TODO bounds checking to 127 ) - POP - .Playback/pattern-index LDZ #01 SUB .Playback/pattern-index STZ - ;load-pattern JSR2 - BRK BRK @on-frame ( -> ) @@ -397,10 +364,6 @@ BRK @playhead_icon [ 00 60 78 7e 7e 78 60 00 ] @pointer_icon [ 80c0 e0f0 f8e0 1000 ] -@pattern-table :pattern $fe ( the pattern table is a list of pattern addresses in memory ) - -@pattern-pointer :pattern/end ( the pattern pointer is a pointer to where in memory the next pattern will be put. ) - ( pattern format - each note has 3 bytes. Pitch, instrument, volume. patterns are 0x10 long. an ff in the note column of the pattern will kill the existing note without starting a new one (this is the tracker "box" note) ) @@ -420,5 +383,5 @@ BRK 54 00 66 ff 00 66 56 00 ff - 57 00 66 &end + 57 00 66 ]