Crack QuickDraw

That is to day, put *something* in its place with the right length and
symbol locations. Now we can be sure that no incorrect bytes are due to
confused branch instructions, and therefore that they must all be fixed.
This commit is contained in:
Elliot Nunn 2017-10-09 12:37:27 +08:00
parent 1833036a99
commit cf23aad670
11 changed files with 530 additions and 305 deletions

Binary file not shown.

View File

@ -1746,27 +1746,85 @@ VARSIZE EQU 0
share LINK A6,#VARSIZE ;ALLOCATE STACK FRAME
MOVEM.L D3-D7/A2-A4,-(SP) ;SAVE WORK REGISTERS FOR DEVLOOP
CLR.L -4(A6)
MOVE.L MASKBITS(A6), D0
BEQ @skip
MOVEA.L D0, A0
CMPI #$1, $20(A0)
BNE @skip
MOVEA.L $16(A6), A0
MOVEA.L $E(A6), A1
MOVE $4(A0), D0
SUB (A0), D0
SUB $4(A1), D0
ADD (A1), D0
BGT.B @L0
MOVE $6(A0), D0
SUB $2(A0), D0
SUB $6(A1), D0
ADD $2(A0), D0
BLE @skip
@L0 SUBQ #$4, SP
DC.W $AA18 ;_GetCTable
MOVE.L (SP)+, D3
BEQ @skip
SUBQ #$2, SP
PEA.L -4(A6)
MOVE #$2, -(SP)
PEA.L MASKRECT(A6)
MOVE.L D3, -(SP)
CLR.L -(SP)
MOVE #4,-(SP)
MOVE.L #$160000,D0 ;_QDExtensions -> _NewGWorld
DC.W $AB1D
MOVE (SP)+, D4
BNE.B @L1
TST.L -4(A6)
BNE.B @L2
@L1 SUBQ #$2, SP
PEA.L -4(A6)
MOVE #$2, -(SP)
PEA.L MASKRECT(A6)
MOVE.L D3, -(SP)
CLR.L -(SP)
CLR.L -(SP)
MOVE.L #$160000,D0 ;_QDExtensions -> _NewGWorld
DC.W $AB1D
MOVE (SP)+, D4
@L2 MOVE.L D3, -(SP)
DC.W $AA24 ;_DisposCTable
TST D4
BNE.B @skip
MOVE.L -4(A6), D0
BEQ.B @skip
MOVEA.L D0, A3
SUBQ #$8, SP
PEA.L $4(SP)
PEA.L $4(SP)
MOVE.L #$80005,D0 ;_QDExtensions -> _GetGWorld
DC.W $AB1D
MOVE.L -4(A6), -(SP)
CLR.L -(SP)
MOVE.L #$80006,D0 ;_QDExtensions -> _SetGWorld
DC.W $AB1D
MOVE.L MASKBITS(A6), -(SP)
PEA.L $2(A3)
MOVE.L MASKRECT(A6), -(SP)
PEA.L $10(A3)
CLR -(SP)
CLR.L -(SP)
DC.W $A8EC ;_CopyBits
SUBQ #$2, SP
MOVE.L $2(A3), -(SP)
MOVE.L #$40001,D0 ;_QDExtensions -> _LockPixels
DC.W $AB1D
ADDQ #$2, SP
MOVEA.L $2(A3), A0
_HLock
MOVE.L (A0), MASKBITS(A6)
MOVE.L #$160000,D0 ;_QDExtensions -> _NewGWorld
DC.W $AB1D
@skip
; SET UP REGISTERS FOR CALLING CMDEVLOOP
@ -1815,7 +1873,15 @@ SRCOK MOVE.L DSTBITS(A6),A0 ;POINT TO DSTBITS
NOTPORT MOVE.L DSTBITS(A6),A1 ;Pass DSTBITS (not derefed) <BAL 28May89>
JSR CMDevLoop ;AND DRAW THE IMAGE
MOVE.L -4(A6),D0
BEQ.S @skipQDCall
MOVE.L D0,-(SP)
MOVE.L #$40004,D0 ;_QDExtensions -> _DisposeGWorld
DC.W $AB1D
@skipQDCall
MOVEM.L (SP)+,D3-D7/A2-A4 ;RESTORE WORK REGISTERS
UNLINK PARAMSIZE,'KopyMask'
@ -2348,7 +2414,7 @@ cutOutDevices
move.l pmTable(a0),a0 ;get handle to source color table
move.l (a0),a0 ;deref it
cmp.l ctSeed(a0),d1 ;do the color tables seeds match ?
beq.s @next
beq @next
movem.l d1/a1,-(sp) ;save our scratch registers
@ -2359,7 +2425,34 @@ cutOutDevices
pea tempRect2(a6) ;pointer to the result
_SectRect ;get the intersection
tst.b (sp)+ ;if they didn't intersect at all, then skip to
beq.s @skip ;..the next device
beq @skip ;..the next device
move.l (a1),a0
move.l GDPMap(a0),a0
move.l (a0),a0
move.l pmTable(a0),a0
move.l (a0),a0
move.l (DeviceList),a2
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
bne @done
sub #$8,sp
clr.b -(sp)
pea.l tempRect1(a6)
pea.l $22(a2)
pea.l $a(sp)
_SectRect
tst.b (sp)+
add #8,sp
bne @skip
@done Move.L GDNextGD(a2),d0
move.l d0,a2
bne.b @again
lea tempRect2(a6),a0 ;point to our temp rect
pea topleft(a0) ;convert the temp rect back to local coordinates

