/*
 * @(#)PictStructs.txt  1.0  2010-06-25
 *
 * Copyright (c) 2010 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the
 * license agreement you entered into with Werner Randelshofer.
 * For details see accompanying license terms.
 */

/** QuickDraw Picture Opcodes
 * http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-458.html
 */

/* Picture Record. */
magic Picture "Picture";
typedef struct {
    ushort picSize;
    Rect picFrame;
} Picture;

/* Rect Structure 
 */
typedef struct {
    short top;
    short left;
    short bottom;
    short right;
} Rect;

/* Point Structure 
 */
typedef struct {
    short x;
    short y;
} Point;

/* RGBColor Structure 
 */
typedef struct {
    ushort red;
    ushort green;
    ushort blue;
} RGBColor;

/* Fixed Structure */
typedef struct {
    short decimalPart;
    short fractionalPart;
} Fixed;

/* Rgn Struct
 *
 */
typedef struct {
    ushort regionSize;
    Rect regionRect;
} Rgn;

/* Poly Struct
 *
 */
typedef struct {
    ushort polySize;
    Rect boundingRectangle;
    Point[] points;
} Poly;


/* PixMap Struct 
 * http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-202.html
 */
typedef struct {
    uint baseAddr; // Pointer to the image data
    ushort rowbytes; // Flags, and bytes in a row
    Rect boundsTop; // Boundary rectangle
    ushort pmVersion; // Pixel map version number
    ushort packType; // Packing format
    uint packSize; // Size of data in packed state
    Fixed hRes; // Horizontal resolution in dots per inch 
    Fixed vRes; // Vertical resolution in dots per inch 
    ushort pixelType; // Format of pixel image
    ushort pixelSize; // Physical bits per pixel
    ushort cmpCount; // Number of components in each pixel
    ushort cmpSize; // Number of bits per component
    uint planeBytes; // Offset to next plane
    uint pmTable; // Handle to a color table for this image
    uint pmReserved; // Reserved
} PixMap;

typedef struct {
    //uint baseAddr; // Pointer to the image data
    ushort rowbytes; // Flags, and bytes in a row
    Rect boundsTop; // Boundary rectangle
    ushort version; // Pixel map version number
    ushort packType; // Packing format
    uint packSize; // Size of data in packed state
    Fixed hRes; // Horizontal resolution in dots per inch 
    Fixed vRes; // Vertical resolution in dots per inch 
    ushort pixelType; // Format of pixel image
    ushort pixelSize; // Physical bits per pixel
    ushort cmpCount; // Number of components in each pixel
    ushort cmpSize; // Number of bits per component
    uint planeBytes; // Offset to next plane
    uint colorTable; // Handle to a color table for this image
    uint reserved; // Reserved
    uint reserved2; // Reserved
} PixMapShifted;

/* PixData Struct
 * http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-461.html#HEADING461-0
 * PixData:
 * IF packType = 1 (unpacked) OR rowbytes < 8 THEN 
 *  data is unpacked; 
 *  data size = rowBytes * (bounds.bottom - bounds.top);
 *
 * IF packType = 2 (drop pad byte) THEN 
 *  the high-order pad byte of a 32-bit direct pixel is 
 *  dropped; 
 *  data size = (3/4) * rowBytes * 
 *  (bounds.bottom - bounds.top);
 *
 * IF packType > 2 (packed) THEN 
 *  image contains (bounds.bottom - bounds.top) packed 
 *  scan lines;
 *  each scan line consists of [byteCount] [data];
 *  IF rowBytes > 250 THEN 
 *     byteCount is a word
 *  ELSE 
 *     it is a byte
 *
 * Here are the currently defined packing types:
 * Packing type	Meaning 
 * 0	Use default packing
 * 1	Use no packing
 * 2	Remove pad byte--supported only for 32-bit pixels 
 * (24-bit data)
 * 3	Run length encoding by pixelSize chunks, one scan line 
 * at a time--supported only for 16-bit pixels
 * 4	Run length encoding one component at a time, one scan 
 * line at a time, red component first--supported only for 
 * 32-bit pixels (24-bit data)
 */
typedef struct {
    ubyte[] data;
} PixData;

/* ColorTable
 * http://developer.apple.com/documentation/mac/quickdraw/QuickDraw-206.html#MARKER-14-266
 */
typedef struct {
    //int seed; // unique identifier from table
    ushort flags; //flags describing the value in the 
                 // table field; clear for a pixel map
    ushort size;  // number of entries in the next field minus 1
    ColorSpec[size+1] table; // an array of ColorSpec records
} ColorTable;

/* ColorSpec
 * http://developer.apple.com/documentation/mac/quickdraw/QuickDraw-205.html
 */
typedef struct {
    short value; // index or other value
    RGBColor rgb; // true color
} ColorSpec;

/* NOP OpCode */
magic NOPOp ushort 0x0000;
description NOPOp "NOP", "No operation (0)";
typedef struct {
} NOPOp;

/* Clip OpCode */
magic ClipOp ushort 0x0001;
description ClipOp "Clip", "Clipping region (Region size)";
typedef struct {
    Rgn clippingRegion;
} ClipOp;

/* BkPat OpCode */
magic BkPatOp ushort 0x0002;
description BkPatOp "BkPat", "Background pattern (8)";
typedef struct {
    byte[8] backgroundPattern;
} BkPatOp;

