This repository has been archived on 2022-04-18. You can view files and clone it, but cannot push or open issues or pull requests.
kalama-sin/player.tal

140 lines
3.1 KiB
Tal

( a blank file )
%DEBUG { ;print-hex/byte JSR2 #0a18 DEO }
%DEBUG2 { ;print-hex JSR2 #0a18 DEO }
%RTN { JMP2r }
%10/ { #04 SFT }
( 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 )
&loopflags $1 ( if different channels are set to loop )
&instruments $2 ( address that instruments start at )
&tick $1
&line $1
&speed $1
( program )
|0100 ( -> )
( theme )
#0fe5 .System/r DEO2
#0fc5 .System/g DEO2
#0f25 .System/b DEO2
;module ;k-init-module JSR2
#00 #00 ;k-load-instrument JSR2
;on-frame/run .Screen/vector DEO2
BRK
@on-frame ( -> )
&run
;k-tick/run JSR2
BRK
@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
~engine.tal
@module
88 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 )
3c 02 00 ( C-3 I00 )
00 00 00
ff 00 00
00 00 00
3c 00 00
00 00 00
00 00 00
00 00 00
3c 00 00
00 00 00
00 00 00
00 00 00
3c 00 00
00 00 00
00 00 00
00 00 00
( pattern 01 )
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 )
80 ( flags - loop sample )
00f0 ( 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 )