supermario/base/SuperMarioProj.1994-02-09/Patches/MiscPatches.a
2019-06-29 23:17:50 +08:00

515 lines
19 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;
; File: MiscPatches.a
;
; Contains: Miscellaneous patches that don't fit anyplace else. Currently contains the following patches:
;
; Patch to _SynchIdleTime to handle idling for File Manager, Edition Manager, Data Access
; Manager, and PPC Toolbox.
;
; InitApplication and CleanupApplication.
;
; Gestalt function for Data Access Manager, Edition Manager,
; Standard File, and AppleEvent Manager.
;
; Copyright: © 1989-1992 by Apple Computer, Inc. All rights reserved.
;
; Change History (most recent first):
;
; <SM8> 11/3/92 SWC Changed SlotEqu.a->Slots.a and removed INCLUDE of Traps.a.
; <SM7> 9/3/92 PN Nuke the check for IIci because this is SuperMario.
; <SM6> 7/14/92 PN Use the real name for PPCTrap
; <SM5> 5/20/92 TN Moved entry points for Packs 8 ,9, 11, 13, 15 to new files in
; the folder with the corresponding Pack sources.
; <SM4> 5/16/92 kc Remove PowerPrivEqu.a include.
; <SM3> 4/15/92 kc Change bsr to jsr.
; <SM2> 4/13/92 JSM Roll-in changes from Reality: (note: still need to merge in revision <55>)
; <56> 4/7/92 JSM Use more specific equates in place of emPackGlobals everywhere.
; <54> 12/31/91 RB Removed _PowerDispatch trap definition. It is now in Traps.a
; <53> 12/6/91 YK Added _CleanUpApplicationComponents to CleanupApplication.
; (Deja Vu…)
; <52> 11/21/91 YK Removed _InputUtilsDispatch.
; <51> 10/28/91 SAM/KSM Rolled in Regatta changes.
; <3> 6/14/91 SAM (HJR) Using new PowerMgr record names.
; <1> 5/15/91 SAM Split off from 7.0 GM sources. Added support for power cycling
; at every few SynchIdle calls (for TIM).
; <50> 10/23/91 DTY _CleanUpApplication now calls _GetOverrideMap to determine when
; to stop closing files instead of blindly going on through to the
; System file.
; <49> 10/23/91 YK Added _InputUtilsDispatch for the Input Utilities.
; <48> 10/18/91 JH Fixed dumb error accessing DictionaryMgr handle in
; DictionaryDispatch
; <47> 10/17/91 JH Added _DictionaryDispatch for the dictionary manager.
; <46> 10/17/91 JSM Dont use hasPPC conditional.
; <45> 9/19/91 JSM Dont use forNuFinder conditional (this was the only file that
; used it).
; <44> 9/18/91 JSM Cleanup header, remove references to hasSplineFonts.
; <43> 6/12/91 LN removed #include 'HardwareEqu.a'
; <42> 2/25/91 dnf dfh, #80720,#82672: Give the File Manager some idle time so it
; can make sure there are enough FCBs available.
; <41> 2/4/91 CL (MR)Moving the cleanup of TrueType™ caches into cleanup app from
; BassPatches for 7.0.
; <40> 12/14/90 DFH (ksm) DoSevenOhIdle was a head patch to SystemTask. Now it is
; its own trap, SynchIdleTime, and is called by the Process Mgr at
; SystemTask and in idle scheduling time.
; <39> 10/15/90 JSM <stb> Use ppcIdleCmd.
; <38> 9/21/90 DDG Added a package handler for picture utilities.
; <37> 9/5/90 ngk Add AppleEventMgr stuff and conditionalizing code more
; <36> 8/17/90 gbm stop using myHasEditionMgr, since the build system now has its
; act together
; <35> 8/6/90 BBH add CommToolbox cleanup code to CleanupApplication as a JSR
; instead of a patch
; <34> 7/31/90 DFH Fixed typos in new CleanupApplication code.
; <33> 7/31/90 DFH Put CleanupApplication's calls in proper sequence. Added Sound
; Mgr and Resource Mgr cleanups.
; <32> 7/25/90 PKE In CleanupApplication, call to CleanupScriptApp replaces code
; that disposed of application itl cache. In InitApplication, add
; InitScriptApp call to set up application-specific Script Mgr
; globals (including itl cache). Include ScriptPriv.a.
; <31> 7/25/90 DFH Include MFPrivate.a to get InitApplication and
; CleanupApplication.
; <30> 7/12/90 STB Moved _DispatchHelper & _ProcHelper patch installation code to
; DispatchHelper.a
; <29> 7/8/90 JSM Pass in pointer to use count instead of offset when calling
; _ProcHelper.
; <28> 7/7/90 JSM Split DispatchHelper and ProcHelper off to {OS}DispatchHelper.a
; so SixPack can use them, general format cleanup.
; <27> 7/2/90 PKE Added code to CleanupApplication that disposes of applications
; itl2/itl4 cache.
; <26> 6/20/90 DTY Removed ShutdownMgr.a from MiscPatches and made it a stand-alone
; 'lpch'
; <25> 6/19/90 VL Convert various routines for linked patches.
; <24> 6/13/90 JSM Add include of SlotEqu.a and ROMEqu.a to fix BigBang build after
; ShutDownMgr.a changes.
; <23> 6/8/90 ngk Fix bug in PACKHelper, It was trashing A2.
; <22> 5/31/90 ngk Add gestault selector for StandardFile. Changed PACKHelper to
; not need a exit proc.
; <21> 5/2/90 PKE Included 'GestaltPrivateEqu.a' to fix the build. It is now
; needed for ShutDownMgr.a, which is included here.
; <20> 4/24/90 S To Include a Call to PPC at System Task Time.
; <19> 4/20/90 KSM DispatchHelper used to assume that there were no “holes” in the
; table, even if they were between the first and last selectors.
; With a simple branch (I hope), we can keep this from being a
; problem.
; <18> 3/20/90 EMT Used smaller (and faster) color quickdraw test.
; <17> 3/15/90 JSM Do a JMP instead of RTS from PACKHelper to DispatchHelper.
; <16> 3/10/90 ngk Change Pack11 (Editions Mgr) to use new package dispatcher.
; Added bit to dispatch flags that means selectors are even
; numbers.
; <15> 3/5/90 DVB Only PMgrExit on color machines ha ha
; <14> 2/26/90 JSM Fix Pack13Entry to check for globals.
; <13> 2/26/90 JSM Database Access Manager (PACK 13) now uses PACKHelper.
; <12> 2/24/90 JSM Add support for reentrant locking to PACKHelper.
; <11> 2/21/90 JSM Tighten up DispatchHelper.
; <10> 2/20/90 JSM Change DispatchTable format for DispatchHelper, tweak
; PACKHelper.
; <9> 2/19/90 JSM Add generic package dispatcher PACKHelper, add PPC Browser as
; PACK 9.
; <8> 2/16/90 DVB Add PMgrExit
; <7> 2/15/90 JSM Add generic dispatcher DispatchHelper.
; <6> 2/4/90 DNF Add include of FileMgrPrivate.a
; <5> 1/21/90 ngk Changed gestaltEditionMgr to gestaltEditionMgrAttr
; <4> 1/12/90 CCH Added include of “HardwarePrivateEqu.a”.
; <3> 1/6/90 ngk Use symbolic names for Edition manager calls
; <2> 1/4/90 JSM Add Gestalt function for 7.0 features.
; <2.4> 12/11/89 GMR Pulled Sony driver Format patch from this file, now in separate
; patch file (FormatPatch.a).
; <2.3> 12/8/89 dnf Reorder equates to make things work
; <2.2> 11/6/89 csd changed ShutDown Manager trap to point to the ShutDown Manager
; dispatcher, instead of the ShutDown Manager init code.
; <2.1> 11/4/89 ngk Added call to DataPublication Quit in _CleanupApp
; <2.0> 11/2/89 dba fixed ShutDown Manager initialization; I am a bad doggie!
; <1.9> 10/31/89 dba moved ShutDown Manager here
; <1.8> 10/16/89 KST Added two traps: InitApplication and CleanUpApplication.
; <1.7> 10/16/89 CCH Commented out EntryTable entries for InitApplication and
; CleanupApplication until the extended trap dispatcher is rolled
; into the big bang build.
; <1.6> 10/11/89 CCH Added _InitApplication and _CleanupApplication.
; <1.5> 10/6/89 JSM Patch SystemTask and _Pack13 for SnarfMan.
; <1.4> 10/1/89 ngk Added DataPublications Idle call to SytemTask chain.
; <1.3> 8/18/89 CCH Removed definition of onMac32.
; <1.2> 8/9/89 ngk Added new safer dispatcher for PACK=11 (DataPublications)
; <1.1> 8/8/89 GMR Fixed conditional testing for new sony driver.
; <1.0> 8/7/89 GMR Adding for first time to EASE.
;
PRINT PUSH,OFF
LOAD 'StandardEqu.d'
INCLUDE 'LinkedPatchMacros.a'
INCLUDE 'BTreeEqu.a'
include 'MMUEqu.a'
include 'BootEqu.a'
include 'HardwareEqu.a'
include 'FileMgrPrivate.a'
include 'GestaltEqu.a'
include 'GestaltPrivateEqu.a' ; <21>
include 'Slots.a' ; <24>
include 'ROMEqu.a' ; <24>
include 'EditionsPrivate.a'
include 'DatabaseAccess.a'
include 'DispatchHelperPriv.a'
include 'MFPrivate.a'
include 'ScriptPriv.a' ; <32>
include 'ResourceMgrPriv.a'
include 'PPCPriv.a' ; <39>
include 'fontPrivate.a' ; <CEL-41>
include 'universalEqu.a'
include 'PowerPrivEqu.a'
PwrCycCount EQU $AA ; <1>
PRINT POP
;
; These patches are installed on all ROM families
;
ROMs Plus,SE,II,Portable,IIci
;___________________________________________________________________________________
;
; Routine: SynchIdleTime
;
; Inputs: none
;
; Outputs: none
;
; Can destroy: D0-D2,A0-A1
;
; Function: Gets called at synchronous idlish time by Process Mgr
;
; Calls FileManagerIdleProc to check FCB allocation.
;
; Calls _EditionBackGroundTask only if the package is loaded
; and some edition files are in use.
;
; Calls DBIdle only if the Data Access manager globals are allocated.
;
; Calls idle routine for PPC Toolbox.
;
;___________________________________________________________________________________
SynchIdleTimeProc PatchProc _SynchIdleTime
import FileManagerIdleProc
jsr FileManagerIdleProc ; <42>
IF hasEditionMgr THEN
;
; Check if we need to call _EditionBackGroundTask
;
MOVE.L ExpandMem, A0 ; get expanded memory area
LEA ExpandMemRec.emDataPub(A0),A0 ; get em globals location
MOVE.L (A0),D0 ; test if allocated
BEQ.S @emIdleDone ; if not, no need to do idle
MOVE.L D0,A1
MOVE.L EdtnMgrGlobals.firstPubCB(A1),D0
CMP.L D0,A0 ; if no pub control blocks
BEQ.S @emIdleDone ; then done
MOVE.L EdtnMgrGlobals.nextPollTime(A1),D0 ; if timer has not expired
CMP.L Ticks,D0 ; then check for DBIdle
BHI.S @emIdleDone
SUBQ #2,SP ; place holder for result
_EditionBackGroundTask ; call dpBackGroundTask
TST.W (SP)+ ; ignore result
@emIdleDone
ENDIF
IF hasDataAccessMgr THEN
;
; Check if we need to call DBIdle
;
MOVE.L ExpandMem, A0 ; get expanded memory area
MOVE.L ExpandMemRec.emSnarfGlobals(A0), D0 ; get Snarf globals
BEQ.S @doneDBIdle ; if not allocated no need to do idle
SUBQ #2,SP ; place holder for result
MOVE.W #$00FF,D0 ; actually call DBIdle
_Pack13
TST.W (SP)+ ; ignore result
@doneDBIdle
ENDIF
;
; always do PPC idle routine
;
MOVEQ #ppcIdleCmd,D0 ; <39> call PPC idle routine
_PPC ; PPC trap <PN>
WITH PMgrRec,PowerDispRec ;
BRA.S @Done ; <PN> branch always because we are SM ROM
Testfor hwCbPwrMgr ; do we have a power manager?
BEQ.S @Done ; no power cycling
MOVE.L PMgrBase,A0 ; Get the Power Manager Globals
MOVE.W PwrCycSyncCount(A0),D0 ; Get the number of syncIdle before IdleMind
ADDI.W #1,PMgrScratch.SyncCounter(A0) ; Increment scratch counter
CMP.W PMgrScratch.SyncCounter(A0),D0 ; Have we done enough SyncIdles
BLT.S @Done
CLR.W PMgrScratch.SyncCounter(A0) ; reset counter
MOVEQ #IdleMindDisp,D0 ; Set the selector to IdleMind
_PowerDispatch
@Done
rts
ENDPROC ; SynchIdleTimeProc
;___________________________________________________________________________________
;
; Routine: InitApplication <1.6>
;
; Inputs: none
;
; Outputs: status flag ? (currently unused) in D0
;
; Can destroy: D0-D2,A0-A1
;
; Function: Gets called at application launch by Multifinder to set up the world.
;
;___________________________________________________________________________________
InitApp PatchProc _InitApplication
;
; Set up application-specific Script Mgr globals <32>
;
SUBQ #2,SP ; space for OSErr result
_InitScriptApp ; go set up apps script globals
ADDQ #2,SP ; always returns NoErr, ignore
;
; All done, return status flag in D0
;
MOVEQ #-1,D0
RTS ; big routine
ENDPROC ; InitApp
;___________________________________________________________________________________
;
; Routine: CleanupApplication <1.6>
; Inputs: none
; Outputs: none
; Destroys: D0/A0-A1
; Gets called by the Process Mgr's ExitToShell code. The current low memory, traps,
; VBLs, etc. are for the dying application. This is the chance for OS and ToolBox to
; tidy up things that were given to the application.
; BEWARE! The order of operations here is VERY important. This is why you add code
; here, rather than patching this or some other trap. In general, we want to cleanup
; from the top down. For example, since closing the resource files nukes any custom
; code provided by the app (e.g. WDEFs), we must cleanup parts that use the custom code
; (e.g. the Palette Mgr) BEFORE closing the resource files. Similarly, CloseResFiles and
; _BTCleanUp are called before _FSCleanup so _FSCleanup doesn't close the files out from
; under the Btree or Resource Mgrs.
;
;___________________________________________________________________________________
CleanupApp PatchProc _CleanupApplication
CLR.L -(SP) ; room for result
MOVE.L applZone,A0 ; point to zone hdr
MOVE.L A0,-(SP) ; push start ptr
MOVE.L (A0),-(SP) ; push zone trailer
_sbKillSomeCaches
ADDQ #4,SP ; ignore result
IF hasCommToolbox THEN
;
; Clean up CommToolbox if necessary
;
import CleanUpCommToolbox
JSR CleanupCommToolbox
ENDIF
IF hasEditionMgr THEN ; <36>
;
; Check if app was doing Edition Manager stuff that needs cleaning up
;
MOVE.L ExpandMem, A0 ; get expanded memory area
MOVE.L ExpandMemRec.emDataPub(A0), D0 ; get dp globals
BEQ.S @noEditionMgr ; if not allocated, no need to do cleanup
SUBQ #2,SP ; place holder for result
_QuitEditionPack ; call pack11 clean up
TST.W (SP)+ ; ignore result
@noEditionMgr
ENDIF
;
; Clean up Compoents and Component insetances belong to this app.
;
_CleanUpApplicationComponents <53>
;
; Clean up the Palette Manager if there is one.
;
CMP.W #$3FFF,ROM85 ; do we have color QD?
BHI.S @noPMgrExit
_PMgrExit
@noPmgrExit
;
; Clean up Sound Manager
;
_SndAppDead
;
; Clean up application-specific Script Mgr globals (incl itl2/4 cache) <27><32>
;
SUBQ #2,SP ; space for OSErr result
_CleanupScriptApp ; go clean up apps script globals
ADDQ #2,SP ; always returns NoErr, ignore
;
; Clean up Resource Manager. Close resource files from the top of the
; chain down to, but not including, the system file. After this, defprocs
; and any other "system" code from the application chain are suspect.
; NOTE: Could be using ROM routine CloseFiles in ResourceMgr.a.
;
@CloseResFiles
move.l TopMapHndl, a1 ; start at the top
subq #4,sp
move.l SysMapHndl,-(sp) ; <50>
_GetOverrideMap ; <50> Stop at the first system override file
cmpa.l (sp)+, a1 ; down to the system file?
beq.s @DoneResMgr ; stop at the system file
move.l (a1), a1 ; deref handle to get map
move.w MRefNum(a1), -(sp) ; get file refnum from map
_CloseResFile ; close said file (sets new TopMapHndl)
bra.s @CloseResFiles ; and try again
@DoneResMgr
;
; Do BTree Manager clean up
;
suba #fscpbLen,sp ; allocate ioPB
movea.l sp,a0 ; a0=ioPB
moveq #(fscpbLen/4)-1,d0 ; d0=size in long
movea.l a0,a1
@BTClear clr.l (a1)+
dbra d0,@BTClear
_BTCleanUp ; clean up B*tree
;
; Do File System clean up
;
moveq #(fscpbLen/4)-1,d0 ; d0=size in long
movea.l a0,a1
@FSClear clr.l (a1)+
dbra d0,@FSClear
_FSCleanUp ; cleanup FS
adda.L #fscpbLen,sp ; deallocate space
rts
ENDPROC ; CleanupApp
;___________________________________________________________________________________
;
; FUNCTION get70MgrAttr(selector : OSType; VAR response : LONGINT) : OSErr;
;
; Generic Gestalt function for testing for existence of System 7.0
; features. Since this patch is for 7.0 only, it always returns 1 in the
; response. If your particular feature requires more bits set in the
; response, don't use this routine. Currently, this is the function
; for the gestaltDBAccessMgrAttr and gestaltEditionMgrAttr selectors.
;
; Registers A0 and A1 are destroyed.
;
;___________________________________________________________________________________
get70MgrAttr PROC
MOVE.L (SP)+,A0 ; return address
MOVE.L (SP)+,A1 ; address of result
MOVE.L #1,(A1) ; 7.0 features always under 7.0!
ADDA.W #4,SP ; pop the selector type
MOVE.W #noErr,(SP) ; it always works
JMP (A0)
ENDPROC ; get70MgrAttr
;___________________________________________________________________________________
;
; Additional patch code goes here
;
;___________________________________________________________________________________
;___________________________________________________________________________________
;
; dimg entry - Dictionary Manager
;
;___________________________________________________________________________________
DictionaryDispatch PatchProc _DictionaryDispatch
DictionaryHandle EQU ExpandMemRec.emDictionaryMgrPackHandle
DictionaryUseCount EQU ExpandMemRec.emDictionaryMgrUseCount
MOVE.L ExpandMem,A1 ; get expand mem into A1
MOVE.L DictionaryHandle(A1),A0 ; move the handle to the code into A0
ADD.W #DictionaryUseCount,A1 ; A1 = pointer to use count
_ProcHelper ; let ProcHelper take over
ENDPROC ; DictionaryDispatch
;___________________________________________________________________________________
;
; Install Gestalt functions for gestaltDBAccessMgrAttr, gestaltEditionMgr,
; gestaltStandardFileAttr, and gestaltAppleEventsAttr
;
; !!!! all just return 1 for system 7.0 !!!!!
;
;___________________________________________________________________________________
MiscPatchesInstall InstallProc
IMPORT get70MgrAttr
IF hasDataAccessMgr THEN ; <37>
MOVE.L #gestaltDBAccessMgrAttr, D0 ; Data Access Manager
lea get70MgrAttr, A0
_NewGestalt
ENDIF
IF hasEditionMgr THEN ; <37>
MOVE.L #gestaltEditionMgrAttr, D0 ; Edition Manager
lea get70MgrAttr, A0
_NewGestalt
ENDIF
MOVE.L #gestaltStandardFileAttr, D0 ; Standard File
leaResident get70MgrAttr, A0
_NewGestalt
IF hasAppleEventMgr THEN ; <37>
MOVE.L #gestaltAppleEventsAttr, D0 ; AppleEvent Manager
lea get70MgrAttr, A0
_NewGestalt
ENDIF
;___________________________________________________________________________________
; Gestalt function for the dictionary manager.
; just returns 1 for CubeE
;____________________________________________________________________________________
MOVE.L #gestaltDictionaryMgrAttr, D0 ; Dictionary Manager
lea get70MgrAttr, A0
_NewGestalt
RTS
ENDPROC
END ; of file