/* TxFont OpCode */
magic TxFontOp ushort 0x0003;
description TxFontOp "TxFont", "Font number for text (Integer) (2)";
typedef struct {
    short fontNumber;
} TxFontOp;

/* TxFace OpCode */
magic TxFaceOp ushort 0x0004;
description TxFaceOp "TxFace", "Text's font style (0..255) (1)";
typedef struct {
    ubyte fontStyle;
    ubyte filler;
} TxFaceOp;

/* TxMode OpCode */
magic TxModeOp ushort 0x0005;
description TxModeOp "TxMode", "Source mode (Integer) (2)";
typedef struct {
    short sourceMode;
} TxModeOp;


/* SpExtra OpCode */
magic SpExtraOp ushort 0x0006;
description SpExtraOp "SpExtra", "Extra space (Fixed) (4)";
typedef struct {
    Fixed extraSpace;
} SpExtraOp;

/* PnSize OpCode */
magic PnSizeOp ushort 0x0007;
description PnSizeOp "PnSize", "Pen size (Point) (4)";
typedef struct {
    Point penSize;
} PnSizeOp;

/* PnMode OpCode */
magic PnModeOp ushort 0x0008;
description PnModeOp "PnMode", "Pen mode (Integer) (2)";
typedef struct {
    short penMode;
} PnModeOp;

/* PnPat OpCode */
magic PnPatOp ushort 0x0009;
description PnPatOp "PnPat", "Pen pattern (8)";
typedef struct {
    ubyte[8] penPattern;
} PnPatOp;

/* FillPat OpCode */
magic FillPatOp ushort 0x000A;
description FillPatOp "FillPat", "Fill pattern (8)";
typedef struct {
    ubyte[8] fillPattern;
} FillPatOp;

/* OvSize OpCode */
magic OvSizeOp ushort 0x000B;
description OvSizeOp "OvSize", "Oval size (Point) (4)";
typedef struct {
    Point ovalSize;
} OvSizeOp;

/* Origin OpCode */
magic OriginOp ushort 0x000C;
description OriginOp "Origin", "dh, dv (Integer) (4)";
typedef struct {
    short dh;
    short dv;
} OriginOp;

/* TxSize OpCode */
magic TxSizeOp ushort 0x000D;
description TxSizeOp "TxSize", "Text size (Integer) (2)";
typedef struct {
    short textSize;
} TxSizeOp;

/* FgColor OpCode */
magic FgColorOp ushort 0x000E;
description FgColorOp "FgColor", "Foreground color (Long) (4)";
typedef struct {
    int color;
} FgColorOp;

/* BkColor OpCode */
magic BkColorOp ushort 0x000F;
description BkColorOp "BkColor", "Background color (Long) (4)";
typedef struct {
    int color;
} BkColorOp;

/* TxRatio OpCode */
magic TxRatioOp ushort 0x0010;
description TxRatioOp "TxRatio", "Numerator (Point), denominator (Point) (8)";
typedef struct {
    Point numerator;
    Point denominator;
} TxRatioOp;

/* Version OpCode */
magic VersionOp ushort 0x0011;
description VersionOp "Version", "Version (0..255) (1)";
typedef struct {
    ubyte version;
    ubyte filler;
} VersionOp;

/* Listing A-1 Data for the BkPixPat, PnPixPat, and FillPixPat opcodes
IF patType = ditherPat  
THEN
   PatType:    word;       {pattern type = 2}
   Pat1Data:   Pattern;    {old pattern data}
   RGB:        RGBColor;   {desired RGB for pattern}
ELSE 
   PatType:    word;       {pattern type = 1}
   Pat1Data:   Pattern;    {old pattern data}
   PixMap:     PixMap;
   ColorTable: ColorTable;
   PixData:    PixData;    
END;
 */

/* BkPixPat OpCode */
magic BkPixPatOp ushort 0x0012;
description BkPixPatOp "BkPixPat", "Background pixel pattern (Variable; see Listing A-1 on page A-17)";
typedef struct {
} BkPixPatOp;

/* PnPixPat OpCode */
magic PnPixPatOp ushort 0x0013;
description PnPixPatOp "PnPixPat", "Pen pixel pattern (Variable; see Listing A-1 on page A-17)";
typedef struct {
} PnPixPatOp;

/* FillPixPat OpCode */

magic FillPixPatOp ushort 0x0014;
description FillPixPatOp "FillPixPat", "Fill pixel pattern (Variable; see Listing A-1 on page A-17)";
typedef struct {
} FillPixPatOp;

/* PnLocHFrac OpCode */
magic PnLocHFracOp ushort 0x0015;
description PnLocHFracOp "PnLocHFrac", "Fractional pen position (Integer--low word of Fixed); if value is not 0.5, pen position is always set to the picture before each text-drawing operation. (2)";
typedef struct {
    short fractionalPenPosition;
} PnLocHFracOp;

/* ChExtra OpCode */
magic ChExtraOp ushort 0x0016;
description ChExtraOp "ChExtra", "Added width for nonspace characters (Integer) (2)";
typedef struct {
    short addedWidth;
} ChExtraOp;

/* Reserved for Apple use OpCode */
magic Reserved0017Op ushort 0x0017;
description Reserved0017Op "Reserved for Apple use", "  (Not determined)";
typedef struct {
} Reserved0017Op;

