#ifndef WINTYPES_H #define WINTYPES_H // ============================================================================ // wintypes.h - Windows 16-bit type definitions and constants // // Provides the fundamental types used by the Win16 API and DDI: // basic integer types (WORD, DWORD, BOOL16), 16-bit handle types, // far pointer (segment:offset) helpers, COLORREF, geometry types // (Point16T, Rect16T), GetWinFlags constants, GlobalAlloc flags, // and raster operation codes (ROP2 and ROP3). // // Uses stdint.h types for portability (DJGPP's uint32_t is unsigned // long, not unsigned int). // ============================================================================ #include // ============================================================================ // Windows 16-bit basic types // ============================================================================ typedef uint16_t WORD; typedef int16_t SWORD; typedef uint32_t DWORD; typedef int32_t LONG; typedef uint8_t BYTE; typedef int16_t BOOL16; // 16-bit handle types typedef uint16_t HANDLE16; typedef uint16_t HWND16; typedef uint16_t HDC16; typedef uint16_t HMODULE16; typedef uint16_t HINSTANCE16; typedef uint16_t HGLOBAL16; typedef uint16_t HBITMAP16; typedef uint16_t HBRUSH16; typedef uint16_t HPEN16; typedef uint16_t HPALETTE16; typedef uint16_t HRGN16; typedef uint16_t HCURSOR16; typedef uint16_t ATOM16; // ============================================================================ // Far pointer types (16:16 segment:offset, stored little-endian) // ============================================================================ typedef struct __attribute__((packed)) { uint16_t offset; uint16_t segment; } FarPtr16T; #define FARPTR16_NULL ((FarPtr16T){0, 0}) static inline FarPtr16T makeFarPtr16(uint16_t seg, uint16_t off) { FarPtr16T fp; fp.segment = seg; fp.offset = off; return fp; } static inline uint32_t farPtr16ToLinear(FarPtr16T fp) { // For real-mode addresses only; PM addresses need descriptor lookup return ((uint32_t)fp.segment << 4) + fp.offset; } // ============================================================================ // Color types // ============================================================================ typedef uint32_t ColorRefT; #define RGB_RED(c) ((uint8_t)(c)) #define RGB_GREEN(c) ((uint8_t)((c) >> 8)) #define RGB_BLUE(c) ((uint8_t)((c) >> 16)) #define MAKE_RGB(r, g, b) ((ColorRefT)(((BYTE)(r)) | ((WORD)((BYTE)(g)) << 8) | ((DWORD)((BYTE)(b)) << 16))) // Palette index color reference #define PALETTEINDEX(i) ((ColorRefT)(0x01000000L | (DWORD)(WORD)(i))) // ============================================================================ // Geometry types (16-bit, packed for compatibility with Win16 structures) // ============================================================================ typedef struct __attribute__((packed)) { int16_t x; int16_t y; } Point16T; typedef struct __attribute__((packed)) { int16_t left; int16_t top; int16_t right; int16_t bottom; } Rect16T; // ============================================================================ // Windows constants // ============================================================================ // GetWinFlags return values #define WF_PMODE 0x0001 #define WF_CPU286 0x0002 #define WF_CPU386 0x0004 #define WF_CPU486 0x0008 #define WF_STANDARD 0x0010 #define WF_ENHANCED 0x0020 #define WF_80x87 0x0400 // GlobalAlloc flags #define GMEM_FIXED 0x0000 #define GMEM_MOVEABLE 0x0002 #define GMEM_ZEROINIT 0x0040 #define GHND (GMEM_MOVEABLE | GMEM_ZEROINIT) #define GPTR (GMEM_FIXED | GMEM_ZEROINIT) // Boolean #define WIN_FALSE 0 #define WIN_TRUE 1 // Null handle #define NULL16 ((uint16_t)0) // ============================================================================ // Raster operation codes (ROP2 and ROP3) // ============================================================================ #define R2_BLACK 1 #define R2_NOTMERGEPEN 2 #define R2_MASKNOTPEN 3 #define R2_NOTCOPYPEN 4 #define R2_MASKPENNOT 5 #define R2_NOT 6 #define R2_XORPEN 7 #define R2_NOTMASKPEN 8 #define R2_MASKPEN 9 #define R2_NOTXORPEN 10 #define R2_NOP 11 #define R2_MERGENOTPEN 12 #define R2_COPYPEN 13 #define R2_MERGEPENNOT 14 #define R2_MERGEPEN 15 #define R2_WHITE 16 // Common ROP3 codes #define SRCCOPY 0x00CC0020L #define SRCPAINT 0x00EE0086L #define SRCAND 0x008800C6L #define SRCINVERT 0x00660046L #define SRCERASE 0x00440328L #define NOTSRCCOPY 0x00330008L #define NOTSRCERASE 0x001100A6L #define MERGECOPY 0x00C000CAL #define MERGEPAINT 0x00BB0226L #define PATCOPY 0x00F00021L #define PATPAINT 0x00FB0A09L #define PATINVERT 0x005A0049L #define DSTINVERT 0x00550009L #define BLACKNESS 0x00000042L #define WHITENESS 0x00FF0062L #endif // WINTYPES_H