Massaging load/unload with an eye to automap flushing.

This commit is contained in:
Martin Haye 2018-03-28 15:29:49 -07:00
parent 7350c47b89
commit 5d71d911a4
3 changed files with 33 additions and 24 deletions

View File

@ -273,16 +273,12 @@ QUEUE_LOAD = $16
;------------------------------------------------------------------------------
FINISH_LOAD = $17
; Input: X-reg = 0 to close out and release $4000.5fff,
; X-reg = 1 to keep open (for anticipated immediate queueing)
; Input: None
;
; Output: None
;
; Completes all prior QUEUE_LOAD requests, clearing the queue. It's the
; last part of a START_LOAD / QUEUE_LOAD / FINISH_LOAD sequence. If more
; loads are anticipated right away, set X-reg to 1 to keep the loader
; open which will make them faster. If no more loads right away, set
; X-reg to 0.
; last part of a START_LOAD / QUEUE_LOAD / FINISH_LOAD sequence.
;
; This command is acted upon by this loader and passed to chained loaders.

View File

@ -2231,6 +2231,9 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Load code and data, set up everything to display a 2D or 3D map
def initMap(x, y, dir)#0
// If we have a renderer loaded, let it know to flush automap marks
if renderLoaded; texControl(0); fin
// Reset memory (our module will stay since memory manager locked it upon load)
mmgr(RESET_MEMORY, 0)
renderLoaded = FALSE // leave it this way until all scripts done, else scriptDisplayStr renders

View File

@ -287,9 +287,8 @@ LOAD_ALL_TILES
JSR LOAD_ALL_TILES
}
!macro finishLoad keepOpen {
!macro finishLoad {
LDA #FINISH_LOAD
LDX #keepOpen
JSR mainLoader
}
@ -316,7 +315,7 @@ LOAD_SCRIPTS_NO_CALC:
RTS
.got CMP SCRIPTS_ID
BNE .diff
+finishLoad 1 ; all done
+finishLoad
RTS
.diff STA SCRIPTS_ID
PHA
@ -335,7 +334,7 @@ LOAD_SCRIPTS_NO_CALC:
}
STX SCRIPTS_LOC
STY SCRIPTS_LOC+1
+finishLoad 1 ; all done
+finishLoad
LDX PLASMA_X
JSR .callit ; perform script init
RTS
@ -346,9 +345,9 @@ LOAD_SCRIPTS_NO_CALC:
}
FINISH_MAP_LOAD
+finishLoad 1 ; keep open for further loading
+finishLoad
+loadAllTiles
+finishLoad 1 ; because loadScripts does a new START_LOAD
+finishLoad
+loadScripts
RTS
@ -1002,6 +1001,22 @@ pl_initMap: !zone
INX ; skip dir so that X/Y pos are at top of eval stack
JMP SETPOS
;----------------------------------------------------------------------
LOAD_ALL_SECTIONS:
+startLoad
LDA NW_MAP_ID
+loadSection NW_MAP_LOC
LDA NE_MAP_ID
+loadSection NE_MAP_LOC
LDA SW_MAP_ID
+loadSection SW_MAP_LOC
LDA SE_MAP_ID
+loadSection SE_MAP_LOC
RTS
!macro loadAllSections {
JSR LOAD_ALL_SECTIONS
}
;----------------------------------------------------------------------
; >> pl_setPos
; Params: X, Y
@ -1158,16 +1173,7 @@ SETPOS:
; At this point, all sections are correct,
; and REL_X, REL_Y, ORIGIN_X and ORIGIN_Y are set.
; Time to load the map segments.
loadAllSections:
+startLoad
LDA NW_MAP_ID
+loadSection NW_MAP_LOC
LDA NE_MAP_ID
+loadSection NE_MAP_LOC
LDA SW_MAP_ID
+loadSection SW_MAP_LOC
LDA SE_MAP_ID
+loadSection SE_MAP_LOC
+loadAllSections
JSR FINISH_MAP_LOAD
; Let the client choose when to render the first frame.
@ -1270,9 +1276,13 @@ pl_setDir:
pl_texControl: !zone {
tax
beq .unload
.load jmp loadAllSections
.load +loadAllSections
+finishLoad
+loadAllTiles
+finishLoad
RTS
.unload +freeAllTiles
+freeScripts
;NO: +freeScripts ; Note: leave scripts resident, in case they're running!
+freeResource NW_MAP_LOC
+freeResource NE_MAP_LOC
+freeResource SW_MAP_LOC