2021-08-11 20:14:53 +00:00
|
|
|
( utility macros )
|
|
|
|
|
|
|
|
%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 }
|
|
|
|
|
|
|
|
%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
|
2021-08-14 06:53:17 +00:00
|
|
|
@anim-speed $1
|
2021-08-13 06:41:38 +00:00
|
|
|
|
|
|
|
@logo-coords [
|
|
|
|
&x $2
|
|
|
|
&y $2
|
|
|
|
]
|
|
|
|
|
2021-08-16 04:26:23 +00:00
|
|
|
@cart $32
|
|
|
|
@realm $32
|
2021-08-11 20:14:53 +00:00
|
|
|
|
|
|
|
( program )
|
|
|
|
|
2021-08-13 06:41:38 +00:00
|
|
|
|0100
|
|
|
|
@init ( -> )
|
|
|
|
|
|
|
|
( steppewnolf-dark theme )
|
2021-08-13 06:20:05 +00:00
|
|
|
#02c1 .System/r DEO2
|
|
|
|
#02cd .System/g DEO2
|
|
|
|
#02cb .System/b DEO2
|
2021-08-11 20:14:53 +00:00
|
|
|
|
2021-08-13 06:20:05 +00:00
|
|
|
;spritesheet .File/name DEO2
|
|
|
|
#0100 .File/length DEO2
|
2021-08-11 20:14:53 +00:00
|
|
|
|
2021-08-13 06:20:05 +00:00
|
|
|
#0000 .File/offset DEO2
|
|
|
|
;uxnlogo .File/load DEO2
|
2021-08-11 20:14:53 +00:00
|
|
|
|
|
|
|
#0200 .File/offset DEO2
|
|
|
|
;xrxslogo .File/load DEO2
|
|
|
|
|
2021-08-13 06:15:00 +00:00
|
|
|
#00 .ticker STZ
|
|
|
|
#00 .state STZ
|
2021-08-14 06:53:17 +00:00
|
|
|
#20 .anim-speed STZ
|
2021-08-13 06:15:00 +00:00
|
|
|
|
2021-08-13 06:41:38 +00:00
|
|
|
CENTER-X .logo-coords/x STZ2
|
|
|
|
CENTER-Y .logo-coords/y STZ2
|
|
|
|
|
2021-08-13 06:15:00 +00:00
|
|
|
;on-frame .Screen/vector DEO2
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-frame ( -> )
|
2021-08-13 06:41:38 +00:00
|
|
|
|
2021-08-13 06:15:00 +00:00
|
|
|
.ticker LDZ #01 ADD
|
2021-08-14 06:53:17 +00:00
|
|
|
DUP .anim-speed LDZ EQU ,&next-render JCN
|
2021-08-13 06:15:00 +00:00
|
|
|
.ticker STZ
|
2021-08-13 06:41:38 +00:00
|
|
|
BRK
|
2021-08-13 06:15:00 +00:00
|
|
|
|
2021-08-14 06:53:17 +00:00
|
|
|
&next-render
|
|
|
|
POP #00 .ticker STZ
|
|
|
|
.state LDZ
|
|
|
|
|
2021-08-16 04:26:23 +00:00
|
|
|
( draw uxn logo )
|
2021-08-13 06:15:00 +00:00
|
|
|
DUP #00 NEQ ,&state1 JCN
|
|
|
|
;draw-uxn-logo JSR2
|
|
|
|
#01 ADD .state STZ
|
|
|
|
BRK
|
2021-08-16 04:26:23 +00:00
|
|
|
|
|
|
|
( draw first syllable of xrxs logo )
|
2021-08-13 06:15:00 +00:00
|
|
|
&state1 DUP #01 NEQ ,&state2 JCN
|
|
|
|
;draw-xrxs-logo-xr JSR2
|
|
|
|
#01 ADD .state STZ
|
|
|
|
BRK
|
2021-08-16 04:26:23 +00:00
|
|
|
|
|
|
|
( draw second syllable of xrxs logo )
|
2021-08-13 06:15:00 +00:00
|
|
|
&state2 DUP #02 NEQ ,&state3 JCN
|
|
|
|
;draw-xrxs-logo-xs JSR2
|
2021-08-14 06:53:17 +00:00
|
|
|
|
2021-08-13 06:15:00 +00:00
|
|
|
#01 ADD .state STZ
|
|
|
|
BRK
|
2021-08-16 04:26:23 +00:00
|
|
|
|
|
|
|
( clear screen )
|
2021-08-13 06:15:00 +00:00
|
|
|
&state3
|
2021-08-14 06:53:17 +00:00
|
|
|
;clear-screen JSR2
|
2021-08-16 04:26:23 +00:00
|
|
|
|
|
|
|
( move shove logo into top-left corner )
|
2021-08-14 06:53:17 +00:00
|
|
|
DUP #03 NEQ ,&state4 JCN
|
|
|
|
#04 .anim-speed STZ
|
|
|
|
;scoot-logos JSR2
|
|
|
|
;draw-uxn-logo JSR2
|
|
|
|
;draw-xrxs-logo-xr JSR2
|
|
|
|
;draw-xrxs-logo-xs JSR2
|
|
|
|
.logo-coords/x LDZ2 #0020 GTH2 ,&keep-state JCN
|
|
|
|
#01 ADD .state STZ BRK
|
|
|
|
&keep-state POP
|
|
|
|
BRK
|
2021-08-16 04:26:23 +00:00
|
|
|
|
|
|
|
( render the logo and window decorations )
|
2021-08-14 06:53:17 +00:00
|
|
|
&state4 DUP #04 NEQ ,&state5 JCN
|
2021-08-15 06:41:54 +00:00
|
|
|
;draw-gray-borders JSR2
|
2021-08-16 04:26:23 +00:00
|
|
|
;draw-bl-scanlines JSR2
|
2021-08-15 06:41:54 +00:00
|
|
|
;draw-tl-scanlines JSR2
|
|
|
|
;draw-tr-scanlines JSR2
|
2021-08-16 04:26:23 +00:00
|
|
|
;draw-br-scanlines JSR2
|
2021-08-14 06:53:17 +00:00
|
|
|
;draw-uxn-logo JSR2
|
|
|
|
;draw-xrxs-logo-xr JSR2
|
|
|
|
;draw-xrxs-logo-xs JSR2
|
|
|
|
POP
|
|
|
|
BRK
|
|
|
|
&state5 POP
|
2021-08-11 20:14:53 +00:00
|
|
|
BRK
|
|
|
|
|
2021-08-14 06:53:17 +00:00
|
|
|
@clear-screen ( -> )
|
2021-08-15 06:41:54 +00:00
|
|
|
|
2021-08-14 06:53:17 +00:00
|
|
|
.Screen/width DEI2 #0000 &whilex EQU2k ,&endx JCN
|
|
|
|
DUP2 ,&x STR2
|
|
|
|
.Screen/height DEI2 #0000 &whiley EQU2k ,&endy JCN
|
|
|
|
DUP2 ,&y STR2
|
|
|
|
,&x LDR2 .Screen/x DEO2
|
|
|
|
,&y LDR2 .Screen/y DEO2
|
|
|
|
;blank .Screen/addr DEO2
|
2021-08-15 06:41:54 +00:00
|
|
|
#10 .Screen/sprite DEO
|
|
|
|
#40 .Screen/sprite DEO
|
2021-08-14 06:53:17 +00:00
|
|
|
#0008 ADD2 ,&whiley JMP &endy POP2 POP2
|
|
|
|
#0008 ADD2 ,&whilex JMP &endx POP2 POP2
|
|
|
|
|
2021-08-15 06:41:54 +00:00
|
|
|
RTN
|
|
|
|
&x $2
|
|
|
|
&y $2
|
|
|
|
|
2021-08-14 06:53:17 +00:00
|
|
|
@scoot-logos ( -> )
|
|
|
|
.logo-coords/x LDZ2 #0021 LTH2 ,&no-scoot-x JCN
|
|
|
|
.logo-coords/x LDZ2 #01 SFT2
|
|
|
|
.logo-coords/x STZ2
|
|
|
|
&no-scoot-x
|
|
|
|
|
|
|
|
.logo-coords/y LDZ2 #0021 LTH2 ,&no-scoot-y JCN
|
|
|
|
.logo-coords/y LDZ2 #01 SFT2
|
|
|
|
.logo-coords/y STZ2
|
|
|
|
&no-scoot-y
|
|
|
|
RTN
|
|
|
|
|
2021-08-11 20:14:53 +00:00
|
|
|
@draw-uxn-logo ( -> )
|
|
|
|
|
2021-08-13 06:41:38 +00:00
|
|
|
.logo-coords/x LDZ2 #0020 SUB2 .Screen/x DEO2
|
|
|
|
.logo-coords/y LDZ2 #0010 SUB2 .Screen/y DEO2
|
2021-08-11 20:14:53 +00:00
|
|
|
|
|
|
|
#0100 #0000 &while EQU2k ,&end JCN
|
|
|
|
DUP2 ;uxnlogo ADD2 .Screen/addr DEO2
|
2021-08-15 06:41:54 +00:00
|
|
|
#c1 .Screen/sprite DEO INC-X
|
2021-08-11 20:14:53 +00:00
|
|
|
|
2021-08-13 06:15:00 +00:00
|
|
|
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
|
2021-08-13 06:41:38 +00:00
|
|
|
.logo-coords/x LDZ2 #0020 SUB2 .Screen/x DEO2
|
2021-08-11 20:14:53 +00:00
|
|
|
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 ( -> )
|
2021-08-11 20:14:53 +00:00
|
|
|
|
2021-08-13 06:41:38 +00:00
|
|
|
.logo-coords/x LDZ2 .Screen/x DEO2
|
|
|
|
.logo-coords/y LDZ2 #0010 SUB2 .Screen/y DEO2
|
2021-08-11 20:14:53 +00:00
|
|
|
|
2021-08-13 06:15:00 +00:00
|
|
|
#0080 #0000 &while EQU2k ,&end JCN
|
|
|
|
DUP2 ;xrxslogo ADD2 .Screen/addr DEO2
|
2021-08-15 06:41:54 +00:00
|
|
|
#c1 .Screen/sprite DEO INC-X
|
2021-08-13 06:15:00 +00:00
|
|
|
|
|
|
|
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
|
2021-08-13 06:41:38 +00:00
|
|
|
.logo-coords/x LDZ2 .Screen/x DEO2
|
2021-08-13 06:15:00 +00:00
|
|
|
INC-Y
|
|
|
|
&no-inc-y
|
|
|
|
#0010 ADD2 ,&while JMP &end POP2 POP2
|
|
|
|
|
|
|
|
RTN
|
|
|
|
|
|
|
|
@draw-xrxs-logo-xs ( -> )
|
|
|
|
|
2021-08-13 06:41:38 +00:00
|
|
|
.logo-coords/x LDZ2 .Screen/x DEO2
|
|
|
|
.logo-coords/y LDZ2 .Screen/y DEO2
|
2021-08-13 06:15:00 +00:00
|
|
|
|
|
|
|
#0100 #0080 &while EQU2k ,&end JCN
|
2021-08-11 20:14:53 +00:00
|
|
|
DUP2 ;xrxslogo ADD2 .Screen/addr DEO2
|
2021-08-15 06:41:54 +00:00
|
|
|
#c1 .Screen/sprite DEO INC-X
|
2021-08-11 20:14:53 +00:00
|
|
|
|
2021-08-13 06:15:00 +00:00
|
|
|
NEXT-TILE #0030 AND2 #0000 NEQ2 ,&no-inc-y JCN
|
2021-08-13 06:41:38 +00:00
|
|
|
.logo-coords/x LDZ2 .Screen/x DEO2
|
2021-08-11 20:14:53 +00:00
|
|
|
INC-Y
|
|
|
|
&no-inc-y
|
|
|
|
#0010 ADD2 ,&while JMP &end POP2 POP2
|
|
|
|
|
|
|
|
RTN
|
|
|
|
|
2021-08-15 06:41:54 +00:00
|
|
|
@draw-gray-borders ( -> )
|
|
|
|
|
|
|
|
;blank .Screen/addr DEO2
|
|
|
|
#0028 #0000 &whilemtop EQU2k ,&endmtop JCN
|
|
|
|
DUP2 .Screen/y DEO2
|
|
|
|
.Screen/width DEI2 #0000 &whiletop EQU2k ,&endtop JCN
|
|
|
|
DUP2 .Screen/x DEO2
|
|
|
|
#84 .Screen/sprite DEO
|
|
|
|
#0008 ADD2 ,&whiletop JMP &endtop POP2 POP2
|
|
|
|
#0008 ADD2 ,&whilemtop JMP &endmtop POP2 POP2
|
|
|
|
|
|
|
|
#0040 #0000 &whilemleft EQU2k ,&endmleft JCN
|
|
|
|
DUP2 .Screen/x DEO2
|
|
|
|
.Screen/height DEI2 #0028 SUB2 #0028 &whileleft EQU2k ,&endleft JCN
|
|
|
|
DUP2 .Screen/y DEO2
|
|
|
|
#84 .Screen/sprite DEO
|
|
|
|
#0008 ADD2 ,&whileleft JMP &endleft POP2 POP2
|
|
|
|
#0008 ADD2 ,&whilemleft JMP &endmleft POP2 POP2
|
|
|
|
|
|
|
|
.Screen/width DEI2 DUP2 #0040 SUB2 &whilemright EQU2k ,&endmright JCN
|
|
|
|
DUP2 .Screen/x DEO2
|
|
|
|
.Screen/height DEI2 #0028 SUB2 #0028 &whileright EQU2k ,&endright JCN
|
|
|
|
DUP2 .Screen/y DEO2
|
|
|
|
#84 .Screen/sprite DEO
|
|
|
|
#0008 ADD2 ,&whileright JMP &endright POP2 POP2
|
|
|
|
#0008 ADD2 ,&whilemright JMP &endmright POP2 POP2
|
|
|
|
|
|
|
|
.Screen/height DEI2 DUP2 #0028 SUB2 &whilembottom EQU2k ,&endmbottom JCN
|
|
|
|
DUP2 .Screen/y DEO2
|
|
|
|
.Screen/width DEI2 #0000 &whilebottom EQU2k ,&endbottom JCN
|
|
|
|
DUP2 .Screen/x DEO2
|
|
|
|
#84 .Screen/sprite DEO
|
|
|
|
#0008 ADD2 ,&whilebottom JMP &endbottom POP2 POP2
|
|
|
|
#0008 ADD2 ,&whilembottom JMP &endmbottom POP2 POP2
|
|
|
|
RTN
|
|
|
|
|
|
|
|
|
|
|
|
( come up with a more elegant way to draw these that doesn't cause a stack underflow )
|
|
|
|
|
|
|
|
@draw-bl-scanlines ( -> )
|
|
|
|
CENTER-Y ,&y STR2
|
|
|
|
#0008 ,&x STR2
|
|
|
|
|
|
|
|
&whileld
|
2021-08-16 04:26:23 +00:00
|
|
|
,&y LDR2 CENTER-Y SUB2 #0010 DIV2 DUP2 ADD2 #0008 ADD2 ,&x STR2
|
2021-08-15 06:41:54 +00:00
|
|
|
.Screen/height DEI2 #0028 SUB2 ,&y LDR2 LTH2 ,&endld JCN
|
|
|
|
&dlscan #0040 ,&x LDR2 EQU2 ,&enddlscan JCN
|
|
|
|
,&x LDR2 .Screen/x DEO2
|
|
|
|
,&y LDR2 .Screen/y DEO2
|
|
|
|
#03 .Screen/pixel DEO
|
|
|
|
,&x LDR2 #0001 ADD2 ,&x STR2 ,&dlscan JMP &enddlscan
|
|
|
|
,&y LDR2 #0004 ADD2 ,&y STR2 ,&whileld JMP &endld
|
|
|
|
RTN
|
|
|
|
&x $2
|
|
|
|
&y $2
|
|
|
|
|
|
|
|
@draw-tl-scanlines
|
|
|
|
#0028 ,&y STR2
|
|
|
|
#0008 ,&x STR2
|
|
|
|
|
2021-08-16 04:26:23 +00:00
|
|
|
&whilelu
|
|
|
|
CENTER-Y ,&y LDR2 SUB2 #0010 DIV2 DUP2 ADD2 #0008 ADD2 ,&x STR2
|
2021-08-15 06:41:54 +00:00
|
|
|
CENTER-Y ,&y LDR2 LTH2 ,&endlu JCN
|
|
|
|
&ulscan #0040 ,&x LDR2 EQU2 ,&endulscan JCN
|
|
|
|
,&x LDR2 .Screen/x DEO2
|
|
|
|
,&y LDR2 .Screen/y DEO2
|
|
|
|
#03 .Screen/pixel DEO
|
|
|
|
,&x LDR2 #0001 ADD2 ,&x STR2 ,&ulscan JMP &endulscan
|
|
|
|
,&y LDR2 #0004 ADD2 ,&y STR2 ,&whilelu JMP &endlu
|
|
|
|
|
|
|
|
RTN
|
|
|
|
&x $2
|
|
|
|
&y $2
|
|
|
|
|
|
|
|
@draw-br-scanlines ( -> )
|
|
|
|
CENTER-Y ,&y STR2
|
2021-08-16 04:26:23 +00:00
|
|
|
.Screen/width DEI2 #0008 SUB2 ,&x STR2
|
2021-08-15 06:41:54 +00:00
|
|
|
|
|
|
|
&whilerd
|
2021-08-16 04:26:23 +00:00
|
|
|
.Screen/width DEI2 #0040 SUB2 ,&x STR2
|
2021-08-15 06:41:54 +00:00
|
|
|
.Screen/height DEI2 #0028 SUB2 ,&y LDR2 LTH2 ,&endrd JCN
|
2021-08-16 04:26:23 +00:00
|
|
|
&drscan .Screen/width DEI2 #0008 SUB2 ,&y LDR2 CENTER-Y SUB2 #0010 DIV2 DUP2 ADD2 SUB2 ,&x LDR2 EQU2 ,&enddrscan JCN
|
2021-08-15 06:41:54 +00:00
|
|
|
,&x LDR2 .Screen/x DEO2
|
|
|
|
,&y LDR2 .Screen/y DEO2
|
|
|
|
#03 .Screen/pixel DEO
|
2021-08-16 04:26:23 +00:00
|
|
|
,&x LDR2 #0001 ADD2 ,&x STR2 ,&drscan JMP &enddrscan
|
2021-08-15 06:41:54 +00:00
|
|
|
,&y LDR2 #0004 ADD2 ,&y STR2 ,&whilerd JMP &endrd
|
|
|
|
RTN
|
|
|
|
&x $2
|
|
|
|
&y $2
|
|
|
|
|
|
|
|
@draw-tr-scanlines
|
|
|
|
#0028 ,&y STR2
|
2021-08-16 04:26:23 +00:00
|
|
|
.Screen/width DEI2 #0008 SUB2 ,&x STR2
|
2021-08-15 06:41:54 +00:00
|
|
|
|
2021-08-16 04:26:23 +00:00
|
|
|
&whileru
|
|
|
|
.Screen/width DEI2 #0040 SUB2 ,&x STR2
|
2021-08-15 06:41:54 +00:00
|
|
|
CENTER-Y ,&y LDR2 LTH2 ,&endru JCN
|
2021-08-16 04:26:23 +00:00
|
|
|
&urscan .Screen/width DEI2 #0008 SUB2 CENTER-Y ,&y LDR2 SUB2 #0010 DIV2 DUP2 ADD2 SUB2 ,&x LDR2 EQU2 ,&endurscan JCN
|
2021-08-15 06:41:54 +00:00
|
|
|
,&x LDR2 .Screen/x DEO2
|
|
|
|
,&y LDR2 .Screen/y DEO2
|
|
|
|
#03 .Screen/pixel DEO
|
2021-08-16 04:26:23 +00:00
|
|
|
,&x LDR2 #0001 ADD2 ,&x STR2 ,&urscan JMP &endurscan
|
2021-08-15 06:41:54 +00:00
|
|
|
,&y LDR2 #0004 ADD2 ,&y STR2 ,&whileru JMP &endru
|
|
|
|
|
|
|
|
RTN
|
|
|
|
&x $2
|
|
|
|
&y $2
|
|
|
|
|
|
|
|
|
2021-08-11 20:14:53 +00:00
|
|
|
( constants )
|
|
|
|
@spritesheet "xrxs.chr 00
|
|
|
|
|
|
|
|
( sprites )
|
2021-08-14 06:53:17 +00:00
|
|
|
@blank $16
|
2021-08-15 06:41:54 +00:00
|
|
|
@uxnlogo $128
|
2021-08-11 20:14:53 +00:00
|
|
|
@xrxslogo $128
|