mirror of
https://github.com/elliotnunn/supermario.git
synced 2024-11-25 09:30:50 +00:00
70 lines
2.3 KiB
Plaintext
70 lines
2.3 KiB
Plaintext
;
|
||
; File: ProcessManagerSegmentTweaks.a
|
||
;
|
||
; Contains: Code to do smarter loading of Process Manager segments to reduce
|
||
; system heap fragmentation. Based on Greg’s 7 Up code.
|
||
;
|
||
; Written by: Dean Yu
|
||
;
|
||
; Copyright: © 1991 by Apple Computer, Inc., all rights reserved.
|
||
;
|
||
; Change History (most recent first):
|
||
;
|
||
; <1> 12/16/91 DTY first checked in
|
||
;
|
||
; To do: Take decompression slop into account (this doesn’t happen yet, but it might)
|
||
;
|
||
|
||
load 'StandardEqu.d'
|
||
include 'LinkedPatchMacros.a'
|
||
|
||
;
|
||
; Loading these segments lower in the system heap helps reduce fragmentation of the
|
||
; system heap. Preloading resources from the System file doesn’t work because they
|
||
; come in before the decompression hooks are installed. For each Process Manager
|
||
; segment in our list, find out it’s size, reserve enough space for it, and load
|
||
; it low in the heap.
|
||
;
|
||
|
||
kProcessManagerSegmentType equ 'scod' ; Process Manager segment resource type
|
||
|
||
LoadProcessManagerSegmentsLowerInSysHeap InstallProc (Plus,SE,II,IIci,Portable)
|
||
|
||
subq #2,sp
|
||
_CurResFile ; Remember the current resource file
|
||
clr.w -(sp)
|
||
_UseResFile ; Work on the System file
|
||
move.b ResLoad,-(sp) ; Save current resource load state
|
||
|
||
lea ProcessManagerSegmentTable,a4 ; Table of Process Manager segments to load low
|
||
@loadLoop
|
||
move.w (a4)+,d7 ; Get the segment number
|
||
bz.s @doneWithSegments ; Did ’em all
|
||
sf ResLoad ; Don’t load in resources
|
||
subq #8,sp ; Space for _SizeResource result too
|
||
move.l #kProcessManagerSegmentType,-(sp)
|
||
move.w d7,-(sp)
|
||
_Get1Resource
|
||
_SizeRsrc ; Find out how big it is
|
||
move.l (sp)+,d0 ; Get the size
|
||
_ResrvMem ,Sys ; Make some space low in the heap
|
||
st ResLoad ; Load it in for real now
|
||
subq #4,sp
|
||
move.l #kProcessManagerSegmentType,-(sp)
|
||
move.w d7,-(sp)
|
||
_Get1Resource ; Load it in
|
||
addq #4,sp ; We don’t really care about the resource
|
||
bra.s @loadLoop
|
||
|
||
@doneWithSegments
|
||
move.b (sp)+,ResLoad ; Restore resource load state
|
||
_UseResFile ; The current resource file is on the stack
|
||
rts
|
||
|
||
ProcessManagerSegmentTable
|
||
dc.w $BFAC ; MiscSeg
|
||
dc.w $BFB0 ; KernelSeg
|
||
dc.w $BFB2 ; EPPCSeg
|
||
dc.w 0 ; End of table
|
||
EndProc
|
||
End |