From a7ae3d0ca58d602e50bdf3c2da1edff969c9f5d5 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 10 Sep 2022 12:19:31 -0700 Subject: [PATCH] Init ray --- ray/bin/ray.rom | Bin 0 -> 1645 bytes ray/build.sh | 34 +++++++ ray/etc/map.chr | Bin 0 -> 4096 bytes ray/etc/map.chr.nmt | Bin 0 -> 768 bytes ray/src/ray.tal | 227 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 261 insertions(+) create mode 100644 ray/bin/ray.rom create mode 100755 ray/build.sh create mode 100644 ray/etc/map.chr create mode 100644 ray/etc/map.chr.nmt create mode 100644 ray/src/ray.tal diff --git a/ray/bin/ray.rom b/ray/bin/ray.rom new file mode 100644 index 0000000000000000000000000000000000000000..0720557067f44cb1d9f41d95f3f3995d611c03b4 GIT binary patch literal 1645 zcmbtSOK2KV6upkd8b47X;7|e?t(^p0%=iJvv|tDX3NE{`ltL+WXGjpb>*Ba607x)Sy{1JZ6 zw-GD|*A}#bpr@dWphGB}v+!hu>oiRu1BxL?I}xr|=?yL~;3^eOxJ$ylmlm2D(^>F4 z=~rV(Tbbncf!w1A-8jR}x+=)MEj;^XTe!cOxLb(FSFsgyy~gKIVi&3Rf_&yuf$I;U1WzT% zQ)Gkbtr)SXd!Khjg}vmAUGcr$pEh1Vzw_pLPi{HBD5S@tG^Kdf5yuYD{ut*QLny*KOnrK^u$ zg}XfV+u&|ZN4VtU`!bg-)&%IpOdgmi8{MgSKr3E&)_FmA&5LC}Hg2jgRH(7qF{k)3 zzVjnd#C&N+_~vv(O{L{+2RhNNdam_S{rq5OSRPfz)k%GV$ zok4rp8a2m9+^kQk>B@zxE>yx^7T|{xPJpQ>-be)5Qik^ z9GvAG{vW;EJD0EUXXRX1o8Db!*>cXasQ)8llQytVk&N>c#)~prZ(K5=Etmt>)h`~+ l^Kh^&w>V@evt+pC45@K4S7WEAG?dwx{w> Cleaning" +rm -rf bin +mkdir bin + +if [[ "$*" == *"--lint"* ]] +then + echo ">> Linting $SRC" + $LIN $SRC $ETC +fi + +echo ">> Assembling $SRC" +$ASM $SRC $DST + +if [[ "$*" == *"--save"* ]] +then + echo ">> Saving $DST" + cp $DST $CPY +fi + +echo ">> Running $DST" +$EMU $DST $ARG diff --git a/ray/etc/map.chr b/ray/etc/map.chr new file mode 100644 index 0000000000000000000000000000000000000000..bec83dbe7325192fed1b34227821141594941c68 GIT binary patch literal 4096 zcmeIuu?+wq2n0Yza2$qncWt!5&XVN5A$%yvMbxa5+D6>|o$p<{edNs1?rRSdAV7cs Q0RjXF5FkK+0D&)o4RpjH?EnA( literal 0 HcmV?d00001 diff --git a/ray/etc/map.chr.nmt b/ray/etc/map.chr.nmt new file mode 100644 index 0000000000000000000000000000000000000000..3af9b3f426934a1b3c70640c4691df58731b8629 GIT binary patch literal 768 zcmbtSfeFAc2=j!U&=Y*o&le0x(515{By{ZMFVM|v1Q zu_b8R_#Z#twz|oOvrSiiJ1a+e&-6bkB^IeIRCEjYw3XjqE-XVMr~bJb_W+2+2w=-f X1tSGLs_eODGLY5tZ$V|da&__>T7!xK literal 0 HcmV?d00001 diff --git a/ray/src/ray.tal b/ray/src/ray.tal new file mode 100644 index 0000000..abc4838 --- /dev/null +++ b/ray/src/ray.tal @@ -0,0 +1,227 @@ +( 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 + + #0060 .player/x STZ2 + #0070 .player/y STZ2 + #0032 .player/a STZ2 + + ;draw-map JSR2 + +BRK + +( +@|vectors ) + +@on-frame ( -> ) + + .player/x LDZ2 + .player/y LDZ2 + [ LIT2 &range 0020 ] STH2k ;raycast JSR2 + + OVR2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2 + #03 SFT2 ;print JSR2 #2018 DEO + DUP2 .player/y LDZ2 STH2kr #01 SFT2 SUB2 ADD2 + #03 SFT2 ;print JSR2 #0a18 DEO + + SWP2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2 SWP2 + .player/y LDZ2 STH2r #01 SFT2 SUB2 ADD2 + #02 ;draw-line JSR2 + + ,&range LDR2 INC2 ,&range STR2 + +BRK + +@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 ) + + .player/x LDZ2 #0004 SUB2 .Screen/x DEO2 + .player/y LDZ2 #0004 SUB2 .Screen/y DEO2 + ;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 ) + + #03 SFT2 #0010 SFT2 + #03 SFT2 ADD2 #0003 MUL2 ;nametable ADD2 LDZ + +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 + +