2022-09-10 15:19:31 -04:00
|
|
|
( a blank file )
|
|
|
|
|
|
|
|
|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 @File0 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
|
|
|
|b0 @File1 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
|
|
|
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|
|
|
|
|
|
|
|
( variables )
|
|
|
|
|
|
|
|
|0000
|
|
|
|
|
|
|
|
@player
|
|
|
|
&x $2 &y $2 &a $2
|
|
|
|
@line
|
|
|
|
&x $2 &y $2 &dx $2 &dy $2 &e1 $2
|
|
|
|
|
|
|
|
( program )
|
|
|
|
|
|
|
|
|0100 ( -> )
|
|
|
|
|
|
|
|
( theme )
|
|
|
|
#0fe5 .System/r DEO2
|
|
|
|
#0fc5 .System/g DEO2
|
|
|
|
#0f25 .System/b DEO2
|
|
|
|
|
|
|
|
( vectors )
|
|
|
|
;on-frame .Screen/vector DEO2
|
2022-09-10 17:28:00 -04:00
|
|
|
;on-mouse .Mouse/vector DEO2
|
2022-09-10 17:32:54 -04:00
|
|
|
;on-button .Controller/vector DEO2
|
2022-09-10 15:19:31 -04:00
|
|
|
|
|
|
|
#0060 .player/x STZ2
|
|
|
|
#0070 .player/y STZ2
|
|
|
|
#0032 .player/a STZ2
|
|
|
|
|
|
|
|
;draw-map JSR2
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
(
|
|
|
|
@|vectors )
|
|
|
|
|
|
|
|
@on-frame ( -> )
|
|
|
|
|
2022-09-10 17:32:54 -04:00
|
|
|
.Controller/button DEI
|
|
|
|
DUP #10 NEQ ,&no-u JCN
|
|
|
|
.player/y LDZ2k #0001 SUB2 ROT STZ2
|
|
|
|
&no-u
|
|
|
|
DUP #20 NEQ ,&no-d JCN
|
|
|
|
.player/y LDZ2k #0001 ADD2 ROT STZ2
|
|
|
|
&no-d
|
|
|
|
DUP #40 NEQ ,&no-l JCN
|
|
|
|
.player/x LDZ2k #0001 SUB2 ROT STZ2
|
|
|
|
&no-l
|
|
|
|
DUP #80 NEQ ,&no-r JCN
|
|
|
|
.player/x LDZ2k #0001 ADD2 ROT STZ2
|
|
|
|
&no-r
|
|
|
|
POP
|
|
|
|
;draw-viewport JSR2
|
|
|
|
;draw-minimap JSR2
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-button ( -> )
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-10 17:28:00 -04:00
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-mouse ( -> )
|
|
|
|
|
|
|
|
;draw-viewport JSR2
|
|
|
|
;draw-minimap JSR2
|
|
|
|
|
|
|
|
BRK
|
|
|
|
|
|
|
|
(
|
|
|
|
@|drawing )
|
|
|
|
|
|
|
|
@draw-viewport ( -- )
|
|
|
|
|
|
|
|
#00 .Screen/auto DEO
|
|
|
|
#3c00
|
|
|
|
&h
|
|
|
|
#00 OVR #10 SFT2 #0090 ADD2 .Screen/x DEO2
|
|
|
|
#00 OVR .Mouse/x DEI2 ADD2 #003c DIV2k MUL2 SUB2 .player/a STZ2
|
|
|
|
( get distance ) ;cast JSR2 ;draw-col JSR2
|
|
|
|
INC GTHk ,&h JCN
|
|
|
|
POP2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@draw-col ( distance -- )
|
|
|
|
|
|
|
|
STH
|
|
|
|
#8000
|
|
|
|
&l
|
|
|
|
#00 OVR .Screen/y DEO2
|
|
|
|
DUP STHkr ;get-color JSR2 .Screen/pixel DEO
|
|
|
|
INC GTHk ,&l JCN
|
|
|
|
POP2
|
|
|
|
POPr
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@get-color ( y distance -- color )
|
|
|
|
|
|
|
|
OVR #40 GTH ,&bottom JCN
|
|
|
|
|
|
|
|
#01 SFT GTH INC
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
&bottom
|
|
|
|
#00 SWP SUB #01 SFT LTH INC
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@draw-minimap ( -- )
|
|
|
|
|
2022-09-10 16:38:54 -04:00
|
|
|
;draw-map JSR2
|
|
|
|
|
|
|
|
.Mouse/x DEI2 #003c DIV2k MUL2 SUB2 .player/a STZ2
|
|
|
|
|
2022-09-10 15:19:31 -04:00
|
|
|
.player/x LDZ2
|
|
|
|
.player/y LDZ2
|
2022-09-10 16:43:29 -04:00
|
|
|
|
2022-09-10 17:28:00 -04:00
|
|
|
[ #00 ;cast JSR2 ]
|
2022-09-10 16:38:54 -04:00
|
|
|
STH2k ;raycast JSR2
|
|
|
|
OVR2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2
|
|
|
|
OVR2 .player/y LDZ2 STH2kr #01 SFT2 SUB2 ADD2
|
|
|
|
;get-tile JSR2 #00 NEQ ,&color STR
|
2022-09-10 15:19:31 -04:00
|
|
|
SWP2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2 SWP2
|
|
|
|
.player/y LDZ2 STH2r #01 SFT2 SUB2 ADD2
|
2022-09-10 16:38:54 -04:00
|
|
|
#02 [ LIT &color $1 ] ADD ;draw-line JSR2
|
2022-09-10 15:19:31 -04:00
|
|
|
|
2022-09-10 17:28:00 -04:00
|
|
|
JMP2r
|
2022-09-10 15:19:31 -04:00
|
|
|
|
2022-09-10 16:38:54 -04:00
|
|
|
@cast ( -- range )
|
|
|
|
|
|
|
|
#8001
|
|
|
|
&r
|
|
|
|
#00 OVR STH2k ;raycast JSR2
|
|
|
|
SWP2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2
|
|
|
|
SWP2 .player/y LDZ2 STH2r #01 SFT2 SUB2 ADD2
|
|
|
|
;get-tile JSR2 #00 NEQ ,&collide JCN
|
|
|
|
INC GTHk ,&r JCN
|
|
|
|
&collide
|
|
|
|
NIP
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
2022-09-10 15:19:31 -04:00
|
|
|
@raycast ( range* -- x* y* )
|
|
|
|
|
|
|
|
STH2
|
|
|
|
.player/a LDZ2 #10 SFT2 ;sin60 ADD2 LDA2
|
|
|
|
#00 SWP STH2kr MUL2 #08 SFT2 ,&y STR2
|
|
|
|
#00 SWP STH2r MUL2 #08 SFT2 ,&x STR2
|
|
|
|
[ LIT2 &x $2 ]
|
|
|
|
[ LIT2 &y $2 ]
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@draw-map ( -- )
|
|
|
|
|
|
|
|
#01 .Screen/auto DEO
|
|
|
|
#0000 .Screen/y DEO2
|
|
|
|
#1000
|
|
|
|
&ver
|
|
|
|
STHk
|
|
|
|
#0000 .Screen/x DEO2
|
|
|
|
#1000
|
|
|
|
&hor
|
|
|
|
( id ) #00 OVR STHkr #40 SFT ADD
|
|
|
|
( addr* ) #0003 MUL2 ;nametable ADD2
|
|
|
|
LDA2k ;spritesheet ADD2 .Screen/addr DEO2
|
|
|
|
( color ) INC2 INC2 LDA .Screen/sprite DEO
|
|
|
|
INC GTHk ,&hor JCN
|
|
|
|
POP2
|
|
|
|
POPr
|
|
|
|
.Screen/y DEI2k #0008 ADD2 ROT DEO2
|
|
|
|
INC GTHk ,&ver JCN
|
|
|
|
POP2
|
|
|
|
|
|
|
|
( draw player )
|
|
|
|
|
2022-09-10 16:38:54 -04:00
|
|
|
.player/x LDZ2 #0003 SUB2 .Screen/x DEO2
|
|
|
|
.player/y LDZ2 #0003 SUB2 .Screen/y DEO2
|
2022-09-10 15:19:31 -04:00
|
|
|
;player-icn .Screen/addr DEO2
|
|
|
|
#05 .Screen/sprite DEO
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
#3c00
|
|
|
|
&a
|
|
|
|
#00 OVR .player/a STZ2
|
|
|
|
#ff00
|
|
|
|
&r
|
|
|
|
#00 OVR ;raycast JSR2 ;get-tile JSR2 #00 NEQ ,&collide JCN
|
|
|
|
INC GTHk ,&r JCN
|
|
|
|
&collide
|
|
|
|
POP2
|
|
|
|
INC GTHk ,&a JCN
|
|
|
|
POP2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@get-tile ( x* y* -- tile )
|
|
|
|
|
2022-09-10 16:38:54 -04:00
|
|
|
#43 SFT2 SWP2 #03 SFT2 ADD2 #0003 MUL2
|
|
|
|
;nametable ADD2 LDA2 NIP
|
2022-09-10 15:19:31 -04:00
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@draw-line ( x1* y1* x2* y2* color -- )
|
|
|
|
|
|
|
|
( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2
|
|
|
|
,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2
|
|
|
|
#0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2
|
|
|
|
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2
|
|
|
|
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2
|
|
|
|
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
|
|
|
|
&loop
|
|
|
|
.line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2
|
|
|
|
.line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2
|
|
|
|
STHkr .Screen/pixel DEO
|
|
|
|
AND ,&end JCN
|
|
|
|
.line/e1 LDZ2 DUP2 ADD2 DUP2
|
|
|
|
.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
|
|
|
|
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
|
|
|
|
.line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2
|
|
|
|
&skipy
|
|
|
|
.line/dx LDZ2 ;gts2 JSR2 ,&skipx JCN
|
|
|
|
.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
|
|
|
|
.line/y LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y STZ2
|
|
|
|
&skipx
|
|
|
|
,&loop JMP
|
|
|
|
&end
|
|
|
|
POPr
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@abs2 DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 JMP2r
|
|
|
|
@lts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r
|
|
|
|
@gts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r
|
|
|
|
|
|
|
|
@print ( short* -- )
|
|
|
|
|
|
|
|
SWP ,&byte JSR
|
|
|
|
&byte ( byte -- ) DUP #04 SFT ,&char JSR
|
|
|
|
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@print-str ( str* -- )
|
|
|
|
|
|
|
|
&while
|
|
|
|
LDAk #18 DEO
|
|
|
|
INC2 LDAk ,&while JCN
|
|
|
|
POP2
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@player-icn
|
|
|
|
0010 387c 3810 0000
|
|
|
|
|
|
|
|
@sin60 ( 60 positions on a circle )
|
|
|
|
8000 8d00 9a02 a706 b40b c011 cb18 d520
|
|
|
|
df2a e734 ee40 f44b f958 fd65 ff72 ff80
|
|
|
|
ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df
|
|
|
|
cbe7 c0ee b4f4 a7f9 9afd 8dff 80ff 72ff
|
|
|
|
65fd 58f9 4bf4 40ee 34e7 2adf 20d5 18cb
|
|
|
|
11c0 0bb4 06a7 029a 008d 0080 0072 0265
|
|
|
|
0658 0b4b 113f 1834 202a 2a20 3418 3f11
|
|
|
|
4b0b 5806 6502 7200
|
|
|
|
|
|
|
|
@spritesheet
|
|
|
|
0000 0000 0000 0000 0000 0000 0000 0000
|
|
|
|
ffff ffff ffff ffff 0000 0000 0000 0000
|
|
|
|
0000 0000 0000 0000 ffff ffff ffff ffff
|
|
|
|
ffff ffff ffff ffff ffff ffff ffff ffff
|
|
|
|
0000 0000 0000 0000 ffff ffff ffff ffff
|
|
|
|
ffff ffff ffff ffff ffff ffff ffff ffff
|
|
|
|
0000 0000 0000 0000 ffff ffff ffff ffff
|
|
|
|
ffff ffff ffff ffff ffff ffff ffff ffff
|
|
|
|
|
|
|
|
@nametable
|
|
|
|
|
|
|
|
0010 8100 1081 0010 8100 1081 0010 8100 1081 0010 8100 1081 0010 8100 1081 0010
|
|
|
|
8100 1081 0010 8100 1081 0010 8100 1081 0010 8100 0081 0000 8100 0081 0000 8100
|
|
|
|
0081 0000 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 1081
|
|
|
|
0010 8100 0081 0000 8100 0081 0000 8100 2081 0020 8100 0081 0000 8100 0081 0000
|
|
|
|
8100 0081 0000 8100 0081 0000 8100 1081 0010 8100 0081 0000 8100 0081 0000 8100
|
|
|
|
1081 0000 8100 0081 0010 8100 1081 0010 8100 1081 0010 8100 3081 0030 8100 1081
|
|
|
|
0010 8100 0081 0000 8100 0081 0000 8100 1081 0000 8100 0081 0000 8100 0081 0000
|
|
|
|
8100 0081 0000 8100 0081 0000 8100 1081 0010 8100 0081 0000 8100 0081 0000 8100
|
|
|
|
1081 0000 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 1081
|
|
|
|
0010 8100 0081 0000 8100 1081 0010 8100 1081 0010 8100 1081 0010 8100 1081 0000
|
|
|
|
8100 0081 0000 8100 0081 0000 8100 1081 0010 8100 0081 0000 8100 1081 0000 8100
|
|
|
|
0081 0000 8100 0081 0000 8100 2081 0020 8100 2081 0020 8100 0081 0000 8100 1081
|
|
|
|
0010 8100 0081 0000 8100 1081 0000 8100 0081 0000 8100 0081 0000 8100 1081 0000
|
|
|
|
8100 0081 0000 8100 0081 0000 8100 1081 0010 8100 0081 0000 8100 1081 0000 8100
|
|
|
|
0081 0000 8100 0081 0000 8100 1081 0000 8100 2081 0020 8100 2081 0020 8100 2081
|
|
|
|
0010 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 3081 0000
|
|
|
|
8100 0081 0000 8100 0081 0000 8100 2081 0020 8100 0081 0000 8100 0081 0000 8100
|
|
|
|
0081 0000 8100 0081 0000 8100 3081 0000 8100 0081 0000 8100 0081 0000 8100 2081
|
|
|
|
0020 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 1081 0000
|
|
|
|
8100 0081 0000 8100 0081 0000 8100 2081 0020 8100 0081 0010 8100 1081 0020 8100
|
|
|
|
2081 0020 8100 2081 0010 8100 1081 0000 8100 0081 0000 8100 0081 0000 8100 1081
|
|
|
|
0020 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 0081 0000 8100 0081 0000
|
|
|
|
8100 0081 0000 8100 0081 0000 8100 1081 0020 8100 2081 0020 8100 1081 0010 8100
|
|
|
|
1081 0010 8100 3081 0030 8100 3081 0010 8100 1081 0020 8100 2081 0010 8100 1081
|
|
|
|
|
|
|
|
|