add play/pause

This commit is contained in:
Nico 2021-05-15 20:41:34 +01:00
parent b321104198
commit c40cf5574d
1 changed files with 18 additions and 4 deletions

View File

@ -38,7 +38,7 @@
|0000
@Playback [ &position $2 &pattern-addr $2 &tick $1 &speed $1 ]
@Playback [ &position $2 &pattern-addr $2 &tick $1 &speed $1 &playing $1 ]
@Draw [ &row $1 &col $1
&pattern-x $2 &pattern-y $2
&pattern-vspacing $2 &pattern-hspacing $2
@ -73,6 +73,8 @@
#0007 .Draw/playhead-x STZ2
#0004 .Draw/pattern-hspacing STZ2
#01 .Playback/playing STZ
BRK
@get-selected-addr ( -- addr* ) ( get the address of the current selection in the pattern )
@ -124,12 +126,20 @@ RTN
@on-button ( -> )
.Controller/button DEI ( get button )
;handle-cursor JSR2
.Controller/key DEI
.Controller/key DEI DUP
;handle-editing JSR2
( play/pause )
#70 NEQ ,&end JCN
.Playback/playing LDZ #00 EQU .Playback/playing STZ
&end
BRK
@on-frame ( -> )
;draw JSR2
.Playback/playing LDZ #00 NEQ ,&play JCN ( if we're paused, skip playback )
;pause JSR2
BRK
&play
.Playback/tick LDZ .Playback/speed LDZ NEQ ,&inc JCN ( if the tick != speed, skip to inc )
;on-step JSR2 ( otherwise, run the on-step routine )
#00 .Playback/tick STZ ( reset the tick )
@ -139,6 +149,11 @@ BRK
&end
BRK
@pause ( pause playback )
#00 .Playback/tick STZ
#ff .Audio1/pitch DEO
RTN
@draw-nibble ( nibble )
#00 SWP ;hex-chars ADD2 LDA #00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2 ( locate nibble in the hex font )
.Edit/selection-y LDZ .Draw/row LDZ NEQ
@ -175,8 +190,7 @@ RTN
#3b ;draw-char JSR2
#00 ;draw-char JSR2
#3d ;draw-char JSR2 ( draws "[ ]" )
POPr ( remove octave from returnstack )
POP
POPr ( remove octave from returnstack ) POP
RTN
&note
#0c MOD #00 SWP ;notes ADD2 LDA DUP #7f AND ;draw-char JSR2