View File

@ -116,7 +116,7 @@ CRSRCORE PROC EXPORT
IMPORT _InitCursor
IMPORT _SetCursor
IMPORT _ObscureCursor
IMPORT _AllocCrsr
IMPORT AllocCrsr
IMPORT _SetCCursor
;
@ -131,7 +131,7 @@ InitCrTable
DC.W _InitCursor-InitCrTable
DC.W _SetCursor-InitCrTable
DC.W _ObscureCursor-InitCrTable
DC.W _AllocCrsr-InitCrTable
DC.W AllocCrsr-InitCrTable
DC.W _SetCCursor-InitCrTable
@ -275,7 +275,7 @@ _ObscureCursor PROC EXPORT
; Allocates all global cursor data structures. A maximum depth of 8 is assumed.
;
_AllocCrsr PROC EXPORT
AllocCrsr PROC EXPORT
IMPORT QDNEW_ALLOCCRSR
JMP QDNEW_ALLOCCRSR

View File

@ -134,10 +134,6 @@ _PMBackColor OPWORD $Aa98
ENDM
QD_ERASECURSOR proc export
QD_DRAWCURSOR proc export
GETDCTLENTRY proc export
BlockHead PROC EXPORT
GBLC &CurFile ;current file name used by DrawingVars
@ -188,35 +184,4 @@ BlockHead PROC EXPORT
INCLUDE 'PaletteMgr.a' ; <02Jun87 DAF>
INCLUDE 'GWorld.a' ; <29May89 BAL>
QDEXTENSIONS2_SELECTOR_0 PROC EXPORT
QDEXTENSIONS2_SELECTOR_1 PROC EXPORT
QDEXTENSIONS2_SELECTOR_2 PROC EXPORT
QDEXTENSIONS2_SELECTOR_3 PROC EXPORT
QDEXTENSIONS2_SELECTOR_4 PROC EXPORT
QDEXTENSIONS2_SELECTOR_5 PROC EXPORT
QDEXTENSIONS2_SELECTOR_6 PROC EXPORT
QDEXTENSIONS2_SELECTOR_7 PROC EXPORT
QDEXTENSIONS2_SELECTOR_8 PROC EXPORT
QDEXTENSIONS2_SELECTOR_9 PROC EXPORT
QDEXTENSIONS2_SELECTOR_10 PROC EXPORT
QDNEW_HIDECURSOR PROC EXPORT
QDNEW_SHOWCURSOR PROC EXPORT
QDNEW_SHIELDCURSOR PROC EXPORT
QDNEW_SCRNADDRESS PROC EXPORT
QDNEW_SCRNSIZE PROC EXPORT
QDNEW_INITCURSOR PROC EXPORT
QDNEW_SETCURSOR PROC EXPORT
QDNEW_OBSCURECURSOR PROC EXPORT
QDNEW_ALLOCCRSR PROC EXPORT
QDNEW_SETCCURSOR PROC EXPORT
CRSRVBLTASK PROC EXPORT
UNBLITCURSOR PROC EXPORT
BLITCURSOR PROC EXPORT
SETCRSRDATA PROC EXPORT
GETMAINCRSR PROC EXPORT
CURSORSECT PROC EXPORT
ALLOCCRSR PROC EXPORT
END

View File

@ -21,6 +21,7 @@ QDPatchesDir = {ColorQDDir}Patches:
CQDObjs = "{ObjDir}CheckDevicesINIT.a.o" ¶
"{ObjDir}CQD.a.o" ¶
"{LibDir}MoreCQD.lib" ¶
"{ObjDir}DeviceLoop.a.o"

View File

