add first things to player - lookup helper funcs
This commit is contained in:
parent
34ca2153b5
commit
0a5e4f8d07
|
@ -0,0 +1 @@
|
|||
*.rom
|
|
@ -0,0 +1,161 @@
|
|||
( a blank file )
|
||||
|
||||
%DEBUG { ;print-hex/byte JSR2 #0a18 DEO }
|
||||
%DEBUG2 { ;print-hex JSR2 #0a18 DEO }
|
||||
%RTN { JMP2r }
|
||||
|
||||
( devices )
|
||||
|
||||
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|
||||
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|
||||
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|
||||
|30 @Audio0 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1
|
||||
|40 @Audio1 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1
|
||||
|50 @Audio2 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1
|
||||
|60 @Audio3 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1
|
||||
|80 @Controller &vector $2 &button $1 &key $1 &func $1
|
||||
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2
|
||||
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
||||
|b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|
||||
|
||||
( variables )
|
||||
|
||||
|0000
|
||||
|
||||
@kalama
|
||||
&module $2 ( pointer to start of module file )
|
||||
|
||||
( program )
|
||||
|
||||
|0100 ( -> )
|
||||
|
||||
( theme )
|
||||
#0fe5 .System/r DEO2
|
||||
#0fc5 .System/g DEO2
|
||||
#0f25 .System/b DEO2
|
||||
|
||||
;module .kalama/module STZ2
|
||||
|
||||
;on-frame/run .Screen/vector DEO2
|
||||
#00 ;k-get-instrument/run JSR2 LDA2 DEBUG2
|
||||
|
||||
BRK
|
||||
|
||||
@on-frame ( -> )
|
||||
&run
|
||||
BRK
|
||||
|
||||
( gets the memory address of the given pattern in loaded module )
|
||||
@k-get-pattern ( number -- addr* )
|
||||
&run
|
||||
STH ( stash pattern number to return stack for loop counter later )
|
||||
.kalama/module LDZ2 ( get module start address )
|
||||
#0003 ADD2 ( skip header )
|
||||
DUP2 LDA2 ( load pattern table length )
|
||||
#0002 ADD2 ( skip pattern table length byte )
|
||||
ADD2 ( and skip the pattern table )
|
||||
( we are now at the size byte of pattern 00 )
|
||||
|
||||
&loop
|
||||
STHrk #00 EQU ,&end JCN
|
||||
STHr #01 SUB STH ( decrement counter )
|
||||
DUP2 LDA #00 SWP ( load length byte and convert to short )
|
||||
#0001 ADD2 ( jump over length byte )
|
||||
ADD2 ( jump to next pattern )
|
||||
,&loop JMP
|
||||
&end
|
||||
POPr
|
||||
RTN
|
||||
|
||||
( gets the memory address of the given instrument in loaded module )
|
||||
@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 )
|
||||
|
||||
( we are now at the size byte of instrument 00, the start of instrument memory )
|
||||
&loop
|
||||
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 )
|
||||
ADD2 ( jump to next pattern )
|
||||
,&loop JMP
|
||||
|
||||
&end
|
||||
POPr
|
||||
RTN
|
||||
|
||||
@print-hex ( value* -- )
|
||||
|
||||
SWP ,&byte JSR
|
||||
&byte ( byte -- )
|
||||
STHk #04 SFT ,&parse JSR #18 DEO
|
||||
STHr #0f AND ,&parse JSR #18 DEO
|
||||
RTN
|
||||
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD RTN
|
||||
&above #57 ADD RTN
|
||||
|
||||
RTN
|
||||
|
||||
@print-dec ( value* -- )
|
||||
|
||||
#2710 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2
|
||||
#03e8 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2
|
||||
#0064 DIV2k DUP #30 ADD #18 DEO MUL2 SUB2
|
||||
#000a DIV2k DUP #30 ADD #18 DEO MUL2 SUB2
|
||||
#30 ADD #18 DEO POP
|
||||
|
||||
RTN
|
||||
|
||||
@print-str ( string* -- )
|
||||
|
||||
#0001 SUB2
|
||||
&while
|
||||
INC2 LDAk DUP #18 DEO ,&while JCN
|
||||
POP2
|
||||
|
||||
RTN
|
||||
|
||||
@module
|
||||
|
||||
84 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 )
|
||||
( pattern 00 )
|
||||
12 ( size byte )
|
||||
3c 02 00 ( C-3 I00 )
|
||||
ff bc
|
||||
ff bc
|
||||
ff bc
|
||||
ff bc
|
||||
ff bc
|
||||
ff bc
|
||||
ff bc
|
||||
ff
|
||||
( pattern 01 )
|
||||
14 ( size byte )
|
||||
ff
|
||||
3c 02 00 ( C-3 I00 )
|
||||
ff be
|
||||
ff be
|
||||
ff
|
||||
3e 01 66 ( D-3 V66 )
|
||||
ff be
|
||||
ff be
|
||||
ff be
|
||||
ff be
|
||||
( instrument 00 )
|
||||
0002 ( sample length )
|
||||
ff ( volume )
|
||||
80 ( flags - loop sample )
|
||||
ff 00 ( square wave sample data )
|
||||
( instrument 01, unused )
|
||||
0008 ( sample length )
|
||||
60 ( volume )
|
||||
00 ( flags - no loop )
|
||||
ff de 21 32 fa 43 aa 04 ( 8 random bytes )
|
Reference in New Issue