diff --git a/player.tal b/player.tal index b24411f..b64ba39 100644 --- a/player.tal +++ b/player.tal @@ -26,6 +26,7 @@ @kalama &module $2 ( pointer to start of module file ) &loopflags $1 ( if different channels are set to loop ) + &instruments $2 ( address that instruments start at ) ( program ) @@ -36,7 +37,7 @@ #0fc5 .System/g DEO2 #0f25 .System/b DEO2 - ;module .kalama/module STZ2 + ;module ;k-init-module JSR2 ;on-frame/run .Screen/vector DEO2 #00 #00 ;k-load-instrument/run JSR2 @@ -47,6 +48,16 @@ BRK &run BRK +( initialises kalama with module data ) +@k-init-module ( addr* -- ) +&run + DUP2 .kalama/module STZ2 ( store module address ) + #0001 ADD2 LDA ( get pattern count byte ) + ;k-get-pattern/run JSR2 ( get the "pattern" that is 1 over the pattern index numbers. This is the first byte of the instruments ) + .kalama/instruments STZ2 + +RTN + ( gets the memory address of the given pattern in loaded module ) @k-get-pattern ( number -- addr* ) &run @@ -73,11 +84,7 @@ RTN @k-get-instrument ( number -- addr* ) &run STH ( store instrument number for later ) - .kalama/module LDZ2 ( get module start address ) - #0001 ADD2 LDA ( get pattern count byte ) - ;k-get-pattern/run JSR2 ( get that "pattern". This is 1 over the number of patterns, so this spits us out at the first byte after all the patterns which is the first byte of the first instrument ) - ( TODO don't recalculate this every time ) - + .kalama/instruments LDZ2 ( we are now at the size byte of instrument 00, the start of instrument memory ) &loop STHrk #00 EQU ,&end JCN @@ -180,7 +187,7 @@ ff be 0002 ( sample length ) ff ( volume ) 80 ( flags - loop sample ) -10f0 ( ADSR ) +05f5 ( ADSR ) ff 00 ( square wave sample data ) ( instrument 01, unused ) 0008 ( sample length )