mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-14 10:30:24 +00:00
Fixed for broken scripting after loading new map sections.
This commit is contained in:
parent
907666c716
commit
2069140e31
@ -1794,7 +1794,12 @@ class PackPartitions
|
|||||||
emitCodeWord(vec_setScriptInfo)
|
emitCodeWord(vec_setScriptInfo)
|
||||||
emitCodeByte(0x30) // DROP
|
emitCodeByte(0x30) // DROP
|
||||||
|
|
||||||
// The table itself goes in the data segment.
|
// The table itself goes in the data segment. First comes the X
|
||||||
|
// and Y origins.
|
||||||
|
emitDataWord(xRange ? xRange[0] : 0)
|
||||||
|
emitDataWord(yRange ? yRange[0] : 0)
|
||||||
|
|
||||||
|
// Then the Y tables
|
||||||
triggers.each { y, xs ->
|
triggers.each { y, xs ->
|
||||||
emitDataByte(y)
|
emitDataByte(y)
|
||||||
def size = 2 // 2 bytes for y+off
|
def size = 2 // 2 bytes for y+off
|
||||||
|
@ -87,6 +87,7 @@ byte mapIs3D
|
|||||||
word pFont
|
word pFont
|
||||||
word pMap
|
word pMap
|
||||||
word cmdTbl[64]
|
word cmdTbl[64]
|
||||||
|
word triggerOriginX, triggerOriginY
|
||||||
word triggerTbl
|
word triggerTbl
|
||||||
byte redraw
|
byte redraw
|
||||||
byte frameLoaded = 0
|
byte frameLoaded = 0
|
||||||
@ -689,6 +690,8 @@ def checkScripts()
|
|||||||
if !triggerTbl; return; fin
|
if !triggerTbl; return; fin
|
||||||
setWindow2()
|
setWindow2()
|
||||||
getPos(@x, @y)
|
getPos(@x, @y)
|
||||||
|
x = x - triggerOriginX
|
||||||
|
y = y - triggerOriginY
|
||||||
p = triggerTbl
|
p = triggerTbl
|
||||||
while TRUE
|
while TRUE
|
||||||
if ^p == $FF
|
if ^p == $FF
|
||||||
@ -904,8 +907,12 @@ end
|
|||||||
// 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)
|
||||||
|
|
||||||
|
// Grab the trigger table origins (used so the table can be more compact)
|
||||||
|
triggerOriginX = trigTbl=>0
|
||||||
|
triggerOriginY = trigTbl=>2
|
||||||
|
|
||||||
// Record the trigger table pointer
|
// Record the trigger table pointer
|
||||||
triggerTbl = trigTbl
|
triggerTbl = trigTbl + 4
|
||||||
|
|
||||||
// Display map name
|
// Display map name
|
||||||
setWindow1()
|
setWindow1()
|
||||||
@ -1050,6 +1057,7 @@ loadTitle()
|
|||||||
setCallbacks()
|
setCallbacks()
|
||||||
mapIs3D = OVERMAP_IS_3D
|
mapIs3D = OVERMAP_IS_3D
|
||||||
mapNum = OVERMAP_NUM
|
mapNum = OVERMAP_NUM
|
||||||
|
//initMap(6, 123, 12) // per Seth. Need to have this in a script in the future
|
||||||
initMap(4, 4, 0)
|
initMap(4, 4, 0)
|
||||||
checkScripts()
|
checkScripts()
|
||||||
kbdLoop()
|
kbdLoop()
|
||||||
|
@ -89,7 +89,8 @@ ORIGIN_X = $A4 ; 16-bit origin for X (add REL_X to get avatar's global map X)
|
|||||||
ORIGIN_Y = $A6 ; 16-bit origin for Y (add REL_Y to get avatar's global map Y)
|
ORIGIN_Y = $A6 ; 16-bit origin for Y (add REL_Y to get avatar's global map Y)
|
||||||
AVATAR_DIR = $A8 ; direction (0-15, though only 0,4,8,12 are valid)
|
AVATAR_DIR = $A8 ; direction (0-15, though only 0,4,8,12 are valid)
|
||||||
PLASMA_X = $A9 ; save for PLASMA's X reg
|
PLASMA_X = $A9 ; save for PLASMA's X reg
|
||||||
next_zp = $AA
|
SCRIPTS_ID = $AA ; Module number of scripts
|
||||||
|
next_zp = $AB
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
;----------------------------------------------------------------------
|
||||||
; Here are the entry points for PLASMA code. Identical API for 2D and 3D.
|
; Here are the entry points for PLASMA code. Identical API for 2D and 3D.
|
||||||
@ -272,6 +273,12 @@ LOAD_ALL_TILES
|
|||||||
JSR LOAD_ALL_TILES
|
JSR LOAD_ALL_TILES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
!macro finishLoad keepOpen {
|
||||||
|
LDX #keepOpen ; 1 to keep open for next load, 0 for close so you can flip to HGR page 2
|
||||||
|
LDA #FINISH_LOAD
|
||||||
|
JSR mainLoader
|
||||||
|
}
|
||||||
|
|
||||||
FREE_SCRIPTS
|
FREE_SCRIPTS
|
||||||
+freeResource SCRIPTS_LOC
|
+freeResource SCRIPTS_LOC
|
||||||
RTS
|
RTS
|
||||||
@ -281,8 +288,9 @@ FREE_SCRIPTS
|
|||||||
}
|
}
|
||||||
|
|
||||||
!zone
|
!zone
|
||||||
LOAD_SCRIPTS
|
LOAD_SCRIPTS:
|
||||||
JSR CALC ; determine which map avatar is on
|
JSR CALC ; determine which map avatar is on
|
||||||
|
LOAD_SCRIPTS_NO_CALC:
|
||||||
LDA AVATAR_SECTION+1 ; no section? no scripts
|
LDA AVATAR_SECTION+1 ; no section? no scripts
|
||||||
BEQ .none
|
BEQ .none
|
||||||
LDY #5
|
LDY #5
|
||||||
@ -292,49 +300,43 @@ LOAD_SCRIPTS
|
|||||||
STA SCRIPTS_LOC
|
STA SCRIPTS_LOC
|
||||||
STA SCRIPTS_LOC+1
|
STA SCRIPTS_LOC+1
|
||||||
RTS
|
RTS
|
||||||
.got TAY ; resource # in Y
|
.got CMP SCRIPTS_ID
|
||||||
!if DEBUG {
|
BNE .diff
|
||||||
+prStr : !text "loadScripts ",0
|
+finishLoad 0 ; all done
|
||||||
+prY
|
RTS
|
||||||
}
|
.diff STA SCRIPTS_ID
|
||||||
|
TAY ; resource # in Y
|
||||||
LDX #RES_TYPE_MODULE
|
LDX #RES_TYPE_MODULE
|
||||||
LDA #QUEUE_LOAD
|
LDA #QUEUE_LOAD
|
||||||
JSR mainLoader
|
JSR mainLoader
|
||||||
!if DEBUG {
|
!if DEBUG {
|
||||||
|
+prStr : !text "loadScripts ",0
|
||||||
|
+prByte SCRIPTS_ID
|
||||||
+prStr : !text "-> ",0
|
+prStr : !text "-> ",0
|
||||||
+prYX
|
+prYX
|
||||||
+crout
|
+crout
|
||||||
}
|
}
|
||||||
STX SCRIPTS_LOC
|
STX SCRIPTS_LOC
|
||||||
STY SCRIPTS_LOC+1
|
STY SCRIPTS_LOC+1
|
||||||
|
+finishLoad 0 ; all done
|
||||||
|
!if DEBUG { +prStr : !text "Calling init script.",0 }
|
||||||
|
LDX PLASMA_X
|
||||||
|
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
|
||||||
|
JSR .callit ; perform script init
|
||||||
|
BIT setROM ; switch out PLASMA so we're ready to render
|
||||||
|
!if DEBUG { +prStr : !text "Back from init script.",0 }
|
||||||
RTS
|
RTS
|
||||||
|
.callit JMP (SCRIPTS_LOC) ; the init function is always first in the script module
|
||||||
|
|
||||||
!macro loadScripts {
|
!macro loadScripts {
|
||||||
JSR LOAD_SCRIPTS
|
JSR LOAD_SCRIPTS
|
||||||
}
|
}
|
||||||
|
|
||||||
!macro finishLoad keepOpen {
|
|
||||||
LDX #keepOpen ; 1 to keep open for next load, 0 for close so you can flip to HGR page 2
|
|
||||||
LDA #FINISH_LOAD
|
|
||||||
JSR mainLoader
|
|
||||||
}
|
|
||||||
|
|
||||||
FINISH_MAP_LOAD
|
FINISH_MAP_LOAD
|
||||||
+finishLoad 1 ; keep open for further loading
|
+finishLoad 1 ; keep open for further loading
|
||||||
+loadAllTiles
|
+loadAllTiles
|
||||||
+loadScripts
|
+loadScripts
|
||||||
+finishLoad 0 ; all done
|
|
||||||
LDA SCRIPTS_LOC+1 ; are there scripts?
|
|
||||||
BNE .scr ; yes, go init them
|
|
||||||
RTS ; no, we're done
|
|
||||||
.scr !if DEBUG { +prStr : !text "Calling script init.",0 }
|
|
||||||
LDX PLASMA_X
|
|
||||||
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
|
|
||||||
JSR .callit ; perform script init
|
|
||||||
BIT setROM ; switch out PLASMA so we're ready to render
|
|
||||||
!if DEBUG { +prStr : !text "Back from script init.",0 }
|
|
||||||
RTS
|
RTS
|
||||||
.callit JMP (SCRIPTS_LOC) ; the init function is always first in the script module
|
|
||||||
|
|
||||||
; >> CHECK CROSSINGS
|
; >> CHECK CROSSINGS
|
||||||
!zone
|
!zone
|
||||||
@ -1004,6 +1006,7 @@ SETPOS:
|
|||||||
STA NW_MAP_ID
|
STA NW_MAP_ID
|
||||||
STA NE_MAP_ID
|
STA NE_MAP_ID
|
||||||
STA SW_MAP_ID
|
STA SW_MAP_ID
|
||||||
|
STA SCRIPTS_ID
|
||||||
LDA INDEX_MAP_ID
|
LDA INDEX_MAP_ID
|
||||||
STA SE_MAP_ID
|
STA SE_MAP_ID
|
||||||
|
|
||||||
@ -1302,6 +1305,9 @@ pl_advance: !zone {
|
|||||||
BEQ .ret
|
BEQ .ret
|
||||||
INY ; moved and also new place is scripted, return 3.
|
INY ; moved and also new place is scripted, return 3.
|
||||||
.ret TYA
|
.ret TYA
|
||||||
|
PHA
|
||||||
|
JSR LOAD_SCRIPTS_NO_CALC ; we might have moved to a new place; load new scripts.
|
||||||
|
PLA
|
||||||
LDY #0 ; hi byte of return always zero
|
LDY #0 ; hi byte of return always zero
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user