@ -105,8 +105,38 @@ LocalSize EQU *
link A6, #LocalSize
movem.l D3-D7/A2-A4, callerRegs(A6) ; save the callers registers
btst #6, ROM85 ; Color QuickDraw available?
bnz @classicQD ; if not, handle old case
machine MC68030
move.l ([$2b6],$1fc),a0
machine MC68020
tst.b $b5(a0)
beq.s @noShield
move.l drawingRgn(a6),d0
beq.s @noConversion
move.l d0,a0
move.l (a0),a0
move.l $2(a0),localRect+0(a6)
move.l $6(a0),localRect+4(a6)
pea localRect+0(a6)
_LocalToGlobal
pea localRect+4(a6)
_LocalToGlobal
bra.s @proceedWithShield
@noConversion
move.l #$80008000,localRect+0(a6)
move.l #$7fff7fff,localRect+4(a6)
@proceedWithShield
pea localRect+0(a6)
clr.l -(sp)
_ShieldCursor
@noShield
move.l TheGDevice, D0 ; Get the handle to the current GDevice
move.l MainDevice, D1 ; Get the handle to the main device
@ -149,11 +179,11 @@ LocalSize EQU *
beq @noMore ; if so, no more devices
move.l (A4), A3 ; point at the GDevice record
bsr TestAndIntersect ; is device good for drawing?
bz.s @nextDevice ; if not, keep searching
bz @nextDevice ; if not, keep searching
move.l flags(A6), D0 ; get the callerÕs options
btst #allDevicesBit, D0 ; are we ignoring regions?
bnz.s @visRgnSetup ; if so, donÕt change the visRgn
bnz @visRgnSetup ; if so, donÕt change the visRgn
move.l D4, -(SP) ; rectangle region handle
pea localRect(A6) ; this device (local coords)
@ -175,10 +205,12 @@ LocalSize EQU *
move.l ctSeed(A0), D7 ; stash deviceÕs ctab seed
move.l flags(A6), D0 ; get callerÕs flags
btst #singleDevicesBit, D0 ; should we group devices?
bnz.s @groupingDone ; if not, donÕt call AddSimilar
bnz @groupingDone ; if not, donÕt call AddSimilar
bsr AddSimilarDevices ; find all the like devices
@groupingDone
movem.l D3-D7/A2-A4/A6, -(SP) ; save OUR registers
bsr NewFunc1
move D2,-(SP)
swap D6
move.l D6, -(SP) ; pass depth and flags
move.l A4, -(SP) ; and the GDHandle
@ -187,6 +219,8 @@ LocalSize EQU *
movem.l callerRegs(A6), D3-D7/A2-A4 ; restore callerÕs registers
move.l A6Link(A6), A6 ; and restore callerÕs A6
jsr (A0) ; call the drawing procedure
move (SP)+,D2
bsr NewFunc2
movem.l (SP)+, D3-D7/A2-A4/A6 ; get OUR register set back
move.l (A4), A3 ; fix GDevicePtr
@nextDevice
@ -194,13 +228,6 @@ LocalSize EQU *
addq #1, D3 ; increment device number
bra.s @deviceIntersect ; try this one
@classicQD
move.l A6, -(SP) ; save our stack frame ptr
move.w #1, -(SP) ; pass depth (always 1)
move.w #fakeDeviceFlags, -(SP) ; and gdflags (something reasonable)
clr.l -(SP) ; NIL for GDHandle
bra.s @simpleDeviceCommon
@oneDevice
move.l A6, -(SP) ; save our stack frame ptr
move.l gdPMap(A0), A1 ; PixMapHandle
@ -230,6 +257,17 @@ LocalSize EQU *
_DisposRgn
move.l savedVis(A6), visRgn(A2) ; put original visRgn back
@exit
machine MC68030
move.l ([$2b6],$1fc),a0
machine MC68020
tst.b $b5(a0)
beq.s @noShow
_ShowCursor
@noShow
movem.l callerRegs(A6), D3-D7/A2-A4 ; restore regs
unlk A6
move.l (SP)+, A0 ; clean stack and return
@ -252,27 +290,30 @@ AddSimilarDevices
movem.l A3-A4/D3/D6, -(SP) ; save original state
andi.w #importantFlagsMask, D6 ; keep only pertinent flags
move.l A3, A1
move.l gdNextGD(A3), A4 ; start with next device
addq #1, D3 ; which is next in number, too
@addLoop
move.l A4, D0 ; is there a GDHandle?
bz.s @noMore ; if NIL, then weÕre done
bz @noMore ; if NIL, then weÕre done
move.l (A4), A3 ; handle->ptr
bsr.s TestAndIntersect ; see if device is okay by itself
bz.s @nextDevice ; if not, try next one
move.l A1, -(SP)
bsr TestAndIntersect ; see if device is okay by itself
move.l (SP)+, A1
bz @nextDevice ; if not, try next one
move.w gdFlags(A3), D0 ; get device attributes
andi.w #importantFlagsMask, D0 ; strip unimportant ones
cmp.w D0, D6 ; is this device similar to test device?
bne.s @nextDevice ; if not, donÕt use it
bne @nextDevice ; if not, donÕt use it
move.l gdPMap(A3), A0 ; get deviceÕs PixMapHandle
move.l (A0), A0 ; get deviceÕs PixMapPtr
move.l D6, D0 ; get depth and flags
swap D0 ; get depth into low word
cmp.w pmPixelSize(A0), D0 ; save depth as test device?
bne.s @nextDevice ; if not, donÕt use it
bne @nextDevice ; if not, donÕt use it
move.l flags(A6), D0 ; get the option flags
btst #dontMatchSeedsBit, D0 ; should we check ctSeeds?
@ -280,12 +321,49 @@ AddSimilarDevices
move.l pmTable(A0), A0 ; handle to color table
move.l (A0), A0
cmp.l ctSeed(A0), D7 ; are the seeds the same?
bne.s @nextDevice ; if not, donÕt use this one
bne @nextDevice ; if not, donÕt use this one
@seedsChecked
move.l A3, A0
move.l $22(A1), D0
cmp $24(A0), D0
bgt.s @L4
blt.s @L1
swap D0
cmp $22(A0), D0
bgt.s @L5
blt.s @L2
move.l $26(A1), D0
cmp $28(A0), D0
blt.s @L6
bgt.s @L3
bra.s @nextDevice
@L1 swap D0
cmp $22(A0), D0
bgt.s @doneWhateverThatWas
@L2 move.l $26(A1), D0
cmp $28(A0), D0
blt.s @doneWhateverThatWas
@L3 swap D0
cmp $26(A0), D0
blt.s @doneWhateverThatWas
bra.s @nextDevice
@L4 swap D0
cmp $22(A0), D0
blt.s @doneWhateverThatWas
@L5 move.l $26(A1), D0
cmp $28(A0), D0
bgt.s @doneWhateverThatWas
@L6 swap D0
cmp $26(A0), D0
bgt.s @doneWhateverThatWas
bra.s @nextDevice
@doneWhateverThatWas
move.l flags(A6), D0 ; what are the current options?
btst #allDevicesBit, D0 ; are we ignoring drawingRgn?
bnz.s @visRgnSetup ; if so, no regions to setup
move.l A1, -(SP)
move.l D4, -(SP) ; rectangle region handle
pea localRect(A6) ; this device (local coords)
@ -299,6 +377,7 @@ AddSimilarDevices
move.l (SP), -(SP) ; get ORed together
_XorRgn ; XOr is a fast way to Union when guaranteed no overlap
move.l (A4), A3 ; fix GDevicePtr
move.l (SP)+, A1
@visRgnSetup
bset.l D3, D5 ; mark this device done
@ -347,4 +426,73 @@ TestAndIntersect
@exit
rts
NewFunc1
moveq #0, D2
move.l (DeviceList), D0
beq.s @return
moveq #0, D1
@L0 movea.l D0, A0
movea.l (A0), A0
cmp D3, D1
beq.s @L8
tst $14(A0)
bpl.s @L8
movea.l (A4), A1
move.l $22(A1), D0
cmp $24(A0), D0
bgt.s @L4
blt.s @L1
swap D0
cmp $22(A0), D0
bgt.s @L5
blt.s @L2
move.l $26(A1), D0
cmp $28(A0), D0
blt.s @L6
bgt.s @L3
bra.s @L7
@L1 swap D0
cmp $22(A0), D0
bgt.s @L8
@L2 move.l $26(A1), D0
cmp $28(A0), D0
blt.s @L8
@L3 swap D0
cmp $26(A0), D0
blt.s @L8
bra.s @L7
@L4 swap D0
cmp $22(A0), D0
blt.s @L8
@L5 move.l $26(A1), D0
cmp $28(A0), D0
bgt.s @L8
@L6 swap D0
cmp $26(A0), D0
bgt.s @L8
@L7 bclr.s #7, $14(A0)
bset.l D1, D2
@L8 addq #1, D1
move.l $1E(A0), D0
bne.s @L0
@return Rts
NewFunc2
tst D2
beq.s @return
move.l (DeviceList), D0
beq.s @return
@L10 move.l D0, A0
move.l (A0), A0
lsr #1, D2
bcc.s @L11
bset.s #7, $14(A0)
tst D2
beq.s @return
@L11 move.l $1E(A0), D0
bne.s @L10
@return Rts
END

