broke selection movement within song into seperate routine, preparing for input to other parts of the UI

This commit is contained in:
Nico 2022-03-02 16:18:51 +00:00
parent 20632681dd
commit 345c2f0b76
1 changed files with 25 additions and 11 deletions

View File

@ -1,5 +1,5 @@
( a blank file ) ( a blank file )
( TODO fix ugly stack effects, add bounds-checking for pattern movemenv ) ( TODO selecting within patterns + basic editing )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } %+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ } %< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } %++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
@ -52,7 +52,10 @@
&songpos $2 ( position in song table ) &songpos $2 ( position in song table )
@tracker @tracker
&selected-pattern $1 &selected-song-line $1
&selected-channel $1
&selected-col $1
&selected-pane $1 ( song pane = 00, patterns = 01 )
( program ) ( program )
@ -64,7 +67,7 @@
#0f25 .System/b DEO2 #0f25 .System/b DEO2
;module ;k-init-module/run JSR2 ;module ;k-init-module/run JSR2
;on-input .Controller/vector DEO2 ;on-input .Controller/vector DEO2
;redraw JSR2 ;redraw JSR2
BRK BRK
@ -80,22 +83,33 @@ BRK
RTN RTN
@on-input ( -> ) @on-input ( -> )
.tracker/selected-pane LDZ #00 EQU ,&song JCN
BRK
&song
;move-song-selection JSR2
BRK
( moves the cursor in the song )
@move-song-selection
.Controller/button DEI .Controller/button DEI
DUP #10 AND ,&up JCN DUP #10 AND ,&up JCN
#20 AND ,&down JCN #20 AND ,&down JCN
BRK RTN
&up &up
POP POP
.tracker/selected-pattern LDZ #00 EQU ,&end JCN .tracker/selected-song-line LDZ #00 EQU ,&end JCN ( line 0 - don't move up )
.tracker/selected-pattern LDZ #01 SUB .tracker/selected-pattern STZ .tracker/selected-song-line LDZ #01 SUB .tracker/selected-song-line STZ
,&end JMP ,&end JMP
&down &down
.tracker/selected-pattern LDZ #01 ADD #00 SWP #0004 MUL2 .kalama/module LDZ2 #0003 ( song length ) ADD2 LDA2 EQU2 ,&end JCN ( if we're off the end of the song, don't move ) .tracker/selected-song-line LDZ #01 ADD #00 SWP #0004 MUL2 ( selected song line offset )
.tracker/selected-pattern LDZ #01 ADD .tracker/selected-pattern STZ .kalama/module LDZ2 #0003 ADD2 LDA2 ( song length ) EQU2 ,&end JCN ( if we're off the end of the song, don't move )
.tracker/selected-song-line LDZ #01 ADD .tracker/selected-song-line STZ
,&end JMP ,&end JMP
&end &end
;redraw JSR2 ;redraw JSR2
BRK RTN
@draw-patterns ( addr* ) @draw-patterns ( addr* )
DUP2 DUP2
@ -112,7 +126,7 @@ BRK
RTN RTN
@get-selected-song-line-address ( -- addr* ) @get-selected-song-line-address ( -- addr* )
.tracker/selected-pattern LDZ #00 SWP #0004 MUL2 .tracker/selected-song-line LDZ #00 SWP #0004 MUL2
.kalama/module LDZ2 #0005 ADD2 ADD2 .kalama/module LDZ2 #0005 ADD2 ADD2
RTN RTN
@ -182,7 +196,7 @@ RTN
DUP #ff EQU ;&note-off JCN2 DUP #ff EQU ;&note-off JCN2
DUP #00 EQU ;&blank JCN2 DUP #00 EQU ;&blank JCN2
DUP #0c MOD ( note minus octave ) DUP #0c MOD ( note without octave )
#00 SWP #0002 MUL2 #00 SWP #0002 MUL2
;&notes ADD2 LDA2 SWP ;&notes ADD2 LDA2 SWP
#20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 ( first note character ) #20 SUB #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 ( first note character )