From 3b55e1a336e4cc3a771d8d578f09e3990f107a6d Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Sun, 1 Sep 2013 10:37:33 -0700 Subject: [PATCH] Fixed several bugs in the ray caster. --- .../virtual/src/raycast/javascript/intcast.js | 6 ++-- Platform/Apple/virtual/src/raycast/render.s | 33 ++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Platform/Apple/virtual/src/raycast/javascript/intcast.js b/Platform/Apple/virtual/src/raycast/javascript/intcast.js index f9487d56..79a366f6 100644 --- a/Platform/Apple/virtual/src/raycast/javascript/intcast.js +++ b/Platform/Apple/virtual/src/raycast/javascript/intcast.js @@ -20,12 +20,12 @@ var map = [ ]; var player = { - x : 2.5, // current x, y position - y : 2.5, + x : 11.0, // current x, y position + y : 10.5, dir : 0, // the direction that the player is turning, either -1 for left or 1 for right. angleNum : 0, // the current angle of rotation speed : 0, // is the playing moving forward (speed = 1) or backwards (speed = -1). - moveSpeed : 0.5, // how far (in map units) does the player move each step/update + moveSpeed : 0.25, // how far (in map units) does the player move each step/update rotSpeed : 22.5 * Math.PI / 180 // how much does the player rotate each step/update (in radians) } diff --git a/Platform/Apple/virtual/src/raycast/render.s b/Platform/Apple/virtual/src/raycast/render.s index 5a1aef72..3272f513 100644 --- a/Platform/Apple/virtual/src/raycast/render.s +++ b/Platform/Apple/virtual/src/raycast/render.s @@ -42,7 +42,7 @@ pixNum = $C ; len 1 byteNum = $D ; len 1 pTmp = $E ; len 2 tmp = $10 ; len 2 -bacKBuf = $12 ; len 1 (value 0 or 1) +backBuf = $12 ; len 1 (value 0 or 1) frontBuf = $13 ; len 1 (value 0 or 1) pRayData = $14 ; len 2 playerX = $16 ; len 2 (hi=integer, lo=fraction) @@ -501,8 +501,8 @@ castRay: lda mapX ; map X is the integer byte sbc playerX+1 bit stepX - bmi :+ - ina ; if stepping forward, add one to dist + bpl :+ + ina ; if stepping backward, add one to dist : sta dist+1 ldx rayDirX ; parameters for wall calculation ldy rayDirY @@ -512,7 +512,7 @@ castRay: lda playerY ; fractional player pos clc adc txColumn - bit stepY ; if stepping forward in X... + bit stepX ; if stepping forward in X... bmi :+ eor #$FF ; ...invert the texture coord : sta txColumn @@ -675,6 +675,7 @@ castRay: DEBUG_STR "txCol=" DEBUG_BYTE txColumn DEBUG_LN + jsr rdkey .endif ; Advance pLine to the next line on the hi-res screen @@ -1101,7 +1102,7 @@ makeLines: ; Set screen lines to current back buf setBackBuf: ; calculate screen start - lda bacKBuf + lda backBuf asl asl asl @@ -1110,12 +1111,11 @@ setBackBuf: clc adc #$20 sta setAuxZP - sta $FF ldx #0 @lup: - lda 1,x - and #$1F - ora $FF + eor 1,x + and #$60 ; only two bits control the screen buf + eor 1,x sta 1,x inx inx @@ -1212,7 +1212,7 @@ test: sta playerX+1 lda #$80 sta playerX - ; Y=2.5 + ; Y=2.6 lda #2 sta playerY+1 lda #$80 @@ -1309,13 +1309,14 @@ test: .if DOUBLE_BUFFER lda #1 .endif - sta bacKBuf + sta backBuf - ;DEBUG_STR "Staying in text mode." - ;.if 0 + .if DEBUG + DEBUG_STR "Staying in text mode." + .else bit clrText bit setHires - ;.endif + .endif lda #63 sta lineCt @@ -1385,9 +1386,9 @@ test: @nextLevel: ; flip onto the screen .if DOUBLE_BUFFER - ldx bacKBuf + ldx backBuf lda frontBuf - sta bacKBuf + sta backBuf stx frontBuf lda page1,x .endif