mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-08-09 13:25:17 +00:00
Optimized switching to and from render modes.
This commit is contained in:
@@ -689,10 +689,12 @@ _prShared: !zone {
|
||||
sta .ld+1
|
||||
jsr _getStackByte
|
||||
sta .ld+2
|
||||
.ld: lda $2000,y
|
||||
.lup jsr restLCState
|
||||
.ld lda $2000,y
|
||||
bit setROM
|
||||
jsr ROM_prbyte ; not safePrbyte, because we already switched to ROM
|
||||
dey
|
||||
bpl .ld
|
||||
bpl .lup
|
||||
lda #$A0
|
||||
jsr ROM_cout ; not safeCout, because we already switched to ROM
|
||||
jmp __iorestLC
|
||||
@@ -1102,7 +1104,7 @@ gc2_sweep: !zone
|
||||
closePartFile: !zone
|
||||
lda partFileRef ; close the partition file
|
||||
beq .done
|
||||
!if DEBUG { +prStr : !text "Closing part file.",0 }
|
||||
!if DEBUG { +prStr : !text "ClosePart.",0 }
|
||||
jsr closeFile
|
||||
lda #0 ; zero out...
|
||||
sta partFileRef ; ... the file reference so we know it's no longer open
|
||||
@@ -1517,12 +1519,10 @@ reset: !zone
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
outOfMemErr: !zone
|
||||
jsr printMem
|
||||
jsr inlineFatal : !text "OutOfMem", 0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
reservedErr: !zone
|
||||
jsr printMem
|
||||
jsr inlineFatal : !text "DblAlloc", 0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -1693,7 +1693,6 @@ shared_scan: !zone
|
||||
+ rts
|
||||
|
||||
invalParam: !zone
|
||||
jsr printMem
|
||||
jsr inlineFatal : !text "InvalParam", 0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -1747,6 +1746,11 @@ mem_unlock: !zone
|
||||
mem_free: !zone
|
||||
clc ; do not check for active flg (ok to multiple free)
|
||||
jsr shared_scan ; scan for exact memory block
|
||||
pha
|
||||
and #$40 ; check lock flag
|
||||
beq +
|
||||
jmp invalParam ; must unlock block before freeing it (also prevents accidentally freeing $0000)
|
||||
+ pla
|
||||
and #$3F ; remove the 'active' and 'locked' flags
|
||||
sta tSegType,x ; store flags back
|
||||
and #$F ; get down to just the type, without the flags
|
||||
@@ -1991,7 +1995,7 @@ calcBufferDigest: !zone
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
openPartition: !zone
|
||||
!if DEBUG { +prStr : !text "Opening part file ",0 : +prByte curPartition : +crout }
|
||||
!if DEBUG { +prStr : !text "OpenPart ",0 : +prByte curPartition : +crout }
|
||||
; complete the partition file name, changing "1" to "2" if we're in multi-disk mode
|
||||
; and opening partition 2.
|
||||
.mkname ldx #1
|
||||
|
@@ -81,6 +81,7 @@ byte frameLoaded = 0
|
||||
byte heapLocked = FALSE
|
||||
byte skipScripts = FALSE
|
||||
byte allowZoneInit = FALSE
|
||||
word curEngine = NULL
|
||||
|
||||
// Queue setMap / teleport / start_encounter, since otherwise script might be replaced while executing
|
||||
byte q_mapIs3D = 0
|
||||
@@ -1331,8 +1332,8 @@ def initMap(x, y, dir)
|
||||
clearWindow()
|
||||
setWindow2()
|
||||
clearWindow()
|
||||
setWindow3()
|
||||
clearWindow()
|
||||
//setWindow3() // not needed, because showParty() does it for us
|
||||
//clearWindow()
|
||||
|
||||
// Clear the list of encounter zones from any previous maps
|
||||
if allowZoneInit
|
||||
@@ -1653,6 +1654,7 @@ export def setScriptInfo(mapName, trigTbl, wdt, hgt)
|
||||
totalMapHeight = hgt
|
||||
|
||||
// Display map name
|
||||
global=>s_mapName = mmgr(HEAP_INTERN, mapName)
|
||||
showMapName(mapName)
|
||||
|
||||
// Get ready for new encounter zones
|
||||
@@ -1898,30 +1900,37 @@ end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def loadEngine(moduleNum)
|
||||
word p_engine
|
||||
saveMapPos()
|
||||
if curEngine; fatal("dblEng"); fin
|
||||
clearPortrait()
|
||||
flipToPage1()
|
||||
diskActivity($FF)
|
||||
if renderLoaded and mapIs3D
|
||||
auxMmgr(FREE_MEMORY, expandVec)
|
||||
fin
|
||||
mmgr(RESET_MEMORY, 0)
|
||||
renderLoaded = FALSE
|
||||
nMapScripts = 0
|
||||
mapIs3D = FALSE
|
||||
curPortrait = NULL
|
||||
if renderLoaded; texControl(0); fin
|
||||
mmgr(START_LOAD, 1) // code is in partition 1
|
||||
p_engine = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE)
|
||||
curEngine = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE)
|
||||
mmgr(FINISH_LOAD, 0)
|
||||
diskActivity(0)
|
||||
return p_engine() // return function table
|
||||
return curEngine() // return function table
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def returnFromEngine()
|
||||
if curEngine
|
||||
mmgr(FREE_MEMORY, curEngine)
|
||||
curEngine = NULL
|
||||
clearPortrait()
|
||||
if renderLoaded; texControl(1); fin
|
||||
setWindow2(); clearWindow()
|
||||
mapNameHash = 0; showMapName(global=>s_mapName)
|
||||
doRender()
|
||||
showParty()
|
||||
fin
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load the Party engine and show data for the given player
|
||||
def showPlayerSheet(num)
|
||||
loadEngine(MODULE_PARTY)=>party_showPlayerSheet(num)
|
||||
restoreMapPos()
|
||||
returnFromEngine()
|
||||
end
|
||||
|
||||
def showPlayer1()
|
||||
@@ -1970,32 +1979,7 @@ end
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Called by user-defined map scripts to initiate a combat encounter.
|
||||
export def scriptCombat(mapCode)
|
||||
word pScripts
|
||||
word result
|
||||
|
||||
// Lock the currently running script in memory so combat engine doesn't destroy our calling
|
||||
// context.
|
||||
if renderLoaded
|
||||
pScripts = getMapScript()
|
||||
mmgr(LOCK_MEMORY, pScripts)
|
||||
else
|
||||
pScripts = NULL
|
||||
fin
|
||||
|
||||
// Also suppress running further scripts on this tile, since we're going to switch out the
|
||||
// rendering engine.
|
||||
skipScripts = TRUE
|
||||
|
||||
// Now run the combat
|
||||
result = doCombat(mapCode)
|
||||
|
||||
// Unlock the script module so it can get freed a the natural time (when it's done)
|
||||
if pScripts
|
||||
mmgr(UNLOCK_MEMORY, pScripts)
|
||||
fin
|
||||
|
||||
// Let the caller know what happened (1=won, 0=fled)
|
||||
return result
|
||||
return doCombat(mapCode)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -2018,7 +2002,7 @@ def doCombat(mapCode)
|
||||
playerDeath()
|
||||
return
|
||||
fin
|
||||
restoreMapPos()
|
||||
returnFromEngine()
|
||||
|
||||
// If the party fled the combat instead of winning, back up to previous square.
|
||||
if (!result)
|
||||
@@ -2058,7 +2042,7 @@ end
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def saveGame
|
||||
loadEngine(MODULE_DISKOPS)=>diskops_saveGame()
|
||||
restoreMapPos()
|
||||
returnFromEngine()
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -9,7 +9,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Garbage collection pointer offsets within each type
|
||||
byte typeTbl_Global[] = Global, p_players, p_enemyGroups, p_combatFirst, p_encounterZones, p_gameFlags, 0
|
||||
byte typeTbl_Global[] = Global, p_players, p_enemyGroups, p_combatFirst, p_encounterZones, s_mapName, p_gameFlags, 0
|
||||
byte typeTbl_Player[] = Player, p_nextObj, s_name, p_combatNext, p_skills, p_items, p_effects, 0
|
||||
byte typeTbl_Modifier[] = Modifier, p_nextObj, s_name, 0
|
||||
byte typeTbl_Effect[] = Effect, p_nextObj, s_name, 0
|
||||
|
@@ -25,6 +25,7 @@ struc Global
|
||||
word w_mapX
|
||||
word w_mapY
|
||||
byte b_mapDir
|
||||
word s_mapName
|
||||
|
||||
// Shared player gold amount
|
||||
word w_gold
|
||||
|
@@ -1672,11 +1672,12 @@ pl_texControl: !zone {
|
||||
- txa
|
||||
pha
|
||||
ldy texAddrHi,x
|
||||
beq + ; allow texControl(0) to work twice in a row
|
||||
lda texAddrLo,x
|
||||
tax
|
||||
lda #FREE_MEMORY
|
||||
jsr auxLoader
|
||||
pla
|
||||
+ pla
|
||||
tax
|
||||
lda #0
|
||||
sta texAddrLo,x
|
||||
|
Reference in New Issue
Block a user