boot3/Patches/PatchIIROM.a
Elliot Nunn 5b0f0cc134 Bring in CubeE sources
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included.

The Tools directory, containing mostly junk, is also excluded.
2017-12-26 10:02:57 +08:00

7116 lines
284 KiB
Plaintext

;
; File: PatchIIROM.a
;
; Contains: patches for the ROMs first shipped in a Macintosh II ($0178)
;
; Copyright: © 1986-1992 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <90> 1/19/92 DTY Look at emAppleTalkInactiveOnBoot before checking out the
; AppleTalk version. If AppleTalk was inactive, donÕt set up the
; LAP Manager. This is part of a large conspiracy to convince the
; universe that AppleTalk really isnÕt around if it is inactive.
; <89> 12/4/91 csd #1016447: Added support for Scruffy. DonÕt install the MaxBlock
; patch if Scruffy in installed.
; <88> 6/12/91 LN added #include 'InternalOnlyEqu.a'
; <87> 6/12/91 LN removed #include 'HardwareEqu.a'
; <86> 3/17/91 eh Serial driver status calls 9 and $8000 now return hardcoded
; driver version instead of getting it from DCE. This obviates the
; need for the linked patch to _Open to patch the version number
; in the DCE, a fix which was causing FileShare to crash.
; <85> 3/4/91 dba dty: get rid of SysVers conditionals
; <84> 2/21/91 eh (djw) Fixed bug in serial driver that was preventing use of one
; port when Nike was printing on the other.
; <83> 2/6/91 eh (djw) Fix bug that was causing Smartcom not to be able to do a
; direct connect. We were trashing d1 in the FixInitSCC patch. Now
; we don't.
; <82> 1/19/91 mbs (jg) Include ATalkPrivateEQU.a to get AGBHandle definitions that
; were moved out of ATalkEQU.a
; <81> 1/19/91 eh (djw) Patch Port A async serial driver headers to insert
; signature word for use in serial driver linked patch. Insert
; signature before already patched port B headers. Change port B
; arbitration code to call 'atkv' Gestalt call instead of old
; 'atlk'.
; <80> 1/14/91 eh (djw) Added external clocking support for Nike printer to the
; Async Serial Driver.
; <79> 1/8/91 gbm (sab) Fix DaveÕs removal of the unmount patch, which Chris (csd)
; says he did without having Chris look at it. This is, if true,
; a hanging offense. If you see Dave in the halls after this
; date, then he probably got off with just a public flogging.
; <78> 1/8/91 dnf (csd) Since the File System no longer attempts to save the bits
; behind the disk switch hook, the patch to the code which did
; that is no longer necessary.
; <77> 12/15/90 djw (jwk) Add SCSI Mgr support for Quantum 7.9 ROM problem by adding
; a separate TIB interpreter and replacing blind write
; <76> 12/14/90 dnf (jsm) Turn all patches on ExtFSHook off for 7.0 since they have
; been moved to LaterFileMgrPatches.a
; <75> 12/14/90 bbm (djw) roll in linked comefrompatch from patchIIrom.a.
; <74> 12/14/90 dba <JDR> get rid of VMCalls.a
; <73> 12/13/90 BBM (stb) move the patch to compactmem into memorymgrpatches.a.
; <72> 12/11/90 BBM (fjs) Eliminate HUnlock patch code under 7.0. This code was
; commented wrong. The patch was to fix a bug in GetPicTable
; (Color QuickDraw). Since that routine is completely replaced by
; the System file in 7.0, this patch is no longer needed. In
; actual fact, the patch is better than the ROM code but still has
; a bug in it which is fixed in 7.0.
; <71> 12/7/90 JSM <dba> Move patch on _DisposDialog and come-from patches on
; _GetAuxWin, _DetachResource, and _SetWinColor to
; DialogMgrPatches.a, ifdef come-from patch on _HandToHand and
; patches to [CouldFree][AlertDialog] for pre-7.0 only, since we
; no longer support the Could and Free calls in 7.0.
; <70> 11/27/90 JSM <gbm> Move come-from patch on _SetPort inside DrawItem to
; DialogMgrPatches.a.
; <69> 11/26/90 JSM <bbm> Move come-from patch on _StackSpace inside RgnOp to
; QuickDrawPatches.a, move come-from patches on _DisposeHandle
; inside CloseDialog and _ValidRect inside SetIText to
; DialogMgrPatches.a.
; <68> 11/21/90 gbm & dba; Get rid of the nasty patch to GetResource that is set up
; for a Font Mgr. patch for 7.0. It was causing nasty bugs, and
; not doing anyone any good, since the other patch was
; conditionalized out already!
; <67> 11/20/90 JSM <dba> Move come-from patch on _GetResource inside GetNextEvent
; to disable FKEYs from the keypad to ToolboxEventMgrPatches.a.
; <66> 11/9/90 dba & gbm & JSM; Move LoadResource patch that checks for errors
; while loading WDEFs and CDEFs to WindowMgrPatches.a and
; ControlMgrPatches.a Ñ one more step towards the obsolescence of
; this file; conditionalize out the come-from patch on SwapFont
; when we have TrueType, since TrueType patches in a whole new
; SwapFont
; <65> 10/31/90 dba & csd; kill 8¥24 GC loading code for 7.0 (StartSystem.a does it
; now)
; <64> 10/29/90 KST Fixing a bug in "ExtBTFile" patch that didn't handle reentrant
; call correctly. (code read by B.Bruffey).
; <63> 10/22/90 gbm (mostly dba) get rid of ReleaseResource patch for boot code in
; 7.0, since the old ROM boot code isnÕt used in 7.0
; <62> 9/25/90 KIP Change Sound Mgr. to a linked patch.
; <61> 9/23/90 dba Reinstate the patch to GetNewCWindow that loads 'pltt' resources
; for 7.0.
; <60> 9/22/90 dba get rid of Time Mgr. patching here since we now use the real
; TimeMgr.a to make a linked patch; get rid of obsolete ADB
; patches
; <59> 8/18/90 dba get rid of ptchInst 7 and 8 (Sony Format and Eject patches) and
; ptchInst 14 and 15 (SwapHMMUMode and SwapPMMUMode) as they are
; now linked patches
; <58> 8/17/90 DTY Removed Slot Manager ptch (13) since itÕs a linked patch now.
; <57> 8/14/90 DTY Removed ptchInst 0 since TextEdit is now a linked patch.
; <56> 8/8/90 SAM Changing DispatchHelper & ProcHelper into an old style ptch.
; ¥¥¥--> Temporary <--¥¥¥ Remove when the Sound ptch get converted
; into an Lptch.
; <55> 8/7/90 DTY ptch 34 be linked now.
; <54> 7/30/90 dnf Remove installation of ptch 18 (File Manager) and ptch 6 (Btree
; Manager), now linked patches
; <53> 7/23/90 dba get rid of MenuMgrPatchII
; <52> 7/23/90 dba get rid of ptch 25 for 7.0; it is covered by DialogMgrPatches;
; get rid of extraneous pre-6.0.6 SysVers conditionals; removed
; ptchInst 16 since PrGlue is a linked patch
; <51> 7/20/90 DTY Remove ptchInst 10 & 11 since Bass is now a linked patch.
; <50> 7/20/90 gbm Change some identifiers to eliminate assembler warnings
; <49> 7/19/90 CCH NEEDED FOR SIXPACK: Removed HwPriv patch. The HwPriv trap is now
; a linked patch.
; <48> 7/19/90 EH Add VM support for async.a, the SerSetBuf control call. Also
; rolled in the BAP stuff so we can get rid of the SINI resources.
; <47> 7/19/90 GMR Install ptch 7 on SuperDrive ROMS as well now.
; <46> 7/16/90 gbm Get rid of warnings...
; <45> 7/16/90 VL Fixed out-of-range references (including DelMCEntries,
; LoadResource and NewOldPatToNew) by using SetTrapFar instead of
; InstToolTp.
; <44> 7/2/90 DTY Remove ptchInst 21 since Resource Manager extensions are now in
; a linked patch.
; <43> 6/29/90 DDG Fixed out-of-range references in the patch install area again.
; <42> 6/26/90 DTY Remove ptchInst 2 since NotificationMgr is now a linked patch.
; <41> 6/25/90 DTY Remove ptchInst 9 since ScrollSpeedFix is a linked patch.
; <40> 6/25/90 DDG Fixed out-of-range references in the patch install area
; (specificly the menu manager traps).
; <39> 6/19/90 VL Remove PtchInst 29 since MiscPatches is a linked patch
; now.
; <38> 6/12/90 JSM Remove PtchInst 33 since PPC Toolbox is a linked patch now.
; <37> 6/11/90 EMT Moved alternate trap dispatcher loading to boot blocks.
; <36> 6/7/90 EMT Remove PtchInst 17 since Layer Manager is a linked patch now.
; <35> 6/7/90 VL Remove PtchInst 28 since HelpMgr is a linked patch now.
; <34> 5/29/90 DDG NEEDED FOR SIXPACK: Changed all the sixpack conditionals from
; six-point-oh-seven to six-point-oh-six.
; <33> 5/10/90 JSM AliasMgr now a linked patch, don't install it here anymore.
; <32> 4/23/90 EMT Conditionalized out routines replaced by 32-bit QuickDraw:
; StretchBits, MoveTo, OpenRgn, CloseRgn, PlotCIcon, OldPatToNew,
; BitsToPix, MakeITable, MapRect, NewPixPat, MakeScale, RgnBlt,
; GetSeek, ColorMap, DrawPicture, StdBits.
; <31> 4/18/90 DDG Rolling in the ReallocHandle patch from the sys6 sources.
; <30> 4/16/90 SMB Changed 'ptch' 27 conditionals to include it for 6.0.6 builds.
; <29> 4/16/90 DDG Rolled over some changes from the system 6 split offs to the
; main sources: We added patch 25 (generic system patches), a
; hwPriv patch, the patch for the tiburon video card, and we
; changed the equate for spline fonts to use the build variable
; hasSplineFonts.
; <28> 3/29/90 EH Changed slot interrupt priority order AGAIN. $FF is highest.
; <27> 3/23/90 NC Added ptch 43 for System 6.0.6 on up. This is for Sound.
; <26> 3/15/90 djw Enable slot manager patch (ptch 13) for bigbang (it works now)
; <25> 3/7/90 dba change DetachResource to use BackToTrap
; <24> 2/22/90 JSM Comment out (temporarily?) slot manager patch 13 for 7.0 (see
; Dave Wong).
; <23> 2/22/90 DDG Changed the installation of the HiliteMenu trap from InstToolTp
; to SetTrapFar.
; <22> 2/14/90 BBM Jcrsrtask patch was breaking mouse movement, because someone
; changed almost all the labels in its globals.
; <21> 2/14/90 EMT Conditionalized PaintOne and PaintBehind patches - these are now
; part of the Layer Manager.
; <20> 2/5/90 DDG Changed the installation of the MenuSelect trap patch from
; InstToolTp to SetTrapFar. This also required that I specify the
; real trap number.
; <19> 2/3/90 NC Removed SysBeep patch. SysBeep will be patched for 6.1 and 7.0
; from the Sound Manager.
; <18> 2/2/90 JWK NEEDED FOR 6.0.5: Changed SCSI Mgr bus error handler to chain to
; previously installed bus error handler if a non-SCSI bus error
; occurs. Also fixed a bug causing a -1 to be returned by blind
; reads or writes if less than five bus errors occurred during a
; transfer.
; <17> 2/2/90 EH Fixed Slot Interrupt patch to use the standard macros from
; patchmacros.a
; <16> 2/2/90 BAL Changed InstOsTp to setTrapFar for recoverHandle patch.
; <15> 2/2/90 KON NEEDED FOR 6.0.5: Recover handle now checks for pointers in the
; MF heap.
; <14> 2/2/90 GGD NEEDED FOR 6.0.5: Modified the Deferred Task Manager to enable
; interrupts when returning just so QuickMail servers will
; continue to work (their bug, but we'll fix them for now).
; <13> 2/1/90 csd Needed for 6.0.5: Changed 32-Bit QuickDraw loader to stash a
; magic cookie if it canÕt find the right resource. This indicates
; an older version of 32-Bit QuickDraw. INIT 7 checks the magic
; cookie and puts up an alert.
; <12> 2/1/90 NC Now patches SysBeep for system 6.1 on up.
; <11> 1/26/90 EMT Fixed <4> conflict with the Layer Manager; both patch
; SetWinColor.
; <10> 1/25/90 KON NEEDED FOR 6.0.5: QD version is Offscreen version + $100, not
; $200.
; <9> 1/23/90 KON NEEDED FOR 6.0.5: Added Gestalt stuff for Quickdraw.
; <8> 1/22/90 PKE Used new InstallGestaltEarly symbol to control whether Gestalt's
; ptch 5 installation is done earlier (needed for TextEdit 3.0),
; and made it happen for SysVers>=$605 instead of SysVers>=$700.
; (This is already in the System6Proj sources).
; <7> 1/18/90 DVB Include PalettePriv.a, remove some compile-control slime
; <6> 1/15/90 CCH Fixed out-of-range offset.
; <5> 1/12/90 CCH Added include of ÒHardwarePrivateEqu.aÓ.
; <4> 1/4/90 DAF Corrected color dialog color table handling. This entailed
; removing a patch on GetResource and modifying one on SetWinColor.
; <3> 1/4/90 dba NEEDED FOR 6.0.5: (the 32-Bit QD stuff is needed for 6.0.5)
; redid the comments; added extra slop to RgnOp (StackSpace) patch
; so that it does not have to be patched out by 32-Bit QD; made it
; a MAIN instead of a PROC to get dead-code stripping; changed
; some symbols to avoid warnings; got rid of some 32-Bit QD
; patches that are superceded by the new version of 32-Bit QD;
; changed the code that loads the 32-Bit QD file to work only with
; new files (changed 'ptch' ID from 32 to 132); do not load the
; WaitNextEvent patch out of 7.0 builds
; <2> 12/21/89 dvb Modified to use qd32 pmgr.
; <1> 12/17/89 CCH Adding for the first time into BBS.
; <8.4> 12/11/89 GMR Added ptchInst 8; Sony Format patch is now in it's own patch
; file (FormatPatch.a).
; <8.3> 11/29/89 GGD NEEDED FOR 6.0.5 Replaced the prior patch to the Deferred Task
; Manager (which still had a small bug) with the fixed code from
; the IIci/Portable ROMs. Enabled the Extended Time Manager (which
; matches the code that is in the IIci/Portable ROMs). Enabled the
; New ADB Manager (which matches the code that is in the IIci
; ROM). Initialized the new LowMems VIA2 and TimeViaDB which were
; introduced with the IIci ROM.
; <8.2> 11/21/89 EMT NEEDED FOR 6.0.5: Added humane scrolling.
; <8.1> 11/20/89 BAL Fixed up conditionals for install code as well.
; <8.0> 11/20/89 BAL Changed paletteMgr.a and QuickPolysPatch.a to PaletteMgrPatch.a
; and QuickPolysMacIIPatch.a Removed QuickerDraw.a and several
; other CQD patches from the 7.0 build.
; <7.9> 10/25/89 rwh NICE FOR 6.0.5: add ptch38, backpatch of hwPriv trap for Rom
; revs 1.0, 1.2.
; <7.8> 10/16/89 GMR Re-added ptch34 - ADB manager patch, for system 7.0
; <7.7> 10/11/89 djw Changed to install slot mgr ptch AFTER 32 bit QuickDraw ptch
; <7.6> 10/10/89 djw Added ptch 13 - slot manager patch for system 7.0
; <7.5> 10/10/89 GMR Backed out ptch 34, until it can be cleaned up
; <7.4> 10/6/89 JSM Removed SnarfMan 'ptch', now PACK 13.
; <7.3> 10/3/89 GMR Added Ptch 34, Gary D's new ADB manager, for 7.0.
; <7.2> 9/25/89 BAL Integrated 32-Bit QuickDraw into 7.0 build process.
; <7.1> 9/18/89 CVC Integrate the PPC Toolbox as a ptch the first time.
; <7.0> 9/18/89 RLC Moved ptch 28 (Help Mgr) to after the FCQD (32bitQD) install.
; <6.9> 9/5/89 PKE Install Script Manager 7.0 extensions, ptch 27.
; <6.8> 8/30/89 dba got rid of fast traps for QDExtensions patch since Traps.a has
; the appropriate macros (sure to anger my pal, Bruce Leak)
; <6.7> 8/28/89 SES Removed references to nFiles. Changed DeclRomEqu.a to RomEqu.a.
; <6.6> 8/21/89 PKE NEEDED FOR 6.0.4: ¥ only re-load the standard clut into QDColors
; if QDColors exists; this is so that A/UX will work ¥
; Conditionalize 6.4 for Scripts604 OR (SysVers >= $700)
; <6.5> 8/21/89 BAL NEEDED FOR 6.0.4: Fixed patch to PenNormal to first call through
; to ROM.
; <6.4> 8/19/89 PKE NEEDED FOR 6.0.4 (SCRIPTS BUILD) & 7.0: Moved PtchInst 5
; (Gestalt) ahead of other PtchInsts so they can use Gestalt.
; <6.3> 8/17/89 djw NEEDED FOR 6.0.4: Added 32 bit QD patch to slot manager to fix a
; bug in pRead4Bytes. Was doing a long read from NuBus - patch
; skips long read to only bytes.
; <6.2> 8/17/89 CCH Now gets SCC base addresses from low-mem globals. Also added
; definition of vBase2 to this Mac II-only patch file since
; NuMac-only features will be going away.
; <6.1> 8/15/89 DAF NEEDED FOR 6.0.4: removed patches (for gamma) to NewGDevice and
; one time boot gamma fixer
; <6.0> 8/15/89 dba NEEDED FOR 6.0.4: moved some patches here from MacIIMenuPatch
; because they patch QuickDraw traps and will be overpatched
; unless they are installed after 32-Bit QuickDraw; in WDEF 0
; patch (one of the above patches from MacIIMenuPatch) use a
; StripAddress technique instead of funky cmpRA with $A08XXXXX
; address. patch PaintOne to do nothing if WWExist is non-0; got
; rid of milestones and used new PatchMacs macros instead; tried
; to change gamma table stuff so that old cards get the TFB gamma
; table instead of the linear one (done by DAF) as in an earlier
; patch, but this does not seem to work yet on the Radius monitor
; in GiffordÕs office; moved NewGDevice patch after 32-Bit
; QuickDraw so it will not be overpatched moved the boot gamma
; one-shot code so it *will* be loaded under A/UX (and after
; 32-Bit QuickDraw); changed the NewGWorld patch so that the
; current port is saved; re-load the standard clut into QDColors
; so that the green channel is fixed; changed the cut-back code to
; use new long-distance macros from PatchMacs
; <5.9> 8/14/89 BAL NEEDED FOR 6.0.4: (really dvb) Added tailpatch to Initpalettes
; to kill misROMmed ExitToShell patch.
; <5.8> 8/12/89 dba NEEDED FOR 6.0.4: installed new MacIIMenuPatch patches;
; rearranged as needed
; <5.7> 8/11/89 dba NEEDED FOR 6.0.4: moved patches in and out of A/UX as a result
; of soul-searching, conversation with Dave Berry, and code review
; of IIci patches; made HNoPurge patch A/UX-friendly; made ATP
; duplicate-request patch 32-bit clean by deleting unecessary
; CLR.B
; <5.6> 8/9/89 GMR Added ptch 29 - BigBang only patches for all ROMs
; <5.5> 8/7/89 DAF FOR 6.0.4 BUILD - Added two sets of patches that correct the
; start code to load the default gamma tables from each video card
; rather than stuffing the standard Mac II gamma table into every
; card. One set works on the boot screen, the other fixes the rest
; <5.4> 8/2/89 EVA Reversed Slot Handler priority scheme back to what it was prior
; to <3.7> patch
; <5.3> 8/1/89 BG Added GGD's optimized A-Trap Dispatcher.
; <5.2> 8/1/89 CSD Needed for 6.0.4: Fixed a bug in ColorMap which affects
; scrolling in old ports. Also changed OffscreenVersNum to 1.0 so
; it's less than the version of 32-Bit QuickDraw in Aurora.
; <5.1> 7/31/89 EVA conditionalized out patch <3.7> for big bang
; <5.0> 7/26/89 GMR Needed for 6.0.4: Added Sony Eject patch (ptch 7)
; <4.9> 7/25/89 GGD Needed for 6.0.4, Fixed change <3.1> by REALLY deleting change
; PB261.
; <4.8> 7/25/89 BAL Needed for 6.0.4: Fixed crashing bugs in offscreen graphics
; support.
; <¥4.7> 7/21/89 DAF FOR 6.0.4 BUILD - Removed CheckDevices fix from GetResource.
; Removed QDColors green fix from GetResource, too. These patches
; are taken care of by the QDCheckDevices init and a new ROM
; override
; <4.6> 7/3/89 NJC Sound Manager Extensions (ptch 23) rolled in for real.
; <4.5> 6/30/89 BBM Added partial resources to System 7.0 ('ptch' 21).
; <4.4> 6/29/89 RLC Added HelpMgr PtchInst 28
; <4.3> 6/26/89 BAL dvb For 6.0.4 Move initpalettes call from initmenus to end of
; initwindows.
; <4.2> 6/21/89 NJC Added a ptchinst 3 to if it wasn't already there and added in a
; commented-out ptchinst 23 for the sound dispatcher,DJ, and S.M.
; enhancements.
; <4.1> 6/13/89 dnf Moved btree ptch install after hfs70 ptch install.
; <4.0> 6/12/89 BAL Patched up 32-Bit QD's StdBits.
; <3.9> 6/12/89 BAL Removed patch to GetForeColor because it didn't always work and
; I didn't like it. Added a fix to 32-Bit QuickDraw's stdBits.
; <¥3.8> 6/10/89 CEL Moved Private.a QuickDraw Equates into proper QuickDraw private
; file (colorequ.a), got rid of QuickDraw nFiles dependencies and
; fixed up necessary filesÉ
; <3.7> 6/5/89 EVA Patch Slot Interrupt/VBL handlers
; <3.6> 5/31/89 CEL Only defined Spline_Font variable if it is undefined - makes it
; easier to build test 6.0.4 systems
; <3.5> 5/31/89 prp Added Alias Manager Support
; <3.4> 5/30/89 dnf Changed comment for ptch 18 (18 is now HFS 7.0 enhancements)
; <3.3> 5/23/89 jaz Change version conditionals to check for $700 instead of $604
; <3.2> 5/19/89 jaz Add code to patch in Gary D's new Extended Time Manager
; <3.1> 5/18/89 rwh replaced PB261 SwapMMUMode patch with new one that installs ptch
; 14 or 15. ptch14 fixes the 'HMMU systems lose sound interrupts'
; bug, ptch 15 is a better swapMMUMode for PMMU machines.
; <3.0> 5/16/89 EMT Moved include of ToolTrapFix so that it would be executed at
; installation time.
; <2.9> 5/15/89 CEL Previously, I grouped the patches that effect the spline font
; routines together with the spline font patch. This relocated the
; patches below that32-bit QDat. 32-bit QD got patched out. Sorry
; team!
; <2.8> 5/15/89 EKN Added load of File IDs patch (#18).
; <2.7> 5/13/89 EMT Added Window Manager extensions (Layers).
; <2.6> 5/8/89 NMB Replaced PrGlue with Ginsu's PrGlue.
; <2.5> 5/3/89 CEL Fixed out of range error in compile for the sys604 build
; <2.4> 5/3/89 CEL Rolling in Bass for the first time into EASEÉ
; <2.3> 4/17/89 CCH Put in a milestone for NewStretchBits.
; <2.1> 4/11/89 JSM Install SnarfMan 'ptch'.
; <¥2.0> 4/11/89 CCH Rolled out Altair changes in a big way.
; <1.9> 3/22/89 CCH Replaced SE hard addresses for FSQSync and CmdDone in Cache
; Control trap with Mac II hard addresses. Also looks for
; DiskCachePriv.a in Aincludes dir now.
; <1.8> 3/13/89 CCH Resolved some out-of-range offsets for Big Bang, and added
; B-Tree Mgr patch installation.
; <1.7> 2/22/89 CCH Added install code to bring in Gestalt patch.
; <1.6> 2/21/89 CCH Added milestones so file would link because it is now larger
; than a 16-bit offset can deal with. This is temporary, and
; should be fixed right when patches are rearranged.
; <1.5> 2/21/89 JB (DNF, actually) These files seems to work, so I'm checking them
; back in.
; <1.4> 2/20/89 JB Cleaned up revision history comments.
; <1.3> 2/20/89 JB Moved cache control trap, MapFBlock patch, and "not a Mac disk"
; ExtFSPatch from BeforePatches.a
; <1.2> 1/31/89 CCH Merged changes from 6.0.3.
; <1.1> 1/6/89 CCH Added changes from 6.0.3 sources for building 6.0.4 and 7.0.
; <1.0> 11/16/88 CCH Added to EASE.
; PMAB581> 10/16/88 GGD Installed latest version of TimeMgr, which also includes work
; around for bug with Rockwell VIAs (6.0.3 and Altair) Replaces
; PMAB564
; <PB578> 10/5/88 bbm moved everything aroung so the stupid thing would link.
; <PB576> 10/4/88 GGD Changed SuperDrive MFM formatting on Mac IIx ROMs to be more
; compatible with IBM (Altair and 6.0.3)
; <PB575> 10/3/88 EMT Support for PMAB568 (Menu Manager)
; PMAB574> 9/25/88 jwk Rolled old SCSI Mgr enhancements to support new SCSI Mgr trap.
; 9/24/88 rwh roll in PB541 22jul88 rwh from 6.0.2 sources: fix PowerOff trap
; patch PB091 to delay & rts instead of infinite loop after
; turning machine off. For machines w/o soft poweroff, Shutdown
; Manager will then put up the 'Safe to Restart' dialog.
; <PB573> 9/22/88 jwk Cleaned up Deferred Task dispatcher for Mac II.
; <PB571> 9/8/88 djw Fixed bugs in PB499 - get gDevice handle from MainDevice low
; mem, Next1sRsrc and SecondaryInit bug
; <PB570> 9/8/88 BAL Added install code for FCQD. Look for and execute 'ptch' ID:-24
; PMAB564> 8/18/88 ggd Patched in the New Improved Time Manager for all CPUs,
; Completely replaces old Time Manager, and replaces patches on
; MacPlus and MacSE.
; <PB553> 7/28/88 djw/RPD Added A/UX conditional test for PB499 start code patch, and
; moved slot manager part of patch out of A/UX.
; <PB512> 6/24/88 JB Added patch to fix UpdAltMDB to use correct disk address on
; 1440k disks
; <PB520> 7/1/88 AWC Removed installation of NewPWindow
; <PB499> 6/24/88 djw Add secondary init and search features to slot manager. Added
; patch code to start manager just before patch cutback.
; <S497> 6/7/88 med Changed Script Manager to ptch resource
; <s483> 4/29/88 bbm changed hardwired constant to HiIntMask (see s481).
; <PB482> 4/27/88 DAF Fixed desktop color pattern (again) to be MPW Shell friendly.
; This involves moving the desk pat back to the system heap, but
; correctly dealing with existing pats.
; <s481> 4/27/88 bbm There was a small window after the vremove where a timer
; interrupt could happen. Since the sound driver services the
; timer in the vbl task, the code to reinstall the vbl task would
; never happen.
; PMAB466> 4/13/88 JWK Fixed SCSIGet to perform cleaner arbitration.
; <PB465> 4/13/88 BAL/DAF Altered PB375 to use BackColor (once again) as the transparent
; color.
; <PB464> 4/12/88 AGH Changed JMPROM to BackToTrap for DisposHandle for A/UX.
; <PB463> 4/11/88 DAF Moved Palette Manger installs into the A/UX patch group
; <PM459> 4/7/88 AWC Fixed DisposePalette/CloseWindow bug; implemented AppPalette and
; DisposeBit
; <PB458> 4/1/88 BAL Fixed OpenPicture to re-dereference picsave handle after
; NewPixPat.
; PMAB457> 4/7/88 RWW Fixed CloseDialog to properly dispose TERecord
; <PB452> 4/1/88 BAL Fixed a bug in OR-mode patterned lines and ovals in
; quickerdraw.a
; PMAB449> 3/30/88 rwh replace SysEnvirons code w/INCLUDE SysEnvirons.a (Version 2!)
; <PB447> 3/30/88 DBG Fixed patch to SetupStretch to be completely A/UX friendly.
; <PB445> 3/28/88 DAF Fixed PB408 by extending patched routine.
; PMAB442> 3/25/88 EKH Fixed 'PatchInstall' fail bug. (Wasn't calling SysErr
; correctly).
; PMAB440> 3/24/88 AWC Removed include for QuickPolysEqu.a, which is now imbedded in
; QuickPolysPatch.a
; <PB438> 3/23/88 DAF Improved PB435. Moved desktop ppat to app heap rather than
; system heap.
; <PB435> 3/22/88 DAF I (STUPIDLY) handled the deskCPat lo-mem incorrectly causing
; many bytes of system heap to disappear when launching apps. This
; set of patches on InitWindows (via GetPixPat) and SetDeskCPat
; correct the problem.
; <PB433> 3/22/88 DAF Improved the QuickerDraw dispatch back to ROM. Save a few
; instructions and a few cycles.
; <PB428> 3/18/88 DAF Made QuickerDraw.a installs A/UX friendly. Likewise for PB408.
; Thanks to Andy Heninger for LEARom macro.
; <PB427> 3/17/88 BAL Fixed some bugs in arithmetic modes in quickerdraw.a
; <PB421> 3/7/88 DAF Removed conditional include of QuickerDraw.a. The trap
; installation is still conditional.
; PMAB417> 3/3/88 EMT Patch GetMenuBar and SetMenuBar to handle saved bits correctly.
; <PB415> 3/1/88 DAF/BAL Added QuickerDraw conditionally - set Quicker EQU 1 to enable
; <PB408> 2/26/88 DAF Added a small fix to 32X scaling in SetupStretch (CQD Vector)
; PMAB407> 2/26/88 DAF Removed PMAB370 (UprStr). I didn't know that you could use
; UprStr to just strip diacriticals. My post processing was
; causing AppleShare to get grave accents accidentally when
; stripping names. This can still be fixed, it just requires a
; deeper fix rather than post processing.
; <PB404> 2/25/88 DAF Fixed and improved SaveEntries and RestoreEntries
; PMAB401> 2/23/88 djw Bug in async driver - killIO did not set reg D0 to good return
; status. Combine with patch PMAB372
; <PB386> 2/9/88 djw Fix PMAB372 incorrect use of CmpRA for ROM resource address
; <PB384> 2/9/88 DAF Set crsrBusy during Mac II ShowCursor to prevent garbaged
; cursors.
; <PB373> 2/3/88 AGH Fix A/UX Hostile patches.
; <PB375> 1/27/88 BAL Patched ColorMap to set transColor from RGBOpColor instead of
; backColor.
; <PB373> 1/26/88 AGH Fixed Install code for A/UX Macros to allow CMPRA to work with
; return addresses from ROM Resources
; PMAB372> 1/26/88 djw Fixed DTR bug in async serial driver - a jump to the wrong label
; PMAB370> 1/25/88 DAF UprStr had an "a" instead of a "`" in it's case table, so I
; added a post-call scan of the string to fix this.
; <S369> 1/25/88 DAF Made a fix to WDEF 0 via PenNormal here, at menu mgr's PenNormal
; <PB366> 1/25/88 bbm fixed a bug in maxblock.
; PMAB364> 1/23/88 EMT Fix Pop-up menus to come up on any screen
; <PB362> 1/21/88 BAL Extended drText patch to fix fractional pen positioning in new
; ports.
; PMAB354> 1/7/88 EMT Unimplemented Toolbox versions of 12 bisexual traps
; <PB352> 1/6/88 BAL Fixed drawPicture to condense pixmap -> bitmap in place when
; BitsProc is not StdBits.
; PMAB340> 12/17/87 EMT Miscellaneous fixes to NMgr + System Alarm uses NMgr.
; <PB337> 12/16/87 bbm fixed SetOSDef to keep it from trashing PRam.
; <PB336> 12/16/87 AGH Add back install code that was accidently removed by PB302.
; PMAB335> 12/15/87 EMT ptchInstall now calls SysError on failure
; <PB330> 12/14/87 AGH/EMT Fixed bug in A/UX friendly patching
; PMAB329> 12/10/87 JWK Fixed PMAB295 to avoid 10sec delay when booting without SCSI
; devices attached.
; <PB323> 12/7/87 BAL Changed makeScaleTbl patch (PB233) to restore d7 before bitblt.
; <PB319> 12/2/87 AWC Modified StdPoly so QuickDraw regions are not used.
; PMAB318> 11/30/87 jw Added new improved sound manager.
; PMAB317> 11/28/87 EMT Added Notification Manager.
; <PB313> 11/25/87 bbm Fixed the fontmanager. When a synthetic font of greater than
; 128k was displayed, the offset to the width table was not
; retrieved right. fixed by patching hsetstate.
; PMAB315> 11/25/87 RWW Err, GetResource doesn't return resNotFound? Fixed ptchInstall
; <PMAB310> 11/24/87 PYG/EMT Make WaitNextEvent trap for Classic Mac OS.
; PMAB309> 11/24/87 RWW Massive, world-shattering change - yank TE patches and do this
; whizzy new installation. This one patch, in one fell swoop,
; replaces the following old, sometimes ugly patches:
; PMAB308> 11/24/87 RWW Added ptchInstall, which installs 'ptch' resources. This saves
; keeping duplicate copies of identical code in several patch
; files.
; <PB305> 11/22/87 DAF fixed buffer size calculations in RgnOp
; <PB304> 11/22/87 DAF fixed "wrong result when no change" bug in GrowWindow
; <PB302> 11/17/87 AGH Massive changes to make all patches A/UX friendly.
; PMAB301> 11/15/87 ABO Fix ATP delayed duplicate response bug
; PMAB295> 10/20/87 SHF Modified last call to SCSILoad -- increased patched select
; timeout to 25 msec (was 5); made more robust for CD ROM.
; <PB292> 9/30/87 DAF Fixed DisposPixPat/DisposeCCursor and CloseCPort/ClosePort to
; test for NIL pathandles to save the General CDEV. The pairs of
; routines above are multiple names for the same code (but
; different traps!)
; <PAB291> 9/26/87 DBG Changed mouse button debounce time back to 20 msec, and changed
; code so that mouse downs always get noticed. The code will now
; never discard a down/up pair, only up/down pairs.
; <PAB288> 9/24/87 CSL Reduced the mouse button delayed time from 20 msec. to 10 msec.
; <PB286> 9/22/87 BAL Patched RSect to fix DrText for offscreen pixmaps.
; PMAB284> 9/21/87 JTC Fix patch to MoveHHi to weed out dinky free block cases. Fix
; involves moving more of patched loop into RAM.
; <S281> 9/18/87 bbm sound manager uses sound manager uses soundactive different than
; sound driver. Thus soundactive could be true with no sound vbl
; task installed. So now we check for an error from vremove, which
; we should have done in the first place. (This is the same patch
; as S278, which got deleted when pb279 was checked in.)
; <PB279> 9/18/87 DAF Fixed picture recording of regions and polygons.
; <S277> 9/16/87 DAF Removed install of _InitWindows patch, since the _InitPalettes
; is now done in INIT=31. NOTE: I did NOT remove the patch from
; PaletteMgr.a. In the new ROM sources, _InitPalettes should be
; done during startup.
; PMAB271> 9/14/87 BB/JB Modified unmount patch PB245 to unconditionally unmount a volume
; if the HFS bit is set in the ioTrap word.
; PMAB270> 9/13/87 FJL Patch DrawPicture to first check for valid picture handle and
; pointer, then do GetState, lock, and SetState on return. At the
; request of Sheila, Phil and Scott.
; <PB268> 9/10/87 DAF Detached DRVR resource loaded in PB238
; <PB266> 9/8/87 BAL Change equate for ExTbl in patch for setCCursor (PB206).
; <s263> 9/7/87 bbm The current sound driver uses low memory as a vbl queue element.
; A bug occurs if sound is active. The low memory queue element is
; zeroed regardless if there is a next element in the queue or
; not. Thus the machine may hang. The fix forces the sound vbl
; queue element to be last in the queue always.
; <PB262> 9/4/87 AWC Patched ActivatePalette: Blo.S => Bhi.S to fix color priority
; problem
; <PB261> 9/4/87 rwh Patched SwapMMUMode: prevent hang when already in mode neing
; swapped to.
; <PB260> 9/2/87 BAL Patched GetSeek to prevent region clipping to overshoot minRect.
; Patch recomputes bufSize(a6) for rgnBlt, stretch, drawArc,
; drawLine.
; <PB259> 9/1/87 AWC Patched NewPWindow so it doesn't polymerize the stack.
; <PB258> 9/1/87 BAL Patched rgnBlt to attempt TrimRect(clipRgn,minRect) for faster
; windows.
; <PB257> 9/1/87 BAL Fixed patch to MakeScaleTbl (PB233) to delete 1 bit search proc.
; PMAB255> 8/31/87 FJL Menu enable bits no longer get shifted randomly when more than
; 32 items are added to a menu. Patch DrawMenuBar and call
; HiliteMenu(0) and HiliteMenu(TheMenu) after so don't have
; dangling "bits behind" the menu title
; PMAB253> 8/27/87 CRC Fixed MaxSizeRsrc in FontMgr for Radius (once again)
; <PB251> 8/26/87 RDC Fix bug in PB236 patch so MicroBug still works if no debugger
; installed.
; PABM250> 8/25/87 MBK TextEdit: Patched DisposPtr and StackSpace to fix Pixel2Char
; dispose bug
; <PB245> 8/25/87 BB/JB Patch UnmountVol to prevent unmount when files are open.
; PMAB242> 8/24/87 BAL changed patch to patConvert (PB206) to use the proper equate for
; return address comparison
; PMAB241> 8/24/87 RDC Added patch for BadTrap handler routine to save registers before
; exiting to SysError routine
; <PB236> 8/24/87 RDC Added patch for NMI handler routine to pass proper error code to
; SysError routine so new MacsBug doesn't get confused.
; <PA237> 8/19/87 BB/JB Patched FClose to fix problem which failed to release BTCB's for
; OffLine, Eject, and Unmount.
; <PB238> 8/19/87 DAF Added patch to Open to correct loading of slot drivers and
; videoInit to reload the boot video driver if a newer one is in
; the system file.
; <C864> 8/12/87 rwh added RomPaletteMgr equate. It must be here for assembly to
; work. Its a Cxxx, not a PBxxx, cuz PaletteMgr.a is in Post Mac2
; ROMs also.
; <PB233> 8/7/87 BAL Patch MakeScaleTbl so that copybits color mapping only happens
; if absolutely necessary.
; <PB232> 8/4/87 bbm added some parameter checking to writeXParm.
; <PB231> 7/28/87 rwh add Rich Castro's fix to deferred task dispatcher: make it
; dequeue the task BEFORE calling it.
; <PB230> 7/24/87 DBG&BAL Was jumping back into ROM (for ROMNotProc case) with D0 trashed,
; so we jump back in a little earlier to restore its contents.
; <PAB229> 7/23/87 WRL MouseDrvr MouseDrvr New, improved mouse button debouncing code
; for ADB machines.
; <PB217> 7/22/87 BAL Patch RSECT in order to fix fast DrawLine in CGrafPorts
; <PB220> 7/22/87 SHF Fixed SCSI Mgr to clear up occasional hanging during reads.
; PMAB226> 7/21/87 GWN Backout PMAB216.
; PMAB216> 7/21/87 GWN Patch Read, Write, Control and Status to fix Async problem.
; <PB215> 7/21/87 FJL Fix GNEFilter to do GetClip after SetPort instead of before.
; <PB212> 7/20/87 DAF Improved Disk Switch Hook patch. Updated some palette manager
; patches.
; PMAB210> 7/20/87 DAF Fixed some resource handling in the window and control managers.
; <PB208> 7/18/87 SHF SCSIMgr: Added a delay to the bus error retry code.
; <PB206> 7/16/87 EHB HUnlock GetPicTable
; <PB206> 7/16/87 EHB BitsToMap CopyBits
; <PB206> 7/16/87 EHB MapRect DrawPicture
; <PB206> 7/16/87 EHB PatConvert SetCCursor
; <PB204> 7/13/87 DAF PaintOne, PaintBehind wmgrasm1:PaintDesk
; <PB204> 7/13/87 DAF PaintOne, PaintBehind wmgrasm1:PaintDesk WindowMgr: Fixed
; PaintDesk to switch to sysheap in case of deskCPat pattern
; expansion.
; PABM197> 7/9/87 MBK HLock TEStylInsert TextEdit: Fix to TEStylInsert call when
; record is deactivated
; PABM198> 7/9/87 MBK HLock,HUnlock,TEDispose,TESetSelect,TEClick,TEDispatch,TEKey
; TextEdit: Fix to allow styles to be set at null selection
; PABM201> 7/9/87 MBK FindLine SetLineHite TextEdit: Fix to allow fixed line heights
; to work
; PABM202> 7/9/87 MBK FindLine RecalLines TextEdit: Fix to recalibration bomb when
; text length = 32,767
; PABM203> 7/9/87 MBK FindLine RecalLines TextEdit: Fix to deletion bug (display would
; get messed up)
; <PB195> 7/9/87 CRC Dialog Manager: fixes color Could/Free Alert/Dialog, and orphan
; handle patched: GetAuxWin DisposDlg DetachRsrc SetWinColor
; HandToHand CouldAlert CouldDialog FreeAlert FreeDialog to
; correct: CouldAlert FreeAlert CouldDialog FreeDialog
; GetNewDialog Alert
; <PB196> 7/9/87 CRC SetPort DrawDialog Dialog Manager: fixe to leave port alone
; across user item if no color items note: this is patched in
; MacIIMenuPatch
; <PAB191> 7/2/87 CSL ADBReInit Kbd.a Added pre- and post- processing routine hook for
; ADBReinit.
; <PAB192> 7/2/87 EMT ADBProc KbdDrvr Use JADBProc to clean up on ADBReInit
; <PB189> 7/1/87 CRC StretchBits DrawText reverse order of shadow only for old port,
; bic and or modes.
; PABM187> 7/1/87 CRC GetMaskTab, GetResource FMSwapFont fixes fractenable underline
; <> plain widths bug patched GetResource to set register flag,
; and GetMaskTab for bug fix
; <PB188> 7/1/87 CRC FixDiv CharExtra translate zero size into correct size
; PABM186> 7/1/87 CRC GetHandleSize RealFont removed PB164 and replace GetHandleSize
; w/ MaxSizeRsrc
; <PAB185> 6/29/87 ABO Fix NBP write-to-zero on lookup bug.
; 6/10/87 JTC Amend format of patches for use by A/UX Toolbox. Idea is to
; split the install code into two parts, one that installs on all
; machines, and one that installs only when NOT on A/UX. The
; latter is handy for those OS-ish routines that have no exact
; correspondent on A/UX. Subtleties like patching
; <PB172> 4/10/87 JTC&SMD Fix problem with D3 not being initialized on B2D conversions.
; <PB170> 4/8/87 DBG&BAL The ROM Optimization Squad decrees that JSR + RTS = JMP (in PB112).
; <PB169> 4/8/87 DBG&BAL Fixed bug in patch to SetIText (PBAM109): 24-bit ROM addresses vs. 32
; <PB168> 4/8/87 DBG&BAL Remove patch to GetSeek (part of PB093), since any negative
; coordinates passed to StretchBits are in error. (Mac Plus
; compatibility??)
; <PB167> 4/8/87 DBG Fix patch to patch to _BitsToPix (PB162) to keep A0 where ROM
; expects.
; <PB166> 4/8/87 DBG Fix patch to _BitsToMap (PB122) so that dstmap gets wedged to
; port only if 1) thePort is printer port, and 2) dstmap is
; currently screenbits
; <PBM164> 4/7/87 JTC&JDT DANGER: Patch RealFont with caution after this, since we look
; into the stack at RealFont internal return addresses.
; <PB160> 4/1/87 AWC PMgr; fix D5 save; regs in P2CT; AnimXXX intfc chg; animation
; fix
; <PB158> 3/30/87 JTC Tweak install of Palette jIAZInit patch to use daisy chain.
; <PB153> 3/30/87 FJL Removed fix to GetMaxDevice call in StandardMBDF.a. Changed
; MenuMgrPatchII.a and PatchIIROM.a
; PABM150> 3/28/87 JTC&JAF SysEnvirons patch
; <PB148> 3/28/87 EHB Added patch to checkDevices to make monochrome/color work. Moved
; InitGDevice patch into this one.
; <PB146> 3/27/87 CRC Patched FixMul to fix bug if input value to CharExtra is
; negative.
; <PB147> 3/27/87 EHB New palette mgr. Patched the RGBxxColor family of routines.
; PABM139> 3/26/87 MBK Patched FindLine to fix recal delete bug.
; <PB136> 3/24/87 JTC GetNewControl GetNewControl Little fix to LINK with even count.
; <PB137> 3/24/87 EHB Revised BitsToMap patch to make printing work.
; <PB131> 3/24/87 JTC Patch ReleaseResource to fix start code to detach DSAT=2. Since
; itÕs a one-shot, just blast the correct address back when done.
; BEWARE: If you patch ReleaseResource further, disable my revert
; BEWARE: code that bolts the old ROM address back in.
; <PB126> 3/23/87 EHB Added CalcCMask, SeedCFill, and newBitsToMap
; <PB125> 3/20/87 DAF Patched MakeITable to not SysError when it can't allocate the
; cube or queue in the app heap. Now it returns an error in QDErr.
; <PB122> 3/19/87 EHB Added 3 QuickDraw patches
; <PB121> 3/19/87 DAF DiskSwitchAlert TFS:TFS.a/DSHook Modified disk switch alert to
; post an update if the mainscreen is not in 1-bit mode. This
; patches DskSwtchHook in lo-mem- not a trap!
; <PAB117> 3/19/87 CRC LoadResource FMSwapFont if fast path fails because of disk
; switch, recover with panache.
; <PB112> 3/19/87 mgl Sound Manager timer interrupt patch
; <PB110> 3/18/87 FJL Menu Manager patches for: variable speed scrolling,
; PopUpMenuSelect, GetItemCmd, SetItemCmd
; PBAM109> 3/17/87 CRC ValidRect GetIText patched ValidRect to restore register
; clobbered by DrawItem in SetIText
; <PB103> 3/10/87 EHB/AWC Palette Manager
; PMAB102> 3/10/87 EMT Fixed all patches to not use FKEYs when code came from keypad.
; <PB093> 3/9/87 EHB 3 QuickDraw patches: StdPoly: Put proper opcode to new pictures
; GetSeek: Watch for negative sources (when called by stretch)
; PlotCIcon: Set fg to black and bk to white
; <PB092> 3/9/87 JTC CompactMem MemMgr: MoveHHi Prevent creation of bogus tiny free
; blocks.
; <PB071> 3/7/87 SHF SCSIWrite, SCSIWBlind OS:SCSIMgr.a Fix bus error handler, DMA
; turn-off check
; <PAB87> 3/6/87 CSL Patch JCrsrTask to support absolute cursor position.
; <PB086> 3/5/87 MBK HUnlock TextEdit.a:InsertRecal fixed obscure recal bug
; <PAB87> 3/6/87 CSL Patch JCrsrTask to support absolute cursor position.
; <PB079> 3/2/87 CRC improper mode, hilite fixes
; <PB071> 3/7/87 SHF Fix bus error handler, DMA turn-off check
; <PB091> 3/8/87 RDC Fix timing problem in poweroff routine
; <PB074> 3/2/87 ABO Fix re-entrancy problem (don't install if already there)
; <PB069> 2/27/87 mbk fix for Mac+ (!) scrolling bug
; <PB0689> 2/27/87 mbk added TextEdit patch for International
; <PB0679> 2/27/87 mbk added TextEdit patch for International
;
STRING ASIS
MACHINE MC68020
LOAD 'StandardEqu.d'
include 'ATalkEqu.a' ; <PABM150>
include 'ATalkPrivateEqu.a' ; <81>
include 'ApplDeskBus.a'
include 'HardwarePrivateEqu.a'
include 'MMUEqu.a' ; <3.1>
include 'PrEqu.a'
include 'PrPrivate.a'
include 'ColorEqu.a'
include 'SCSIEqu.a'
INCLUDE 'SlotMgrEqu.a'
INCLUDE 'VideoEqu.a'
INCLUDE 'PaletteEqu.a'
INCLUDE 'PalettePriv.a' ; <dvb 18Jan90>
INCLUDE 'QDHooks.a'
INCLUDE 'ROMEqu.a' ; <PM238/DAF><6.7>
INCLUDE 'PatchMacros.a'
INCLUDE 'ScriptPriv.a' ; <30>
INCLUDE 'InternalOnlyEqu.a'
IF (&TYPE('SPLINE_FONT') = 'UNDEFINED') THEN
SPLINE_FONT EQU hasSplineFonts ; <29> modified 4/16/90 DDG
ENDIF
IF (&TYPE('Scripts604') = 'UNDEFINED') THEN
Scripts604 EQU 0 ;<6.6><08/21/89 pke>
ENDIF
Quicker EQU 1 ; set to zero to not build QuickerDraw, 1 to include <PB415>
ROM78Fix MAIN EXPORT
IMPORT RAMSysInit
EXPORT SysBase,CutBack
; Cut back Code:
;
; SysBase is the entry point for ROM78Fix. 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
jmpFar RAMSysInit ; <6.0>
DC.L ('PTCH') ; resource type
DC.W $0178 ; patch ID $78 processor $01.
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
;################################ PATCH CODE GOES HERE #######################################
;____________________________________________________________________________________
; PAB87 06Mar87 CSL patch out the JcrsrTask to support absolute cursor position.
; The whole Jcrsrtask routine is replaced by the patch below.
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 06Mar87 #PAB87 (JcrsrTask) (InsertRecal)
;
; OMIT FROM A/UX
;
CrsrPtch PROC EXPORT
;
; ===================================================================
; Constants. Size of the mapping table.
; ===================================================================
;
MaxL EQU 8 ; Maximum value of L
RomScrnPin EQU $4081B1EA
; ===================================================================
; Globals. First words of this resource.
; ===================================================================
;
Cnt EQU 0 ; word: number of valid error deltas
MaxCnt EQU Cnt+2 ; word: limit on number of error deltas
Err7 EQU MaxCnt+2 ; word: time-7 error magnitude
Err6 EQU Err7+2 ; word: time-6 error magnitude
Err5 EQU Err6+2 ; word: time-5 error magnitude
Err4 EQU Err5+2 ; word: time-4 error magnitude
Err3 EQU Err4+2 ; word: time-3 error magnitude
Err2 EQU Err3+2 ; word: time-2 error magnitude
Err1 EQU Err2+2 ; word: time-1 error magnitude
Error EQU Err1+2 ; word: accumulated error
GSize EQU Error+2
;
;
; ===================================================================
; Code. @MouseMap+EntryOff
; ===================================================================
;
TST.B CrsrNew ; Mouse changed?
BEQ Done ; No É return
TST.B CrsrBusy ; Cursor locked?
BNE Done ; Yes É return
;
TST.B CrsrCouple ; Cursor coupled to mouse?
BEQ NoComp ; No É skip computation <DSV>
;
MOVE.W MTemp+H,D0 ; Find ÆMx
SUB.W RawMouse+H,D0
;
MOVE.W MTemp+V,D1 ; Find ÆMy
SUB.W RawMouse+V,D1
;
MOVE.W D0,D2 ; x := |ÆMx|
BGE.S AbsX1
NEG.W D2
AbsX1
;
MOVE.W D1,D3 ; y := |ÆMy|
BGE.S AbsY1
NEG.W D3
AbsY1
;
move.l MickeyBytes,a0 ; <10/7/86 SMH> get globals
CMP.W D2,D3 ; D3 := magnitude(x,y)
BLS.S MagDone
EXG D2,D3
MagDone
ASR.W #1,D3
ADD.W D2,D3
;
; *** BEGIN NEW ***
;
BNE.S DoComp ; Zero magnitude É donÕt compute ***
MOVE.W #1,Cnt(A0) ; No hits ***
CLR.W Error(A0) ; No errors ***
BRA DoPin ; Update the cursor ***
DoComp
;
MOVEM.L D4-D5,-(A7) ; Save off registers
MOVE.W Cnt(A0),D4 ; D4 is the number of samples
CMP.W MaxCnt(A0),D4 ; Is Cnt less than MaxCnt
BGE.S CountOK
ADD.W #1,Cnt(A0) ; Yes É we will have one more error
CountOK
;
MOVE.W D3,D5 ; Magnitude at current time
;
MOVE.W D4,D2 ; Get Count
SUB.W #1,D2 ; Index into JTab
ASL.W #1,D2 ; REQUIRES BRA.SÕs IN JUMP TABLES
JMP JTab(PC,D2.W) ; Jump to the right code per Count
;
JTab
BRA.S E1 ; Count = 1
BRA.S E2 ; Count = 2
BRA.S E3 ; Count = 3
BRA.S E4 ; Count = 4
BRA.S E5 ; Count = 5
BRA.S E6 ; Count = 6
BRA.S E7 ; Count = 7
; *** BRA.S E8 ; Count = 8 ***
;
E8 ADD.W Err7(A0),D5 ; Accumulate time-7 magnitude
;
E7 ADD.W Err6(A0),D5 ; Accumulate time-6 magnitude
MOVE.W Err6(A0),Err7(A0) ; Shift out time-6 magnitude
;
E6 ADD.W Err5(A0),D5 ; Accumulate time-5 magnitude
MOVE.W Err5(A0),Err6(A0) ; Shift out time-5 magnitude
;
E5 ADD.W Err4(A0),D5 ; Accumulate time-4 magnitude
MOVE.W Err4(A0),Err5(A0) ; Shift out time-4 magnitude
;
E4 ADD.W Err3(A0),D5 ; Accumulate time-3 magnitude
MOVE.W Err3(A0),Err4(A0) ; Shift out time-3 magnitude
;
E3 ADD.W Err2(A0),D5 ; Accumulate time-2 magnitude
MOVE.W Err2(A0),Err3(A0) ; Shift out time-2 magnitude
;
E2 ADD.W Err1(A0),D5 ; Accumulate time-1 magnitude
MOVE.W Err1(A0),Err2(A0) ; Shift out time-1 magnitude
;
E1 MOVE.W D3,Err1(A0) ; Shift out current magnitude
;
MOVE.W D4,D2 ; Round up the divide
ASR.W #1,D2 ; by half the denominator
ADD.W D2,D5
EXT.L D5 ; Set up for the divide
DIVU D4,D5 ; Find the average magnitude
;
MOVE.W D3,D4 ; Get the original magnitude
SUB.W D5,D3 ; Find distance to average magnitude
ADD.W Error(A0),D3 ; Add on the accumulated error
CMP.W #-1,D3 ; Define -1 div 2 = 0
BNE.S DivOK
CLR.W D3
DivOK ASR.W #1,D3 ; Get half of it
MOVE.W D3,Error(A0) ; Update it
ADD.W D5,D3 ; Desired mag is average+Error
;
CMP.W #255,D5 ; mag := MAX(mag,255)
BLS.S MaxDone
MOVE.B #255,D5
MaxDone
;
move.l MickeyBytes,a0 ; <10/7/86 SMH> get at globals
add #GSize,a0 ; <10/24/86 SMH> point to table
CLR.W D2 ; i := 0
;
Search
ADD.B #1,D2 ; repeat
CMP.B (A0)+,D5 ; i := i+1
BHI.S Search ; until mag ² Table[i]
;
MULS D2,D3 ; D4 := i*(Mag(ÆM)+Error)
;
MULS D3,D0 ; ÆCx := (ÆMx*i*(Mag(ÆM)+Error))/Mag(ÆM)
DIVS D4,D0 ; <<<<<< D3 >>>>>>>
;
MULS D3,D1 ; ÆCy := (ÆMy*i*(Mag(ÆM)+Error))/Mag(ÆM)
DIVS D4,D1 ; <<<<<< D3 >>>>>>>
;
MOVEM.L (A7)+,D4-D5 ; Restore registers
;
; *** END NEW ***
;
ADD.W D0,RawMouse+H ; Update raw mouse location
ADD.W D1,RawMouse+V
;
DoPin
LEA CrsrPin,A0 ; Bounding rect for cursor ***
MOVE.L RawMouse,D0 ; Pin mouse inside rect
JSR RomScrnPin ; return to SHOWIT if screen changes
;
MOVE.L D0,RawMouse ; Update cursor locations
MOVE.L D0,MTemp
;
AND.L MouseMask,D0 ; Do jerky masking to drop low bits
MOVE.L MouseOffset,D1 ; Get the offset
BEQ.S SkipPin ; Skip 2nd pin if not
ADD.L D1,D0 ; Do jerky offset
JSR RomScrnPin ; return to SHOWIT if screen changes
SkipPin
MOVE.L D0,Mouse ; Actual mouse location
;
Repaint
TST.B CrsrObscure ; Unpaint the cursor
BNE.S Unpainted
_HideCursor ; Hide the cursor
Unpainted
;
CLR.B CrsrNew ; Cursor is fresh
CLR.B CrsrObscure ; Cursor is not obscured
_ShowCursor ; Repaint the cursor
;
; *** BEGIN NEW ***
;
RTS ; Goodbye
;
Done
move.l MickeyBytes,a0 ; <10/7/86 SMH> get globals
MOVE.W #1,Cnt(A0) ; No hits
CLR.W Error(A0) ; No errors
RTS ; Goodbye
;
NoComp
move.l MickeyBytes,a0 ; <10/7/86 SMH> get globals
MOVE.W #1,Cnt(A0) ; No hits
CLR.W Error(A0) ; No errors
BRA.S Repaint ; Update the cursor
;
; *** END NEW ***
ENDPROC
;____________________________________________________________________________________
; PB073 2Mar87 ABO VInstall atalk:nonres.a
; PAB185 29Jun87 ABO VInstall atalk:nonres.a
;
; PB073 Fixes a re-entrancy problem in nonres.a within MPP.
; PAB185 Fixes an NBP lookup bug where if the response comes back too quickly it
; is written to location zero.
;
; If we're doing a VInstall from Nonres, and the queue element we're installing
; is already there, don't install. If we're doing a lookup, skip the first write.
;
; s263 The current sound driver uses low memory as a vbl queue element. A bug occurs
; if sound is active. The low memory queue element is zeroed regardless if there is a
; next element in the queue or not. Thus the machine may hang. The fix forces the
; sound vbl queue element to be last in the queue always.
;
; s481 there was a small window after the vremove where a timer interrupt could happen.
; Since the sound driver services the timer in the vbl task, the code to reinstall the
; vbl task would never happen.
;
; s483 changed hardwired constant to HiIntMask (see s481).
;
; OMIT FROM A/UX
NewVInstall PROC EXPORT
CalledFrom EQU $1C ; Where we were called from (return addr)
SkipBytes EQU 18 ; No. of bytes to skip write (PAB185)
ROMVInstall EQU $40806344 ; ROM VInstall address
NRVBLHnd EQU $82D2DC ; VBL task address in ROM
tst.b SoundActive ; sound playing? fixes trashed vbl queue <s263>
beq.s @TruVinst ; if not, just do real vinstall <s263>
move.w sr,-(sp) ; Save sr <s481>
ori.w #HiIntMask,sr ; Disable interrupts <s483>
move.l a0,-(sp) ; save new vbl element on stack <s263>
lea SoundVBL,a0 ; point at hertzfeldÕs vbl element <s263>
_VRemove ; remove sound vbl element <s263>
move.l (sp)+,a0 ; get new vbl element back in a0 <s263>
tst.w d0 ; check for error from vremove <s281>
bne.s @popstatus ; if error then donÕt reinstall sound vbl <s281>
bsr.s @TruVinst ; install new vbl element back in queue <s263>
lea SoundVBL,a0 ; get sound vbl element, and install it <s263>
bsr.s @TruVinst ; install sound vbl element back in queue <s481>
move.w (sp)+,sr ; Restore interrupts <s481>
rts ; <s481>
@popstatus ; <s481>
move.w (sp)+,sr ; Restore interrupts <s481>
@TruVinst ; <s263>
MOVE.L VBLAddr(A0),D1 ; D1 = VBL task address
AND.L MaskBC,D1 ; Mask off high bits to be sure
CMP.L #NRVBLHnd,D1 ; Called from NBP VBL task?
BNE.S @30 ; Branch if not
; PAB185 start
MOVE.L -4(A0),A2 ; A2 -> queue element from call
CMP #LookupName,CSCode(A2) ; Was it a lookup request?
BNE.S @5 ; Branch if not
TST.B VBLCount(A2) ; Check count (used to be count(A2)... I can't believe this code ever worked!)
BEQ.S @3 ; Branch if zero (leave alone)
ADDQ.B #1,VBLCount(A2) ; Need to add one since aren't sending now
@3 ADD.L #SkipBytes,CalledFrom(SP) ; Skip past the write
MOVE #1,VBLCount(A0) ; Set to send out real soon
; PAB185 end
@5 MOVE SR,-(SP) ; Save SR
MOVE #$2600,SR ; Disable interrupts
LEA VBLQueue+QHead,A2 ; A2 -> Head of VBL queue
@10 TST.L (A2) ; Done?
BEQ.S @20 ; Branch if so
MOVE.L (A2),A2 ; A2 -> next element
CMP.L A2,A0 ; Matches the one we're installing?
BNE.S @10 ; Loop if not
MOVE (SP)+,SR ; Restore SR
MOVEQ #0,D0 ; Indicate no error
RTS ; Return (already installed)
@20 MOVE (SP)+,SR ; Restore SR
@30 JMP ROMVInstall ; Jump to ROM VInstall code
ENDPROC
;___________________________________________________________________________
; PB071 07Mar87 SHF SCSIWrite, SCSIWBlind OS:SCSIMgr.a
; Fix bus error handler, DMA turn-off check
; PB208 18Jul87 SHF SCSIWBlind OS:SCSIMgr.a
; PB220 22Jul87 SHF SCSIRead,SCSIRBlind OS:SCSIMgr.a
; Fixed hanging bug at end of read data transfer.
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 06Mar87 #PB071 (SCSIWrite,SCSIWBlind) (SCSIWrite,SCSIWBlind)
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 18Jul87 #PB208 (SCSIWBlind) (SCSIWBlind)
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 22Jul87 #PB220 (SCSIRead,SCSIRBlind) (SCSIRead,SCSIRBlind)
;
; This patch fixes a bug in the SCSI Manager's bus error handler. It also
; fixes a bug in the 'check for turning off DMA' code which crept in
; somewhere between Maui and Becks.
;
; OMIT FROM A/UX
;
;
PatchSCSIRead EQU 1 ; patch SCSI Read (it and Write are patched <PB208>)
NewSCSIMgr PROC EXPORT
EXPORT NewSCSIGet,mySCSIRead, mySCSIRBlind, mySCSIWrite, mySCSIWBlind
;
; Stack frame for blind read/write bus error information
;
OldBusErrVct EQU -4 ; long
BusErrCount EQU -6 ; word
LocalSize EQU -6 ; total a6 offset for locals
zeroReg EQU d7 ; SCSI Manager convention
; should be in a separate "SCSIMgrPrivate" include file <PMAB466/JWK>
maxOpcode EQU 8 ; highest numbered TIB opcode
numSCSIVect EQU 24 ; max. number of selectors <C936/06Nov87> <PMAB466/JWK>
jmpTblSize EQU numSCSIVect*4 ; <C936/06Nov87> <PMAB466/JWK>
G_State EQU jmpTblSize+1 ; byte <PMAB466/JWK>
ROMRegSave EQU $408266B4
ROMUnimp EQU $408266FE
ROMDataEnd EQU $4082681A
ROMBlCmp1 EQU $40826B4A
ROMBlRd1 EQU $40826B54
ROMBlWr1 EQU $40826B9C
ROMGetExit EQU $40826744 ; exit the SCSIGet code <PMAB466/JWK>
ROMGetArb EQU $4082673A ; jump to "bsr Arbitrate" and continue <PMAB466/JWK>
move.l (sp)+,a0 ; get the return address
move.w (sp)+,d0 ; function selector (word)
move.l a0,-(sp) ; push the return address
cmp.w #numSCSIVect,d0 ; valid selector?
bhs.s @Unimp ; Sorry, Charlie
link a6,#LocalSize ; locals for bus error stuff
jmp ROMRegSave ; carry on as before
@Unimp
jmp ROMUnimp ; give them the bomb
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
;
; PMAB466 13Apr88 JWK SCSIGet SCSIMgr.a
;
; This cleans up the SCSIGet arbitration scheme. A "bset" instruction is used to
; test-and-set the SCSI Mgr's G_State global state variable. The ROM implementation
; could allow two processes into the SCSI Mgr code.
;
NewSCSIGet
bset.b #0,G_State(a4) ; mark SCSI Mgr state as "sBusy" <PMAB466/JWK>
beq.s @1 ; if zero, SCSI Mgr was free <PMAB466/JWK>
moveq.l #scMgrBusyErr,d0 ; SCSI Mgr is busy <PMAB466/JWK>
jmp ROMGetExit ; get out <PMAB466/JWK>
@1
jmp ROMGetArb ; jump to "bsr Arbitrate" and continue <PMAB466/JWK>
;--------------------------------------------------------------------------
;
; FUNCTION SCSIWrite(Control:Ptr): INTEGER;
; FUNCTION SCSIWBlind(Control:Ptr): INTEGER;
; FUNCTION SCSIRead(Control:Ptr): INTEGER;
; FUNCTION SCSIRBlind(Control:Ptr): INTEGER;
; (8) (12)
;
; This is the heart of the SCSI data transfer code, which includes the
; Transfer Information Block (TIB) interpreter.
;
mySCSIWBlind
bset #15,d4 ; blind flag
mySCSIWrite
st.b d4 ; set write flag
IF PatchSCSIRead THEN
bra.s myDataCommon
mySCSIRBlind
bset #15,d4 ; blind flag
mySCSIRead
move.b zeroReg,d4 ; clear write flag
move.b #iIO,sTCR+WrOffs(a3) ; match Data In phase
move.b #iDMA,sMR+WrOffs(a3) ; set DMA mode
move.b zeroReg,sIDMArx+WrOffs(a3) ; start DMA for a read
ENDIF
myDataCommon
moveq.l #bDMAR,d3 ; bit for DREQ test used in DataXFER <29Oct85>
move.l 8(a6),a1 ; get the control block pointer
bra.s @exec ; tighten loop by branching first
@c_compare
move.b #1,d4 ; this means compare to DataXFER <29Oct85>
; FALL THROUGH to @c_inc
@c_inc ; INC Addr,count
bsr.s @DataXFER ; move some data <23Apr86 LAK>
bne.s @data_end
add.l d2,scParam1(a1) ; increment the pointer
; FALL THROUGH to @next_cmd
@next_cmd
@c_nop ; NOP, just skip the command
add.w #SCSIZE,a1 ; move the command pointer
; FALL THROUGH to @exec
@exec
move.w scOpcode(a1),d0 ; get the function opcode
move.l scParam1(a1),a2 ; get the generic address
move.l scParam2(a1),d2 ; get the generic count
cmp.w #maxOpcode,d0 ; valid opcode?
bhi.s @c_badop ; return error if not
jmp @JmpTable(d0.w*2) ; go to jump table
@JmpTable
bra.s @c_badop ; 0 is not a valid opcode
bra.s @c_inc ; 1
bra.s @c_noinc ; 2
bra.s @c_add ; 3
bra.s @c_move ; 4
bra.s @c_loop ; 5
bra.s @c_nop ; 6
bra.s @c_stop ; 7
bra.s @c_compare ; 8
@c_badop
moveq.l #scBadParmsErr,d0 ; bad opcode
bra.s @data_end
@c_noinc ; NOINC addr,count
bsr.s @DataXFER ; move some data <23Apr86 LAK>
bne.s @data_end
bra.s @next_cmd ; and process next command
@c_add ; ADD addr,data
add.l d2,(a2) ; the count added to the where
bra.s @next_cmd
@c_move ; MOVE addr1,addr2
move.l d2,a0
move.l (a2),(a0) ; simple enough
bra.s @next_cmd
@c_loop ; LOOP relative addr,count
subq.l #1,d2 ; drop the count
beq.s @next_cmd ; if count = 1, quit loop <PB208>
move.l d2,scParam2(a1) ; put the count back for next time
add.l a2,a1 ; modify the command pointer
bra.s @exec ; and process the next command
@c_stop
moveq.l #noErr,d0 ; indicate no error, fall through.
@data_end
jmp ROMDataEnd ; back to the ROM
;--------------------------------------------------------------------------
;
; Move some data. d2 bytes into/from a2->.
; d4 contains modifying information:
; bit 15 is the blind bit.
; d4.b = minus = write
; = zero = read
; = plus = compare
;
; d2 contains the byte count on entry.
;
@DataXFER
moveq.l #0,d0 ; assume success (error code 0)
lea sBSR(a3),a4 ; save later indexing
tst.l d2 ; zero count?
beq.w @Xfer_rts ; yes, so exit
movem.l a1/d2,-(sp) ; save these registers
move.w #5,BusErrCount(a6) ; initialize count-down variable
move.l BusErrVct,OldBusErrVct(a6) ; keep old vector
lea @BusErrHandler,a0 ; use our handler
move.l a0,BusErrVct
tst.b d4 ; read or write?
bpl.s @RdCmp
@wreq
btst.b #bREQ,sCSR(a3) ; test for *REQ
beq.s @wreq
move.b zeroReg,sTCR+WrOffs(a3) ; match data out
move.b #iDMA,sMR+WrOffs(a3) ; set DMA mode
move.b #iDB,sICR+WrOffs(a3) ; assert data bus
move.b zeroReg,sDMAtx+WrOffs(a3) ; start write DMA
IF PatchSCSIRead THEN
bra.s @ckphase
@RdCmp
btst.b d3,(a4) ; test DRQ
bne.s @BlChk ; if there, ready for bytes
btst.b #bREQ,sCSR(a3) ; test for *REQ in case of phase error
beq.s @RdCmp ; no req either, must be seeking
ENDIF
@ckphase
btst.b #bPM,(a4) ; phase check
bne.s @BlChk ; branch if OK
moveq.l #scPhaseErr,d0
bra.w @Xfer_done
@BlChk
tst.w d4 ; if d4 is <1, these are blinds...
bmi.s @BlkStart ; go to the blind code
subq.l #1,d2 ; decr for DBRA
move.l d2,d5 ; make a copy of the byte count
swap d5 ; and get high word in d5
;
; Polled transfer modes
;
move.l SCSIDMA,a1 ; use the global
IF PatchSCSIRead THEN
tst.b d4 ; write/read?
bmi.s @SnWr ; it's a write
lea sIDR(a1),a0 ; input data offset
beq.s @SnRd ; it's a read
; else it's a compare
;
; This is the loop for polled compares. Byte count is in d2,d5
;
@SnCmp
btst.b d3,(a4) ; DRQ?
beq.s @SnCmpChk ; no, so check phase
move.b (a0),d1 ; get data byte
cmp.b (a2)+,d1 ; same?
beq.s @SnCmp1
moveq.l #scCompareErr,d0 ; record compare error
@SnCmp1
dbra d2,@SnCmp
dbra d5,@SnCmp
bra.s @RdDone
@SnCmpChk
btst.b #bPM,(a4) ; phase OK?
bne.s @SnCmp ; continue if it is
bra.s @RdPhaseErr ; else return error
;
; This is the loop for polled reads. Byte count is in d2,d5
;
@SnRd
btst.b d3,(a4) ; DRQ?
beq.s @SnRdChk ; no, so check phase
move.b (a0),(a2)+ ; read bytes into memory
@SnRd1
dbra d2,@SnRd
dbra d5,@SnRd
bra.s @RdDone
@SnRdChk
btst.b #bPM,(a4) ; phase OK?
bne.s @SnRd ; continue if it is
@RdPhaseErr
moveq.l #scPhaseErr,d0 ; else return error
bra.s @RdDone
ENDIF ; (IF PatchSCSIRead)
;
; This is the loop for polled writes. Byte count is in d2,d5
;
@SnWr
btst.b d3,(a4) ; DRQ?
beq.s @SnWrChk ; no, so check phase
move.b (a2)+,(a1) ; write bytes from memory
@SnWr1
dbra d2,@SnWr
dbra d5,@SnWr
bra.s @WrDone
@SnWrChk
btst.b #bPM,(a4) ; phase OK?
bne.s @SnWr ; continue if it is
moveq.l #scPhaseErr,d0 ; else return error
bra.s @DMAOff
;
; We get here for blind mode operations...
;
@BlkStart
move.l SCSIHsk,a1 ; hardware-handshaking write
lea sIDR(a1),a0 ; read address (NOTE: sODR = 0)
@DRQSync
btst.b d3,(a4) ; first wait for DMA to start
beq.s @DRQSync
IF PatchSCSIRead THEN
tst.b d4 ; test the I/O direction
beq.s @StartBlRd ; it's a read...
bmi.s @StartBlWr ; or a write...
; must be a compare, so fall through
@StartBlCmp
jsr ROMBlCmp1 ; do the ROM version
bra.s @RdDone
@StartBlRd
jsr ROMBlRd1 ; do the ROM version
bra.s @RdDone
ENDIF
@StartBlWr
jsr ROMBlWr1 ; do the ROM version
; We shouldn't turn off DMA mode before the last byte was
; taken. If the NCR chip asserts DRQ, then the peripheral got
; the byte. If the peripheral changes the bus phase, then it
; must have also gotten it.
@WrDone
btst.b d3,(a4) ; did we get DRQ?
bne.s @DMAOff ; if so, then turn DMA mode off
btst.b #bPM,(a4) ; still in the same phase?
bne.s @WrDone ; if so, then wait around...
@DMAOff
move.b zeroReg,sMR+WrOffs(a3) ; clear DMA mode
move.b zeroReg,sICR+WrOffs(a3) ; disable data bus
bra.s @Xfer_done ; <PB208>
@RdDone
btst.b #bREQ,sCSR(a3) ; test for *REQ <PB208>
beq.s @Xfer_Done ; if it's gone, we're done <PB220>
btst.b #bPM,(a4) ; still in same phase? <PB220>
bne.s @RdDone ; if so, go back and wait <PB220>
@Xfer_Done
move.l OldBusErrVct(a6),BusErrVct ; restore previous vector
movem.l (sp)+,a1/d2 ; restore the registers
tst.w d0 ; set the condition codes
@Xfer_rts
rts
;____________________________________________________________________________ jwk <18>
;
; BusErrHandler -- New and improved chaining SCSI bus error handler.
; When the SCSI Mgr is performing a blind data transfer, it patches
; out the bus error vector. The old SCSI Mgr bus error handler
; assumed that if it got called, it must be handling a SCSI bus error.
; Unfortunately, NuBus cards could bus error while the SCSI Mgr is
; installed. To be a better bus error citizen, the SCSI bus error
; handler now checks for a SCSI address as the fault address, and
; chains to the bus error handler that it replaced.
;
@BusErrHandler
move.l d0,-(sp) ; save d0 <18>
moveq.l #$ffffff9c,d0 ; mask = $ffffff9c <start>
and.l 4+$10(sp),d0 ; clear variable bits of the fault address
cmp.l SCSIHsk,d0 ; was it a SCSI chip access ?
beq.s @start ; if so, start processing the bus error
move.l (sp)+,d0 ; restore d0
move.l OldBusErrVct(a6),-(sp) ; put old bus error handler addr on stack <end>
rts ; jump to old handler, assuming it'll RTE <18>
@start
subq.w #1,BusErrCount(a6) ; retry until we get tired
beq.s @CleanUp
move.w TimeDBRA,d0 ; DBRA's per millisecond <18>
lsr.w #4,d0 ; 1ms/16 = approximately 62us (was 50us) <18>
@ErrWait dbra d0,@ErrWait ; recovery time (was 50us) <C865/PB208> <18>
move.l (sp)+,d0 ; restore d0 <18>
rte ; haven't reached max, so restart
@CleanUp
addq.l #4,sp ; throw away copy of d0 on stack <18>
move.w (sp),d0 ; get sr from the stack
bfextu 6(sp){0:4},d1 ; get format code from stack
cmp.b #$0A,d1 ; short exception frame?
bne.s @Drop46w ; no, so use larger frame
adda.w #16*2,sp ; dispose of the 16-word frame
bra.s @DummyFrame ; and finish up
@Drop46w ; format code $0B
adda.w #46*2,sp ; dispose of the 46-word frame
@DummyFrame
move.w zeroReg,-(sp) ; format code 0 (four word frame)
pea @Continue ; PC value
move.w d0,-(sp) ; sr value
rte ; 'return' from the fake exception
@Continue
moveq.l #scBusTOErr,d0 ; assume a slow peripheral
btst.b #bPM,sBSR(a3) ; phase change? <C478/10Dec86> <v1.5><18>
bne.s @ErrorDone ; no phase change
moveq.l #scPhaseErr,d0 ; return phase change error
@ErrorDone
rts ; return to TIB interpreter
;
; End of chaining SCSI bus error handler patch
;____________________________________________________________________________ jwk <18>
;_________________________________________________________________________________________ <72> djw
; Beginning code for Quantum 7.9 ROM fix
;
; Detailed description of the Quantum problem and solution:
;
; Quantum drives with the firmware version 7.9, has a problem with loosing the last byte
; of a block during a multi-block write. The problem occurs when the time between blocks
; written to the SCSI bus on the CPU side, is greater than 482 microseconds. This may
; occur in situations where there are a lot of interrupts. When conditions are right and
; the problem happens, the last byte of the previous block (in a multi-block transaction),
; is "eaten" by the drive. Any checksum or CRC calculated by the drive is correct,
; because the drive calculates it after the byte has been corrupted. This problem is
; especially frequent when email packages are installed on the Mac, since they generate
; a lot of interrupts which take a long time. This problem only occurs during fast
; writes in the SCSI manager (pseudo-dma mode).
;
; The way the SCSI manager currently works is it gets a TIB packet which contains the
; instructions on how to talk to a particular device. Included in the TIB is when to
; re-synchronize with the drive by waiting for a *REQ. When we see *REQ, the SCSI
; manager then begins the next TIB data transfer instruction and loads a byte of data
; into the 53C80's output register. After the first byte is "manually" sent, the
; hardware handshaking automatically takes care of the *REQ and *ACK handshaking. When
; the TIB write transfer is complete, pseudo-dma is disable, which releases *ACK,
; completing the handshake. This allows the target to assert *REQ when it is ready.
;
; The window of vulnerability is between the last byte of the previous block and the
; first byte of the next block. More correctly, it is between the rising edge of *ACK
; and the falling edge of the next *ACK. Because we release *ACK to synchronize, an
; interrupt may come in and delay the next transfer.
;
; The solution to the problem is to pre-load a data byte into the 53C80's data output
; register before we release *ACK. There are two ways of releasing *ACK: disable pseudo
; dma, and write a byte to the data output register. Leaving pseudo-dma enabled through
; the entire TIB will mean that whenever a *REQ occurs, there will be data available in
; the output register. This means there will be no delay between bytes because the
; hardware is not subject to interrupt delays.
;
; This patch therefore involves patching the TIB interpreter and the fast write routine
; in the SCSI manager. There are five versions of the SCSI manager to patch: Mac Plus,
; SE, Mac II, Portable, and IIci.
;
;_________________________________________________________________________________________
; QuantumWBlindII - patch to NewSCSIWBlind
;
; This code replaces the original SCSIWBlind entry point. The new entry for blind
; writes enables pseudo-dma on a per-transaction basis. Pseudo-dma was previously
; enabled only on a per-TIB-instruction basis. We completely patch out the existing
; ROM and system patch code for blind writes. This includes the TIB interpeter and
; the blind data transfer routine.
;
; Input: reg a3 = base of SCSI read addr
; a6 = SCSI stack frame
; d7 = zero
;
Export QuantumWBlindII
QuantumWBlindII
; This is the entry to the TIB interpeter for blind writes. Enable pseudo-dma mode
; for the duration of the write transaction.
move.b d7,sTCR+WrOffs(a3) ; set to match data out phase (to zero)
move.b #iDMA,sMR+WrOffs(a3) ; enable DMA in mode register
move.b #iDB,sICR+WrOffs(a3) ; assert data bus in initiator command reg
move.b d7,sDMAtx+WrOffs(a3) ; start write DMA
; Start of TIB interpreter
dataCommon
move.l 8(a6),a1 ; get the TIB pointer
bra.s @exec ; tighten loop by branching first
@c_inc
bsr.s FastWriteFix ; go to write blind routine
bne.s @data_end ; if error, bail out
add.l d1,scParam1(a1) ; increment the pointer
; FALL THROUGH to @next_cmd ; continue
@next_cmd
@c_nop ; also NOP, just skip the command
add.w #scSize,a1 ; point to the next TIB instruction
; FALL THROUGH to @exec
@exec
move.w scOpcode(a1),d1 ; get the function opcode
move.l scParam1(a1),a2 ; get the generic address
move.l scParam2(a1),d2 ; get the generic count
cmp.w #maxOpcode,d1 ; valid opcode ?
bhi.s @c_badop ; return err if not
jmp @JmpTable(d1.w*2) ; jump into table
@JmpTable
bra.s @c_badop ; 0 is not a valid opcode
bra.s @c_inc ; 1
bra.s @c_noinc ; 2
bra.s @c_add ; 3
bra.s @c_move ; 4
bra.s @c_loop ; 5
bra.s @c_nop ; 6
bra.s @c_stop ; 7
nop ; 8 not valid
; fall through to @c_badop
@c_badop
moveq.l #scBadparmsErr,d0 ; bad opcode
bra.s @data_end
@c_noinc ; NOINC addr,count
bsr.s FastWriteFix ; go to write blind routine
bne.s @data_end ; if error, exit
bra.s @next_cmd ; else process next command
@c_add ; ADD addr,data
add.l d2,(a2) ; the count added to the address
bra.s @next_cmd ; process the next command
@c_move ; MOVE addr1,addr2
move.l d2,a0 ; get the destination address
move.l (a2),(a0) ; simple enough
bra.s @next_cmd ; process the next command
@c_loop ; LOOP relative addr,count
tst.l d2 ; check for zero loop count
beq.s @next_cmd ; if count is already zero, quit loop
subq.l #1,d2 ; drop the count
move.l d2,scParam2(a1) ; put the count back for next time
beq.s @next_cmd ; if count exhausted, don't loop
add.l a2,a1 ; modify the command pointer
bra.s @exec ; and process the next command
@c_stop
moveq.l #noErr,d0 ; indicate no error
; FALL THROUGH to @data_end
@data_end
jmp (ROMDataEnd) ; back to ROM <77> djw
;_________________________________________________________________________________________
; FastWriteFix - patch to FastWrite
;
; This code replaces the low level data transfer routine for fast writes in the SCSI
; manager. It is rewritten to assume psuedo-dma is always on, and to do the device
; synchronization (looking for *REQ and *DRQ), after loading a data byte into the
; output register of the 5380. We don't have to worry about zero-byte transfers. They
; are weeded out in the calling routine (Transfer).
;
; Entry: d2 = number of bytes to transfer
; a2 = ptr to data buffer to transfer
; a3 = base addr of NCR 53C80
;
; Exit: d1 = number of bytes actually transfered. This value is only good if
; the transfer was good with no errors. It is inaccurate when an
; error aborts the transfer.
FastWriteFix
@savedregs Reg d2-d4/a1-a2/a5
; Setup for the transfer by installing our bus exception handler and saving
; registers.
movem.l @savedregs,-(sp)
move.w #5,BusErrCount(a6) ; store upper limit for allowable bus errors <77> djw
lea.l sBSR(a3),a1 ; a1 = sBSR(a3) by convention
lea @Done,a5 ; a5 = return addr if bus excptn
move.l BusErrVct,OldBusErrVct(a6) ; keep old vector
lea @BusErrHandler,a0 ; get addr of exception handler
move.l a0,BusErrVct ; install it in exception table
move.l SCSIHsk,a0 ; point to addr for pseudo-dma (hhsk)
; Check for zero count transactions
moveq.l #noErr,d0 ; assume no error
move.l d2,d1 ; make a copy of the count - is it zero ?
beq @Done ; no bytes to xfer - done
; Pre-load the NCR 53C80's output register with a byte of data. If we are in
; the middle of a multi-block write, *ACK is currently asserted. Writing a byte
; to the output register will release *ACK, completing the handshaking, allowing
; the target to assert *REQ.
sub.l #1,d2 ; dec number of bytes to xfer
move.b (a2)+,(a0) ; write data byte to output register
; With *ACK released, determine if the target is in sync. We cannot look for
; *REQ to be asserted, because the target may have already accepted the data byte
; and released *REQ at this point. We can sync on DRQ which will signal when
; the NCR 53C80 is ready to accept a data byte, meaning a *REQ from the target
; must have already occurred and our data byte was taken.
@syncWait
btst.b #bDMAR,(a1) ; check bus & status reg for DRQ
bne.s @doWrite ; DRQ present - sync-ed up so proceed
btst.b #bREQ,sCSR(a3) ; no DRQ - is *REQ present ?
beq.s @syncWait ; no *REQ yet - wait for sync
btst.b #bPM,(a1) ; with *REQ, check phase lines
bne.s @syncWait ; still in data out phase - wait
moveq.l #0,d1 ; out of phase - did not xfer any bytes
moveq.l #scPhaseErr,d0 ; return error
bra.s @Done ; exit
; Perform the write to the SCSI chip. First align the bytes to longs, then
; align them to 32 byte chunks. Transfer the bulk of the data in 32 byte
; blocks.
; Reg d2.l = number of bytes to move
@doWrite
cmpi.l #3,d2 ; check for very short copy
bls.s @veryShort ; skip alignment if very short
move.l a2,d0 ; get addr of data buffer
andi.l #$00000003,d0 ; check for long word alignment
beq.s @Aligned ; if no alignment needed
subq.l #4,d0 ; bias by 4 to get correct index
jmp @Aligned(d0.w*2) ; do the alignment
move.b (a2)+,(a0) ; move a byte
move.b (a2)+,(a0) ; move a byte
move.b (a2)+,(a0) ; move a byte
@Aligned
add.l d0,d2 ; adjust the byte count (d0 = neg)
move.l d2,d4 ; save tail byte count
lsr.w #2,d2 ; adjust to number of longs to move
moveq.l #7,d0 ; mask for starting index
and.l d2,d0 ; number of long words to move first
neg.w d0 ; negate to index backwards
lsr.l #3,d2 ; number of 32 byte blocks to move
move.l d2,d3 ; get number of 32*64K byte blks to move
swap d3 ; count in low word
jmp @CopyStart(d0.w*2) ; jump into the loop
@CopyLoop move.l (a2)+,(a0) ; move a 32 byte block of data....
move.l (a2)+,(a0) ; ... 4 bytes at a time
move.l (a2)+,(a0)
move.l (a2)+,(a0)
move.l (a2)+,(a0)
move.l (a2)+,(a0)
move.l (a2)+,(a0)
move.l (a2)+,(a0)
@CopyStart dbra d2,@CopyLoop ; loop in chunks of 32 bytes
dbra d3,@CopyLoop ; loop in chunks of 32*64K bytes
andi.l #$00000003,d4 ; check for tail alignment
move.l d4,d2 ; d2 = number of bytes remaining
@veryShort
neg.w d2 ; negate to index backwards
jmp @Remaining(d2.w*2) ; write remaining bytes
move.b (a2)+,(a0) ; move a byte
move.b (a2)+,(a0) ; move a byte
move.b (a2)+,(a0) ; move a byte
@Remaining
; Before exiting this routine, make sure that the peripheral has actually accepted
; the data byte. Wait for a DRQ (meaning the SCSI chip is ready for another byte)
; before exiting.
@DoneWait
moveq.l #noErr,d0 ; set good return
btst.b #bDMAR,(a1) ; check for DRQ (a1 = sBSR(a3))
bne.s @Done ; if DRQ, peripheral got the byte
btst.b #bREQ,sCSR(a3) ; no DRQ - is *REQ present ?
beq.s @DoneWait ; no *REQ yet - wait for it
btst.b #bPM,(a1) ; are we still in phase ?
bne.s @DoneWait ; if so, keep waiting
@Done
move.l OldBusErrVct(a6),BusErrVct ; restore previous Bus Error vector
movem.l (sp)+,@savedregs
tst.w d0 ; set the condition codes
rts ; we're done
;_________________________________________________________________________________________
; BusErrHandler - SCSI manager's bus exception handler for blind writes
;
; The SCSI manager patches out the bus exception vector during blind transfers. If
; a device fails to handshake within 4 microseconds, we get a bus exception. Retry
; the access to the SCSI chip a set number of times. If we exceed the rety count,
; then pop the exception stack frame and fake a short frame on the stack. Return
; from exception a given location.
;
; Input: a5 = addr to return to if retries expire
; a6 = SCSI manager locals
;
; Trashes reg d0 if retry expires
;
@BusErrHandler
move.l d0,-(sp) ; save d0
; Access to a number of SCSI addresses could cause a bus exception. Mask off the low
; bits of the fault address to get the base address. If it matches the SCSI chip's
; base address
moveq.l #$ffffff9c,d0 ; mask = $ffffff9c
and.l 4+$10(sp),d0 ; clear variable bits of the fault address
cmp.l SCSIHsk,d0 ; was it a SCSI chip access ?
beq.s @start ; if so, start processing the bus error
move.l (sp)+,d0 ; restore d0
move.l OldBusErrVct(a6),-(sp) ; jump to original handler
rts
; At this point, we believe the exception was caused by the SCSI manager. Decrement
; the re-try count. Continue re-trying the access until the count expires. Delay
; 62 microseconds between re-trys to allow the device to get its act together.
@start
subq.w #1,BusErrCount(a6) ; retry until we get tired
beq.s @CleanUp
move.w TimeDBRA,d0 ; DBRA's per millisecond
lsr.w #4,d0 ; 1ms/16 = approximately 62us (was 50us)
@ErrWait dbra d0,@ErrWait ; recovery time (was 50us)
move.l (sp)+,d0 ; restore d0
rte ; haven't reached max, so restart
; The device access failed past the retry count. Pop the bus exception stack
; frame and fake a short exception frame.
@CleanUp
addq.l #4,sp ; throw away copy of d0 on stack
move.w (sp),d0 ; get sr from the stack
adda.w #46*2,sp ; dispose of the 46-word frame
move.w #0,-(sp) ; format code 0 (four word frame)
move.l a5,-(sp) ; new return address
move.w d0,-(sp) ; sr value
; Determine whether this was a phase change or a device timeout from hardware handshaking
moveq.l #scBusTOErr,d0 ; assume a slow peripheral
btst.b #bREQ,sCSR(a3) ; is *REQ present ?
beq.s @ErrorDone ; no *REQ - assume timeout error
btst.b #bPM,sBSR(a3) ; phase change?
bne.s @ErrorDone ; no phase change
moveq.l #scPhaseErr,d0 ; return phase change error
@ErrorDone
rte ; 'return' from the fake exception
Endp
; end of SCSI patch
;
;___________________________________________________________________________
;____________________________________________________________________________ CCH <3.2>
; Record to describe gestalt function parameters
;
; Used by the following two gestalt patches <3.2> and <2.5>
;
gestaltParmFrame record {oldA6},decrement
result ds.w 1 ; OSErr
argSize equ *-8
gestaltSelector ds.l 1 ; packed array [1..4] of char
gestaltResult ds.l 1 ; addr of longint result
return ds.l 1
oldA6 ds.l 1
localFrame equ *
endR
;____________________________________________________________________________ CCH <3.2>
; Gestalt function for gestaltQuickdrawVersion
;
; The following is a patch to the gestaltQuickdrawVersion selector.
;
; Routine gestaltQDVers (
; gestaltSelector: OSType; = PACKED ARRAY [1..4] OF CHAR;
; VAR gestaltResult: Longint;
; ): OSErr; = Integer;
;
gestaltQD32Vers PROC EXPORT
with gestaltParmFrame
link a6,#localFrame
clr.l -(sp) ;make room for result
_OffScreenVersion
move.l gestaltResult(a6),a0 ; get address to place result
move.l (sp)+, d0 ; get QD version from GWorld
add.w #$100, d0
move.l d0, (a0) ; return version number for ci
move.w #noErr,result(a6) ; return no error
unlk a6
move.l (sp)+,a0 ; get return value
add.l #argSize,sp ; restore stack pointer
jmp (a0) ; return
ENDPROC
;____________________________________________________________________________________
; PB091 Cxxx 8Mar87 RDC PowerOff OS:InterruptHandlers.a
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 8Mar87 #PB091 (PowerOff) (PowerOff)
;
; PB541 Cxxx 22jul88 rwh PowerOff OS:InterruptHandlers.a
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 22jul88 PB541 (PowerOff) (PowerOff)
;
; Interrupt Handler patch for Power button interrupt. This patch fixes
; problem of turning system off from rear power button. If the button
; is depressed for too long the system will power off and then turn right
; back on. To fix the problem we wait for the button to be released before
; actually powering off the system. Also use timing constant to do about
; a half second delay before poweroff - fixed constant used instead of system
; determined value (i.e., TimeDBRA) for safety reasons.
; <PB541> Fix things so that PowerOff trap RETURNS if the machine didn't power off. This
; lets us use the Mac II ROM (actually, the Mac IIx ROM) in machines like Fafnir which
; do not have a soft power-off feature. The ShutDown code call to PowerOff conveniently
; is followed by the 'Its safe to Restart' dialog box code.
;
; <PB541> Note that we changed the TRAP vector to point to a different place than the
; power button interrupt vector, so we can still do the debounce/RTE code that was
; already here (Why the RTE stuff? Who knows, but don't change it cuz Mac II's do work).
; The trap now points to a place where we can to an rts. In the power button interrupt
; case on Mac II's, the two second delay should be ample time for the machine to power
; off before executing the rts (with a bogus return address cuz there is an interrupt
; stack frame on the stack, not a return address)
;
; OMIT FROM A/UX
;____________________________________________________________________________________
IF (&TYPE('vBase2') = 'UNDEFINED') THEN ; <6.2> Needed for Mac II Patch file
vBase2 EQU $50f02000 ; <6.2>
ENDIF ; <6.2>
NewPowerOff PROC EXPORT
EXPORT PowerOff ; <PB541>
ROMPowerOff EQU $408062EE ; ROM PowerOff address
OnemsDBRA EQU $0A3C ; about one ms DBRA loop (same as TimeDBRA)
PowerBtn BSET #6,NMIFlag ; use bit in NMIFlag as indicator
BNE.S PowerRTE ; skip if already in routine
; (button still depressed)
move.w #$2500,SR ; drop level to allow switch debounce <PB541>
bsr.s PowerOff ; attempt suicide (Fafnir won't) <PB541>
PowerRTE RTE ; just return until button released <PB541>
; entry point used by shutdown trap
PowerOff movem.l a0/d0-d1,-(sp) ; save regs, in case no soft poweroff <PB541>
CLR.L D0 ; clear for use
MOVE.W #OnemsDBRA,D0 ; get 1ms constant
MULU.W #500,D0 ; setup half second delay
MOVE.L D0,D1 ; save result
SWAP D1 ; setup high word
@1 DBRA D0,@1 ; decrement low word
DBRA D1,@1 ; then high word
;<PB541> JMP ROMPowerOff ; go back to ROM to do poweroff <PB541>
bsr.s Pause2Sec ; wait before dying <PB541>
MOVE.L #VBase2,A0 ; get base address of VIA2 <PB541>
BCLR.B #v2PowerOff,vBufB(A0) ; set VIA bits for poweroff <PB541>
BSET.B #v2PowerOff,vDirB(A0) ; goodbye... <PB541>
bsr.s Pause2Sec ; wait before rising from the dead <PB541>
movem.l (sp)+,a0/d0-d1 ; unsave regs, in case no soft poweroff <PB541>
rts ; this rts gets executed on machines <PB541>
; that don't have soft power-off <PB541>
; so ShutDown falls into 'safe to <PB541>
; restart' dialog <PB541>
Pause2Sec MOVEQ #OneSecConst*2,D0 ; setup twosec delay <PB541>
SWAP D0 ; to debounce button <PB541>
@1 SUBQ.L #1,D0 ; <PB541>
BNE.S @1 ; <PB541>
rts
ENDPROC
**********************************************************************************
* PB136 GetNewControl GetNewControl
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 24Mar87 #PB136 (GetNewControl) (GetNewControl)
;
* 24Mar87 JTC Patch GetNewControl to fix first instruction, that is, patch to
* use even-sized stack frame.
**********************************************************************************
MyGetNewControl PROC
ROMGNC2 EQU $1538A ; <PB302>
link a6,#-2 ; take two bytes, even if need just one
jmpRom ROMGNC2
ENDPROC
;-----------------------------------------------------------------------------
; PABM150 28Mar87 JTC&JAF New SysEnvirons call.
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 28Mar87 #PABM150 (SysEnvirons) (SysEnvirons)
;
INCLUDE 'SysEnvirons.a' ;<PMAB449>
*************************************************************************
* PB172 Patch Pack4 to fix Pack4 as implemented in ROM. In case of bin 2 dec
* conversion, signaled by opword bits $0B, clear bit #30 of D3 (or all bits, if
* you please) for use as an internal variable. By its nature, this patch should
* work (or cause no problems) for ANY version of Pack4, so we neednÕt test whether
* weÕre in the ROM version or not. Without this patch, numbers may be too
* small by 1ulp in decimal, so that 100 is 99.9999999 and the hideous like.
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 01jan1904 #PB172 (Pack4) (Pack4)
;
*************************************************************************
myPack4 proc
MOVEM.L D0/A0-A1,-(SP) ; two work regs and a slot for the pack address
@P4Retry
MOVE.L AppPacks+16,D0 ; low-mem handle
BEQ.S @P4NoHand ; no handle, no speed
MOVEA.L D0,A0 ; need to deref
MOVE.L (A0),8(SP) ; alleged ptr into rts cell
BEQ.S @P4LoadIt ; purged, no speed
BRA.S @P4GotIt
@P4NoHand ; get it the old-fashioned way
CLR.L -(SP) ; room for handle
MOVE.L #'PACK',-(SP) ;
MOVE.W #4,-(SP) ;
MOVE.W #MapTrue,ROMMapInsert ; use ROM map as well
_GetResource
MOVE.L (SP)+,AppPacks+16
BNE.S @P4Retry
@P4Die
MOVEQ #21,D0 ; Pack4notfound
_SysError ; out of luck this time...
@P4LoadIt
MOVE.L A0,-(SP) ; handle
MOVE.W #MapTrue,ROMMapInsert ; use ROM map as well
_LoadResource
MOVE.L (A0),8(SP) ; jam address of package
BEQ.S @P4Die ; if not loaded out of luck
@P4GotIt
MOVEQ #$1F,D0 ; mask for opcode bits
AND.W 16(SP),D0 ; D0<A0<ADRS<RET<opword<3longs
CMPI.B #$0B,D0 ; is it bin2dec?
BNE.S @P4Safe ; if not, go on as usual
; Now munge frame to save d3 across call, return to patch, and strip all
; extraneous parameters.
MOVEM.L (SP)+,D0/A0 ; stack: pack<rts<opword<3longs
MOVE.L D3,-(SP) ; save d3 across the dreaded call
MOVE.L 22(SP),-(SP) ; R3<d3<pack<rts<op<3longs
MOVE.L 22(SP),-(SP) ; R2<R3<d3<pack<rts<op<3longs
MOVE.L 22(SP),-(SP) ; R1<R2<R3<d3<pack<rts<op<3longs
MOVE.W 24(SP),-(SP) ; op<R1<R2<R3<d3<pack<rts<op<3longs
PEA @P4cleanUp ; now have new stack frame
MOVE.L 22(SP),-(SP) ; pack<ourrts<op<R1<R2<R3<d3<pack<rts<op<3longs
MOVEQ #0,D3 ; dummy up internal variable LostDigitFlag
RTS ; off to Pack4 at last!
@P4cleanUp ; resume here with d3<pack<rts<op<3longs
MOVE.L (SP)+,D3 ; restore our friend
ADDQ.L #4,SP ; strip pack, leaving rts<op<3longs
MOVE.L (SP),14(SP) ; op<2longs<rts
ADDA.W #14,SP ; rts
RTS ; back to original caller
@P4Safe
MOVEM.L (SP)+,D0/A0 ; restore work regs
RTS ; branch to package with clean stack
endproc ; myPack4
; ******************************************************************************************
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 16Jul87 #PB206 (PatConvert) (SetCCursor)
PatConvert PROC EXPORT
;-------------------------------------------------------------
;
; Replace PatConvert to fix a bug in SetCCursor
;
; BUG8: A2 would be trashed while expanding the cursor's
; data, and then be used in the multiple device loop (crash!).
FromSetCC EQU $1AF5C ;Return address we want <PB302>
ROMPatCvt EQU $1F36A ;Routine we're patching <PB302>
ROMA2ok EQU $1AF8C ;Where to go when done <PB302>
EXTBL EQU $22C16 ;Table of expand routines<<PB266 BAL 08Sep87>><PB302>
CMPRA FromSetCC,(SP) ;called by setCCursor? <<PB242 BAL 24Aug87>><PB302>
;used to be #ROMPatCvt <<PB242 BAL 24Aug87>>
BNE.S @NotUs ;=> no, continue
ADDQ #4,SP ;strip old return address
PEA @Patch ;and push new address
@NotUs JMPROM ROMPatCvt ;call the real routine <PB302>
@Patch MOVE.L (SP)+,THEGDEVICE ;RESTORE GRAFDEVICE
; EXPAND THE MASK TO THE CURRENT DEPTH
MOVE D3,D0 ;GET DEPTH
MOVEQ #0,D1 ;DEFAULT SHIFT = 0
@NXTSHFT1 LSR #1,D0 ;CHECK NEXT DEPTH BIT
BCS.S @GOTSHFT1 ;=>GOT SHIFT
ADDQ #1,D1 ;ELSE ADD ONE TO SHIFT
BRA.S @NXTSHFT1 ;LOOP UNTIL WE HIT A ONE
@GOTSHFT1 MOVE.L A2,-(SP) ;preserve A2 across expansion
LEA THECRSR+MASK,A0 ;SRC = CURSOR MASK
MOVE.L ([GDCCXMASK,A4]),A1 ;POINT TO EXPANDED MASK (LOCKED)
MOVE.L A1,A2 ;GET START OF DST BUFFER
MOVE #32,D0 ;GET #BYTES OF SOURCE
LSL D1,D0 ;MULTIPLY BY DEPTH
ADD D0,A2 ;POINT TO END OF BUFFER
LEA ([ROMBASE],EXTBL),A3 ;POINT TO ROUTINE TABLE <PB302>
ADD 0(A3,D1*2),A3 ;USE DEPTH TO SELECT ROUTINE
MOVEQ #0,D0 ;CLEAR HIGH PART OF D0
JSR (A3) ;EXPAND 32*DEPTH BYTES
MOVE.L (SP)+,A2 ;restore A2
JMPROM ROMA2ok ;=> return with A2 restored <PB302>
;___________________________________________________________________________
; PB212 CXXX 20Jul87 DAF GetNewCWindow
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 20Jul87 #PB212 (GetNewCWindow) (GetNewCWindow)
;
;
; FUNCTION GetNewCWindow(windowID: INTEGER; wStorage: Ptr; behind: windowPtr):windowPtr;
;
; GetNewWindow allocates a new window using the parameters contained
; in the "WIND" resource specified by the windowID
;
myGetNewCWindow PROC EXPORT
GetWDone EQU $15338 ; <PB302>
NoGetNew1 EQU $1537A ; <PB302>
result EQU 18 ; parameter equates
winID EQU 16
wStor EQU 12
behind EQU 8
VisState EQU -1 ; flag for resource's vis state <C314/31Oct86> DAF
Align EQU -2 ; another byte to re-align stack frame <C666/22Jan87> DAF
LINK A6,#Align ; build stack frame
MOVE.L A3,-(SP) ; preserve a work register
CLR.L result(A6) ; set result to NIL
SUBQ #4,SP ; make space for result
MOVE.L #'WIND',-(SP) ; push resource class "WIND"
MOVE.W winID(A6),-(SP) ; push window ID
_GetResource ; get the resource
MOVE.L (SP)+,A3 ; keep handle in A3
MOVE.L A3,D0 ; did we get one?
BNE.S @1 ; if so, continue <PB212>
JMPROM NoGetNew1 ; if not, don't allocate one <PB302>
@1
MOVE.L (A3),A0 ; keep pointer in A0
;
; OK, we got the parameter block so call NewWindow to allocate the window
;
SUBQ #4,SP ; make space for result
MOVE.L wStor(A6),-(SP) ; push wStorage
MOVE.L A0,-(SP) ; push pointer to boundsRect
PEA 18(A0) ; push pointer to title
MOVE.B 10(A0),VisState(A6) ; keep original vis state <A353/05Nov86> DAF
CLR.W -(SP) ; push vis FALSE <A353/05Nov86> DAF
MOVE.W 8(A0),-(SP) ; push procID <A353/05Nov86> DAF
MOVE.L behind(A6),-(SP) ; push "behind"
MOVE.W 12(A0),-(SP) ; push GoAway flag
MOVE.L 14(A0),-(SP) ; push the refCon
MOVEA.L A3,A0 ; handle <C169>
_HLock ; trash D0 <C169>
_NewCWindow ; allocate a color window <C106 EHB>
clr.l -(sp) ; make room for palette handle <erich>
move winID(a6),-(SP) ; push window ID <erich>
_GetNewPalette ; fetchez la palette <erich>
move.l (sp)+,d0 ; well? <erich>
Beq.S NoWindowPltt ; sorry, no automatic palette today AWC.PB459
Move.L D0,A0 ; get the palette AWC.PB459
Move.L (A0),A0 ; dereference it AWC.PB459
Move PmPrivate(A0),D1 ; grab the update bits AWC.PB459
Lsr #1,D1 ; put them in position AWC.PB459
BSet #NNewBit,D1 ; use the new CUpdates format AWC.PB459
BSet #DisposeBit,PmPrivate(A0) ; set for automatic disposal AWC.PB459
move.l (sp),-(sp) ; push the window <erich>
move.l d0,-(sp) ; push the palette <erich>
move D1,-(sp) ; push cUpdates AWC.PB459
_SetPalette ; <erich>
NoWindowPltt ; AWC.PB459
JMPROM GetWDone ; and back to the ROM <PB212/DAF> <PB302>
ENDPROC
;___________________________________________________________________________
; PB217 CXXX 22Jul87 BAL RSECT
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 22Jul87 #PB217 (RSECT) (DrawLine)
;AppleSystemPatch PatchIIROM.a 22Sep87 #PB286 (RSECT) (DrText)
;
;
; 2 Patches to RSect to fix bug in DrawLine, DrText
;
; DrawLine fast case is taken for black or white patterned single
; pixel horizontal or vertical lines. The test for black or white patterns
; in the ROM DrawLine is incompatible with new patterns. This patch
; allows fastline to be used in CGrafPorts.
;
; When skipping the shieldCursor call for offscreen pixmaps, drText branched <<PB286>>
; to NotFast instead of GetPtrs. This resulted in all offscreen drawing unnecessarily <<PB286>>
; taking the slow text drawing case--furthermore crashes would occur if the offscreen drawing <<PB286>>
; was to a multibit pixmap. <<PB286>>
;
;------------------------------------------------------------------
;___________________________________________________________________________
; PB286 CXXX 22Sep87 BAL RSECT
;
;
; 1st Patch to RSect to fix bug in DrText
;
; When skipping the shieldCursor call for offscreen pixmaps, drText branched <<PB286>>
; to NotFast instead of GetPtrs. This resulted in all offscreen drawing unnecessarily <<PB286>>
; taking the slow text drawing case--furthermore crashes would occur if the offscreen drawing <<PB286>>
; was to a multibit pixmap. <<PB286>>
;
; PB362
;
; Extend this patch to fix fractional pen positioning in new ports
;------------------------------------------------------------------------
MyTextFix PROC EXPORT
;------------------------------------------------------------
;
; PROCEDURE DrText(count: INTEGER; textAddr: Ptr; numer,denom: Point);
;
; DRAWS CHARACTERS INTO THE CURRENT PORT'S BITMAP.
; THE FONT AND ATTRIBUTES ARE GIVEN IN THE CURRENT PORT'S CHARSTYLE.
;
oldIteration EQU 0
;-------------------------------------------
;
; KERNED STRIKE FONT FORMAT OFFSETS:
;
FORMAT EQU 0 ;WORD
MINCHAR EQU 2 ;WORD
MAXCHAR EQU 4 ;WORD
MAXWD EQU 6 ;WORD
FBBOX EQU 8 ;WORD fKernMax
FBBOY EQU 10 ;WORD save as nDescent; unused except as high owTLoc
FBBDX EQU 12 ;WORD fRectWidth
FBBDY EQU 14 ;WORD fRectHeight
LENGTH EQU 16 ;WORD owTLoc
ASCENTVAL EQU 18 ;WORD
DESCENTVAL EQU 20 ;WORD
XOFFSET EQU 22 ;WORD leading
RASTER EQU 24 ;WORD rowWords
;------------------------------------------------------
;
; A6 OFFSETS OF PARAMETERS AFTER LINK:
;
PARAMSIZE EQU 14 ;SIZE OF PARAMETERS
CHARCOUNT EQU PARAMSIZE+8-2 ;WORD
TEXTADDR EQU CHARCOUNT-4 ;LONG
NUMER EQU TEXTADDR-4 ;LONG, POINT
DENOM EQU NUMER-4 ;LONG, POINT
;-----------------------------------------------------------
;
; A6 OFFSETS OF LOCAL VARIABLES AFTER LINK:
;
SAVESTK EQU -4 ;long stack before allocating buffers
TEXTRECT EQU SAVESTK-8 ;RECT original bounding rect
TEXTR2 EQU TEXTRECT-8 ;RECT copy of textRext used by maprect
MINRECT EQU TEXTR2-8 ;RECT minimum rect for clipping
BUFEND EQU MINRECT-4 ;LONG where the offscreen buffer ends
BUFSIZE EQU BUFEND-2 ;WORD the size of the offscreen buffer
BUFROW EQU BUFSIZE-2 ;WORD the rowBytes for the offscreen buffer
BUF2START EQU BUFROW-4 ;LONG second buffer used for shadow
BUF2END EQU BUF2START-4 ;LONG where shadow buffer ends
BUFLEFT EQU BUF2END-2 ;WORD output left edge
HEIGHT EQU BUFLEFT-2 ;WORD font fRectHeight copy
SRCPTR EQU HEIGHT-4 ;LONG used only in wide character case as temp
DSTPTR EQU SRCPTR-4 ;LONG used only in wide character case as temp
BUFSTART EQU DSTPTR-4 ;LONG \ start of bits buffer
SRCADDR EQU BUFSTART-4 ;LONG >- these 3 grouped: address of font bits
SRCROW EQU SRCADDR-4 ;LONG / rowbytes of font bits
maskStart EQU SRCROW-4 ;LONG \ start of mask buffer
maskAddr EQU maskStart-4 ;LONG >- these 3 grouped: address of mask bits
mSrcRow EQU maskAddr-4 ;LONG / rowbytes of mask bits
FROMRECT EQU mSrcRow-8 ;RECT mapRect parameter
TORECT EQU FROMRECT-8 ;RECT mapRect parameter
PENLOC EQU TORECT-4 ;POINT copy of original pnLoc
SPWIDTH EQU PENLOC-4 ;FIXED POINT width of space
CHARLOC EQU SPWIDTH-4 ;FIXED POINT fractional pen position
HEIGHTAB EQU CHARLOC-4 ;LONG pointer to font height table
WIDTAB EQU HEIGHTAB-4 ;LONG pointer to font offset/width table
LOCTAB EQU WIDTAB-4 ;LONG pointer to font location table
SAVEA5 EQU LOCTAB-4 ;LONG register saved so can be reused
characterExtra EQU SAVEA5-4 ;LONG fixed point extra added to each character
maskBitsPtr EQU characterExtra-4 ;LONG pointer to maskBits, sourcePix, or 0
bkCol EQU maskBitsPtr-4 ;LONG full of the background color
leftBack EQU bkCol-4 ;LONG bkCol masked to the left part of the character
rightBack EQU leftBack-4 ;LONG bkCol masked to the right part of the character
REALBOUNDS EQU rightBack-4 ;LONG USED FOR SHIELDCURSOR
leftOffset EQU REALBOUNDS-8 ;2 LONGs offset used by bit field instructions in charblt
maskSize EQU leftOffset-2 ;WORD size of mask buffer
mBufRow EQU maskSize-2 ;WORD \ these 2 mask buffer row size
maskBlts EQU mBufRow-6 ;3 WORDS / grouped: saved state for mask blit
FAKERGN EQU maskBlts-10 ;RECTANGULAR REGION
FAKEPTR EQU FAKERGN-4 ;LONG, FAKE MASTER POINTER
INFO EQU FAKEPTR-8 ;4 WORDS font info record returned by txMeasure (unused)
NUMER2 EQU INFO-4 ;Point copy of numer for iterative case
DENOM2 EQU NUMER2-4 ;Point copy of denom for iterative case
charsRemain EQU DENOM2-2 ;word remaining characters to draw in iterative case
SRCBITS EQU charsRemain-14 ;bitMap input to shadow stretchBits, bitsToPix
SRCPIX EQU SRCBITS-(PMREC+CTREC+20) ;pixMap input to normal stretchbits
maskBits EQU SRCPIX-14 ;bitMap input to bitsToPix for font mask
DSTPIX EQU maskBits-(PMREC+CTREC+20) ;pixMap destination
FASTFLAG EQU DSTPIX-1 ;BYTE flag set if source ORing to screen is OK
maskFont EQU FASTFLAG-1 ;byte flag set if a maskFont is available + requested
STRETCH EQU maskFont-1 ;BOOLEAN flag set if numerator not equal denominator
HEIGHTFLAG EQU STRETCH-1 ;byte flag set if font has a height table
TOPHT EQU HEIGHTFLAG-2 ;word character top & height from font or clip
MAXMIN EQU TOPHT-2 ;word number of characters in font
MINCH EQU MAXMIN-2 ;word first character in font
bitDepth EQU MINCH-2 ;word \ These two bits per pixel in font
bkCol1 EQU bitDepth-2 ;word / grouped. 1 pixel worth of background color
italicSlop EQU bkCol1-2 ;word extra width due to italic, bold, outline, shadow
kernAdjust EQU italicSlop-2 ;word left kerning due to kerning and italic
penLocHFrac EQU kernAdjust-2 ;word fractional pen position for recursive calls
longCount EQU penLocHFrac-2 ;word loop counter for doMove
charWidth EQU longCount-2 ;word width in pixels of current character blt
stackOffset EQU charWidth-2 ;word 2 if stack was word aligned before link
countCopy EQU stackOffset-2 ;word copy of character count, decremented as drawn
CRSRFLAG EQU countCopy-2 ;WORD
locMode EQU CRSRFLAG-2 ;word copy of text mode, adjusted if arith. + 1 bit
bitShift EQU locMode-2 ;word how far to shift to multiply by bitDepth
orNotOK EQU bitShift-1 ;Boolean true if bit extract/insert must be used instead
notMaskPass EQU orNotOK-1 ;Boolean true if blit is not creating font mask
textCopyMode EQU notMaskPass-1 ;Boolean true if blit must use extract/insert
orMode EQU textCopyMode-1 ;Boolean true if mode is srcOr & forecolor is black
colorSource EQU orMode-1 ;Boolean true if font contains colors (nonblack/white)
saveHilite EQU colorSource-1 ;byte saved hilite flag for iterative state
VARSIZE EQU (((colorSource+1)/4)-1)*4 ;SIZE OF VARIABLES long aligned
ROMRSect equ $1d58a ;ROM RSect code <PB302>
fromROMDrText equ $1a238 ;ROM RSect call return address <PB302>
ROMgoOn equ $1a562 ;ROM normal re-entry point <PB302>
ROMIterate equ $19f7e ;ROM iteration re-entry point <PB302>
ROMGoHome equ $1ab64 ;ROM do nothing re-entry point <PB302>
; _RSECT ;CALC INTERSECTION
;Do rsect then come back to us
comeBack
bne.s continue ;yes, non-empty intersection
goHome JMPROM ROMGoHome ;QUIT IF NO INTERSECTION
continue
MOVE (SP)+,textR2+right(A6) ;restore text right
;
; Set up srcAddr, srcRow, and height
;
LEA 26(A2),A0 ;GET START OF FONT BITMAP
MOVE.L A0,SRCADDR(A6) ;SAVE FOR LATER
MOVEQ #0,D1 ;zero high word
MOVE RASTER(A2),D1 ;GET WORDS PER ROW IN FONT
MOVE bitShift(A6),D0
LSL.L D0,D1 ;scale up font rowWords
ADD.L D1,D1 ;DOUBLE FOR BYTES PER ROW
MOVE.L D1,SRCROW(A6) ;REMEMBER FOR LATER
MOVE FBBDY(A2),HEIGHT(A6) ;SETUP HEIGHT FOR LATER
;
; Test for fast case:
; not stretched, no color mapping, txMode = srcOr, same bits per pixel
; not bold, italic, underlined, outlined or shadowed,
; visRgn and clipRgn both rectangular.
;
TST.W 6(A4) ;TEST BOLD AND ITALIC
BNE NOTFAST ;NOT FAST UNLESS BOTH ZERO
TST.B orMode(A6) ;IS TEXT MODE SRCOR ? (or srcCopy + mask, see above)
BEQ NOTFAST ;NO, NOT FAST
TST.W 10(A4) ;TEST ULTHICK AND SHADOW
BNE NOTFAST ;NOT FAST UNLESS BOTH ZERO
TST.B STRETCH(A6) ;IS TEXT STRETCHED ?
BNE NOTFAST ;YES, NOT FAST
MOVE.L ([CLIPRGN,A3]),A0 ;GET CLIPRGN HANDLE, dereferenced
MOVEQ #10,D0
CMP RGNSIZE(A0),D0 ;IS CLIPRGN RECTANGULAR ?
BNE NOTFAST ;NO, NOT FAST
MOVEQ #1,D0
MOVE bitShift(A6),D1 ;get the depth of the source map
LSL D1,D0 ;turn into 1 ÉÊ8
CMP DSTPIX+PIXELSIZE(A6),D0 ;same depth per pixel?
BNE NOTFAST ;=>NOPE
MOVE.L VISRGN(A3),A1 ;GET VISRGN HANDLE
MOVE.L (A1),A0 ;DE-REFERENCE IT
CMP RGNSIZE(A0),D0 ;IS VISRGN RECTANGULAR ?
BEQ.S FAST ;YES, TAKE FAST OPTIMIZATION
;
; All systems go except for VisRgn not rectangular.
; Check if visRgn sect minRect is rectangular.
; IF TrimRect(visRgn,minRect) THEN take the fast way.
;
MOVE.L A1,-(SP) ;PUSH VISRGN
PEA MINRECT(A6) ;PUSH MINRECT
JSR ([$E00+$329*4]) ;_TRIMRECT ;CALL TRIMRECT
BLT.s GOHOME ;quit if intersection empty
BGT NOTFAST ;continue if non-rectangular
;
; Fast case, go directly to screen.
; If text is clipped vertically, then clear heightflag and update TOPHT
;
FAST ST FASTFLAG(A6) ;REMEMBER WE'RE GOING FAST
CLR.B maskFont(A6) ;no need for second mask pass in fast case
CLR.L bkCol(A6) ;zero out back color long
MOVE MINRECT+TOP(A6),D0 ;GET MINRECT.TOP
MOVE MINRECT+BOTTOM(A6),D1 ;GET MINRECT.BOTTOM
SUB TEXTRECT+TOP(A6),D0 ;was top clipped ?
BNE.S VCLIP ;yes, handle clip
CMP TEXTRECT+BOTTOM(A6),D1 ;was bottom clipped ?
BEQ.S VCLIPOK ;no, continue
VCLIP CLR.B HEIGHTFLAG(A6) ;can't use height table
MOVE.B D0,TOPHT(A6) ;use adjusted top
SUB MINRECT+TOP(A6),D1 ;calc clipped height
MOVE.B D1,TOPHT+1(A6) ;replace TOPHT
VCLIPOK MOVE TEXTRECT+TOP(A6),D0 ;GET DST TOP
SUB DSTPIX+BOUNDS+TOP(A6),D0 ;CONVERT TO GLOBAL COORDINATES
MOVE DSTPIX+ROWBYTES(A6),D1 ;GET ROWBYTES
AND #RBMASK,D1 ;CLEAR OFF FLAG BITS
MULS D1,D0 ;MULT BY ROWBYTES
ADD.L DSTPIX+BASEADDR(A6),D0 ;ADD START OF DST BITMAP
MOVE.L D0,BUFSTART(A6) ;SET UP BUFSTART FOR LATER
MOVE D1,BUFROW(A6) ;SET UP BUFROW FOR LATER
MOVE DSTPIX+BOUNDS+LEFT(A6),BUFLEFT(A6) ;REMEMBER BUFLEFT
MOVE.L THEGDEVICE,A0 ;GET CURRENT DEVICE
MOVE.L (A0),A0 ;POINT AT IT
MOVE.L GDPMAP(A0),A0 ;GET ITS PIXMAP
MOVE.L (A0),A0 ;POINT AT IT
MOVE.L BASEADDR(A0),D0 ;GET BASE OF SCREEN
CMP.L DSTPIX+BASEADDR(A6),D0 ;DRAWING TO SCREEN?
SEQ CRSRFLAG(A6) ;IF SO, SET FLAG
bne GETPTRS ;=>NO, so just skip skieldCursor--don't go slow! <PB362>
PEA MINRECT(A6) ;PUSH SHIELD RECT
MOVE.L REALBOUNDS(A6),-(SP) ;PUSH DELTA FOR GLOBAL
JSR ([$E00+$55*4]) ;_SHIELDCURSOR ;HIDE CURSOR IF IT INTERSECTS
;_____________________________________________________________________
;
; <<Begin PB362 BAL>>
BRA GETPTRS
;
; Slow case: Setup for an off-screen buffer.
;
; Calc bufLeft: (LONG-align to avoid shift)
;
NOTFAST SF FASTFLAG(A6) ;NOT GOING DIRECTLY TO SCREEN
MOVE TEXTRECT+LEFT(A6),D0 ;GET TEXTRECT LEFT
SUB DSTPIX+BOUNDS+LEFT(A6),D0 ;CONVERT TO GLOBAL
AND #$FFE0,D0 ;TRUNC TO LONG BOUND
ADD DSTPIX+BOUNDS+LEFT(A6),D0 ;RETURN TO LOCAL COORDS
MOVE D0,BUFLEFT(A6) ;REMEMBER FOR LATER
;
; Calculate buffer size
;
MOVEQ #0,D1 ;clear high word
MOVE TEXTRECT+RIGHT(A6),D1 ;BUFRIGHT := TEXTRECT RIGHT
SUB D0,D1 ;WIDTH:=BUFRIGHT-BUFLEFT
MOVE D1,D2 ;mask depth as well
MOVE bitShift(A6),D4 ;convenient constant
LSL.L D4,D1 ;scale up by pixel size + 1 for mask
LSR.L #5,D1 ;CONVERT DOTS TO LONGS
ADD #2,D1 ;ROUND UP PLUS EXTRA LONG
MOVE HEIGHT(A6),D3 ;GET HEIGHT
MULU D1,D3 ;BUFSIZE:=HEIGHT*BUFROW LONGS
; if the intermediate result is too big, stop before going any further
CMP.L #$1C00,D3 ;is it bigger than 28K? (unit is longs)
BGT.S DoSubDivide ;if so, draw fewer characters at a time
MOVE D3,BUFSIZE(A6) ;SAVE FOR LATER
ADD D1,D3 ;add for stretch srcBuf
LSL #2,D1 ;QUAD BUFROW FOR BYTES
MOVE D1,BUFROW(A6) ;SAVE FOR LATER
MOVE TEXTR2+RIGHT(A6),D5
SUB TEXTR2+LEFT(A6),D5
LSR #5,D5 ;convert to longs
ADDQ #2,D5 ;account for slop
MOVE D5,D0
ADD D0,D3 ;in case clip is nonrectangular
ADD D0,D3 ;in case vis is nonrectangular
LSL D4,D0 ;scale up by source depth
ADD D0,D3 ;add stretch destination buffer size
MULU dstPix+pixelSize(A6),D5 ;size of composite mask
ADD D5,D3 ;include it
;if srcDepth not equal to dstDepth, add stretch dest. buf. again
ADD D5,D3 ;include space for scale buffer
;set up maskSize, maskRow
TST.B maskFont(A6) ;do we need a mask to pass to stretchBits?
BEQ.S @noMask
LSR #5,D2 ;CONVERT DOTS TO LONGS
ADD #2,D2 ;ROUND UP PLUS EXTRA LONG
ADD D2,D1 ;total number of longs
MOVE HEIGHT(A6),D0 ;GET HEIGHT
MULU D2,D0 ;BUFSIZE:=HEIGHT*BUFROW LONGS
MOVE D0,maskSize(A6) ;SAVE FOR LATER
LSL #2,D2 ;QUAD BUFROW FOR BYTES
MOVE D2,mBufRow(A6) ;SAVE FOR LATER
ADD D0,D3 ;add for stack check calculation
ADD D2,D3 ;add for stretch srcMaskBuf
MOVE TEXTR2+RIGHT(A6),D0
SUB TEXTR2+LEFT(A6),D0
LSR #5,D0 ;convert from dots to longs
ADD D0,D3 ;add stretch mask destination buffer size
@noMask
;
; Calculate total stack requirements for off-screen buffers.
;
TST.B 11(A4) ;ARE WE SHADOWING ?
BEQ.S @1 ;NO, CONTINUE
ADD bufSize(A6),D3 ;YES, CALC 2*BUFSIZE
ADD D1,D3 ;add in 4 * source rows for shadow
@1 LSL.L #2,D3 ;CALC TOTAL STACK BYTES NEEDED
; how much slop? size of scale table (256 bytes maximum)
; size of stretch stack frame (750 bytes for parameters, local stack frame, saved regs),
; and about 1K for interrupts.
ADD.L #2048,D3 ;ADD 2 KBYTE SLOP
;
; If stack is too small to allocate buffer(s), then draw half as many characters at a time.
;
_StackAvail ;Get StackAvail IN D0
CMP.L D0,D3 ;IS stackNeeded > stackAvail ?
BLE.S StackAlmost ;NO, CONTINUE
DoSubDivide
MOVE stackOffset(A6),D6 ;2 if stack was not aligned, otherwise, 0
MOVE charCount(A6,D6),D0 ;how many characters to draw
MOVE D0,D7 ;figure half
LSR #1,D7
BNE.S @subDivide ;if more than 1 left, can subdivide problem
SUBQ #1,charsRemain(A6) ;pretend the one character was drawn
BRA GoHome ;if only 1 character, punt
@subDivide
; *** look for space character? Could adjust D7 to coincide with a space if any, making
; *** drawing look better (for italics, kerns)
TST charsRemain(A6) ;if zero, this is the first time through
BNE.S @notFirst
MOVE.B HiliteMode,saveHilite(A6) ;save original in case stretch is called multiple times
MOVE D0,charsRemain(A6) ;initialize partial count drawing location
@notFirst
MOVE.L PENLOC(A6),PNLOC(A3) ;RESTORE PNLOC TO ORIGINAL
TST PORTBITS+ROWBYTES(A3) ; is it a new port?
BPL.S @useOld ; no, no fraction to restore
MOVE PenLocHFrac(A6),pnLocHFrac(A3) ;restore fraction if applicable
@useOld
MOVE D7,charCount(A6,D6) ;reset count to draw
doIterate
MOVE.L grafGlobals(A5),A4 ;set up grafGlobals pointer for getting real width
MOVE.L numer2(A6),numer(A6,D6) ;restore numerator
MOVE.L denom2(A6),denom(A6,D6) ;restore denominator
MOVE.B saveHilite(A6),HiliteMode ;restore hilite bit
JMPROM ROMIterate ;draw first half of string <PB362>
; draw the second half of the string, but drawing no more characters than could be successfully
; drawn by the first half.
secondHalf
MOVEQ #0,D7 ;zero high word
MOVE stackOffset(A6),D6 ;2 if stack was not aligned, otherwise, 0
MOVE charCount(A6,D6),D7 ;number of characters drawn last
MOVE charsRemain(A6),D0 ;how many characters remain?
CMP D0,D7 ;donÕt try to draw more than worked last
BLE.S @ok
MOVE D0,charCount(A6,D6) ;draw what remains for the second half
@ok
ADD.L D7,textAddr(A6,D6) ;bump source address by half already drawn
BRA.S doIterate
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
;
; Allocate and clear an off-screen buffer
;
; If the source font is only 1 bit deep, clear the screen to white. Also, if the transfer
; mode is xor, bic, or, clear the screen to white. If an arithmetic mode or copy and
; source is multibits deep, assume depth of source font is equal to destination depth.
; Also assume that background of buffer must be colored the same as the port background color.
StackAlmost
MOVEQ #0,D0
TST bitShift(A6) ;is source 1 bit?
BEQ.S @whiteBackCol
CMP #srcXor,locMode(A6) ;srcXor?
BEQ.S @whiteBackCol ;even if font contains colors, leave background white
TST.B colorSource(A6) ;font contains color?
BNE.S @useBackCol ;if so, must color the buffer
CMP #$32,locMode(A6) ;hilite?
BEQ.S @whiteBackCol ;leave background white if so
BTST #5,locMode+1(A6) ;arithmetic?
BEQ.S @whiteBackCol ;if copy, or leave background white
@useBackCol
SUBQ #6,SP ;allocate VAR RGBColor
MOVE.L SP,-(SP) ;point to VAR RGBColor
_GetBackColor ;ask for the background color
CLR.L -(SP) ;make room for function result
PEA 4(SP) ;point to VAR RGBColor
_Color2Index
MOVEQ #0,D0
MOVEQ #32,D1 ;
MOVE bitDepth(A6),D2 ;get destination bits per pixel
@nxtPixel
ASL.L D2,D0
OR 2(SP),D0 ;or in result of color2Index
SUB D2,D1
BGT.S @nxtPixel
ADD #10,SP ;strip RGBColor and long result
@whiteBackCol
MOVE.L D0,bkCol(A6) ;save for comparing with background, later
STACKOK MOVE bufSize(A6),D3
SUBQ #1,D3 ;INIT DBRA LOOP COUNT
MOVE.L D0,-(SP) ;PAD BUFFER WITH AN EXTRA ZERO
MOVE.L SP,BUFEND(A6) ;REMEMBER WHERE BUFFER ENDS
CLRLOOP MOVE.L D0,-(SP)
DBRA D3,CLRLOOP ;ALLOCATE AND CLEAR BUFFER
MOVE.L SP,BUFSTART(A6) ;REMEMBER START OF BUFFER
MOVE.L D0,-(SP) ;PAD BUFFER WITH AN EXTRA ZERO
TST.B maskFont(A6)
BEQ.S @noMask
MOVE maskSize(A6),D3
SUBQ #1,D3
CLR.L -(SP)
@clrMask
CLR.L -(SP)
DBRA D3,@clrMask
MOVE.L SP,maskStart(A6)
@noMask
CLR.L -(SP)
;
; Get pointers to location table, width table, and height table in font
;
GETPTRS LEA 26(A2),A0 ;GET START OF FONT BITMAP
MOVEQ #0,D0 ;zero high word
MOVE FBBDY(A2),D0 ;GET HEIGHT OF FONT BITMAP
MULU.L SRCROW(A6),D0 ;CALC TOTAL SIZE OF STRIKE
ADD.L D0,A0 ;A1 := START OF LOC TABLE
MOVE.L A0,LOCTAB(A6) ;SAVE FOR LATER
; *** could test bitShift first and only check fNDescent if bitDepth > 1 É
MOVE.W fNDescent(A2),D0 ;possibly the high word of owTLoc
SWAP D0 ;put it in the high word
BPL.S @notNegative
MOVEQ #0,D0 ;old fonts have negative of ascent here
@notNegative
MOVE LENGTH(A2),D0 ;HOW MANY WORDS IN STRIKE BODY
LEA 16(A2,D0.L*2),A1 ;GET START OF WIDTH TABLE
MOVE.L A1,WIDTAB(A6) ;SAVE FOR LATER
MOVE MAXCHAR(A2),D0 ;GET MAXCHAR
MOVE MINCHAR(A2),D1 ;GET MINCHAR
MOVE D1,MINCH(A6) ;STASH MINCHAR FOR LATER
SUB D1,D0 ;CALC MAXCHAR-MINCHAR
MOVE D0,MAXMIN(A6) ;SAVE FOR LATER
ADD #3,D0 ;CALC MAXMIN+3
BTST #1,1(A2) ;DOES FONT HAVE WIDTH TABLE ?
BEQ.S NOWID ;NO, CONTINUE
ADD D0,D0 ;SKIP WIDTH TABLE
NOWID LEA 0(A1,D0*2),A0 ;POINT TO HEIGHT TABLE
MOVE.L A0,HEIGHTAB(A6) ;SAVE FOR LATER
;
; Set up space width
;
MOVE.L widthTabHandle,A0 ;point to width table
MOVE.L (A0),A0
MOVE.L 128(A0),SPWIDTH(A6) ;get width of the space char
;
; Setup misc stuff in registers for speed
;
MOVE BUFLEFT(A6),D1 ;GET BUFLEFT
MOVE PENLOC+H(A6),D0 ;GET PEN LOCATION
ADD kernAdjust(A6),D0 ;ADJUST FOR KERNING
SUB D1,D0 ;MAKE CHARLOC RELATIVE TO BUFLEFT
MOVE.W D0,CHARLOC(A6) ;INIT INT PART OF CHARLOC
TST PORTBITS+ROWBYTES(A3) ;is it a new port?
BPL.S @useOld ;no, set fraction to 1/2
;
; The following line is the only one source line changed in this patch <PB362> BAL
;
MOVE penLocHFrac(A6),CHARLOC+2(A6) ;set up fractional part <PB362> BAL
BRA.S @goOn
@useOld
MOVE #$8000,CHARLOC+2(A6)
@goOn
JMPROM ROMgoOn ;jmp back to ROM
;
; <<End PB362 BAL>>
;_____________________________________________________________________
ENDPROC
;___________________________________________________________________________
; PB217 CXXX 22Jul87 BAL RSECT
;
;
; 2nd Patch to RSect to fix bug in DrawLine
;
; DrawLine fast case is taken for black or white patterned single
; pixel horizontal or vertical lines. The test for black or white patterns
; in the ROM DrawLine is incompatible with new patterns. This patch
; allows fastline to be used in CGrafPorts.
;
;------------------------------------------------------------------
MyRSect PROC EXPORT
IMPORT myTextFix
;------------------------------------------------
;
; A6 OFFSETS OF DrawLine PARAMETERS AFTER LINK:
;
PARAMSIZE EQU 8 ;SIZE OF PARAMETERS
P1 EQU PARAMSIZE+8-4 ;POINT
P2 EQU P1-4 ;POINT
;-------------------------------------------------
;
; A6 OFFSETS OF LOCAL VARIABLES AFTER LINK:
;
; STACK FRAME VARS USED BY SEEKMASK (CALLED BY STRETCHBITS, RGNBLT, DRAWARC, DRAWLINE)
;
RECTFLAG EQU -2 ;WORD
VERT EQU RECTFLAG-2 ;WORD
RGNBUFFER EQU VERT-4 ;LONG
BUFLEFT EQU RGNBUFFER-2 ;WORD
BUFSIZE EQU BUFLEFT-2 ;WORD
EXRTN EQU BUFSIZE-4 ;LONG
SEEKMASK EQU EXRTN-4 ;LONG
DSTMASKBUF EQU SEEKMASK-4 ;LONG
DSTMASKALIGN EQU DSTMASKBUF-4 ;LONG
STATEA EQU DSTMASKALIGN-RGNREC ;RGN STATE RECORD
STATEB EQU STATEA-RGNREC ;RGN STATE RECORD
STATEC EQU STATEB-RGNREC ;RGN STATE RECORD
; STACK FRAME VARS USED BY PATEXPAND
; (CALLED BY STRETCHBITS, RGNBLT, BITBLT, DRAWARC, DRAWLINE)
EXPAT EQU STATEC-4 ;LONG
PATVMASK EQU EXPAT-2 ;WORD (must follow expat)
PATHMASK EQU PATVMASK-2 ;WORD (must follow PATVMASK)
PATROW EQU PATHMASK-2 ;WORD (must follow PATHMASK)
PATHPOS EQU PATROW-2 ;WORD
PATVPOS EQU PATHPOS-2 ;WORD
LOCMODE EQU PATVPOS-2 ;WORD
PIXSRC EQU LOCMODE-1 ;BYTE YES
NEWPATT EQU LOCMODE-2 ;BYTE YES
LOCPAT EQU NEWPATT-4 ;LONG YES
FCOLOR EQU LOCPAT-4 ;LONG YES
BCOLOR EQU FCOLOR-4 ;LONG
DSTPIX EQU BCOLOR-(PMREC+CTREC+20) ;PIXMAP
DSTSHIFT EQU DSTPIX-2 ;WORD
; these shared stack frame vars are set up and used by the arithmetic drawing modes
weight EQU DSTSHIFT-6 ;RGB weight for averaging
pin EQU weight ;RGB used by max, min
notWeight EQU weight-6 ;RGB complement of weight (for average)
multiColor EQU notWeight-2 ;byte set if source contains nonblack/white colors
colorTable EQU multiColor-4 ;long pointer to color table
invColor EQU colorTable-4 ;long pointer to inverse color table
invSize EQU invColor-2 ;word resolution of inverse color table
rtShift EQU invSize-2 ;Word used by average how far to shift
transColor EQU rtShift-4 ;long copy of backcolor for transparent
hilitColor EQU transColor-4 ;long hilite color pixels
; STACK FRAME VARS USED ONLY BY DRAWLINE
LINERECT EQU hilitColor-8 ;RECT
MINRECT EQU LINERECT-8 ;RECT
SAVESTK EQU MINRECT-4 ;LONG
MODECASE EQU SAVESTK-4 ;LONG
LFTEDGE EQU MODECASE-4 ;LONG, FIXED POINT
RGHTEDGE EQU LFTEDGE-4 ;LONG, FIXED POINT
SLOPE EQU RGHTEDGE-4 ;LONG, FIXED POINT
DSTLEFT EQU SLOPE-4 ;LONG
SAVEA5 EQU DSTLEFT-4 ;LONG
PORT EQU SAVEA5-4 ;LONG
FASTFLAG EQU PORT-2 ;BYTE
BIGRGN EQU FASTFLAG-4 ;LONG, RgnHandle
DSTROW EQU BIGRGN-2 ;WORD
CRSRFLAG EQU DSTROW-2 ;WORD
REALBOUNDS EQU CRSRFLAG-4 ;LONG
VARSIZE EQU REALBOUNDS ;SIZE OF LOCAL VARIABLES
DrawLineRSect equ $1c222 ; <PB302>
ROMRSect equ $1d58a ; <PB302>
ROMGoHome equ $1c62e ; <PB302>
ROMDone equ $1c61e ; <PB302>
ROMFlagOK equ $1c2b8 ; <PB302>
ROMoldPat equ $1c284 ; <PB302>
fromROMDrText equ $1a238 ;ROM RSect call return address
;-----------------------------------------------------------------------
;
; CALC MINRECT, THE INTERSECTION OF LINERECT, BITMAP BOUNDS,
; CLIPRGN BBOX, AND VISRGN BBOX. QUIT IF NO INTERSECTION.
;
; PEA LINERECT(A6) ;PUSH LINE RECT
; PEA DSTPIX+BOUNDS(A6) ;PUSH PIXMAP BOUNDS
; PEA RGNBBOX(A2) ;PUSH CLIPRGN BBOX
; PEA RGNBBOX(A3) ;PUSH VISRGN BBOX
; MOVE #4,-(SP) ;PUSH NRECTS=4
; PEA MINRECT(A6) ;PUSH DST ADDR
; _RSECT ;CALC INTERSECTION
CMPRA DrawLineRsect,(sp) ;was RSect called from drawline?
beq.s fixROM ;yes, go patch the code after the call
CMPRA fromROMDrText,(sp) ;was RSect called from drText?
beq.s fixText ;yes, go patch the code after the call
JMPROM ROMRSect ;no, continue with RSect
fixROM lea myRet,a0 ;trash a0
move.l a0,(sp) ;force return to us
JMPROM ROMRSect
fixText lea myTextFix,a0 ;trash a0
move.l a0,(sp) ;force return to us
JMPROM ROMRSect
myRet bne.s continue ;continue with patch if intersect not empty
JMPROM ROMGoHome ;QUIT IF NO INTERSECT
continue
;-----------------------------------------------------------
;
; HIDE CURSOR IF CURSOR INTERSECTS MINRECT AND DST IS SCREEN.
; (A5 must contain global ptr)
;
MOVE.L SAVEA5(A6),A5 ;GET GLOBAL PTR
MOVE.L THEGDEVICE,A0 ;GET CURRENT DEVICE
MOVE.L (A0),A0 ;POINT AT IT
MOVE.L GDPMAP(A0),A0 ;GET ITS PIXMAP
MOVE.L (A0),A0 ;POINT AT IT
MOVE.L BASEADDR(A0),D0 ;GET BASE OF SCREEN
CMP.L DSTPIX+BASEADDR(A6),D0 ;DRAWING TO SCREEN?
SEQ CRSRFLAG(A6) ;IF SO, SET FLAG
BNE.S NOTSCRN ;=>NO
PEA MINRECT(A6) ;PUSH SHIELDRECT PARAMETER
MOVE.L REALBOUNDS(A6),-(SP) ;PUSH DELTA FOR GLOBAL
_SHIELDCURSOR ;HIDE CURSOR IF IT INTERSECTS
NOTSCRN MOVE.L PORT(A6),A5 ;GET BACK THEPORT
;-----------------------------------------------------------
;
; CHECK FOR BOTH VISRGN AND CLIPRGN RECTANGULAR
;
CLR.B FASTFLAG(A6) ;FASTFLAG := FALSE
CMP #10,RGNSIZE(A2) ;IS CLIPRGN RECTANGULAR ?
BNE.S FLAGOK ;NO, CONTINUE
CMP #10,RGNSIZE(A3) ;IS VISRGN RECTANGULAR ?
BEQ.S CKPAT ;YES, CONTINUE
;-----------------------------------------------------------
;
; If only visRgn is non-rectangular, then check if
; its intersection with minrect would be rectangular.
; IF TrimRect(visRgn,minRect) then treat as rectangular.
;
MOVE.L visRgn(A5),-(SP) ;push rgnHandle
PEA minRect(A6) ;push addr of minRect
_TrimRect ;call trimRect
Bge.s @1
JMPROM ROMDone ;quit if intersection empty
@1 BGT.S FLAGOK ;continue if non-rectangular
;-----------------------------------------------------------
;
; CHECK FOR BLACK OR WHITE PATTERN
;
CKPAT BTST #5,LocMode+1(A6) ;AN ARITHMETIC MODE?
BNE.S FLAGOK ;SKIP FAST CASE IF SO
MOVE.L LOCPAT(A6),A0 ;POINT TO PATTERN/PIXPAT HANDLE
;patched code begins here:
tst.b NewPatt(A6) ;is it a new pattern?
Beq.s @oldPat ;=>yes, skip pixpat fields
move.l (a0),a0 ;get the pixpat handle
move.l (a0),a0 ;get the pixpat pointer
TST PATTYPE(A0) ;is it an old-style pattern?
BNE.S FLAGOK ;=>no, skip fast case
move.l patData(a0),a0 ;get handle to pattern data
move.l (a0),a0 ;get pattern ptr
@oldPat JMPROM ROMoldPat ;return to ROM code w/ pattern ptr in a0
;MOVE.L (A0)+,D0 ;GET 1ST HALF OF PATTERN
;CMP.L (A0)+,D0 ;IS IT SAME AS 2ND HALF ?
;BNE.S FLAGOK ;NO, CONTINUE
;NOT.L D0 ;IS PATTERN BLACK ?
;BEQ.S YESFLAG ;YES, WE MADE IT
;NOT.L D0 ;IS PATTERN WHITE ?
;BNE.S FLAGOK ;NO, CONTINUE
;EOR #4,LOCMODE(A6) ;YES, ALTER MODE AS IF BLACK
;YESFLAG ST FASTFLAG(A6) ;RECT CLIPPED AND BLACK
FlagOK JMPROM ROMFlagOK
ENDPROC
;----------------------------------------------------------------------------------------
; PB231 28Jul87 rwh/rdc DisPtchTsk DisPtchTsk
; Patch for dispatching of deferred tasks
; PB573 22Sep88 jwk DisPtchTsk
; Cleaned up using ggd's technique.
; <8.3> 28Nov89 GGD Replaced with the code that shipped in the IIci ROM.
; Fixes problem in earlier version which could cause deferred
; tasks to be delayed until the next interrupt occurs if a new
; task was queued while the last task was running. (It needs to
; check to see if the queue is empty AFTER running the task, with
; interrupts masked during the check)
; <14> 02Feb90 GGD Re-Enabled interrupts upon exiting this routine to fix QuickMail <14>
; servers (for now at least), because they call through jDisptch at <14>
; application level and wind up with all interrupts being masked, <14>
; and this code expects to only be called from then end of an interrupt <14>
; handler, which will restore the interrupt level via an RTE. <14>
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 28Jul87 PB231 (DisPtchTsk) (DisPtchTsk)
;
; Patch for dispatching of deferred tasks
; The fix is to first dequeue the request and then execute it rather than vice versa.
; This should fix a bug related to requeueing of the same task found by the AppleShare crew
; Note that regs D0-D3, A0-A3 are previously saved by the interrupt handlers
; NOT IN A/UX
NewDisPtch PROC EXPORT
ROMDequeue EQU $4080602A
vDisptch BTST.B #INVBL,QFLAGS+VBLQUEUE ; doing VBL tasks? **begin** <8.3>
BNE.S @Exit ; if so, keep deferring
BSET.B #InDTQ,DTQFlags ; already in dispatcher?
BEQ.S @DspStart ; check the queue if not
@Exit RTS ; otherwise exit
@DspLoop MOVEA.L D0,A0 ; else setup ptr for use
LEA DTQueue,A1 ; get ptr to queue
JSR ROMDeQueue ; dequeue task to be executed
MOVEA.L DTAddr(A0),A2 ; get ptr to first task
MOVEA.L DTParm(A0),A1 ; get optional parameter
ANDI.W #$F8FF,SR ; enable all ints
JSR (A2) ; and go do task
@DspStart ORI.W #HiIntMask,SR ; disable all ints
MOVE.L DTskQHdr,D0 ; get queue head
BNE.S @DspLoop ; loop if tasks exist
BCLR.B #InDTQ,DTQFlags ; clear indicator
ANDI.W #$F8FF,SR ; enable all ints (to fix QuickMail) <14>
RTS ; and exit **end** <8.3>
ENDPROC
;----------------------------------------------------------------------------------------
; PB232 04aug87 bbm WriteXPRam WriteXPRam ; OS trap $52
; Patch to check validity of parameters to WriteXPRam
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 04aug87 PB232 (WriteXPRam) (WriteXPRam)
;
; Patch to check validity of parameters to WriteXPRam
; NOT IN A/UX
NewWriteXPRam PROC EXPORT
ROMWriteXPRam EQU $4080DD82
move.l d1,-(sp) ; save working regs.
move.l d0,d1 ; get copy of input parameters
swap d1 ;
add.w d0,d1 ; check if addressing past end of chip.
bcs.s @errexit ; Écould be carry if there is a lot of garbage in high bytes.
cmp.w #$0100,D1 ; Éaddressing past end means >= #$100.
bcc.s @errexit ; Édo unsigned compare.
move.l (sp)+,d1 ; restore regs.
jmp ROMWriteXPRam ; go to real trap
@errexit
move.l (sp)+,d1 ; restore regs.
moveq #-1,d0 ; signal error
rts ; and return
ENDPROC
;----------------------------------------------------------------------------------------
; PB238 19aug87 DAF Patch Open to check driver version numbers when opening slot devices
; PB268 10Sep87 DAF Detached DRVR resource opened in PB238§
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 19aug87 PB238 (Open) (Open)
;AppleSystemPatch PatchIIROM.a 10Sep87 PB268 (Open) (Open)
;
; This patch corrects Open so that the latest version of a driver is open whether it is
; in the slot card, or in the system file. It is in support of video driver overrides
; but acts correctly for all slot devices. It could be much smaller, but the Juggler
; team doesn't patch Open at the low-level, so doing it this way saves having two versions.
; I neglected to detach the DRVR resource I loaded, and switch launching was killing the system.
; This patch corrects that problem.
;
; NOT IN A/UX <PB302>
;______________________________________________________________________
MyOpen PROC EXPORT
ROMDetRefNum EQU $40806902
NonSlotDrvr EQU $4080696E
IsSlotDrvr EQU $408067C2
SetUpspBlk EQU $408067EE
OldDrvr EQU $40806966
DrvrBad EQU $40806956
ToFSOpen EQU $40806830
MOVEM.L D3-D5/A2-A4,-(SP) ; observe pascal regsave conventions <C133/29Aug86>
MOVE.L A0,D5 ; save parameter block pointer
MOVE.W D1,IOTrap(A0) ; and D1
MOVE.W IOFileType(A0), D2 ; save for desk acc check
MOVE.L IOFileName(A0), A0 ; point A0 to input filename for search of installed drivers
MOVEQ #0,D1 ; clear high bytes
MOVE.B (A0)+,D1 ; IOFileName length
CMP.B #$40,D2 ; is it from OpenDeskAcc?? <01Nov85>
BNE.S @100
JMP NonSlotDrvr
@100
CMP.B #'.',(A0) ; does name start with a period?
BEQ.S @150 ; <PB238/DAF>
JMP ToFSOpen ; <PB238/DAF>
;+++ BNE.S ToFSOpen ; must be for the file system if not a
; deskmgr call or driver name is not prefixed with period
@150
JSR IsSlotDrvr ; is this a slot device? <C600>
BEQ.S @200
JMP NonSlotDrvr ; branch if not. <C600>
@200
; ---------+++++++++++ Begin Slot Driver +++++++++++--------- <C133/29Aug86>
WITH spBlock, seBlock
; Initialize the SDM parameter block
SlotDrvr SUB.L #spBlockSize,SP ; Allocate parameter block for slot manager
MOVE.L SP,A4 ; Save pointer to spBlock.
JSR SetUpspBlk ; Set up some of the SDM parameters. <C600>
; First search for the driver among those already installed . . .
MOVE.W UnitNtryCnt, D2 ; number of units to check
SUB.W #BgnSlotUnit,D2 ; adjust for # of slot unit entries.
MOVEQ #BgnSlotRef,D4 ; init refnum index
MOVE.L UTableBase, A3 ; get address of the unit I/O table
MOVEQ #BgnSlotUnit,D0 ; adjust to beginning of slot unit entries.
LSL.L #2,D0
ADD.L D0,A3 ; A3 <- ptr to unit table, beginning at slot DCE's.
; REPEAT
@Repeat MOVE.L (A3)+,D0 ; get next Device Control Entry handle
BEQ.S @Until ; branch if no entry installed
MOVE.L D0,A2 ; prepare to de-reference it.
MOVE.L (A2),D0 ; de-reference it.
BNE.S @10 ; branch if ok <C750>
CLR.L -(A3) ; Clear the bad UT entry. <C750>
BRA.S @Repeat ; Continue at top of loop <C750>
@10 MOVE.L D0,A1 ; A1 <- ptr to DCE <C750>
MOVE.B dCtlSlot(A1),D0 ; do the slot numbers match?
CMP.B spSlot(A4),D0
BNE.S @Until ; if not then continue search.
MOVE.B dCtlSlotId(A1),D0 ; do the sResource Id's match?
CMP.B spId(A4),D0
BNE.S @Until ; if not then continue search. <C523>
MOVE.B dCtlExtDev(A1),D0 ; do the Device Id's match? <C523>
CMP.B spExtDev(A4),D0 ; <C523><C537>
BEQ.S DCEFound ; if yes then DCE is found. <C523>
@Until SUBQ #1,D4 ; bump refnum index
SUBQ.W #1,D2 ; next unit table entry
BGT.S @Repeat ; continue searching.
; UNTIL (proper DCE is found) OR (unit table entries are exhausted)
BRA.S LookInRsrc ; not installed, begin looking for driver in resources.
; DCE was among the installed slot drivers, but is the driver still installed?
DCEFound MOVE.L dctlDriver(A1),D0 ; D0 <- handle to the driver
BEQ.S BadDCE ; if driver handle is nil then there is no driver.
MOVE.L D0,A1
MOVE.L (A1),D0 ; D0 <- ptr to the driver
BEQ.S @300 ;
JMP OldDrvr ; if driver ptr is not nil then driver is already here, goto DrvrLock.
@300
BadDCE MOVE.L A2,A0 ; if no driver, then purge the DCE, and reload and install the driver.
_DisposPtr ; dispose of DCE
MOVE.L #0,-(A3) ; clear unit table entry
; It wasn't among the installed slot drivers, so check resources . . .
LookInRsrc SUBQ #4,SP ; make room for result
MOVE.L #'DRVR',-(SP) ; push resource class DRVR
MOVE.L spIOFileName(A4),-(SP) ; push name pointer
MOVE.W #MapTrue,ROMMapInsert ; in case it's in sys ROM <C632/14Jan87> DAF
_GetNamedResource ; search resource files first (blows A0, D1??)
MOVE.L (SP)+,D3 ; did it find one? D3 <- handle to driver.
; get the slot driver too... ; <PB238/DAF>
LookInSlot
MOVE.L A4,A0 ; set A0 for use by the slot manager.
_sGetDriver ; get the slot driver
BEQ.S @1 ; continue if no error
TST.L D3 ; was there a resource drvr? <PB238/DAF>
BNE.S DetRefNum ;
JMP DrvrBad
@1 MOVE.L spResult(A0),A3 ; get the handle to the driver <PB238/DAF>
MOVE.L (A3),A1 ; get the pointer to the driver <PB238/DAF>
CLR.L D0 ; for upcoming add <PB238/DAF>
MOVE.B drvrName(A1),D0 ; get the driver name length <PB238/DAF>
ADDQ #2,D0 ; Adjust offset to version field <PB238/DAF>
BCLR #0,D0 ; Adjust to word alignment <PB238/DAF>
MOVE.W drvrName(A1,D0.W),D0 ; Get the sDriver version number <PB238/DAF>
;
; compare DRVR resource version with sDrvr version, being careful to test if the
; drivers were really present. Iff the DRVR version is greater, use it, else
; use the slot drvr, or finally, no driver available, return error
;
TST.L D3 ; is there a resource driver? <PB238/DAF>
BEQ.S @UseSlot ; if no system driver, use sDrvr <PB238/DAF>
MOVE.L D3,A0 ; get handle in an A-reg <PB238/DAF>
MOVE.L (A0),A0 ; get pointer <PB238/DAF>
CLR.L D2 ; for upcoming add <PB238/DAF>
MOVE.B drvrName(A0),D2 ; get the driver name length <PB238/DAF>
ADDQ #2,D2 ; Adjust offset to version field. <PB238/DAF>
BCLR #0,D2 ; Adjust alignment. <PB238/DAF>
CMP.W drvrName(A0,D2.W),D0 ; Compare versions with sDrvr <PB238/DAF>
BGE.S @UseSlot ; if sDrvr ³ drvr, then use sDrvr <PB238/DAF>
MOVE.L A3,A0 ; get rid of slot driver <PB238/DAF>
_DisposHandle ;
MOVE.L D3,-(SP) ; we need to detach the resource! <PB268/DAF>
_DetachResource ; <PB268/DAF>
BRA.S DetRefNum
@UseSlot
MOVE.L D3,-(SP) ; push the resource handle <PB238/DAF>
_ReleaseResource ; we're using the sDrvr, so dump the system drvr <PB238/DAF>
MOVE.L A3,D3 ; slotDrvr handl in A3 <PB238/DAF>
DetRefNum
JMP ROMDetRefNum ; and back to the ROM
ENDPROC
;____________________________________________________________________________________
; PP235 FClosePatch patch:
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 19Aug87 PP235 (FClose) (FClose)
;
; This patch fixes a problem in FClose which results in the catalog and extents file
; BTCB's not being released for an Eject call. The branch following a test for a system
; CNID was reversed.
;
; Patched using the "FClose" vector.
;
; The corresponding source code change for this patch was made to TFSRFN2.a in
; the "FClose" routine.
;
; NOT IN A/UX <PB302>
;____________________________________________________________________________________
RomMFSClose EQU $4080A860 ; MFS Close code
FClose3 EQU $4080A71E ; @3 in ROM FClose
FCloseCont EQU $4080A708 ; MOVE after inverted branch instruction "BLS.S @3"
FClosePatch proc
MOVE.L (SP)+,-(A6) ; save caller's addr <01Oct85>
MOVEM.L A0-A5/D1-D3,-(A6) ; Store scratch registers <28Oct85>
CMPI.W #Tsigword,VCBSigWord(A2) ; is sigword that of TFS? <01Oct85>
BNE.S @2 ; no, must be MFS
TST.L FCBBTCBPtr(A1,D1) ; BTCB associated with this open file?
BEQ.S @3 ; No - just an ordinary file
CMPI.L #NxFreeFN,FCBFlNm(A1,D1) ; a system file? <21May86>
BCC.S @3 ; no, some other BTree file <12Aug87>
JMP FCloseCont
@2 JMP RomMFSClose
@3 JMP FClose3
endproc ; *** End of FClose patch ***
;____________________________________________________________________________________
; PB236 NMI Handler patch
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 24Aug87 PB236 (GenExcps) (GenExcps)
;AppleSystemPatch PatchIIROM.a 26Aug87 PB251 (GenExcps) (GenExcps)
;
; This code patches the NMI handler routine so that it passes correct error code to SysError
; routine. This is needed by the new MacsBug debugger to be released with MPW 2.1.
;
; NOT IN A/UX <PB302>
;____________________________________________________________________________________
NewNMIExcp PROC EXPORT
ROMExcp EQU $40802112 ; ROM entry point for interrupt exceptions w/
; debugger installed
ROMExcp2 EQU $4080211E ; ROM entry point for interrupt exceptions w/o <PB251>
; debugger installed
BSET #7,NMIFlag ; use high bit of NMI flag as indicator
BEQ.S @1 ; process first interrupt
RTE ; else just ignore
@1 TST.L MacJmp ; any debugger installed? <PB251>
BEQ.S @2 ; no, take exit for MicroBug <PB251> <PB251>
JMP ROMExcp ; go process it, sets D0=13 for MacsBug
@2 JMP ROMExcp2 ; go process it, sets D0=$13 for MicroBug <PB251>
ENDPROC
;____________________________________________________________________________________
; PMAB241 BadTrap Handler patch
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 24Aug87 PMAB241 (BadTrap) (BadTrap)
;
; This patch is to salvage D0 reg for MacsBug on Debugger traps which use the ROM BadTrap routine.
; Fix is to save regs prior to using D0 reg for error code.
;
; NOT IN A/UX <PB302>
;____________________________________________________________________________________
NewBadTrap PROC EXPORT
ROMSysErr3 EQU $40802126 ; ROM entry point in SysErr after save of regs
MOVEM.L D0-D7/A0-A7,SEVars ; save all regs for debugger
MOVEQ #12,D0 ; signal bad trap error
JMP ROMSyserr3 ; and go to ROM, don't resave regs
ENDPROC
;____________________________________________________________________________________
; PB534 SETCCURSOR Patch
; by Bruce & Dave
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 13Sep87 PB270 (SetCCursor) (SetCCursor)
;
; Patch SetCCursor to first lock the ccursor handle, SetState on return.
;____________________________________________________________________________________
MySETCCURSOR PROC EXPORT
ROMSetCCursor equ $1d734 ;SetCCursor entry point in ROM
move.l 4(sp),a0 ;get ccursor handle
_HGetState ;handle already in A0
Move.B D0, -(SP) ;save state on the stack
_HLock ;and lock it down for the call
Move.L a0, -(SP) ;copy crsr handle
JSRROM ROMSetCCursor ;jump into the rom
Move.L 6(SP), A0 ;get crsr handle
Move.B (SP)+, D0 ;restore pic handle state
_HSetState
rtd #4 ;return to sender
;____________________________________________________________________________________
; PB279 Picture Recording patches
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 18Sep87 PB279 (StdRgn,StdPoly) (StdRgn,StdPoly)
;
; In MacII PICT2's, opcode is word rather than byte sized. Previously existing code in
; these std routines took advantage of the old byte-sizing for opcode generation. As
; a result, it is possible to generate bogus word opcodes based on whatever happened
; to be in the registers at the time of execution. This patch clears the hi byte of
; these register halves so the opcodes will be OK. The StdPoly patch is patched elsewhere
; with another StdPoly patch.
;____________________________________________________________________________________
StdRgn PROC EXPORT
ROMStdRgn EQU $236B4 ; entry into StdRgn in ROM <PB302>
LINK A6,#0 ;NO LOCALS
MOVEM.L D6-D7/A2-A4,-(SP) ;SAVE REGS
MOVEQ #0,D7 ; clear the loword of the register <PB279/DAF>
JMPROM ROMStdRgn ; <PB302>
;____________________________________________________________________________________
; PB292 PatHandle Verification Patches
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 30Sep87 PB292 (DisposPixPat,DisposCCursor) (DisposPixPat,DisposCCursor)
;
; When you throw away a pixpat or cursor, verify that the object was not thrown away
; or purged.
;
; When you close a cGrafPort, verify that all pixPat handles are not NIL before
; disposing. This is particularily critical for FillPixPat, since it is a handle
; provided to FillCSomething, and may have been independently disposed.
;
;____________________________________________________________________________________
FixDisposPixPat PROC EXPORT
FixDisposCCursor PROC EXPORT
ROMDispPPat EQU $1EEB2 ; re-enter the ROM code here <PB302>
MOVE.L 4(SP),D0 ; get the pixPat handle
BEQ.S goBack ; if NIL, then do nothing
MOVE.L D0,A1 ; move to A-reg
MOVE.L (A1),D0 ; if purged, then do nothing
BEQ.S goBack ;
MOVE.L D0,A1 ; move to A-reg
JMPROM ROMDispPPat ; and continue in the ROM
GoBack RTD #4 ; clean stack and return
FixCloseCPort PROC EXPORT
FixClosePort PROC EXPORT
DelPortList EQU $1E8AA ; <PB302>
ROMNxtPat EQU $1EA34 ; <PB302>
MOVE.L 4(SP),-(SP) ;PUSH GRAFPTR
JSRROM DelPortList ;DELETE PORT FROM PORTLIST <PB302>
MOVE.L 4(SP),A0 ;GET PORT
MOVE.L CLIPRGN(A0),A0 ;GET CLIPRGN HANDLE
_DisposHandle ;DISCARD IT
MOVE.L 4(SP),A0 ;GET PORT
MOVE.L VISRGN(A0),A0 ;GET VISRGN HANDLE
_DisposHandle ;DISCARD IT
MOVE.L 4(SP),A0 ;GET PORT
TST PortBits+RowBytes(A0) ;IS IT A NEW PORT?
BPL.S DONE ;=>NO, STRIP PARAMS AND RETURN
;-------------------------------------------
;
; DISPOSE OF OLD COLOR PATTERNS, BUT NOT NEW
;
MOVEQ #-1,D0 ; init loop counter <PB292/30Sep87> DAF
MOVE.L bkPixPat(A0),D1 ; get handle <PB292/30Sep87> DAF
BSR.S SetPPat ; if NIL, get rid of it, else push <PB292/30Sep87> DAF
MOVE.L pnPixPat(A0),D1 ; get handle <PB292/30Sep87> DAF
BSR.S SetPPat ; if NIL, get rid of it, else push <PB292/30Sep87> DAF
MOVE.L fillPixPat(A0),D1 ; get handle <PB292/30Sep87> DAF
BSR.S SetPPat ; if NIL, get rid of it, else push <PB292/30Sep87> DAF
JMPROM ROMNxtPat ; and back to ROM <PB292/30Sep87> DAF <PB302>
SetPPat MOVE.L (SP)+,A1 ; get return address <PB292/30Sep87> DAF
BEQ.S NILPPat ; if NIL, don't dispose it <PB292/30Sep87> DAF
MOVE.L D1,-(SP) ; push it <PB292/30Sep87> DAF
ADDQ #1,D0 ; and increment counter <PB292/30Sep87> DAF
NILPPat JMP (A1) ; return <PB292/30Sep87> DAF
Done RTD #4 ;
ENDPROC
;____________________________________________________________________________________
; PMAB301 ATP delayed duplicate response bug patch
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 16Nov87 PMAB301 SendRequest SendRequest
;
; If a delayed duplicate response came in to ATP it could overwrite a valid response
; before it was thrown out due to a bad TID. Patch SendRequest to install a new socket
; listener which checks the TID first. Patch installed in the ATP control hook.
;
; NOT IN A/UX <PB302>
;____________________________________________________________________________________
ATPPatch PROC EXPORT
ROMJATPEx2 EQU $4082B8B8
ROMSndRqInit EQU $4082B994
ToROMSendReq EQU $4082B8D8
ROMATPIgnore EQU $4082BE58
ROMReadResp EQU $4082BE6C
TCBE EQU 12 ; Number of TCB's
TSktNum EQU 4 ; Offset to socket no.
TQElPtr EQU TSktNum+TCBE ; Offset to qEl ptr
CMP #SendRequest,CSCode(A0) ; Is it SendRequest?
BNE.S AnRTS ; Just return if not
MOVE.L MaskBC,D3 ; D3 = mask value
MOVE.L ROMBase,D2 ; D2 = ROM base
AND.L D3,D2 ; D2 = masked ROM base
AND.L (SP),D3 ; D3 = masked calling address
CMP.L D2,D3 ; Make sure called from ROM
BLO.S AnRTS ; Just return if not
ADDQ #4,SP ; Pop return address
MOVE.L AbusVars,A2 ; A2 -> MPP variables
MOVE.L ATPVars(A2),A2 ; A2 -> ATP variables
MOVE.L AddrBlock(A0),D3 ; D3 = address block from queue element
AND.B #FlagMask,ATPFlags(A0) ; Make sure nothing but flag bits
MOVE #TooManyReqs,D0 ; Assume too many concurrent requests
MOVEQ #TCBE-1,D2 ; D2 = offset into TCB table
@10 TST.B TSktNum(A2,D2) ; Is this entry free?
DBEQ D2,@10 ; Keep going until got one
BNE.S @20 ; Return error if none
JSR ROMSndRqInit ; Do initial setup. A3 -> data area.
BNE.S @20 ; Just return if error
CLR.B D1 ; Indicate we want a dynamic socket
LEA newATPRead,A1 ; A1 -> new socket listener
JMP ToROMSendReq ; Jump into ROM
@20 JMP ROMJATPEx2
AnRTS RTS ; Just return if not SendRequest
;
; This is the real patch. We make sure the TID matches before reading in
; the response
;
newATPRead MOVEQ #ATPHdSz,D3 ; D3 = size to read
CMP.B #ATP,-(A3) ; Make sure DDP type was ATP (46)
BNE.S @20 ; Ignore it if not, (RHA ptr now even)
JSR (A4) ; Read header into RHA
BNE.S AnRTS ; Just return if error
MOVE.L ATPVars(A2),A5 ; A5 -> our local variables
MOVE.B DDPDstSkt-DDPType-ATPHdSz(A3),D0 ; D0 = dest. socket no.
MOVE.B ATPControl-ATPHdSz(A3),D2 ; D2 = control byte
BPL.S @20 ; Ignore if not a response (2)
ADD.B D2,D2 ; Shift it left one bit
BMI.S @20 ; Ignore if not a response (3)
;
; Incoming response - find the TCB for it and read it in
;
MOVEQ #TCBE-1,D2 ; D2 = number to search, less one
LEA TSktNum+TCBE(A5),A5 ; A5 -> past sockets
@10 CMP.B -(A5),D0 ; This it? (fast loop!)
DBEQ D2,@10 ; Try all we can
BNE.S @20 ; Ignore it if no match
SUB D2,A5 ; A5 -> start of TCB table
LSL #2,D2 ; D2 = offset to queue element pointer
ADD D2,A5 ; A5 -> queue element ptr, offset
MOVE.L TQElPtr-TSktNum(A5),A5 ; A5 -> queue element
;
; *** The actual fix ***
;
MOVE ATPTransID-ATPHdSz(A3),D0 ; D0 = TID from packet
CMP ReqTID(A5),D0 ; Is it the one we want?
BNE.S @20 ; If not just ignore it
JMP ROMReadResp ; Otherwise continue
@20 JMP ROMATPIgnore ; Ignore the packet
;____________________________________________________________________________________
; PB337 SetOSDef Patch
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 16dec87 PB337 SetOSDef SetOSDef
;
; The trap SetOSDef is used to tell the start code to boot off of a foreign OS. The Problem
; was SetOSDef just stuffed whatever A0 was pointing to into pram. There was no validity
; check. The trap number is A083, which happens to be the high word of a master pointer
; pointing at ROM resources. So if your program crashed and executed garbage, such as
; master pointers, whatever A0 was pointing to got written to pram. This meant your machine
; would no longer recognize your hard disk. The fix was to change the interface, since
; noone was using this trap nohow, nowhere, and add a password. The password was put into
; lowmemory to keep the same glue in the compiliers.
;
nSetOSDef PROC EXPORT
AppPhne EQU $09961010 ;
realSetOS EQU $40801578 ;
Peril EQU $0CDC ;
cmpi.l #AppPhne,Peril ; check if oneshot is on
bne.s @errexit ;
clr.l Peril ;
jmp realSetOS ; go to real trap
@errexit ;
clr.l Peril ;
moveq #-1,d0 ; signal error
rts ; and return
ENDPROC ; end nSetOSDef
;____________________________________________________________________________________
; PB366 maxblock Patch
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 25jan88 PB366 maxblock maxblock
;
; PB366 25jan88 bbm fixed a bug in maxblock.
;
nMaxBlock PROC EXPORT
realMxBlk EQU $E05E ;offset to routine Maxblock in rom (from rombase)
JsrRom realMxBlk ;go do maxblock and then do a postfix.
tst.l D0 ;check for an error.
ble.s @rtn ;if an error or zero just return.
subq.l #2,D0 ;else adjust maximum size by two.
@rtn rts ;
;____________________________________________________________________________________
; PMAB372 Async serial driver patch
;
; Fix File Date Patch# Fix Routine(s) Routine(s) Fixed
;AppleSystemPatch PatchIIROM.a 26jan88 PMAB372 (AOutOpen,RAIntHnd) (RAIntHnd)
;AppleSystemPatch PatchIIROM.a 09Feb88 PB386 (AOutOpen)
;AppleSystemPatch PatchIIROM.a 23Feb88 PMAB401 (Control) (Control)
; If hardware handshaking is enabled, and the receiver de-asserts DTR, but the sender ignores
; it and keeps sending, the receiver will go into an infinite loop in the receive interrupt
; routine. This was caused by a jump to the wrong label. The patch is installed in a patch
; vector for the async driver. Needed to include all async driver code which jumped to
; the receive interrupt handler.
; 24May90 <48> (Control) Ctl #9
; OK, so this is a mess. Let's sort thru the various tangles.
; First off, the N&C BAP stuff had to be rolled in for 7.0, so that the patch
; they had put in their SINI resources stopped stomping this one. This entailed --
; -- patching out the .BOut and .BIn driver headers such that all the B driver
; calls would get driver storage ptr from ExpandMem instead of PortBVars.
; See end of patch.
; -- patching TB and ExtB interrupt handlers to get driver storage ptr from
; ExpandMem instead of PortBVars.
; See end of patch.
; -- changing the already patched SCB and RB interrupt handlers
; to get driver storage ptr from ExpandMem instead of PortBVars.
; -- patching the routines (mostly interrupt handlers) that used the lowMem
; BInDCE to now just get the DCE ptr from the Unit Table. (Yeah, the offset
; is hardcoded-- sue me).
; -- patching the Open and Close calls for port B to incorporate the BAP stuff
; to call the LAP mgr to arbitrate for port B.
; Second, Control call 9 had to be patched to hold the buffer in memory for VM.
; This meant i had to patch .AOut and .BOut close as well to unhold the buffer.
;
;
;AppleSystemPatch PatchIIROM.a 17Dec90 <80> (all B driver entry points,InitSCC,all int handlers)
; We need to add provide nike printer support. This entails:
; -- patch control call 16 to use bit 6 for setting external/internal clocking modes.
; -- Patch to add status call to return version.
; -- Patch InitSCC routine to use this RAM-based table so
; that clocking mode is now variable instead of hard-wired to internal only.
; -- set clock divide to 1 instead of 16 for external clocking
; -- clear HWHS enable since we can't clock and handshake on same line
; -- Patch whole ExtIntHandler so we can (set bit 3 of AsyncErr if break rcvd) at end of rtn.
; Also, we change the BAP stuff such that it is also supported in 6.x, not just 7.0
; -- Always get the driver storage pointer for port B from extended mem
; -- Call Gestalt in Open and Close to determine version of AppleTalk to see which
; port arbitration scheme we should use, ours or the LAP mgr's.
;
;AppleSystemPatch PatchIIROM.a 16Jan91 <81> (all A driver entry points)
; We patch all the port A driver headers (port B driver headers already patched)
; so that we can put a signature word before each header that we can use
; to identify ourselves as the Apple async serial driver. We do this
; right now so that that our linked patch on Open (in Serialpatches.a) will
; not stomp the version number of some third party driver that sticks them-
; selves into our spot in the unit table. I think this idea will come in
; handy later as well.
; I think i'll use the signature word 'wong'.
;
; Also, fix the port arbitration code in Open and Close to make call to the
; new 'atkv' Gestalt call instead of the old 'atlk' call. We do this because
; the new call return atalk version number regardless of whether MPP driver
; is open (i.e. appletalk is active).
;
; <84> Fixed bug in external clock stuff that was causing us to disable
; internal clocking on both ports if we were trying to do external
; clocking on just one. So Nike would print but Tabasco would just
; sit there. The fix was to set clocking params at each time we go
; thru InitSCC, rather than just once during the external clocking
; control call. This way even tho the ports share the InitSCCTable,
; we set the Table properly by keying off of the value in CtlOptions
; variable, which they don't share.
; <86> Status calls 9 and $8000 now return static version number for driver
; instead of what's in the DCE.
asyncPatch PROC EXPORT
; Equates
SerialVers equ 5 ; current version 3/91 <86>
SCCARWOFF equ 2 ; SCC A side R/W offset <A357/06nov86>
SCCBRWOFF equ 0 ; SCC B side R/W offset <A357/06nov86>
PortAVars EQU SerialVars ; serial chan A variables and buffer
AInDCE EQU PortAVars+4 ; Device Control Entry ptr for input
PortBVars EQU AInDCE+4 ; serial port B variables and buffer
BInDCE EQU PortBVars+4 ; Device Control Entry ptr for input
; next come variable offsets within the user's local variable buffer
OutDCE EQU 0 ;(4) long DCE pointer for output driver
SCCOffset EQU 4 ;(2) word of SCC offset . . .
InBufPtr EQU 6 ;(4) pointer to local input buffer
BufSize EQU 10 ;(2) size of local input buffer
BufLow EQU 12 ;(2) low buf byte count to send XOn
BufHigh EQU 14 ;(2) bytes from end of buffer to send XOff
SWHS EQU 16 ;(1) software handshake enable
HWHS EQU 17 ;(1) hardware handshake enable
XONChar EQU 18 ;(1) input char which continues output (SWHS)
XOFFChar EQU 19 ;(1) input char which stops output
Options EQU 20 ;(1) bit 4 = abort on parity error
; bit 5 = abort on overrun
; bit 6 = abort on framing error
PostOptions EQU 21 ;(1) bit 7=1 enables posting break changes
; bit 5=1 enables posting handshake changes
InSWHS EQU 22 ;(1) input XOn/XOff flow control enable
InHWHS EQU 23 ;(1) input RTS (DTR) flow ctl enb <14Oct85>
AsyncErr EQU 24 ;(1) error indications (cumulative)
SoftOR EQU 0 ; bit 0 = soft overrun
; bit 4 = parity error
; bit 5 = overrun error
; bit 6 = framing error
FlowOff EQU 25 ;(1) $80 = input flow shut off by XOff, $40 by DTR
ReadCmd EQU 26 ;(1) FF = read command pending
WriteCmd EQU 27 ;(1) FF = write command pending
CTSFlag EQU 28 ;(1) FF = CTS asserted
XOFFlag EQU 29 ;(1) FF = XOFF pending
LastWR5 EQU 30 ;(1) WR5 value with last DTR state <14Oct85>
DTRNegVal EQU 31 ;(1) WR5 value used to negate DTR <14Oct85>
SCCReset EQU 32 ;(1) WR9 value for reset
StopBits EQU 33 ;(1) stop bits/parity option (WR4 value)
WR1AVal EQU 34 ;(1) first WR1 value to write
WR3AVal EQU 35 ;(1) first WR3 value to write
WR5AVal EQU 36 ;(1) first WR5 value to write
BaudLoCnst EQU 37 ;(2) 2 byte baud rate constant (WR12-13)
BaudHiCnst EQU 38
RcvrBits EQU 39 ;(1) 1 byte receiver bits/char (WR3 value)
XmitBits EQU 40 ;(1) 1 byte xmitter bits/char (WR5 value)
WReqPin EQU 41 ;(1) w/req pin state (WR1 value)
lastSetup EQU 42 ;(2) last SCC init values . . .
BufIndex EQU 44 ;(2) index into local buffer (insert)
BufOutdex EQU 46 ;(2) index into local buffer (remove)
LocalBuf EQU 48 ;(64) local buffer for input chars
LclBufSize EQU 64 ; default input buffer size = 64 bytes
HSCount EQU 112 ;(2) count of CTS pulses in VBL time (clk detect) <14Oct85>
LastTime EQU 114 ;(4) ticks time of last CTS pulse (clk detect) <14Oct85>
SendXOnff EQU 118 ;(1) flag to xmit logic to send XOn/XOff <14Oct85>
CharMask EQU 119 ;(1) $1F,$3F,$7F, or $FF mask for input chars <14Oct85>
PEChar EQU 120 ;(1) char to change incoming parity errors to <14Oct85>
AltChar EQU 121 ;(1) char to change incoming PEChars to <14Oct85>
InSWHS1 EQU 122 ;(1) saved InSWHS state <14Oct85>
CtlOptions EQU 123 ;(1) bits 0-6=0 (reserved). bit 7=1 to leave <14Oct85>
; DTR state unchanged at close.
SaveExInt EQU 124 ;(4) saved Ext int vector <14Oct85>
SaveTxInt EQU 128 ;(4) saved TxD int vector <14Oct85>
SaveRxInt EQU 132 ;(4) saved RxD int vector <14Oct85>
SaveSxInt EQU 136 ;(4) saved Special Rx int vector <14Oct85>
LclVarSize EQU 140 ; output driver storage size <14Oct85>
;
; ROM ADDRESS OFFSETS
;
; where did we come from?
fromAOutOpen EQU $4082AC58 ; addr's to compare on stack - called from ROM rsrc <PB386>
fromAInOpen EQU $4082abf4
fromBOutOpen EQU $4082AC86 ;
fromBInOpen EQU $4082ABFC ; new arbitration for port B and new PortBVars
fromControl EQU $4082AF74 ; <PMAB401>
fromClose EQU $4082ae96 ;
fromStatus EQU $4082af22
fromInitSCC EQU $4082ae14
; open call patch equates
backToAinOpen EQU $2abf4 ; ROM offsets (use macros for operations)
backToAOutOpen EQU $2AC74
backToBInOpen EQU $2AC00
backToBOutOpen EQU $2ACA0 ; different return addr's for 6.X and 7.0
ROM_TAIntHnd EQU $2b1c8 ; interrupt handlers we're NOT patching
backToPollDtain EQU $2B2E8
ToContOut EQU $2B1EA
ToGoodFinish EQU $2B18A
ToGetBufRegs EQU $2B262
ToGetBufCnt EQU $2B272
ToCtlXOff EQU $2B390
ToPut EQU $2B38A
backToPut EQU $2B386
ToRdReqDone EQU $2B3F6
ToCtlSet EQU $2b0a6
toContOut1 EQU $2b1ee
; Control Patch equates
backToBypassControl EQU $2af86
ROM_CtlGood EQU $2afbc
ROM_CtlExit EQU $2afbe
; SerialBuf (ctl call 9) patch equates
FinishCall9 EQU $2b01a
; Control Call 16 patch equates
InitSCC EQU $2ae04
;
; Status patch equates
backToStatus EQU $2af3c
;InitSCC patch equates
backToInitSCC EQU $2ae14
initData EQU $2add0
; close patch equates
SyncOutput EQU $2aee8
InitSCC1 EQU $2ae0a
ResetData EQU $2ae5a
ResetLth EQU $10
freePort EQU $2aed6
; bypass driver ROM entrypoint addresses <81>
;port A
ROM_AInEntryOpen EQU $2abf2
ROM_AInEntryClose EQU $2aee4
ROM_AInEntryPrime EQU $2b1fa
ROM_AOutEntryOpen EQU $2ac56
ROM_AOutEntryClose EQU $2ae6a
ROM_AOutEntryPrime EQU $2b146
ROM_AEntryControl EQU $2af60
ROM_AEntryStatus EQU $2af0e
;port B
backToBInOpenStart EQU $2ABFA
backToBOutOpenStart EQU $2AC84
ToBOutClose EQU $2AE7E
backToBInPrime EQU $2B204
backToBOutPrime EQU $2B150
backToBControl EQU $2AF6A
backToBStatus EQU $2AF18
; for BAP only interrupt handler patches
backToTXIntHnd EQU $2B1CC
; for BAP only patches-- since these are not in Interfaces or Internals,
; where they should be
LUsePortB EQU 17 ; request use of printer port ;<2.0>
LFreePortB EQU 18 ; grant use of printer port