Add text rendering support via the Windows 3.x ExtTextOut DDI function. Builds a .FNT v3 font structure from the VGA BIOS 8x16 ROM font (INT 10h AH=11h), with v3 char table (6-byte entries, absolute offsets) required by VBESVGA.DRV's BigFontFlags in protected mode. Provides a full-screen clip rect since STRBLT.ASM unconditionally dereferences lpClipRect. Tested with both VBESVGA.DRV and S3TRIO.DRV. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
334 lines
14 KiB
C
334 lines
14 KiB
C
#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;
|
|
|
|
// ============================================================================
|
|
// .FNT v2 file header (117 bytes)
|
|
//
|
|
// Display drivers expect the full .FNT format with fsVersion at offset 0.
|
|
// lp_font passed to ExtTextOut points to fsType at offset 0x42.
|
|
// ============================================================================
|
|
|
|
typedef struct __attribute__((packed)) {
|
|
uint16_t fsVersion; // 0x00: 0x0200
|
|
uint32_t fsSize; // 0x02: total structure size
|
|
char fsCopyright[60]; // 0x06: copyright string
|
|
uint16_t fsType; // 0x42: 0 = raster
|
|
uint16_t fsPoints; // 0x44: point size
|
|
uint16_t fsVertRes; // 0x46: vertical resolution
|
|
uint16_t fsHorizRes; // 0x48: horizontal resolution
|
|
uint16_t fsAscent; // 0x4A: baseline from top
|
|
uint16_t fsInternalLeading; // 0x4C
|
|
uint16_t fsExternalLeading; // 0x4E
|
|
uint8_t fsItalic; // 0x50
|
|
uint8_t fsUnderline; // 0x51
|
|
uint8_t fsStrikeOut; // 0x52
|
|
uint16_t fsWeight; // 0x53: 400 = normal
|
|
uint8_t fsCharSet; // 0x55: 255 = OEM
|
|
uint16_t fsPixWidth; // 0x56: 0=proportional, else fixed
|
|
uint16_t fsPixHeight; // 0x58: character cell height
|
|
uint8_t fsPitchAndFamily; // 0x5A
|
|
uint16_t fsAvgWidth; // 0x5B
|
|
uint16_t fsMaxWidth; // 0x5D
|
|
uint8_t fsFirstChar; // 0x5F
|
|
uint8_t fsLastChar; // 0x60
|
|
uint8_t fsDefaultChar; // 0x61: relative to fsFirstChar
|
|
uint8_t fsBreakChar; // 0x62: relative to fsFirstChar
|
|
uint16_t fsWidthBytes; // 0x63: bytes per bitmap row
|
|
uint32_t fsDevice; // 0x65: offset to device name
|
|
uint32_t fsFace; // 0x69: offset to face name
|
|
uint32_t fsBitsPointer; // 0x6D: far ptr to bitmap data
|
|
uint32_t fsBitsOffset; // 0x71: offset to bitmap data
|
|
} FntHeader16T; // 0x75 = 117 bytes
|
|
|
|
// v2 character table entry (at offset 0x76 after header + pad byte)
|
|
typedef struct __attribute__((packed)) {
|
|
uint16_t width; // character width in pixels
|
|
uint16_t offset; // byte offset from bitmap start
|
|
} FntCharEntry16T; // 4 bytes
|
|
|
|
// v3 character table entry (at offset 0x94 after v3 extension fields)
|
|
typedef struct __attribute__((packed)) {
|
|
uint16_t width; // character width in pixels
|
|
uint32_t offset; // absolute byte offset from segment base
|
|
} FntCharEntry30T; // 6 bytes
|
|
|
|
// ExtTextOut option flags
|
|
#define ETO_OPAQUE 0x0002
|
|
#define ETO_CLIPPED 0x0004
|
|
|
|
#endif // WINDDI_H
|