LOAD 'Macros.dump' INCLUDE 'Pict.equ' INCLUDE 'Driver.equ' IMPORT D_MemoryError IMPORT D_BeachBall IMPORT Q_BgColor IMPORT Q_ChExtra IMPORT Q_DhDvText IMPORT Q_DhText IMPORT Q_DvText IMPORT Q_FgColor IMPORT D_GrowHandle IMPORT Q_LongText IMPORT D_NeedHandle IMPORT Q_PixRect IMPORT Q_PixRgn IMPORT Q_Region IMPORT Q_SpExtra IMPORT Q_Text IMPORT Q_TxFace IMPORT Q_TxFont IMPORT Q_TxMode IMPORT Q_TxSize IMPORT Q_addbytes IMPORT Q_center IMPORT Q_gotPScomm IMPORT Q_op IMPORT Q_pictSCB IMPORT Q_picterr IMPORT Q_theBGcolor IMPORT Q_theChExtra IMPORT Q_theFGcolor IMPORT Q_theMask IMPORT Q_thePnLoc IMPORT Q_thePnSize IMPORT Q_theSpExtra IMPORT Q_theTxFont IMPORT Q_theTxLoc IMPORT Q_theTxMode ENTRY Q_Angles ENTRY Q_Arc ENTRY Q_Arcs ENTRY Q_ChangePictSize ENTRY Q_Comments ENTRY Q_Copy2 ENTRY Q_Copy4 ENTRY Q_CopyPt ENTRY Q_DhDv ENTRY Q_FakeDhDv ENTRY Q_JustRect ENTRY Q_linetext ENTRY Q_manglePt ENTRY Q_Mask ENTRY Q_Nop ENTRY Q_NudgePt ENTRY Q_OvalSize ENTRY Pict_pattern ENTRY Q_PenSize ENTRY Q_Pixels ENTRY Q_Point ENTRY Q_Poly ENTRY Q_Polys ENTRY Q_Rect ENTRY Q_Rects ENTRY Q_Regions ENTRY Q_ShiftPen ENTRY Q_Undef ENTRY Q_Lfrom ENTRY Q_Line ENTRY Q_Slfrom ENTRY Q_Sline **************************************************************** * ; * Picture mangling routines ; *______________________________________________________________* * ; * Some things should be brought to the attention of ; * whoever tries to D_Read this piece of spaghetti code. ; * ; * First of all, all pictures are flipped and rotated ; * ;as if* the picture were defined in 320-mode. The actual ; * SCB for the D_New picture is no different from that of the ; * old picture, but rectangles which look approximately ; * Q_square will still look approximately Q_square when rotated. ; * Such a rectangle will in fact be twice as wide as tall if ; * it's defined in 640 mode, so before rotation, horizontal ; * values are doubled and vertical values are halved. This ; * can introduce a bit of round-off error, but it's ; * unavoidable. ; * ; * A result of this mode-faking is that occasionally, ; * a 'ShortLine' opcode will have to be translated into a ; * 'Q_Line' opcode, or a 'SLineFrom' into 'LineFrom'. For ; * this reason (and to place mangled Q_Text), the location of ; * the pen is maintained throughout the source picture. ; * ; * Secondly, naively rotated and flipped lines will not ; * appear to be mangled correctly, due to the somewhat ; * inconsistent way QuickDraw handles pensizes. Thus, the ; * pen size is also maintained, and used in Q_NudgePt. ; * ; * Third, there is some number-hacking in Q_Point rotation ; * to prevent rotated pictures from creeping up and to the ; * left. There's a comment in Q_CopyPt describing the hack. ; * ; * Other notes concerning the mangling of pixel maps, ; * Q_Text, and Q_Regions can be found in their respective files. ; * ; * -- jge, 2/4/88 ; * ; **************************************************************** **************************************************************** * * Q_ManglePict(oldpict:l,what:w) -> newpict:l -- the guts of the * picture routines. Interprets the opcodes, distributing * the work to other routines. * **************************************************************** Q_ManglePict PROC EXPORT ;Using Q_PictData EXPORT Q_linetext EXPORT Q_Rects EXPORT Q_Arcs EXPORT Q_Polys EXPORT Q_Regions EXPORT Q_Pixels EXPORT Q_Comments EXPORT Q_Nop EXPORT Q_Copy2 EXPORT Q_Copy4 EXPORT Q_Copy6 EXPORT Q_Point EXPORT Q_OvalSize EXPORT Q_PenSize EXPORT Q_Line EXPORT Q_Lfrom EXPORT Q_Sline EXPORT Q_Slfrom EXPORT Q_Rect EXPORT Q_JustRect EXPORT Q_FixRect EXPORT Q_Arc EXPORT Q_Poly EXPORT Q_DhDv EXPORT Q_ShiftPen EXPORT Q_FakeDhDv EXPORT Q_CopyPt EXPORT Q_manglePt EXPORT Q_NudgePt EXPORT Q_Angles EXPORT Pict_pattern EXPORT Q_Mask EXPORT Q_Undef EXPORT Q_ChangePictSize export oldpict export what export newpict export Q_newsize export oldptr export newptr export count export thepoint export temp input ~~oldpict:l,~~what:w output ~~newpict:l local oldsize:l,~~newsize:l local ~~oldptr:l,~~newptr:l local oldend:l local ~~count:w,~~thepoint:l,~~temp:l begin +b stz Q_picterr *--------------------------------------------------------------* * Lock down the old pict, allocate the D_New one, copy the ; * header, and compute some useful information. ; *--------------------------------------------------------------* movelong #0,Q_theTxFont movelong #0,Q_theSpExtra movelong #0,Q_theChExtra moveword #1,Q_thePnSize moveword #1,Q_thePnSize+2 moveword #0,Q_theFGcolor moveword #15,Q_theBGcolor moveword #0,Q_theTxMode movelong #$ffffffff,Q_theMask movelong #$ffffffff,Q_theMask+4 movelong #0,Q_thePnLoc movelong #0,Q_theTxLoc stz Q_gotPScomm pushlong DC.L Q_Undef ; 11 = DC.L Q_ChExtra ; 12 = char extra DC.L Q_Mask ; 13 = pen Q_Mask DC.L Q_Copy4 ; 14 = Q_Arc rot?? DC.L Q_Copy4 ; 15 = font flags *--------------------------------------------------------------* * The short routine table ; *--------------------------------------------------------------* h_table2 DC.L Q_linetext ; 2x = lines or Q_Text DC.L Q_Rects ; 3x = rectangle DC.L Q_Rects ; 4x = round Q_Rect DC.L Q_Rects ; 5x = oval DC.L Q_Arcs ; 6x = Q_Arc DC.L Q_Polys ; 7x = polygon DC.L Q_Regions ; 8x = Q_Region DC.L Q_Pixels ; 9x = Q_Pixels DC.L Q_Comments ; Ax = Q_Comments **************************************************************** * ; * DRAWING OPCODE-GROUP ROUTINES ; * ; **************************************************************** *--------------------------------------------------------------* * Copy lines or Q_Text, depending on low nybble of Q_op ; *--------------------------------------------------------------* Q_linetext ; lda Q_op ; get the low nybble and #$f jtl lt_table rtl lt_table DC.L Q_Line ; 20 = Q_Line DC.L Q_Lfrom ; 21 = Q_Line from DC.L Q_Sline ; 22 = short Q_Line DC.L Q_Slfrom ; 23 = short Q_Line from DC.L Q_Undef ; 24 = DC.L Q_Undef ; 25 = DC.L Q_Undef ; 26 = DC.L Q_Undef ; 27 = DC.L Q_Text ; 28 = Q_Text DC.L Q_DhText ; 29 = dh Q_Text DC.L Q_DvText ; 2A = dv Q_Text DC.L Q_DhDvText ; 2B = offset Q_Text DC.L Q_LongText ; 2C = long Q_Text DC.L Q_Undef ; 2D = DC.L Q_Undef ; 2E = DC.L Q_Undef ; 2F = *--------------------------------------------------------------* * Copy Q_Rect opcode and parameters (if any) ; *--------------------------------------------------------------* Q_Rects ; lda Q_op ; get the low three bits and #7 cmp #5 ; is this legal? jgt Q_Undef lda Q_op and #8 ; same Q_Rect? jeq Q_Rect ; if not, copy the D_New one jmp Q_Nop ; otherwise, just the opcode will do *--------------------------------------------------------------* * Copy Q_Arc opcode and parameters (if any) ; *--------------------------------------------------------------* Q_Arcs ; lda Q_op ; get the low nybble and #$7 cmp #$5 ; is this legal? jgt Q_Undef lda Q_op and #$8 ; same? jeq Q_Arc ; if not, copy the D_New one jsl Q_Nop ; if so, just copy the opcode jmp Q_Angles ; and the Q_Angles *--------------------------------------------------------------* * Copy Q_Poly opcode and parameters (if any) ; *--------------------------------------------------------------* Q_Polys ; lda Q_op ; get the low nybble and #$7 cmp #$5 ; is this legal? jgt Q_Undef lda Q_op and #$8 ; same? jeq Q_Poly ; if not, copy it jmp Q_Nop ; else, just copy the opcode *--------------------------------------------------------------* * Copy Q_Region opcode and parameters (if any) ; *--------------------------------------------------------------* Q_Regions ; lda Q_op ; get the low nybble and #$7 cmp #$5 ; is this legal? jgt Q_Undef lda Q_op and #$8 ; same? jeq Q_Region ; if not, copy the D_New one jmp Q_Nop ; else just copy the opcode *--------------------------------------------------------------* * Copy pixelmap opcode and parameters ; *--------------------------------------------------------------* Q_Pixels ; cmpw Q_op,#$91 jgt Q_Undef jeq Q_PixRgn jmp Q_PixRect *--------------------------------------------------------------* * Copy comment opcode and data ; * Now mangles the first PSHandle comment appropriately ; *--------------------------------------------------------------* Q_Comments ; cmpw Q_op,#$A1 jne Q_Undef jsl Q_Copy2 ; copy the opcode moveword [ P U N T < ; cmp #256-64 ; bgt dosline ; movelong #2,Q_addbytes ; What luck. Change the pict size jsl Q_ChangePictSize ; to accomodate the different opcode moveword #$20,[ P U N T < ; cmp #265-64 ; bgt doslfrom movelong #2,Q_addbytes ; What luck. Change the pict size jsl Q_ChangePictSize ; to accomodate the different opcode moveword #$21,[ clc adc Q_center+2 ; pt.x <= -(pt.y - Q_center.y) + Q_center.x adc Q_center sta clc adc Q_center sec sbc Q_center+2 sta clc adc Q_center ; pt.y <= -(pt.x - Q_center.x) + Q_center.y adc Q_center+2 sta clc adc Q_center+2 sec sbc Q_center sta **************************************************************** * ; * MISCELLANY ; * ; **************************************************************** *--------------------------------------------------------------* * Abort! An undefined opcode was found! ; *--------------------------------------------------------------* Q_Undef ; moveword #$A501,Q_picterr sec rtl *--------------------------------------------------------------* * Add Q_addbytes to newpict and D_Update the pointer ; *--------------------------------------------------------------* Q_ChangePictSize ; sublong