From b295a577131af32295fba885162fd0d8c153e225 Mon Sep 17 00:00:00 2001 From: Elliot Nunn Date: Mon, 9 Oct 2017 15:46:40 +0800 Subject: [PATCH] Clean QuickDraw lurkers Only three monolithic chunks of code to go! --- Interfaces/AIncludes/Processes.a | 3 +- Internal/Asm/ColorEqu.a | 4 +- QuickDraw/BitMaps.a | 22 +++++------ QuickDraw/CCrsrCore.a | 24 +++++++++++- QuickDraw/CheckDevicesINIT.a | 19 ++++++---- QuickDraw/ColorMgr.a | 2 +- QuickDraw/FastTraps.a | 1 + QuickDraw/GDevice.a | 2 + QuickDraw/GWorld.a | 8 ++-- QuickDraw/LCursor.a | 63 +++++++------------------------- QuickDraw/PaletteMgr.a | 8 ++-- QuickDraw/Patterns.a | 4 +- QuickDraw/Pictures.a | 2 +- QuickDraw/QDUtil.a | 4 +- QuickDraw/ScaleBlt.a | 2 +- 15 files changed, 79 insertions(+), 89 deletions(-) diff --git a/Interfaces/AIncludes/Processes.a b/Interfaces/AIncludes/Processes.a index ac3e08a..b31d444 100644 --- a/Interfaces/AIncludes/Processes.a +++ b/Interfaces/AIncludes/Processes.a @@ -202,7 +202,8 @@ processAppSpec EQU 56 MACRO _GetFrontProcess - PEA $FFFFFFFF + MOVEQ.L #$FFFFFFFF,D0 + MOVE.L D0,-(SP) MOVE.W #$39,-(SP) _OSDispatch ENDM diff --git a/Internal/Asm/ColorEqu.a b/Internal/Asm/ColorEqu.a index f85f05a..23e6656 100644 --- a/Internal/Asm/ColorEqu.a +++ b/Internal/Asm/ColorEqu.a @@ -266,7 +266,7 @@ PMFlag EQU $8000 ; flag to say it's a new pixMap cPortFlag EQU $C000 ; isPixMap+isCPort pixVersion EQU $0000 ; isPixMap -qdStackXtra EQU $0640 ; stack space left for interrupts <1.4> BAL +qdStackXtra EQU $0800 ; stack space left for interrupts <1.4> BAL isPixMap EQU 15 ; for testing high bit of pRowbytes isCPort EQU 14 ; indicates that "bitmap" belongs to port @@ -376,7 +376,7 @@ CCSTATEREGS EQU CCDEPTH+2 ;[16 BYTES] STATE INFO OF SAVED DATA CCBYTES EQU CCSTATEREGS+16 ;[WORD] ROWBYTES OF EXPANDED DATA CCMAXDEPTH EQU CCBYTES+2 ;[WORD] MAXIMUM SCREEN DEPTH -CCSAVEREC EQU CCMAXDEPTH+2 ;SIZE OF CURSOR SAVE AREA +CCSAVEREC EQU CCMAXDEPTH+2+8 ;SIZE OF CURSOR SAVE AREA ; Font Manager low mem ; diff --git a/QuickDraw/BitMaps.a b/QuickDraw/BitMaps.a index 8d2064f..eab2aba 100644 --- a/QuickDraw/BitMaps.a +++ b/QuickDraw/BitMaps.a @@ -1741,7 +1741,7 @@ DSTRECT EQU MASKRECT-4 ;long, addr of Rect MODE EQU DSTRECT-2 ;WORD MASKRGN EQU MODE-4 ;LONG, RGNHANDLE -VARSIZE EQU 0 +VARSIZE EQU -4 share LINK A6,#VARSIZE ;ALLOCATE STACK FRAME MOVEM.L D3-D7/A2-A4,-(SP) ;SAVE WORK REGISTERS FOR DEVLOOP @@ -1774,7 +1774,7 @@ share LINK A6,#VARSIZE ;ALLOCATE STACK FRAME PEA.L MASKRECT(A6) MOVE.L D3, -(SP) CLR.L -(SP) - MOVE #4,-(SP) + PEA 4 MOVE.L #$160000,D0 ;_QDExtensions -> _NewGWorld DC.W $AB1D MOVE (SP)+, D4 @@ -1822,7 +1822,7 @@ share LINK A6,#VARSIZE ;ALLOCATE STACK FRAME MOVEA.L $2(A3), A0 _HLock MOVE.L (A0), MASKBITS(A6) - MOVE.L #$160000,D0 ;_QDExtensions -> _NewGWorld + MOVE.L #$80005,D0 ;_QDExtensions -> _GetGWorld DC.W $AB1D @skip @@ -2416,7 +2416,7 @@ cutOutDevices cmp.l ctSeed(a0),d1 ;do the color tables seeds match ? beq @next - movem.l d1/a1,-(sp) ;save our scratch registers + movem.l d1/a1-a3,-(sp) ;save our scratch registers clr.b -(sp) ;make space for boolean result pea tempRect1(a6) ;pointer to the SrcRect in global coordinates @@ -2433,26 +2433,26 @@ cutOutDevices move.l pmTable(a0),a0 move.l (a0),a0 move.l (DeviceList),a2 - move.l (a2),a2 +@again move.l (a2),a2 move.l GDPMap(a2),a3 move.l (a3),a3 move.l pmTable(a3),a3 move.l (a3),a3 move.l (a3),d0 -@again Cmp.L (a0),d0 + cmp.l (a0),d0 bne @done - sub #$8,sp + sub.l #8,sp clr.b -(sp) pea.l tempRect1(a6) pea.l $22(a2) pea.l $a(sp) _SectRect tst.b (sp)+ - add #8,sp + add.l #8,sp bne @skip -@done Move.L GDNextGD(a2),d0 +@done move.l GDNextGD(a2),d0 move.l d0,a2 - bne.b @again + bne.s @again lea tempRect2(a6),a0 ;point to our temp rect pea topleft(a0) ;convert the temp rect back to local coordinates @@ -2468,7 +2468,7 @@ cutOutDevices move.l d6,-(sp) _DiffRgn -@skip movem.l (sp)+,d1/a1 ;restore our scratch registers +@skip movem.l (sp)+,d1/a1-a3 ;restore our scratch registers @next move.l (a1),a0 ;deref the current device list handle move.l GDNextGD(a0),d0 ;get the next device handle into D0 diff --git a/QuickDraw/CCrsrCore.a b/QuickDraw/CCrsrCore.a index 2151389..3fa53e7 100644 --- a/QuickDraw/CCrsrCore.a +++ b/QuickDraw/CCrsrCore.a @@ -102,12 +102,32 @@ 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 - ds.b 48 - IMPORT _HideCursor IMPORT _ShowCursor IMPORT _ShieldCursor diff --git a/QuickDraw/CheckDevicesINIT.a b/QuickDraw/CheckDevicesINIT.a index 24a273c..5c9d41b 100644 --- a/QuickDraw/CheckDevicesINIT.a +++ b/QuickDraw/CheckDevicesINIT.a @@ -221,8 +221,8 @@ SlotParms EQU IOPBlk-spBlock.SPBlockSize ; parameter block for slot manag VidParms EQU SlotParms-12 ; [12] size of mode params StartList EQU VidParms-4 ; [long] pointer to start of resource -VARSIZE EQU StartList ; size of local vars for CheckDevices -UTILVARS EQU VidParms ; size of local vars for utility routines +VARSIZE EQU StartList-4 ; size of local vars for CheckDevices +UTILVARS EQU VidParms-$30 ; size of local vars for utility routines ; ¥¥¥ Start of Code ¥¥¥ ; @@ -318,6 +318,8 @@ SetDevGamma +NewFunc + Link A6,#-$B4 Move.l A2,-(SP) Move.l (A0),A2 @@ -344,7 +346,7 @@ CheckDevices ; <19>: Moved label from within if-endif to embed utility ; stuff AFTER the GotScrn entrypoint. LINK A6,#VARSIZE ; allocate local stack frame - MOVEM.L A0-A6/D0-D7,-(SP) ; so we donÕt screw up the boot process + MOVEM.L A0-A4/D0-D7,-(SP) ; so we donÕt screw up the boot process Move.l DeviceList,A0 ; A0 contains gDevice. Move.l #-1,A1 ; Use gDeviceÕs PixMap for colorTable. @@ -405,10 +407,9 @@ NoGammaFix Cmp.b #15,D0 Bcs.b @dont Move.l A3,A0 - Bsr.w CheckDevices - nop - Bne.s * + $4A - Bra.s * + $62 + Bsr.w NewFunc + Bne.s @reallyDont + Bra.s @skipGD @dont Lea SlotParms(A6),A0 ; Fill out SpBlock: @@ -433,6 +434,8 @@ NoGammaFix ; We found a non-TFB card that contains no gamma table directory. So, we need to ; employ our fix, which is to make a SetGamma and then a SetEntries call. +@reallyDont + Move.l A2,A0 ; Lock down the gammaTable Handle. _Hlock @@ -620,7 +623,7 @@ DoDrvrPatches ; ; Save all registers to prevent problems with the ROM INIT running code. ; - MOVEM.L A0-A6/D0-D7,-(SP) ; so we donÕt screw up the boot process + MOVEM.L A5-A6,-(SP) ; so we donÕt screw up the boot process ; ; Point to UnitTable in A2. diff --git a/QuickDraw/ColorMgr.a b/QuickDraw/ColorMgr.a index 2175257..ca971cc 100644 --- a/QuickDraw/ColorMgr.a +++ b/QuickDraw/ColorMgr.a @@ -637,7 +637,7 @@ Seed MOVE.L D5,D4 ; copy total # of color (and cleared hi word) SUBQ #2,D4 ; this is the number of colors remaining - BLE.S QVille ; if zero or negative, all done + BLT.S QVille ; if zero or negative, all done MOVEQ #1,D5 ; start at color #1 (zero based) @TheRestOfUs ; a temporary label for the rest of us BSR.S QUtil ; queue it diff --git a/QuickDraw/FastTraps.a b/QuickDraw/FastTraps.a index 157fed1..304dc38 100644 --- a/QuickDraw/FastTraps.a +++ b/QuickDraw/FastTraps.a @@ -2921,6 +2921,7 @@ _EmptyHandle OPWORD $A000+43 _InitApplZone OPWORD $A000+44 _SetApplLimit OPWORD $A000+45 _BlockMove OPWORD $A000+46 +_BlockMoveData OPWORD $A000+46+$200 ; Here are the event manager routines diff --git a/QuickDraw/GDevice.a b/QuickDraw/GDevice.a index 1db9554..dbfbf01 100644 --- a/QuickDraw/GDevice.a +++ b/QuickDraw/GDevice.a @@ -362,6 +362,8 @@ oldBaseAddr DS.B 4 ; old base address, for later comparison oldPort DS.B 4 ; thePort, before we got here oldColor DS.B 8 ; a colorSpec used to reinstantiate fg/bk + DS.B 356 + VARSIZE DS.B 0 ; size of locals ENDR diff --git a/QuickDraw/GWorld.a b/QuickDraw/GWorld.a index 58b0f4c..3165b6f 100644 --- a/QuickDraw/GWorld.a +++ b/QuickDraw/GWorld.a @@ -1047,7 +1047,7 @@ createPixMap ; Create a dummy inverse table (doesn't have to be a seed) - moveq #2,d0 ; small handle for dummy inverse table + moveq #4,d0 ; small handle for dummy inverse table _NewHandle ,CLEAR ; allocate it bne reportError ; if Memory Manager error, report it and quit @@ -1171,7 +1171,7 @@ dontCloneCTab ; Allocate inverse table to its initial size - moveq #2,d0 ; initial size is 2 + moveq #4,d0 ; initial size is 2 _NewHandle ,CLEAR ; allocate it bne reportError ; if Memory Manager error, report it and quit @@ -1417,7 +1417,7 @@ disposOffscreenHandles cmp #cPortFlag,d0 ; is it set? bne.s @0 ; if not set, don't close port move.l (a0),-(sp) ; push pointer to port - _ClosePort ; close it down + _CloseCPort ; close it down @0 move.l d7,a0 ; get handle to offscreen port _DisposHandle ; dispose it @@ -1754,7 +1754,7 @@ dontDisposeBaseAddr dontDisposeGDevice move.l offscreenGWorld(sp),-(sp) ; push pointer to offscreen port - _ClosePort ; get rid of all substructures + _CloseCPort ; get rid of all substructures move.l offscreenGWorld(sp),a0 ; get pointer to grafport _RecoverHandle ; find handle to grafport diff --git a/QuickDraw/LCursor.a b/QuickDraw/LCursor.a index d7487e1..1e2ea5b 100644 --- a/QuickDraw/LCursor.a +++ b/QuickDraw/LCursor.a @@ -40,11 +40,7 @@ AllocCursor PROC EXPORT ; PROCEDURE AllocCursor; ; - LEA AllocCrsr,A0 ;get default cursor routine - MOVE.L JAllocCrsr,D0 ;has vector been initialized? - BEQ.S @0 ;=>no, use default routine - MOVE.L D0,A0 ;else use routine in vector -@0 JMP (A0) ;and call it + JMP AllocCrsr InitCursor PROC EXPORT @@ -55,8 +51,8 @@ InitCursor PROC EXPORT MOVE.L GRAFGLOBALS(A5),A0 ;POINT TO QUICKDRAW GLOBALS PEA ARROW(A0) ;PUSH ADDR OF ARROW _SetCursor ;INSTALL ARROW CURSOR - MOVE.L JInitCrsr,A0 ;get lo mem pointer - JMP (A0) ;and call it + IMPORT _InitCursor + JMP _InitCursor @@ -70,8 +66,8 @@ SetCursor PROC EXPORT MOVE #16,-(SP) ;HEIGHT:=16 PEA DATA(A0) ;PUSH ADDR OF DATA PEA MASK(A0) ;PUSH ADDR OF MASK - MOVE.L JSetCrsr,A0 ;get lo mem vector - JSR (A0) ;call vector + IMPORT _SetCursor + JSR _SetCursor MOVE.L (SP)+,(SP) ;strip param RTS ;and return @@ -92,8 +88,8 @@ SetCCursor PROC EXPORT ; _SetCursor ; and set it the old way MOVE.L 4(SP),-(SP) ; Push handle to color cursor - MOVE.L JSetCCrsr,A0 ; get lo mem vector - JSR (A0) ; call vector (but don't call him hector) + IMPORT _SetCCursor + JSR _SetCCursor ; _ShowCursor ; balance is a virtue MOVE.L (SP)+,(SP) ; strip param RTS ; and return @@ -107,8 +103,8 @@ HideCursor PROC EXPORT ; ; ALL REGS PRESERVED. ; - MOVE.L JHideCursor,-(SP) ;get lo mem vector - RTS ;and call it + IMPORT _HideCursor + JMP _HideCursor @@ -119,36 +115,8 @@ ShowCursor PROC EXPORT ; ; ALL REGS PRESERVED. ; - MOVE.L JShowCursor,-(SP) ;get lo mem vector - RTS ;and call it - - - -ShieldCursor PROC EXPORT -;--------------------------------------------------------- -; -; PROCEDURE ShieldCursor(shieldRect: Rect; offset: Point); -; -; ALL REGS PRESERVED. -; - MOVEM.L D0-D3/A0-A1,-(SP) ;SAVE REGS - MOVE.L 32(SP),A0 ;POINT TO SHIELDRECT - MOVEM.W (A0)+,D0/D1/D2/D3 ;GET TOP ... RIGHT - LEA 28(SP),A1 - SUB (A1),D0 ;TOP - OFFSET.V - SUB (A1)+,D2 ;BOTTOM - OFFSET.V - SUB (A1),D1 ;LEFT - OFFSET.H - SUB (A1),D3 ;RIGHT - OFFSET.H - MOVE D1,-(SP) ;PUSH GLOBAL LEFT - MOVE D0,-(SP) ;PUSH GLOBAL TOP - MOVE D3,-(SP) ;PUSH GLOBAL RIGHT - MOVE D2,-(SP) ;PUSH GLOBAL BOTTOM - MOVE.L JShieldCursor,A0 ;get lo mem vector - JSR (A0) ;and call it - MOVEM.L (SP)+,D0-D3/A0-A1 ;RESTORE REGS - MOVE.L (SP)+,(SP) - MOVE.L (SP)+,(SP) ;STRIP 8 BYTES - RTS ;AND RETURN + IMPORT _ShowCursor + JMP _ShowCursor @@ -159,13 +127,8 @@ ObscureCursor PROC EXPORT ; ; Hide the cursor image until the next time the mouse moves. ; - MOVE.L JCrsrObscure,A0 ;get lo mem vector - JMP (A0) ;and call it - - - ds.b 32 - - + IMPORT _ObscureCursor + JMP _ObscureCursor ENDPROC diff --git a/QuickDraw/PaletteMgr.a b/QuickDraw/PaletteMgr.a index 0664340..f75181a 100644 --- a/QuickDraw/PaletteMgr.a +++ b/QuickDraw/PaletteMgr.a @@ -694,7 +694,7 @@ linkSize DS.B 0 ; linky number PEA inFront(A6) _SameProcess ; are we the front process? ADDQ #2,SP ; OSErr leaves inFront true from above - TST inFront(A6) + TST.B inFront(A6) BEQ.S @doNothing @front @@ -1841,7 +1841,7 @@ linkSize DS.B 0 ;linky number BNE.S GoHome ; No=> go home w/false MOVE $14(A3),D0 AND #$8010,D0 - BPL.S GoHome ; No=> ditto + BEQ.S GoHome ; No=> ditto SUBQ #4,SP ; space for result MOVE.L A2,-(SP) ; push gDevice handle JSR GetClut ; get the appropriate default clut @@ -3188,9 +3188,9 @@ SetDev Move.L (A0),A0 ; dereference it TST gdType(A0) ; is it CLUT type (zero)? dvb1 BNE GoHome ; No => do nothing - MOVE $14(A3),D0 + MOVE $14(A0),D0 AND #$8010,D0 - BPL GoHome ; No=>go home + BEQ GoHome ; No=>go home Move.L gdPMap(A0),A0 ; get handle to pixmap Move.L (A0),A0 ; dereference pixmap Move.L pmTable(A0),A0 ; get handle to CTab diff --git a/QuickDraw/Patterns.a b/QuickDraw/Patterns.a index 6d241c9..7e0a641 100644 --- a/QuickDraw/Patterns.a +++ b/QuickDraw/Patterns.a @@ -2350,11 +2350,11 @@ NEXTGD move.l (a2),a0 lea dstRectRgn+rgnBBox(A6),a0 move.l a0,d0 move.l a0,-(sp) - jsr ([$FC0]) ; _GlobalToLocal? + jsr ([$FC4]) ; _GlobalToLocal? add #4,d0 move.l d0,-(sp) - jsr ([$FC0]) ; _GlobalToLocal? + jsr ([$FC4]) ; _GlobalToLocal? MOVE.L (A2),A0 ; POINT TO DEVICE MOVE.L GDPMAP(A0),A0 ; GET PIXMAP diff --git a/QuickDraw/Pictures.a b/QuickDraw/Pictures.a index 2183ec0..0008db4 100644 --- a/QuickDraw/Pictures.a +++ b/QuickDraw/Pictures.a @@ -4245,7 +4245,7 @@ MORE1 MOVE.L A3,A0 ;PTR TO FIRST byte of src move.l d5,d0 ;get rowbytes in d0 - _BlockMove ;copy from there to here + _BlockMoveData ;copy from there to here ;assumes here is a 24 bit address moveq #false32b,d0 ;switch back before calling PutPicProc diff --git a/QuickDraw/QDUtil.a b/QuickDraw/QDUtil.a index 17cbbdf..2431604 100644 --- a/QuickDraw/QDUtil.a +++ b/QuickDraw/QDUtil.a @@ -1389,7 +1389,7 @@ GETPIXEL MOVEQ #0,D2 ;ROUTINE = GETPIXEL SHARE LINK A6,#VARSIZE ;ALLOCATE STACKFRAME - MOVEM.L D4-D5/A2-A3,-(SP) ;SAVE WORK REGISTERS + MOVEM.L D4-D6/A2-A3,-(SP) ;SAVE WORK REGISTERS MOVE.L THEGDEVICE,-(SP) ;SAVE CURRENT GRAFDEVICE MOVE.L GRAFGLOBALS(A5),A0 ;POINT TO QUICKDRAW GLOBALS MOVE.L THEPORT(A0),A0 ;GET THEPORT @@ -4731,7 +4731,7 @@ DSTH EQU SRCH-4 MOVE.L (A0),A0 ; get SRC pointer MOVE.L (A1),A1 ; get DST pointer MOVE.L D1,D0 ; D0 = size - _BlockMove ; copy the data + _BlockMoveData ; copy the data DONE MOVE.L (SP)+,A0 ; get return address ADDQ #8,SP ; strip parameters diff --git a/QuickDraw/ScaleBlt.a b/QuickDraw/ScaleBlt.a index 31ea259..24376e1 100644 --- a/QuickDraw/ScaleBlt.a +++ b/QuickDraw/ScaleBlt.a @@ -127,7 +127,7 @@ multColor EQU RGNC-2 ;byte, set if source contains nonblack/white colors ; _StackAvail ;GET STACK AVAIL IN D0.L LSR.L #2,D0 ;CONVERT BYTES TO LONGS - SUB.L #qdStackXtra,D0 ;SUBTRACT SLOP FACTOR <1.2> BAL + SUB.L #$200,D0 ;SUBTRACT SLOP FACTOR <1.2> BAL MOVE.L D0,STACKFREE(A6) ;AND SAVE FREE LONGS ON STACK bpl.s @stkOK _stNoStack ;=>NOT ENOUGH STACK, QUIT