Fix rendering bug when switching 3D map to 3D map. Fix keyboard teleport when switching maps. Fix redisplay of map name when changing section.

This commit is contained in:
Martin Haye 2015-06-30 09:27:10 -07:00
parent 03e0117537
commit a6876e8d39
2 changed files with 52 additions and 14 deletions

View File

@ -105,6 +105,7 @@ byte q_mapNum = 0
word q_x word q_x
word q_y word q_y
byte q_dir byte q_dir
word mapNameHash = 0
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Definitions used by assembly code // Definitions used by assembly code
@ -328,6 +329,40 @@ asm getXReg
rts rts
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Calculate 16-bit hash of a string
asm hashString
+asmPlasm 1
sta pTmp
sty pTmp+1
ldy #0
sty tmp+1
lda (pTmp),y
tax
iny
- clc
adc (pTmp),y
bcc +
inc tmp+1
+ asl
rol tmp+1
bcc +
ora #1
+ asl
rol tmp+1
bcc +
ora #1
+ asl
rol tmp+1
bcc +
ora #1
+ iny
dex
bne -
ldy tmp+1
rts
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Print a string // Print a string
asm puts asm puts
@ -956,6 +991,7 @@ def setMap(is3D, num, x, y, dir)
setWindow1(); clearWindow() setWindow1(); clearWindow()
displayChar('Y'-$40) // center mode displayChar('Y'-$40) // center mode
displayStr("Traveling...") displayStr("Traveling...")
mapNameHash = 0 // because we replaced the title text
displayChar('N'-$40) // normal mode displayChar('N'-$40) // normal mode
setMapWindow(); clearWindow() setMapWindow(); clearWindow()
setWindow2(); clearWindow() setWindow2(); clearWindow()
@ -969,6 +1005,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def kbdTeleport() def kbdTeleport()
byte d3, num
word x, y word x, y
byte dir byte dir
@ -979,9 +1016,10 @@ def kbdTeleport()
printf3("\nCurrent: X=%d Y=%d Facing=%d\n", x, y, getDir()) printf3("\nCurrent: X=%d Y=%d Facing=%d\n", x, y, getDir())
puts("3D : ") puts("3D : ")
mapIs3D = parseDec(readStr()) d3 = parseDec(readStr())
if d3 > 1; d3 = 1; fin
puts("Map: ") puts("Map: ")
mapNum = parseDec(readStr()) num = parseDec(readStr())
puts("X : ") puts("X : ")
x = parseDec(readStr()) x = parseDec(readStr())
puts("Y : ") puts("Y : ")
@ -991,7 +1029,7 @@ def kbdTeleport()
^$c052 ^$c052
setMap(mapIs3D, mapNum, x, y, dir) setMap(d3, num, x, y, dir)
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -1060,6 +1098,7 @@ end
// Set initial info for the scripts on this map: the trigger table and the name of the map. This // Set initial info for the scripts on this map: the trigger table and the name of the map. This
// is called by the init function for the scripts. // is called by the init function for the scripts.
def setScriptInfo(mapName, trigTbl) def setScriptInfo(mapName, trigTbl)
word newNameHash
// Grab the trigger table origins (used so the table can be more compact) // Grab the trigger table origins (used so the table can be more compact)
triggerOriginX = trigTbl=>0 triggerOriginX = trigTbl=>0
@ -1069,12 +1108,16 @@ def setScriptInfo(mapName, trigTbl)
triggerTbl = trigTbl + 4 triggerTbl = trigTbl + 4
// Display map name // Display map name
setWindow1() newNameHash = hashString(mapName)
clearWindow() if newNameHash <> mapNameHash
displayChar('Y'-$40) // center mode setWindow1()
displayStr(mapName) clearWindow()
displayChar('N'-$40) // normal mode displayChar('Y'-$40) // center mode
if mapIs3D; copyWindow(); fin displayStr(mapName)
displayChar('N'-$40) // normal mode
if mapIs3D; copyWindow(); fin
mapNameHash = newNameHash
fin
// Back to the main text window. // Back to the main text window.
setWindow2() setWindow2()

View File

@ -62,7 +62,6 @@ mapRayOrigin: !word 0
mapNum: !byte 1 mapNum: !byte 1
nMapSprites: !byte 0 ; number of sprite entries on map to fix up nMapSprites: !byte 0 ; number of sprite entries on map to fix up
nextLink: !byte 0 ; next link to allocate nextLink: !byte 0 ; next link to allocate
tablesInitted: !byte 0 ; 1 after init
plasmaStk: !byte 0 plasmaStk: !byte 0
skyColorEven: !byte $20 skyColorEven: !byte $20
@ -2027,16 +2026,12 @@ pl_initMap: !zone
; Proceed with loading ; Proceed with loading
jsr loadTextures jsr loadTextures
jsr copyScreen jsr copyScreen
lda tablesInitted
bne +
; Build all the unrolls and tables ; Build all the unrolls and tables
!if DEBUG { +prStr : !text "Making tables.",0 } !if DEBUG { +prStr : !text "Making tables.",0 }
jsr makeBlit jsr makeBlit
jsr makeClrBlit jsr makeClrBlit
jsr makeDecodeTbls jsr makeDecodeTbls
jsr makeLines jsr makeLines
+ lda #1
sta tablesInitted
jsr setExpansionCaller jsr setExpansionCaller
jsr graphInit jsr graphInit
jmp renderFrame jmp renderFrame