mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-13 03:30:28 +00:00
Heap test now runs for a long, long time. I think the heap code is solid.
This commit is contained in:
parent
cc9b77f7e6
commit
f88866085f
@ -331,6 +331,13 @@ init: !zone
|
|||||||
jsr main_dispatch
|
jsr main_dispatch
|
||||||
stx framePtr
|
stx framePtr
|
||||||
stx outerFramePtr
|
stx outerFramePtr
|
||||||
|
stx .frameSet+1
|
||||||
|
stx frameChk+1
|
||||||
|
sty .frameSet+2
|
||||||
|
sty frameChk+2
|
||||||
|
lda #$AA ; store sentinel byte at bottom of frame
|
||||||
|
.frameSet:
|
||||||
|
sta $1111 ; self-modified above
|
||||||
iny ; twice for 2 pages: initial pointer at top of new space
|
iny ; twice for 2 pages: initial pointer at top of new space
|
||||||
iny
|
iny
|
||||||
sty framePtr+1
|
sty framePtr+1
|
||||||
@ -630,6 +637,10 @@ __asmPlasm: !zone
|
|||||||
pha ; and save that
|
pha ; and save that
|
||||||
cmp #$11 ; again, X must be in range 0..$10
|
cmp #$11 ; again, X must be in range 0..$10
|
||||||
bcs .badx
|
bcs .badx
|
||||||
|
frameChk:
|
||||||
|
lda $1111 ; self-modified by init code
|
||||||
|
cmp #$AA ; check for sentinel value
|
||||||
|
bne .badFrame
|
||||||
lda evalStkL,x ; get last param to A=lo
|
lda evalStkL,x ; get last param to A=lo
|
||||||
ldy evalStkH,x ; ...Y=hi
|
ldy evalStkH,x ; ...Y=hi
|
||||||
.jsr jsr $1111 ; call the routine to do work
|
.jsr jsr $1111 ; call the routine to do work
|
||||||
@ -644,7 +655,9 @@ __asmPlasm: !zone
|
|||||||
.badx ; X reg ran outside valid range. Print and abort.
|
.badx ; X reg ran outside valid range. Print and abort.
|
||||||
+prStr : !text $8D,"X=",0
|
+prStr : !text $8D,"X=",0
|
||||||
+prX
|
+prX
|
||||||
jsr inlineFatal : !text "PlasmXRng", 0
|
jsr inlineFatal : !text "PlasmXRng",0
|
||||||
|
.badFrame:
|
||||||
|
jsr inlineFatal : !text "PlasmFrm",0
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Debug code to support macros
|
; Debug code to support macros
|
||||||
@ -1072,7 +1085,6 @@ gc3_fix:
|
|||||||
lda gcHash_dstHi,x
|
lda gcHash_dstHi,x
|
||||||
+ sty pTmp ; store object pointer so we can dereference it
|
+ sty pTmp ; store object pointer so we can dereference it
|
||||||
sta pTmp+1
|
sta pTmp+1
|
||||||
+prWord pTmp
|
|
||||||
ldy #0 ; first byte
|
ldy #0 ; first byte
|
||||||
lda (pTmp),y ; is the type
|
lda (pTmp),y ; is the type
|
||||||
bpl .outer ; or, if not hi bit, just a string so skip (no ptrs)
|
bpl .outer ; or, if not hi bit, just a string so skip (no ptrs)
|
||||||
@ -1147,12 +1159,6 @@ gc2_sweep: !zone
|
|||||||
tax ; and in index for byte-copy count
|
tax ; and in index for byte-copy count
|
||||||
lda tmp ; check for pSrc == pDst
|
lda tmp ; check for pSrc == pDst
|
||||||
beq .advDst ; if equal, no need to copy
|
beq .advDst ; if equal, no need to copy
|
||||||
|
|
||||||
+prWord pSrc
|
|
||||||
+prStr : !text "->",0
|
|
||||||
+prWord pDst
|
|
||||||
+crout
|
|
||||||
|
|
||||||
inx ; set up to copy type/len byte as well
|
inx ; set up to copy type/len byte as well
|
||||||
.cplup lda (pSrc),y
|
.cplup lda (pSrc),y
|
||||||
sta (pDst),y
|
sta (pDst),y
|
||||||
@ -1180,17 +1186,12 @@ gc2_sweep: !zone
|
|||||||
sta heapTop
|
sta heapTop
|
||||||
lda pDst+1
|
lda pDst+1
|
||||||
sta heapTop+1
|
sta heapTop+1
|
||||||
+prWord heapTop
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
heapCollect: !zone
|
heapCollect: !zone
|
||||||
+prStr : !text "Phase 1.",0
|
|
||||||
jsr gc1_mark ; mark reachable blocks
|
jsr gc1_mark ; mark reachable blocks
|
||||||
+prStr : !text "Phase 2.",0
|
|
||||||
jsr gc2_sweep ; sweep them into one place
|
jsr gc2_sweep ; sweep them into one place
|
||||||
+prStr : !text "Phase 3.",0
|
|
||||||
jsr gc3_fix ; adjust all pointers
|
jsr gc3_fix ; adjust all pointers
|
||||||
+prStr : !text "Phase 4.",0
|
|
||||||
jsr heapClr ; and clear newly freed space
|
jsr heapClr ; and clear newly freed space
|
||||||
lda #0 ; heap end lo always 0
|
lda #0 ; heap end lo always 0
|
||||||
sec
|
sec
|
||||||
|
@ -1505,7 +1505,7 @@ def freeObj(ptr)
|
|||||||
byte typeNum
|
byte typeNum
|
||||||
if ptr == NULL; return; fin
|
if ptr == NULL; return; fin
|
||||||
typeNum = ^ptr
|
typeNum = ^ptr
|
||||||
printf3(" freeObj p=$%x t=$%x ct=%d\n", ptr, typeNum, typeCounts[typeNum])
|
//printf3(" freeObj p=$%x t=$%x ct=%d\n", ptr, typeNum, typeCounts[typeNum])
|
||||||
if typeCounts[typeNum] == 0
|
if typeCounts[typeNum] == 0
|
||||||
fatal("Can't decr count past 0")
|
fatal("Can't decr count past 0")
|
||||||
fin
|
fin
|
||||||
@ -1744,12 +1744,14 @@ def randomHeapAction()
|
|||||||
|
|
||||||
// Random actions
|
// Random actions
|
||||||
acted = FALSE
|
acted = FALSE
|
||||||
when rand16() % 11
|
when rand16() % 12
|
||||||
|
|
||||||
// Add player
|
// Add player
|
||||||
is 0
|
is 0
|
||||||
is 1
|
is 1
|
||||||
if countList(global=>players) < 10
|
is 2
|
||||||
|
is 3
|
||||||
|
if countList(global=>players) < 15
|
||||||
puts("\n*** ADDING PLAYER ***\n")
|
puts("\n*** ADDING PLAYER ***\n")
|
||||||
addPlayer()
|
addPlayer()
|
||||||
acted = TRUE
|
acted = TRUE
|
||||||
@ -1757,8 +1759,8 @@ def randomHeapAction()
|
|||||||
break
|
break
|
||||||
|
|
||||||
// Remove player
|
// Remove player
|
||||||
is 2
|
is 4
|
||||||
if countList(global=>players) > 5
|
if countList(global=>players) > 8
|
||||||
puts("\n*** REMOVING PLAYER ***\n")
|
puts("\n*** REMOVING PLAYER ***\n")
|
||||||
p = randomFromList(global=>players)
|
p = randomFromList(global=>players)
|
||||||
printf1("Unlinking player $%x\n", p)
|
printf1("Unlinking player $%x\n", p)
|
||||||
@ -1770,11 +1772,11 @@ def randomHeapAction()
|
|||||||
break
|
break
|
||||||
|
|
||||||
// Add item
|
// Add item
|
||||||
is 3
|
|
||||||
is 4
|
|
||||||
is 5
|
is 5
|
||||||
|
is 6
|
||||||
|
is 7
|
||||||
p = randomFromList(global=>players)
|
p = randomFromList(global=>players)
|
||||||
if p and countList(p=>items) > 2
|
if p and countList(p=>items) < 10
|
||||||
puts("\n*** ADDING ITEM ***\n")
|
puts("\n*** ADDING ITEM ***\n")
|
||||||
addItem(p)
|
addItem(p)
|
||||||
acted = TRUE
|
acted = TRUE
|
||||||
@ -1782,10 +1784,9 @@ def randomHeapAction()
|
|||||||
break
|
break
|
||||||
|
|
||||||
// Remove item
|
// Remove item
|
||||||
is 6
|
is 8
|
||||||
is 7
|
|
||||||
p = randomFromList(global=>players)
|
p = randomFromList(global=>players)
|
||||||
if p and countList(p=>items) > 0
|
if p and p=>items
|
||||||
puts("\n*** REMOVING ITEM ***\n")
|
puts("\n*** REMOVING ITEM ***\n")
|
||||||
p2 = randomFromList(p=>items)
|
p2 = randomFromList(p=>items)
|
||||||
unlinkFromList(p + items, p2)
|
unlinkFromList(p + items, p2)
|
||||||
@ -1795,22 +1796,20 @@ def randomHeapAction()
|
|||||||
break
|
break
|
||||||
|
|
||||||
// Trade item
|
// Trade item
|
||||||
is 8
|
|
||||||
is 9
|
is 9
|
||||||
|
is 10
|
||||||
p = randomFromList(global=>players)
|
p = randomFromList(global=>players)
|
||||||
if p
|
if p and p=>items
|
||||||
|
puts("\n*** TRADING ITEM ***\n")
|
||||||
p2 = randomFromList(p=>items)
|
p2 = randomFromList(p=>items)
|
||||||
if p2
|
unlinkFromList(p + items, p2)
|
||||||
puts("\n*** TRADING ITEM ***\n")
|
p = randomFromList(global=>players)
|
||||||
unlinkFromList(p + items, p2)
|
addToList(p + items, p2)
|
||||||
p = randomFromList(global=>players)
|
|
||||||
addToList(p + items, p2)
|
|
||||||
fin
|
|
||||||
fin
|
fin
|
||||||
break
|
break
|
||||||
|
|
||||||
// Garbage collect
|
// Garbage collect
|
||||||
is 10
|
is 11
|
||||||
puts("\n*** COLLECTING GARBAGE ***\n")
|
puts("\n*** COLLECTING GARBAGE ***\n")
|
||||||
collect()
|
collect()
|
||||||
acted = TRUE
|
acted = TRUE
|
||||||
@ -1818,9 +1817,9 @@ def randomHeapAction()
|
|||||||
|
|
||||||
if acted
|
if acted
|
||||||
mmgr(CHECK_MEM, 0)
|
mmgr(CHECK_MEM, 0)
|
||||||
puts("Hit a key: ")
|
//puts("Hit a key: ")
|
||||||
getUpperKey()
|
//getUpperKey()
|
||||||
crout()
|
//crout()
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user