Moved disk activity marker display logic to memory manager, so that it very accurately reflects real disk activity.

This commit is contained in:
Martin Haye 2016-09-22 07:51:07 -07:00
parent cfadecc9f6
commit 9b6c00bebb
4 changed files with 43 additions and 55 deletions

View File

@ -1145,6 +1145,7 @@ nSegsQueued: !byte 0
fixupHint: !word 0
bufferDigest: !fill 4
multiDiskMode: !byte 0 ; hardcoded to YES for now
diskActState: !byte 0
;------------------------------------------------------------------------------
; Heap management variables
@ -2133,6 +2134,8 @@ startHeaderScan: !zone
disk_queueLoad: !zone
stx resType ; save resource type
sty resNum ; and resource num
lda #$FF
jsr showDiskActivity ; graphical marker that disk activity happening
inc nSegsQueued ; record the fact that we're queuing a seg
lda partFileRef ; check if we've opened the file yet
bne + ; yes, don't re-open
@ -2171,7 +2174,13 @@ disk_queueLoad: !zone
sta reqLen+1 ; both bytes
!if DEBUG { +prStr : !text "uclen=",0 : +prWord reqLen : +crout }
jsr shared_alloc ; reserve memory for this resource (main or aux as appropriate)
stx tmp ; save lo part of addr temporarily
tya ; check for
ora isAuxCmd ; main memory
cmp #$20 ; hi-res page 1
bne +
lda #0 ; when loading hi-res page 1, reset the visible marker
sta diskActState
+ stx tmp ; save lo part of addr temporarily
ldx segNum ; get the segment number back
lda resType ; put resource type in segment descriptor
ora #$80 ; add 'active' flag
@ -2220,7 +2229,7 @@ disk_finishLoad: !zone
jsr doAllFixups ; found fixups - execute and free them
.done lda #0
sta nSegsQueued ; we loaded everything, so record that fact
rts
jmp showDiskActivity ; finally turn off disk activity marker (A is already zero)
.notdone:
bmi .load ; hi bit set -> queued for load
iny ; not set, not queued, so skip over it
@ -2974,6 +2983,37 @@ heapIntern: !zone
bne .cplup
beq .found ; always taken
;------------------------------------------------------------------------------
; Show or hide the disk activity icon (at the top of hi-res page 1). The icon consists of a 4x4
; block of blue pixels surrounded by a black border.
; Params: show/hide ($FF, or 0)
showDiskActivity: !zone
cmp diskActState
beq .done
sta diskActState
ldx #0
stx pTmp
ldy #$F8 ; offset of screen holes
lda #$20 ; first line of screen is $2000
- sta pTmp+1
cmp #$30 ; pre-check for last line
bit diskActState ; check mode
beq +
lda (pTmp,x) ; show mode
sta (pTmp),y
lda #$85
bcc ++ ; first 4 lines
lda #0 ; last line
beq ++ ; always taken
+ lda (pTmp),y ; hide mode
++ sta (pTmp,x)
lda pTmp+1
clc
adc #4
cmp #$34 ; Do 5 lines: $2000, $2400, $2800, $2C00, $3000; Stop before $3400.
bne -
.done rts
;------------------------------------------------------------------------------
; Segment tables

View File

@ -179,7 +179,6 @@ def _saveGame()
// Copy data to main memory
showMapName("Saving game...")
diskActivity($FF)
copyHeap(0) // LC to low mem
// Open the file if it already exists...
@ -206,7 +205,6 @@ def _saveGame()
// All done.
close_fileref = open_fileref
guaranteeMLI(MLI_CLOSE, @close_params)
diskActivity(0)
end
def loadInternal()
@ -242,17 +240,13 @@ end
def _loadGame()
setMapWindow()
clearWindow()
diskActivity($FF)
showMapName("Loading game...")
// Open the file
^$4000 = 0 // so 3D engine knows we overwrite HGR page 2, even if we fail
if !loadInternal()
diskActivity(0)
showMapName("Not found.")
getUpperKey()
else
diskActivity(0)
fin
end

View File

