Compare commits

...

3 Commits

Author SHA1 Message Date
Nico b321104198 draw note stops properly 2021-05-15 15:48:38 +01:00
Nico 4750c4fce8 refactoring 2021-05-15 14:36:16 +01:00
Nico 4be183387c display octaves 2021-05-15 13:42:57 +01:00
1 changed files with 33 additions and 15 deletions

View File

@ -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
@ -162,13 +170,23 @@ RTN
( draw-note draws a byte as a note name and number on the screen )
@draw-note ( byte )
DUP #0c DIV #01 SUB STH ( stash octave )
DUP #6c LTH ,&note JCN ( if note is in range, draw note, otherwise continue to draw a rest )
#3b ;draw-char JSR2
#00 ;draw-char JSR2
#3d ;draw-char JSR2 ( draws "[ ]" )
POPr ( remove octave from returnstack )
POP
RTN
&note
#0c MOD #00 SWP ;notes ADD2 LDA DUP #7f AND ;draw-char JSR2
#80 AND ,&else JCN ( if the high bit is unset )
#0d ;draw-char JSR2 ( draw a dash )
#00 ;draw-char JSR2 ( draw a space )
,&then JMP
&else
#03 ;draw-char JSR2 ( otherwise draw a # )
&then
STHr ;draw-nibble JSR2 ( unstash and draw octave number )
RTN
@ -319,7 +337,7 @@ RTN
52 00 20
53 00 66
54 00 66
55 00 66
ff 00 66
56 00 ff
57 00 66
]