play song sequence

This commit is contained in:
Nico 2022-01-10 23:41:14 +00:00
parent 99ab8482f4
commit e1f50db931
2 changed files with 31 additions and 24 deletions

View File

@ -13,14 +13,20 @@ multiple channels )
#ff .kalama/tick STZ
.kalama/line LDZ #01 ADD DUP
DUP #00 SWP #0003 MUL2
#00 ;k-get-pattern/run JSR2 ADD2 #00 ;k-play-line/run JSR2
.kalama/songpos LDZ2 #0005 ADD2 .kalama/module LDZ2 ADD2 ( song position ) LDA ;k-get-pattern/run JSR2 ADD2 #00 ;k-play-line/run JSR2
#0f EQU ,&next JCN
.kalama/line STZ
RTN
&next
( TODO next pattern )
( TODO respect if song loops or not )
POP
#ff .kalama/line STZ
#ff .kalama/line STZ .kalama/songpos LDZ2 #0004 ADD2 DUP2
.kalama/module LDZ2 #0003 ADD2 LDA2 ( song length ) EQU2 ,&reset JCN
.kalama/songpos STZ2
RTN
&reset
POP
#0000 .kalama/songpos STZ2
RTN
( initialises kalama with module data )
@ -33,7 +39,8 @@ RTN
.kalama/instruments STZ2
#ff .kalama/tick STZ
#ff .kalama/line STZ
#0000 .kalama/songpos STZ2
RTN
( gets the memory address of the given pattern in loaded module )
@ -59,7 +66,7 @@ RTN
STHr #01 SUB STH ( decrement counter )
DUP2 LDA2 ( load length byte and convert to short )
#0006 ADD2 ( jump over length short, vol, flags, ADSR )
ADD2 ( jump to next pattern )
ADD2 ( jump to next instrument )
,&loop JMP
&end
@ -69,10 +76,10 @@ RTN
@k-play-line ( *l channel -- )
&chan $1
&run
,&chan STR
#10 MUL ,&chan STR
LDA DUP
#00 EQU ,&rest JCN
.Audio0/pitch DEO ( TODO use correct channel, effects )
.Audio0/pitch ,&chan LDR ADD DEO ( TODO use correct channel, effects, use loop bit )
RTN
&rest
POP

View File

@ -89,8 +89,8 @@ RTN
@module
8f 02 02 ( file header - speed 8, loop on, 2 patterns, 2 instruments )
0008 ( size )
00 00 ff ff
00 01 ff ff ( song table, 2 rows )
00 ff ff ff
01 ff ff ff ( song table, 2 rows )
( pattern 00 )
54 02 00 ( C-3 I00 )
52 00 00
@ -109,22 +109,22 @@ ff 00 00
48 00 00
ff 00 00
( pattern 01 )
54 00 00
56 02 00 ( C-3 I00 )
57 00 00
56 00 00
57 00 00
54 00 00
56 00 00
54 00 00
56 00 00
52 00 00
54 00 00
52 00 00
54 00 00
50 00 00
54 00 00
ff 00 00
3c 02 00 ( C-3 I00 )
ff 00 00
3c 00 00
ff 00 00
3c 00 00
ff 00 00
3c 00 00
ff 00 00
3c 00 00
ff 00 00
3c 00 00
ff 00 00
3c 00 00
ff 00 00
3c 00 00
( instrument 00 )
0002 ( sample length )
ff ( volume )