/* Reserved for Apple use OpCode */
magic Reserved0018Op ushort 0x0018;
description Reserved0018Op "Reserved for Apple use", "  (Not determined)";
typedef struct {
} Reserved0018Op;

/* Reserved for Apple use OpCode */
magic Reserved0019Op ushort 0x0019;
description Reserved0019Op "Reserved for Apple use", "  (Not determined)";
typedef struct {
} Reserved0019Op;

/* RGBFgCol OpCode */
magic RGBFgColOp ushort 0x001A;
description RGBFgColOp "RGBFgCol", "Foreground color (RGBColor) (6)";
typedef struct {
    RGBColor color;
} RGBFgColOp;

/* RGBBkCol OpCode */
magic RGBBkColOp ushort 0x001B;
description RGBBkColOp "RGBBkCol", "Background color (RGBColor) (6)";
typedef struct {
    RGBColor color;
} RGBBkColOp;

/* HiliteMode OpCode */
magic HiliteModeOp ushort 0x001C;
description HiliteModeOp "HiliteMode", "Highlight mode flag: no data; this opcode is sent before a drawing operation that uses the highlight mode (0)";
typedef struct {
} HiliteModeOp;

/* HiliteColor OpCode */
magic HiliteColorOp ushort 0x001D;
description HiliteColorOp "HiliteColor", "Highlight color (RGBColor) (6)";
typedef struct {
    RGBColor color;
} HiliteColorOp;

/* DefHilite OpCode */
magic DefHiliteOp ushort 0x001E;
description DefHiliteOp "DefHilite", "Use default highlight color; no data; set highlight to default (from low memory) (0)";
typedef struct {
} DefHiliteOp;

/* OpColor OpCode */
magic OpColorOp ushort 0x001F;
description OpColorOp "OpColor", "Opcolor (RGBColor) (6)";
typedef struct {
    RGBColor color;
} OpColorOp;

/* Line OpCode */
magic LineOp ushort 0x0020;
description LineOp "Line", "pnLoc (Point), newPt (Point) (8)";
typedef struct {
    Point pnLoc;
    Point newPt;
} LineOp;

/* LineFrom OpCode */
magic LineFromOp ushort 0x0021;
description LineFromOp "LineFrom", "newPt (Point) (4)";
typedef struct {
    Point newPt;
} LineFromOp;

/* ShortLine OpCode */
magic ShortLineOp ushort 0x0022;
description ShortLineOp "ShortLine", "pnLoc (Point), dh (-128..127), dv (-128..127) (6)";
typedef struct {
    Point pnLoc;
    byte dh;
    byte dv;
} ShortLineOp;

/* ShortLineFrom OpCode */
magic ShortLineFromOp ushort 0x0023;
description ShortLineFromOp "ShortLineFrom", "dh (-128..127), dv (-128..127) (2)";
typedef struct {
    byte dh;
    byte dv;
} ShortLineFromOp;

/* Reserved for Apple use OpCode */
magic Reserved0024Through0027Op ushort 0x0024 .. 0x0026;
description Reserved0024Through0027Op "Reserved for Apple use", "Data length (Integer), data (2 + data length)";
typedef struct {
    short dataLength;
    byte[dataLength] data;
} Reserved0024Through0027Op;




/* LongText OpCode */
magic LongTextOp ushort 0x0028;
description LongTextOp "LongText", "txLoc (Point), count (0..255), text (5 + text)";
typedef struct {
    Point txLoc;
    ubyte count;
    charbyte[count] text;
} LongTextOp;

/* DHText OpCode */
magic DHTextOp ushort 0x0029;
description DHTextOp "DHText", "dh (0..255), count (0..255), text (2 + text)";
typedef struct {
    ubyte dh;
    ubyte count;
    charbyte[count] text;
} DHTextOp;

/* DVText OpCode */
magic DVTextOp ushort 0x002A;
description DVTextOp "DVText", "dv (0..255), count (0..255), text (2 + text)";
typedef struct {
    ubyte dv;
    ubyte count;
    charbyte[count] text;
} DVTextOp;

/* DHDVText OpCode */
magic DHDVTextOp ushort 0x002B;
description DHDVTextOp "DHDVText", "dh (0..255), dv (0..255), count (0..255), text (3 + text)";
typedef struct {
    ubyte dh;
    ubyte dv;
    ubyte count;
    charbyte[count] text;
} DHDVTextOp;

/* fontName OpCode */
magic FontNameOp ushort 0x002C;
description FontNameOp "fontName", "Data length (Integer), old font ID (Integer), name length (0..255), font name[1] (5 + name length)";
typedef struct {
    short dataLength;
    short oldFontId;
    ubyte nameLength;
    charbyte[nameLength] fontName;
} FontNameOp;

/* lineJustify OpCode */
magic LineJustifyOp ushort 0x002D;
description LineJustifyOp "lineJustify", "Operand data length (Integer), intercharacter spacing (Fixed), total extra space for justification (Fixed)[2] (10)";
typedef struct {
    short operandDataLength;
    Fixed intercharacterSpacing;
    Fixed totalExtraSpaceForJustification;
} LineJustifyOp;

