some refactoring to tick rountine

This commit is contained in:
Nico 2022-01-19 22:56:23 +00:00
parent ecb0380916
commit 428029e062
2 changed files with 37 additions and 19 deletions

View File

@ -1,7 +1,7 @@
( TODO
commmands
song playback
multiple channels )
( TODO
multiple channels
commmands )
@k-tick
&run
.kalama/tick LDZ #01 ADD DUP
@ -11,17 +11,18 @@ multiple channels )
&play
POP
#ff .kalama/tick STZ
.kalama/line LDZ #01 ADD DUP
DUP #00 SWP #0003 MUL2
.kalama/songpos LDZ2 DUP2
#ffff EQU2 ,&no-play JCN ( don't play if song pos is ffff aka song is stopped or over )
#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
.kalama/line LDZ #01 ADD STHk ( line )
#00 SWP #0003 MUL2 ( lineaddr* )
.kalama/songpos LDZ2 DUP2 ( songpos* songpos* lineaddr* )
( don't play if song pos is ffff aka song is stopped or over )
#ffff EQU2 ,&no-play JCN ( songpos* lineaddr* )
#0005 ADD2 .kalama/module LDZ2 ADD2 ( songposinmod* lineaddr* )
LDA ( -- pattern1 lineaddr* ) ;k-get-pattern/run JSR2 ADD2 #00 ;k-play-line/run JSR2 ( -- )
STHrk #0f EQU ,&next JCN
STHr .kalama/line STZ
RTN
&next
( TODO respect if song loops or not )
POP
POPr
#ff .kalama/line STZ .kalama/songpos LDZ2 #0004 ADD2 DUP2
.kalama/module LDZ2 #0003 ADD2 LDA2 ( song length ) EQU2 ,&reset JCN
.kalama/songpos STZ2
@ -35,7 +36,7 @@ RTN
#ffff .kalama/songpos STZ2
RTN
&no-play
POP2 POP2 POP2
POP2 POP2 POPr
RTN
( initialises kalama with module data )
@ -56,7 +57,7 @@ RTN
( gets the memory address of the given pattern in loaded module )
@k-get-pattern ( number -- addr* )
&run
( #00 #01 EQU ,&blank JCN )
DUP #ff EQU ,&blank JCN
#00 SWP #0030 MUL2
;module #0003 ADD2 DUP2 LDA2 ADD2 #0002 ADD2 ADD2
RTN

View File

@ -89,11 +89,11 @@ RTN
~engine.tal
@module
8f 02 02 ( file header - speed f, loop on, 2 patterns, 2 instruments )
8f 03 02 ( file header - speed f, loop on, 3 patterns, 2 instruments )
000c ( size )
00 ff ff ff
ff ff ff ff ( song table, 2 rows )
01 ff ff ff
00 02 ff ff
ff 02 ff ff ( song table, 2 rows )
01 02 ff ff
@DEBUG-patterns
( pattern 00 )
54 02 00 ( C-3 I00 )
@ -129,6 +129,23 @@ ff 00 00
50 00 00
54 00 00
ff 00 00
( pattern 02 )
3c 00 00
00 00 00
3c 00 00
00 00 00
3c 00 00
00 00 00
3c 00 00
00 00 00
3c 00 00
00 00 00
3c 00 00
00 00 00
3c 00 00
00 00 00
3c 00 00
00 00 00
@DEBUG-instruments
( instrument 00 )
0002 ( sample length )