View File

@ -1005,7 +1005,7 @@ selectGetGray equ 25
MACRO
_ZapLinks
DoPaletteDispatch selectZapLinks,0
DoPaletteDispatch selectZapLinks,4
ENDM
MACRO

View File

@ -695,6 +695,9 @@ varSize equ localRect ; size of local variables
move #noErr,result(a6) ; flag a successful operation,
move.l offscreenGWorld(a6),a0
clr.l (a0)
;-------------------------------------------------------------------------
; Initialize all offscreen local variables to zero.
; If an error happens during this function, we deallocate the memory for
@ -765,6 +768,14 @@ varSize equ localRect ; size of local variables
cmp #32,d7 ; illegal if > 32
bhi badPixelDepth ; exit with error
;-------------------------------------------------------------------------
; Treat 24-bit color as 32-bit.
cmp #24,d7
bne.s @dontSetTo32
moveq #32,d7
@dontSetTo32
;-------------------------------------------------------------------------
; If pixelDepth is not 0, don't try to align offscreen pixmap to screen
@ -1003,6 +1014,17 @@ createPixMap
moveq #5,d0 ; no, cmpSize = 5
@0 move d0,pmCmpSize(a1) ; store cmpSize in pixmap
btst.l #$1,d3
beq.s @skipthisnonsense
move.l ([museDevice,a6]),a0
move.l ([gdPMap,a0]),a0
move.l gdMode(a0),a0
move.l a0,offscreenCTable(a6)
move.l ([offscreenPixMap,a6]),a1
move.l a0,gdMode(a1)
bra createDevice
@skipthisnonsense
; Create an empty color table.
move #ctRec,d0 ; size of an empty color table
@ -1393,7 +1415,7 @@ disposOffscreenHandles
move portVersion(a0),d0 ; get portVersion
and #cPortFlag,d0 ; check if cPortFlag set
cmp #cPortFlag,d0 ; is it set?
bne @0 ; if not set, don't close port
bne.s @0 ; if not set, don't close port
move.l (a0),-(sp) ; push pointer to port
_ClosePort ; close it down
@0

View File

