From 60b0f24e46d603a3a9dc2853c9af48c5eff1527f Mon Sep 17 00:00:00 2001 From: Nihilazo Date: Wed, 12 May 2021 21:11:43 +0100 Subject: [PATCH] add basic editing features --- main.usm | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/main.usm b/main.usm index 42b819e..1e414cf 100644 --- a/main.usm +++ b/main.usm @@ -74,29 +74,48 @@ #08 .Edit/selection-y STZ BRK -@on-button ( -> ) - .Controller/button DEI ( get button ) +@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 + +@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 DUP #40 AND ,&left JCN #80 AND ,&right JCN - BRK ( if none are pressed, break ) + RTN ( if none are pressed, break ) &up #00 .Edit/selection-y LDZ EQU ,&end JCN .Edit/selection-y LDZ #01 SUB .Edit/selection-y STZ - BRK + RTN &down PTN_LEN #01 SUB .Edit/selection-y LDZ EQU ,&end JCN .Edit/selection-y LDZ #01 ADD .Edit/selection-y STZ - BRK + RTN &left #00 .Edit/selection-x LDZ EQU ,&end JCN .Edit/selection-x LDZ #01 SUB .Edit/selection-x STZ - BRK + RTN &right PTN_WIDTH #01 SUB .Edit/selection-x LDZ EQU ,&end JCN .Edit/selection-x LDZ #01 ADD .Edit/selection-x STZ &end +RTN + +@on-button ( -> ) + .Controller/key DEI + DUP #2b EQU ,&plus JCN + DUP #2d EQU ,&minus JCN + .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 @on-frame ( -> )