#ifndef WINDDI_H #define WINDDI_H // ============================================================================ // winddi.h - Windows 3.x Display Driver Interface (DDI) structures // // These packed structures match the binary layout expected by 16-bit // Windows display drivers. They are used to communicate between the // 32-bit host program and the 16-bit driver code via shared memory // in DGROUP. // // Key structures: // GdiInfo16T - Device capabilities, filled by Enable(style=1) // PDevice16T - Physical device descriptor, filled by Enable(style=0) // DrawMode16T - Drawing parameters (ROP2, colors, text spacing) // LogBrush16T - Logical brush input to RealizeObject // LogPen16T - Logical pen input to RealizeObject // DibPDevice16T - DIB engine PDEVICE extension (for software drivers) // // All structures use __attribute__((packed)) to match Win16 layout. // ============================================================================ #include "wintypes.h" // ============================================================================ // GDIINFO - Device capabilities structure filled by Enable(style=1) // This is the 16-bit Windows 3.1 DDK GDIINFO structure (0x6C bytes). // ============================================================================ typedef struct __attribute__((packed)) { int16_t dpVersion; // 0x00: driver version (0x030A for 3.10) int16_t dpTechnology; // 0x02: device technology int16_t dpHorzSize; // 0x04: horizontal size in mm int16_t dpVertSize; // 0x06: vertical size in mm int16_t dpHorzRes; // 0x08: horizontal resolution (pixels) int16_t dpVertRes; // 0x0A: vertical resolution (pixels) int16_t dpBitsPixel; // 0x0C: bits per pixel int16_t dpPlanes; // 0x0E: number of bit planes int16_t dpNumBrushes; // 0x10: number of device brushes int16_t dpNumPens; // 0x12: number of device pens int16_t dpNumFonts; // 0x14: number of device fonts int16_t dpNumColors; // 0x16: number of colors in color table int16_t dpDEVICEsize; // 0x18: size of PDEVICE structure uint16_t dpCurves; // 0x1A: curve capabilities uint16_t dpLines; // 0x1C: line capabilities uint16_t dpPolygonals; // 0x1E: polygon capabilities uint16_t dpText; // 0x20: text capabilities uint16_t dpClip; // 0x22: clipping capabilities uint16_t dpRaster; // 0x24: raster capabilities int16_t dpAspectX; // 0x26: x aspect ratio int16_t dpAspectY; // 0x28: y aspect ratio int16_t dpAspectXY; // 0x2A: diagonal aspect ratio int16_t dpStyleLen; // 0x2C: length of styled line segment Point16T dpMLoWin; // 0x2E: metric lo-res window Point16T dpMLoVpt; // 0x32: metric lo-res viewport Point16T dpMHiWin; // 0x36: metric hi-res window Point16T dpMHiVpt; // 0x3A: metric hi-res viewport Point16T dpELoWin; // 0x3E: english lo-res window Point16T dpELoVpt; // 0x42: english lo-res viewport Point16T dpEHiWin; // 0x46: english hi-res window Point16T dpEHiVpt; // 0x4A: english hi-res viewport Point16T dpTwpWin; // 0x4E: twips window Point16T dpTwpVpt; // 0x52: twips viewport int16_t dpLogPixelsX; // 0x56: logical pixels per inch X int16_t dpLogPixelsY; // 0x58: logical pixels per inch Y int16_t dpDCManage; // 0x5A: DC management flags uint16_t reserved1[5]; // 0x5C: reserved uint16_t dpPalColors; // 0x66: number of palette colors uint16_t dpPalReserved; // 0x68: number of reserved palette entries uint16_t dpPalResolution; // 0x6A: palette DAC resolution (bits per gun) } GdiInfo16T; // dpTechnology values #define DT_PLOTTER 0 #define DT_RASDISPLAY 1 #define DT_RASPRINTER 2 #define DT_RASCAMERA 3 #define DT_CHARSTREAM 4 #define DT_METAFILE 5 #define DT_DISPFILE 6 // dpRaster capability bits #define RC_BITBLT 0x0001 #define RC_BANDING 0x0002 #define RC_SCALING 0x0004 #define RC_BITMAP64 0x0008 #define RC_GDI20_OUTPUT 0x0010 #define RC_DI_BITMAP 0x0080 #define RC_PALETTE 0x0100 #define RC_DIBTODEV 0x0200 #define RC_BIGFONT 0x0400 #define RC_STRETCHBLT 0x0800 #define RC_FLOODFILL 0x1000 #define RC_STRETCHDIB 0x2000 // ============================================================================ // PDEVICE - Physical device descriptor // The first word indicates the type. The rest is driver-specific. // We allocate a generous buffer for the driver to fill in. // ============================================================================ #define PDEVICE_MAX_SIZE 4096 typedef struct __attribute__((packed)) { int16_t pdType; // 0 = memory bitmap, nonzero = physical device uint8_t pdData[PDEVICE_MAX_SIZE - 2]; // driver-specific data } PDevice16T; // ============================================================================ // DRAWMODE - Drawing mode structure (passed to BitBlt, Output, etc.) // ============================================================================ typedef struct __attribute__((packed)) { int16_t rop2; // 0x00: raster operation (R2_*) int16_t bkMode; // 0x02: background mode (TRANSPARENT=1, OPAQUE=2) uint32_t bkColor; // 0x04: background color (physical) uint32_t textColor; // 0x08: text color (physical) int16_t tBreakExtra; // 0x0C: total break extra int16_t breakExtra; // 0x0E: break extra per char int16_t breakErr; // 0x10: accumulated break error int16_t breakRem; // 0x12: break remainder int16_t breakCount; // 0x14: break count int16_t charExtra; // 0x16: extra pixels per char uint32_t lbkColor; // 0x18: logical background color uint32_t ltextColor; // 0x1C: logical text color uint16_t icrBk; // 0x20: index to background color uint16_t icrText; // 0x22: index to text color } DrawMode16T; // Background mode constants #define BM_TRANSPARENT 1 #define BM_OPAQUE 2 // ============================================================================ // Logical brush (for RealizeObject) // ============================================================================ typedef struct __attribute__((packed)) { uint16_t lbStyle; // Brush style uint32_t lbColor; // Brush color (COLORREF) int16_t lbHatch; // Hatch pattern uint32_t lbBkColor; // Background color (Win 3.1) } LogBrush16T; // Brush styles #define BS_SOLID 0 #define BS_HOLLOW 1 #define BS_NULL 1 #define BS_HATCHED 2 #define BS_PATTERN 3 #define BS_DIBPATTERN 5 // Hatch styles #define HS_HORIZONTAL 0 #define HS_VERTICAL 1 #define HS_FDIAGONAL 2 #define HS_BDIAGONAL 3 #define HS_CROSS 4 #define HS_DIAGCROSS 5 // ============================================================================ // Logical pen (for RealizeObject) // ============================================================================ typedef struct __attribute__((packed)) { uint16_t lopnStyle; // Pen style Point16T lopnWidth; // Pen width uint32_t lopnColor; // Pen color (COLORREF) } LogPen16T; // Pen styles #define PS_SOLID 0 #define PS_DASH 1 #define PS_DOT 2 #define PS_DASHDOT 3 #define PS_DASHDOTDOT 4 #define PS_NULL 5 #define PS_INSIDEFRAME 6 // ============================================================================ // CURSORINFO - Cursor shape description // ============================================================================ typedef struct __attribute__((packed)) { int16_t csHotX; // Hotspot X int16_t csHotY; // Hotspot Y int16_t csWidth; // Cursor width int16_t csHeight; // Cursor height int16_t csWidthB; // Width in bytes int16_t csColor; // Planes * bitsPixel } CursorInfo16T; // ============================================================================ // Enable() style parameter values // ============================================================================ #define ENABLE_INQUIRE 0 // First call: fill GDIINFO #define ENABLE_ENABLE 1 // Second call: initialize PDEVICE // ============================================================================ // Output() style values // ============================================================================ #define OS_ARC 3 #define OS_SCANLINES 4 #define OS_RECTANGLE 6 #define OS_ELLIPSE 7 #define OS_MARKER 8 #define OS_POLYLINE 18 #define OS_ALTPOLYGON 22 #define OS_WINDPOLYGON 20 #define OS_PIE 23 #define OS_POLYMARKER 24 #define OS_CHORD 39 #define OS_CIRCLE 55 #define OS_ROUNDRECT 72 // ============================================================================ // Control() function codes // ============================================================================ #define CTRL_GETSCALINGFACTOR 14 #define CTRL_RESETDEVICE 128 #define CTRL_MOUSETRAILS 39 // ============================================================================ // RealizeObject() styles // ============================================================================ #define OBJ_PEN 1 #define OBJ_BRUSH 2 #define OBJ_FONT 3 // ============================================================================ // Physical brush/pen structures (driver-specific, maximum size) // ============================================================================ #define PHYS_OBJ_MAX_SIZE 128 typedef struct __attribute__((packed)) { uint8_t data[PHYS_OBJ_MAX_SIZE]; } PhysObj16T; // ============================================================================ // DIBENGINE structures (for drivers that use the DIB engine) // ============================================================================ // DIB_BitmapInfo passed to DIB engine functions typedef struct __attribute__((packed)) { int16_t bmType; int16_t bmWidth; int16_t bmHeight; int16_t bmWidthBytes; uint8_t bmPlanes; uint8_t bmBitsPixel; uint32_t bmBits; // Far pointer to bits (as DWORD) uint32_t bmWidthPlanes; uint32_t bmBitsLong; // Selector:0 far pointer uint16_t bmSegmentIndex; uint16_t bmScanSegment; uint16_t bmFillBytes; uint16_t reserved1; uint16_t reserved2; } DibBitmapInfo16T; // DIB engine PDEVICE extension (placed at start of PDEVICE by DIB-based drivers) typedef struct __attribute__((packed)) { int16_t deType; // Device type uint16_t deWidth; // Width in pixels uint16_t deHeight; // Height in pixels uint16_t deWidthBytes; // Bytes per scan line uint8_t dePlanes; // Number of planes uint8_t deBitsPixel; // Bits per pixel uint32_t delpPDevice; // Pointer to next PDEVICE uint32_t dlpColorTable; // Pointer to color table // ... additional fields follow } DibPDevice16T; #endif // WINDDI_H