@ -172,7 +172,7 @@ plttUpdates Equ $0002 ; value passed to SetPalette [short] AWC.PB457
;ctReserveBit EQU 6
;ctReserveVal EQU $4000
PMgrVersNum EQU $0202 ; Version number (VVss: version subversion)
PMgrVersNum EQU $0203 ; Version number (VVss: version subversion)
;-----------------------------------------------------------
; Let's talk about PMgrVersNum --
;
@ -228,6 +228,46 @@ PMgrVersNum EQU $0202 ; Version number (VVss: version subversion)
; GetNewCWindow which is patched in PatchIIROM.a
FlushPalettes PROC EXPORT ; THIEVED FROM THE MEMORY MGR
;-----------------------------------------------------------------------
; Call DisposePalette for all palettes in the app heap.
;
; Registers: D0-D2/A0-A1
; Called by vIAZInit.
;----------------------------------------------------------------------
IMPORT AppZoneAddr
MOVEM.L A2-A3/D3,-(SP) ; save work registers
MOVE.L PMgrHandle,A2 ; get paletteMgr handle
CMP.L MinusOne,A2 ; is it there?
BEQ.S @DONE ; => 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
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 D1,D0 ; and get for routine
JSR AppZoneAddr ; in application area (or zero)? <SM30 BT>
BNE.S @FindNext ; => not in app heap
MOVE.L D1,-(SP) ; push palette handle
DC.W $AA93 ; _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
@DONE MOVEM.L (SP)+,A2-A3/D3 ; restore work registers
RTS
;---------------------------------------------------
;
; PROCEDURE ActivatePalette(dstWindow: WindowPtr); INLINE $AA94;
@ -584,14 +624,8 @@ gLoopEnd DBRA D3,gLoop ; loop for all devices <dvb5>
; return Z-flag Clear if the process mgr is here (BNE ProcMgrTrue)
CheckForProcessMgr PROC EXPORT
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
MOVE.L ExpandMem,A0
TST $128(A0)
RTS
;---------------------------------------------------
@ -624,7 +658,7 @@ linkSize DS.B 0 ; linky number
movem.l a0-a2/d0-d2,-(sp) ; Those pesky c routines <mc8>
sub.l a0,a0 ; Pass the current process (0)
move.w #12,d0 ; _TrashProcess
moveq #12,d0 ; _TrashProcess
;_FigmentDispatch ; let everyone know this stuff is gone
dc.w $A0A4
movem.l (sp)+,a0-a2/d0-d2 ; Restore em
@ -1805,7 +1839,8 @@ linkSize DS.B 0 ;linky number
MOVE.L (A2),A3 ; A3->gDevice
TST gdType(A3) ; a clut device? <dvb5>
BNE.S GoHome ; No=> go home w/false
TST gdFlags(A3) ; Device active?
MOVE $14(A3),D0
AND #$8010,D0
BPL.S GoHome ; No=> ditto
SUBQ #4,SP ; space for result <dvb5>
MOVE.L A2,-(SP) ; push gDevice handle <dvb5>
@ -2505,8 +2540,9 @@ FoundAPltt Move.L A2,srcPalette(A6) ; save it so we can unlock it AWC.PB520
BEQ.s @a ; is it a clut device? <dvb12>
SUBQ #1,D1 ; fixed type? <dvb12>
BNE.S UnlockPltt ; no => we're almost done <dvb3>
@a TST gdFlags(A0) ; is it active?
BPL.S UnlockPltt ; no => ditto
@a MOVE $14(A3),D0
AND #$8010,D0
BEQ.S UnlockPltt
Move ciUsage(A3),D1 ; get flags
MoveQ #0,D0 ; clear high word
Move srcEntry(A6),D0 ; set D0 in case it is an explicit index
@ -3152,7 +3188,8 @@ SetDev
Move.L (A0),A0 ; dereference it
TST gdType(A0) ; is it CLUT type (zero)? dvb1
BNE GoHome ; No => do nothing
TST gdFlags(A0) ; is it active
MOVE $14(A3),D0
AND #$8010,D0
BPL GoHome ; No=>go home
Move.L gdPMap(A0),A0 ; get handle to pixmap
Move.L (A0),A0 ; dereference pixmap
@ -4542,66 +4579,7 @@ ReleaseList PROC EXPORT
;
FindModeID FUNC Export
WITH SpBlock,VPBlock
FMVars RECORD {A6Link},Decrement
result DS.B 2 ; integer result
gd DS.B 4 ; input: GDevice
depth DS.B 2 ; input: depth
return DS.B 4 ; return address
A6Link DS.B 4 ; link
spBlk DS.B spBlockSize ; slot parameter block
vpPtr DS.B 4 ; pointer to vidParams block
linkSize DS.B 0 ; size of record
ENDR
WITH FMVars
LINK A6,#linkSize
MOVEM.L A2/D3,-(SP) ; save 'em
CLR result(A6) ; default to failure!
MOVE.L gd(A6),A0 ; A0 = gDevice handle
MOVE.L (A0),A1 ; A1->gDevice
MOVE.L UTableBase,A0 ; A0->unit table
MOVE gdRefNum(A1),D0 ; D0 = refnum
NEG D0
SUBQ #1,D0
MOVE.L (A0,D0.W*4),A1 ; A1 = AuxDCEHandle for gDevice
MOVE.L (A1),A1 ; A1 = AuxDCEPtr for gDevice
LEA spBlk(A6),A0 ; A0 -> spBlock
MOVE.B dCtlSlot(A1),spSlot(A0) ; stash gDevice slot
CLR.B spID(A0) ; clear the ID
MOVE #catDisplay,spCategory(A0) ; category: display
MOVE #typVideo,spCType(A0)
MOVE #drSwApple,spDrvrSW(A0) ; Appleª style driver
MOVE.B #1,spTBMask(A0)
_sNextTypeSRsrc
BNE.S @goHome ; failure
MOVE.L spsPointer(A0),A2 ; keep saving it here
MOVE #127,D3 ; the 0th mode we'll look for
@depthScan
ADDQ #1,D3 ; bump to next mode
MOVE.B D3,spID(A0) ; look for the next mode
MOVE.L A2,spsPointer(A0) ; sFindStruct wipes out each time
_sFindStruct ; look for it
BNE.S @goHome ; failure
MOVE.B #mVidParams,spID(A0) ; now we look for video params
_sGetBlock
BNE.S @goHome ; failure
MOVE.L spResult(A0),A1 ; A1->vidParam block, finally
MOVE vpPixelSize(A1),D0 ; D0 = depth for this description
CMP depth(A6),D0 ; the one we want?
BNE.S @depthScan ; scan 'til found, or slot error
MOVE D3,result(A6)
@goHome MOVEM.L (SP)+,A2/D3
UNLK A6
RTD #result-return-4
RTS
@ -4625,6 +4603,7 @@ A6Link DS.B 4 ; link
r DS.B 4 ; regionhandle
oldPort DS.B 4 ; previous port
myRect DS.B 8 ; rectangle for little black corners
moreStuff DS.B 10 ; not sure what for?
linkSize DS.B 0 ; size of record
ENDR
@ -4634,10 +4613,31 @@ linkSize DS.B 0 ; size of record
MOVEM.L A2-A3/D3-D5,-(SP) ; <6>
MOVE #paramErr,result(A6) ; default to failure!
MOVE.B #1,myRect+6(A6)
MOVEQ #0,D0
MOVE depth(A6),D0
MOVE.L D0,r(A6)
MOVE.L gd(A6),A0 ; A0 = gDevice handle
MOVE.L (A0),A1 ; A1->gDevice
CLR -(SP)
MOVE.L gd(A6),-(SP)
CLR.L -(SP)
MOVE.L r(A6),-(SP)
PEA oldPort(A6)
CLR.L -(SP)
PEA myRect+7(A6)
MOVE #$C12,D0 ; _DMRemoveDisplay
DC.W $ABEB
TST (SP)+
BNE.S @goHome
MOVE.L oldPort(A6),D0
BTST.L #1,D0
BNE.S @goHome
MOVE.L gd(A6),A1
MOVE.L (A1),A1
MOVE whichFlags(A6),D0 ; D0 = mask of flags to change
ANDI #whichMask,D0 ; D0 = only the ones we let them change
MOVE D0,D1 ; D1 = mask of flags to change
@ -4646,137 +4646,21 @@ linkSize DS.B 0 ; size of record
AND gdFlags(A1),D0 ; D0 = all the unchanged gdFlags
OR D1,D0 ; D0 = new gdFlags word
MOVE D0,gdFlags(A1) ; Put back into gDevice
MOVE gdRefNum(A1),D3 ; D3 = refnum, for later use
MOVE depth(A6),D4 ; get the depth or mode
TST.B D4 ; see which it is
BMI.S @gotMode
SUBQ #2,SP
CLR -(SP)
MOVE.L gd(A6),-(SP)
MOVE D4,-(SP)
Import FindModeID
BSR FindModeID ; find the mode number, if it exists
MOVE (SP)+,D4 ; did we find one?
BEQ @goHome
@gotMode Movea.l gd(A6),A2 ; Get GDHandle into A2.
Movea.l (A2),A2 ; Get a GDPtr into A2.
Btst #mainScreen,gdFlags(A2) ; If weÕre not on the menubar screen,
Beq.s @NotMain1 ; then just keep going.
Move.w theMenu,D5 ; Get the currently hilited menuID.
Clr.w -(Sp) ; And unhilite it.
_HiliteMenu
@NotMain1
; Originally, DVB wasnÕt getting the current port until corner-rounding code
; was about to be executed (below). That seemed to cause port problems, so
; I move the port getting/setting code to here (which is the way Monitors
; does it).
;
; -- jmp --
PEA oldPort(A6) ; Save the current port
_GetPort
MOVE.L WMgrPort,-(SP) ; We want to use the WMgrPort
_SetPort
MOVE D3,-(SP) ; push refnum
EXT.L D4
MOVE.L D4,-(SP) ; push new gdev mode
MOVE.L gd(A6),-(SP) ; push the handle
_InitGDevice
Btst #mainScreen,gdFlags(A2) ; If weÕre not on the menubar screen,
Beq.s @NotMain2 ; then just keep going.
Move.w D5,-(Sp) ; Get the hilite state.
_HiliteMenu ; Restore it.
_DrawMenuBar ; Draw the MenuBar.
@NotMain2
CLR.L -(SP) ; Activate the front palette
_FrontWindow ; before drawing anything.
_ActivatePalette
; In Monitors (the cdev) this is the point in the code where
; the PortList is walked to update all the CGrafPorts to the
; new depth. We donÕt need to do that here because InitGDevice
; does that for us with Save/ResoreFore and Save/RestoreBack
; calls.
;
; -- jmp --
; If the LayerManger is around, we need to start at the root, otherwise
; we just use FrontWindow. Originally, DVB had PaintOne instead of
; PaintBehind here but VL said that was wrong. Also, Monitors uses the
; PaintOne/PaintBehind method instead of PaintOne/PaintOne method.
;
; -- jmp --
If HasLayers Then
_RedrawAll ; CheckUpdate on all layers <42>
Else
SUBQ #4,SP
_NewRgn
MOVE.L (SP),r(A6) ; get a fresh region, LEAVE ON STACK
MOVE.L gd(A6),A0 ; A0 = gd handle
MOVE.L (A0),A0 ; A0->gdevice
PEA gdRect(A0) ; push rectangle to RectRgn
_RectRgn ; r is now our region
CLR.L -(SP)
MOVE.L r(A6),-(SP)
_PaintOne
PEA r(A6)
CLR.L -(SP)
CLR.L -(SP)
SUBQ #4,SP
_FrontWindow
MOVE.L r(A6),-(SP)
_PaintBehind
MOVE #$A11,D0 ; _DMEnableDisplay
DC.W $ABEB
MOVE.L r(A6),-(SP) ; Done with region
_DisposRgn
Endif
CLR.L myRect+topLeft(A6) ; Set the empty rect
CLR.L myRect+botRight(A6)
MOVE.L deviceList,A2 ; A2 = 1st GDHandle
@dloop MOVE.L (A2),A2 ; A2 -> GDevice
BTST #screenActive,gdFlags(A2) ; bit 15 in upper byte of word
BEQ.S @dloopEnd ; Inactive screen?
PEA gdRect(A2)
PEA myRect(A6)
MOVE.L (SP),-(SP)
_UnionRect
@dloopEnd MOVE.L gdNextGD(A2),A2
MOVE.L A2,D0
BNE.S @dloop
MOVE (SP)+,result(A6)
PEA myRect(A6) ; Set a nice big clip
_ClipRect
PEA myRect(A6)
MOVE.L #$FFFDFFFD,-(SP) ; outset by three
_InsetRect
MOVE.L #$00030003,-(SP) ; pensize is three
_PenSize
PEA myRect(A6)
MOVE.L #$00160016,-(SP) ; and a radius for nice rounding
_FrameRoundRect ; and black out the corners
_PenNormal
MOVE.L oldPort(A6),-(SP) ; restore the previous port
_SetPort
MOVE.L gd(A6),A0
MOVE.L (A0),A0
BTST #mainScreen,gdFlags(A0) ; (mainScreen=11, in upper byte)
BEQ.S @notMain
_DrawMenuBar
@notMain
CLR result(A6) ; success
@goHome
MOVEM.L (SP)+,A2/D3-D5
MOVEM.L (SP)+,A2-A3/D3-D5
UNLK A6
RTD #result-return-4
@ -4790,13 +4674,15 @@ HasDepth FUNC EXPORT
whichMask EQU $FFFE ; the lowest bit is settable, else fail
SDVars RECORD {A6Link},DECREMENT
result DS.B 2 ; boolean result
gd DS.B 4 ; input: GDevice to set
depth DS.B 2 ; input: depth to set to
whichFlags DS.B 2 ; which GDFlags to affect
flags DS.B 2 ; input: various flags
return DS.B 4 ; return address on stack
result DS.B 2 ; 18 $12 boolean result
gd DS.B 4 ; 14 $E input: GDevice to set
depth DS.B 2 ; 12 $C input: depth to set to
whichFlags DS.B 2 ; 10 $A which GDFlags to affect
flags DS.B 2 ; 8 $8 input: various flags
return DS.B 4 ; 4 $4 return address on stack
A6Link DS.B 4 ; link
myDepth DS.B 4
moreStuff DS.B 24
linkSize DS.B 0 ; size of record
ENDR
@ -4809,13 +4695,43 @@ linkSize DS.B 0 ; size of record
MOVE whichFlags(A6),D0 ; D0 = mask of flags to change
AND flags(A6),D0 ; D0 = new flags to set
AND #whichMask,D0 ; D0 = all the bits we can't change
BNE.S @goHome ; User tried to set bits we don't yet do!
BNE @goHome ; User tried to set bits we don't yet do!
MOVEQ #0,D0
MOVE depth(A6),D0
MOVE.L D0,myDepth(A6)
CLR moreStuff+0(A6)
CLR.L moreStuff+2(A6)
CLR moreStuff+6(A6)
CLR.L moreStuff+8(A6)
CLR.L moreStuff+12(A6)
CLR -(SP)
MOVE.L gd(A6), -(SP)
PEA moreStuff(A6)
MOVE.L myDepth(A6), -(SP)
PEA -$C(A6)
CLR.L -(SP)
MOVE #$AF3,D0 ; unknown _DisplayDispatch selector
DC.W $ABEB
TST (SP)+
BNE.B @goHome
MOVEQ.L #$7F, D0
MOVEQ.L #0, D1
MOVE depth(A6), D1
CMP.L D1, D0
BLT.B @whaaa
MOVE $C(A6), D0
CMP -$C(A6), D0
BNE.B @goHome
@whaaa MOVE -$1C(A6), $12(A6)
SUBQ #2,SP
MOVE.L gd(A6),-(SP)
MOVE depth(A6),-(SP)
BSR FindModeID ; find the mode number, if it exists
MOVE (SP)+,result(A6) ; did we find one?
@goHome
UNLK A6
RTD #result-return-4
@ -5087,6 +5003,7 @@ linkSize DS.B 0 ; size of record
_HLock
MOVE.L (A0),A2 ; A2->color table to check
MOVE ctSize(A2),D3 ; D3 = last color in table
BEQ.S @goHome
MOVEQ #0, D5 ; initialized number of colors checked
; MOVE D3,D0
; ADDQ #1,D0
@ -5108,6 +5025,9 @@ linkSize DS.B 0 ; size of record
@next ADDQ #8,A2 ; Bump to next color
DBRA D3,@loop ; loop through all colors
TST D5
BEQ.S @goHome
DIVU D5,D7 ; compute average tolerance
; DIVU colorCount(A6),D7 ; compute average tolerance
CMP maxAveTol(A6),D7 ; in range?

