render note names and octaves

This commit is contained in:
Nico 2021-05-14 22:10:14 +01:00
parent b35995ef0a
commit 0479f0f396
1 changed files with 51 additions and 16 deletions

View File

@ -5,6 +5,8 @@
%LOB { SWP POP } ( get low byte of short as byte )
%HIB { POP } ( get high byte of short as byte )
%MOD { DUP2 DIV MUL SUB }
( data structure access macros )
%NOTE { NOP } ( get the note of a pattern line addr )
%INST { #0001 ADD2 } ( get the instrument of a pattern line addr )
@ -141,6 +143,34 @@ BRK
&then
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 ( move right a sprite )
RTN
@draw-char ( char )
#00 SWP #0008 MUL2 ;font ADD2 .Screen/addr DEO2
.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
( notes is a table of the note characters, starting at C. The highest bit is used to mark if it's sharp or not. )
@notes [ 23 a3 24 a4 25 26 a6 27 a7 21 a1 22 ]
( draw-note draws a byte as a note name and number on the screen )
@draw-note ( byte )
#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 )
,&then JMP
&else
#03 ;draw-char JSR2 ( otherwise draw a # )
&then
RTN
( draw-byte draws a byte as hex on the screen )
@draw-byte ( byte )
@ -152,7 +182,12 @@ RTN
@draw-pattern-line ( addr )
#00 .Draw/col STZ
&loop
#00 .Draw/col LDZ NEQ ,&else JCN ( if it's not the note value, draw a byte )
DUP2 LDA ;draw-note JSR2
,&then JMP
&else
DUP2 LDA ;draw-byte JSR2
&then
.Screen/x DEI2 #0004 ADD2 .Screen/x DEO2 ( add spacing between digits )
#0001 ADD2 ( get the next byte in the pattern )
#01 .Draw/col LDZ ADD .Draw/col STZ
@ -271,20 +306,20 @@ RTN
an ff in the note column of the pattern will kill the existing note without starting a new one (this is the tracker "box" note) )
@pattern [
3c 12 66
ff 34 66
3e 56 22
00 78 66
3c 9a 88
ff bc 66
3e de 66
00 ff 66
3c 00 22
ff 00 66
3e 00 20
00 00 66
3c 00 66
ff 00 66
3e 00 ff
40 00 66
48 12 66
49 34 66
4a 56 22
4b 78 66
4c 9a 88
4d bc 66
4e de 66
4f ff 66
50 00 22
51 00 66
52 00 20
53 00 66
54 00 66
55 00 66
56 00 ff
57 00 66
]