/* glyphState OpCode */
magic GlyphStateOp ushort 0x002E;
description GlyphStateOp "glyphState", "Data length (word), followed by these 1-byte Boolean values: outline preferred, preserve glyph, fractional widths, scaling disabled (8)";
typedef struct {
    ushort dataLength;
    byte outlinePreferred;
    byte preserveGlyph;
    byte fractionalWidths;
    byte scalingDisabled;
} GlyphStateOp;


/* Reserved for Apple use OpCode */
magic Reserved002fOp ushort 0x002F;
description Reserved002fOp "Reserved for Apple use", "Data length (Integer), data (2 + data length)";
typedef struct {
} Reserved002fOp;

/* frameRect OpCode */
magic FrameRectOp ushort 0x0030;
description FrameRectOp "frameRect", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} FrameRectOp;

/* paintRect OpCode */
magic PaintRectOp ushort 0x0031;
description PaintRectOp "paintRect", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} PaintRectOp;

/* eraseRect OpCode */
magic EraseRectOp ushort 0x0032;
description EraseRectOp "eraseRect", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} EraseRectOp;

/* invertRect OpCode */
magic InvertRectOp ushort 0x0033;
description InvertRectOp "invertRect", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} InvertRectOp;

/* fillRect OpCode */
magic FillRectOp ushort 0x0034;
description FillRectOp "fillRect", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} FillRectOp;

/* Reserved for Apple use OpCode */
magic Reserved0035Through0037Op ushort 0x0035 .. 0x0037;
description Reserved0035Through0037Op "Reserved for Apple use", "8 bytes of data (8)";
typedef struct {
    byte[8] data;
} Reserved0035Through0037Op;



/* frameSameRect OpCode */
magic FrameSameRectOp ushort 0x0038;
description FrameSameRectOp "frameSameRect", "Rectangle (Rect) (0)";
typedef struct {
} FrameSameRectOp;

/* paintSameRect OpCode */
magic PaintSameRectOp ushort 0x0039;
description PaintSameRectOp "paintSameRect", "Rectangle (Rect) (0)";
typedef struct {
} PaintSameRectOp;

/* eraseSameRect OpCode */
magic EraseSameRectOp ushort 0x003A;
description EraseSameRectOp "eraseSameRect", "Rectangle (Rect) (0)";
typedef struct {
} EraseSameRectOp;

/* invertSameRect OpCode */
magic InvertSameRectOp ushort 0x003B;
description InvertSameRectOp "invertSameRect", "Rectangle (Rect) (0)";
typedef struct {
} InvertSameRectOp;

/* fillSameRect OpCode */
magic FillSameRectOp ushort 0x003C;
description FillSameRectOp "fillSameRect", "Rectangle (Rect) (0)";
typedef struct {
} FillSameRectOp;

/* Reserved for Apple use OpCode */
magic Reserved003dThrough003fOp ushort 0x003D .. 0x003F;
description Reserved003dThrough003fOp "Reserved for Apple use", "  (0)";
typedef struct {
} Reserved003dThrough003fOp;



/* frameRRect OpCode */
magic FrameRRectOp ushort 0x0040;
description FrameRRectOp "frameRRect", "Rectangle (Rect). Uses the setting of the OvSize point. (8)";
typedef struct {
    Rect rectangle;
} FrameRRectOp;

/* paintRRect OpCode */
magic PaintRRectOp ushort 0x0041;
description PaintRRectOp "paintRRect", "Rectangle (Rect). Uses the setting of the OvSize point. (8)";
typedef struct {
    Rect rectangle;
} PaintRRectOp;

/* eraseRRect OpCode */
magic EraseRRectOp ushort 0x0042;
description EraseRRectOp "eraseRRect", "Rectangle (Rect). Uses the setting of the OvSize point. (8)";
typedef struct {
    Rect rectangle;
} EraseRRectOp;

/* invertRRect OpCode 
* For opcodes $0040-$0044: rounded rectangles use the setting of the OvSize point (refer to opcode $000B). 
*/
magic InvertRRectOp ushort 0x0043;
description InvertRRectOp "invertRRect", "Rectangle (Rect). Uses the setting of the OvSize point. (8)";
typedef struct {
    Rect rectangle;
} InvertRRectOp;

/* fillRRect OpCode */
magic fillRRectOp ushort 0x0044;
description FillRRectOp "fillRRect", "Rectangle (Rect)[3] (8)";
typedef struct {
    Rect rectangle;
} FillRRectOp;

/* Reserved for Apple use OpCode */
magic Reserved0045Through0047Op ushort 0x0045 .. 0x0047;
description Reserved0045Through0047Op "Reserved for Apple use", "8 bytes of data (8)";
typedef struct {
    byte[8] data;
} Reserved0045Through0047Op;



/* frameSameRRect OpCode */
magic FrameSameRRectOp ushort 0x0048;
description FrameSameRRectOp "frameSameRRect", "Rectangle (Rect) (0)";
typedef struct {
} FrameSameRRectOp;

/* paintSameRRect OpCode */
magic PaintSameRRectOp ushort 0x0049;
description PaintSameRRectOp "paintSameRRect", "Rectangle (Rect) (0)";
typedef struct {
} PaintSameRRectOp;

/* eraseSameRRect OpCode */
magic EraseSameRRectOp ushort 0x004A;
description EraseSameRRectOp "eraseSameRRect", "Rectangle (Rect) (0)";
typedef struct {
} EraseSameRRectOp;

