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