View File

@ -9589,32 +9589,107 @@ Scale32to16 PROC EXPORT
; CLOBBERS A0-A1/D0-D5
;
tst.b -$a5(a6)
bne.s @different_implementation
lea @sexy_code,a4
move.l a4,-$228(a6)
@sexy_code
move.l a2,d2 ;get ptr to end
sub.l a1,d2 ;sub ptr to beginning
lsr.l #2,d2 ;get long cnt in d1
subq #1,d2 ;make zero based
move.l #$7fff7fff,d3
@NXTSLNG
MOVE.L (A0)+,D0 ;GET NEXT LONG OF SRC
ror.l #8,d0
lsr.w #3,d0
ror.l #5,d0
lsr.w #3,d0
ror.l #6,d0 ;16 bit pixel in high word
lsr.l #3,d0
lsl.b #3,d0
lsl #3,d0
lsr.l #6,d0
swap d0
MOVE.L (A0)+,D1 ;GET NEXT LONG OF SRC
ror.l #8,d1
lsr.w #3,d1
ror.l #5,d1
lsr.w #3,d1
ror.l #6,d1 ;16 bit pixel in high word
lsr.l #3,d1
lsl.b #3,d1
lsl #3,d1
lsr.l #6,d1
swap d1 ;merge pixels
move.w d1,d0
and.l d3,d0
move.l d0,(a1)+ ;write out 2 pixels
dbra d2,@NXTSLNG ;loop for all longs in dst scanline
RTS
@different_implementation
clr.b -$2a9(a6)
lea @sexy_code_2,a4
move.l a4,-$228(a6)
@sexy_code_2
move.l a2,d2
sub.l a1,d2
lsr.l #2,d2
subq #1,d2
moveq.l #3,d0
and.b -$2a9(a6),d0
move.l @data_tbl(d0.w*4),d3
addq.b #1,-$2a9(a6)
@loop
moveq.l #0,d1
move.l (a0)+,d0
swap d0
add.b d3,d0
scs.b d1
or.b d0,d1
lsl.l #5,d1
swap d0
move.b d0,d4
lsr #8,d0
add.b d3,d0
scs.b d1
or.b d0,d1
lsl.l #5,d1
add.b d3,d4
scs.b d1
or.b d4,d1
lsr.l #3,d1
move d1,d5
rol.l #8,d3
swap d5
moveq.l #0,d1
move.l (a0)+,d0
swap d0
add.b d3,d0
scs.b d1
or.b d0,d1
lsl.l #5,d1
swap d0
move.b d0,d4
lsr #8,d0
add.b d3,d0
scs.b d1
or.b d0,d1
lsl.l #5,d1
add.b d3,d4
scs.b d1
or.b d4,d1
lsr.l #3,d1
move d1,d5
move.l d5,(a1)+
rol.l #8,d3
dbf d2,@loop
rts
@data_tbl
dc.l $05010400
dc.l $03070206
dc.l $04000501
dc.l $02060307
; from QDciPatchROM.a verbatim <sm 6/9/92>stb

View File

@ -687,6 +687,7 @@ int main(int argc, char **argv)
my_name = patchstack[pi]->name;
original_size = longfrom(mod_sizeobj + 2);
if(original_size & 1) original_size ++; /* even-align the patches -- found this bug while reversing QuickDraw */
if(l) fprintf(l, " File \"{RomDump}\"; Line 0; File \"{RomDump}\"; Find /Entry=¶\"%.*s¶\"/ # patch ID %d, ", *my_name, my_name+1, patchstack[pi]->clean_id);
if(l) debug_print_about_patch(l, patchstack[pi]->data, patchstack[pi]->len);