/* invertSameRRect OpCode */
magic InvertSameRRectOp ushort 0x004B;
description InvertSameRRectOp "invertSameRRect", "Rectangle (Rect) (0)";
typedef struct {
} InvertSameRRectOp;

/* fillSameRRect OpCode */
magic FillSameRRectOp ushort 0x004C;
description FillSameRRectOp "fillSameRRect", "Rectangle (Rect) (0)";
typedef struct {
} FillSameRRectOp;

/* Reserved for Apple use OpCode */
magic Reserved004dThrough004fOp ushort 0x004D .. 0x004f;
description Reserved004dThrough004fOp "Reserved for Apple use", "  (0)";
typedef struct {
} Reserved004dThrough004fOp;



/* frameOval OpCode */
magic FrameOvalOp ushort 0x0050;
description FrameOvalOp "frameOval", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} FrameOvalOp;

/* paintOval OpCode */
magic PaintOvalOp ushort 0x0051;
description PaintOvalOp "paintOval", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} PaintOvalOp;

/* eraseOval OpCode */
magic EraseOvalOp ushort 0x0052;
description EraseOvalOp "eraseOval", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} EraseOvalOp;

/* invertOval OpCode */
magic InvertOvalOp ushort 0x0053;
description InvertOvalOp "invertOval", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} InvertOvalOp;

/* fillOval OpCode */
magic FillOvalOp ushort 0x0054;
description FillOvalOp "fillOval", "Rectangle (Rect) (8)";
typedef struct {
    Rect rectangle;
} FillOvalOp;

/* Reserved for Apple use OpCode */
magic Reserved0055Through0057Op ushort 0x0055 .. 0x0057;
description Reserved0055Through0057Op "Reserved for Apple use", "8 bytes of data (8)";
typedef struct {
    byte[8] data;
} Reserved0055Through0057Op;



/* frameSameOval OpCode */
magic FrameSameOvalOp ushort 0x0058;
description FrameSameOvalOp "frameSameOval", "Rectangle (Rect) (0)";
typedef struct {
} FrameSameOvalOp;

/* paintSameOval OpCode */
magic PaintSameOvalOp ushort 0x0059;
description PaintSameOvalOp "paintSameOval", "Rectangle (Rect) (0)";
typedef struct {
} PaintSameOvalOp;

/* eraseSameOval OpCode */
magic EraseSameOvalOp ushort 0x005A;
description EraseSameOvalOp "eraseSameOval", "Rectangle (Rect) (0)";
typedef struct {
} EraseSameOvalOp;

/* invertSameOval OpCode */
magic InvertSameOvalOp ushort 0x005B;
description InvertSameOvalOp "invertSameOval", "Rectangle (Rect) (0)";
typedef struct {
} InvertSameOvalOp;

/* fillSameOval OpCode */
magic FillSameOvalOp ushort 0x005C;
description FillSameOvalOp "fillSameOval", "Rectangle (Rect) (0)";
typedef struct {
} FillSameOvalOp;

/* Reserved for Apple use OpCode */
magic Reserved005dThrough005fOp ushort 0x005D .. 0x005f;
description Reserved005dThrough005fOp "Reserved for Apple use", "  (0)";
typedef struct {
} Reserved005dThrough005fOp;



/* frameArc OpCode */
magic FrameArcOp ushort 0x0060;
description FrameArcOp "frameArc", "Rectangle (Rect), startAngle, arcAngle (12)";
typedef struct {
    Rect rectangle;
    short startAngle;
    short arcAngle;
} FrameArcOp;

/* paintArc OpCode */
magic PaintArcOp ushort 0x0061;
description PaintArcOp "paintArc", "Rectangle (Rect), startAngle, arcAngle (12)";
typedef struct {
    Rect rectangle;
    short startAngle;
    short arcAngle;
} PaintArcOp;

/* eraseArc OpCode */
magic EraseArcOp ushort 0x0062;
description EraseArcOp "eraseArc", "Rectangle (Rect), startAngle, arcAngle (12)";
typedef struct {
    Rect rectangle;
    short startAngle;
    short arcAngle;
} EraseArcOp;

/* invertArc OpCode */
magic InvertArcOp ushort 0x0063;
description InvertArcOp "invertArc", "Rectangle (Rect), startAngle, arcAngle (12)";
typedef struct {
    Rect rectangle;
    short startAngle;
    short arcAngle;
} InvertArcOp;

/* fillArc OpCode */
magic FillArcOp ushort 0x0064;
description FillArcOp "fillArc", "Rectangle (Rect), startAngle, arcAngle (12)";
typedef struct {
    Rect rectangle;
    short startAngle;
    short arcAngle;
} FillArcOp;

/* Reserved for Apple use OpCode */
magic Reserved0065Through0067Op ushort 0x0065 .. 0x0067;
description Reserved0065Through0067Op "Reserved for Apple use", "12 bytes of data (12)";
typedef struct {
    byte[12] data;
} Reserved0065Through0067Op;




/* frameSameArc OpCode */
magic FrameSameArcOp ushort 0x0068;
description FrameSameArcOp "frameSameArc", "Rectangle (Rect) (4)";
typedef struct {
    Rect rectangle;
} FrameSameArcOp;

