Refactored code to save space when running standalone modules like combat and player-info.

This commit is contained in:
Martin Haye 2016-06-19 07:42:11 -07:00
parent db95a87e69
commit c352a867a2
2 changed files with 17 additions and 44 deletions

View File

@ -414,8 +414,8 @@ SWXX: bit monrts ; set V to denote SWX (not SBX)
.shst lda evalStkH+1,x ; get hi byte of pointer to store to .shst lda evalStkH+1,x ; get hi byte of pointer to store to
cmp #$D0 ; in $0000.CFFF range, cmp #$D0 ; in $0000.CFFF range,
bcc .norm ; just do normal store bcc .norm ; just do normal store
inc setLcRW+lcBank2 ; PLASMA normally write-protects the LC, sta setLcRW+lcBank2 ; PLASMA normally write-protects the LC,
inc setLcRW+lcBank2 ; but let's allow writing there. Don't use BIT as it affects V flg. sta setLcRW+lcBank2 ; but let's allow writing there. Don't use BIT as it affects V flg.
cmp #$E0 ; in $E000.FFFF range do normal store after write-enable cmp #$E0 ; in $E000.FFFF range do normal store after write-enable
bcs .norm bcs .norm
sty tmp sty tmp

View File

@ -1265,6 +1265,7 @@ def initMap(x, y, dir)
setWindow2() setWindow2()
initDisplay(mapNum, pMap, x, y, dir) initDisplay(mapNum, pMap, x, y, dir)
needRender = FALSE needRender = FALSE
textDrawn = FALSE
curPortrait = 0 curPortrait = 0
// Display the party characters // Display the party characters
@ -1861,29 +1862,24 @@ def restoreMapPos()
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Load the Party engine and show data for the given player def loadEngine(moduleNum)
def showPlayerSheet(num) word p_engine
word partyEngine
word x, y
byte dir
saveMapPos() saveMapPos()
// Load the party engine
flipToPage1() flipToPage1()
diskActivity($FF)
mmgr(RESET_MEMORY, 0) mmgr(RESET_MEMORY, 0)
renderLoaded = FALSE renderLoaded = FALSE
mmgr(START_LOAD, 1) // partition 1=code mmgr(START_LOAD, 1) // code is in partition 1
partyEngine = mmgr(QUEUE_LOAD, MODULE_PARTY<<8 | RES_TYPE_MODULE) p_engine = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, LEAVE_OPEN) mmgr(FINISH_LOAD, LEAVE_OPEN)
diskActivity(0)
return p_engine() // return function table
end
// Run the party engine ///////////////////////////////////////////////////////////////////////////////////////////////////
partyEngine()=>party_showPlayerSheet(num) // Load the Party engine and show data for the given player
def showPlayerSheet(num)
// Resume where we left off loadEngine(MODULE_PARTY)=>party_showPlayerSheet(num)
textDrawn = TRUE
clearPortrait()
setWindow2()
restoreMapPos() restoreMapPos()
end end
@ -1946,33 +1942,10 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def doCombat(mapCode) def doCombat(mapCode)
word combatEngine // Handled in a separate module. Clear enemies out of the heap when finished.
word x, y loadEngine(MODULE_COMBAT)=>combat_zoneEncounter(mapCode)
byte dir
saveMapPos()
// Load the combat engine
flipToPage1()
diskActivity($FF)
mmgr(RESET_MEMORY, 0)
renderLoaded = FALSE
mmgr(START_LOAD, 1) // code is in partition 1
combatEngine = mmgr(QUEUE_LOAD, MODULE_COMBAT<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, LEAVE_OPEN)
diskActivity(0)
// Run the combat engine
combatEngine()=>combat_zoneEncounter(mapCode)
// Clear enemies out of the heap
global=>p_enemyGroups = NULL global=>p_enemyGroups = NULL
mmgr(HEAP_COLLECT, 0) mmgr(HEAP_COLLECT, 0)
// Resume where we left off
textDrawn = TRUE
clearPortrait()
setWindow2()
restoreMapPos() restoreMapPos()
end end