mirror of
https://github.com/elliotnunn/supermario.git
synced 2024-11-22 19:31:02 +00:00
274 lines
10 KiB
Plaintext
274 lines
10 KiB
Plaintext
;
|
||
; File: PackageMgr.a
|
||
;
|
||
; Contains: xxx put contents here (or delete the whole line) xxx
|
||
;
|
||
; Written by: xxx put name of writer here (or delete the whole line) xxx
|
||
;
|
||
; Copyright: © 1983-1992 by Apple Computer, Inc., all rights reserved.
|
||
;
|
||
; Change History (most recent first):
|
||
;
|
||
; <SM3> 6/11/92 PN Roll in patchIIciROM.a the optimized package 4 and 5 in
|
||
; Startboot.a and delete Pack4 &5 in this file
|
||
; <SM2> 5/20/92 TN Removed entry points for Packs 8, 9, 11, 13, 15. They are now
|
||
; with the corresponding Pack sources.
|
||
; <1.2> 8/22/89 SES Removed references to nFiles.
|
||
; <1.1> 11/10/88 CCH Fixed Header.
|
||
; <1.0> 11/9/88 CCH Adding to EASE.
|
||
; <•1.1> 9/23/88 CCH Got rid of inc.sum.d and empty nFiles
|
||
; <1.0> 2/11/88 BBM Adding file for the first time into EASE…
|
||
; <C636> 1/14/87 JTC Unrolled the Pack 4&5 code to expedite, so 881 wouldn’t be
|
||
; slowed any more than necessary.
|
||
; <C215> 10/14/86 RDC Removed check for FPU on NuMac - it is assumed to always be
|
||
; there and FPU packs replace packs 4 and 5
|
||
; <C206> 10/9/86 bbm Modified to mpw aincludes.
|
||
; <C169> 9/23/86 JTC Cleanse pack address with _StripAddress rather than CLR.B before
|
||
; jumping into package.
|
||
; <C67> 7/28/86 RDC Added changes to allow install of new math packs if NuMac FPU
|
||
; chip is installed.
|
||
; 2/19/86 BBM Made some modifications to work under MPW
|
||
; 7/10/85 LAK Added set up of ROMMapInsert for ROM resources.
|
||
; 5/7/85 JTC Minor clean-up and extend to 16 packages.
|
||
; 4/16/85 SC NoPack code changed and called after _LoadResource (in case the
|
||
; load failed)
|
||
; 4/16/85 SC InitAllPacks now saves/restores resload state (directly to low
|
||
; memory too, no traps
|
||
; 3/6/85 LAK Clear high byte of address before dispatching (to be nice . .
|
||
; .).
|
||
; 1/28/85 LAK Uses new equates files. Changed InitMath to InitAllPacks. Added
|
||
; ram patches.
|
||
; 6/15/83 AJH Made it use deep shit errors defined in SysErr
|
||
;
|
||
;
|
||
|
||
;EASE$$$ READ ONLY COPY of file “PackageMgr.a”
|
||
; 1.2 SES 08/22/1989 Removed references to nFiles.
|
||
; 1.1 CCH 11/10/1988 Fixed Header.
|
||
; 1.0 CCH 11/ 9/1988 Adding to EASE.
|
||
; OLD REVISIONS BELOW
|
||
;•1.1 CCH 9/23/1988 Got rid of inc.sum.d and empty nFiles
|
||
; 1.0 BBM 2/11/88 Adding file for the first time into EASE…
|
||
; END EASE MODIFICATION HISTORY
|
||
; File: Packages.TEXT
|
||
;---------------------------------------------------------------------
|
||
;
|
||
; Macintosh Application Package Dispatch Interface
|
||
;
|
||
; written by Jerome Coonen and Andy Hertzfeld 13-May-83
|
||
;
|
||
; ROM-based interface to RAM-based package. The packages are
|
||
; resources of type "PACK", numbered 0 through 7. Packages 0 through
|
||
; 3 are for use by applications (presumably, several applications
|
||
; sharing the same resources); packages 4 through 7 are reserved for
|
||
; math routines such as floating point arithmetic, elementary
|
||
; functions, etc.
|
||
;
|
||
; PROCEDURE InitPack(PackNumber : integer); when passed a
|
||
; PackNumber between 0 and 7 performs a GetResource of the appropriate
|
||
; PACK resource, setting up the dispatch vector for subsequent
|
||
; invocations of the package from the application. InitPack turns off
|
||
; resource loading (via SetResLoad) so that the GetResource simply
|
||
; up the resource map. Thus the package is loaded into memory, and
|
||
; need only be available at all in the resource file, if and when it
|
||
; is used. Resource loading is turned back on after the GetResource.
|
||
; InitPack follows the Pascal register conventions.
|
||
;
|
||
; PROCEDURE InitMath; calls InitPack four times with the arguments
|
||
; 4, 5, 6, and 7 and then initializes the 3 word floating point state
|
||
; area.
|
||
;
|
||
; Labels PACK0, PACK1, ..., PACK7 receive the respective A-line traps.
|
||
; The in turn transfer control to the package whose handle was saved
|
||
; by InitPack; they preserve ALL registers. They must check the
|
||
; handle, in case GetResource failed to find the package, and then
|
||
; check the pointer, in case the package has been purged.
|
||
;
|
||
; Modification history:
|
||
;
|
||
; 15-Jun-83 AJH Made it use deep shit errors defined in SysErr
|
||
;
|
||
;---------------------------------------------------------------------
|
||
;
|
||
; 28 Jan 85 LAK Uses new equates files. Changed InitMath to InitAllPacks.
|
||
; Added ram patches.
|
||
; 06 Mar 85 LAK Clear high byte of address before dispatching (to
|
||
; be nice . . .).
|
||
; 16 Apr 85 SC InitAllPacks now saves/restores resload state (directly
|
||
; to low memory too, no traps
|
||
; 16 Apr 85 SC NoPack code changed and called after _LoadResource (in case
|
||
; the load failed)
|
||
; 07 May 85 JTC Minor clean-up and extend to 16 packages.
|
||
; <10Jul85> LAK Added set up of ROMMapInsert for ROM resources.
|
||
;_______________________________________________________________________
|
||
;
|
||
; Post Lonely Hearts
|
||
;_______________________________________________________________________
|
||
;
|
||
; <19feb86> BBM Made some modifications to work under MPW
|
||
; <C67/28Jul86> RDC Added changes to allow install of new math packs
|
||
; if NuMac FPU chip is installed.
|
||
; <C169/23Sep86> JTC Cleanse pack address with _StripAddress rather than
|
||
; CLR.B before jumping into package.
|
||
; <C206/09oct86> bbm Modified to mpw aincludes.
|
||
; <C215/14Oct86> RDC Removed check for FPU on NuMac - it is assumed to
|
||
; always be there and FPU packs replace packs 4 and 5
|
||
; <C636/14Jan87> JTC Unrolled the Pack 4&5 code to expedite, so 881 wouldn’t
|
||
; be slowed any more than necessary.
|
||
;---------------------------------------------------------------------
|
||
|
||
|
||
BLANKS ON
|
||
STRING ASIS
|
||
|
||
LOAD 'StandardEqu.d'
|
||
|
||
PackDispatcher PROC EXPORT
|
||
|
||
EXPORT InitPack, InitAllPacks
|
||
EXPORT Pack0, Pack1, Pack2, Pack3, Pack6, Pack7
|
||
EXPORT Pack10, Pack12, Pack14
|
||
EXPORT PackMgrEnd
|
||
|
||
;
|
||
; PROCEDURE InitPack(PackNumber : integer);
|
||
;
|
||
; Stack: return adrs < PackNumber
|
||
;
|
||
InitPack
|
||
SUBQ.L #4,SP ; room for handle from GetResource
|
||
MOVE.L #'PACK',-(SP) ; resource type PACK
|
||
|
||
; Stack: "PACK" < handle slot < resLoad < return adrs < PackNumber
|
||
|
||
MOVE.W 12(SP),-(SP) ; resource number = PackNumber <10Jul85>
|
||
MOVE.W #MapFalse,ROMMapInsert ; check ROM map as well <10Jul85>
|
||
_GetResource
|
||
|
||
; Stack: handle slot < resLoad < return adrs < PackNumber
|
||
|
||
MOVE.W 8(SP),D0 ; PackNumber, beyond handle, ret adrs <10Jul85>
|
||
BSR.S GetPHand ; point A0 to the saved handle <07May85>
|
||
MOVE.L (SP)+,(A0) ; store resource handle <07May85>
|
||
|
||
; Stack: return adrs < PackNumber
|
||
|
||
MOVEA.L (SP)+,A0 ; return address
|
||
ADDQ.L #2,SP ; kill PackNumber
|
||
JMP (A0)
|
||
|
||
;
|
||
; PROCEDURE InitAllPacks;
|
||
;
|
||
InitAllPacks ; deleted FPU check for NuMac <C215>
|
||
MOVE.L (SP)+,A0 ; get trap return
|
||
MOVEQ #15,D0 ; 16 packages <07May85>
|
||
|
||
@1 MOVE.W D0,-(SP) ; pack to init
|
||
MOVE.L A0,-(SP) ; where to go
|
||
LEA InitPack,A0 ; where to go from here
|
||
DBRA D0,@1
|
||
MOVE.L A0,-(SP) ; push InitPack for RTS-style branch
|
||
|
||
CLR.W FPState ; set default modes for arithmetic
|
||
LEA FPException,A0
|
||
MOVE.L A0,FPState+2 ; default halt address
|
||
RTS ; RTS, initing all packs
|
||
|
||
; deleted FPU check for NuMac <C215>
|
||
|
||
;
|
||
; Default floating point exception handler simply signals deep six alert.
|
||
;
|
||
FPException
|
||
MOVEQ #DSFPErr,D0
|
||
_SysError
|
||
|
||
; deleted NuMac FPU check routine <C215>
|
||
|
||
; deleted Pack4 and Pack5 since they are installed at boot time <SM3>
|
||
|
||
;
|
||
; Given pack number 0..15 in D0.W, return A0 pointing to saved handle in low memory. <07May85>
|
||
;
|
||
GetPHand
|
||
LEA App2Packs,A0 ; presume it's the latter set <07May85>
|
||
SUBQ.W #8,D0 ; < 0 for 0-7; >= 0 for 8-15 <07May85>
|
||
BGE.S @1 ; Greater or Equal => App2Packs is right <07May85>
|
||
LEA AppPacks,A0 ; <07May85>
|
||
ADDQ.W #8,D0 ; <07May85>
|
||
@1
|
||
LSL.W #2,D0 ; mult by four to index into longs <07May85>
|
||
ADDA.W D0,A0 ; point to saved handle <07May85>
|
||
RTS ; <07May85>
|
||
|
||
|
||
;
|
||
; Common jump routine. Must preserve values of all registers.
|
||
; Jump to address saved in location AppPacks + OFFSET,
|
||
; where OFFSET = 2 * (<return address> - Pack1).
|
||
;
|
||
PackCom
|
||
MOVEM.L D0/A0,-(SP) ; need two work registers
|
||
MOVE.L 8(SP),D0 ; get return address
|
||
LEA Pack1,A0
|
||
SUB.L A0,D0 ; difference is 0,2,4,6,...,14,16,...,30 <07May85>
|
||
LSR.W #1,D0 ; back to 0,1,2,...,15 <07May85>
|
||
BSR.S GetPHand ; point A0 to saved handle <07May85>
|
||
|
||
TST.L (A0)
|
||
BEQ.S NoPack ; 0 handle means GetResource failed
|
||
|
||
MOVEA.L (A0),A0 ; now dereference handle down to pointer
|
||
TST.L (A0) ; 0 pointer means must reload resource
|
||
BNE.S GoToPack
|
||
|
||
MOVE.L A0,-(SP) ; push handle for LoadResource
|
||
MOVE.W #MapTrue,ROMMapInsert ; use ROM map as well <10Jul85>
|
||
_LoadResource ; Note: preserves ALL registers.
|
||
|
||
TST.L (A0) ; Did load fail? <SC 16-Apr-85>
|
||
BEQ.S NoPack ; if so, deep shit
|
||
GoToPack
|
||
; Get here with A0=handle; want to cleanse ptr. <C169>
|
||
MOVE.L (A0),D0 ; deref to dirty ptr <C169>
|
||
_StripAddress ; true address in D0 <C169>
|
||
MOVE.L D0,8(SP) ; pack adrs replaces old return adrs <C169>
|
||
MOVEM.L (SP)+,D0/A0 ; restore work registers
|
||
RTS ; into package
|
||
|
||
; Signal deep six alert if GetResource failed
|
||
|
||
NoPack
|
||
MOVE.L 8(SP),D0 ; get return address <SC 16-Apr-85>
|
||
LEA Pack1,A0
|
||
SUB.L A0,D0 ; difference is 0,2,4,6,...,14
|
||
LSR #1,D0 ; shift to 0,1,2,3,...,7
|
||
|
||
ADD.W #DSNoPackErr,D0 ; error number for this NoPack
|
||
_SysError
|
||
|
||
;
|
||
; Routines differ only in offset into handle table. So compute offset from
|
||
; the difference <return address> - Pack1
|
||
;
|
||
Pack0 BSR.S PackCom
|
||
Pack1 BSR.S PackCom
|
||
Pack2 BSR.S PackCom
|
||
Pack3 BSR.S PackCom
|
||
xPack4 BSR.S PackCom ; bogus name, to leave placeholder <C636>
|
||
xPack5 BSR.S PackCom ; bogus name, to leave placeholder <C636>
|
||
Pack6 BSR.S PackCom
|
||
Pack7 BSR.S PackCom
|
||
xPack8 BSR.S PackCom ; bogus name as placeholder. Entry in AEPackEntry.a <SM2 tcn>
|
||
xPack9 BSR.S PackCom ; bogus name as placeholder. Entry in PPCBrowserPackEntry.a <SM2 tcn>
|
||
Pack10 BSR.S PackCom
|
||
xPack11 BSR.S PackCom ; bogus name as placeholder. Entry in dpPackEntry.a <SM2 tcn>
|
||
Pack12 BSR.S PackCom
|
||
xPack13 BSR.S PackCom ; bogus name as placeholder. Entry in DataAccessPackEntry.a <SM2 tcn>
|
||
Pack14 BSR.S PackCom
|
||
xPack15 BSR.S PackCom ; bogus name as placeholder. Entry in puPackEntry.a <SM2 tcn>
|
||
PackMgrEnd
|
||
END
|
||
|