/* paintSameArc OpCode */
magic PaintSameArcOp ushort 0x0069;
description PaintSameArcOp "paintSameArc", "Rectangle (Rect) (4)";
typedef struct {
    Rect rectangle;
} PaintSameArcOp;

/* eraseSameArc OpCode */
magic EraseSameArcOp ushort 0x006A;
description EraseSameArcOp "eraseSameArc", "Rectangle (Rect) (4)";
typedef struct {
    Rect rectangle;
} EraseSameArcOp;

/* invertSameArc OpCode */
magic InvertSameArcOp ushort 0x006B;
description InvertSameArcOp "invertSameArc", "Rectangle (Rect) (4)";
typedef struct {
    Rect rectangle;
} InvertSameArcOp;

/* fillSameArc OpCode */
magic FillSameArcOp ushort 0x006C;
description FillSameArcOp "fillSameArc", "Rectangle (Rect) (4)";
typedef struct {
    Rect rectangle;
} FillSameArcOp;

/* Reserved for Apple use OpCode */
magic Reserved006dThrough006fOp ushort 0x006D .. 0x006f;
description Reserved006dThrough006fOp "Reserved for Apple use", "4 bytes of data (4)";
typedef struct {
    byte[4] data;
} Reserved006dThrough006fOp;



/* framePoly OpCode */
magic FramePolyOp ushort 0x0070;
description FramePolyOp "framePoly", "Polygon (Poly) (Polygon size)";
typedef struct {
    Poly polygon;
} FramePolyOp;

/* paintPoly OpCode */
magic PaintPolyOp ushort 0x0071;
description PaintPolyOp "paintPoly", "Polygon (Poly) (Polygon size)";
typedef struct {
    Poly polygon;
} PaintPolyOp;

/* erasePoly OpCode */
magic ErasePolyOp ushort 0x0072;
description ErasePolyOp "erasePoly", "Polygon (Poly) (Polygon size)";
typedef struct {
    Poly polygon;
} ErasePolyOp;

/* invertPoly OpCode */
magic InvertPolyOp ushort 0x0073;
description InvertPolyOp "invertPoly", "Polygon (Poly) (Polygon size)";
typedef struct {
    Poly polygon;
} InvertPolyOp;

/* fillPoly OpCode */
magic FillPolyOp ushort 0x0074;
description FillPolyOp "fillPoly", "Polygon (Poly) (Polygon size)";
typedef struct {
    Poly polygon;
} FillPolyOp;

/* Reserved for Apple use OpCode */
magic Reserved0075Through0077Op ushort 0x0075 .. 0x0077;
description Reserved0075Through0077Op "Reserved for Apple use", "Polygon (Poly) (Polygon size)";
typedef struct {
    Poly polygon;
} Reserved0075Through0077Op;



/* frameSamePoly OpCode */
magic FrameSamePolyOp ushort 0x0078;
description FrameSamePolyOp "frameSamePoly", "(Not yet implemented) (0)";
typedef struct {
} FrameSamePolyOp;

/* paintSamePoly OpCode */
magic PaintSamePolyOp ushort 0x0079;
description PaintSamePolyOp "paintSamePoly", "(Not yet implemented) (0)";
typedef struct {
} PaintSamePolyOp;

/* eraseSamePoly OpCode */
magic EraseSamePolyOp ushort 0x007A;
description EraseSamePolyOp "eraseSamePoly", "(Not yet implemented) (0)";
typedef struct {
} EraseSamePolyOp;

/* invertSamePoly OpCode */
magic InvertSamePolyOp ushort 0x007B;
description InvertSamePolyOp "invertSamePoly", "(Not yet implemented) (0)";
typedef struct {
} InvertSamePolyOp;

/* fillSamePoly OpCode */
magic FillSamePolyOp ushort 0x007C;
description FillSamePolyOp "fillSamePoly", "(Not yet implemented) (0)";
typedef struct {
} FillSamePolyOp;

/* Reserved for Apple use OpCode */
magic Reserved007dThrough007fOp ushort 0x007D .. 0x007f;
description Reserved007dThrough007fOp "Reserved for Apple use", "  (0)";
typedef struct {
} Reserved007dThrough007fOp;



/* frameRgn OpCode */
magic FrameRgnOp ushort 0x0080;
description FrameRgnOp "frameRgn", "Region (Rgn) (Region size)";
typedef struct {
    Rgn region;
} FrameRgnOp;

/* paintRgn OpCode */
magic PaintRgnOp ushort 0x0081;
description PaintRgnOp "paintRgn", "Region (Rgn) (Region size)";
typedef struct {
    Rgn region;
} PaintRgnOp;

/* eraseRgn OpCode */
magic EraseRgnOp ushort 0x0082;
description EraseRgnOp "eraseRgn", "Region (Rgn) (Region size)";
typedef struct {
    Rgn region;
} EraseRgnOp;

/* invertRgn OpCode */
magic InvertRgnOp ushort 0x0083;
description InvertRgnOp "invertRgn", "Region (Rgn) (Region size)";
typedef struct {
    Rgn region;
} InvertRgnOp;

/* fillRgn OpCode */
magic FillRgnOp ushort 0x0084;
description FillRgnOp "fillRgn", "Region (Rgn) (Region size)";
typedef struct {
    Rgn region;
} FillRgnOp;

