1 /* ---------------------------------------------------------------------- * 2 * lcwin32.h 3 * This file is part of lincity. 4 * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2001. 5 * ---------------------------------------------------------------------- */ 6 #ifndef __lcwin32_h__ 7 #define __lcwin32_h__ 8 9 // Turn off compiler warning converting const double to float 10 #pragma warning(disable : 4244) 11 12 13 /* ---------------------------------------------------------------------- * 14 * Defines 15 * ---------------------------------------------------------------------- */ 16 #define APPNAME "Lincity" 17 18 // Operating System Versions 19 #if defined (WIN32) 20 #define IS_WIN32 TRUE 21 #else /* */ 22 #define IS_WIN32 FALSE 23 #endif /* */ 24 #define IS_NT IS_WIN32 && (BOOL)(GetVersion() < 0x80000000) 25 #define IS_WIN32S IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4)) 26 #define IS_WIN95 (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32 27 28 #define WINWIDTH 640 29 #define WINHEIGHT 480 30 31 // Palette and DIB constants 32 #define PALETTESIZE 256 33 #define PALVERSION 0x300 34 35 36 // --------------------------------------------------------------------------- 37 // Macros 38 // --------------------------------------------------------------------------- 39 /* Handle to a DIB */ 40 DECLARE_HANDLE (HDIB); 41 42 43 // DIB Macros 44 #define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER)) 45 #define RECTWIDTH(lpRect) ((lpRect)->right - (lpRect)->left) 46 #define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top) 47 48 // WIDTHBYTES performs DWORD-aligning of DIB scanlines. The "bits" 49 // parameter is the bit count for the scanline (biWidth * biBitCount), 50 // and this macro returns the number of DWORD-aligned bytes needed 51 // to hold those bits. 52 #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4) 53 54 55 // --------------------------------------------------------------------------- 56 // Type Definitions 57 // --------------------------------------------------------------------------- 58 typedef struct _disp 59 { 60 HINSTANCE hInst; 61 HANDLE hAccelTable; 62 63 HWND hWnd; 64 HDC hdcMem; 65 HBITMAP hBitmap; // Backing store 66 67 HDC hSaveUnderHdc; 68 HBITMAP hSaveUnderBitmap; 69 70 int winX; 71 int winY; 72 int winW; 73 int winH; 74 75 BOOL fullscreen; 76 INT screenW; // Width of screen 77 INT screenH; // Height of screen 78 INT winFullscreenClientW; // Width of full screen window 79 INT winFullscreenClientH; // Height of full screen window 80 INT clientW; // Width of pixmap (adjusted by borderx/pix_double) 81 INT clientH; // Height of pixmap (adjusted by borderx/pix_double) 82 long colorDepth; // Number of color planes (e.g. 24 for full color) 83 int min_h; // Minimum size for resizing 84 int min_w; // Minimum size for resizing 85 86 BOOL useDIB; // Use DIB or DDB? 87 BITMAPINFO *pbminfo; // DIB Header 88 PBYTE pBits; // DIB Bits 89 HBITMAP hDIB; // DIB BITMAP 90 91 BOOL hasPalette; 92 INT paletteSize; // Only valid if hasPalette 93 INT defaultPaletteSize; // Only valid if hasPalette 94 HANDLE hPal; // Handle to the application's logical palette 95 HANDLE hPaletteMemOri; // Original palette for hdcMem 96 NPLOGPALETTE pLogPal; // Pointer to program's logical palette 97 COLORREF colorrefPal[256]; // For mapping index to COLORREF (for full color) 98 HBRUSH brushPal[256]; // For mapping index to HBRUSH 99 100 HFONT hFont; // Lin City font 101 } 102 disp; 103 104 // --------------------------------------------------------------------------- 105 // Globals 106 // --------------------------------------------------------------------------- 107 extern HANDLE hAccelTable; 108 extern disp display; 109 extern char *bg_color; 110 extern int verbose; 111 extern int pix_double; 112 extern int text_bg; 113 extern int text_fg; 114 extern int x_key_value; 115 extern BOOL x_key_shifted; 116 extern int borderx, bordery; 117 extern long unsigned int colour_table[256]; 118 extern int xclip_x1, xclip_y1, xclip_x2, xclip_y2, clipping_flag; 119 extern unsigned char *open_font; 120 extern int open_font_height; 121 extern int suppress_next_expose; 122 extern int no_init_help; 123 extern char colour_pal_file[], fontfile[]; 124 extern char windowsfontfile[]; 125 extern int cs_mouse_x, cs_mouse_y; 126 /* extern int cs_current_mouse_x, cs_current_mouse_y; 127 extern int cs_current_mouse_button;*/ 128 extern int cs_mouse_button; 129 extern int cs_mouse_shifted; 130 extern float gamma_correct_red, gamma_correct_green, gamma_correct_blue; 131 132 #ifdef USE_PIXMAPS 133 extern HBITMAP icon_pixmap[]; 134 #endif /* USE_PIXMAPS */ 135 136 137 // --------------------------------------------------------------------------- 138 // Function Prototypes 139 // --------------------------------------------------------------------------- 140 void ProcessPendingEvents (void); 141 void ProcessNextEvent (void); 142 char GetKeystroke (void); 143 void HandleMouse (void); 144 void RefreshScreen (void); 145 void RefreshArea (int, int, int, int); 146 void SaveUnder (int, int, int, int, void *); 147 void RestoreSaveUnder (int, int, int, int, void *); 148 void CopyPixmapToScreen (int t2, int src_x, int src_y, int width, int height, 149 int dst_x, int dst_y); 150 void AddPaletteEntry (int col, int red, int grn, int blu); 151 void HandleError (char *, int); 152 void UpdatePalette (void); 153 HBRUSH GetPaletteBrush (int col); 154 155 int AdjustX (int x); 156 int AdjustY (int y); 157 int UnAdjustX (int x); 158 int UnAdjustY (int y); 159 160 void my_x_putchar (int, int, unsigned char); 161 void open_x_putchar (int, int, unsigned char); 162 void call_event (void); 163 void do_call_event (int); 164 void init_windows_font (void); 165 void init_mouse (void); 166 void draw_border (void); 167 168 void EnableWindowsMenuItems (void); 169 void DisableWindowsMenuItems (void); 170 171 #endif /* __lcwin32_h__ */ 172