mark selections, make selection byte new color
This commit is contained in:
parent
8a2a60b3b8
commit
d6d0e52369
70
main.usm
70
main.usm
|
@ -41,6 +41,7 @@
|
|||
&pattern-x $2 &pattern-y $2
|
||||
&pattern-vspacing $2 &pattern-hspacing $2
|
||||
&playhead-x $2 &playhead-y $2 ]
|
||||
@Edit [ &selection-x $1 &selection-y $1 ]
|
||||
|
||||
( program )
|
||||
|
||||
|
@ -48,13 +49,13 @@
|
|||
|
||||
( set a pallete )
|
||||
#0f00 .System/r DEO2
|
||||
#0ff0 .System/g DEO2
|
||||
#0f0f .System/b DEO2
|
||||
#0f00 .System/g DEO2
|
||||
#0fff .System/b DEO2
|
||||
|
||||
( speed - how many ticks we play a note every )
|
||||
#10 .Playback/speed POK
|
||||
#10 .Playback/speed STZ
|
||||
|
||||
;pattern .Playback/pattern-addr POK2
|
||||
;pattern .Playback/pattern-addr STZ2
|
||||
|
||||
( display/audio init )
|
||||
;on-frame .Screen/vector DEO2
|
||||
|
@ -63,27 +64,34 @@
|
|||
#0002 .Audio0/length DEO2
|
||||
|
||||
( drawing properties )
|
||||
#0010 .Draw/pattern-x POK2
|
||||
#0010 .Draw/pattern-y POK2
|
||||
#0004 .Draw/pattern-vspacing POK2
|
||||
#0007 .Draw/playhead-x POK2
|
||||
#0004 .Draw/pattern-hspacing POK2
|
||||
#0010 .Draw/pattern-x STZ2
|
||||
#0010 .Draw/pattern-y STZ2
|
||||
#0004 .Draw/pattern-vspacing STZ2
|
||||
#0007 .Draw/playhead-x STZ2
|
||||
#0004 .Draw/pattern-hspacing STZ2
|
||||
BRK
|
||||
|
||||
@on-frame ( -> )
|
||||
;draw JSR2
|
||||
.Playback/tick PEK .Playback/speed PEK NEQ ,&inc JNZ ( if the tick != speed, skip to inc )
|
||||
.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 POK ( reset the tick )
|
||||
#00 .Playback/tick STZ ( reset the tick )
|
||||
,&end JMP ( jump to end )
|
||||
&inc
|
||||
#01 .Playback/tick PEK ADD .Playback/tick POK ( tick up 1 )
|
||||
#01 .Playback/tick LDZ ADD .Playback/tick STZ ( tick up 1 )
|
||||
&end
|
||||
BRK
|
||||
|
||||
@draw-nibble ( nibble )
|
||||
#08 MUL #00 SWP ;font_hex ADD2 .Screen/addr DEO2 ( locate nibble in the hex font )
|
||||
.Edit/selection-y LDZ .Draw/row LDZ NEQ
|
||||
.Edit/selection-x LDZ .Draw/col LDZ NEQ ADD ( if the row and column are the selected ones, use a different color )
|
||||
,&else JCN
|
||||
#22 .Screen/color DEO
|
||||
,&then JMP
|
||||
&else
|
||||
#21 .Screen/color DEO ( display it )
|
||||
&then
|
||||
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 ( move right a sprite )
|
||||
RTN
|
||||
|
||||
|
@ -95,36 +103,36 @@ RTN
|
|||
|
||||
( draw-pattern-line draws a single line in a pattern )
|
||||
@draw-pattern-line ( addr )
|
||||
#00 .Draw/col POK
|
||||
#00 .Draw/col STZ
|
||||
&loop
|
||||
DUP2 LDA ;draw-byte JSR2
|
||||
.Screen/x DEI2 #0004 ADD2 .Screen/x DEO2 ( add spacing between digits )
|
||||
#0001 ADD2 ( get the next byte in the pattern )
|
||||
#01 .Draw/col PEK ADD .Draw/col POK
|
||||
.Draw/col PEK PTN_WIDTH LOB NEQ ,&loop JNZ
|
||||
#01 .Draw/col LDZ ADD .Draw/col STZ
|
||||
.Draw/col LDZ PTN_WIDTH LOB NEQ ,&loop JCN
|
||||
POP2 ( remove final address from stack )
|
||||
RTN
|
||||
|
||||
( draw-pattern draws a pattern )
|
||||
@draw-pattern ( addr )
|
||||
#00 .Draw/row POK
|
||||
#00 .Draw/row STZ
|
||||
&loop
|
||||
.Draw/pattern-y PEK2 .Screen/x DEO2
|
||||
.Draw/pattern-y LDZ2 .Screen/x DEO2
|
||||
DUP2 ;draw-pattern-line JSR2
|
||||
.Screen/y DEI2 #0008 .Draw/pattern-vspacing PEK2 ADD2 ADD2 .Screen/y DEO2 ( add spacing between rows )
|
||||
.Screen/y DEI2 #0008 .Draw/pattern-vspacing LDZ2 ADD2 ADD2 .Screen/y DEO2 ( add spacing between rows )
|
||||
PTN_WIDTH ADD2 ( get the next byte in the pattern )
|
||||
#01 .Draw/row PEK ADD .Draw/row POK
|
||||
.Draw/row PEK PTN_LEN LOB NEQ ,&loop JNZ
|
||||
#01 .Draw/row LDZ ADD .Draw/row STZ
|
||||
.Draw/row LDZ PTN_LEN LOB NEQ ,&loop JCN
|
||||
POP2 ( remove final address from stack )
|
||||
RTN
|
||||
|
||||
@draw-playhead
|
||||
( clear previous playhead )
|
||||
.Draw/playhead-y PEK2 .Screen/y DEO2
|
||||
.Draw/playhead-x PEK2 .Screen/x DEO2
|
||||
.Draw/playhead-y LDZ2 .Screen/y DEO2
|
||||
.Draw/playhead-x LDZ2 .Screen/x DEO2
|
||||
#20 .Screen/color DEO
|
||||
( draw new playhead )
|
||||
.Draw/pattern-y PEK2 .Playback/position PEK2 #0001 SUB2 #0004 MUL2 ADD2 #0008 SUB2 DUP2 .Draw/playhead-y POK2
|
||||
.Draw/pattern-y LDZ2 .Playback/position LDZ2 #0001 SUB2 #0004 MUL2 ADD2 #0008 SUB2 DUP2 .Draw/playhead-y STZ2
|
||||
.Screen/y DEO2
|
||||
;playhead_icon .Screen/addr DEO2
|
||||
#21 .Screen/color DEO
|
||||
|
@ -132,26 +140,26 @@ RTN
|
|||
|
||||
@draw
|
||||
;draw-playhead JSR2
|
||||
.Draw/pattern-x PEK2 .Screen/x DEO2
|
||||
.Draw/pattern-y PEK2 .Screen/y DEO2
|
||||
.Playback/pattern-addr PEK2 ;draw-pattern JSR2
|
||||
.Draw/pattern-x LDZ2 .Screen/x DEO2
|
||||
.Draw/pattern-y LDZ2 .Screen/y DEO2
|
||||
.Playback/pattern-addr LDZ2 ;draw-pattern JSR2
|
||||
RTN
|
||||
|
||||
@on-step ( whenever a pattern step should be played )
|
||||
|
||||
PTN_WIDTH PTN_LEN MUL2 .Playback/position PEK2 NEQ2 ,&continue JNZ ( if we're at the end of the pattern, reset the counter )
|
||||
#0000 .Playback/position POK2
|
||||
PTN_WIDTH PTN_LEN MUL2 .Playback/position LDZ2 NEQ2 ,&continue JCN ( if we're at the end of the pattern, reset the counter )
|
||||
#0000 .Playback/position STZ2
|
||||
&continue
|
||||
.Playback/position PEK2 .Playback/pattern-addr PEK2 ADD2 ( put pattern line address on the stack )
|
||||
.Playback/position LDZ2 .Playback/pattern-addr LDZ2 ADD2 ( put pattern line address on the stack )
|
||||
DUP2 VOL LDA .Audio0/volume DEO ( ln -- ) ( put the address of the pattern line on the stack )
|
||||
NOTE LDA ( get the current note )
|
||||
DUP #00 EQU ,&rest JNZ ( if the note is 00, aka empty, skip playing it )
|
||||
DUP #00 EQU ,&rest JCN ( if the note is 00, aka empty, skip playing it )
|
||||
.Audio0/pitch DEO ( play the note )
|
||||
,&end JMP ( jump to the end )
|
||||
|
||||
&rest POP ( if the note is a 00, jump here. POP to clean up the stack )
|
||||
&end
|
||||
PTN_WIDTH .Playback/position PEK2 ADD2 .Playback/position POK2
|
||||
PTN_WIDTH .Playback/position LDZ2 ADD2 .Playback/position STZ2
|
||||
;draw-playhead JSR2 ( update the playhead position )
|
||||
RTN
|
||||
|
||||
|
|
Reference in New Issue