/* Reserved for Apple use OpCode */
magic Reserved0085Through0087Op ushort 0x0085 .. 0x0087;
description Reserved0085Through0087Op "Reserved for Apple use", "Region (Rgn) (Region size)";
typedef struct {
    Rgn region;
} Reserved0085Through0087Op;



/* frameSameRgn OpCode */
magic FrameSameRgnOp ushort 0x0088;
description FrameSameRgnOp "frameSameRgn", "(Not yet implemented) (0)";
typedef struct {
} FrameSameRgnOp;

/* paintSameRgn OpCode */
magic PaintSameRgnOp ushort 0x0089;
description PaintSameRgnOp "paintSameRgn", "(Not yet implemented) (0)";
typedef struct {
} PaintSameRgnOp;

/* eraseSameRgn OpCode */
magic EraseSameRgnOp ushort 0x008A;
description EraseSameRgnOp "eraseSameRgn", "(Not yet implemented) (0)";
typedef struct {
} EraseSameRgnOp;

/* invertSameRgn OpCode */
magic InvertSameRgnOp ushort 0x008B;
description InvertSameRgnOp "invertSameRgn", "(Not yet implemented) (0)";
typedef struct {
} InvertSameRgnOp;

/* fillSameRgn OpCode */
magic FillSameRgnOp ushort 0x008C;
description FillSameRgnOp "fillSameRgn", "(Not yet implemented) (0)";
typedef struct {
} FillSameRgnOp;

/* Reserved for Apple use OpCode */
magic Reserved008dThrough008fOp ushort 0x008D .. 0x008f;
description Reserved008dThrough008fOp "Reserved for Apple use", "(0)";
typedef struct {
} Reserved008dThrough008fOp;



/* BitsRect OpCode 
* [4][5]; see Listing A-2 on page A-17
*/
magic BitsRectOp ushort 0x0090;
description BitsRectOp "BitsRect", "CopyBits with clipped rectangle (Variable)";
typedef struct {
   PixMap pixMap;     //pixel map
   ColorTable colorTable; //ColorTable record
   Rect srcRect;       //source rectangle  
   Rect dstRect;       //destination rectangle  
   short mode;       //transfer mode (may include new transfer modes)
   PixData pixData;       
} BitsRectOp;

/* BitsRgn OpCode 
 * [4][5]; see Listing A-3 on page A-18
*/
magic BitsRgnOp ushort 0x0091;
description BitsRgnOp "BitsRgn", "CopyBits with clipped region (Variable)";
typedef struct {
   PixMap pixMap;         
   ColorTable colorTable;     
   Rect srcRect;          //source rectangle 
   Rect dstRect;          //destination rectangle 
   short mode;          //transfer mode (may include new modes)
   Rgn maskRgn;         //region for masking 
   PixData pixData;       
} BitsRgnOp;

/* Reserved for Apple use OpCode */
magic Reserved0092Through0097Op ushort 0x0092 .. 0x0097;
description Reserved0092Through0097Op "Reserved for Apple use", "Data length (Integer), data (2 + data length)";
typedef struct {
    short dataLength;
    byte[dataLength] data;
} Reserved0092Through0097Op;






/* PackBitsRect OpCode 
* ; see Listing A-2 on page A-17
*/
magic PackBitsRectOp ushort 0x0098;
description PackBitsRectOp "PackBitsRect", "Packed CopyBits with clipped rectangle (Variable)";
typedef struct {
   PixMapShifted pixMap;     //pixel map
   ColorTable colorTable; //ColorTable record
   Rect srcRect;      //source rectangle  
   Rect dstRect;      //destination rectangle  
   short mode;       //transfer mode (may include  new transfer modes)}
   PixData pixData;
} PackBitsRectOp;

/* PackBitsRgn OpCode 
* ; see Listing A-3 on page A-18)
*/
magic PackBitsRgnOp ushort 0x0099;
description PackBitsRgnOp "PackBitsRgn", "Packed CopyBits with clipped rectangle (Variable)";
typedef struct {
    PixMap pixMap;
    ColorTable colorTable;
    Rect srcRect;
    Rect dstRect;
    short mode;
    Rgn maskRgn;
    PixData pixData;
} PackBitsRgnOp;

/* DirectBitsRect OpCode */
magic DirectBitsRectOp ushort 0x009A;
description DirectBitsRectOp "DirectBitsRect ", "PixMap, srcRect, dstRect, mode (Integer), PixData (Variable)";
typedef struct {
    PixMap pixMap;
    Rect srcRect;
    Rect dstRect;
    short mode;
    PixData pixData;
} DirectBitsRectOp;


/* DirectBitsRgn OpCode */



magic DirectBitsRgnOp ushort 0x009B;
description DirectBitsRgnOp "DirectBitsRgn", "PixMap, srcRect, dstRect, mode (Integer), maskRgn, PixData Variable ()";
typedef struct {
    PixMap pixMap;
    Rect srcRect;
    Rect dstRect;
    short mode;
    Rgn maskRg; 
    PixData pixData;
} DirectBitsRgnOp;


/* Reserved for Apple use OpCode */
magic Reserved009cThrough009fOp ushort 0x009C .. 0x009f;
description Reserved009cThrough009fOp "Reserved for Apple use", "Data length (Integer), data (2 + data length)";
typedef struct {
    short dataLength;
    byte[dataLength] data;
} Reserved009cThrough009fOp;




