boot3/Patches/PatchIIciROM.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

9813 lines
376 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;
; File: PatchIIciROM.a
;
; Contains: patches for the ROMs first shipped in a Macintosh IIci ($067C)
;
; Copyright: © 1985-1991 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <146> 12/2/91 SAM Using official boxflag equates now.
; <145> 12/2/91 pvh Added cache flushing to fixup patch table code.
; <144> 10/28/91 SAM/KSM Rolled in Regatta Changes.
;
; Regatta Change History:
;
; <15> 8/30/91 SAM Added a check for Tim boxFlag to the code that changes boxFlag
; from boxTim to BoxTimLC. This prevents non-Tim/TimLC machines
; using the TERROR ROM with power mgrs and no-FPU being identified
; as a TimLC.
; <14> 8/30/91 SAM Added a check for an FPU in the previous backpatch patch so it
; will not install on machines without one.
; <13> 8/29/91 SAM Added a check for Zydeco to the "should we remove (ie override)
; the PACK 4 & 5 SANE rsrcs in ROM" check. (CCH) Added a patch to
; _FP68k for 030 TERROR machines that will not allow _FP68k calls
; made from ROM to be backpatched.
; <12> 8/15/91 SAM (RMP) Added v32SetHandleSize patch. SetHandleSize calls the same
; common routine that v32SetPtrSize calls, a32SetSize. SetPtrSize
; was patched earlier to fix a bug in a32SetSize <121> but
; SetHandleSize was never patched.
; <11> 8/9/91 SAM Moved the disposal of the Gestalt tables made by ROM to after
; the reinstallation of Gestalt from disk. This prevents crashes
; caused by someone calling gestalt after the old tables have been
; trashed prior to the new table's creation.
; <10> 8/8/91 SAM (eva) patch level 4 autovector pointed to by vbr, not just the
; zero-offset cuz when VM is running VBR ­ 0.This routine is a
; patch to the _VM trap. It fixes a bug in the Terror ROM which
; occurs when the page the stack is marked uncacheable in the MMU
; tables, then a subsequent PFLUSH'd is executed with data still
; in the cache.
; <9> 8/7/91 SAM Moved the boxFlag slam before Gestalt. Brainfade.
; <8> 8/6/91 SAM Added a check for TIM LC that will stuff the correct boxFlag
; into BoxFlag if we're running on a TIm LC. Gestalt's private
; storage allocated by the ROM version is disposed of prior to
; reinstalling gestalt from the disk.
; <7> 8/5/91 SAM (eva) fix patch <6>: Port B dispatcher fixed to call serial
; service routines and to have same number of bytes before the rts
; so that async serial driver Rx and SCx patches (which fiddle
; with return address on stack) return to the proper place.
; <6> 7/30/91 SAM (eva) fix the Farallon MacRecorder bug by modifing patch to test
; for port A RxChar and loop back only if we are servicing a channel
; A interrupt. For port B we just jump to service routine like ROM
; code.
; <5> 7/29/91 SAM (eva) patched SCx interrupt handler to fix the StyleWriter bug.
; On faster machines we are able to send out a byte fast enough
; after the TBE bit in RR0 gets set that the byte gets written
; before the TBE interrupt is generated. Instead of just not
; generating the interrupt, the SCC goes ahead and generates it,
; but changes the interrupt source code to read 'no interrupt'
; instead of 'TBE'. This 'no interrupt' code is identical to the
; 'Special Condition on port B' code, which was the source of our
; problem. Fix is to just exit SCIntHnd if no special condition
; bits are set.
; <4> 7/17/91 SAM (EH) Added Lvl4 irq patch to improve serial performance.
; <3> 6/30/91 SAM Conditionalizing the SCSI Chaining Bus Error handler for non
; C96.
; <2> 6/14/91 SAM Removed the GestaltHardware patch in favor of the real code in
; GestaltFunction.a. Fixed a check for an unallocated Palette Mgr
; handle in the InitPalettes Patch. (RMP) Added the IIfx IOP irq
; MPW fix to the set of Eclipse fixes. (bg) Changed the Egret
; "CheckPacket()" patch to allow the full
; range check of possible pseudo-commands.
; <1> 5/15/91 SAM Split off from 7.0 GM sources. Added code to use PACK 4 & 5 from
; disk on IIciROM machines that are not TERROR A7 or newer. Do
; not save GestaltÕs old Logical mem size across PtchInst 5
; (which is Gestalt) cuz the old number is wrong.
; 7.0 Change History:
;
; <143> 9/18/91 JSM Cleanup header, donÕt include InternalOnlyEqu.a (already in dump
; file).
; <142> 8/30/91 DTY Define isUniversal here since itÕs no longer defined in
; BBSStartup. This file used to use {Defs32}, so isUniversal is
; defined to be 1.
; <141> 6/12/91 LN added #include 'ROMPrivateEqu.a'
; <140> 6/12/91 LN removed #include 'HardwareEqu.a'
; <139> 4/12/91 dba ewa: add magic signature to Time Manager task used to implement
; VBLs; the signature will prevent VM from deferring the task
; <138> 4/8/91 eh Fixed bug in iop serial driver that was causing bad printing to
; Imagewriter. Actually, it was two bugs. CTS interrupt disable
; code had a bad branch and the IOP timer never got kickstarted.
; <137> 4/5/91 eh Fix to Serial driver SerSetbuf call. Missed one place in <135>
; that sign extended a register.
; <136> 3/28/91 SAM As per DarinÕs request, I have added a TestFor SCSI96_1Exists
; before the Quantum 7.9 ROM fix from the Regatta deltas (without
; forRegattaCPUs).
; <135> 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. Also
; fixed bug in IOP SerSetBuff (control 9) call -- was sign
; extending a register unintentionally.
; <134> 3/8/91 DFH VL,WS#DFH-910308a: Fixed SetEntries patch to not chew on a2.
; This led to crashes, such as in AfterDark.
; <133> 3/4/91 dba dty: get rid of SysVers checks
; <132> 2/26/91 DFH csd,WS#910226a: Fixed bug in ptchPMgrExit where it assumed that
; graphics has been initialized. Bug introduced by change <124>.
; <131> 2/25/91 gbm csd, #83338: Fix the fix to Gestalt. Save the original Gestalt
; globals pointer, and put some important (but hard to figure out)
; data back in it after the RAM copy installs
; <130> 2/21/91 gbm csd, #83338: Start including the Gestalt ptch even on ci ROMs.
; <129> 2/21/91 eh (djw) Fixed bug in serial driver that was preventing use of one
; port when Nike was printing on the other.
; <128> 2/19/91 gbm csd, #Go5 approved: Make sure _MemoryDispatch is NOT implemented
; on machines without PMMUs.
; <127> 1/29/91 eh (djw) Fixed a bug in the External Status interrupt handler. On
; port A we crashed on receiving a break if a read was pending
; because we weren't getting the .Ain DCE ptr properly. Now we get
; the DCE ptr directly from the Unit table, just like for port B.
; <126> 1/25/91 eh Fix iop serial driver to: time out an waiting for all-sent in
; the close, and to disable HWHS properly when external clocking
; is set.
; <125> 1/19/91 eh (djw) Patch async serial bypass driver headers to insert
; signature longword used by linked patch to Open in Serial
; Patches.a . Added signature longword before already patch IOP
; driver headers.
; <124> 1/18/91 dvb Don't restore color environment if it hasn't been changed.
; Modify SetEntries to mark flag in QDSpare.
; <123> 1/14/91 eh (djw) Added external clocking support for the NIke printer to
; the Async Serial Driver.
; <122> 12/19/90 djw (ewa) Patch ROM SCSIDispatch to the ROM SCSIDispatch to resolve
; a VM patch conflict.
; <121> 12/19/90 TL Fixed an old bug in setptrsize for old time sake, in calls
; between relocRel, the tag is restored in the old block, instead
; of the new block location. And also discard flag when two block
; sizes are identical.
; <120> 12/19/90 dvb Don't draw windowframes after InitGDevice. Removed some
; duplicate code between PatchIIciROM.a and PaletteMgr.a.
; <119> 12/15/90 djw (jwk) Add SCSI Mgr support for Quantum 7.9 ROM problem by
; replacing blind write routine
; <118> 12/14/90 dnf (jsm) Turn all patches on ExtFSHook off for 7.0 since they have
; been moved to LaterFileMgrPatches.a
; <117> 12/14/90 SMC Patched DisposeAppPalettes via PMgrExit to use ApplZone->bklim
; instead of HeapEnd to determine if palette is in the application
; heap. Also, patched PMgrExit to only throw away palettes if app
; is front process. With DFH.
; <116> 12/14/90 dba <JDR> get rid of VMCalls.a
; <115> 12/6/90 BBM (dba) Protect the Come-from patches. Eleminate TextFont patch to
; the MDEF, as the MDEF in ROM is not used anymore, RomOverride at
; its best.
; <114> 11/15/90 JSM <bbm> Move come-from patch on _OpenCPort inside NewGWorld to
; QuickDrawPatches.a.
; <113> 10/31/90 dba & csd; kill 8¥24 GC loading code for 7.0 (StartSystem.a does it
; now)
; <112> 10/22/90 JJ Rex V8: Change VISAChipBit to V8ChipBit.
; <111> 10/22/90 JJ Rex V8: Change all box flag references to use boxMacLC. Get rid
; of boxElsie and boxElsieV8.
; <110> 10/9/90 SAM Updated the AppleTalk _Open patch so that it stuffs PortNotCf
; into ioResult if SPConfig >= 2.
; <109> 9/26/90 SAM Redoing the patch to Open that fixes the .MPP crash.
; <108> 9/25/90 KIP Change Sound Mgr. to a linked patch.
; <107> 9/18/90 SAM Added changes from SixPack code review (search for <107>).
; Removed EclipseNOPs (as per BGs request). Fixed the last of the
; build warnings for this file (rah).
; <106> 9/15/90 DC added GetGray
; <105> 9/15/90 GMR Fixed Gestalt parity routine to set good parity before testing
; the byte with bad parity, so the RPU interrupt would not cause
; bad data to be stacked.
; <104> 9/5/90 EH Removed duplicate declarations for PollProc, Pollstack, and
; HiIntMask from EgretMgr patch <101>.
; <103> 8/31/90 SAM Adding fix to ReallocHandle patch that checks to see if SysZone
; = AppZone and if so it only checks the current heap then jumps
; back to ROM. Added a patch to open so that it clears out the low
; nibble of SPConfig when the .MPP driver is opened. Made
; GestaltHardwareAttr recognize Visa/V8.
; <102> 8/29/90 GMR Fixed Gestalt parity check on FX so it does not destroy A4 (this
; reg needs to be preserved throughout patches and inits!)
; <101> 8/22/90 SAM Adding a series of REgret patches & a SANE ptch (search for
; <101> for more explicit descriptions).
; <100> 8/20/90 dvb Remove "DrawGrayishText"
; <99> 8/19/90 SAM Adding changes to make sound (MACE) work on ci ROMs
; <98> 8/18/90 dba get rid of ptchInst 7 and 8 (Sony Format and Eject patches) as
; they are now linked patches
; <97> 8/17/90 gbm start loading soundmgr patch 23 on erickson and elsie, cause
; BigBang don't work otherwise
; <96> 8/14/90 DTY Removed TextEditPatchIIciROM since itÕs a linked patch now. (For
; real this time.) Also deleted an INIT 18 patch for Darin.
; <95> 8/13/90 JWK NEEDED FOR SIXPACK: Added NuBus and Serial Gestalt selectors.
; <94> 8/11/90 PKE NEEDED FOR SIXPACK: Fixed bug in previous revision - (per KIP)
; ptch 3 must load before ptch 23 so SoundMgr globals are
; initialized!! Was causing ci & fx to hang during boot.
; <93> 8/10/90 SAM Made ptch 3 (7.0 Sound Mgr) load on all IIciROM machines. It
; used to *not* load on Erickson/Elsie.
; <92> 8/8/90 SAM Changing DispatchHelper & ProcHelper into an old style ptch.
; ¥¥¥--> Temporary <--¥¥¥ Remove when the Sound ptch get converted
; into an Lptch.
; <91> 8/7/90 PKE Fixed the SixPack build by adding an eclipseDebug conditional
; around a BRA.S. Build was broken because BG changed BBSStartup
; to turn on eclipseDebug for Mac32 (which applies to this file),
; so EclipseNOPs are expanded and a branch went out of range.
; Also, altered the previous comment to say needed for SixPack.
; <90> 8/5/90 PKE NEEDED FOR SIXPACK: Moved installation of Script Mgr ptch 39 and
; 27 to Mac and A/UX section of install code (was formerly for Mac
; OS only). Search for <90> to see changes.
; <89> 7/30/90 SAM Added Egret TickHandler patch so it doesnt loose time while IRQs
; are off.
; <88> 7/30/90 dnf Remove installation of ptch 18 (File Manager) and ptch 6 (Btree
; Manager), now linked patches
; <87> 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
; <86> 7/21/90 BG Added EclipseNOPs for flakey 040s.
; <85> 7/20/90 CSL Needed for SIXPACK: Totally replaced Memory manager routine
; a32SetSize, patch <68> only replaced part of a32SetSize and is
; not sufficient.
; <84> 7/20/90 DTY Removed Bass patches since itÕs a linked patch now.
; <83> 7/20/90 gbm Get rid of some warnings
; <82> 7/19/90 CCH NEEDED FOR SIXPACK: Removed HwPriv patch since it is now a
; linked patch.
; <81> 7/19/90 EH Add VM support for async.a, SetSerBuf control call
; <80> 7/19/90 GMR Install ptch 7 to change eject track from 79 to 40.
; <79> 7/18/90 DDG NEEDED FOR SIXPACK: Fixed previous comment.
; <78> 7/18/90 DDG NEEDED FOR SIXPACK: clean up lomem $B50 after the netbooting socket
; listener.
; <77> 7/17/90 DVB Fix DrawGrayishText, and include PaletteMgr.a
; <76> 7/14/90 DVB Add in new PMgr dispatches
; <75> 7/11/90 gbm get rid of a few duplicate symbols
; <74> 7/11/90 DDG NEEDED FOR SIXPACK: Fixed a bug in our new ReadDateTime call. We
; now return an error code of zero, instead of garbage.
; <73> 7/2/90 DTY Remove ptchInst 21 since Resource Manager extensions are now in
; a linked patch.
; <72> 6/28/90 DDG NEEDED FOR SIXPACK: Put in a fix for egret. Now the
; _ReadDateTime call does not actually call the clock chip. It
; simply reads the low mem global (Time) and returns that. This is
; OK, since Time is automatically updated. This fix only happens
; on Elsie and Erickson.
; <71> 6/25/90 DTY Removed ptchInst 9.
; <70> 6/25/90 KON Remove rSwapMMUMode macro 'cause it's in QDHooks.
; <69> 6/19/90 VL Remove ptchinst 29 since MiscPatches is a linked patch now.
; <68> 6/14/90 CSL Needed for Six-Pack. Fixed _setptrsize problem in memory
; mananger for 32 bit mode only. It will not de-reference from
; address $0 now.
; <67> 6/12/90 JSM Remove PtchInst 33 since PPC Toolbox is a linked patch now.
; <66> 6/7/90 EMT Remove PtchInst 17 since Layer Manager is a linked patch now.
; <65> 6/7/90 VL Remove PtchInst 28 since HelpMgr is a linked patch now.
; <64> 5/31/90 DDG Adding a special system error for machines that donÕt have an
; FPU.
; <63> 5/31/90 DDG Added the extFS patch from the PatchIIROM.a file. This will fix
; a strange bug where the wrong error code is being returned from
; the MountVol call.
; <62> 5/29/90 DDG NEEDED FOR SIXPACK: Changed all the sixpack conditionals from
; six-point-oh-seven to six-point-oh-six.
; <61> 5/17/90 KON Clear high word of d3 and d4 so compare is done as a word in
; ResizePalette.
; <60> 5/10/90 JSM AliasMgr now a linked patch, don't install it here anymore.
; <59> 5/2/90 CCH Fixed bug in parity routine for pre-IIci machines with IIci
; ROMs.
; <58> 5/1/90 CCH Added Scrolling throttle and Square menus to misc selector.
; <57> 4/22/90 csd commented out the installation of SCSI DMA so we stop trashing
; hard disks on the IIfx.
; <56> 4/19/90 NB Add PrGlue to the PtchInst list (#16). It's already on all other
; machines
; <55> 4/18/90 DDG Rolling in the ReallocHandle patches from the sys6 sources.
; <54> 4/16/90 DDG Rolled over changes from the split off sources including: a
; patch to hwPriv, an IOP serial driver fix, SCSI DMA is now
; disabled on the IIfx due to bugs, added an init (18) to fix the
; comm toolbox, added the patch for tiburon video cards, added
; patch 25 (generic system fixes), and finally changed the equate
; for spline fonts to use the build variable hasSplineFonts.
; <53> 4/11/90 dba move PPC after B-Tree Manager; get rid of old AppleShare patch
; for 7.0
; <52> 3/30/90 DVB Add "WhatPal" PmgrDispatch
; <51> 3/27/90 PKE Deleted import (currently conditionalized out) of NewSwapIcon,
; which no longer exists in this PTCH.
; <50> 3/26/90 PKE Moved definition of symbols that control Script Mgr patch and
; 'ptch' installation into ScriptPriv.a. Renamed symbols and added
; some.
; <49> 3/23/90 NC Added ptch 43 for System 6.0.6 on up. This is for Sound.
; <48> 3/20/90 DDG Added code to not install patch 3 on Ericksons and above for
; Sys607 and above.
; <47> 3/12/90 DVB Fix PMgrExit so that ExitToShell doesn't crash!
; <46> 3/8/90 JAL Took out include of QuickEqu.a because it is already in
; StandardEqu.d.
; <45> 3/4/90 PKE Changed _UprText to _UpperText to match new Traps.a.
; <44> 3/1/90 GMR Fixed bug in Gestalt parity check for Zone-5, where longword was
; not being written back with good parity after each SIMM check.
; <43> 2/28/90 GMR Added include of EgretEqu.a to fix system disk build.
; <42> 2/28/90 PKE For 7.0, moved Script Mgr ROM patches into ÔptchÕ 39: patches to
; _Pack6 and _GetIndADB, fixes to String2Date/InitDateCache,
; installation of some new vectors, and the change to SwapIcon.
; For all of these except the SwapIcon change, the code is still
; here but conditionalized differently (in case we need it for
; 6.1).
; <41> 2/26/90 EH Rewrote <8.7> to use patch macros. Added on patch for 68000 IOP
; Serial Driver read bug.
; <40> 2/23/90 DVB PMgrExit no longer clears the windowlist.
; <39> 2/22/90 PKE Replaced obsolete _LwrStringToUpr opword with _UprText. Removed
; setting of temporary sVectFixSpExtra vector (see <12>); we no
; longer need it.
; <38> 2/21/90 JS NEEDED FOR 6.0.5: SetDepth also takes a mode
; <37> 2/16/90 EH Fixed CTS status bug and low baud rate bug in IOP Serial Driver.
; Fixed <27> to use the patch macros properly.
; <36> 2/15/90 EMT Moved <1.9> before <1.2> - both patch SetWinColor, SetCtlColor.
; <35> 2/15/90 DVB Change SetDepth's return to OSErr
; <34> 2/14/90 DVB Fix SetDepth's register trashage
; <33> 2/14/90 EH NEEDED FOR 6.0.5: 'Come from' patched IOPMoveData trap to fix
; IOP Serial Driver DMA hang bug.
; <32> 2/14/90 CCH NEEDED FOR 6.0.5 - Made sure external cache on Zone 5 does not
; interfere with the check to see if parity RAM is installed.
; <31> 2/13/90 SMB NEEDED for 6.0.5 - Added installation code for ptchGetLRPosition
; and ptchPixelWidths for TextEdit.
; <30> 2/9/90 EH NEEDED FOR 6.0.5: Patched Level4SccIopInt to set flags such that
; all the IOP completion routines be called immediately from the
; IOP Manager, rather than be run as deferred tasks. This, so we
; don't break Timbuktu/Remote.
; <29> 2/2/90 JWK NEEDED FOR 6.0.5: Changed SCSI Mgr bus error handler to allow
; chaining to previously installed handler if a non-SCSI bus error
; occurs.
; <28> 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).
; <27> 1/31/90 EH NEEDED FOR 6.0.5: 'Come from' patched IOPMsgRequest trap to fix
; IOP serial driver control call bug
; <26> 1/30/90 CCH NEEDED FOR 6.0.5: Modified gestaltHardwareAttr patch to set
; gestaltHasSCC bit in result if in IOP bypass mode.
; <25> 1/29/90 GGD NEEDED FOR 6.0.5, Adding a temporary patch to make cmd-period
; not hang the MPW shell on Zone-5, until the shell can be reved
; to fix the real problem.
; <24> 1/29/90 DVB NEEDED FOR 605 - Add PMgrVersion call
; <23> 1/25/90 KON NEEDED FOR 6.0.5: QDversion is offscreenVersion + $100, not
; $200.
; <22> 1/23/90 KON NEEDED FOR 6.0.5: Gestalt now gets the Quickdraw version from
; GWorld Offscreen version and adds 200.
; <21> 1/23/90 DVB NEEDED FOR 6.0.5 - Add HasDepth and SetDepth PMgr Dispatches
; <20> 1/22/90 CCH NEEDED FOR 6.0.5 - Added notification mgr selector.
; <19> 1/19/90 JWK NEEDED FOR 6.0.5 - Turn on SCSI DMA code in Zone5 final ROM's.
; <18> 1/18/90 DVB Include PalettePriv.a
; <17> 1/17/90 CCH NEEDED FOR 6.0.5: moved restoration of cache register in parity
; check routine.
; <16> 1/16/90 SMB NEEDED FOR 6.0.5: added install code for TENew and
; TEStylNew patch and included TextEditPriv.a.
; <15> 1/16/90 CCH NEEDED FOR 6.0.5: Turn off cache when checking RPU for parity.
; <14> 1/16/90 KON NEEDED FOR 6.0.5: Added ptch 26
; <13> 1/12/90 CCH Added include of ÒHardwarePrivateEqu.aÓ.
; <12> 1/11/90 PKE Initialize Script Manager's new sVectFixSpExtra vector.
; <11> 1/11/90 DVB Remove _Zaplinks macro.
; <10> 1/8/90 CCH Added gestaltMiscAttr selector.
; <9> 1/5/90 GMR Added ptchInst 8; Sony Format patch is now in it's own patch
; file (FormatPatch.a).
; <8> 1/5/90 CCH NEEDED FOR 6.0.5. Added parity support for Zone 5, removed base
; address selectors.
; <7> 1/4/90 BBM NEEDED FOR 6.0.5. Make the new sound manager patch out the rom
; on all machines.
; <6> 1/4/90 PKE NEEDED FOR 6.0.5 (smb's changes from SS-6.0.4b23 to SS-6.0.4f1):
; ¥ Add install code for TEFindLine patch. ALSO: Updated
; conditionals so SS-6.0.4 changes go in 6.0.5 as well as 7.0.
; Cleaned up the BBS header and eliminated the EASE header.
; <5> 1/3/90 BAL NEEDED FOR 6.0.5: Fixed Zero width character problem in
; drawtext.
; <4> 12/19/89 EH REALLY fix the pound signs!
; <3> 12/19/89 EH try to fix the pound signs!
; <2> 12/19/89 EH NEEDED FOR 6.0.5: Fix bug in 7.1 async patch; switched registers
; <1> 12/17/89 CCH Adding for the first time into BBS.
; <8.8> 12/14/89 SWC NEEDED FOR 6.0.5: Added RecoverHandle patch to also check if the
; pointer points to a ROM resource. Removed the NewSCSI trap
; initialization since async SCSI will not be in Zone 5 until 7.0
; or later.
; <8.7> 12/14/89 EVA NEEDED FOR 6.0.5 Fix SerialDriver.a patch to check SCCIOPFlag
; instead of PRAM to see which driver to load
; <8.6> 12/11/89 smb NEEDED FOR Scripts 604 AND (6.0.5 <= SysVers < 7.0): added
; installation code for TE routines CaretInsideRun,
; InvrtRectangle, SetKeyboard2Font.
; <8.5> 12/8/89 PKE NEEDED FOR Scripts604 AND FOR (6.0.5 <= SysVers < 7.0): Patch
; LwrString to handle 2-byte chars via Transliterate (yuck). For
; 7.0, we do this elsewhere.
; <8.4> 11/29/89 GGD NEEDED FOR 6.0.5: Re-Enabled the SANE optimization to bypass the
; Package Manager which never made it into 6.0.4. Fixed bug
; StripAddress that caused it to sometimes not strip when in a
; interrupt handler. Modified ADB auto/srq polling to not poll
; device addresses that are not in the device table. On OSS based
; machines, install a time manager task to simulate a 60.15Hz
; pseudo VBL because the OSS generates a 60.00Hz interrupt which
; is the wrong frequency.
; <8.3> 11/28/89 dvb Fixed bug in PMgr Zaplinks by working over pmgrDispatch. Also
; fixed bug in dispatch.
; <8.2> 11/22/89 EMT NEEDED FOR 6.0.5: Added humane scrolling.
; <8.1> 11/21/89 smb Added installation code for TE routines ptchGetWidth and
; ptchGetRLPosition.
; <8.0> 11/17/89 PKE Tail patch on _GetIndADB to fix Script Mgr SwapKybd routine,
; which cleared ADB keyboard driver dead state as a word: should
; be a long.
; <7.9> 11/10/89 KON PTCH'ed GetNewCWindow so when a palette with the same ID as the
; window exists in the resource file, the palette is attached to
; the window.
; <7.8> 11/6/89 PKE NEEDED FOR 6.0.5!! Bug fixes for InitDateCache and String2Date
; needed for HyperCard. InitDateCache: Fixed CopyArray to use
; correct register (A4) for source pointer, and to initialize all
; relevant bytes of length register (D0). String2Date: if first
; relevant (i.e., day or month name) alpha token is a month name,
; we now search the day name list if we find another alpha token
; (fixes BRC #54946). Rearranged Cache structure to fix invalid
; use of month/day name index.
; <7.7> 10/12/89 smb Moved TextEdit patches to TextEditPatchIIciROM.a. Fixed bug in
; old highlighting code that I introduced accidently (changed
; move.w -> move.l).
; <7.6> 10/11/89 CCH Added INCLUDE of "MMUEqu.a"
; <7.5> 10/11/89 CCH Set up MMUType if not already initialized.
; <7.4> 10/6/89 JSM Removed SnarfMan 'ptch', now PACK 13.
; <7.3> 10/5/89 CCH Changed an ORI to a BSET in gestaltAddressingModeAttr patch, and
; added installation of it.
; <7.2> 10/5/89 smb Added old highlighting code for TextEdit for HyperCard
; outlining.
; <7.1> 10/5/89 EVA NEEDED FOR 6.0.5!!! Fixed bug in async serial driver Ext/Stat
; int handler
; <7.0> 10/4/89 smb Fixed 6.0.4 build by moving around some of my conditionals due
; to dependencies! Fixed TEInit to set TEDoText like it used to.
; Cleaned up TEOutlineHilite. Fixed caret display for outline
; highlighting.
; <6.9> 9/29/89 CCH Added patch for gestaltAddressingModeAttr selector to add
; gestalt32BitCapable attribute. (version 6.8 breaks 6.0.4 builds,
; so I just tested on bigbang - because alpha 0 is in two days,
; thats why)
; <6.8> 9/29/89 smb Added patches for TextEdit for TEFeatureFlag, SetFont2Keyboard,
; and fixed CursorMovement for double-byte characters.
; <6.7> 9/27/89 EMT Fixed 6.2 to use Lea rather than LeaROM for RAM address.
; <6.6> 9/26/89 CVC Added PPC Toolbox as a 'ptch'.
; <6.5> 9/25/89 EMT Added ptchs 18, 6, 29.
; <6.4> 9/19/89 RLC Add Balloon Help (ptch 28) to this file.
; <6.3> 9/18/89 BBM Install resource manager extensions, ptch 21
; <6.2> 9/18/89 PKE For 7.0, patch Script Manager internal routine SwapIcon to use
; new 'kscn' resource type instead of 'SICN'.
; <6.1> 9/17/89 PKE Decided to patch out GetScript/SetScript entirely in ptch 27, so
; we no longer patch them here (see 5.9). Also, for 7.0 we now
; install the Script Manager's Gestalt function in ptch 27 instead
; of here (see 2.5).
; <6.0> 9/12/89 EMT PaintOne patch (3.7) nukes the layer manager. Only use on pre
; 7.0 systems.
; <5.9> 9/6/89 PKE Patch Script Manager GetScript/SetScript routines to support
; additional font info verbs for 7.0, and set up this font info in
; Roman ScriptRecord. Set new sVectCallInterface vector. Redo
; Script Manager version setup, using new smgrVersPTCHRom equate.
; <5.8> 9/5/89 jwk NEEDED FOR 6.0.5: Turn on NewSCSI in ROM if on F19.
; <5.7> 9/4/89 PKE Install Script Manager 7.0 extensions, ptch 27. Set Script Mgr
; version for 7.0.
; <5.6> 8/31/89 JSM Added SnarfMan support.
; <5.5> 8/30/89 smb NEEDED FOR Scripts604 and Big Bang! Bug fix in ptchTEFindWord
; (fixed word dragging bug and now uses old FindWord code when
; RecalLines calls. Also added ptchMeasureWidth to fix a
; hilighting bug at line ends when the line direction is RL on a
; system that is normally LR (ie - Roman, Kanji, etc.)
; <5.4> 8/28/89 PKE For 7.0, initialize additional Script Mgr vectors for
; SMgrCalcRect and SMgrInitFonts.
; <5.3> 8/27/89 PKE NEEDED FOR Scripts604, 6.0.5: Bump Script Manager version for
; Scripts604 or SysVers > $604, since IntlForce bug fix (4.5) is
; installed.
; <5.2> 8/22/89 PKE NEEDED FOR 6.0.4: (really dba) Tail patch to TextFont which
; fixes an MDEF bug in calculating the icon height. Replaces
; GetResource patch in 3.7 which attempted to fix the same
; problem.
; <5.1> 8/21/89 PKE NEEDED FOR 6.0.4: Really put in 4.1, which was only present as a
; comment until now (although it existed on Fiction sources).
; <5.0> 8/21/89 PKE NEEDED FOR 6.0.4: (really CSD) Fixed MDEF 3.7 patch (again. Last
; time, right?) to load #$00200020 into D1 when appropriate
; instead of jumping back into ROM at the same place for both
; cases cicn found and cicn not found.
; <4.9> 8/21/89 PKE NEEDED FOR 6.0.4: (really dba) Changed MDEF patch 3.7 to load A0
; with the right value instead of preserving its value.
; <4.8> 8/21/89 PKE NEEDED FOR 6.0.4: (Per CSD) Correct ROMNoColor address in MDEF
; patch (part of 3.7).
; <4.7> 8/21/89 PKE NEEDED FOR 6.0.4:
; ¥ (per dba) Only re-load the standard clut into QDColors if
; QDColors exists; this is so that A/UX will work
; ¥ Conditionalize 4.5 for Scripts604 OR (SysVers > $604)
; <4.6> 8/21/89 PKE NEEDED FOR 6.0.4!: Patch RelString,UprString,CmpString to
; re-introduce the bug in which "`" is converted to uppercase as
; "a". This is necessary to prevent HFS problems, since existing
; disk catalogs use the old, buggy sorting. Also remove SANE
; optimization (2.0); breaks Excel.
; <4.5> 8/21/89 PKE NEEDED FOR 6.0.4 SCRIPTS BUILD, 6.0.5: Extend Pack6 patch to fix
; a problem in LwrString,CharType,Transliterate,FindWord. These
; routines should save the IntlForce flags then clear them before
; the IUGetIntl call, restoring the flags afterward. This is so we
; get the itl2 tables for the correct script (instead of the
; tables for the system script).
; <4.4> 8/21/89 PKE NEEDED FOR 6.0.4!: Fixed accidental deletion of INCLUDE
; 'VideoPatch.a' in (4.3).
; <4.3> 8/21/89 PKE NEEDED FOR 6.0.4!!: Patch Pack6 to fix me-too problem with
; pointer to unlocked handle in Transliterate; affects Roman
; system (this problem looks familiar; did I dream that I already
; fixed this one?).
; <4.2> 8/18/89 smb NEEDED FOR 6.0.4: Another unlocked handle problem!
; AAAARRRRRGGGGHHHHHH! (See ptchOnSameLine below)
; <4.1> 8/18/89 DAF FOR 6.0.4 BUILD - Fixed a bug on non-CLUT devices in the
; SaveEntries trap on Aurora
; <4.0> 8/16/89 dba NEEDED FOR 6.0.4: InitProcMenu bug fixed: MBDF ID was not put in
; MenuList if MenuList was already allocated (InitMenus already
; called)
; <3.9> 8/15/89 prp Added Alias Manager and Folder Manager support.
; <3.8> 8/15/89 smb NEEDED FOR 6.0.4: Fixed some problems in my patch code for the
; bad pointer bug.
; <3.7> 8/15/89 dba NEEDED FOR 6.0.4:
; ¥ Shortened the SetWin/CtlColor patch by returning to ROM earlier.
; ¥ Patch PaintOne to do nothing if WWExist is non-0.
; ¥ Patch OpenCPort so that the current port is saved across
; NewGWorld.
; ¥ Patch GetResource so that GetIconSize in MDEF does not trash A0.
; ¥ Moved VideoPatch.a so that it does not happen on A/UX.
; ¥ Re-load the standard clut into QDColors so that the green channel
; is fixed
; <3.6> 8/14/89 djw NEEDED FOR 6.0.4: Fixed bug in slot mgr in pInitEntry routine.
; When calling _InsertSRTRec, and the sRsrc has a refnum
; associated with it, _sFindDevBase has bad spId.
; <3.5> 8/13/89 BAL NEEDED FOR 6.0.4: Added tail patch to InitPalettes to defeat
; spurious ExitToShell patching code (leftover from JP builds).
; (dvb really)
; <3.4> 8/11/89 smb Finally rolled in patches for a bad pointer bug (#51602) and an
; up & down arrow keys bug (#51961). See comments below.
; <3.3> 8/11/89 djw NEEDED FOR 6.0.4: Cleaned up file by deleting old comments,
; adding new comments, laying out patches in a "prettier" and more
; orderly format. Added A/UX runtime conditional check for
; Mac-only patches. Moved patches <2.4> and <2.7> to Mac OS only.
; Modified slot manager calls in patche <2.1> as per code review.
; <3.2> 8/9/89 CCH NEEDED FOR 6.0.4: Added patch to gestaltQuickdrawVersion to
; return two digit versions.
; <3.1> 8/8/89 smb NEEDED FOR 6.0.4: Reverted TEFindWord patch since the previous
; patch introduces an uglier bug that won't be fixed now. Also
; added gestalt function for TE.
; <¥3.0> 8/8/89 dba RealityÕs hard disk was full! Try submitting again.
; <3.0> 8/8/89 dba NEEDED FOR 6.0.4: added Menu Manager patches; InitProcMenu patch
; because it simply didnÕt work; MenuSelect patch to reinstate
; WaitMouseUp check
; <2.9> 8/8/89 PKE NEEDED FOR 6.0.4: In gestaltScriptMgr function, if gestalt
; selector is undefined, just leave gestalt result alone.
; <2.8> 8/8/89 smb NEEDED FOR 604: Added more TE patches for Aurora!
; <2.7> 8/7/89 GGD Changed SIntInstall again, to leave $FF as highest priority, but
; reverse handling of equal priorities. Modified to use less
; space. Changed GetBoardROM from <2.4> to be a ROM Offset,
; instead of absolute ROM address.
; <2.6> 8/6/89 DAF FOR 6.0.4 BUILD - Added TFB video card driver override for boot
; screen. This is the same code as is included in PatchIIROM.a
; (VideoPatch.a)
; <2.5> 8/5/89 PKE NEEDED FOR 6.0.4: Add Gestalt function for Script Manager,
; install corresponding Gestalt selectors.
; <2.4> 8/4/89 djw NEEDED FOR 6.0.4: Deleted patch <1.3> (no longer needed). Added
; code to re-init board id's in slot pram (fixes a bug in Aurora
; in InitPRAMRecs).
; <2.3> 8/2/89 EVA (forgot to) include hardwareEqu.a and SlotMgrEqu.a
; <2.2> 8/2/89 EVA FOR 6.0.4 (and above) Patched _SIntInstall to reverse slot
; interrupt queueing order
; <2.1> 8/1/89 CSD FOR 6.0.4: Added patch to suppress appleshare arrows on 32-bit
; video cards.
; <2.0> 7/26/89 GGD NEEDED FOR 6.0.4 Added SANE optimization to bypass the package
; manager
; <1.9> 7/25/89 DAF FOR 6.0.4 BUILD - Fixes for SetWinColor, SetCtlColor in 32-bit
; mode
; <1.8> 7/25/89 smb NEEDED FOR 6.0.4: Added TextEdit patches for Aurora.
; <1.7> 7/3/89 NJC Sound Manager Extensions (ptch 23) rolled in for real.
; <1.6> 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.
; <1.5> 5/31/89 CEL Only defined Spline_Font variable if it is undefined - makes it
; easier to build test 6.0.4 systems
; <1.4> 5/22/89 AG Fixed my mistake in gettrapaddress call
; <1.3> 5/21/89 AG Remove NEW SCSI manager trap (A089)
; <1.2> 5/13/89 EMT Added Window Manager extensions (Layers).
; <1.1> 5/3/89 CEL Rolling in Bass for the first time into EASEÉ
; <1.0> 3/6/89 CCH Adding to EASE for first time.
;___________________________________________________________________________________________________
; To Do:
;
;___________________________________________________________________________________________________
IF (&TYPE('SPLINE_FONT') = 'UNDEFINED') THEN
SPLINE_FONT EQU hasSplineFonts ;<1.1-4april89-CEL> <DDG>
ENDIF
IF (&TYPE('Scripts604') = 'UNDEFINED') THEN
Scripts604 EQU 0 ;<4.7><08/21/89 pke>
ENDIF
if (&type('isUniversal') = 'UNDEFINED') then
isUniversal: equ 1 ; <142> Define isUniversal here instead of BBSStartup
endif
BLANKS ON
STRING ASIS
MACHINE MC68020 ; changed from MC68000 to MC68020 <24July89smb>
MC68881
LOAD 'StandardEqu.d' ;
INCLUDE 'PatchMacros.a'
INCLUDE 'SlotMgrEqu.a' ;<2.3>
INCLUDE 'HardwarePrivateEqu.a'
INCLUDE 'UniversalEqu.a' ;<7.1>
INCLUDE 'VideoEqu.a'
INCLUDE 'ROMEqu.a'
INCLUDE 'MMUEqu.a' ;<7.6>
Include 'ScriptPriv.a' ;
INCLUDE 'GestaltEqu.a' ;
INCLUDE 'GestaltPrivateEqu.a' ;
INCLUDE 'TextEditPriv.a' ; <1/16/90smb> <16>
INCLUDE 'PackMacs.a' ;
INCLUDE 'InternalMacros.a' ; <54>
INCLUDE 'PaletteEqu.a' ;
INCLUDE 'PalettePriv.a'
INCLUDE 'ApplDeskBus.a' ; <8.0>
INCLUDE 'EgretEqu.a' ; <43>
INCLUDE 'IOPEqu.a' ; <8.4>
INCLUDE 'AppleDeskBusPriv.a' ; <8.4>
INCLUDE 'SCSIEqu.a' ; <19>
INCLUDE 'SCSIPriv.a' ; <19>
include 'ColorEqu.a'
INCLUDE 'QDHooks.a'
TERRORmajorVers EQU $067C ; TERROR major ROM version
TERRORminorVers EQU $15 ; TERROR ROM minor version number
ZYDECOminorVers EQU $17 ; Zydeco ROM minor version number
; The following symbols are defined in ScriptPriv.a. They control whether <50>
; various Script Mgr patches are resident and installed here (since many
; are also included in 'ptch' 39 or 27), and also control installation of
; Script Mgr 'ptch' resources.
;
; doScriptMgrGestalt ; in ptch 27
; doScriptMgrPack6Fix ; in ptch 39
; doScriptMgrStr2DatFix ; in ptch 39
; doScriptMgrRstKCHRFix ; in ptch 39
; doScriptMgrLwrString2 ; in ptch 27
; doScriptMgrSetROMVers ; in ptch 39
; doScriptMgrNewVectors ; in ptch 39
; installScriptMgrPtch27
; installScriptMgrPtch39
;
;-------------------------------------------------------------------------------
ROM67CFix PROC EXPORT
IMPORT PatchInit
EXPORT StartPatch,CutBack
; Cut back Code:
;
; StartPatch is the entry point for ROM67CFix. Upon entry D1.L contains our handle.
;
StartPatch
Bra PatchInit ; Carry out the patches <1.1-4april89-CEL>
DC.B 'PTCH' ; resource type
DC.W $67C ; patch ID $67C.
DC.W 1 ; current version number.
; cut back the ram-based system code to exclude this initialization code
; d0 = size to cut patch down to (EndOfPatch - StartPatch)
; a0 = handle to this PTCH resource (passed into StartPatch in D1 from SysPatch)
CutBack
_SetHandleSize ; adjust our size <1.1-4april89-CEL>
MOVEQ #$7F,D0 ; a soon to be large number
SWAP D0
_CompactMem ,SYS ; of course there must be a comma!
RTS ; all done
ENDPROC ; <24July89smb>
;=========================================================================================
;=========================================================================================
;= =
;= RESIDENT PATCH INSTALL CODE IS BELOW THIS POINT =
;= =
;= Add patch code which remains resident in the system in the following section. The =
;= installation code for the resident patches are further down in the file. Please =
;= begin your patch code with a header which serves to delimit your code from the =
;= previous person's patch code. Use another patches header as an example. Leave at =
;= least 2 or 3 blank lines between your code and the next code. Be sure to be careful =
;= about your conditionals. The safest thing to do is to make your code self-contained =
;= and not depend on someone elses conditionals encompassing your code. =
;= =
;= To find a place to insert your resident patch code, search for 'EndOfPatch' =
;= =
;= Please be neat and follow the format =
;= Drive safely =
;= =
;=========================================================================================
;=========================================================================================
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
;********************** PaletteMgr Patches Start Here ************************
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
INCLUDE 'paletteMgr.a'
ptchInitPalettes PROC EXPORT
RomInitPalettes EQU $3E1F0
; <dvb 8 August 1989> 3.5
; This neutralizes some spurious code in InitPalettes that patches ExitToShell
; the first time [InitPalettes is called and MultiFinder is active]. We depend
; on getting at least one InitPalettes before MultiFinder (from INIT 31).
JSRRom RomInitPalettes ; Call the old one.
MOVE.L PMgrHandle,A0 ; A0 = handle to pm globals
MOVE.L A0,D0 ; Are we a pmgr?
BEQ.S ptchIPEnd ; No=>bye.
CMPI.L #-1,D0 ; Is it -1? <2>
BEQ.S ptchIPEnd ; -> Yes, bail out. <2>
MOVE.L (A0),A0 ; A0->pm globals
TST.L OldExitToShell(A0) ; Has it been patched yet?
BNE.S ptchIPEnd ; Yes => do nothing
MOVE #1,OldExitToShell(A0) ; Put something there; pretend its patched
ptchIPEnd RTS
ENDPROC
;-------------- Start of PMgrDispatch patch added by dvb 28Nov89 <8.3> --------------------
PROC
EXPORT ptchPMgrDispatch,pMgrProcs,pMgrProcsEnd
IMPORT SetDepth,HasDepth,PMgrVersion
IMPORT SetPaletteUpdates,GetPaletteUpdates,CheckColors
IMPORT GetGray
RomEntry2Index EQU $3E8C0
RomIndex2Entries EQU $3E9A0
RomDeltaRGB EQU $3CBF0
RomNewHiliteColor EQU $3F8D0
RomPMgrExit EQU $3DAA0
RomSaveFore EQU $3F910
RomSaveBack EQU $3F914
RomRestoreFore EQU $3F970
RomRestoreBack EQU $3F98E
RomReinstantiateColors EQU $3F9B0 ;this routine should do something heh heh
RomReleaseList EQU $3F9C0
RomPMgrDispatch EQU $3FA36
RomPMgrFinalError EQU $3FA4A
RomRestoreDeviceClut EQU $3F8A0
RomResizePaletteplusEight EQU $3F818
RomFindLink EQU $3E460
RomUnhookAfterZapLinks EQU $3F61E
RomUnhookGoHome EQU $3F642
RomZapLinksAtA EQU $3F70A
;ctReserveBit EQU 6
ptchResizePalette
;---------------------------------------------------
;
; PROCEDURE ResizePalette(srcPalette:PaletteHandle; dstSize:INTEGER); AAA2/3;
;
; Set the number of entries in the palette, and properly dispose of some
; of them if the palette is shrinking.
;ResizePalette PROC EXPORT
RPVars RECORD {A6Link},DECREMENT
result DS.B 0 ; Result: none
srcPal DS.B 4 ; input: palette handle
dstSize DS.B 2 ; input: new size for palette
return DS.B 4
A6Link DS.B 4 ; old contents of A6
linkSize DS.B 0 ;linky number
ENDR
WITH RPVars
LINK A6,#linkSize
MOVEM.L A2/D3-D4,-(SP) ; save 'em.
moveq #0,d3 ;<KON 17May90>
move.l d3,d4 ;<KON 17May90>
JMPRom RomResizePaletteplusEight
ptchZapLinks
; Following code is spliced out of CQD:PaletteMgr.a <dvb>
; ROM67C: Zaplinks bug is that it doesn't clear the ctReserve bit if its
; not on the main screen. Zaplinks is called by Pillage, UnreserveDevices,
; and ReleaseList. Pillage and UnreserveDevices end up clearing the bit
; themselves, so only ReleaseList must be patched here.
;
ZLVars RECORD {A6Link},DECREMENT
result DS.B 0 ;Result length: none
myIndex DS.B 2 ;Input: device number and index to unlink
return DS.B 4
A6Link DS.B 4 ;old contents of A6
linkSize DS.B 0 ;linky number
ENDR
WITH ZLVars
LINK A6,#linkSize
MOVEM.L A0-A2/D0-D4,-(SP)
MOVE.L PMgrHandle,A1
MOVE.L (A1),A1 ; A1->PMgrData
LEA LinkTabs(A1),A0 ; A0->Link Tables
MOVE.L PListHandle(A1),A2 ; A2 = palette list handle
MOVE.L (A2),A2 ; A2 -> palette info list
MOVE myIndex(A6),D0 ; D0 = tricky link
AND #$1FFF,D0 ; clear key bits
MOVE D0,D1
LSR #8,D1 ; D1 = device number
MOVE.L DevHandles(A1,D1*8),A1 ; A1 = device handle
MOVE.L (A1),A1 ; A1->device
MOVE.L gdPMap(A1),A1 ; A1 = pixmap handle
MOVE.L (A1),A1 ; A1->pixmap
MOVE.L pmTable(A1),D1 ; D0 = color table for this device
BEQ.S @a ; Skip this if none
MOVE.L D1,A1 ; A1 = color table handle
MOVE.L (A1),A1 ; A1 -> color table
CLR D1
MOVE.B D0,D1 ; We need to clear the upper bits
CMP ctSize(A1),D1 ; Index in range? <fixed>
BHI.S @a ; No=>skip this
BCLR #ctReserveBit,ctTable+value(A1,D1*8) ; unreserve!
@a JMPRom RomZapLinksAtA ; return to ROM code
;---------------------------------------------------
;
; PROCEDURE PMgrExit; AAA2/12;
;
; Someone should call here when an application quits. Please.
;
ptchPMgrExit
PXVars RECORD {A6Link},DECREMENT
result DS.B 0 ;Result: nothing
return DS.B 4
A6Link DS.B 4 ; old contents of A6
frontPSN DS.B 8 ; a 64-bit process serial number
myPSN DS.B 8 ; likewise
inFront DS.B 2 ; a boolean
linkSize DS.B 0 ; linky number
ENDR
ROMINTOPMGREXIT EQU $3DAB2
WITH PXVars
MOVE.L WindowList,-(SP) ; Save the windowlist value
LINK A6,#linkSize
TST.B QDExist ; if InitGraf has not been called yetÉ
BNE.S @doNothing ; (a5) not valid and there is nothing to do
CMP.L #PMgrNil,PMgrHandle ; If the palette manager doesnt exist...
BEQ.S @doNothing
CLR.L AppPalette
BSR.S DisposeAppPalettes
MOVE.L (A5),A0 ; < 124 >
BTST #3,QDSpare0(A0) ; Any change to color env? < 124 >
BEQ.S @doNothing ; < 124 >
BSR.S CheckForProcessMgr
BEQ.S @front ; if no process mgr, assume we're in front
MOVE #$0100,inFront(A6) ; default inFront to true
SUBQ #2,SP ; space for result
PEA frontPSN(A6)
_GetFrontProcess
TST (SP)+ ; problem getting front psn?
BNE.S @front ; YES => just zap the cluts
CLR.L myPSN(A6)
MOVE.L #kCurrentProcess,myPSN+4(A6)
SUBQ #2,SP ; space for OSErr result
PEA frontPSN(A6)
PEA myPSN(A6)
PEA inFront(A6)
_SameProcess ; are we the front process?
ADDQ #2,SP ; OSErr leaves inFront true from above
TST inFront(A6)
BEQ.S @doNothing
@front
JSRROM ROMINTOPMGREXIT
; JSR CheckAllDeviceCluts ; A pretty simple patch, really.
; CLR -(SP) ; No Setentries on Scatter
; JSR ScatterDevices
; BSR.S CheckForJuggler ; Is Jugglertm active?
; BNE.S @doNothing ; No=>WMgr is void, next line dangerous
; JSR UpdateDevices
; MOVE.L mainDevice,theGDevice
@doNothing
UNLK A6
MOVE.L (SP)+,WindowList
RTS
;---------------------------------------------------
;
; FUNCTION CheckForProcessMgr:Boolean;
;
; Determine if the process mgr is present using Gestalt.
; (we assume that gestaltLaunchControl iff processMgr is here)
; Affect only A0/D0, since Gestalt is an OS trap.
; return Z-flag Clear if the process mgr is here (BNE ProcMgrTrue)
CheckForProcessMgr
MOVE.L #'os ',D0 ; type of question
_Gestalt
TST D0 ; OSErr from Gestalt?
BEQ.S @a ; No=>test result
SUBA A0,A0 ; Yes=>assume there's no procMgr
@a
MOVE.L A0,D0
BTST #gestaltLaunchControl,D0 ; clear the Z-flag if procmgr here
RTS
;---------------------------------------------------
;
; PROCEDURE DisposeAppPalettes();
;
; Look through the palette list and dispose of any in the current App heap.
DisposeAppPalettes
MOVEM.L A0-A3/D0-D3,-(SP) ; save all registers
MOVE.L PMgrHandle,A2 ; get paletteMgr handle
CMP.L MinusOne,A2 ; is it there?
BEQ GoHome ; => no, just return
MOVE.L (A2),A1 ; point to data structure
MOVE.L PListHandle(A1),A0 ; get handle to palette list
_HLock ; and lock it down
MOVE.L (A0),A3 ; point to palette list
Move APalettes(A1),D3 ; get number of active handles
Beq.s NoPals ; no friends => go home
Add FreeSpaces(A1),D3 ; calculate total number of entries
;<13> Clr.L WindowList ; clear the list of windows for FrontWindow AWC.PB506
BRA.S FindEnd ; => check for no entries
FindLoop Move.L PaletteRef(A3),D1 ; get first entry
BEQ.S FindNext ; => no palette in entry
MOVE.L ApplZone,A0 ; get application heap zone <117>
CMP.L A0,D1 ; Are we before the heap zone? <117>
BLO.S FindNext ; Yes => not in app heap
CMP.L bklim(A0),D1 ; Are we past the heap zone <117>
BHS.S FindNext ; => not in app heap
MOVE.L D1,-(SP) ; push palette handle
_DisposePalette ; and dispose it in place
FindNext AddQ #PLstEntrySz,A3 ; bump to the next entry
FindEnd DBra D3,FindLoop ; repeat for all spaces
NoPals MOVE.L (A2),A1 ; point to palette stuff
MOVE.L PListHandle(A1),A0 ; get handle to palette list
_HUnlock ; and unlock it
GoHome Clr.L AppPalette ; set us up for the next guy AWC.PB508
MOVEM.L (SP)+,A0-A3/D0-D3
RTS
; This is the Palette Manager's dispatch table. ROM routines
; which work are included with DcRom to give absolute
; addresses. New routines are offsets from the table base, with
; the low bit set, just for clarity.
ptchPMgrError JMPRom RomPMgrFinalError
pMgrProcs
switch00 DcRom RomEntry2Index
switch01 DcRom RomIndex2Entries
switch02 DC.L RestoreDeviceClut-pMgrProcs+1
switch03 DC.L ptchResizePalette-pMgrProcs+1
switch04 DC.L ptchZapLinks-pMgrProcs+1
switch05 DC.L WhatPal-pMgrProcs+1
switch06 DC.L ptchPMgrError-pMgrProcs+1 ; Some unused dispatchs
switch07 DC.L ptchPMgrError-pMgrProcs+1
switch08 DC.L ptchPMgrError-pMgrProcs+1
switch09 DC.L ptchPMgrError-pMgrProcs+1
switch10 DcRom RomDeltaRGB
switch11 DcRom RomNewHiliteColor
switch12 DC.L ptchPMgrExit-pMgrProcs+1
switch13 DcRom RomSaveFore
switch14 DcRom RomSaveBack
switch15 DcRom RomRestoreFore
switch16 DcRom RomRestoreBack
switch17 DcRom RomReinstantiateColors
switch18 DC.L ReleaseList-pMgrProcs+1
switch19 DC.L SetDepth-pMgrProcs+1
switch20 DC.L HasDepth-pMgrProcs+1
switch21 DC.L PMgrVersion-pMgrProcs+1
switch22 DC.L SetPaletteUpdates-pMgrProcs+1
switch23 DC.L GetPaletteUpdates-pMgrProcs+1
switch24 DC.L CheckColors-pMgrProcs+1
switch25 DC.L GetGray-pMgrProcs+1
pMgrProcsEnd
ptchPMgrDispatch
CMP.B #(PMgrProcsEnd-PMgrProcs)/4,D0
BHS.S ptchPMgrError ; Too high a dispatch
MOVE.L A0,-(SP) ; Preserve A0
LEA pMgrProcs,A0 ; A0->absolute table of dispatchs
AND #$00FF,D0 ; Kill arg count from dispatch
MOVE.L (A0,D0*4),-(SP) ; Push target as return address
MOVE.L 4(SP),A0 ; Restore A0
RTD #4 ; And go to routine.
ENDPROC ; <107>
;--- This equate must be kept outside of code/data modules --- ; <107>
pMgrProcsSize EQU pMgrProcsEnd-pMgrProcs ; <107>
;-------------- Start of GetNewCWindow patch added by KON 10Nov89 --------------------
ptchGetNewCWindow PROC EXPORT
RomGetNewCWindow EQU $21c90
;
; First we call the existing routine to get a CWindow. Then we add a palette if one
; with the same ID exists in the resource file.
;
result EQU 18 ; parameter equates
winID EQU 16
wStor EQU 12
behind EQU 8
link a6, #0 ;no local parameters <10Nov89 KON>
clr.l -(sp) ;room for result from ROM GetNewCWindow <10Nov89 KON>
move.w winID(a6),-(sp) ;do same call as requested <10Nov89 KON>
move.l wStor(a6),-(sp)
move.l behind(a6),-(sp)
JSRRom RomGetNewCWindow ;call the old one <10Nov89 KON>
move.l (sp)+,result(a6) ;return result <10Nov89 KON>
;
; Check if palette with same ID as window exists (taken from getmgr.a)
;
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 result(a6),-(sp) ; push the window <10Nov89 KON>
move.l d0,-(sp) ; push the palette <erich>
move D1,-(sp) ; push cUpdates AWC.PB459
_SetPalette ; <erich>
NoWindowPltt ; AWC.PB459
unlk a6
move.l (sp)+,a0 ;return address
add #10,sp ;strip parameters, leave result
jmp (a0)
ENDPROC
;-------------- End of GetNewCWindow patch added by KON 10Nov89 ----------------------
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
;********************** End Of PaletteMgr Patches? ************************
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
;____________________________________________________________________________ DAF <2.6>
; Window manager patch
;
; This patch corrects a bug in SetWin/CtlColor in 32-bit addressing mode. These routines
; (which operate on identical data structures) can accept a colortable whose ctSize=-1
; which allows an application to specify that the wcTable be set to the default color
; set (via a copy of the color table handle). In 32-bit mode it is important that there
; be exactly one auxWinRec per window. This routine has a bug where -1 color tables can
; cause extra auxWinRecs to be allocated in 32-bit mode.
;
;
; procedure SetWinColor ( theWindow:windowPtr; newColorTable:CTabHandle );
;
; This procedure changes the awCTable field of the theWindow's auxWinRec.
; If newColorTable is equal to the default record's CTabHandle, then
; the auxWinRec is deallocated. If this window does not have an
; auxWinRec, then one is allocated at the head of the list. If theWindow
; is NIL, then the default colors are changed. If a record gets deallocated,
; it's colorTable is disposed unless it has it's resource bit set (then the
; app must take responsibility)
;
; Most of this code is shared with the control manager. Since the auxRec
; offsets are the same for both types of auxrecs, the code should be OK,
; even though the code uses the auxWinRec names.
;
NewSetWinColor PROC EXPORT
EXPORT NewSetCtlColor
ROMSetWinColorAfterSetGutsCall EQU $19744
ROMSetCtlColorAfterSetGutsCall EQU $1979C
ROMGetAuxGuts EQU $19888 ; GetAuxGuts in Aurora ROM
ROMSetGutsAfterSpecAlloc32Call EQU $197F6
ROMDeAlAux EQU $1983A
ROMSpecAlloc EQU $1981A
ROMSWCDone EQU $19816
MOVEM.L A2/A3,-(SP) ;get some address registers
MOVE.L AuxWinHead,A2 ;get the list head
LEA AuxWinHead,A3 ;in case we need to deallocate
BSR.S SetGuts ;bsr so that we can redraw on return
JMPROM ROMSetWinColorAfterSetGutsCall
NewSetCtlColor
MOVEM.L A2/A3,-(SP) ;get some address registers
MOVE.L AuxCtlHead,A2 ;get the list head
LEA AuxCtlHead,A3 ;in case we need to deallocate
BSR.S SetGuts ;
JMPROM ROMSetCtlColorAfterSetGutsCall
SetGuts
tWind EQU $18 ;some equates for parameters
nCTab EQU $14 ; after LINK (don't forget the movem above!)
LINK A6,#0 ;no globals
CLR.L -(SP) ;return AuxWinHandle here
CLR.W -(SP) ;function return here
CLR.L -(SP) ;NIL for default
PEA 6(SP) ;pointer to the placeholder
MOVE.L A2,A1 ;set up list head for GetAuxGuts
JSRROM ROMGetAuxGuts ;get the default record
ADDQ #2,SP ;ignore boolean result
MOVE.L (SP)+,A0 ;get the default handle
MOVE.L (A0),A0 ;get a pointer
MOVE.L awCTable(A0),A0 ;get the cTabHandle
CMP.L nCTab(A6),A0 ;if the same then deallocate
BEQ DeAlAux ;
CMP.L #-1,nCTab(A6) ;if -1, then allocate a rec with default table
BEQ.S SpecAlloc ;
MOVE.L A0,-(SP) ;save a reg (yuck, but registers are tight!)
MOVE.L nCTab(A6),A0 ;get the new color table handle
MOVE.L (A0),A0 ;get a pointer
CMP.W #-1,ctSize(A0) ;is ctSize -1?
MOVE.L (SP)+,A0 ;get the register back (don't change flags)
BEQ.S SpecAlloc32 ;If so, alloc a rec with default table
JMPROM ROMSetGutsAfterSpecAlloc32Call
DeAlAux JMPROM ROMDeAlAux
SpecAlloc JMPROM ROMSpecAlloc
; if this routine is called in 24-bit mode, then it falls through to SpecAlloc and makes
; a new auxWinRec with a copy of the default colortable. If it is called in 32-bit
; mode, then it finds the window's pre-existing auxWinRec (one is always guaranteed to
; exist) and sets it's colortable to be a copy of the default colortable handle.
SpecAlloc32
TST.B MMU32Bit ; are we in 32-bit mode?
BEQ.S SpecAlloc ; no, so allocate a new record with a copy of the default colors
MOVE.L A0,nCTab(A6) ; stick the default colors in the stack frame
CLR.L -(SP) ; return AuxWinHandle here
CLR.W -(SP) ; leave room for return value here
MOVE.L tWind(A6),-(SP) ; find this window
PEA 6(SP) ; point to placeholder
MOVE.L A2,A1 ; set up list head for GetAuxGuts (windows or controls)
JSRROM ROMGetAuxGuts ; get it (it will always be here in 32-bit mode)
ADDQ #2,SP ; the result should have always returned true
MOVE.L (SP)+,A0 ; get the win/ctl rec handle>
MOVE.L (A0),A0 ; get a pointer
MOVE.L nCTab(A6),awCTable(A0) ;and set the default colortable (in nCTab) field
JMPROM ROMSWCDone
;____________________________________________________________________________ GGD <2.7>
; Slot interrupt patch for _sIntInstall
;
; <2.2/2.7> Slot Interrupt patch: patches _SIntInstall, and reverses Slot
; interrupt queue order
;
; Change the treatment of Equal Priorities to match the Mac II, which ran the most
; recently installed element soonest when priorities were equal. This code matches
; Inside Mac Vol 5, and treats $FF as highest priority. The Mac II has a bug and
; treats $FF as LOWEST priority within the slot, but as HIGHEST priority across slots.
; Most cards seemed to beleive the documentation, and none have multiple handlers per slot,
; One developer figured out that the Mac II was backwards within the slot, and wanted to
; insert an element ahead of a priority zero (highest with Mac II bug) element. To do
; this, he took advantage of the was that equal priorities were treated on the Mac II,
; which is why we are now patching this to match.
;
SIntCorePtch proc export
WITH SlotIntQElement,slotIntGlobals
EXPORT SIntINSTALL
ROMGetSlotIntQHead equ $00006E30 ; offset to GetSlotIntQHead
;_______________________________________________________________________
;
; Routine: SIntINSTALL
;
; Arguments: D0 (input) : slot number for routine ($0..$E possible)
; A0 (input) : ptr to queue element
; D0 (output): error code - 0 no error
;
; Function: Installs a slot interrupt poll routine which is called when
; a slot interrupt occurs. The queue element is installed in
; in priority order, $FF highest (first), $00 lowest (last).
;
; When elements with EQUAL priorities exist, the most recently
; installed one is run sooner.
;
; <2.7> changes the treatment of Equal priorities to match Mac II.
;
; Only low byte of priority word is used (0-255 range).
; Priorities 200-255 are reserved by Apple.]
;
; The Mac II used to maintain priority across slots, which was
; used when multiple slots interrupted AT THE SAME TIME.
; We no longer support this, and prioritize by slot number instead.
; This will be removed from the Mac II in system 7.0
;
; The Mac II had a bug in SIntInstall, which had $FF as the highest
; priority across slots, but had $FF as the lowest within a slot.
; Most cards used the priority order as documented, ($FF highest), so
; we will retain that ordering.
; This will be fixed in the Mac II in System 7.0.
;
; Registers Used: D0,D1,D2,A0,A1
;_______________________________________________________________________
SIntINSTALL JsrROM ROMGetSlotIntQHead ; a1 := pointer to qheader
move.b SQPrio+1(a0),d0 ; get the priority (low byte of word)
move.w sr,-(sp) ; save interrupt level
ori.w #HiIntMask,sr ; disable interrupts
@PrioritySearch
move.l SQLink(a1),d1 ; get next queue element to check
beq.s @insert ; if end of list, insert before this
exg.l a1,d1 ; swap previous and current pointers
cmp.b SQPrio+1(a1),d0 ; compare priorities
blo.s @PrioritySearch ; loop until lower priority found (was BLS.S) <2.7>
; if equal, insert newer in front of older <2.7>
exg.l d1,a1 ; a1 points to previous, d1 points to current
@insert ; insert before the lower priority element
move.l d1,SQLink(a0) ; remainder of queue goes after new element
move.l a0,SQLink(a1) ; new element goes after previous element
move.w (sp)+,sr ; restore interrupt level
moveq.l #noErr,d0 ; return success
rts ; all done
ENDP
;____________________________________________________________________________ <20>
; Patches to Gestalt Functions
;____________________________________________________________________________
; The following gestalt selectors are patched or added in this file:
; - gestaltHardwareAttr
; - gestaltParityAttr
; - gestaltMiscAttr
; - gestaltVersion
; - gesaltNotificationMgrAttr
; - gestaltQuickdrawVersion
; - gestaltAddressingModeAttr
; - gestaltNuBusConnectors <95>
; - gestaltSerialAttr <95>
;
; The following gestalt selectors are removed in this file:
; - gestaltRBVAddr
; - gestaltSCCReadAddr
; - gestaltSCCWriteAddr
; - gestaltVIA1Addr
; - gestaltVIA2Addr
; - gestaltSlotAttr <95>
; - gestaltFirstSlot <95>
; - gestaltSlotCount <95>
;
;-----------------------------------------------------------------------------------------
;
; Record to describe gestalt function parameters
;
;-----------------------------------------------------------------------------------------
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 <8>
; Gestalt function to effectively remove a selector
;
; The following is a gestalt function that will return an error as if the
; selector were undefined.
;
; Routine gestaltUndef (
; gestaltSelector: OSType; = PACKED ARRAY [1..4] OF CHAR;
; VAR gestaltResult: Longint;
; ): OSErr; = Integer;
;
gestaltUndef PROC EXPORT
with gestaltParmFrame
link a6,#localFrame
move.w #gestaltUndefSelectorErr,result(a6) ; return an error
unlk a6
move.l (sp)+,a0 ; get return value
add.l #argSize,sp ; restore stack pointer
jmp (a0) ; return
ENDP
;____________________________________________________________________________ CCH <10>
; Gestalt function for gestaltMiscAttr
;
; The following is a patch to the gestaltMiscAttr selector. It returns
; miscellaneous information about things.
;
; Routine gestaltMisc (
; gestaltSelector: OSType; = PACKED ARRAY [1..4] OF CHAR;
; VAR gestaltResult: Longint;
; ): OSErr; = Integer;
;
UserDelayTrap EQU $A84C ; user delay trap <17>
gestaltMisc PROC EXPORT
with gestaltParmFrame
link a6,#localFrame
clr.l d3 ; clear result
@hasBootGlobs bset #gestaltBootGlobals,d3 ; we have boot globals
@userDelay move.w #UnimplementedTrap,D0 ; get loc of unimplemented trap <58>
_GetTrapAddress ,newTool ; get the address into A0
Move.l A0,D2 ; save it for a sec
Move.l #UserDelayTrap,D0 ; trap ID to check for scrolling throttle
_GetTrapAddress ,newTool ; get the address of it
cmp.l a0,d2 ; is it unimplemented?
beq.s @squareMenus ; nope.. <58>
bset #gestaltScrollingThrottle,d3 ; <58>
@squareMenus move.b NTSC,d0 ; get a copy of the NTSC byte <58>
andi.b #$0F,d0 ; only look at bottom nibble <58>
bne.s @next ; if it's non-zero, menus aren't square <58>
bset #gestaltSquareMenuBar,d3 ; otherwise, it is! <58>
@next
move.l d3,d0 ; put result into d0 <58>
move.l gestaltResult(a6),a0 ; get address to place result
move.l d0,(a0) ;
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
ENDP
;____________________________________________________________________________ CCH <20>
; Gestalt function for gestaltNotificationMgrAttr
;
; The following is a patch to the gestaltNotificationMgrAttr selector.
; It indicates existence of the notification manager trap.
;
; Routine gestaltNMgr (
; gestaltSelector: OSType; = PACKED ARRAY [1..4] OF CHAR;
; VAR gestaltResult: Longint;
; ): OSErr; = Integer;
;
NMInstallTrap EQU $A05E ; notification manager install trap <20>
gestaltNMgr PROC EXPORT
with gestaltParmFrame
link a6,#localFrame
clr.l d0 ; clear result
Move.w #UnimplementedTrap,D0 ; get loc of unimplemented trap
_GetTrapAddress ,newTool ; get the address into A0
Move.l A0,D2 ; save it for a sec
Move.l #NMInstallTrap,D0 ; trap ID to check for notification mgr
_GetTrapAddress ,newTool ; get the address of it
Cmp.l A0,D2 ; is it unimplemented?
Beq.s @noNMgr ; it is?!
bset #gestaltNotificationPresent,d0 ; otherwise it exists
@noNMgr move.l gestaltResult(a6),a0 ; get address to place result
move.l d0,(a0) ;
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
ENDP
;____________________________________________________________________________ CCH <8>
; Gestalt function for gestaltVersion
;
; The following is a patch to the gestaltVersion selector. It returns the
; correct version number.
;
; Routine getGestaltVers (
; gestaltSelector: OSType; = PACKED ARRAY [1..4] OF CHAR;
; VAR gestaltResult: Longint;
; ): OSErr; = Integer;
;
getGestaltVers PROC EXPORT
with gestaltParmFrame
link a6,#localFrame
move.l gestaltResult(a6),a0 ; get address to place result
move.l #1,(a0) ; return response determined at install time
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
ENDP
;____________________________________________________________________________ jwk <95>
; Gestalt function for gestaltNuBusConnectors
;
; The following returns a bitmap of slots with NuBus connectors.
;
gestaltNBCon PROC EXPORT
MaxSlots EQU 16 ; max number of slots possible
with gestaltParmFrame, NuBusInfo, ProductInfo
link a6,#localFrame
movea.l UnivInfoPtr,a0 ; get universal info ptr
adda.l NuBusInfoPtr(a0),a0 ; add in offset to NuBus info
clr.l d0 ; clear index
clr.l d1 ; clear bitmap of NuBus connectors
@slotLoop btst #hasConnector,(a0,d0.w) ; does this slot have a connector?
beq.s @next ; if not, go look at next slot
bset.l d0,d1 ; note that this slot has a NuBus connector
@next addq #1,d0 ; bump up to next slot
cmpi.l #MaxSlots,d0 ; have we gone through all slots?
bne.s @slotLoop ; if not, keep going
move.l gestaltResult(a6),a0 ; get address to place result
move.l d1,(a0) ; return the bitmap of NuBus connectors
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
ENDP
;____________________________________________________________________________ EH <95>
; Gestalt function for gestaltSerialAttr
;
; The following is a patch to the gestaltSerialAttr selector.
; It indicates existence of serial attributes on the machine.
;
gestaltSerial PROC EXPORT
with gestaltParmFrame,ExpandMemRec,GestaltGlobals
link a6,#localFrame
movea.l ExpandMem,a0 ; get ptr to expandmem rec
movea.l emGestalt(a0),a0 ; get gestalt global ptr
moveq.l #0,d0 ; assume no GPI connections
cmpi.w #gestaltMacLC,machType(a0) ; <107> use real machine name now...
beq.s @noGPI
; IIci and IIsi have GPI connected
moveq.l #(1<<gestaltHasGPIaToDCDa)|\ ; GPIa connected to DCDa
(1<<gestaltHasGPIaToRTxCa)|\ ; GPIa connected to RTxCa clock input)
(1<<gestaltHasGPIbToDCDb),d0 ; GPIb connected to DCDb
@noGPI move.l gestaltResult(a6),a0 ; get address to place result
move.l d0,(a0) ;
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
ENDP
;____________________________________________________________________________ CCH <8>
; Gestalt function for gestaltParityAttr
;
; The following is a patch to the gestaltParityAttr selector. It correctly
; handles parity on Zone 5, as well as the IIci.
;
; Routine gestaltParity (
; gestaltSelector: OSType; = PACKED ARRAY [1..4] OF CHAR;
; VAR gestaltResult: Longint;
; ): OSErr; = Integer;
;
gestaltParity PROC EXPORT
EXPORT parityValue
with gestaltParmFrame
link a6,#localFrame
move.l gestaltResult(a6),a0 ; get address to place result
move.l parityValue,(a0) ; return response determined at install time
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
parityValue dc.l 0 ; response for parity selector
ENDP
;____________________________________________________________________________ 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;
;
gestaltQDVers 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
ENDP
;____________________________________________________________________________ CCH <6.9>
; Gestalt function for gestaltAddressingModeAttr
;
; The following is a patch to the gestaltAddressingModeAttr selector to add the
; gestalt32BitCapable bit to this selector.
;
; Routine gestaltAddrMode (
; gestaltSelector: OSType; = PACKED ARRAY [1..4] OF CHAR;
; VAR gestaltResult: Longint;
; ): OSErr; = Integer;
;
gestaltAddrMode PROC EXPORT
with gestaltParmFrame
link a6,#localFrame
clr.l d0 ; clear result value <6.9>
move.b SystemInfo,d0 ; get status byte into d1 <6.9>
not.b d0 ; invert status bits <6.9>
and.l #3,d0 ; only want bit 0 and bit 1 <6.9>
bset #gestalt32BitCapable,d0 ; return that ROM is 32-bit clean <6.9>
move.l gestaltResult(a6),a0 ; get address to place result
move.l d0,(a0) ; save result <6.9>
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
ENDP
IF doScriptMgrGestalt AND (NOT installScriptMgrPtch27) THEN ; <6.1><50>
;____________________________________________________________________________ pke <2.5>
; Gestalt function for Script Mgr <08/05/89 pke>
;
; The following Gestalt Function is an interface between the Gestalt mechanism
; and the Script Manager's GetEnvirons routine. Currently, it only supports two
; Gestalt selectors: gestaltScriptMgrVersion and gestaltScriptCount.
;
; Routine gestaltScriptMgr (
; gestaltSelector: OSType; = PACKED ARRAY [1..4] OF CHAR;
; VAR gestaltResult: Longint;
; ): OSErr; = Integer;
;
; <08/05/89 pke> New today
;
gestaltScriptMgr proc export
export gestaltSMgrTable ; table for installation <8/05/89 pke>
with gestaltParmFrame ; <3.2>
link a6,#localFrame
; initialize loop, set up default return values
move.l gestaltSelector(a6),d0 ; selector value
;; move.l gestaltResult(a6),a0 ; addr for result
;; clr.l (a0) ; initially set result to 0
move.l #gestaltUndefSelectorErr,result(a6) ; assume unknown selector
lea gestaltSMgrTable,a1
; loop to find Gestalt selector in table
@gestaltLoop
move.l (a1)+,d1 ; get next table entry
beq.s @gestaltDone ; end of list, quit
move.w (a1)+,d2 ; now get GetEnvirons verb
cmp.l d0,d1 ; is selector correct?
bne.s @gestaltLoop ; no, get next one
; ok, we found the Gestalt selector. Now call GetEnvirons with correct verb
clr.l -(sp) ; space for result
move.w d2,-(sp) ; push verb
_GetEnvirons
move.l gestaltResult(a6),a0 ; addr for result
move.l (sp)+,(a0) ; pop result into Gestalt
move.w #noErr,result(a6) ; return no error
; all done
@gestaltDone
unlk a6
move.l (sp)+,a0
add.l #argSize,sp
jmp (a0)
endWith
; Table for converting between gestalt selectors and GetEnvirons verbs. Each pair
; consists of a long with the gestalt selector, followed by a word with the
; GetEnvirons verb. This table and the equate files where the Gestalt selectors
; are defined are the only things that need to change to add new Gestalt selectors
; for the Script Manager.
gestaltSMgrTable
dc.l gestaltScriptMgrVersion
dc.w smVersion
dc.l gestaltScriptCount
dc.w smEnabled
dc.l 0 ; terminator
endProc
ENDIF ; <6.1>
IF NOT SPLINE_FONT THEN ; <6.0.5>
;____________________________________________________________________________ CEL <5>
; NewRSect (fixes DrawText)
;
; DrText had a check to see if the advance width of a character was zero. If so,
; it would skip the character. This was bad since International uses zero width
; characters to lay out certain kanji or vertical text. only one line needed to
; be taken out. The patch is big but the change is small.
;
NewRSect proc export
;-------------------------------------------
;
; 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
locASCENT EQU 18 ;WORD Conflict with other Ascent and Descent defines
locDESCENT 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
COUNT EQU PARAMSIZE+8-2 ;WORD
TEXTADDR EQU COUNT-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
SRCRECT EQU TEXTR2-8 ;RECT original shadow bounding rect
DSTRECT EQU SRCRECT-8 ;RECT copy of srcRect used by maprect
MINRECT EQU DSTRECT-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-1 ;BYTE set if crsr is shielded (to screen)
MMUSave EQU CRSRFLAG-1 ;BYTE MMU mode on entry to drawText
locMode EQU MMUSave-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
run32bit EQU saveHilite-1 ;byte flag to run 32 bit
VARSIZE EQU (((run32bit+1)/4)-1)*4 ;SIZE OF VARIABLES long aligned
FromDrText EQU $28468
ROMRSect EQU $2C6D4
RomIterate EQU $281AA
cmpRA FromDrText,(sp) ; is this called from DrText?
beq.s @doDrTextPatch ; yes, go fix the patch
jmpROM ROMRSect ; call back to the ROM
@doDrTextPatch
ADDQ #4, sp ; Pop off return addr and come back here
jsrROM ROMRSect ; call back to the ROM
;---------------------------------------------------------------------------------------
; < BELOW COPIED VERBATIM FROM THE ROM UNTIL FURTHER NOTICE >
;
BEQ GOHOME ;QUIT IF NO INTERSECTION
MOVE (SP)+,textR2+right(A6) ;restore text right
;
; Test to see if spline:
; If spline set up clipping variables
;
;
; 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.B fmOutItalic(A4) ;TEST BOLD $$$
BNE NOTFAST ;NOT FAST UNLESS BOTH ZERO
TST.B fmOutBold(A4) ;TEST BOLD
BNE NOTFAST ;NOT FAST
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
cmp #16,dstPix+pixelType(A6) ;is it a direct device? @@@@ BAL 16Jun88
bne.s @modeok
seq textCopyMode(a6) ;yes, can't go fast for now @@@@ BAL 16Jun88
clr locmode(a6) ;this essentially alters mode to srcCopy
bra NotFast
@modeok MOVE.L VISRGN(A3),A1 ;GET VISRGN HANDLE
MOVE.L (A1),A0 ;DE-REFERENCE IT
CMP #10,RGNSIZE(A0) ;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
MOVE.W #-1,-(SP) ;pass Trim = True
_TRIMRECT ;CALL TRIMRECT
BLT 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 #nuRBMask,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
TST.B CRSRFLAG(A6) ;IS DST TO A SCREEN? <BAL 19Sep88>
BEQ GETPTRS ;=>NO
PEA MINRECT(A6) ;PUSH SHIELD RECT
MOVE.L REALBOUNDS(A6),-(SP) ;PUSH DELTA FOR GLOBAL
_SHIELDCURSOR ;HIDE CURSOR IF IT INTERSECTS
;-----------------------------------------------------------
;
; Clean pointers and then
; Switch to 32 bit addressing mode
;
MOVE.L SRCADDR(A6),d0 ;get 24 bit base addr
_Translate24To32 ;mask off high byte BAL/MCF 03Dec88
MOVE.L d0,SRCADDR(A6) ;SAVE FOR LATER
move.l a2,d0 ;get FontPtr
_Translate24To32 ;mask off high byte BAL/MCF 03Dec88
move.l d0,a2 ;clean font ptr
@setMMUMode
MOVE stackOffset(A6),D1
MOVE.L TEXTADDR(A6,D1),D0 ;GET TEXTPTR
_Translate24To32 ;mask off high byte BAL/MCF 03Dec88
MOVE.L d0,TEXTADDR(A6,D1) ;SAVE FOR LATER
moveq #true32b,d0 ;switch to 32 bit addressing
move.l a2,-(sp) ;save FontPtr
_rSwapMMUMode ;get previous mode in d0.b (can trash a0/a1/a2, d0/d1/d2)
move.l (sp)+,a2 ;restore FontPtr
move.b d0,MMUsave(a6) ;save previous state for later
MOVE.B #1, run32bit(A6) ; Set flag to state running 32 bit clean
BRA GETPTRS
NOTSCREEN
;
; Slow case: Setup for an off-screen buffer.
;
; Calc bufLeft: (LONG-align to avoid shift)
;
NOTFAST SF FASTFLAG(A6) ;NOT GOING DIRECTLY TO SCREEN
SF CRSRFLAG(A6) ;CRSR HAS NOT BEEN SHIELDED <BAL 19Sep88>
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 count(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,count(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
;
; < ABOVE COPIED VERBATIM FROM THE ROM >
;---------------------------------------------------------------------------------------
; JMP Iterate ;draw first half of string
JMPRom RomIterate ;
;---------------------------------------------------------------------------------------
; < BELOW COPIED VERBATIM FROM THE ROM >
;
; 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 count(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,count(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 ;get a long of white
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.l (SP),D0 ;or in result of color2Index <BAL 04July88>
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
MOVE penLocHFrac(A6),CHARLOC+2(A6) ;set up fractional part <PB362> BAL
BRA.S @goOn
@useOld
MOVE #$8000,CHARLOC+2(A6)
@goOn
SUB D1,MINRECT+LEFT(A6) ;MAKE MINRECT.LEFT AND
SUB D1,MINRECT+RIGHT(A6) ;MINRECT.RIGHT BUFFER RELATIVE
MOVE stackOffset(A6),D0
MOVE.L TEXTADDR(A6,D0),A1 ;GET TEXTPTR
BRA.S NEXTCH ;GO TO LOOP START
;---------------------------------------------------
;
; Here's the main character drawing loop:
;
MISSING
MOVE MAXMIN(A6),D0 ;NO, USE MISSING SYMBOL
ADD #1,D0 ;WHICH IS ONE PAST MAXCHAR
MOVE.L WIDTAB(A6),A0 ;POINT TO WIDTH TABLE
MOVE 0(A0,D0*2),D3 ;GET OFFSET AND WIDTH BYTES
CMP #-1,D3 ;missing?
BNE NOTMISS ;IS MISSING CHAR MISSING ?
BRA.S NEXTCH ;YES, SKIP THIS CHAR
SPACECH MOVE.L SPWIDTH(A6),D1 ;GET SPACE WIDTH
ADD.L D1,CHARLOC(A6) ;BUMP CHARLOC
SKIPCH SUB #1,charsRemain(A6) ;decrement total character count
SUB #1,countCopy(A6) ;decrement partial draw character count
BLE STRDONE ;QUIT IF CHARCOUNT <= 0
NEXTCH CLR D0 ;get ready for byte
MOVE.B (A1)+,D0 ;GET NEXT CHAR
CMP.B #32,D0 ;IS IT A SPACE ?
BEQ.S SPACECH ;YES, HANDLE IT
MOVE.L WidthTabHandle,A0 ;POINT TO WIDTH TABLE
MOVE.L (A0),A0
MOVE D0,D4 ;COPY CHARACTER
MOVE.L 0(A0,D4*4),D4 ;GET FIXED POINT WIDTH
ADD.L characterExtra(A6),D4 ;add in character extra, if any
;
; < ABOVE COPIED VERBATIM FROM THE ROM >
;
;---------------------------------------------------------------------------------------
;
; BLE.S SKIPCH ;SKIP CharBlt if Advance width <= 0 <1.6-11april89-CEL>
;
;---------------------------------------------------------------------------------------
;
; < BELOW COPIED VERBATIM FROM THE ROM UNTIL FURTHER NOTICE >
;
SUB MINCH(A6),D0 ;SUBTRACT SAVED MINCHAR
CMP MAXMIN(A6),D0 ;IS CH BETWEEN MINCHAR AND MAXCHAR ?
BHI MISSING ;Missing so skip it
OKCHAR MOVE.L WIDTAB(A6),A0 ;POINT TO WIDTH TABLE
MOVE 0(A0,D0*2),D3 ;GET OFFSET AND WIDTH BYTES
CMP #-1,D3 ;missing?
BEQ MISSING ;OFFSET NEG = MISSING CHAR
NOTMISS LSR #8,D3 ;GET OFFSET BYTE
ADD.W CHARLOC(A6),D3 ;DSTLEFT := CHARLOC.INT + OFFSET
ADD.L D4,CHARLOC(A6) ;ADD FIXED POINT WIDTH TO CHARLOC
MOVE.L LOCTAB(A6),A0 ;POINT TO LOCATION TABLE
MOVEQ #0,D1 ; *** clear top word
MOVE 0(A0,D0*2),D1 ;GET SRCLEFT
MOVE 2(A0,D0*2),D2 ;GET SRCRIGHT
SUB D1,D2 ;CALC WIDTH OF BITS
BLE SKIPCH ;SKIP CHARBLT IF WIDTH <= 0
MOVE D2,charWidth(A6) ;save for later
ADD D3,D2 ;DSTRIGHT := DSTLEFT + WIDTH
TST.B HEIGHTFLAG(A6) ;does font have height table ?
BEQ.S NOHEIGHT ;no, continue
MOVE.L HEIGHTAB(A6),A0 ;get height table
MOVE 0(A0,D0*2),TOPHT(A6) ;get this char's top and height
NOHEIGHT
;-----------------------------------------------------------------------
;
; Horizontal clip only if FastFlag: (else stretch,outline,shadow,italic die)
;
; skip if hidden on left, string done if hidden on right.
;
; at this point: D1: srcLeft
; D2: dstRight
; D3: dstLeft
;
TST.B FastFlag(A6) ;ARE WE GOING FAST ?
BEQ.S HORIZOK ;NO, DON'T CLIP
CMP MINRECT+LEFT(A6),D3 ;IS DSTLEFT < MINRECT.LEFT ?
BGE.S LEFTOK ;NO, CONTINUE
CMP MINRECT+LEFT(A6),D2 ;IS DSTRIGHT <= MINRECT.LEFT ?
BLE SKIPCH ;YES, SKIP THIS CHAR
TRIMLFT MOVE MINRECT+LEFT(A6),D0 ;NO, GET MINRECT.LEFT
SUB D3,D0 ;DISCARD:=MINRECT.LEFT-DSTLEFT
ADD D0,D1 ;SRCLEFT:=SRCLEFT+DISCARD
ADD D0,D3 ;DSTLEFT:=DSTLEFT+DISCARD
CMP MINRECT+RIGHT(A6),D2 ;IS DSTRIGHT > MINRECT.RIGHT ?
BLE.S fixCharWidth ;NO, CONTINUE
BRA.S TRIMRT ;YES, TRIM RIGHT
LEFTOK CMP MINRECT+RIGHT(A6),D2 ;IS DSTRIGHT <= MINRECT.RIGHT ?
BLE.S HORIZOK ;YES, CONTINUE
CMP MINRECT+RIGHT(A6),D3 ;IS DSTLEFT >= MINRECT.RIGHT ?
BGE STRDONE ;YES, IGNORE REST OF STRING
TRIMRT MOVE MINRECT+RIGHT(A6),D2 ;NO, TRIM DSTRIGHT
fixCharWidth
MOVE D2,D0 ;char width has been trimmed left, right, or both
SUB D3,D0 ;so recalculate char width to draw
MOVE D0,charWidth(A6) ;and save this tidbit of info. for later
HORIZOK
;--------------------------------------------------------------
;
; Inputs to local block CharBlt:
;
; srcAddr(A6)
; srcRow(A6)
; bufStart(A6) = dstAddr
; bufRow(A6) = dstRow
; D1 = srcLeft
; D2 = dstRight relative to buffer, > dstLeft
; D3 = dstLeft relative to buffer
; TOPHT(A6) top and height
;
; CLOBBERS: D0,D1,D2,D3,D4,D5,D6,D7,A0,A2,A3,A4,A5
; PRESERVES: A1,A6,A7
;
;
; Setup shift count in D5 (relative shift between src and dst)
;
MOVEM D1-D3,maskBlts(A6)
MOVE.B textCopyMode(A6),orNotOK(A6) ;if copy or if mask mode, do bit moves instead of OR
ST notMaskPass(A6) ;use the bitDepth this pass
MOVE bitShift(A6),D0 ;get font scale factor
LSL D0,D1
LSL D0,D2
LSL D0,D3 ;scale up all three
MOVE BUFROW(A6),A3
MOVEM.L SRCROW(A6),A2/A4-A5 ;srcRow, srcAddr (src bitmap), bufStart (dst bitmap)
maskBlt
;
; Get char height into D7
;
MOVE.W #255,D7 ;GET -1 BYTE, CLEAR HI BYTE
ADD.B TOPHT+1(A6),D7 ;CALC HEIGHT-1 FOR DBRA LOOP
BMI SKIPCH ;OOPS HEIGHT WAS ZERO !
;
; Adjust srcPtr and dstPtr for charTop
;
MOVEQ #0,D0 ;get ready for byte
MOVE.B TOPHT(A6),D0 ;get char top
MOVE.L A2,D4 ;get srcRow in D-reg
MULU.L D0,D4 ;calc charTop * srcRow
ADD.L D4,A4 ;add to srcPtr
MOVE A3,D4 ;get dstRow in D-reg
MULU D0,D4 ;calc charTop * dstRow
ADD.L D4,A5 ;add to dstPtr
;
; figure alignment offset in source so that dest is long aligned
;
MOVEQ #$1F,D0 ;get a 5 bit mask, needed later
MOVE.L D1,D5
;
; Setup dstPtr in A5, address of leftmost dst word
;
MOVE D3,D6 ;GET A COPY OF DSTLEFT
ASR #5,D6 ;CONVERT FROM DOTS TO LONGS
MOVE D6,D4 ;copy dest left in longs for later
LSL #2,D6 ;quad for bytes
ADD D6,A5 ;move dest pointer to top of character
;
; figure number of longs to move
;
MOVE D2,D6 ;copy dstRight
ASR #5,D6
SUB D4,D6 ;if same, it fits into a single long
BEQ fitsInLong ;most 1 bit deep characters fit into a long
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
;
; Character spans long in destination, so it must be moved in pieces
; Registers used at this point:
; D0 = 5 bit mask D1 = src offset D2 = dstRight D3 = dstLeft
; D4 = -- D5 = src offset D6 = longs to move D7 = character height
; A0 = -- A1 = character ptr A2 = source row sz A3 = dest row size
; A4 = source row ptr A5 = dest row ptr A6 = locals A7 = stack
NEG D3 ;negate for bit counting
AND D0,D3 ;get bottom 5 bits of dstLeft
BNE.S @skip32
MOVEQ #32,D3 ;if 0, make it 32
@skip32
MOVE D6,D4 ;total longs (not including left part)
LSL #2,D4 ;make it a byte count
SUB D4,A2 ;adjust source bump count
SUB D4,A3 ;adjust dest. bump count
SUBQ #1,D6 ;number of whole longs, less left & right parts
ADD D3,D1 ;the right hand start
MOVEQ #32,D4
SUB.L D4,D1
;
; if not 1 bit font & mode is not srcOr, do moves instead
;
TST.B orNotOK(A6)
BNE.S DoMove
;
; OR words to the screen; set up right mask
;
AND D0,D2 ;get bottom 5 bits of dstRight
MOVEQ #1,D4
ROR.L #1,D4 ;set the high bit
ASR.L D2,D4 ;$80000000 to $FFFFFFFF
ASL.L #1,D4 ;$00000000 to $FFFFFFFE
MOVE D6,D2 ;initialize whole long count
MOVE D6,A0 ;save long count for later
MOVE.L D5,D6
ADD D3,D6
MOVEQ #32,D0
SUB.L D0,D6
;
; Slow loop only taken in wierd cases where dst wider than a long.
; Or the more common case that the font is more than 1 bit deep
;
MAIN1
BFEXTU (A4){D5:D3},D0 ;GET SRC FROM BITMAP
BRA.S @checkLong ;see if there is some number of longs to do
@main2
BFEXTU (A4){D6:0},D0 ;GET SRC FROM BITMAP
@checkLong
OR.L D0,(A5)+ ;OR SRC INTO DST
ADDQ #4,A4 ;BUMP SRCPTR RIGHT
DBRA D2,@main2 ;LOOP TILL LAST long
BFEXTU (A4){D1:0},D0 ;GET SRC FROM BITMAP
AND.L D4,D0
OR.L D0,(A5) ;OR SRC INTO DST
ADD.L A2,A4 ;BUMP TO NEXT ROW
ADD.L A3,A5 ;BUMP DST TO NEXT ROW
WIDE1 MOVE A0,D2 ;GET long count
DBRA D7,MAIN1 ;LOOP ALL ROWS
BRA decCount ;skip mask blt part
;
; Handle case of drawing into the offscreen bit map in color separately
;
DoMove
MOVE D2,D4 ;copy dstRight
AND D0,D4 ;get bottom 5 bits of dstRight
MOVE D6,longCount(A6) ;save # of whole longs
MOVE D6,D2 ;set up first loop count
MOVE.L bkCol(A6),D6 ;get a long full of the background color
BFEXTU D6{0:D3},D0 ;background color & left mask
MOVE.L D0,leftBack(A6) ;save for quick compare
BFEXTU D6{0:D4},D0 ;background color & right mask
MOVE.L D0,rightBack(A6) ;right mask color compare
MOVE bitDepth(A6),D0 ;bits in a single pixel
BFEXTU D6{0:D0},D0 ;get a single pixel of the background color
MOVE D0,bkCol1(A6) ;a single background color for quick compare
MOVEQ #32,D6 ;
SUB D3,D6 ;
MOVE.L D5,A0
ADD D3,A0
SUB #32,A0 ;set up center move offset
;
; Slow loop taken in cases where dst wider than a long (common for fonts more than 1 bit
; deep.) Need to move only the pixels that are not colored same as background.
;
MoveLeft
BFEXTU (A5){D6:D3},D0 ;get current background of destination
CMP.L leftBack(A6),D0 ;compare it against the background color AND leftMask
BNE.S leftOnePix ;if different, must move 1 pixel at a time
;
; Here the destination has only background color pixels, so the whole thing can be moved
;
BFEXTU (A4){D5:D3},D0 ;GET SRC FROM BITMAP
BFINS D0,(A5){D6:D3}
checkLong
EXG A0,D5 ;set up center move offset
midChkLong
ADDQ #4,A5 ;bump destination
BRA.S checkMLong ;see if there is some number of longs to do
MoveMid
MOVE.L bkCol(A6),D0
CMP.L (A5),D0 ;same as background color?
BNE.S midOnePix ;if different, move 1 at a time
BFEXTU (A4){D5:0},D0 ;GET SRC FROM BITMAP
MOVE.L D0,(A5)+ ;OR SRC INTO DST
checkMLong
ADDQ #4,A4 ;BUMP SRCPTR RIGHT
DBRA D2,MoveMid ;LOOP TILL LAST WORD
MoveRight
EXG A0,D5 ;set up left move offset
TST D4
BEQ.S nextRow
BFEXTU (A5){0:D4},D0 ;look at the destination
CMP.L rightBack(A6),D0 ;compare it against the background AND rightMask
BNE.S rightOnePix ;if different, must move 1 pixel at a time
;
; Here the destination has only background color pixels, so the whole thing can be moved
;
BFEXTU (A4){D1:D4},D0 ;get the right part of the character
BFINS D0,(A5){0:D4} ;move it to the destination
nextRow
ADD.L A2,A4 ;BUMP TO NEXT ROW
ADD.L A3,A5 ;BUMP DST TO NEXT ROW
offMove
MOVE longCount(A6),D2 ;GET long count
DBRA D7,MoveLeft ;LOOP ALL ROWS
BRA checkMask
;
; need to move only the pixels that are not colored same as background
;
leftOnePix
MOVEM.L D1/D3-D6,-(SP) ;save temporary registers
MOVEM bkCol1(A6),D0/D1 ;D0 = back color D1 = pixel width
@nxtPixel
BFEXTU (A4){D5:D1},D4 ;pick up a source pixel
CMP D4,D0 ;is it the same as the back color?
BEQ.S @skipInsert ;if so, donÕt add to destination
BFINS D4,(A5){D6:D1} ;if not, copy it to the destination
@skipInsert
ADD.L D1,D5 ;move to next source pixel
ADD D1,D6 ;move to next destination pixel
SUB D1,D3 ;decrement count
BGT.S @nxtPixel ;do until weÕre done
MOVEM.L (SP)+,D1/D3-D6 ;restore bkCol, left & right widths, src & dest offsets
BRA.S checkLong
midOnePix
MOVEQ #32,D0 ;full long size in bits
MOVEM.L D1/D3-D6,-(SP) ;save temporary registers
MOVEQ #0,D6
MOVEM bkCol1(A6),D1/D3 ;D1 = back color D3 = pixel width
@nxtPixel
BFEXTU (A4){D5:D3},D4 ;pick up a source pixel
CMP D4,D1 ;is it the same as the back color?
BEQ.S @skipInsert ;if so, donÕt add to destination
BFINS D4,(A5){D6:D3} ;if not, copy it to the destination
@skipInsert
ADD.L D3,D5 ;move to next source pixel
ADD D3,D6 ;move to next destination pixel
SUB D3,D0 ;decrement count
BGT.S @nxtPixel ;do until weÕre done
MOVEM.L (SP)+,D1/D3-D6 ;restore bkCol, left & right widths, src & dest offsets
BRA midChkLong
rightOnePix
MOVEM.L D1/D3-D6,-(SP) ;save temporary registers
MOVEQ #0,D6
MOVEM bkCol1(A6),D3/D5 ;D3 = back color D5 = pixel width
@nxtPixel
BFEXTU (A4){D1:D5},D0 ;pick up a source pixel
CMP D0,D3 ;is it the same as the back color?
BEQ.S @skipInsert ;if so, donÕt add to destination
BFINS D0,(A5){D6:D5} ;if not, copy it to the destination
@skipInsert
ADD.L D5,D1 ;move to next source pixel
ADD D5,D6 ;move to next destination pixel
SUB D5,D4 ;decrement count
BGT.S @nxtPixel ;do until weÕre done
MOVEM.L (SP)+,D1/D3-D6 ;restore bkCol, left & right widths, src & dest offsets
BRA nextRow
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; Here, the character does not cross a long boundary, so faster loops are in order.
;
fitsInLong
MOVE charWidth(A6),D3 ;set up character width in bits
TST.B notMaskPass(A6) ;if dest is 1 bit, or this is the mask,
BEQ.S @skipMul ;then skip the mul scale
MOVE bitShift(A6),D4 ;set up bit depth
LSL D4,D3
@skipMul
TST.B orNotOK(A6) ;can we OR?
BNE.S offLong ;if not, bit extract/insert instead
;
; Optimize if dst fits in one long. (most 1 bit deep characters do)
;
LONG1
;
; OR words to the screen; set up right mask
MOVE D2,D1 ;copy dest right
NEG D1 ;figure not bits from left but bits from right
AND D0,D1 ;but only from 0 to 31
ADD D1,D3 ;add right mask to extract width
AND D0,D2 ;get bottom 5 bits of dstRight
MOVEQ #1,D4
ROR.L #1,D4 ;set the high bit
ASR.L D2,D4 ;$80000000 to $FFFFFFFF
ASL.L #1,D4 ;$00000000 to $FFFFFFFE
; if D5 + D3 < 32, use a faster set of code:
longLoop
BFEXTU (A4){D5:D3},D0 ;GET SRC DATA
AND.L D4,D0
OR.L D0,(A5) ;OR RESULT INTO DST
ADD.L A2,A4 ;BUMP SRCPTR TO NEXT ROW
ADD.L A3,A5 ;BUMP DSTPTR TO NEXT ROW
DBRA D7,longLoop ;LOOP ALL ROWS
BRA.S decCount
;
; Optimize if dst fits in one long. (most normal characters do)
;
offLong
MOVE D2,D6
AND.L D0,D6
SUB D3,D6
BFEXTU bkCol(A6){0:D3},D2
MOVEM.L D5/D6,leftOffset(A6) ;save source left, destination left offsets
MOVE D5,D0 ;source left offset less
ADD D3,D0 ; width of pixels to be moved
MOVE D0,longCount(A6) ; determines inner loop bounds
MOVE bitDepth(A6),D4 ;get source depth
BFEXTU D2{0:D4},D1 ;set up 1 pixel of background color
offLongLoop
; check to see if existing destination is untouched (equal to background) so that there is no
; concern about obliterating over a part of a character that kerns into this space.
BFEXTU (A5){D6:D3},D0 ;get the existing background
CMP.L D2,D0 ;is it background colored?
BEQ.S @okToBlast ;if so, it is safe to cut and fill
; inner loop taken if some kerning has occured so that bits can not be moved directly over bkground
@nxtPixel
BFEXTU (A4){D5:D4},D0
CMP D0,D1
BEQ.S @skipInsert
BFINS D0,(A5){D6:D4}
@skipInsert
ADD D4,D6
ADD D4,D5
CMP longCount(A6),D5 ;where to stop with the mask
BLT.S @nxtPixel
MOVEM.L leftOffset(A6),D5/D6 ;restore source left, destination left offsets
BRA.S @nextRow
; if no kerning, data can be moved without concern for what is already there.
@okToBlast
BFEXTU (A4){D5:D3},D0 ;GET SRC DATA
BFINS D0,(A5){D6:D3} ;move to destination
@nextRow
ADD.L A2,A4 ;BUMP SRCPTR TO NEXT ROW
ADD.L A3,A5 ;BUMP DSTPTR TO NEXT ROW
DBRA D7,offLongLoop ;LOOP ALL ROWS
;
; here, set up things for mask blt
;
checkMask
TST bitShift(A6) ;is source depth 1?
BEQ.S decCount ;if so, skip mask (just copy result to mask later)
TST.B maskFont(A6)
BEQ.S decCount
SF orNotOK(A6) ;next time through, can OR the mask
SF notMaskPass(A6) ;force bitDepth to 1 this pass
MOVEM maskBlts(A6),D1-D3/A3 ;set up words
MOVEM.L mSrcROW(A6),A2/A4/A5 ;set up longs
BRA maskBlt ;then blt mask
decCount
SUB #1,charsRemain(A6) ;decrement total character count
SUB #1,countCopy(A6) ;decrement partial draw character count
BGT NEXTCH ;LOOP IF MORE CHARS LEFT
;------
STRDONE MOVE.L SAVEA5(A6),A5 ;RESTORE GLOBAL PTR
TST.B FASTFLAG(A6) ;WERE WE GOING DIRECT TO SCREEN ?
BEQ.S @1 ;NO, CONTINUE
TST.B CRSRFLAG(A6) ;DRAWING TO SCREEN?
BEQ.S @0 ;=>IF NOT, JUST RETURN
move.b MMUsave(a6),d0 ;get previous MMU state in d0
_rSwapMMUMode ;get previous mode in d0.b (can trash a0/a1/a2, d0/d1/d2)
@32bitNot
_SHOWCURSOR ;YES, RESTORE CURSOR
@0 BRA GOHOME ;AND QUIT
@1 MOVE.L GRAFGLOBALS(A5),A0 ;POINT TO QUICKDRAW GLOBALS
MOVE.L THEPORT(A0),A3 ;GET CURRENT GRAFPORT
MOVE.L FONTPTR(A0),A4 ;POINT TO FMOUTPUT
MOVE.L 2(A4),A2 ;GET FONT HANDLE
MOVE.L (A2),A2 ;DE-REFERENCE IT
MOVE CHARLOC(A6),D7 ;GET FINAL CHARLOC INT PART
SUB fKernMax(A2),D7 ;UN-ADJUST FROM KERNING, but not italic
;
; Make buffer bold if necessary:
;
CKBOLD CLR D2 ;GET READY FOR BYTE
MOVE.B 6(A4),D2 ;GET NUMBER OF OVERSTRIKES
BRA.S NXTBOLD ;BOLD BUFFER IF ANY
BOLDIT MOVE.L BUFSTART(A6),A0 ;POINT TO START OF BUFFER
MOVE BUFSIZE(A6),D1 ;HOW MANY LONGS IN BUF
SUB D0,D0 ;CLEAR X-BIT
BOLDLP MOVE.L (A0),D0 ;GET ONE LONG
ROXR.L #1,D0 ;ROTATE RIGHT WITH EXTEND
OR.L D0,(A0)+ ;OR BACK INTO BUFFER
DBRA D1,BOLDLP ;LOOP ENTIRE BUFFER
NXTBOLD DBRA D2,BOLDIT ;LOOP FOR EACH OVERSTRIKE
;
; Slant the buffer if necessary:
; Work from bottom of buffer up, shifting each row right.
; Work right to left to avoid clobbering src.
;
MOVEQ #0,D2 ;GET READY FOR BYTE
MOVE.B 7(A4),D2 ;DO WE NEED ITALIC ?
BEQ.S CHECKUL ;NO, CONTINUE
MOVE.L BUFEND(A6),A1 ;DSTPTR:=END OF BUFFER
MOVE BUFROW(A6),D3 ;GET BUFFER ROWBYTES
SUB D3,A1 ;BACK UP DSTPTR TO END OF 2ND ROW
LSR #2,D3 ;LONGCNT:=ROWBYTES DIV 4
SUB #1,D3 ;LONGCOUNT-1 FOR DBRA LOOP
MOVE HEIGHT(A6),D6 ;INIT ROW COUNTER
MOVEQ #0,D4 ;INIT OFFSET
BRA.S DOSLANT ;GO TO LOOP START
NXTROW ADD.L D2,D4 ;OFFSET:=OFFSET+ITALIC
MOVE.L D4,D5 ;COPY OFFSET
LSR.L #4,D5 ;DELTA := OFFSET SCALED BY 16
NEG.L D5 ;make negative for BFEXTU
MOVE.L A1,A0 ;SRCPTR:=DSTPTR
SUB #4,A0 ;POINT TO LAST LONG
MOVE D3,D1 ;INIT LOOP TO LONGCNT
NXTLONG BFEXTU (A0){D5:0},D0 ;GET A SHIFTED LONG OF SRC
SUB #4,A0 ;BUMP SRCPTR LEFT ONE LONG
MOVE.L D0,-(A1) ;STORE IN DST AND BUMP DSTPTR
DBRA D1,NXTLONG ;LOOP ALL LONG THIS ROW
DOSLANT DBRA D6,NXTROW ;LOOP FOR ALL ROWS IN BUFFER
;
; Underline characters in buffer if necessary.
;
; Use characters in buffer to hide parts of the underline.
;
CHECKUL TST.B 10(A4) ;IS ULTHICK ZERO ?
BEQ.S NOTUL ;YES, CONTINUE
MOVE.L BUFSTART(A6),A0 ;POINT TO BUFFER START
MOVE BUFROW(A6),D1 ;GET BYTES PER ROW OF BUFFER
MOVE locASCENT(A2),D0 ;GET ASCENT
MOVE locDESCENT(A2),D2 ;GET DESCENT
MULU D1,D0
ADD.L D0,A0 ;POINT TO BASELINE ROW
MOVE.L A0,A1
MOVE.L A0,A2
ADD D1,A1 ;POINT TO BASELINE+1
CMP #2,D2 ;IS DESCENT AT LEAST 2 ?
BLT.S NOTUL ;NO, SKIP UNDERLINE
BEQ.S ONLY2 ;ONLY USE 2 IF DESCENT=2
ADD D1,A2
ADD D1,A2 ;POINT TO BASELINE+2
ONLY2 SUB D1,SP ;ALLOCATE TEMP SCANBUF
MOVE.L A3,-(SP) ;SAVE GRAFPORT
LEA 4(SP),A3 ;POINT TO START OF TEMP
LSR #2,D1 ;CONVERT BYTES TO LONGS
SUB #1,D1 ;INIT DBRA LOOP COUNT
MOVE D1,D2 ;COPY LOOP COUNT
SUB D0,D0 ;CLEAR X-BIT
UL1 MOVE.L (A0)+,D0 ;GET FROM BASELINE
OR.L (A1)+,D0 ;OR WITH BASELINE+1
OR.L (A2)+,D0 ;OR WITH BASELINE+2
MOVE.L D0,(A3) ;PUT RESULT TO TEMP
ROXR.L #1,D0 ;SHIFT WITH CARRY
OR.L D0,(A3)+ ;OR INTO TEMP
DBRA D1,UL1 ;LOOP ALL LONGS IN ROW
MOVE.L A1,A0 ;COPY END PTR
SUB D0,D0 ;CLEAR X-BIT
UL2 MOVE.L -(A3),D0 ;GET FROM TEMP
ROXL.L #1,D0 ;SHIFT LEFT WITH CARRY
OR.L (A3),D0 ;OR WITH TEMP
NOT.L D0 ;INVERT
OR.L D0,-(A1) ;DRAW SOME UNDERLINE
DBRA D2,UL2 ;LOOP ALL LONGS IN ROW
MOVE.L (SP)+,A3 ;RESTORE GRAFPORT
;
; Setup fakeRgn, a dummy rectangular region
;
NOTUL MOVE #10,FAKERGN+RGNSIZE(A6) ;SIZE=10 BYTES FOR RECT RGN
MOVE.L DSTPIX+BOUNDS(A6),FAKERGN+RGNBBOX(A6)
MOVE.L DSTPIX+BOUNDS+4(A6),FAKERGN+RGNBBOX+4(A6)
LEA FAKERGN(A6),A0 ;GET ADDR OF FAKERGN
MOVE.L A0,FAKEPTR(A6) ;POINT FAKE MASTERPTR TO IT
;
; SET UP SOURCE BITMAP TO TRANSFER TO SCREEN
;
; SRCPIX := buffer
;
LEA SRCBITS(A6),A0 ;POINT TO source bits
MOVE.L A0,A1
MOVE.L BUFSTART(A6),(A0)+ ;SET UP BASEADDR
MOVE BUFROW(A6),(A0)+ ;SET UP ROWBYTES
MOVE TEXTRECT+TOP(A6),(A0)+ ;SET UP BOUNDS TOP
MOVE BUFLEFT(A6),(A0)+ ;SET UP BOUNDS LEFT
MOVE.L TEXTRECT+BOTRIGHT(A6),(A0)+ ;SET UP BOTTOM RIGHT
LEA SRCPIX(A6),A2
_BitsToPix
TST.B maskFont(A6)
BEQ.S @finishSrcPix
LEA maskBits(A6),A0 ;POINT TO mask bits
MOVE.L maskStart(A6),(A0)+ ;SET UP BASEADDR
MOVE mBufRow(A6),(A0)+ ;SET UP ROWBYTES
MOVE TEXTRECT+TOP(A6),(A0)+ ;SET UP BOUNDS TOP
MOVE BUFLEFT(A6),(A0)+ ;SET UP BOUNDS LEFT
MOVE.L TEXTRECT+BOTRIGHT(A6),(A0)+ ;SET UP BOTTOM RIGHT
@finishSrcPix
TST bitShift(A6) ;is the bit depth 1?
BEQ.S @skipColorJam
MOVE bitDepth(A6),srcPix+pixelSize(A6) ;set up bit depth
MOVE.L dstPix+pmTable(A6),srcPix+pmTable(A6) ;set up color table
@skipColorJam
;
; check if any shadowing:
;
CLR D3 ;GET READY FOR BYTE
MOVE.B 11(A4),D3 ;GET SHADOW COUNT
BEQ NOSHAD ;SKIP IF NO SHADOWING
;
; Shadowing will be used. Allocate buf2, 4 scans taller than BUF1.
; Clear out new 4 scanlines, and copy BUF1 into the rest.
;
MOVE BUFROW(A6),D0 ;GET 4 * NUMBER OF LONGS PER ROW
SUB #1,D0 ;INIT LOOP COUNTER
CLR.L -(SP) ;ALLOW ONE LONG OF SLOP
MOVE.L SP,BUF2END(A6) ;REMEMBER END OF BUF2
CLR2 CLR.L -(SP) ;ALLOCATE AND CLEAR A LONG
DBRA D0,CLR2 ;CLEAR 4 SCANLINES WORTH
MOVE BUFSIZE(A6),D0 ;GET NUMBER OF LONGS IN BUF1
SUB #1,D0 ;INIT DBRA COUNTER
MOVE.L BUFEND(A6),A0 ;POINT TO END OF BUF1
COPYLP MOVE.L -(A0),-(SP) ;COPY FROM BUF1 TO NEW BUF2
DBRA D0,COPYLP ;COPY ALL OF BUF1
MOVE.L SP,BUF2START(A6) ;REMEMBER START OF BUF2
CLR.L -(SP) ;ALLOW ONE LONG OF SLOP
;
; Bold buf2 across to the right enough for shadow.
;
AND #3,D3 ;RESTRICT SHADOW COUNT TO 1..3
MOVE D3,D2 ;INIT BOLD COUNTER
ACROSS1 MOVE.L BUF2START(A6),A0 ;POINT TO START OF BUFFER2
MOVE BUFSIZE(A6),D1 ;INIT COUNT OF LONGS
SUB D0,D0 ;CLEAR X-BIT
ACROSS2 MOVE.L (A0),D0 ;GET A LONG FROM BUF2
ROXR.L #1,D0 ;SHIFT IT RIGHT EXTENDED
OR.L D0,(A0)+ ;OR IT BACK INTO BUFFER
DBRA D1,ACROSS2 ;LOOP FOR ALL LONGS
DBRA D2,ACROSS1 ;BOLD RIGHT 2,3, OR 4 TIMES
;
; Bold BUF2 down enough for shadow.
;
MOVE.L BUF2START(A6),A2 ;GET LIMIT POINTER
DOWN1 MOVE.L BUF2END(A6),A1 ;DSTPTR:=END OF BUF2
MOVE.L A1,A0
MOVE SRCBITS+ROWBYTES(A6),D2 ;GET SRC ROWBYTES
SUB D2,A0 ;SRCPTR:=END - 1 SCANLINE
DOWN2 MOVE.L -(A0),D0 ;GET A LONG FROM LINE ABOVE
OR.L D0,-(A1) ;OR INTO THIS LINE
CMP.L A2,A0 ;IS SRCPTR <= BUF2START ?
BGT.S DOWN2 ;NO, LOOP ALL LONGS
DBRA D3,DOWN1 ;BOLD DOWN 2,3, OR 4 TIMES
; XOR the plain text into the shadow buffer
MOVE bufSize(A6),D1 ;size of buffers in longs
MOVE.L bufStart(A6),A0 ;start of plain text
MOVE.L A2,A1 ;start of shadowed text
ADD D2,A1 ;bump down a line in the shadowed text
SUB D0,D0 ;clear x bit
@xor
MOVE.L (A0)+,D0 ;a line of plain text
ROXR.L #1,D0 ;shift it right, extended
EOR.L D0,(A1)+ ;combine with shadowed text
DBRA D1,@xor ;repeat for all longs
;
; Alter SRCBITS to use BUF2
;
MOVE.L A2,SRCBITS+BASEADDR(A6) ;SRC BASEADDR:=BUF2START
ADD #4,SRCBITS+BOUNDS+BOTTOM(A6) ;4 SCANS TALLER
;
; Push params and call StretchBits to transfer shadow to screen
;
MOVE.L TEXTRECT(A6),SRCRECT(A6) ;DSTRECT := SRCRECT
MOVE.L TEXTRECT+4(A6),SRCRECT+4(A6)
ADD #4,SRCRECT+BOTTOM(A6) ;PLUS 4 SCANS TALLER
MOVE.L SRCRECT(A6),DSTRECT(A6)
MOVE.L SRCRECT+4(A6),DSTRECT+4(A6)
LEA DSTRECT+TOP(A6),A0 ;OFFSET BY (-1,-1)
SUB #1,(A0)+ ;TOP
SUB #1,(A0)+ ;LEFT
SUB #1,(A0)+ ;BOTTOM
SUB #1,(A0)+ ;RIGHT
TST.B STRETCH(A6)
BEQ.S @1
PEA DSTRECT(A6)
PEA FROMRECT(A6)
PEA TORECT(A6)
_MAPRECT ;THEN MAPPED FOR SCALING
@1
PEA SRCBITS(A6) ;PUSH SRCPIX
MOVE.L maskBitsPtr(A6),-(SP) ;a mask?
BEQ.S @noMask
MOVE.L 4(SP),(SP) ;replace mask with copy of source
@noMask
PEA PORTBITS(A3) ;TRANSFER TO SCREEN
PEA SRCRECT(A6) ;PUSH SRCRECT = TEXTRECT
PEA SRCRECT(A6) ;maskRect same as source rect
PEA DSTRECT(A6) ;PUSH DSTRECT = TEXTR2
MOVE locMode(A6),-(SP) ;PUSH TEXTMODE
CLR.L -(SP) ;NO PATTERN FOR NOW
MOVE.L CLIPRGN(A3),-(SP) ;PUSH CLIPRGN HANDLE
MOVE.L VISRGN(A3),-(SP) ;PUSH VISRGN HANDLE
PEA FAKEPTR(A6) ;PUSH FAKE HANDLE
CLR -(SP) ;pass multicolor flag false
_StretchBits ;TRANSFER BUFFER TO SCREEN
; if old port, srcOr, draw center part in bic; if bic, in srcOr
; (This is done for compatibility with older applications like MacProject and MacDraw that
; expect to put text on an arbitrary background, relying on the center of the shadow to show.)
TST portBits+rowBytes(A3) ;a new port?
BMI.S GOHOME
MOVE locMode(A6),D0
CMP #srcOr,D0
BEQ.S @useBic
CMP #srcBic,D0
BNE.S GOHOME
@useBic
; restored altered srcBits
MOVE.L bufStart(A6),srcBits+baseAddr(A6)
SUB #4,srcBits+bounds+bottom(A6)
; adjust params for center portion StretchBits
CLR.L maskBitsPtr(A6) ;no mask
EOR #2,D0 ;change or to bic, bic to or
MOVE D0,locMode(A6) ;adjust textmode
;
; Push params and call StretchBits to transfer buffer to screen
;
NOSHAD
PEA SRCPIX(A6) ;PUSH SRCBITS
MOVE.L maskBitsPtr(A6),-(SP) ;may be 0 if no mask bitmap
PEA PORTBITS(A3) ;TRANSFER TO SCREEN
PEA TEXTRECT(A6) ;PUSH SRCRECT = TEXTRECT
PEA TEXTRECT(A6) ;maskRect same as source rect
PEA TEXTR2(A6) ;PUSH DSTRECT = TEXTR2
MOVE locMode(A6),-(SP) ;PUSH TEXTMODE
CLR.L -(SP) ;NO PATTERN FOR NOW
MOVE.L CLIPRGN(A3),-(SP) ;PUSH CLIPRGN HANDLE
MOVE.L VISRGN(A3),-(SP) ;PUSH VISRGN HANDLE
PEA FAKEPTR(A6) ;PUSH FAKE HANDLE
MOVE.B colorSource(A6),-(SP) ;pass multicolor flag true if source is multibit
_StretchBits ;TRANSFER BUFFER TO SCREEN
GOHOME
MOVE.L saveStk(A6),SP ;throw away the buffers
MOVE charsRemain(A6),D0
SUB countCopy(A6),D0
MOVE D0,charsRemain(A6) ;if iterative, this will be greater than zero
BGT secondHalf ;so there are more characters to draw
BSET #hiliteBit,HiliteMode ;reset hilite override, in case colormap was skipped
TST stackOffset(A6) ;was the stack aligned?
MOVEM.L (SP)+,D0-D7/A1-A4 ;RESTORE REGS
UNLK A6
BEQ.S @skipAlign
ADDQ #2,SP
@skipAlign
RTD #PARAMSIZE ;Return and pop the stack <1.6-11april89-CEL>
ENDPROC
;
; < ABOVE COPIED VERBATIM FROM THE ROM >
;
;---------------------------------------------------------------------------------------
ENDIF ; <6.0.5> <CEL>
;____________________________________________________________________________ dba <3.0>
; Menu manager patch
;
; The following patch fixes the head of InitProcMenu. The wrong version was
; rolled into the ROM, so we replace the head with this.
NewInitProcMenu proc export
ROMIMCommon equ $16D52 ; place to rejoin ROM in InitMenus
; the following code is copied out of the Menu Manager
move.l (sp)+,a0 ; get the return address
move.w (sp)+,d1 ; get the MBDF resource ID
move.l a0,-(sp) ; put return address back on the stack
jsrROM ROMIMCommon ; call InitMenus <4.0>
move.l MenuList,a0 ; get the menu list <4.0>
move.l (a0),a0 ; dereference the menu list <4.0>
move.w d1,mbResID(a0) ; store MBDF ID <4.0>
rts ; return to InitProcMenu caller <4.0>
endproc
; The following patch reinstates the WaitMouseUp in MenuSelect. It was removed as part
; of the tear-off menu stuff (in an attempt to support double-clicking in the menu bar),
; but that change was probably not a good idea, even for the tear-off menu case.
NewMenuSelect proc export
ROMContinueMenuSelect equ $171A2 ; place to rejoin ROM in MenuSelect
ROMDoneMenuSelect equ $17296 ; place to rejoin ROM in MenuSelect
; the following code is copied out of the Menu Manager
;-----------------------------------------------
; MenuSelect stack frame definitions
;-----------------------------------------------
STARTPT EQU 8 ; 1st parameter is 8, and is 4 bytes long
FUNCRESULT EQU 12 ; longword function result (menu,item)
ITEMRESULT EQU 14 ; item portion of funcResult
MENURECT EQU -8 ; rectangle (8 bytes)
MSavePort EQU MENURECT-4 ; saved grafPort
msLastMenu EQU MSavePort-2 ; how many menus are on the screen
DelayTicks EQU msLastMenu - 4 ; how long mouse in HItem
DragTicks EQU DelayTicks - 4 ; how long mouse moving towards HMenu
menuDelaySave EQU DragTicks - 1 ; store menuDelay from pRAM
menuDragSave EQU menuDelaySave - 1 ; store menuDrag from pRAM
lastFuncResult EQU menuDragSave - 2 ; funcResult last time thru MSLoop
lastItemResult EQU lastFuncResult - 2 ; itemResult last time thru MSLoop
firstMenuID EQU lastItemResult - 2 ; ID of REGULAR menu up
NewHMenuOffset EQU firstMenuID - 2 ; offset into MenuList of new HMenu
tRect1 EQU NewHMenuOffset - 8 ; temp rectangle
SelectFrame EQU tRect1 ; number of bytes to save
;-----------------------------------------------
link a6,#SelectFrame ; set up a stack frame
movem.l d2-d7/a2-a4,-(sp) ; save work registers
clr.w -(sp) ; push zero for this
_HiliteMenu ; make sure no menu is hilited
clr.l funcResult(a6) ; assume nothing will be selected
clr.l MenuDisable ; clear the low-memory location MenuDisable
clr.w -(sp) ; push zero for this
_WaitMouseUp ; is the mouse still down?
tst.b (sp)+ ; examine result
beq.s DoneMenuSelect ; if not still down, donÕt bother
jmpROM ROMContinueMenuSelect ; continue in ROM
DoneMenuSelect jmpROM ROMDoneMenuSelect ; continue in ROM
endproc
;____________________________________________________________________________ djw <3.6>
; Slot Manager pInitEntry patch
;
; Fixes a bug when calling _InsertSRTRec, inserting a ROM sRsrc with a valid
; refnum, pInitEntry is called. pInitEntry calls _sFindDevBase to calc a base
; addr to place in the DCE. The bug is _sFindDevBase is called with a bad
; sRsrc id. The fix is one line to restore the spId before calling
; _sFindDevBase.
;
pInitEntry Proc Export
With spBlock,srrBlock,SlotRsrcType
ROMpInitEntry Equ $00006904 ; addr to continue to in ROM
ROMpInitError Equ $0000691c ; addr of @Error label in ROM
ROMpInitDone Equ $00006920 ; addr of @Done label in ROM
ROMMapUnit Equ $00006930 ; addr of MapUnit routine in ROM
MOVEM.L D1/A2,-(SP) ; save regs
SUBA.W #SRSize,SP ; alloc size to read sRsrc sType field
MOVEA.L SP,A2 ; save A2 = ptr to buffer
; Fill in the fields of a new SRT entry
MOVE.B spSlot(A0),srrSlot(A1) ; slot number
MOVE.B spId(A0),srrId(A1) ; sRsrc id
MOVE.B spExtDev(A0),srrExtDev(A1) ; external device id
CLR.B srrHWDev(A1) ; clear hardware device id
MOVE.W spRefNum(A0),srrRefNum(A1) ; driver reference number
MOVE.W spIOReserved(A0),srrIOReserved(A1) ; IO reserved field (good for nothin?)
MOVE.L spsPointer(A0),srrsRsrcPtr(A1) ; set the ptr to the RAM or ROM sRsrc
CLR.L srrFlags(A1) ; clear flag field
MOVE.L spParamData(A0),D0 ; test state of enable/disable value
BEQ.S @ReadStuff ; zero - sRsrc is marked as enabled
BSET.B #srDisable,srrFlags+3(A1) ; set flag to indicate disabled
; Read the hardware sRsrc id
@ReadStuff MOVE.B #sRsrcHWDevId,spId(A0) ; get hardware id (if present)
_sReadByte ; no error if not present
BNE.S @Continue
MOVE.B spResult+3(A0),srrHWDev(A1) ; only a byte value
; Find and read the sRsrc type field <category><type><drvrSW><drveHW>
@Continue MOVE.B #sRsrcType,spId(A0) ; get ptr to sRsrc type
_sFindStruct
BNE.S @Error ; error - sRsrc type field is required
MOVE.L #SRSize,spSize(A0) ; set size to read
MOVE.L A2,spResult(A0) ; set buffer ptr
_sReadStruct
BNE.S @Error ; error - found but can't read ?
MOVE.L sCategory(A2),srrCategory(A1) ; copy <cat><type>
MOVE.L sDrvrSw(A2),srrDrvrSw(A1) ; copy <drvrSW><drvrHW>
; If there is a valid reference number, then find the DCE and calculate the dCtlDevBase
MOVEQ #0,D0 ; set a good return
MOVE.W spRefNum(A0),D1 ; get ref num
BEQ.S @Done ; no ref num - done
jsrROM ROMMapUnit ; return reg A2 = ptr to DCE
BNE.S @Error ; some error with ref num or DCE
; Read a 24 or 32 bit base address from the sResource
move.b srrId(a1),spId(a0) ; set spId of sRsrc to get base addr (the fix)
jmpROM ROMpInitEntry ; continue in ROM
; Jump points back into ROM
@Error jmpROM ROMpInitError ; jump to @Error label
@Done jmpROM ROMpInitDone ; jump to @Done label
EndProc
;____________________________________________________________________________ DAF <4.1>
; This patch really didn't get in until <5.1>
;
; SaveEntries Patch
;
; OK, I blew it on a patch roll-in from ROM78Fix into the Aurora ROM. In SaveEntries
; the a test was added for non-CLUT devices, but when I rolled it inline, I jumped
; back to the wrong place. This patch head patches the routine just like ROM78Fix
; so that it never hits the ROM routine if there is an error.
;
mySaveEntries PROC EXPORT
ROMSaveEntries EQU $3C920
MOVE.L ([theGDevice]),A0 ; get a pointer to the current device
CMP.W #CLUTType,GDType(A0) ; is it a clut device?
BNE.S SEDevErr ; nope, so report an error
JMPRom ROMSaveEntries ; OK, so execute normal saveEntries
SEDevErr
MOVE.W #cDevErr,QDErr ; post error code
RTD #12 ; and return
;____________________________________________________________________________
; SetEntries, dvb < 124 > 1991
; Mark bit 3 of QDSpare0 when the color environment changes, so pmgrexit
; only cleans up if bit was set for that layer.
mySetEntries PROC EXPORT
ROMSetEntries EQU $3C6C0
; Mark QDSpare that the color environment has changed, but only if
; QD exists
TST.B QDExist ; is QD around?
BNE.S @noQDE ; no, skip this next
MOVE.L (A5),A0
BSET #3,QDSpare0(A0) ; Tell PMgrExit to do color cleaning
@noQDE
JMPRom ROMSetEntries ; and on with our regularly scheduled program. < 124 >
;____________________________________________________________________________
; Script Manager patch to Pack6, fixes problem with pointer to unlocked
; handle in Transliterate. <4.3><08/21/89 pke>
; Also fixes another problem in LwrString, CharType, Transliterate, FindWord:
; These routines need to have the Script Manager IntlForce flag cleared
; before calling IUGetIntl (this flag must be saved beforehand and restored
; afterward). This ensures that the itl2 tables used by these routines apply
; to the current script. <4.5><08/21/89 pke>
; Only do the second fix for Scripts604 OR (SysVers > $604) <4.7><08/21/89 pke>
;
; This patch is not installed for A/UX, since A/UX doesn't support the Script
; Manager.
;
IF doScriptMgrPack6Fix AND (NOT installScriptMgrPtch39) THEN ; <42><50>
ptchPack6 PROC Export
fromROMLwrString EQU $0C0B2
fromROMCharType EQU $1D986
fromROMFindWord EQU $1DBE0
fromROMTranslit EQU $1DB34
toROMTranslit EQU $1DB3A
ROMPack6 EQU $262B2
tlRecord record {a6link},decr
result ds.w 1 ; function result.
tlArgs equ *-8 ; size of arguments.
srcHandle ds.l 1 ; srcHandle.
dstHandle ds.l 1 ; dstHandle.
target ds.w 1 ; target.
srcMask ds.l 1 ; srcMask.
selector ds.l 1 ; selector
return ds.l 1 ; return address.
a6link ds.l 1 ; old a6 register.
tlLocals equ * ; size of local variables.
endr