From 4750c4fce871625d4ab7b9848fb65a251cf4616b Mon Sep 17 00:00:00 2001 From: Nihilazo Date: Sat, 15 May 2021 14:36:16 +0100 Subject: [PATCH] refactoring --- main.usm | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/main.usm b/main.usm index e4bba97..6d9a6c9 100644 --- a/main.usm +++ b/main.usm @@ -73,7 +73,6 @@ #0007 .Draw/playhead-x STZ2 #0004 .Draw/pattern-hspacing STZ2 -#08 .Edit/selection-y STZ BRK @get-selected-addr ( -- addr* ) ( get the address of the current selection in the pattern ) @@ -104,21 +103,30 @@ RTN &end RTN -@on-button ( -> ) - .Controller/key DEI +@handle-editing ( key -- ) DUP #2b EQU ,&plus JCN - DUP #2d EQU ,&minus JCN + #2d EQU ,&minus JCN + RTN + &plus + POP ( pop the key ) + #00 .Edit/selection-x LDZ EQU ;get-selected-addr JSR2 LDA #6c EQU AND ,&end JCN ( if we're on a note and out of bounds, skip moving ) + ;get-selected-addr JSR2 DUP2 STH2 ( stash selection address and keep another copy on the stack ) + LDA #01 ADD STH2r STA + RTN + &minus + #00 .Edit/selection-x LDZ EQU ;get-selected-addr JSR2 LDA #0c EQU AND ,&end JCN ( if we're on a note and out of bounds, skip moving ) + ;get-selected-addr JSR2 DUP2 STH2 ( stash selection address and keep another copy on the stack ) + LDA #01 SUB STH2r STA + RTN + &end +RTN + +@on-button ( -> ) .Controller/button DEI ( get button ) ;handle-cursor JSR2 - BRK - &plus - ;get-selected-addr JSR2 DUP2 STH2 LDA #01 ADD STH2r STA POP2 - BRK - &minus - ;get-selected-addr JSR2 DUP2 STH2 LDA #01 SUB STH2r STA POP2 - BRK - &end - BRK + .Controller/key DEI + ;handle-editing JSR2 +BRK @on-frame ( -> ) ;draw JSR2