/* ShortComment OpCode */
magic ShortCommentOp ushort 0x00A0;
description ShortCommentOp "ShortComment", "Kind (Integer) (2)";
typedef struct {
    short kind;
} ShortCommentOp;

/* LongComment OpCode */
magic LongCommentOp ushort 0x00A1;
description LongCommentOp "LongComment", "Kind (Integer), size (Integer), data (4 + data)";
typedef struct {
    short kind;
    short size;
    charbyte[size] data;
} LongCommentOp;

/* Reserved for Apple use OpCode */
magic Reserved00a2Through00afOp ushort 0x00A2 .. 0x00af;
description Reserved00a2Through00afOp "Reserved for Apple use", "Data length (Integer), data (2 + data length)";
typedef struct {
    short dataLength;
    byte[dataLength] data;
} Reserved00a2Through00afOp;














/* Reserved for Apple use OpCode */
magic Reserved00b0Through00cfOp ushort 0x00B0 .. 0x00cf;
description Reserved00b0Through00cfOp "Reserved for Apple use", "  (0)";
typedef struct {
} Reserved00b0Through00cfOp;





/* Reserved for Apple use OpCode */
magic Reserved00d0Through00feOp ushort 0x00D0 .. 0x00fe;
description Reserved00d0Through00feOp "Reserved for Apple use", "Data length (Long), data (4 + data length)";
typedef struct {
    int dataLength;
    byte[dataLength] data;
} Reserved00d0Through00feOp;





/* EndPic OpCode */
magic EndPicOp ushort 0x00FF;
description EndPicOp "EndPic", "End of picture (2)";
typedef struct {
    byte[2] data;
} EndPicOp;

/* Reserved for Apple use OpCode */
magic Reserved0100Through01ffOp ushort 0x0100 .. 0x01ff;
description Reserved0100Through01ffOp "Reserved for Apple use", "2 bytes of data (2)";
typedef struct {
    byte[2] data;
} Reserved0100Through01ffOp;





/* Reserved for Apple use OpCode */
magic Reserved0200Op ushort 0x0200;
description Reserved0200Op "Reserved for Apple use", "4 bytes of data (4)";
typedef struct {
    byte[4] data;
} Reserved0200Op;

/* Version2Op OpCode */
magic Version2Op ushort 0x02FF;
description Version2Op "VersionOp", "Version number of picture (2)";
typedef struct {
} Version2Op;




/* Reserved for Apple use OpCode */
magic Reserved0bffOp ushort 0x0BFF;
description Reserved0bffOp "Reserved for Apple use", "22 bytes of data (22)";
typedef struct {
    byte[22] data;
} Reserved0bffOp;

/* Header OpCode */
magic HeaderOp ushort 0x0C00;
description HeaderOp "Header", "For extended version 2: version (Integer), reserved (Integer), hRes, vRes (Fixed), srcRect, reserved (Long); for version 2: opcode (24)";
typedef struct {
    short version;
    short reserved1;
    Fixed hRes;
    Fixed vRes;
    Rect srcRect;
    int reserved2;
} HeaderOp;


/* Reserved for Apple use OpCode */
magic Reserved0c01Op ushort 0x0C01;
description Reserved0c01Op "Reserved for Apple use", "24 bytes of data (24)";
typedef struct {
    byte[24] data;
} Reserved0c01Op;




/* Reserved for Apple use OpCode */
magic Reserved7f00Through7fffOp ushort 0x7F00 .. 0x7fff;
description Reserved7f00Through7fffOp "Reserved for Apple use", "254 bytes of data (254)";
typedef struct {
    byte[254] data;
} Reserved7f00Through7fffOp;





/* Reserved for Apple use OpCode */
magic Reserved8000Through80ffOp ushort 0x8000 .. 0x80ff;
description Reserved8000Through80ffOp "Reserved for Apple use", "  (0)";
typedef struct {
} Reserved8000Through80ffOp;





/* Reserved for Apple use OpCode */
magic Reserved8100Through81ffOp ushort 0x8100 .. 0x81ff;
description Reserved8100Through81ffOp "Reserved for Apple use", "Data length (Long), data (4 + data length)";
typedef struct {
    int dataLength;
    byte[dataLength] data;
} Reserved8100Through81ffOp;





/* CompressedQuickTime OpCode */
magic CompressedQuickTimeOp ushort 0x8200;
description CompressedQuickTimeOp "CompressedQuickTime", "Data length (Long), data (private to QuickTime) (4 + data length)";
typedef struct {
    int dataLength;
    byte[dataLength] data;
} CompressedQuickTimeOp;

/* UncompressedQuickTime OpCode */
magic UncompressedQuickTimeOp ushort 0x8201;
description UncompressedQuickTimeOp "UncompressedQuickTime", "Data length (Long), data (private to QuickTime) (4 + data length)";
typedef struct {
    int dataLength;
    byte[dataLength] data;
} UncompressedQuickTimeOp;

/* Reserved for Apple use OpCode */
magic ReservedffffOp ushort 0xFFFF;
description ReservedffffOp "Reserved for Apple use", "Data length (Long), data (4 + data length)";
typedef struct {
    int dataLength;
    byte[dataLength] data;
} ReservedffffOp;
