mac-rom/Patches/BeforePatches.a

776 lines
32 KiB
Plaintext
Raw Normal View History

;
; File: BeforePatches.a (formerly RomAllFix.a)
;
; Contains: patches and patch installation code for all ROMs.
;
; Copyright: <09> 1986-1992 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <SM2> 5/20/92 stb Change an include to :Internal:Decompression.a. I did this once
; before, but I don<6F>t know where it went.
; <26> 1/19/92 DTY Check if AppleTalk is inactive. If it is, set
; emAppleTalkInactiveOnBoot to true, to let other things later on
; in the boot process and the Chooser know that network code
; shouldn<64>t be loaded.
; <25> 12/18/91 DTY Clear only the decompressPasswordBit in the memory attributes
; instead of the entire byte.
; <24> 10/15/91 DTY Set to twoDeepBit to cause one deep calls on the System file to
; look further down the chain for resources. Don<6F>t set the
; overrideNextMapBit (formerly the mapInsertedBit) for the System
; file.
; <23> 10/15/91 DTY Set the mapInsertedBit and dontCountOrIndexDuplicatesBit for the
; System file.
; <22> 9/18/91 JSM Cleanup header.
; <21> 7/3/91 JSM Remove obsolete conditionals and obsolete DSAT patch.
; <20> 6/12/91 LN Removed #includes for private interfaces from public interfaces.
; Changed #include 'HardwareEqu.a' to 'HardwarePrivateEqu.a'
; <19> 1/30/91 gbm sab, #38: Change the name of one of the decompressor header
; files (because Sheila said it was okay)
; <18> 10/30/90 dba Put code in here to set the bit on the system map so that dcmp
; resources will be loaded from it.
; <17> 7/11/90 gbm make changes trending to the elimination of assembler warnings
; <16> 6/14/90 JSM NEEDED FOR SIXPACK: Changed move.w of emRecSize to move.l. This
; doesn't really matter unless the ExpandMem block gets above 64K,
; which will never happen.
; <15> 5/29/90 DDG NEEDED FOR SIXPACK: Changed all the sixpack conditionals from
; six-point-oh-seven to six-point-oh-six.
; <14> 5/24/90 HJR NEEDED FOR SIXPACK: Fixed bug in ExpandMem where the system will
; create its own when the ROM's is larger.
; <13> 5/24/90 CCH Made eclipse the highest box flag supported on 6.0.6 and 6.1.
; (This should not be rolled into SixPac!)
; <12> 3/22/90 dba get rid of the DSAT 2 code for $700 since new boot code no
; longer exhibits this problem
; <11> 3/20/90 DDG Changed Sys607 to work on all machines thru Elsie.
; <10> 2/28/90 DD put proc and endp around the ADBInitPatch too.
; <9> 2/28/90 DD added proc and endP directives so we can use the BIND macros in
; DecompressPatch.a
; <8> 1/24/90 CV Adding checks to limit the CPUs supported by each system disc.
; System 6.0.5 will support CPUs through F-19. Sytem 6.0.6 will
; support CPUs through XO. System 6.1.0 will support CPUs through
; Erickson.
; <7> 1/22/90 CCH NEEDED FOR 6.0.5: Now gets the current size from any existing
; record, and points the expandMem global to the new record before
; disposing of the old one.
; <6> 1/19/90 PKE NEEDED FOR 6.0.5 AND Scripts604: install an ADBproc so that
; ADBReInit will set up the correct KCHR for use by KeyTrans.
; <5> 1/18/90 DD Changed a comment
; <4> 1/18/90 DD Moved DeCompressor patch in front of KeyTrans Patch so the
; conditional cutback will work.
; <3> 1/17/90 DD Added DeCompressor patch.
; <2> 1/4/90 PKE Updated conditionals so SS-6.0.4 changes go in 6.0.5 as well as
; 7.0. Updated header to BBS format.
; <1> 12/17/89 CCH Adding for the first time into BBS.
; (BBS versions above, EASE versions below)
; <1.9> 12/1/89 dba NEEDED FOR 6.0.5: changed conditionals left over from 6.0.4
; <1.8> 11/16/89 EMT Moved KeyTrans trap as well, since keyboard relies on it.
; <1.7> 11/16/89 EMT Moved keyboard initialization from ROM75Fix for FullWrite and
; MacroMaker.
; <1.6> 8/28/89 SMB NEEDED FOR 604 Scripts: Must increase ExpandMem for TE vectors
; for Mac Portable for 6.0.4 Script System Builds. Removed load of
; nEqu.d.
; <1.5> 8/11/89 dba NEEDED FOR 6.0.4: improved the check for <20>too new<65> ROMs by
; checking ROM85 before looking at BoxFlag; left check in for 7.0
; on the assumption that there will be ROMs too new for us even
; then
; <1.4> 8/10/89 CCH NEEDED FOR 6.0.4: For 6.0.4 only, make sure we're running on a
; pre-F19 system and that we're in 24-bit mode.
; <1.3> 2/21/89 CCH Added check to see if expandMem has already been initialized
; before re-initializing it.
; <1.2> 2/20/89 JB (with DNF) Moved cache control trap (PP332), "not a Mac disk"
; ExtFSPatch (P003), and MapFBlock (S118,P005) to individual
; machine patch files. No longer here!
; <1.1> 1/16/89 CCH Merged 6.0.3 final sources into 7.0.
; 1/1/89 CCH Start using SysVers equate, and added conditionals for 6.0.4.
; <1.0> 11/16/88 CCH Added to EASE.
; (pre-EASE history below)
; <S518> 7/1/88 EKH Bumped the hex version number to v6.1, for the Altair release.
; <S507> 6/21/88 EKH Bumped the hex version number to v6.0.1, for the next release.
; <PPyyy> 1/8/88 EKH Bumped the hex version number to v6.0, to match the system disk
; version.
; <PP332> 12/14/87 JB Added cache control trap
; <PPyyy> 12/3/87 EKH Bumped the hex version number for v4.4 system (used by
; SysEnvirons calls).
; <PP296> 10/19/87 SHF Moved call to SCSILoad to each individual patch file (rom75fix,
; etc.).
; <PP282> 9/19/87 BB Modified ExtFS patch (S084 in BeforePatches.a) to release the
; AppleShare FCB following an unsuccessful Close call on an
; offline server volume.
; <PA254> 8/7/87 bbm bumped version number (SysVersNo) for new release.
; <PP227> 7/23/87 BB Fixed ExtFSPatch (S084) to properly set up stack befor calling
; an external FS.
; <PPyyy> 6/15/87 JTC Changes to make system A/UX-friendly.
;
; Above changes are post version 4.2
;
; <PP149> 3/28/87 JTC Jam system version number to its rightful home in SysVersion.
; <PP130> 3/24/87 JTC&SHF Avoid hitting HwCfgFlags on ROM69 machines when installing SCSI
; patch.
; <P005><S118> 3/19/87 BB Added patch to MapFBlock to fix error in the calculation of
; physical block numbers (adding a word value rather than a long
; word value).
; <P004><S089> 3/7/87 SHF Added call to SCSILoad in ROM to load drivers from drives which
; weren't ready at initial boot up.
; <P003><S084> 3/5/87 BB Added patch to CmdDone to call external file systems if
; 'NoMacDskErr' is returned from MountaVol.
; <P002><Pyyy> 2/28/87 med Added patch to load the DSAT 2 for Mac,Mac+,Maui
; <P001><Pxxx> 2/27/87 med Add some more memory for keyboards, Use equates for ExpandMem,
; and record
; <P001><P029> 1/24/87 JTC Created file today, based on PatchSEROM.a. Added code to
; allocate
;
;############################## ROM All Patch File ##############################
LOAD 'StandardEqu.d'
include 'HardWarePrivateEqu.a'
include 'SCSIEqu.a'
include 'ScriptPriv.a'
include 'PatchMacros.a'
include 'ApplDeskBus.a' ; <6>
include 'ResourceMgrPriv.a'
include 'Decompression.a' ; <sm1>stb
ROMAllFix PROC EXPORT
IMPORT RAMSysInit
EXPORT SysBase,CutBack
; Cut back Code:
;
; SysBase is the entry point for ROMAllFix. Upon entry D1.L contains our handle.
;
; Once the patches have been installed, this code is cut back to exclude the patch
; installation code.
SysBase
BRA RAMSysInit ; do the patch installation.
DC.l ('PTCH') ; resource type
DC.W $0000 ; patch ID 0 to work with all ROMs.
DC.W 0 ; current version number.
; cut back the ram-based system code to exclude this initialization code
CutBack
_SetHandleSize ; adjust our size
MOVEQ #$7F,D0 ; a soon to be large number
SWAP D0
_CompactMem ,SYS ; optional comma
RTS ; all done
ENDP
;#####################################################################################
;############################## START PATCH CODE #####################################
;#####################################################################################
; Put new resident patch code here.
;######################### ADBReInit PATCH ********########################## <6>
; ADBReInit causes ADB keyboards to be reset to use KCHR 0. It can be called
; after booting - for example, on the Portable at wakeup if devices are
; connected to the external ADB port. This causes problems for international
; systems, which are normally using other KCHRs. On the non-Roman systems, users
; may also frequently switch back and forth between various KCHRs. Fortunately,
; a pointer to the current KCHR is kept in ExpandMem. This patch (actually, an
; ADBProc) gets the current KCHR pointer from ExpandMem and stuffs it into the
; keyboard driver data structures for all connected keyboards.
;################################################################################
ADBReInitProc Proc
EXPORT ADBReInitPatch, oldJADBProc
oldJADBProc ds.l 1 ; old jADBProc vector (writeable)
ADBReInitPatch
; Only set up KCHR if this is a post-processing call to jADBProc and we
; have an active KCHR pointer in ExpandMem. ADBReInit can't get called on
; non-ADB machines, so we don't have to test if ADB is present.
with ExpandMemRec
tst.b d0 ; is this post processing?
beq.s @doneADBReInitPatch ; no, skip
move.l ExpandMem,a0 ; get expandmem pointer
move.l emKeyCache(a0),d1 ; is there a KCHR pointer?
beq.s @doneADBReInitPatch ; no, bail
endwith ;ExpandMemRec
; save regs and set up for loop
with ADBDataBlock
movem.l d0/d3-d4,-(sp) ; save regs (incl. flag in d0)
move.l d1,d4 ; copy KCHR pointer
sub.w #dbBlkSize,sp ; allocate ADBDataBlock on stack
; Loop through the ADB records, setting the KCHR pointer in all records
; belonging to keyboard devices.
_CountADBs ; load ADB count.
move.w d0,d3 ; copy count for loop.
bra.s @nextADB ; enter loop at bottom.
@ADBLoop move.w d3,d0 ; device table index - 1.
addq.w #1,d0 ; get real index (1..n).
move.l sp,a0 ; pass addr of ADBDataBlock.
_GetIndADB ; load device record.
cmp.b #kybdADBAddr,origADBAddr(sp) ; is it a keyboard?
bne.s @nextADB ; if not, skip it.
move.l dbDataAreaAddr(sp),a0 ; load data area pointer.
clr.l KybdDriverData.deadKey(a0) ; clear dead state.
move.l d4,KybdDriverData.KCHRPtr(a0) ; set KCHR pointer.
@nextADB dbra d3,@ADBLoop ; next ADB device or done.
; clean up stack and restore regs
add.w #dbBlkSize,sp ; kill ADBDataBlock
movem.l (sp)+,d0/d3-d4 ; restore regs
endwith ;ADBDataBlock
; do previously-installed proc(s) and return
@doneADBReInitPatch
move.l oldJADBProc,a0 ; get old jADBProc vector
jsr (a0) ; do previously-installed procs
rts ; (can't we just jmp above and
; skip this rts?)
ENDP
;######################### DeCompressor PATCH ********#####################
include 'DeCompressorPatch.a'
;######################### KeyTrans PATCH ********#####################
; -----------------------------------------------------------------------------
; Routine: KeyHook
; Input: d1.b option, alpha, shift keys in 2,1,0.
; $17A.b bit #7 1 iff feature key set.
; d2.w keycode (0-127).
; d3.b minus iff keyup, plus iff keydown.
; Output: d0.b ASCII code.
;
; Macintosh keyboard mapping hook, which relies on the new KeyTrans trap.
; -----------------------------------------------------------------------------
KeyHook PROC EXPORT
with ExpandMemRec
bra.s SkipHeader ; skip the header.
; Global variables left here for the wacky Key Caps accessory.
deadEnable dc.w $ffff ; enable the dead key processing.
dc.l ('INIT') ; resource type.
dc.w 0 ; resource id number.
export intlEnable
intlEnable dc.b $00 ; intl keybooard flag (false).
dc.b 7 ; hook version number.
dc.w $0000 ; slot to mollify MacTerm. <S159>
; If this is the domestic or international keyboard hook, we check for keycodes
; that are in the keypad range. These are handled by just returning zero so
; the keypad hook can handle them.
SkipHeader
cmp.b #$40,d2 ; beyond keyboard range?
bhs.s @domestic ; yes -> skip mapping.
; If the international flag is on in the header, this is an original
; Macintosh 128K, 512K, 512Ke, or MacPlus, and the keyboard type is not
; the MacPlus key dorfer with built-in keypad, then we perform a mapping
; from key codes to virtual key codes. The original domestic keyboard and
; MacPlus key dorfer just happen to generate virtual key codes all by
; themselves.
move.b intlEnable,d0 ; international flag set?
beq.s @domestic ; no -> skip remapping.
move.w HwCfgFlags,d0 ; load hardware configuration.
btst.l #hwCbADB,d0 ; ADB present?
bne.s @domestic ; yes -> skip remapping.
cmp.b #$0b,kbdType ; MacPlus keyboard?
beq.s @domestic ; yes -> skip remapping.
lea keyTable,a0 ; find the table.
move.b 0(a0,d2.w),d2 ; map to virtual key code.
; Build the arguments and call to the keyboard trap to produce an ASCII code.
; We get the modifiers from the arguments, except for the command key, which is
@domestic
move.b $17A,d0 ; command key is in high bit of D0
lsl.b #1,d0 ; command bit is in X CC
roxl.w #1,d1 ; command now in low bit of D1
move.b d3,d0 ; up/down key is in high bit of D0
lsl.b #1,d0 ; up/down bit is in X CC
roxl.w #1,d1 ; up down now in low bit of D1
lsl.w #7,d1 ; shift all the way up
or.b d2,d1 ; put keycode in low 7 bits.
move.b deadEnable,d0 ; dead keys enabled?
bne.s @deadOn ; yes -> allow key down calls.
bset #7,d1 ; no -> force key up call.
@deadOn
subq.l #4,sp ; make room for result.
move.l expandMem,a0 ; get low memory pointer
move.l emKeyCache(a0),-(sp) ; pass the key cache pointer
move.w d1,-(sp) ; push keycode and modifiers.
pea emKeyDeadState(a0) ; push address of dead key state.
_KeyTrans ; call keyboard trap.
; KeyTrans has left a present for us on the stack. Each word is an ASCII code
; if that word is to be reported as an event, or zero if nothing should happen.
; Coincidentally, our caller expects us to return zero if he should not report
; the event, or the ASCII code if he should. We check the first word and do
; that one ourselves. The second one is left up to the caller. Bring in the
; Hydra!
moveq #0,d0 ; clear a long.
move.w (sp)+,d0 ; get first return code.
beq.s @noPost ; no need to post an event
lsl.w #8,d2 ; shift key code over.
or.w d2,d0 ; or in key code.
move.w #KeyUpEvt,a0 ; assume key up
tst.b d3 ; keyUp?
bmi.s @postIt ; yes -> skip check
move.w #KeyDwnEvt,a0 ; load key down
@postIt _PostEvent ; generate an extra event.
@noPost move.w (sp)+,d0 ; get the second return code.
rts ; return to the caller.
endwith
; ----------------------------------------------------------------------------
; In order to map the old international keyboard correctly, we use the
; following translation table to map key codes to virtual key codes. This
; is not necessary on an old domestic keyboard as the key codes <20>just happen
; to match<63> the virtual key codes.
; ----------------------------------------------------------------------------
keyTable
dc.b $00, $01, $02, $03, $04, $05, $32, $06 ; $00 .. $07
dc.b $07, $08, $2c, $09, $0c, $0d, $0e, $0f ; $08 .. $0f
dc.b $10, $11, $12, $13, $14, $15, $16, $17 ; $10 .. $17
dc.b $18, $19, $1a, $1b, $1c, $1d, $1e, $1f ; $18 .. $1f
dc.b $20, $21, $22, $23, $2a, $25, $26, $27 ; $20 .. $27
dc.b $28, $29, $24, $2e, $2f, $0b, $2d, $2b ; $28 .. $2f
dc.b $30, $34, $0a, $33, $31, $35, $36, $37 ; $30 .. $37
dc.b $38, $39, $3a, $3b, $3c, $3d, $3e, $3f ; $38 .. $3f
ENDP
; -----------------------------------------------------------------------------
; (Patch #60) KeyTrans by Ed Tecot.
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchPlusROM.a 21Nov86 #60 (KeyTrans) (KeyTrans)
;
; Keyboard transation trap for MacPlus. This is provided for compatability
; with new system file resources.
;
; FUNCTION KeyTrans(transData: Ptr; keyCode: Integer;
; Var state: LongInt): LongInt;
;
; Translates a keycode to ASCII.
; TransData is a pointer to a KCHR resource for the use of KeyTrans.
; KeyCode is an integer which contains in bits:
; 0-6 "virtual" keycode
; 7 1 = key up
; 8-15 modifier flags similar to event manager.
; State is an internal code used by KeyTrans, which should be 0 on first call.
; The LongInt returned is actually two words which are to be posted as events.
; $0000 should not be posted; if both words contain values, the high word
; should be posted first.
;
; <21Nov86 jdt>
; -----------------------------------------------------------------------------
KeyTrans PROC EXPORT
; Equates for keyboard character tables (type 'KCHR').
vers EQU $00
tInx EQU vers+2
tCnt EQU tInx+$100
tBgn EQU tCnt+2
MOVE.L (SP)+, D0 ; Return address in D0
MOVE.L (SP)+, A0 ; state address in A0
MOVE.W (SP)+, D1 ; keycode in D1
MOVE.L (SP)+, A1 ; KCHR address in A1
MOVE.L D0, -(SP) ; Put the return address back.
MOVEM.L A2/D3, -(SP) ; Save registers
MOVE.W D1, D2
LSR.W #8, D2 ; Shift modifier flags down
MOVE.B tInx(A1, D2.W), D2 ; Table number in D2
MOVEQ #$7F, D0
AND.B D1, D0 ; D0 contains virtual keycode only
EXT.W D1
EXT.L D1 ; Move up/down bit to bit 31
MOVE.B D2, D1 ; Put the table number in D1
LSL.W #8, D1 ; Shift it up one byte
MOVE.B D0, D1 ; Put in the virtual keycode
; At this point D1 contains all the neccesary input information:
; Bit 31 up/down bit (BMI for up stroke)
; Bits 15-8 modifier bits (also in low byte of D2)
; Bit 7 0
; Bits 6-0 "virtual" keycode
LSL.W #7, D2 ; Multiply by 128
OR.B D1, D2 ; Stuff in keycode
ADD #tBgn, A1 ; A1 is now start of tables
MOVE.B (A1, D2.W), D0 ; ASCII byte in D0
BEQ.S MightBeDead ; Go find out if it really is a dead key.
TST.L D1 ; Key up or down?
BMI.S UpKey ; Skip if up
MOVE.L (A0), D3 ; Previous key dead?
BEQ.S KeyExit ; Done if not
CLR.L (A0) ; Clear out dead key state
LEA (A1, D3.L), A2 ; A2 points to completor table
MOVE.W (A2)+, D2 ; Number of completors in D2
BEQ.S NoComp ; If none, skip
SUBQ.W #1, D2 ; Turn it into a zero-based count
CompLoop
CMP.B (A2)+, D0 ; Do we match?
BEQ.S GotComp ; Jump out if we do
ADDQ.L #1, A2 ; Get to next completor
DBRA D2, CompLoop ; Go around again
NoComp
SWAP D0
MOVE.W (A2), D0 ; Store the default code
SWAP D0
BRA.S KeyExit
GotComp
MOVE.B (A2), D0 ; Get the completor
BRA.S KeyExit
MightBeDead
MOVE.W -2(A1), D3 ; Number of tables in D3
LSL.W #7, D3 ; 128 bytes per table
LEA (A1, D3.W), A2 ; Start of dead key table in A2
MOVE.W (A2)+, D2 ; Number of dead keys in D2
BEQ.S NotDead ; There are no dead keys
SUBQ.W #1, D2 ; Turn it into a zero-based count
DeadLoop
CMP.W (A2)+, D1 ; Do we match?
BEQ.S GotDead ; Jump out if we do
MOVE.W (A2)+, D3 ; Get number of completors
LSL.W #1, D3 ; Multiply by 2
LEA 2(A2, D3.W), A2 ; A2 now points to next entry
DBRA D2, DeadLoop ; Go around again
NotDead ; D0 already contains $00000000
UpKey ; D0 already contains correct ASCII
KeyExit
MOVEM.L (SP)+, A2/D3 ; Restore registers
MOVE.L D0, 4(SP) ; Put return value on stack
RTS ; Sayonara
; The key is a dead key. A2 points to the beginning of the completor table.
GotDead
TST.L D1 ; Key up or down?
BMI.S UpDead ; Skip if up
MOVE.L (A0), D3 ; Previous key dead?
BEQ.S SaveState ; Skip if not
MOVEQ #0, D2 ;
MOVE.W (A1, D3.L), D2 ; Get the number of completors for previous
LSL.W #1, D2 ; Multiply by 2
ADD.L D2, D3 ;
MOVE.W 2(A1, D3.L), D0 ; D0 now has default code for previous dead key
SaveState
TST.W (A2) ; See if there are any completors
BEQ.S @1 ; Skip if not
MOVE.L A2, D2 ; Location of completor table
SUB.L A1, D2 ; Subtract base address
MOVE.L D2, (A0) ; Save it
BRA.S KeyExit
@1 CLR.L (A0) ; Clear out dead key state
SWAP D0 ; There might be something in the low word
MOVE.W 2(A2), D0 ; Send out the default code
BRA.S KeyExit ;
UpDead
MOVE.W (A2)+, D3 ; Get the number of completors
LSL.W #1, D3 ; Multiply by 2
MOVE.W (A2, D3.W), D0 ; Put default code in D0
BRA.S KeyExit
ENDP
;#####################################################################################
;############################### END PATCH CODE ######################################
;#####################################################################################
;#####################################################################################
;############################# PATCH INSTALL CODE ####################################
;#####################################################################################
RAMSysInit PROC EXPORT
IMPORT SysBase,CutBack
Move.L D1,-(SP) ;save our handle
;#####################################################################################
; P001 P027 24Jan87 JTC Allocate extended memory for international folks.
; This is not a patch, but it belongs in line.
;
; P001 Pxxx 2/27/87 med Add some more memory for keyboards,
; Use equates for ExpandMem, and record
; pp582 10/20/88 bbm&cch now checks to see if rom initialized expandmem.
; 24Aug89 smb Must increase ExpandMem for TE vectors on Mac Portable
; <7> 1/22/90 cch Now gets the current size from any existing record, and points the
; expandMem global to the new record before disposing of the old
; one.
;#####################################################################################
with ExpandMemRec
move.l ExpandMem,D0 ; test if expandmem is initialized <pp582>
addq #1,D0 ; (not inited is -1) <pp582>
beq.s @MakeExpandMem ; <24Aug89smb>
; must increase ExpandMem for TE vectors for Mac Portable <24Aug89smb>
; test if already allocated new block for ExpandMem <2Feb89smb>
movea.l ExpandMem,a0
move.l emSize(a0),d0 ; current size of ExpandMem record <7>
cmpi.l #emRecSize,d0 ; already allocated new blocks?
bge.s @noSpandex ; <14>
; allocate new block for ExpandMem
movea.l a0,a1 ; save original ExpandMem pointer
move.l #emRecSize,d0 ; allocate correct amount of space <7> <16>
_NewPtr ,SYS,CLEAR
bne @ErrorXit
; a0 = pointer allocated for new expandMem of emRecSize bytes.
; copy original bytes of expandMem into my local space.
move.l emSize(a1),d0 ; current size of ExpandMem record <7>
exg a0,a1 ; want source in a0 <29June89smb>
_BlockMove ; <29June89smb>
move.w #emCurVersion,emVersion(a1) ; version number <7>
move.l #emRecSize,emSize(a1) ; size <7>
move.l a1,ExpandMem ; start using new expandMem <7>
; dispose of original ExpandMem pointer.
_DisposPtr ; still in a0 after move <29June89smb>
beq.s @noSpandex ; exit if everything is ok <7>
@ErrorXit _SysError ; <24Aug89smb>
@MakeExpandMem
clr.l ExpandMem ; aka <20>BasicGlob<6F>
move.l #emRecSize,d0 ; size of extension to old low-mem
_NewPtr sys,clear ; get a blob of extension memory
bne.s @noSpandex ; if no mem, leave null in global ptr
move.l a0,ExpandMem ; stuff global ptr
move.w #emCurVersion,(a0)+ ; version number
move.l #emRecSize,(a0) ; size
endWith
@noSpandex ; skip around when no room
;____________________________________________________________________________________
; Jam system version number. <PP149>
move.w #SysVers,SysVersion ; jam sys version number <v1.1>
;____________________________________________________________________________________
; Check to see if AppleTalk is active. If it is not, set emAppleTalkInactiveOnBoot
; to true. Various other parts of the System will look at this global later on to
; determine whether or not network code should be loaded.
move.b SPConfig,d0 ; <26> Get serial port configuration
and.b #$0f,d0 ; <26> Mask off Port B bits
cmp.b #useATalk,d0 ; <26> Configured for AppleTalk?
beq.s @appleTalkIsActive ; <26> Yes. Don<6F>t set emAppleTalkInactiveOnBoot
with ExpandMemRec
move.l ExpandMem,a0 ; <26>
move.w #-1,emAppleTalkInactiveOnBoot(a0) ; <26>
@appleTalkIsActive
;____________________________________________________________________________________
; Install the keyboard translation code.
; If the cache has not been allocated, load the KCHR 0 resource from the
; system file, create the key cache, and load the KCHR data into the key
; cache. Not finding the KCHR resource and failing to allocate the key
; cache are both serious errors. Note that this code depends upon ExpandMem
; being allocated above.
move.l expandMem,a2 ; get the memory.
move.l emKeyCache(a2),d0 ; has key cache already?
bne.s @doneCache ; yes -> skip allocation.
clr.l -(sp) ; make room for handle.
move.l #'KCHR',-(sp) ; push KCHR type.
clr.w -(sp) ; try for zero.
_GetResource ; get the KCHR resource.
move.l (sp)+,a3 ; load handle.
move.l a3,d0 ; handle nil?
beq.s @badError ; yes, serious bail.
move.l a3,a0 ; load resource handle.
_GetHandleSize ; find resource size.
clr.l d1 ; longize.
move.w #keyCacheMin,d1 ; minimum size.
cmp.l d1,d0 ; big enough?
bge.s @skipResize ; yes (signed compare ok).
move.l d1,d0 ; set to minimum size.
@skipResize
move.w #keyCacheSlop,d1 ; load slop.
add.l d1,d0 ; add slop.
move.l d0,d2 ; save size.
_NewPtr sys,clear ; new pointer of proper size.
; Copy the KCHR data into the key cache buffer area. This is all done in
; case of a switch launch to an old system file that does not know about
; KCHR resources.
move.l a0,emKeyCache(a2) ; store in emKeyCache (expandMem).
move.l a0,a1 ; set up destination.
move.l a3,a0 ; load resource handle.
move.l (a0),a0 ; load resource pointer.
move.l d2,d0 ; load size.
_BlockMove ; copy keyboard table.
@doneCache
; Load the international configuration resource from the system file.
; Copy the old international keyboard flag into our resource header.
clr.l -(sp) ; make room for handle.
move.l #'itlc',-(sp) ; push itlc type.
move.w #0,-(sp) ; try for zero.
_GetResource ; get the itlc resource.
move.l (sp)+,a0 ; load resource handle.
move.l a0,d0 ; handle nil?
beq.s @badError ; yes, serious bail.
move.l (a0),a0 ; load resource pointer.
lea intlEnable,a1 ; load flag pointer.
move.b 6(a0),(a1) ; copy flag value.
; The keyboard translation routine is ready to go, so store the low memory hooks
lea KeyHook,a0 ; load entry point.
move.l a0,Key1Trans ; install the Key1Trans hook.
move.l a0,Key2Trans ; install the Key2Trans hook.
bra.s @doneInit ; we<77>re done.
@badError
; A serious error occurred somewhere. Do that crazy system bomb thing.
move.l #dsSysErr,d0 ; pick system bomb number.
_SysError ; pow, biff, boffo.
@doneInit
endwith
; HACK ALERT!
; Cutback is conditionalized on whether or not we install KeyTrans.
; Hopefully, when no one uses Key1Trans and Key2Trans, we can put this
; and the above mess back into ROM75Fix where it belongs
IMPORT KeyTrans
PEA KeyTrans ; Assume we don<6F>t.
GetTrapA0 $A89F ; Get unimplemented trap
MOVE.L A0,D1 ; Save its address
GetTrapA0 $A9C3 ; Get KeyTrans
CMP.L A0,D1 ; Are they the same?
BNE.S @1 ; No, so it must exist
SetTrap KeyTrans,$A9C3 ; KeyTrans patch.
LEA RAMSysInit,A0 ; Don<6F>t cut it back.
MOVE.L A0,(SP)
@1
;######################### DeCompressor INSTALLATION ********#####################
IMPORT OldCheckLoadJump,MyCheckLoad
Lea OldCheckLoadJump+2,A0 ; < Denman 1/17/90 >
Move.L jCheckLoad,(A0) ; store the old address in our code
; Set new trap address to this ptr
Lea MyCheckLoad,A0 ; compute the address of the patch code.
Move.L A0,jCheckLoad ; stuff in my checkLoad hook.
; Fix the BIND's to ROM addresses for the Decompressor (SizeRsrc patch).
FixROMAddresses ; bind the addresses
; install our patch to _SizeRsrc.
PatchOSJump Read,$A002 ;Remember the old address of _Read.
InstOSTp ReadDecompression,$A002 ;set the read trap to ReadDecompression
; loop through all the open resource files, and clear the alternate attributes byte
; then, set it for the system file
SetupResourceFileAttributes
move.l TopMapHndl,a0 ;start with the first map
@next
move.l a0,d0 ;are we done?
bz.s @done
move.l (a0),a0 ;get the map pointer
bclr #decompressionPasswordBit,mInMemoryAttr(a0) ; <25> clear the flags for this map
move.l mNext(a0),a0 ;go on to the next map
bra.s @next
@done
move.l SysMapHndl,a0 ;get the system map
move.l (a0),a0
bset #decompressionPasswordBit,mInMemoryAttr(a0) ; allow dcmps here
bset #dontCountOrIndexDuplicatesBit,mInMemoryAttr(a0) ; <23> Don<6F>t count duplicate resources in the System file
bset #twoDeepBit,mInMemoryAttr(a0) ; <24> One deep calls on the System file will search two (or more) maps.
;#####################################################################################
;######################### A/UX CONDITIONAL INSTALLATION ********#####################
;#####################################################################################
; Patches in this group are bypassed when running on A/UX.
MOVE.W HwCfgFlags,D0 ; check <20>em the compulsive way <PPyyy>
BTST #hwCbAUX,D0 ; is it A/UX time? <PPyyy>
BNE skipOSInstalls ; if so skip this OS stuff <PPyyy>
;############################################################################# <6>
; Install ADBReInitPatch - Save old jADBProc and put ADBReInitPatch addr in
; jADBProc. Only do this on ADB machines!
;
; Note - right now this is not installed for A/UX; A/UX didn't (and may still not)
; support ADBReInit.
;#################################################################################
move.w HwCfgFlags,d0 ; hardware configuration
btst #HwCbADB,d0 ; is ADB present?
beq.s @doneADBProcInstall ; no, skip this install
lea oldJADBProc,a0 ; get addr for saving old jADBProc
move.l jADBProc,(a0) ; save it there
lea ADBReInitPatch,a0 ; get addr of new ADBProc
move.l a0,jADBProc ; stuff it in jADBProc
@doneADBProcInstall
;#####################################################################################
skipOSInstalls ; end of the line for OS/hardware <PPyyy>
;#####################################################################################
;############################### END INSTALL CODE ####################################
;#####################################################################################
;############################# PATCHES CUT BACK CODE #################################
;
MOVE.L (SP)+,A1 ; cut back point on stack
LEA SysBase,A0 ; start of patch code <23Apr86 LAK>
Sub.L A0,A1 ; size of patch code <23Apr86 LAK>
Move.L A1,D0 ; <23Apr86 LAK>
Move.L (SP)+,A0 ; restore the handle passed by SysPatch <23Apr86 LAK>
BRA CutBack ; cut us back -> <23Apr86 LAK>
ENDP
END
;########################### END PATCHES CUT BACK CODE ################################