mac-rom/QuickDraw/CCrsrCore.a

370 lines
13 KiB
Plaintext
Raw Permalink Normal View History

;
; File: CCrsrCore.a
;
; Contains: system cursor/mouse routines. Contains the mouse interrupt receivers
; and cursor drawing and hiding routines.
;
; Written by: Bud Tribble 2-Oct-81
;
; Copyright: <09> 1981-1993 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <SM6> 9/12/93 SAM Changed all instances of _Translate24to32 to _rTranslate24to32
; so they can conditionalized out of the build.
; <SM5> 2/4/93 CSS Update from Horror:
; <H3> 7/13/92 djw <GED> Overpatched DrawCursor, EraseCursor and SetCrsrData,
; vectorizing them to allow access later.
; <SM4> 6/11/92 stb <sm 6/9/92>stb Add comments from QDciPatchROM.a to ShowCursor,
; SetCCursor
; <SM3> 5/16/92 kc Add forRom conditionals around last change.
; <SM2> 5/16/92 kc Roll in Horror. Comments follow:
; <H2> 2/12/92 SWC Patched out most of CrsrVBLTask since the new cursor
; acceleration code does things differently.
; <7> 7/10/91 dba end of the forPost70 conditional; we are past 7.0 for good
; <6> 5/31/91 KON Register A2 gets trashed when setting a color cursor and there
; is more than one GDevice.
; <5> 9/17/90 BG Removed <4>. 040s are now behaving more reliably.
; <4> 6/25/90 BG Added EclipseNOPs for flakey 040s.
; <3> 6/25/90 KON Obscure-show-hide leaves crsr hidden only, Obscure-hide-show
; leaves crsr obscured only.
; <2> 1/3/90 BAL Updated to latest local source version.
; <<3C>1.7> 7/14/89 BAL For Aurora: Final CQD
; <1.6> 6/10/89 CEL Moved Private.a QuickDraw Equates into proper QuickDraw private
; file (colorequ.a), got rid of QuickDraw nFiles dependencies and
; fixed up necessary files<65>
; <<3C>1.5> 5/29/89 BAL Blasting in 32-Bit QuickDraw version 1.0 Final
; 4/7/89 BAL Moved crsrVBLTask to head of file and scrnAddress to end of file
; for VM.
; 9/7/88 BAL Altered showCursor to clear crsrObscure if showing cursor.
; 6/28/88 BAL Use special 1 to 24 bit pixel expansion routine.
; 6/21/88 BAL Finally fixed SetCCursor; Needed to Lock input handle across
; routine.
; 3/25/88 BAL Altered Show/Hide Cursor to use 32 bit clean addresses.
; 3/23/88 BAL Fixed bug in CrsrRect.right for pixel depth > 1.
; <C944> 11/7/87 BAL Rolled in patches to SetCCursor to preserve A2.
; 5/27/87 EHB Added fix to SetCCursor for trashed A2
; <C856> 5/26/87 CSL Fixed absolute cursor positioning problem.
; 10/13/86 EHB Rolled in new version of CrsrVBLTask
; 10/13/86 EHB Added AllocCrsr; called by AllocCursor.
; 10/6/86 EHB Added SetCCursor; redid other routines to support color.
; 10/2/86 EHB Redid inner loop of ShowCursor for color support
; 7/14/86 EHB Don't draw cursor if CRSRPTR not set up.
; <C63> 7/2/86 EHB CLEAR D0 BEFORE CALLING EXTBL ROUTINES. Multiply offset amount
; by depth for left pinning Check 8 longs of cursor
; <C63> 7/2/86 EHB Include colorequ in great equate purge
; <C60> 6/30/86 EHB New ShowCursor/HideCursor for depth support Fixed branch bug in
; ShieldCursor
; <C28> 5/30/86 CSL Added changes for Aladdin, and Aladdin Front desk bus support.
; <C1> 5/6/86 RDC Added fixes in ShowCursor routine
; <C1> 4/15/86 RDC Added changes for new 68020 Reno project (NuMac) - Added include
; for newequ.text to get at low mem equates for screen vars -
; Added changes in Cursor routines to use low mem for screen
; values
; 2/19/86 BBM Made some modifications to work under MPW
;_______________________________________________________________________
;
; Before Lonely Hearts
;_______________________________________________________________________
; 11/5/85 JTC for ELR (on telephone) Fix loop termination condition in
; HideCursor that killed MacPaint, e.g.
; 7/25/85 RDC Added include for HWequ file
; 7/23/85 RDC Moved mouse interrupt routines to IntHnd.Text
; 4/23/85 JTC Change to PIN hotSpot between 0 and 16, not 15. <23Apr85>
; 4/5/85 JTC Fix discontinuity in PinGuts; mask hotSpot with $000F000F in
; SetCursor; add ScreenAddress and ScreenSize to SysDef traplist;
; fix 'changed' test in SetCursor. Punted on desired call to get
; Cursor ID ... see Change note for details.
; 8/20/83 LAK Just uses CrsrThresh for scaling params.
; 8/18/83 LAK Changed name of CrsrTask to CrsrVBLTask (but why?).
; 7/20/83 SC Cleaned up after code review
; 4/28/83 AJH moved PinRect into crsrCore
; 1/28/83 AJH made SetCursor display it if its different
; 1/23/83 LAK Adapted for new equate files.
; 1/13/83 SC Decouple and scaled Cursor stuff
; 11/7/82 AJH Made ObscureCursor unbusy cursor if already obscured
; 10/16/82 LAK Modified for new LisaGraf cursor interface
; 9/5/82 LAK IntHnd now handles ext/sts interrupt resetting
; 8/26/82 LAK updated for 512-dots
; 8/5/82 LAK modified for INTHND change (no need to modify A0-1 for SCC port
; A) or read status reg.
; 5/4/82 LAK Updated MV1INT, MH1INT for SCC hardware
; 4/9/82 AJH Changed SHOWCURSOR to clip ala Rick Meyer's Lisa routines
; 10/31/81 AJH Hardwired the CRSR task into the VBL manager
; 10/19/81 bmw fixed a bug andy found in getscreen
; 7/3/81 AJH Installed "ObscureCursror" entry point and support
;
BLANKS ON
STRING ASIS
MACHINE MC68020 ;<C60/30JUN86>
cursorShadow EQU 0
ShieldCursor PROC EXPORT
;---------------------------------------------------------
;
; PROCEDURE ShieldCursor(shieldRect: Rect; offset: Point);
;
; ALL REGS PRESERVED.
;
; Lifted from LCursor.a
;
IMPORT QDNew_OtherShieldCursor
MOVEM.L D0-D2/A0-A1,-(SP) ;SAVE REGS
MOVE.L 28(SP),D0
MOVE.L 24(SP),D1
MOVE.L D0,-(SP) ;PUSH GLOBAL TOP
MOVE.L D1,-(SP) ;PUSH GLOBAL LEFT
JSR QDNew_OtherShieldCursor
MOVEM.L (SP)+,D0-D2/A0-A1 ;RESTORE REGS
RTD #8
CRSRCORE PROC EXPORT
EXPORT InitCrTable
EXPORT PinRect
2017-10-08 15:26:23 +00:00
IMPORT _HideCursor
IMPORT _ShowCursor
IMPORT _ShieldCursor
IMPORT _ScrnAddress
IMPORT _ScrnSize
IMPORT _InitCursor
IMPORT _SetCursor
IMPORT _ObscureCursor
IMPORT AllocCrsr
2017-10-08 15:26:23 +00:00
IMPORT _SetCCursor
;
; offset table for jump table initialization
;
InitCrTable
2017-10-08 15:26:23 +00:00
DC.W _HideCursor-InitCrTable
DC.W _ShowCursor-InitCrTable
DC.W _ShieldCursor-InitCrTable
DC.W _ScrnAddress-InitCrTable
DC.W _ScrnSize-InitCrTable
DC.W _InitCursor-InitCrTable
DC.W _SetCursor-InitCrTable
DC.W _ObscureCursor-InitCrTable
DC.W AllocCrsr-InitCrTable
2017-10-08 15:26:23 +00:00
DC.W _SetCCursor-InitCrTable
;_______________________________________________________________________
; This routine is used by the pinrect routine below and is also called directly
; by CrsrVBLTask above to save time
; A0 should be pinning rect and D0 is the point to be pinned
; Fixed to avoid discontinuity on right and bottom. <05Apr85>
PinGuts
CMP LEFT(A0),D0 ;less than left?
BGE.S @1 ;if not, no problem
MOVE LEFT(A0),D0 ;pin to the left
@1 CMP RIGHT(A0),D0 ;greater than right?
BLT.S @2 ;if not, no problem WAS BLE!! <05Apr85>
MOVE RIGHT(A0),D0 ;pin to the right
SUBQ #1,D0 ;really want one less
@2 SWAP D0 ;consider y
CMP TOP(A0),D0 ;less than top?
BGE.S @3 ;if not, no problem
MOVE TOP(A0),D0 ;pin to the top
@3 CMP BOTTOM(A0),D0 ;greater than bottom?
BLT.S @4 ;if not, no problem WAS BLE!! <05Apr85>
MOVE BOTTOM(A0),D0 ;pin to the bottom
SUBQ #1,D0 ;really want one less
@4 SWAP D0
RTS
;
; Utility FUNCTION PinRect(theRect: Rect; thePt: Point): Point;
;
; given a rectangle and a point, pin the point inside the rectangle
;
PinRect
MOVE.L 4(SP),D0 ;get the point
MOVE.L 8(SP),A0 ;get the rect ptr
BSR.S PinGuts ; go pin it
MOVE.L (SP)+,A0 ;get return address
ADDQ #8,SP ;strip parameters
MOVE.L D0,(SP) ;return pinned pt as result
JMP (A0) ;return to caller
;_______________________________________________________________________
;
; HIDECURSOR - is called from CrsrVBLTask, and via jump table.
;
; Subtracts 1 from crsrstate and hides the cursor if visible.
;
;
2017-10-08 15:26:23 +00:00
_HideCursor PROC EXPORT
MOVEM.L D0-D2/A0-A1,-(SP)
IMPORT QDNEW_HIDECURSOR
JSR QDNEW_HIDECURSOR
MOVEM.L (SP)+,D0-D2/A0-A1
RTS
;_______________________________________________________________________
;
; SHOWCURSOR - Called from CrsrVBLTask and via Jump Table.
;
; Adds 1 to CRSRSTATE and paints cursor if zero and cursor is
; not already visible.
;
2017-10-08 15:26:23 +00:00
_ShowCursor PROC EXPORT
MOVEM.L D0-D2/A0-A1,-(SP)
IMPORT QDNEW_SHOWCURSOR
JSR QDNEW_SHOWCURSOR
MOVEM.L (SP)+,D0-D2/A0-A1
RTS
;_______________________________________________________________________
;
; CURSHIELD - Called via Jump Table
;
; PROCEDURE ShieldCursor(left,top,right,bottom: INTEGER);
;
; Subtracts 1 from CRSRSTATE, hides cursor only if it intersects SHIELDRECT.
; left,top,right bottom is the shieldRect in global coordinates
;
; ALL REGISTERS RESTORED.
;
2017-10-08 15:26:23 +00:00
_ShieldCursor PROC EXPORT
IMPORT QDNEW_SHIELDCURSOR
JMP QDNEW_SHIELDCURSOR
;_______________________________________________________________________
;
2017-10-08 15:26:23 +00:00
; PROCEDURE InitCursor;
;
; Definitely redisplay the cursor, independent of previous calls to
; HideCursor, ShieldCursor and ObscureCursor. It falls into showCursor.
;
2017-10-08 15:26:23 +00:00
_InitCursor PROC EXPORT
IMPORT QDNEW_INITCURSOR
JMP QDNEW_INITCURSOR
;_______________________________________________________________________
;
; PROCEDURE SetCursor(hotSpot: Point; height: INTEGER; data: Ptr; mask:Ptr);
;
; This procedure sets THECRSR pointer in the system global area.
; A reasonable hotSpot is ENFORCED! Also fix bug to note changed when only hotspot does. <05Apr85>
;
; WARNING: to save code, this routine really doesn't use the above interface.
; It ignores the height and mask parameters. It assumes that the mask immediately
; follows the data (as it does when called from LisaGraf)
;
2017-10-08 15:26:23 +00:00
_SetCursor PROC EXPORT
IMPORT QDNEW_SETCURSOR
JMP QDNEW_SETCURSOR
2017-10-08 15:26:23 +00:00
;_______________________________________________________________________
;
; PROCEDURE ObscureCursor -- called via the jump table
;
2017-10-08 15:26:23 +00:00
; Removes the cursor from the screen without hiding it, so the next
; time the mouse moves, it will show up again.
;
2017-10-08 15:26:23 +00:00
_ObscureCursor PROC EXPORT
IMPORT QDNEW_OBSCURECURSOR
JMP QDNEW_OBSCURECURSOR
;--------------------------------------------------
;
; PROCEDURE AllocCrsr;
;
; Allocates all global cursor data structures. A maximum depth of 8 is assumed.
;
AllocCrsr PROC EXPORT
2017-10-08 15:26:23 +00:00
IMPORT QDNEW_ALLOCCRSR
JMP QDNEW_ALLOCCRSR
;_______________________________________________________________________
;
2017-10-08 15:26:23 +00:00
; PROCEDURE SetCCursor(cCrsr: CCrsrHandle);
;
2017-10-08 15:26:23 +00:00
; This procedure copies the data in the specified color cursor into the
; system's cursor save area. If the depth > 2, it expands it.
;
2017-10-08 15:26:23 +00:00
_SetCCursor PROC EXPORT
IMPORT QDNEW_SETCCURSOR
JMP QDNEW_SETCCURSOR
;
;_______________________________________________________________________
;
; FUNCTION ScrnAddress:Ptr;
;
; return a pointer to the start of the bit-map display
;
2017-10-08 15:26:23 +00:00
_ScrnAddress PROC EXPORT
MOVE.L ScrnBase,4(SP) ;get screenBase set up by OS
RTS ;that was easy!
;
;_______________________________________________________________________
;
; PROCEDURE ScrnSize(VAR hDots,vDots: INTEGER);
;
; return the size of the screen in pixels
;
2017-10-08 15:26:23 +00:00
_ScrnSize PROC EXPORT
MOVE.L (SP)+,D0 ;get the return address
MOVE.L MainDevice,A0 ;get handle to main screen device
MOVE.L (A0),A0 ;point to main screen device
MOVE.L (SP)+,A1 ;get pointer to vDots
MOVE GDRect+bottom(A0),D1 ;get bottom
SUB GDRect+top(A0),D1 ;calc height
MOVE D1,(A1) ;return the number of vertical pixels
MOVE.L (SP)+,A1 ;get pointer to hdots
MOVE GDRect+right(A0),D1 ;get right
SUB GDRect+left(A0),D1 ;calc width
MOVE D1,(A1) ;return the number of horizontal pixels
MOVE.L D0,A0 ;get return address
JMP (A0) ;and return
;_______________________________________________________________________
;
; PROCEDURE ScrnBitMap(VAR x: BitMap);
;
; return the screen bitmap
;
ScrnBitMap PROC EXPORT
MOVE.L (SP)+,D0 ;get the return address
MOVE.L MainDevice,A0 ;get handle to main screen device
MOVE.L (A0),A0 ;point to main screen device
MOVE.L GDPMap(A0),A0 ;get handle to screen's pixMap
MOVE.L (A0),A0 ;point to screen's pixMap
MOVE.L (SP)+,A1 ;get pointer to BitMap
MOVE.L (A0)+,(A1)+ ;copy base addr
MOVE (A0)+,D1 ;get rowbytes
AND #nuRBMask,D1 ;mask flag bits
MOVE D1,(A1)+ ;copy rowbytes
MOVE.L (A0)+,(A1)+ ;copy bounds.topleft
MOVE.L (A0)+,(A1)+ ;copy bounds.botright
MOVE.L D0,A0 ;get return address
JMP (A0) ;and return