Getting 3D back into shape.

This commit is contained in:
Martin Haye 2015-05-07 10:17:38 -07:00
parent 64870ea6a8
commit 375cac1459
3 changed files with 57 additions and 10 deletions

View File

@ -148,6 +148,9 @@ end
asm setColor // params: slot (0=sky/1=ground), color (0-15) asm setColor // params: slot (0=sky/1=ground), color (0-15)
jmp $6015 jmp $6015
end end
asm render // no params
jmp $6018
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Simply retrieve the X register. Used to double-check that we're not leaking PLASMA eval // Simply retrieve the X register. Used to double-check that we're not leaking PLASMA eval
@ -697,6 +700,7 @@ end
def moveForward() def moveForward()
byte val byte val
val = advance() val = advance()
printf1("advance returned %d\n", val)
if val > 0 and textDrawn if val > 0 and textDrawn
clearWindow() clearWindow()
textDrawn = FALSE textDrawn = FALSE
@ -724,12 +728,16 @@ end
// Turn left (3D mode) // Turn left (3D mode)
def rotateLeft() def rotateLeft()
adjustDir(-1) adjustDir(-1)
render()
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Rotate to the right (3D mode) // Rotate to the right (3D mode)
def rotateRight() def rotateRight()
adjustDir(1) adjustDir(1)
puts("About to call render.\n")
render()
puts("Back from render.\n")
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -788,17 +796,17 @@ def teleport()
if ^$25 < 23; ^$25 = 23; fin if ^$25 < 23; ^$25 = 23; fin
getPos(@x, @y) getPos(@x, @y)
printf4("\nCurrent: 3D=%d Map=%d X=%d Y=%d ", mapIs3D, mapNum, x, y) printf4("\nCurrent: 3D=%d Map=%d X=%d Y=%d ", mapIs3D, mapNum, x, y)
printf1(" Dir=%d\n", getDir()) printf1("Dir=%d\n", getDir())
puts("New 3D: ") puts("3D : ")
mapIs3D = parseDec(readStr()) mapIs3D = parseDec(readStr())
puts("New Map: ") puts("Map: ")
mapNum = parseDec(readStr()) mapNum = parseDec(readStr())
puts("New X: ") puts("X : ")
x = parseDec(readStr()) x = parseDec(readStr())
puts("New Y: ") puts("Y : ")
y = parseDec(readStr()) y = parseDec(readStr())
puts("New Dir: ") puts("Dir: ")
dir = parseDec(readStr()) dir = parseDec(readStr())
^$c052 ^$c052
@ -809,6 +817,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def oldTeleport(x, y, dir) def oldTeleport(x, y, dir)
printf3("Old teleport: x=%d y=%d dir=%d\n", x, y, dir) printf3("Old teleport: x=%d y=%d dir=%d\n", x, y, dir)
puts("Doing nothing for now.\n")
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -19,6 +19,7 @@ start:
jmp pl_setDir ; params: dir (0-15); return: nothing jmp pl_setDir ; params: dir (0-15); return: nothing
jmp pl_advance ; params: none; return: 0 if same, 1 if new map tile, 2 if new and scripted jmp pl_advance ; params: none; return: 0 if same, 1 if new map tile, 2 if new and scripted
jmp pl_setColor ; params: slot (0=sky/1=ground), color (0-15); return: nothing jmp pl_setColor ; params: slot (0=sky/1=ground), color (0-15); return: nothing
jmp pl_render ; params: none
; Conditional assembly flags ; Conditional assembly flags
DOUBLE_BUFFER = 1 ; whether to double-buffer DOUBLE_BUFFER = 1 ; whether to double-buffer
@ -1689,7 +1690,7 @@ pl_advance: !zone
lda playerX+1 lda playerX+1
pha pha
adc walkDirs+1,x adc walkDirs+1,x
sta playerX sta playerX+1
lda playerY lda playerY
pha pha
@ -1700,6 +1701,7 @@ pl_advance: !zone
pha pha
clc clc
adc walkDirs+3,x adc walkDirs+3,x
sta playerY+1
; Check if the new position is blocked ; Check if the new position is blocked
jsr calcMapOrigin jsr calcMapOrigin
@ -1715,6 +1717,7 @@ pl_advance: !zone
and #2 ; tile flag 2 is for obstructions and #2 ; tile flag 2 is for obstructions
beq .ok beq .ok
; Blocked! Restore old position. ; Blocked! Restore old position.
+prStr : !text "Blocked.", 0
pla pla
sta playerY+1 sta playerY+1
pla pla
@ -1742,10 +1745,10 @@ pl_advance: !zone
; It is a new position. Is script hint set? ; It is a new position. Is script hint set?
ldy playerX+1 ldy playerX+1
lda (pMap),y lda (pMap),y
ldy #1 ldy #1 ; ret val 1 = new blk but no script
and #$20 ; map flag $20 is the script hint and #$20 ; map flag $20 is the script hint
beq .done ; if not scripted, return one beq .done ; if not scripted, return one
iny ; else return 2 iny ; else return 2 = new blk and a script
.done pla .done pla
tax ; restore PLASMA eval stk pos tax ; restore PLASMA eval stk pos
dex ; make room for return value dex ; make room for return value
@ -1756,6 +1759,22 @@ pl_advance: !zone
bit setLcRW+lcBank2 ; switch PLASMA runtime back in bit setLcRW+lcBank2 ; switch PLASMA runtime back in
rts ; and return to PLASMA rts ; and return to PLASMA
;-------------------------------------------------------------------------------
; Render at the current position and direction.
; Params: none
; Return: none
pl_render: !zone
txa
pha ; save PLASMA eval stk pos
bit setROM ; switch out PLASMA while we work
jsr renderFrame
pla
tax ; restore PLASMA eval stk pos
jsr prbyte
jsr crout
bit setLcRW+lcBank2 ; switch PLASMA runtime back in
rts ; and return to PLASMA
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
; Cast all the rays from the current player coord ; Cast all the rays from the current player coord
castAllRays: !zone castAllRays: !zone
@ -1946,6 +1965,7 @@ pl_setPos: !zone {
lda #$80 lda #$80
sta playerY sta playerY
sta playerX sta playerX
inx ; 2 params - 1 ret = +1
rts rts
} }
@ -1955,6 +1975,7 @@ pl_setPos: !zone {
; Returns: Nothing ; Returns: Nothing
pl_getDir: !zone { pl_getDir: !zone {
lda playerDir lda playerDir
dex
sta evalStkL,x sta evalStkL,x
lda #0 lda #0
sta evalStkH,x sta evalStkH,x
@ -1969,6 +1990,7 @@ pl_setDir: !zone {
lda evalStkL,x lda evalStkL,x
and #15 and #15
sta playerDir sta playerDir
dex ; 0 param - 1 ret = -1
rts rts
} }

View File

@ -101,6 +101,7 @@ next_zp = $AA
JMP pl_setDir ; params: dir (0-15); return: nothing JMP pl_setDir ; params: dir (0-15); return: nothing
JMP pl_advance ; params: none; return: 0 if same, 1 if new map tile, 2 if new and scripted JMP pl_advance ; params: none; return: 0 if same, 1 if new map tile, 2 if new and scripted
JMP pl_setColor ; params: slot (0=sky/1=ground), color (0-15); return: nothing JMP pl_setColor ; params: slot (0=sky/1=ground), color (0-15); return: nothing
jmp pl_render ; params: none
; Debug support -- must come after jump vectors, since it's not just macros. ; Debug support -- must come after jump vectors, since it's not just macros.
!source "../include/debug.i" !source "../include/debug.i"
@ -1167,7 +1168,8 @@ pl_setPos:
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
PLA ; restore PLASMA's eval stk pos PLA ; restore PLASMA's eval stk pos
TAX TAX
INX ; toss 1 slot (params=2, ret=1, diff=1) INX ; toss 1 slot (params=2, ret=0, diff=2)
INX
RTS RTS
;---------------------------------------------------------------------- ;----------------------------------------------------------------------
@ -1343,6 +1345,20 @@ pl_advance: !zone {
RTS RTS
} }
;----------------------------------------------------------------------
; >> pl_render
; Params: none; return: none
; Draw at the current position.
pl_render: !zone {
STX PLASMA_X ; save PLASMA eval stk pos
BIT setROM ; switch out PLASMA while we work
JSR DRAW
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
RTS
}
tblHGRl tblHGRl
!byte $00,$80,$00,$80,$00,$80,$00,$80 !byte $00,$80,$00,$80,$00,$80,$00,$80
!byte $28,$A8,$28,$A8,$28,$A8,$28,$A8 !byte $28,$A8,$28,$A8,$28,$A8,$28,$A8