xrxs/uxn-client/xrxs.tal

154 lines
3.8 KiB
Tal
Raw Normal View History

( utility macros )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%INC-X { .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 } ( -- )
%INC-Y { .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 } ( -- )
%CENTER-X { .Screen/width DEI2 #01 SFT2 }
%CENTER-Y { .Screen/height DEI2 #01 SFT2 }
%MOD { DIVk MUL SUB }
%MOD2 { DIV2k MUL2 SUB2 }
%NEXT-TILE { DUP2 #0010 ADD2 }
%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
%RTN { JMP2r }
( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &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 &pad $2 &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 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
|0000
@state $1
2021-08-13 06:15:00 +00:00
@ticker $1
@drawMode $1
@cart $64
@realm $64
( program )
|0100 ( -> )
2021-08-13 06:15:00 +00:00
@init
( theme )
#02c1 .System/r DEO2
#02cd .System/g DEO2
#02cb .System/b DEO2
;spritesheet .File/name DEO2
#0100 .File/length DEO2
#0000 .File/offset DEO2
;uxnlogo .File/load DEO2
#0200 .File/offset DEO2
;xrxslogo .File/load DEO2
2021-08-13 06:15:00 +00:00
#00 .ticker STZ
#00 .state STZ
;on-frame .Screen/vector DEO2
BRK
@on-frame ( -> )
( wait a couple frames, draw uxn logo )
.ticker LDZ #01 ADD
DUP #20 EQU ,&next-render JCN
.ticker STZ
BRK
&next-render .state LDZ
#00 .ticker STZ
DUP #00 NEQ ,&state1 JCN
;draw-uxn-logo JSR2
#01 ADD .state STZ
BRK
&state1 DUP #01 NEQ ,&state2 JCN
;draw-xrxs-logo-xr JSR2
#01 ADD .state STZ
BRK
&state2 DUP #02 NEQ ,&state3 JCN
;draw-xrxs-logo-xs JSR2
#01 ADD .state STZ
BRK
&state3
BRK
@draw-uxn-logo ( -> )
CENTER-X #0020 SUB2 .Screen/x DEO2
CENTER-Y #0010 SUB2 .Screen/y DEO2
#0100 #0000 &while EQU2k ,&end JCN
DUP2 ;uxnlogo ADD2 .Screen/addr DEO2
#81 .Screen/sprite DEO INC-X
2021-08-13 06:15:00 +00:00
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
CENTER-X #0020 SUB2 .Screen/x DEO2
INC-Y
&no-inc-y
#0010 ADD2 ,&while JMP &end POP2 POP2
RTN
2021-08-13 06:15:00 +00:00
@draw-xrxs-logo-xr ( -> )
CENTER-X .Screen/x DEO2
CENTER-Y #0010 SUB2 .Screen/y DEO2
2021-08-13 06:15:00 +00:00
#0080 #0000 &while EQU2k ,&end JCN
DUP2 ;xrxslogo ADD2 .Screen/addr DEO2
#81 .Screen/sprite DEO INC-X
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
CENTER-X .Screen/x DEO2
INC-Y
&no-inc-y
#0010 ADD2 ,&while JMP &end POP2 POP2
RTN
@draw-xrxs-logo-xs ( -> )
CENTER-X .Screen/x DEO2
CENTER-Y .Screen/y DEO2
#0100 #0080 &while EQU2k ,&end JCN
DUP2 ;xrxslogo ADD2 .Screen/addr DEO2
#81 .Screen/sprite DEO INC-X
2021-08-13 06:15:00 +00:00
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
CENTER-X .Screen/x DEO2
INC-Y
&no-inc-y
#0010 ADD2 ,&while JMP &end POP2 POP2
RTN
( constants )
@spritesheet "xrxs.chr 00
( sprites )
@uxnlogo $128
@xrxslogo $128