@ -23,7 +23,7 @@ import gamelib
predef streqi, strncpy, fatal, pause, tossStrings, charToUpper
predef addEncounterZone, clearEncounterZones, showMapName, setMapWindow, getMapWindow
predef addGold, countGold, payGold
predef calcPlayerArmor, diskActivity, rdkey, initHeap, scriptCombat, makeModifier
predef calcPlayerArmor, rdkey, initHeap, scriptCombat, makeModifier
predef giveItemToPlayer, takeItemFromPlayer, playerHasItem, getStat, setStat
predef setGameFlag, getGameFlag, scriptSetAvatar
predef addPlayerToParty, removePlayerFromParty, partyHasPlayer

View File

@ -641,38 +641,6 @@ asm auxMmgr
rts
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Show or hide the disk activity icon (at the top of hi-res page 1). The icon consists of a 4x4
// block of blue pixels surrounded by a black border.
// Params: show/hide ($FF, or 0)
export asm diskActivity
+asmPlasm 1
sta tmp ; save show(FF) / hide(0) flag
ldx #0
stx pTmp
ldy #$F8 ; offset of screen holes
lda #$20 ; first line of screen is $2000
- sta pTmp+1
cmp #$30 ; pre-check for last line
bit tmp ; check mode
beq +
lda (pTmp,x) ; show mode
sta (pTmp),y
lda #$85
bcc ++ ; first 4 lines
lda #0 ; last line
beq ++ ; always taken
+ lda (pTmp),y ; hide mode
++
sta (pTmp,x)
lda pTmp+1
clc
adc #4
cmp #$34 ; Do 5 lines: $2000, $2400, $2800, $2C00, $3000; Stop before $3400.
bne -
rts
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Jump straight to the system monitor
// Params: None
@ -1298,9 +1266,6 @@ def initMap(x, y, dir)
// Reset memory (our module will stay since memory manager locked it upon load)
mmgr(RESET_MEMORY, 0)
// Show disk activity icon while we load
diskActivity($FF)
// Load the raycaster or tile engine, and then the frame image.
mmgr(START_LOAD, 1) // partition 1 is where code lives
mmgr(SET_MEM_TARGET, displayEngine)
@ -1313,11 +1278,9 @@ def initMap(x, y, dir)
fin
mmgr(FINISH_LOAD, 0)
renderLoaded = TRUE
diskActivity(0)
loadFrameImg(mapIs3D+2)
// Load the map
diskActivity($FF)
mmgr(START_LOAD, 2) // partition 2 is where maps live
if mapIs3D
pMap = mmgr(QUEUE_LOAD, mapNum<<8 | RES_TYPE_3D_MAP)
@ -1325,7 +1288,6 @@ def initMap(x, y, dir)
pMap = mmgr(QUEUE_LOAD, mapNum<<8 | RES_TYPE_2D_MAP)
fin
mmgr(FINISH_LOAD, 0)
diskActivity(0)
// Clear all the windows to the background color (hi-bit set)
setWindow1()
@ -1393,9 +1355,7 @@ def doRender()
if !texturesLoaded
if mapIs3D
flipToPage1()
diskActivity($FF)
texControl(1)
diskActivity(0)
fin
texturesLoaded = TRUE
fin
@ -1793,11 +1753,9 @@ export def setPortrait(portraitNum)
restoreCursor()
// Load the portrait image and display it
diskActivity($FF)
mmgr(START_LOAD, 2) // portraits are in partition 2
curPortrait = auxMmgr(QUEUE_LOAD, portraitNum<<8 | RES_TYPE_PORTRAIT)
mmgr(FINISH_LOAD, 0)
diskActivity(0)
animFrame = 0
animFlags = readAuxByte(curPortrait)
animNumFrames = animFlags & $F
@ -1903,12 +1861,10 @@ def loadEngine(moduleNum)
if curEngine; fatal("dblEng"); fin
clearPortrait()
flipToPage1()
diskActivity($FF)
if renderLoaded; texControl(0); fin
mmgr(START_LOAD, 1) // code is in partition 1
curEngine = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0)
diskActivity(0)
return curEngine() // return function table
end
@ -2389,11 +2345,9 @@ export def createAndAddUnique(moduleID, creationFuncNum, pList)
unloadTextures()
// Load the module that is capable of creating the thing
diskActivity($FF)
mmgr(START_LOAD, 1) // code is in partition 1
p_module = mmgr(QUEUE_LOAD, moduleID<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0)
diskActivity(0)
// Figure out which creation function to call there, and create the thing
funcTbl = p_module()