mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-03 06:54:42 +00:00
Added code to display % heap memory in use.
This commit is contained in:
parent
3e54dcf80c
commit
ea25619c78
@ -1588,7 +1588,7 @@ class A2PackPartitions
|
|||||||
def hourCode = (char) (97 + hour) // 'a'=0, 'b'=1, etc.
|
def hourCode = (char) (97 + hour) // 'a'=0, 'b'=1, etc.
|
||||||
def engineCode = String.format("%d%c%02d%c", yearCode, monthCode, day, hourCode)
|
def engineCode = String.format("%d%c%02d%c", yearCode, monthCode, day, hourCode)
|
||||||
|
|
||||||
def offset = (int) ((scenarioStamp - engineStamp) / (1000 * 60 * 60))
|
def offset = Math.max(-99, Math.min(99, (int) ((scenarioStamp - engineStamp) / (1000 * 60 * 60))))
|
||||||
return String.format("%s%s%d", engineCode, offset < 0 ? "-" : ".", Math.abs(offset))
|
return String.format("%s%s%d", engineCode, offset < 0 ? "-" : ".", Math.abs(offset))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +107,9 @@ SetFont JMP DoSetFont ;API call address
|
|||||||
;Set the window boundaries (byte-oriented bounds)
|
;Set the window boundaries (byte-oriented bounds)
|
||||||
SetWindow JMP SetWnd ;API call address
|
SetWindow JMP SetWnd ;API call address
|
||||||
|
|
||||||
|
;Set the window boundaries (byte-oriented bounds)
|
||||||
|
GetWindow JMP GetWnd ;API call address
|
||||||
|
|
||||||
;Clear the window
|
;Clear the window
|
||||||
ClearWindow JMP ClrHome ;API call address
|
ClearWindow JMP ClrHome ;API call address
|
||||||
|
|
||||||
@ -613,6 +616,29 @@ SetWnd LDA evalStkL+SW_TOP,X ;get top coord
|
|||||||
STA WrdWdth
|
STA WrdWdth
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
;Routine: Get the cursor position (relative to the current window)
|
||||||
|
GetWnd DEX
|
||||||
|
LDY #0
|
||||||
|
LDA CursY ; top
|
||||||
|
STA evalStkL,X
|
||||||
|
TYA
|
||||||
|
STA evalStkH,X
|
||||||
|
DEX ; bottom
|
||||||
|
STA evalStkH,X
|
||||||
|
LDA CursYb ; bottom
|
||||||
|
STA evalStkL,X
|
||||||
|
DEX
|
||||||
|
LDA CursXl ; left
|
||||||
|
STA evalStkL,X
|
||||||
|
LDA CursXh
|
||||||
|
STA evalStkH,X
|
||||||
|
DEX
|
||||||
|
LDA CursXrl ; right
|
||||||
|
STA evalStkL,X
|
||||||
|
LDA CursXrh
|
||||||
|
STA evalStkH,X
|
||||||
|
RTS
|
||||||
|
|
||||||
;Routine: Scroll screen up 1 character line
|
;Routine: Scroll screen up 1 character line
|
||||||
;This routine scrolls a window defined by
|
;This routine scrolls a window defined by
|
||||||
;Left, Right, Top, Bottom - Margin parameters.
|
;Left, Right, Top, Bottom - Margin parameters.
|
||||||
|
@ -37,7 +37,8 @@ fontEngine = $EC00
|
|||||||
fontEngineLen = $F00 ; maximum (allows for some debug code)
|
fontEngineLen = $F00 ; maximum (allows for some debug code)
|
||||||
SetFont = fontEngine
|
SetFont = fontEngine
|
||||||
SetWindow = SetFont+3
|
SetWindow = SetFont+3
|
||||||
ClearWindow = SetWindow+3
|
GetWindow = SetWindow+3
|
||||||
|
ClearWindow = GetWindow+3
|
||||||
CopyWindow = ClearWindow+3
|
CopyWindow = ClearWindow+3
|
||||||
DisplayChar = CopyWindow+3
|
DisplayChar = CopyWindow+3
|
||||||
DisplayStr = DisplayChar+3
|
DisplayStr = DisplayChar+3
|
||||||
|
@ -225,11 +225,9 @@ end
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def _saveGame()#1
|
def _saveGame()#1
|
||||||
// Never save corrupted heap
|
|
||||||
mmgr(CHECK_MEM, 0)
|
|
||||||
|
|
||||||
// Perform garbage collection and record the size of the heap so we can restore it correctly
|
// Perform garbage collection and record the size of the heap so we can restore it correctly
|
||||||
global=>w_heapSize = mmgr(HEAP_COLLECT, 0) - HEAP_BOTTOM
|
// (also does a CHECK_MEM to be sure we never save corrupted heap)
|
||||||
|
heapCollect()
|
||||||
|
|
||||||
// Copy data to main memory, and write it out.
|
// Copy data to main memory, and write it out.
|
||||||
memcpy(HEAP_BOTTOM, LOAD_SAVE_BUF, HEAP_SIZE) // LC to low mem
|
memcpy(HEAP_BOTTOM, LOAD_SAVE_BUF, HEAP_SIZE) // LC to low mem
|
||||||
@ -253,7 +251,7 @@ def loadInternal()#1
|
|||||||
fin
|
fin
|
||||||
memcpy(LOAD_SAVE_BUF, HEAP_BOTTOM, HEAP_SIZE) // low mem to LC
|
memcpy(LOAD_SAVE_BUF, HEAP_BOTTOM, HEAP_SIZE) // low mem to LC
|
||||||
initHeap(p_loaded=>w_heapSize)
|
initHeap(p_loaded=>w_heapSize)
|
||||||
mmgr(CHECK_MEM, 0) // make sure heap is valid
|
heapCollect() // make sure heap is valid, and record final size
|
||||||
return TRUE
|
return TRUE
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -412,6 +410,7 @@ def newGame()#0
|
|||||||
if global=>p_players->b_skillPoints
|
if global=>p_players->b_skillPoints
|
||||||
partyModule()=>party_showPlayerSheet(0)
|
partyModule()=>party_showPlayerSheet(0)
|
||||||
fin
|
fin
|
||||||
|
heapCollect()
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -61,6 +61,7 @@ import gamelib
|
|||||||
predef getYN()#1
|
predef getYN()#1
|
||||||
predef girdPlayer(player)#0
|
predef girdPlayer(player)#0
|
||||||
predef giveItemToPlayer(p_player, itemFuncNum)#0
|
predef giveItemToPlayer(p_player, itemFuncNum)#0
|
||||||
|
predef heapCollect()#0
|
||||||
predef hisHerTheir(c_gender)#1
|
predef hisHerTheir(c_gender)#1
|
||||||
predef initHeap(loadedSize)#0
|
predef initHeap(loadedSize)#0
|
||||||
predef initPlayerXP(player)#0
|
predef initPlayerXP(player)#0
|
||||||
|
@ -98,6 +98,7 @@ word pGlobalTileset = NULL
|
|||||||
byte curMapPartition = 0
|
byte curMapPartition = 0
|
||||||
export word pGodModule = NULL
|
export word pGodModule = NULL
|
||||||
export word typeHash = 0
|
export word typeHash = 0
|
||||||
|
word curHeapPct = 0
|
||||||
|
|
||||||
// Queue setMap / teleport / start_encounter, since otherwise script might be replaced while executing
|
// Queue setMap / teleport / start_encounter, since otherwise script might be replaced while executing
|
||||||
byte q_mapIs3D = 0
|
byte q_mapIs3D = 0
|
||||||
@ -797,6 +798,14 @@ export asm setWindow(top, bottom, left, right)#0
|
|||||||
jmp SetWindow
|
jmp SetWindow
|
||||||
end
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Get the font engine's current text window
|
||||||
|
// Returns: top, bottom, left, right
|
||||||
|
export asm getWindow()#4
|
||||||
|
bit setLcRW+lcBank2
|
||||||
|
jmp GetWindow
|
||||||
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Get the cursor position - returns X, Y
|
// Get the cursor position - returns X, Y
|
||||||
export asm getCursor()#2
|
export asm getCursor()#2
|
||||||
@ -1358,33 +1367,75 @@ export def setGround(num)#0
|
|||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def printVersion()#0
|
def printAtBottom(str, textX, botLeft, botRight, strX)#0
|
||||||
word p, len, cv, ch
|
byte cv
|
||||||
if !pResourceIndex; return; fin
|
word origX, origY, origTop, origBottom, origLeft, origRight
|
||||||
|
|
||||||
|
// Save text cursor, and print at bottom of text window
|
||||||
cv = ^$25
|
cv = ^$25
|
||||||
^$23 = 24 // full height window
|
^$23 = 24 // full height window
|
||||||
^$25 = 22
|
^$25 = 22
|
||||||
crout()
|
crout()
|
||||||
^$24 = 25
|
^$24 = textX
|
||||||
puts("V")
|
puts(str)
|
||||||
setWindow(183, 192, 161, 261)
|
|
||||||
clearWindow()
|
|
||||||
setWindow(183, 192, 168, 252)
|
|
||||||
rawDisplayStr("^YV")
|
|
||||||
p = pResourceIndex
|
|
||||||
len = readAuxByte(p)
|
|
||||||
while len
|
|
||||||
p++
|
|
||||||
ch = readAuxByte(p)
|
|
||||||
printChar(ch)
|
|
||||||
displayChar(ch)
|
|
||||||
len--
|
|
||||||
loop
|
|
||||||
rawDisplayStr("^N")
|
|
||||||
^$23 = 23 // shrink window to protect version num
|
^$23 = 23 // shrink window to protect version num
|
||||||
^$25 = cv-1
|
^$25 = cv-1
|
||||||
crout()
|
crout()
|
||||||
setWindow2()
|
|
||||||
|
// Save graphics cursor and window
|
||||||
|
origX, origY = getCursor()
|
||||||
|
origTop, origBottom, origLeft, origRight = getWindow()
|
||||||
|
|
||||||
|
// Establish new graphics window, clear it, and display the string
|
||||||
|
setWindow(183, 192, botLeft, botRight)
|
||||||
|
clearWindow()
|
||||||
|
rawDisplayStr("^T") // do not use printf variants, since it might overwrite str
|
||||||
|
rawDisplayStr(convert3Dec(strX))
|
||||||
|
rawDisplayStr(str)
|
||||||
|
if mapIs3D and texturesLoaded; copyWindow(); fin
|
||||||
|
|
||||||
|
// Restore original graphics cursor and window
|
||||||
|
setWindow(origTop, origBottom, origLeft, origRight)
|
||||||
|
setCursor(origX, origY)
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def printHeapPct()#0
|
||||||
|
word str, len
|
||||||
|
str = sprintf1("%d%%", curHeapPct)
|
||||||
|
len = calcWidth(str)
|
||||||
|
printAtBottom(str, 36, 240, 268, (28-len) >> 1) // center
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def printVersion()#0
|
||||||
|
word p
|
||||||
|
byte len
|
||||||
|
if !pResourceIndex; return; fin
|
||||||
|
|
||||||
|
buildString(@addToString)
|
||||||
|
printChar('V')
|
||||||
|
p = pResourceIndex
|
||||||
|
len = readAuxByte(p)
|
||||||
|
while len
|
||||||
|
p++; printChar(readAuxByte(p)); len--
|
||||||
|
loop
|
||||||
|
p = finishString(FALSE)
|
||||||
|
len = calcWidth(p)
|
||||||
|
printAtBottom(p, 25, 154, 154 + len + 8, 3)
|
||||||
|
printHeapPct()
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
export def heapCollect()#0
|
||||||
|
word pct
|
||||||
|
mmgr(CHECK_MEM, 0)
|
||||||
|
global=>w_heapSize = mmgr(HEAP_COLLECT, 0) - HEAP_BOTTOM
|
||||||
|
pct = min(99, max(0, ((global=>w_heapSize / 10) * 100) / 307))
|
||||||
|
if pct <> curHeapPct
|
||||||
|
curHeapPct = pct
|
||||||
|
printHeapPct()
|
||||||
|
fin
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -2463,8 +2514,7 @@ def doCombat(mapCode, backUpOnFlee)#1
|
|||||||
// Handled in a separate module. Clear enemies out of the heap when finished.
|
// Handled in a separate module. Clear enemies out of the heap when finished.
|
||||||
result = loadEngine(MOD_COMBAT)=>combat_zoneEncounter(mapCode)
|
result = loadEngine(MOD_COMBAT)=>combat_zoneEncounter(mapCode)
|
||||||
global=>p_enemyGroups = NULL
|
global=>p_enemyGroups = NULL
|
||||||
mmgr(CHECK_MEM, 0)
|
heapCollect()
|
||||||
mmgr(HEAP_COLLECT, 0)
|
|
||||||
|
|
||||||
if (result == -99)
|
if (result == -99)
|
||||||
playerDeath()
|
playerDeath()
|
||||||
|
@ -279,6 +279,7 @@ def selectThing(moduleNum, nThings, nSkip, prompt)#1
|
|||||||
|
|
||||||
mmgr(FREE_MEMORY, pModule)
|
mmgr(FREE_MEMORY, pModule)
|
||||||
^$c050
|
^$c050
|
||||||
|
heapCollect()
|
||||||
return nFunc
|
return nFunc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -778,8 +778,7 @@ def _showPlayerSheet(player_num)#1 // funcTbl functions always have to return a
|
|||||||
fin
|
fin
|
||||||
break
|
break
|
||||||
is $1B // Esc
|
is $1B // Esc
|
||||||
mmgr(CHECK_MEM, 0)
|
heapCollect()
|
||||||
mmgr(HEAP_COLLECT, 0)
|
|
||||||
return NULL
|
return NULL
|
||||||
otherwise
|
otherwise
|
||||||
if sel == 'X' and mode <> 'I' // switch from stats to inv
|
if sel == 'X' and mode <> 'I' // switch from stats to inv
|
||||||
|
@ -107,8 +107,7 @@ def displayBuyPage(pItemTbl, markupRatio, pageNum, nPages)#1
|
|||||||
word pFunc, pItem
|
word pFunc, pItem
|
||||||
|
|
||||||
// Clear stuff from previous page
|
// Clear stuff from previous page
|
||||||
mmgr(CHECK_MEM, 0)
|
heapCollect()
|
||||||
mmgr(HEAP_COLLECT, 0)
|
|
||||||
|
|
||||||
displayTitle("buying", "Browse", pageNum, nPages)
|
displayTitle("buying", "Browse", pageNum, nPages)
|
||||||
pFunc = pItemTbl + ((pageNum*PAGE_SIZE) << 1)
|
pFunc = pItemTbl + ((pageNum*PAGE_SIZE) << 1)
|
||||||
@ -255,6 +254,13 @@ def _buyFromStore(storeCode, profitPercent)#1
|
|||||||
while TRUE
|
while TRUE
|
||||||
if redisplay
|
if redisplay
|
||||||
nItemsOnPage = displayBuyPage(pItemTbl, ratio, pageNum, nPages)
|
nItemsOnPage = displayBuyPage(pItemTbl, ratio, pageNum, nPages)
|
||||||
|
flipToPage1 // FOO
|
||||||
|
^$c051
|
||||||
|
mmgr(DEBUG_MEM, 0)
|
||||||
|
rdkey
|
||||||
|
auxMmgr(DEBUG_MEM, 0)
|
||||||
|
rdkey
|
||||||
|
^$c050
|
||||||
fin
|
fin
|
||||||
choice = getUpperKey()
|
choice = getUpperKey()
|
||||||
redisplay = TRUE
|
redisplay = TRUE
|
||||||
@ -276,8 +282,8 @@ def _buyFromStore(storeCode, profitPercent)#1
|
|||||||
loop
|
loop
|
||||||
|
|
||||||
unloadExtraModules()
|
unloadExtraModules()
|
||||||
mmgr(CHECK_MEM, 0)
|
heapCollect()
|
||||||
return mmgr(HEAP_COLLECT, 0)
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -381,8 +387,8 @@ def _sellToStore(profitPercent)#1
|
|||||||
loop
|
loop
|
||||||
|
|
||||||
unloadExtraModules()
|
unloadExtraModules()
|
||||||
mmgr(CHECK_MEM, 0)
|
heapCollect()
|
||||||
return mmgr(HEAP_COLLECT, 0)
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user