mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-12 12:30:07 +00:00
Fixed memory manager init that didn't properly copy heap code.
This commit is contained in:
parent
f3b8b7b48d
commit
ec6368a10b
@ -19,8 +19,8 @@ MAX_SEGS = 96
|
|||||||
|
|
||||||
DO_COMP_CHECKSUMS = 0 ; during compression debugging
|
DO_COMP_CHECKSUMS = 0 ; during compression debugging
|
||||||
DEBUG_DECOMP = 0
|
DEBUG_DECOMP = 0
|
||||||
DEBUG = 0
|
DEBUG = 1
|
||||||
SANITY_CHECK = 0 ; also prints out request data
|
SANITY_CHECK = 1 ; also prints out request data
|
||||||
|
|
||||||
; Zero page temporary variables
|
; Zero page temporary variables
|
||||||
tmp = $2 ; len 2
|
tmp = $2 ; len 2
|
||||||
@ -56,14 +56,17 @@ prodosMemMap = $BF58
|
|||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Relocate all the pieces to their correct locations
|
; Relocate all the pieces to their correct locations
|
||||||
relocate:
|
relocate:
|
||||||
; first our lo memory piece goes to $800 (two pages should be plenty)
|
; first our lo memory piece goes to $800
|
||||||
ldy #0
|
ldy #0
|
||||||
- lda loMemBegin,y
|
ldx #>(loMemEnd-loMemBegin+$FF)
|
||||||
sta $800,y
|
.lold lda loMemBegin,y
|
||||||
lda loMemBegin+$100,y
|
.lost sta $800,y
|
||||||
sta $900,y
|
|
||||||
iny
|
iny
|
||||||
bne -
|
bne .lold
|
||||||
|
inc .lold+2
|
||||||
|
inc .lost+2
|
||||||
|
dex
|
||||||
|
bne .lold
|
||||||
; set up to copy the ProDOS code from main memory to aux
|
; set up to copy the ProDOS code from main memory to aux
|
||||||
bit setLcRW+lcBank1 ; only copy bank 1, because bank 2 is PLASMA runtime
|
bit setLcRW+lcBank1 ; only copy bank 1, because bank 2 is PLASMA runtime
|
||||||
bit setLcRW+lcBank1 ; write to it
|
bit setLcRW+lcBank1 ; write to it
|
||||||
@ -1167,7 +1170,7 @@ scanForAvail: !zone
|
|||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
main_dispatch: !zone
|
main_dispatch: !zone
|
||||||
!if SANITY_CHECK { jsr saneStart : jsr + : jmp saneEnd }
|
!if SANITY_CHECK { jsr saneStart : jsr + : jmp saneEnd }
|
||||||
pha
|
+ pha
|
||||||
lda #0
|
lda #0
|
||||||
beq .go
|
beq .go
|
||||||
aux_dispatch:
|
aux_dispatch:
|
||||||
@ -1193,7 +1196,7 @@ aux_dispatch:
|
|||||||
!if DEBUG {
|
!if DEBUG {
|
||||||
+ cmp #DEBUG_MEM
|
+ cmp #DEBUG_MEM
|
||||||
bne +
|
bne +
|
||||||
jmp mem_debug
|
jmp printMem
|
||||||
}
|
}
|
||||||
+ cmp #CALC_FREE
|
+ cmp #CALC_FREE
|
||||||
bne +
|
bne +
|
||||||
|
@ -6,10 +6,13 @@ const NULL = 0
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Fixed memory locations
|
// Fixed memory locations
|
||||||
const seed = $4E // Incremented continuously by montitor's rdkey routine
|
const seed = $4E // Incremented continuously by keyboard read routine
|
||||||
const displayEngine = $6000 // main mem (raycaster and tile engine at same location)
|
const displayEngine = $6000 // main mem (raycaster and tile engine at same location)
|
||||||
const expandVec = $2000 // aux mem (only for raycaster)
|
const expandVec = $2000 // aux mem (only for raycaster)
|
||||||
const fontEngine = $E000 // main mem
|
const fontEngine = $E000 // main mem
|
||||||
|
const heapStart = $F000 // main mem
|
||||||
|
|
||||||
|
const heapSize = $800
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Resource numbers
|
// Resource numbers
|
||||||
@ -70,6 +73,44 @@ const callbacks = $300
|
|||||||
const OVERMAP_NUM = 1
|
const OVERMAP_NUM = 1
|
||||||
const OVERMAP_IS_3D = 0
|
const OVERMAP_IS_3D = 0
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Structures for testing the heap system
|
||||||
|
const TYPE_GLOBAL = $80
|
||||||
|
struc Global
|
||||||
|
byte type
|
||||||
|
word id
|
||||||
|
word players
|
||||||
|
end
|
||||||
|
|
||||||
|
const TYPE_PLAYER = $81
|
||||||
|
struc Player
|
||||||
|
byte type
|
||||||
|
word id
|
||||||
|
word nextObj
|
||||||
|
word name
|
||||||
|
byte muscle
|
||||||
|
byte quickness
|
||||||
|
word items
|
||||||
|
word health
|
||||||
|
end
|
||||||
|
|
||||||
|
const TYPE_ITEM = $82
|
||||||
|
struc Item
|
||||||
|
byte type
|
||||||
|
word id
|
||||||
|
word nextObj
|
||||||
|
word name
|
||||||
|
byte kind
|
||||||
|
byte cost
|
||||||
|
end
|
||||||
|
|
||||||
|
// Table per type, starts with length, then pointer offsets, ending with zero.
|
||||||
|
byte typeTbl_Global[] = Global, players, 0
|
||||||
|
byte typeTbl_Player[] = Player, nextObj, items, 0
|
||||||
|
byte typeTbl_Item[] = Item, nextObj, 0
|
||||||
|
|
||||||
|
byte typeCounts[256]
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Predefined functions, for circular calls or out-of-order calls
|
// Predefined functions, for circular calls or out-of-order calls
|
||||||
predef setWindow2, initCmds
|
predef setWindow2, initCmds
|
||||||
@ -482,9 +523,9 @@ asm mmgr
|
|||||||
+asmPlasm 2
|
+asmPlasm 2
|
||||||
lda evalStkL+1,x ; command code
|
lda evalStkL+1,x ; command code
|
||||||
pha
|
pha
|
||||||
ldy evalStkH,x ; address (or other param)
|
ldy evalStkH,x ; address (or other param)... hi byte in Y
|
||||||
lda evalStkL,x
|
lda evalStkL,x
|
||||||
tax
|
tax ; ...lo byte in X
|
||||||
pla
|
pla
|
||||||
jsr mainLoader ; ret value in X=lo/Y=hi
|
jsr mainLoader ; ret value in X=lo/Y=hi
|
||||||
txa ; to A=lo/Y=hi for asmPlasm
|
txa ; to A=lo/Y=hi for asmPlasm
|
||||||
@ -1349,6 +1390,8 @@ def loadTitle()
|
|||||||
puts("Loading Lawless Legends.\n")
|
puts("Loading Lawless Legends.\n")
|
||||||
|
|
||||||
// Load the title screen
|
// Load the title screen
|
||||||
|
mmgr(UNLOCK_MEMORY, $2000)
|
||||||
|
mmgr(FREE_MEMORY, $2000)
|
||||||
mmgr(SET_MEM_TARGET, $2000)
|
mmgr(SET_MEM_TARGET, $2000)
|
||||||
mmgr(QUEUE_LOAD, 1<<8 | RES_TYPE_SCREEN) // title screen is fixed at #1
|
mmgr(QUEUE_LOAD, 1<<8 | RES_TYPE_SCREEN) // title screen is fixed at #1
|
||||||
mmgr(LOCK_MEMORY, $2000)
|
mmgr(LOCK_MEMORY, $2000)
|
||||||
@ -1428,9 +1471,52 @@ def setCallbacks()
|
|||||||
callbacks:40 = @clearWindow
|
callbacks:40 = @clearWindow
|
||||||
end
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def newObj(typeNum)
|
||||||
|
typeCounts[typeNum] = typeCounts[typeNum] + 1
|
||||||
|
return mmgr(HEAP_ALLOC, type)
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
def freeObj(ptr)
|
||||||
|
byte typeNum
|
||||||
|
if ptr == NULL; return; fin
|
||||||
|
typeNum = ^ptr
|
||||||
|
typeCounts[typeNum] = typeCounts[typeNum] - 1
|
||||||
|
if typeCounts[typeNum] == 0
|
||||||
|
when type
|
||||||
|
is TYPE_GLOBAL
|
||||||
|
fatal("can't free global obj")
|
||||||
|
is TYPE_PLAYER
|
||||||
|
freeObj(ptr:nextObj)
|
||||||
|
freeObj(ptr:name)
|
||||||
|
freeObj(ptr:items)
|
||||||
|
break
|
||||||
|
is TYPE_ITEM
|
||||||
|
freeObj(ptr:nextObj)
|
||||||
|
freeObj(ptr:name)
|
||||||
|
break
|
||||||
|
wend
|
||||||
|
fin
|
||||||
|
end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Set up the small-object heap
|
||||||
|
def initHeap()
|
||||||
|
mmgr(SET_MEM_TARGET, heapStart)
|
||||||
|
mmgr(REQUEST_MEMORY, heapSize)
|
||||||
|
mmgr(LOCK_MEMORY, heapStart)
|
||||||
|
mmgr(HEAP_SET, heapStart)
|
||||||
|
mmgr(HEAP_ADD_TYPE, typeTbl_Global)
|
||||||
|
mmgr(HEAP_ADD_TYPE, typeTbl_Player)
|
||||||
|
mmgr(HEAP_ADD_TYPE, typeTbl_Item)
|
||||||
|
newObj(TYPE_GLOBAL)
|
||||||
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Main code.
|
// Main code.
|
||||||
//
|
//
|
||||||
|
initHeap()
|
||||||
loadTitle()
|
loadTitle()
|
||||||
setCallbacks()
|
setCallbacks()
|
||||||
mapIs3D = OVERMAP_IS_3D
|
mapIs3D = OVERMAP_IS_3D
|
||||||
|
Loading…
x
Reference in New Issue
Block a user