mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-25 13:29:59 +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
|
||||
stx framePtr
|
||||
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
|
||||
sty framePtr+1
|
||||
@ -630,6 +637,10 @@ __asmPlasm: !zone
|
||||
pha ; and save that
|
||||
cmp #$11 ; again, X must be in range 0..$10
|
||||
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
|
||||
ldy evalStkH,x ; ...Y=hi
|
||||
.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.
|
||||
+prStr : !text $8D,"X=",0
|
||||
+prX
|
||||
jsr inlineFatal : !text "PlasmXRng", 0
|
||||
jsr inlineFatal : !text "PlasmXRng",0
|
||||
.badFrame:
|
||||
jsr inlineFatal : !text "PlasmFrm",0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Debug code to support macros
|
||||
@ -1072,7 +1085,6 @@ gc3_fix:
|
||||
lda gcHash_dstHi,x
|
||||
+ sty pTmp ; store object pointer so we can dereference it
|
||||
sta pTmp+1
|
||||
+prWord pTmp
|
||||
ldy #0 ; first byte
|
||||
lda (pTmp),y ; is the type
|
||||
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
|
||||
lda tmp ; check for pSrc == pDst
|
||||
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
|
||||
.cplup lda (pSrc),y
|
||||
sta (pDst),y
|
||||
@ -1180,17 +1186,12 @@ gc2_sweep: !zone
|
||||
sta heapTop
|
||||
lda pDst+1
|
||||
sta heapTop+1
|
||||
+prWord heapTop
|
||||
rts
|
||||
|
||||
heapCollect: !zone
|
||||
+prStr : !text "Phase 1.",0
|
||||
jsr gc1_mark ; mark reachable blocks
|
||||
+prStr : !text "Phase 2.",0
|
||||
jsr gc2_sweep ; sweep them into one place
|
||||
+prStr : !text "Phase 3.",0
|
||||
jsr gc3_fix ; adjust all pointers
|
||||
+prStr : !text "Phase 4.",0
|
||||
jsr heapClr ; and clear newly freed space
|
||||
lda #0 ; heap end lo always 0
|
||||
sec
|
||||
|
@ -1505,7 +1505,7 @@ def freeObj(ptr)
|
||||
byte typeNum
|
||||
if ptr == NULL; return; fin
|
||||
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
|
||||
fatal("Can't decr count past 0")
|
||||
fin
|
||||
@ -1744,12 +1744,14 @@ def randomHeapAction()
|
||||
|
||||
// Random actions
|
||||
acted = FALSE
|
||||
when rand16() % 11
|
||||
when rand16() % 12
|
||||
|
||||
// Add player
|
||||
is 0
|
||||
is 1
|
||||
if countList(global=>players) < 10
|
||||
is 2
|
||||
is 3
|
||||
if countList(global=>players) < 15
|
||||
puts("\n*** ADDING PLAYER ***\n")
|
||||
addPlayer()
|
||||
acted = TRUE
|
||||
@ -1757,8 +1759,8 @@ def randomHeapAction()
|
||||
break
|
||||
|
||||
// Remove player
|
||||
is 2
|
||||
if countList(global=>players) > 5
|
||||
is 4
|
||||
if countList(global=>players) > 8
|
||||
puts("\n*** REMOVING PLAYER ***\n")
|
||||
p = randomFromList(global=>players)
|
||||
printf1("Unlinking player $%x\n", p)
|
||||
@ -1770,11 +1772,11 @@ def randomHeapAction()
|
||||
break
|
||||
|
||||
// Add item
|
||||
is 3
|
||||
is 4
|
||||
is 5
|
||||
is 6
|
||||
is 7
|
||||
p = randomFromList(global=>players)
|
||||
if p and countList(p=>items) > 2
|
||||
if p and countList(p=>items) < 10
|
||||
puts("\n*** ADDING ITEM ***\n")
|
||||
addItem(p)
|
||||
acted = TRUE
|
||||
@ -1782,10 +1784,9 @@ def randomHeapAction()
|
||||
break
|
||||
|
||||
// Remove item
|
||||
is 6
|
||||
is 7
|
||||
is 8
|
||||
p = randomFromList(global=>players)
|
||||
if p and countList(p=>items) > 0
|
||||
if p and p=>items
|
||||
puts("\n*** REMOVING ITEM ***\n")
|
||||
p2 = randomFromList(p=>items)
|
||||
unlinkFromList(p + items, p2)
|
||||
@ -1795,22 +1796,20 @@ def randomHeapAction()
|
||||
break
|
||||
|
||||
// Trade item
|
||||
is 8
|
||||
is 9
|
||||
is 10
|
||||
p = randomFromList(global=>players)
|
||||
if p
|
||||
if p and p=>items
|
||||
puts("\n*** TRADING ITEM ***\n")
|
||||
p2 = randomFromList(p=>items)
|
||||
if p2
|
||||
puts("\n*** TRADING ITEM ***\n")
|
||||
unlinkFromList(p + items, p2)
|
||||
p = randomFromList(global=>players)
|
||||
addToList(p + items, p2)
|
||||
fin
|
||||
unlinkFromList(p + items, p2)
|
||||
p = randomFromList(global=>players)
|
||||
addToList(p + items, p2)
|
||||
fin
|
||||
break
|
||||
|
||||
// Garbage collect
|
||||
is 10
|
||||
is 11
|
||||
puts("\n*** COLLECTING GARBAGE ***\n")
|
||||
collect()
|
||||
acted = TRUE
|
||||
@ -1818,9 +1817,9 @@ def randomHeapAction()
|
||||
|
||||
if acted
|
||||
mmgr(CHECK_MEM, 0)
|
||||
puts("Hit a key: ")
|
||||
getUpperKey()
|
||||
crout()
|
||||
//puts("Hit a key: ")
|
||||
//getUpperKey()
|
||||
//crout()
|
||||
fin
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user