Basic rangefinding

This commit is contained in:
neauoire 2022-09-10 13:38:54 -07:00
parent a7ae3d0ca5
commit 08a6112a34
3 changed files with 37 additions and 12 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
.DS*
*jpg
*png
*bmp
/bin
*snarf
*theme
*nametable
*rom

Binary file not shown.

View File

@ -47,23 +47,39 @@ BRK
@on-frame ( -> )
;draw-map JSR2
.Mouse/x DEI2 #003c DIV2k MUL2 SUB2 .player/a STZ2
.player/x LDZ2
.player/y LDZ2
[ LIT2 &range 0020 ] STH2k ;raycast JSR2
#0060
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
OVR2 .player/y LDZ2 STH2kr #01 SFT2 SUB2 ADD2
;get-tile JSR2 #00 NEQ ,&color STR
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
#02 [ LIT &color $1 ] ADD ;draw-line JSR2
BRK
@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
@raycast ( range* -- x* y* )
STH2
@ -98,8 +114,8 @@ JMP2r
( draw player )
.player/x LDZ2 #0004 SUB2 .Screen/x DEO2
.player/y LDZ2 #0004 SUB2 .Screen/y DEO2
.player/x LDZ2 #0003 SUB2 .Screen/x DEO2
.player/y LDZ2 #0003 SUB2 .Screen/y DEO2
;player-icn .Screen/addr DEO2
#05 .Screen/sprite DEO
@ -120,8 +136,8 @@ JMP2r
@get-tile ( x* y* -- tile )
#03 SFT2 #0010 SFT2
#03 SFT2 ADD2 #0003 MUL2 ;nametable ADD2 LDZ
#43 SFT2 SWP2 #03 SFT2 ADD2 #0003 MUL2
;nametable ADD2 LDA2 NIP
JMP2r