mac-rom/QuickDraw/PutRgn.a

119 lines
3.7 KiB
Plaintext
Raw Normal View History

;EASE$$$ READ ONLY COPY of file <20>PUTRGN.a<>
;<3B>1.4 BAL 05/29/1989 Blasting in 32-Bit QuickDraw version 1.0 Final
; File PutRgn.a
;
; Copyright Apple Computer, Inc. 1981-1986
; All Rights Reserved
BLANKS ON
STRING ASIS
;------------------------------------------------
;
; MODIFICATION HISTORY
;
; 26Sep86 EHB Fixed putRgn of rectangular region bug
;
PUTRGN PROC EXPORT
IMPORT SetHSize
;----------------------------------------------------------------
;
; PROCEDURE PutRgn(Rgn: RgnHandle; bufHandle: Handle; VAR index,size: INTEGER);
;
; Expands a region out to an array of inversion points.
;
;------------------------------------------------
;
; A6 OFFSETS OF PARAMETERS AFTER LINK:
;
PARAMSIZE EQU 16 ;TOTAL SIZE OF PARAMETERS
RGNHANDLE EQU PARAMSIZE+8-4 ;LONG,RGNHANDLE
BUFHANDLE EQU RGNHANDLE-4 ;LONG, HANDLE
INDEX EQU BUFHANDLE-4 ;LONG, VAR
SIZE EQU INDEX-4 ;LONG, VAR
LINK A6,#0 ;NO LOCAL VARS
MOVEM.L D7/A2-A4,-(SP) ;SAVE REGS
;-------------------------------------------------------
;
; EXPAND BUF TO FIT WORST CASE BYTESNEEDED = RGNSIZE * 2
;
MOVE.L BUFHANDLE(A6),A4 ;GET BUFHANDLE
MOVE.L RGNHANDLE(A6),A3 ;GET RGNHANDLE
MOVE.L INDEX(A6),A2 ;POINT TO CURRENT INDEX
MOVE.L (A3),A0 ;DE-REFERENCE RGN
moveq #0,d7 ;clearout high end <BAL 28Apr89>
MOVE (A0),D7 ;GET RGNSIZE
ADD.l D7,D7 ;TIMES 2 <BAL 28Apr89>
moveq #0,d0 ;clearout high end <BAL 28Apr89>
move (A2),d0 ;get current index as a long <BAL 28Apr89>
ADD.l d0,D7 ;ADD CURRENT INDEX <BAL 28Apr89>
cmp.l #65536-256,d7 ;are we about to overflow? <BAL 28Apr89>
blt.s @sizeOK ;no, don't worry; be happy <BAL 28Apr89>
move #-147,qdErr ;indicate rgnTooBigErr <BAL 28Apr89>
bra GOHOME ;skip this line <BAL 28Apr89>
@sizeOK MOVE.L SIZE(A6),A1 ;POINT TO SIZE
CMP (A1),D7 ;IS REQUIRED > CURRENT SIZE ?
bls.s NOGROW ;NO, CONTINUE <BAL 28Apr89>
ADD #256,D7 ;GROW IN CHUNKS
MOVE D7,(A1) ;UPDATE CURRENT SIZE
MOVE.L A4,-(SP) ;PUSH BUFHANDLE
MOVE D7,-(SP) ;PUSH NEW SIZE
bsr.l SetHSize ;MAKE ROOM IN BUF
MOVE.L (A3),A0 ;RE-DEREFERENCE RGNHANDLE
MOVE.L INDEX(A6),A2 ;GET ADDR OF INDEX AGAIN
NOGROW MOVE.L (A4),A1 ;DE-REFERENCE BUFHANDLE
moveq #0,d0 ;clear out high end <BAL 28Apr89>
move.w (a2),d0 ;get index as a long <BAL 28Apr89>
add.l d0,A1 ;ADD INDEX TO BUFPTR <BAL 28Apr89>
CMP #10,RGNSIZE(A0) ;IS REGION RECTANGULAR ?
BNE.S NOTRECT ;NO, CONTINUE
; PUT RECT AS INVERSION POINTS: TOPLEFT, TOPRIGHT, BOTLEFT, BOTRIGHT
ADD #2,A0 ;YES, POINT TO BBOX TOPLEFT
MOVE.L (A0),(A1)+ ;COPY TOPLEFT <EHB 26Sep86>
MOVE (A0)+,(A1)+ ;COPY TOP <EHB 26Sep86>
MOVE (A0)+,D0 ;GET LEFT <EHB 26Sep86>
MOVE.L (A0),D1 ;GET BOTRIGHT <EHB 26Sep86>
MOVE D1,(A1)+ ;COPY RIGHT <EHB 26Sep86>
MOVE (A0),(A1)+ ;COPY BOT <EHB 26Sep86>
MOVE D0,(A1)+ ;COPY LEFT <EHB 26Sep86>
MOVE.L D1,(A1)+ ;COPY BOTRIGHT <EHB 26Sep86>
BRA.S DONE ;UPDATE INDEX AND QUIT
NOTRECT LEA RGNDATA(A0),A0 ;POINT TO TOP VERT IN RGN
NXTVERT MOVE.L (A0)+,D7 ;GET VERT AND HORIZ COORDS
NXTHOR MOVE.L D7,(A1)+ ;PUT LEFT POINT TO DST
MOVE (A0)+,D7 ;GET HORIZ COORD
MOVE.L D7,(A1)+ ;PUT RIGHT POINT TO DST
MOVE (A0)+,D7 ;GET NEXT HORIZ COORD
CMP #32767,D7 ;END OF SCAN FLAG ?
BNE NXTHOR ;NO, GO FOR MORE
CMP #32767,(A0) ;END OF REGION ?
BNE NXTVERT ;NO, LOOP FOR MORE
DONE SUB.L (A4),A1 ;CALC DSTPTR - DSTSTART
MOVE A1,(A2) ;UPDATE VAR INDEX
GOHOME MOVEM.L (SP)+,D7/A2-A4 ;RESTORE REGISTERS
UNLINK PARAMSIZE,'PUTRGN '
ENDPROC