instrument loading works
This commit is contained in:
parent
0a5e4f8d07
commit
628ed099fc
37
player.tal
37
player.tal
|
@ -3,6 +3,7 @@
|
|||
%DEBUG { ;print-hex/byte JSR2 #0a18 DEO }
|
||||
%DEBUG2 { ;print-hex JSR2 #0a18 DEO }
|
||||
%RTN { JMP2r }
|
||||
%10/ { #04 SFT }
|
||||
|
||||
( devices )
|
||||
|
||||
|
@ -24,6 +25,7 @@
|
|||
|
||||
@kalama
|
||||
&module $2 ( pointer to start of module file )
|
||||
&loopflags $1 ( if different channels are set to loop )
|
||||
|
||||
( program )
|
||||
|
||||
|
@ -35,10 +37,10 @@
|
|||
#0f25 .System/b DEO2
|
||||
|
||||
;module .kalama/module STZ2
|
||||
|
||||
|
||||
;on-frame/run .Screen/vector DEO2
|
||||
#00 ;k-get-instrument/run JSR2 LDA2 DEBUG2
|
||||
|
||||
#00 #00 ;k-load-instrument/run JSR2
|
||||
#3c .Audio0/pitch DEO
|
||||
BRK
|
||||
|
||||
@on-frame ( -> )
|
||||
|
@ -81,7 +83,7 @@ RTN
|
|||
STHrk #00 EQU ,&end JCN
|
||||
STHr #01 SUB STH ( decrement counter )
|
||||
DUP2 LDA2 ( load length byte and convert to short )
|
||||
#0004 ADD2 ( jump over length short, vol, flags )
|
||||
#0006 ADD2 ( jump over length short, vol, flags, ADSR )
|
||||
ADD2 ( jump to next pattern )
|
||||
,&loop JMP
|
||||
|
||||
|
@ -89,6 +91,31 @@ RTN
|
|||
POPr
|
||||
RTN
|
||||
|
||||
( loads instrument with number into specified audio channel, 0-indexed )
|
||||
@k-load-instrument ( number channel -- )
|
||||
&run
|
||||
#10 MUL STH ( stash channel * 0x10, offset for that channel's data relative to Audio0 )
|
||||
|
||||
;k-get-instrument JSR2 ( get instrument location )
|
||||
DUP2 LDA2 STHrk .Audio0/length ADD DEO2 ( copy ADSR value )
|
||||
#0002 ADD2 ( move to volume value )
|
||||
DUP2 LDA STHrk .Audio0/volume ADD DEO ( copy volume value )
|
||||
#0001 ADD2 DUP2 ( move to flags value )
|
||||
LDA #07 SFT ( MSB is set for looping sample, turn it into 0/1 )
|
||||
|
||||
DUP ( set or clear loop bit )
|
||||
#00 EQU ,&clear JCN
|
||||
STHrk SFT .kalama/loopflags LDZ ORA .kalama/loopflags STZ ( set bit on )
|
||||
,&end JMP
|
||||
&clear
|
||||
STHrk SFT #ff EOR .kalama/loopflags LDZ AND .kalama/loopflags STZ ( set bit off )
|
||||
&end
|
||||
|
||||
#0001 ADD2 LDA2 STHrk .Audio0/adsr DEO2 ( copy ADSR value )
|
||||
|
||||
POPr
|
||||
RTN
|
||||
|
||||
@print-hex ( value* -- )
|
||||
|
||||
SWP ,&byte JSR
|
||||
|
@ -153,9 +180,11 @@ ff be
|
|||
0002 ( sample length )
|
||||
ff ( volume )
|
||||
80 ( flags - loop sample )
|
||||
10f0 ( ADSR )
|
||||
ff 00 ( square wave sample data )
|
||||
( instrument 01, unused )
|
||||
0008 ( sample length )
|
||||
60 ( volume )
|
||||
00 ( flags - no loop )
|
||||
10f0 ( ADSR )
|
||||
ff de 21 32 fa 43 aa 04 ( 8 random bytes )
|
||||
|
|
Reference in New Issue