From c5182fb624dc08b8e080c52f580df6240f2a9844 Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Sun, 1 Jun 2014 07:04:37 -0700 Subject: [PATCH] Fixed one sprite bug. --- .../virtual/src/raycast/javascript/intcast.js | 8 +- Platform/Apple/virtual/src/raycast/render.s | 76 ++++++++++++++++--- 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/Platform/Apple/virtual/src/raycast/javascript/intcast.js b/Platform/Apple/virtual/src/raycast/javascript/intcast.js index 90e975e9..95176542 100644 --- a/Platform/Apple/virtual/src/raycast/javascript/intcast.js +++ b/Platform/Apple/virtual/src/raycast/javascript/intcast.js @@ -73,10 +73,10 @@ var allSprites = [ // Player attributes [ref BigBlue2_10] var player = { - x : 1.5, // current x, y position - y : 3.5, + x : 4.2421875, // current x, y position + y : 6.4765625, dir : 0, // the direction that the player is turning, either -1 for left or 1 for right. - angleNum : 4, // the current angle of rotation + angleNum : 0xA, // the current angle of rotation speed : 0, // is the playing moving forward (speed = 1) or backwards (speed = -1). 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) @@ -85,7 +85,7 @@ var player = { var options = 0; -var debugRay = 0; /* Debugging info printed about this ray num, or null for none */ +var debugRay = 4; /* Debugging info printed about this ray num, or null for none */ var debugSprite = 0; /* Debugging info printed about this sprite, or null for none */ diff --git a/Platform/Apple/virtual/src/raycast/render.s b/Platform/Apple/virtual/src/raycast/render.s index 1348cdbe..e554201b 100644 --- a/Platform/Apple/virtual/src/raycast/render.s +++ b/Platform/Apple/virtual/src/raycast/render.s @@ -14,6 +14,7 @@ start: ; Conditional assembly flags DOUBLE_BUFFER = 1 ; whether to double-buffer DEBUG = 1 ; 1=some logging, 2=lots of logging +DEBUG_COLUMN = -1 ; Shared constants, zero page, buffer locations, etc. !source "render.i" @@ -28,6 +29,15 @@ DEBUG = 1 ; 1=some logging, 2=lots of logging MAX_SPRITES = 16 ; max # sprites visible at once NUM_COLS = 63 +; Starting position and dir. Eventually this will come from the map +;PLAYER_START_X = $180 ; 1.5 +;PLAYER_START_Y = $380 ; 3.5 +;PLAYER_START_DIR = 4 + +PLAYER_START_X = $43E ; 1.5 +PLAYER_START_Y = $67A ; 3.5 +PLAYER_START_DIR = $A + ; Useful constants W_LOG_256 = $0800 W_LOG_65536 = $1000 @@ -533,6 +543,7 @@ castRay: !zone lda #$FF ; clamp large line heights to 255 + tay ; save the height in Y reg pla ; get the depth back + !if DEBUG { jsr .debugDepth } jmp saveLink ; save final column data to link buffer !if DEBUG >= 2 { @@ -575,6 +586,18 @@ castRay: !zone +prA +crout rts +.debugDepth: + pha + lda screenCol + cmp #4 + bne + + +prStr : !text "depth for col4=",0 + pla + pha + +prA + +crout ++ pla + rts } ;------------------------------------------------------------------------------ @@ -1099,8 +1122,8 @@ drawSprite: !zone ; (can be used for further manipulation of the values there). ; saveLink: !zone - sta tmp ; keep height for storing later - sty tmp+1 ; same with depth + sta tmp ; keep depth for storing later + sty tmp+1 ; same with height ldx screenCol ldy firstLink,x bne .chk1 @@ -1119,9 +1142,10 @@ saveLink: !zone lda txNum sta txNumBuf,x inc nextLink + !if DEBUG { jsr .debugLink } rts .chk1 ; does it need to be inserted before the existing first link? - lda tmp+1 + lda tmp cmp depthBuf,y bcc .store ; advance to next link @@ -1134,10 +1158,41 @@ saveLink: !zone sta linkBuf,x bne .store2 ; always taken; also note: Y contains next link (0 for end of chain) .chk2 ; do we need to insert before this (non-first) link? - lda tmp+1 + lda tmp cmp depthBuf,y bcc .insert ; found the right place bcs .next ; not the right place to insert, look at next link (always taken) +!if DEBUG { +.debugLink: + lda screenCol + cmp #DEBUG_COLUMN + beq + + rts ++ txa + pha + +prStr : !text "Links for col ",0 + +prByte screenCol + +prStr : !text ": ",0 + ldx screenCol + ldy firstLink,x +.dlup +prStr : !text "[ht=",0 + lda heightBuf,y + +prA + +prStr : !text "tx=",0 + lda txNumBuf,y + +prA + +prStr : !text "dp=",0 + lda depthBuf,y + +prA + +prStr : !text "] ",0 + lda linkBuf,y + tay + bne .dlup + +crout + pla + tax + rts +} ; Advance pLine to the next line on the hi-res screen nextLine: !zone @@ -1582,18 +1637,15 @@ expanderJmp: ;------------------------------------------------------------------------------- ; Establish the initial player position and direction [ref BigBlue3_10] setPlayerPos: !zone - ; X=1.5 - lda #1 + lda #>PLAYER_START_X sta playerX+1 - lda #$80 + lda #PLAYER_START_Y sta playerY+1 - lda #$80 + lda #