sys7.1-doc-wip/OS/Gestalt/GestaltExtensions.a

536 lines
19 KiB
Plaintext
Raw Normal View History

2020-05-10 05:37:38 +00:00
;
; Hacks to match MacOS (most recent first):
;
; <Sys7.1> 8/3/92 Elliot make this change
; 9/2/94 SuperMario ROM source dump (header preserved below)
;
2019-07-27 14:37:48 +00:00
;
; File: GestaltExtensions.a
;
; Contains: Linked patches for Gestalt
;
; Written by: Jeff Miller
;
; Copyright: © 1990-1993 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <SM10> 6/7/93 wc (Really BT)Fix a stupid bug of mine.
; <SM8> 6/3/93 SAM Updating the list of machine icons from the Gibbly project.
; <SM7> 5/10/93 CSS For 'bugy' return that the gestaltmtCheckFix has been fixed in
; SuperMario. Also, update the support of bugy to include bits
; from Indigo. Turned on gestaltGetIndResourceFix as the resource
; manager has been rewritten/reworked -- so we don't want this
; patch.
; <SM6> 3/31/93 CSS Support 'bugy' to add the fix gestaltMoveHHiExtraStackSpace.
; <SM5> 3/18/93 SAM Updated the list of machine icons
; <SM4> 11/11/92 RB Added a machine icon for the LC II, updated the machine icon
; table but left many as undefined. Also left the description of
; the machine on the side since I don't know what those machines
; look like. Changed the code to get the machine icon since we now
; have tons of them and it was out of bounds.
; <SM3> 9/25/92 RB Added a machine icon for the Quadra 950. Updated the machine
; names for some the icons.
; <SM2> 9/10/92 AEK Set FixedMicroseconds bit since QuickTime fixes rolled in (keeps
; QuickTime from patching PrimeTime and Microseconds)
; <1> 4/22/92 PN first checked in
; <2> 3/24/92 PN Move the HasSoftPowerOff and CQDFeatures GetOSTable GetToolboxTable
; GetExtToolboxTable GetFSAttr into GestaltFunction.a
; Remove BWQDFeatures
; <26> 1/19/92 DTY Turn on gestaltDietPatches in 'bugz'.
; <25> 1/10/92 DTY Add gestaltTrueTypeFix to 'bugz'.
; <24> 1/10/92 DTY Add 'bugz' gestalt selector with bits for 7 Up bugs that have
; been rolled into CubeE. (The ones with 0s arent in CubeE
; yet.)
; <23> 12/17/91 DTY Add gestaltResourceOverrides to the 'rsrc' attributes.
; <22> 12/2/91 SAM Using official boxflag equates now.
; <21> 10/28/91 SAM/KSM Rolled in Regatta file:
; Added Apollo to the list of machines that do have the PowerOff
; trap but do not have soft power off (in the
; GestaltHardwardAttributes patch)
; Changed the MachineIcon table to jibe with the new boxFlags.
; Removed the old <12> (put it back into GestaltFunction). (HJR)
; Added Eclipse, Spike, Tim, DBLite, and Asahi to the machine icon
; table.
; <20> 10/4/91 gbm Add the infamous 'rsrc' selector, and change unnecessary
; leaResident to lea
; <19> 9/26/91 gbm #89608: Make the assembler stop optimizing a move.l into a
; moveq. This screwed up the 'qdrw' selector.
; <18> 9/10/91 JSM Kill all codenames!
; <17> 7/3/91 JSM Remove obsolete SysVers conditional, remove 'lram' fix
; completely.
; <16> 3/17/91 DTY gbm, #SAM-005: Setting 'lram' to ROMBase is the Wrong Thing.
; Since 'ptch' 5 is installed on all machines now anyway, and
; theres a wrapper in the patch files which fill in the right
; values for 'lram' and 'ram ', the lramFix routine isnt needed
; anymore, and is IF 0d out.
; <15> 3/12/91 SAM #SAM-005: Made the “lram” selector universal and not assume 8mb
; limit on 24 bit machines (or 32 bit machines running in 24 bit
; mode).
; <14> 3/6/91 gbm dba,csd,dty,#gbm0008: add Quickdraw features selector, fix
; gestaltFSAttr to override the existing one...
; <13> 1/15/91 gbm (bbm) Add new hardware attribute, gestaltHasSoftPowerOff
; <12> 12/14/90 SAM Patched New/Replace Gestalt check for a nil proc ptr and updated
; the “lram” selector patch code to work on all machines.
; <11> 12/5/90 gbm <dba> Add two file system selectors: one for FSSpec calls
; existing, and another for file system manager existing
; <10> 11/29/90 SAM Fixed a typo.
; <9> 11/29/90 SAM Added an LPatch install time patch that reduces Gestalt's "lram"
; value to < 8 meg on IIci ROM systems in 24-bit mode with > 8 meg
; of RAM.
; <8> 9/22/90 KSM Add a semicolon before <7> on line 197 -- you're welcome dave.
; <8> 9/22/90 KSM Add a semicolon before <7> on line 197 -- you're welcome dave.
; <7> 9/22/90 dnf Turn on #gestaltFullExtFSDispatching
; <6> 9/10/90 gbm add file system attributes selector, gestaltFSAttr.
; <5> 8/17/90 JSM Fix machine icon function to work on machines with Gestalt in
; ROM, add Classic, IIsi, and LC icons, change some unnecessary
; leaResidents to leas.
; <4> 8/13/90 gbm add selectors for trap table bases
; <3> 7/18/90 EMT Changed EXPORT to ENTRY to avoid conflicts.
; <2> 7/18/90 CCH Moved machine icon selector in here from GestaltFunction.a,
; since it is added on all machines currently.
; <1> 7/13/90 JSM First checked in.
;
LOAD 'StandardEqu.d'
INCLUDE 'HardwarePrivateEqu.a'
INCLUDE 'GestaltEqu.a'
INCLUDE 'GestaltPrivateEqu.a'
INCLUDE 'SysPrivateEqu.a'
INCLUDE 'InternalOnlyEqu.a'
2020-05-10 05:37:38 +00:00
INCLUDE 'LinkedPatchMacros.a'
2019-07-27 14:37:48 +00:00
;————————————————————————————————————————————————————————————————————————————————————————————————————
; Record that describes stack frame for Gestalt functions
;
GestaltProcParms RECORD 0,INCREMENT
returnAddr DS.L 1
resultPtr DS.L 1
selector DS.L 1
error DS.W 1
ENDR
;————————————————————————————————————————————————————————————————————————————————————————————————————
; Installs new selectors that are not in ROM on any machine (yet).
;————————————————————————————————————————————————————————————————————————————————————————————————————
2020-05-10 05:37:38 +00:00
Newbugz InstallProc (Plus,SE,II,Portable,IIci)
2019-07-27 14:37:48 +00:00
IMPORT getBugFixes ; <24>
2020-05-10 05:37:38 +00:00
leaResident getBugFixes,a0 ; <24>
2019-07-27 14:37:48 +00:00
move.l #gestaltBugFixAttrs,d0 ; <24>
_NewGestalt
2020-05-10 05:37:38 +00:00
RTS
2019-07-27 14:37:48 +00:00
2020-05-10 05:37:38 +00:00
Newmicn InstallProc (Plus,SE,II,Portable,IIci)
2019-07-27 14:37:48 +00:00
IMPORT getMachineIcon
2020-05-10 05:37:38 +00:00
leaResident getMachineIcon,A0 ; address of gestaltMachineIcon patch
2019-07-27 14:37:48 +00:00
MOVE.L #gestaltMachineIcon,D0 ; selector to add
_NewGestalt
2020-05-10 05:37:38 +00:00
RTS
2019-07-27 14:37:48 +00:00
2020-05-10 05:37:38 +00:00
Newostt InstallProc (Plus,SE,II,Portable,IIci)
IMPORT getOSTable
leaResident getOSTable, a0
move.l #gestaltOSTable, d0
_NewGestalt
RTS
Newtbtt InstallProc (Plus,SE,II,Portable,IIci)
IMPORT getToolboxTable
leaResident getToolboxTable, a0
move.l #gestaltToolboxTable, d0
_NewGestalt
RTS
Newxttt InstallProc (Plus,SE,II,Portable,IIci)
IMPORT getExtToolboxTable
leaResident getExtToolboxTable, a0
move.l #gestaltExtToolboxTable, d0
_NewGestalt
RTS
Newrsrc InstallProc (Plus,SE,II,Portable,IIci)
2019-07-27 14:37:48 +00:00
IMPORT getResourceAttrs ; <20>
2020-05-10 05:37:38 +00:00
leaResident getResourceAttrs, a0 ; <20>
2019-07-27 14:37:48 +00:00
move.l #gestaltResourceMgrAttr, d0 ; resource manager attributes <20>
_NewGestalt ; <20>
2020-05-10 05:37:38 +00:00
RTS
2019-07-27 14:37:48 +00:00
2020-05-10 05:37:38 +00:00
Newqdrw InstallProc (Plus,SE,II,Portable,IIci)
IMPORT CQDFeatures
leaResident CQDFeatures, a0
move.l #gestaltQuickdrawFeatures, d0
_NewGestalt
RTS
Replacefs InstallProc (Plus,SE,II,Portable,IIci)
IMPORT getFSAttr
leaResident getFSAttr, a0
move.l #gestaltFSAttr, d0
_ReplaceGestalt
2019-07-27 14:37:48 +00:00
RTS
2020-05-10 05:37:38 +00:00
Replacehdwr InstallProc (Plus,SE,II,Portable,IIci)
WITH ExpandMemRec, GestaltGlobals
UnimplementedTrapNumber EQU $A89F
PowerOffTrapNumber EQU $5B
IMPORT HasSoftPowerOff, hdwrOrigAddr, hdwrNewBits
leaResident HasSoftPowerOff, a0 ; Replace 'hdwr' selector with shim
move.l #gestaltHardwareAttr, d0
_ReplaceGestalt
tst.w d0
bne.s @return
lea hdwrOrigAddr, a1 ; shim JSRs to original routine
move.l a0, (a1)
move.w #UnimplementedTrapNumber, d0 ; Check for PowerOff selector
_GetTrapAddress
move.l a0,a1
moveq #PowerOffTrapNumber, d0
_GetTrapAddress ,newOS
cmp.l a0, a1
beq.s @return
move.l ExpandMem, a0 ; Check for machines known to lack soft power
move.l emGestalt(a0), a0
cmp.w #gestaltMacSE30, machType(a0)
beq.s @return
cmp.w #gestaltMacLC, machType(a0)
beq.s @return
cmp.w #gestaltMacLCII, machType(a0)
beq.s @return
cmp.w #gestaltMacClassic, machType(a0)
beq.s @return
lea hdwrNewBits, a0 ; Set soft-power bit in the shim routine
move.l #1<<gestaltHasSoftPowerOff, (a0)
@return rts
2019-07-27 14:37:48 +00:00
ENDWITH
ENDPROC
2020-05-10 05:37:38 +00:00
qdrwBitsSet1 InstallProc (Plus,SE,Portable)
IMPORT qdrwBits
lea qdrwBits, a0
move.l #(1<<gestaltHasGrayishTextOr), (a0)
rts
qdrwBitsSet2 InstallProc (II,IIci)
IMPORT qdrwBits
lea qdrwBits, a0
move.l #(1<<gestaltHasColor)|(1<<gestaltHasDeepGWorlds)|(1<<gestaltHasDirectPixMaps)|(1<<gestaltHasGrayishTextOr), (a0)
rts
2019-07-27 14:37:48 +00:00
; these will get stripped out if nobody refers to them, so they are not conditionalized
2020-05-10 05:37:38 +00:00
************************************************************************
* OS trap table base
************************************************************************
getOSTable Proc Entry
move.l #$00000400, d0 ; this is the same on all machines
import stdResult
lea stdResult,a0
jmp (a0)
EndProc
************************************************************************
* Toolbox trap table base
************************************************************************
getToolboxTable Proc Entry
move.l RomBase, a0 ; get base of the rom... duh...
cmp.w #$0075, ROMHeader.MachineNumber(a0) ; are we on a MacPlus?
bne.s @notPlus
move.l #$00000C00, d0 ; this is only different on MacPlus
bra.s @stdResult
@notPlus
move.l #$00000E00, d0 ; this is where it goes on everything else
@stdResult
import stdResult
lea stdResult,a0
jmp (a0)
************************************************************************
* Extended Toolbox trap table base
************************************************************************
getExtToolboxTable Proc Entry
move.l RomBase, a0 ; get base of the rom... duh...
cmp.w #$0075, ROMHeader.MachineNumber(a0) ; are we on a MacPlus?
beq.s @plusOrSE ; yes, return the table base address
cmp.w #$0276, ROMHeader.MachineNumber(a0) ; are we on an SE?
beq.s @plusOrSE ; yes, return the table base address
import stdUnknown
lea stdUnknown,a0
jmp (a0)
@plusOrSE
move.l XToolTable, d0 ; get the table base from the vector...
import stdResult
lea stdResult,a0
jmp (a0)
2019-07-27 14:37:48 +00:00
************************************************************************
* <24> Bug fixes
************************************************************************
getBugFixes Proc Entry
moveq #0, d0
move.l # \
(1<<gestaltFixPrinting) | \
(1<<gestaltResponderCrashFix) | \
(1<<gestaltResponderVersionFix) | \
(1<<gestaltPurgeFonts) | \
(1<<gestaltAliasMgrFix) | \
(1<<gestaltSCSIFix) | \
(1<<gestaltKeyboardFix) | \
(1<<gestaltTrueTypeFix) | \ <25>
(1<<gestaltSaveLastSPExtra) | \
(1<<gestaltDietPatches) | \ <26>
2020-05-10 05:37:38 +00:00
(1<<gestaltBackgroundPrintingPatch) | \
(1<<gestaltNoPreferredAlertPatch) | \
2019-07-27 14:37:48 +00:00
(1<<gestaltAllocPtrPatches) | \
(1<<gestaltEPPCConnectionTableFix) | \
(1<<gestaltDAHandlerPatch) | \
(1<<gestaltLaunchFix) | \
(1<<gestaltDeathNoticePatches) | \
(1<<gestaltBacklightFix) | \
(1<<gestaltPrintDriverFix) | \
(1<<gestaltPMSegmentTweaks) | \
(1<<gestaltWDEFZeroFix) | \
(1<<gestaltPACKSixFix) | \
2020-05-10 05:37:38 +00:00
(1<<gestaltResolveFileIDRefFix) | \
(1<<gestaltDisappearingFolderFix) | \
(1<<gestaltPowerBookSerialFix) | \
(1<<gestaltPowerBookSleepQFix) | \
(1<<gestaltPowerBookFloppyEjectFix) \
2019-07-27 14:37:48 +00:00
, d0
import stdResult
lea stdResult,a0
jmp (a0)
EndProc
************************************************************************
* Machine Icon
************************************************************************
machineIcon proc entry
entry getMachineIcon
with ExpandMemRec, GestaltGlobals
; Icon ID ; (boxflag) machine name (icon name) <revision>
MachineIconTable
dc.w 3 ; unknown
dc.w -16482 ; 128, 512
dc.w 3 ; XL = unknown
dc.w -16482 ; 512Ke
dc.w -16482 ; Plus
dc.w -16483 ; SE
dc.w -16486 ; II
dc.w -16486 ; IIx
dc.w -16485 ; IIcx
dc.w -16483 ; SE/30
dc.w -16484 ; Portable
dc.w -16485 ; IIci
dc.w 3 ; unknown
dc.w -16486 ; IIfx
dc.w 3 ; unknown <5>
dc.w 3 ; unknown <5>
dc.w 3 ; unknown <5>
dc.w -16482 ; XO (same as Plus) <5>
dc.w -16502 ; Erickson <5>
dc.w -16503 ; Elsie <5>
dc.w -16504 ; (14) Eclipse <2>
dc.w -16505 ; (15) Tim <2>
dc.w -16507 ; (16) Spike <2>
dc.w -16482 ; (17) Apollo (same as plus/XO) <2>
dc.w -16508 ; (18) Asahi <2>
dc.w -16505 ; (19) Tim LC
dc.w -16504 ; (20) Eclipse33/Zydeco <2>
2020-05-10 05:37:38 +00:00
dc.w 3 ; (21) Vail25 <7>
dc.w 3 ; (22) Carnation33 <1>
dc.w 3 ; (23) DBLight25 <1>
dc.w 3 ; (24) Wombat 25/Lego <14>
dc.w 3 ; (25) Columbia <3>
dc.w 3 ; (26) DBLite33 <3>
dc.w 3 ; (27) Dartanian <3>
dc.w 3 ; (28) DartanianLC <3>
dc.w 3 ; (29) Wombat 33Mhz/fridge <3><14>
dc.w 3 ; (30) Wombat 33/Lego <3><14>
2019-07-27 14:37:48 +00:00
dc.w -16503 ; (31) FosterFarms <3>
2020-05-10 05:37:38 +00:00
dc.w 3 ; (32) Ansel (DBLite TFT) <23>
2019-07-27 14:37:48 +00:00
dc.w 3 ; (33) db20 <3><11>
dc.w 3 ; (34) Vail 16 <9><11>
dc.w 3 ; (35) Carnation 25 <9><11>
dc.w 3 ; (36) Carnation 16 <9><11>
2020-05-10 05:37:38 +00:00
dc.w 3 ; (37) Cyclone33 (Fridge) <24>
dc.w 3 ; (38) Brazil16 in Lego <10><14>
dc.w 3 ; (39) Brazil32 in Lego <10><14>
2019-07-27 14:37:48 +00:00
dc.w 3 ; (40) Brazil16 in Fridgidaire (Killed) <10><14>
dc.w 3 ; (41) Brazil32 in Fridgidaire (Killed) <10><14>
2020-05-10 05:37:38 +00:00
dc.w 3 ; (42) Brazil32c in Lego <10><14>
dc.w 3 ; (43) BoxSlice <9><11>
dc.w 3 ; (44) Monet <21>
dc.w 3 ; (45) Wombat 40/Lego <9><11><14><18>
dc.w 3 ; (46) WLCD 20Mhz/QFC <9><11>
dc.w 3 ; (47) WLCD 25 Mhz/QFC <9><11>
2019-07-27 14:37:48 +00:00
dc.w -16505 ; (48) PowerBook 145 (same as 140/170) <9>
MachineIconTableEnd
numMachineIcons equ (MachineIconTableEnd-MachineIconTable)/2
getMachineIcon
;
; We can't read the machine type directly from the globals, since the globals <5>
; structure used in certain ROM versions (like the Portable) is different from <5>
; the current structure. Otherwise, we could just do: <5>
; <5>
; Move.l ExpandMem,a1 ; find out where expandMem is <5>
; Move.l emGestalt(a1),a1 ; get global ptr <5>
; clr.l d0 ; clear result register <5>
; Move.w machType(a1),d0 ; put machineType in lsw of result <5>
; <5>
; but instead we have to call the gestaltMachineType function. <5>
; <5>
move.l #gestaltMachineType,d0 ; pass machine type selector in d0 <5>
_Gestalt ; <5>
move.l a0,d0 ; put machineType in d0 (only lsw is used) <5>
cmp.w #numMachineIcons,d0 ; do we have a table entry?
blo.s @gotTableEntry
clr.w d0 ; no entry, use the first one in the table
@gotTableEntry
add.w d0,d0 ; advance to offset in table
2020-05-10 05:37:38 +00:00
lea MachineIconTable,a0 ; get table in a0
move.w (a0,d0.w),d0 ; get icon resource id
2019-07-27 14:37:48 +00:00
import stdResult ; <5>
lea stdResult,a0 ; get address of result routine <5>
jmp (a0) ; save result and exit
endproc
2020-05-10 05:37:38 +00:00
************************************************************************
* Extended File System dispatching flags
************************************************************************
getFSAttr Proc Entry
moveq #0, d0
move.w # \
(1<<gestaltFullExtFSDispatching) | \
(1<<gestaltHasFSSpecCalls) | \
(0<<gestaltHasFileSystemManager) \
, d0
import stdResult
lea stdResult,a0
jmp (a0)
2019-07-27 14:37:48 +00:00
************************************************************************
* Resource manager flags
************************************************************************
getResourceAttrs proc entry ;<20>
moveq #0, d0 ;<20>
move.w # \ ;<20>
(1<<gestaltPartialRsrcs) | \ ;<20>
(1<<gestaltResourceOverrides) \ ;<23>
, d0 ;<20>
import stdResult
lea stdResult,a0
jmp (a0)
endproc
2020-05-10 05:37:38 +00:00
************************************************************************
* Quickdraw feature flags
************************************************************************
CQDFeatures Proc Entry
EXPORT qdrwBits
dc.w $203C ; MOVE.L #x, d0
qdrwBits
dc.l $12345678
import stdResult
lea stdResult,a0
jmp (a0)
************************************************************************
* New thing with the hdwr selector (yuck!)
************************************************************************
HasSoftPowerOff Proc Entry
EXPORT hdwrOrigAddr, hdwrNewBits
clr.w -(sp)
move.l 10(sp), -(sp)
move.l 10(sp), -(sp)
dc.w $4EB9 ; JSR to absolute pointer
hdwrOrigAddr
dc.l $40800000
move.w (sp)+, d1
beq.s @nojank
move.w d1, 12(sp)
import stdExit
lea stdExit, a0
jmp (a0)
@nojank
move.l 4(sp), a0
move.l (a0), d0
dc.w $0080 ; OR.L #xxxxxxxx, D0
hdwrNewBits
dc.l 0
import stdResult
lea stdResult,a0
jmp (a0)
2019-07-27 14:37:48 +00:00
************************************************************************
* Common Gestalt Function Return Code
************************************************************************
CommonCode PROC entry
ENTRY stdUnknown, stdResult, noError, stdExit
with GestaltProcParms
stdUnknown move.w #gestaltUnknownErr,error(sp) ; return gestaltUnknownErr
bra.s stdExit
stdResult move.l resultPtr(sp),a0 ; get ptr to place result
move.l d0,(a0) ; return value in d0
noError move.w #noErr,error(sp) ; return noErr
stdExit move.l (sp)+,a0 ; get return address off stack
addq.l #8,sp ; clean up stack
jmp (a0) ; return
ENDWITH
ENDPROC
END