| 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 |
#include "angband.h" |
|---|
| 75 |
#define uint unsigned int |
|---|
| 76 |
|
|---|
| 77 |
#if (defined(WINDOWS) && !defined(USE_SDL)) |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
#define HAS_CLEANUP |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
#ifdef HTML_HELP |
|---|
| 89 |
# define HELP_GENERAL "angband.chm" |
|---|
| 90 |
# define HELP_SPOILERS "angband.chm" |
|---|
| 91 |
#else |
|---|
| 92 |
# define HELP_GENERAL "angband.hlp" |
|---|
| 93 |
# define HELP_SPOILERS "spoilers.hlp" |
|---|
| 94 |
#endif |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
#ifdef ALLOW_BORG |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
#define USE_SAVER |
|---|
| 104 |
|
|---|
| 105 |
#endif |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
#define IDM_FILE_NEW 100 |
|---|
| 113 |
#define IDM_FILE_OPEN 101 |
|---|
| 114 |
#define IDM_FILE_SAVE 110 |
|---|
| 115 |
#define IDM_FILE_EXIT 130 |
|---|
| 116 |
|
|---|
| 117 |
#define IDM_WINDOW_VIS_0 200 |
|---|
| 118 |
#define IDM_WINDOW_VIS_1 201 |
|---|
| 119 |
#define IDM_WINDOW_VIS_2 202 |
|---|
| 120 |
#define IDM_WINDOW_VIS_3 203 |
|---|
| 121 |
#define IDM_WINDOW_VIS_4 204 |
|---|
| 122 |
#define IDM_WINDOW_VIS_5 205 |
|---|
| 123 |
#define IDM_WINDOW_VIS_6 206 |
|---|
| 124 |
#define IDM_WINDOW_VIS_7 207 |
|---|
| 125 |
|
|---|
| 126 |
#define IDM_WINDOW_FONT_0 210 |
|---|
| 127 |
#define IDM_WINDOW_FONT_1 211 |
|---|
| 128 |
#define IDM_WINDOW_FONT_2 212 |
|---|
| 129 |
#define IDM_WINDOW_FONT_3 213 |
|---|
| 130 |
#define IDM_WINDOW_FONT_4 214 |
|---|
| 131 |
#define IDM_WINDOW_FONT_5 215 |
|---|
| 132 |
#define IDM_WINDOW_FONT_6 216 |
|---|
| 133 |
#define IDM_WINDOW_FONT_7 217 |
|---|
| 134 |
|
|---|
| 135 |
#define IDM_WINDOW_BIZ_0 230 |
|---|
| 136 |
#define IDM_WINDOW_BIZ_1 231 |
|---|
| 137 |
#define IDM_WINDOW_BIZ_2 232 |
|---|
| 138 |
#define IDM_WINDOW_BIZ_3 233 |
|---|
| 139 |
#define IDM_WINDOW_BIZ_4 234 |
|---|
| 140 |
#define IDM_WINDOW_BIZ_5 235 |
|---|
| 141 |
#define IDM_WINDOW_BIZ_6 236 |
|---|
| 142 |
#define IDM_WINDOW_BIZ_7 237 |
|---|
| 143 |
|
|---|
| 144 |
#define IDM_WINDOW_I_WID_0 240 |
|---|
| 145 |
#define IDM_WINDOW_I_WID_1 241 |
|---|
| 146 |
#define IDM_WINDOW_I_WID_2 242 |
|---|
| 147 |
#define IDM_WINDOW_I_WID_3 243 |
|---|
| 148 |
#define IDM_WINDOW_I_WID_4 244 |
|---|
| 149 |
#define IDM_WINDOW_I_WID_5 245 |
|---|
| 150 |
#define IDM_WINDOW_I_WID_6 246 |
|---|
| 151 |
#define IDM_WINDOW_I_WID_7 247 |
|---|
| 152 |
|
|---|
| 153 |
#define IDM_WINDOW_D_WID_0 250 |
|---|
| 154 |
#define IDM_WINDOW_D_WID_1 251 |
|---|
| 155 |
#define IDM_WINDOW_D_WID_2 252 |
|---|
| 156 |
#define IDM_WINDOW_D_WID_3 253 |
|---|
| 157 |
#define IDM_WINDOW_D_WID_4 254 |
|---|
| 158 |
#define IDM_WINDOW_D_WID_5 255 |
|---|
| 159 |
#define IDM_WINDOW_D_WID_6 256 |
|---|
| 160 |
#define IDM_WINDOW_D_WID_7 257 |
|---|
| 161 |
|
|---|
| 162 |
#define IDM_WINDOW_I_HGT_0 260 |
|---|
| 163 |
#define IDM_WINDOW_I_HGT_1 261 |
|---|
| 164 |
#define IDM_WINDOW_I_HGT_2 262 |
|---|
| 165 |
#define IDM_WINDOW_I_HGT_3 263 |
|---|
| 166 |
#define IDM_WINDOW_I_HGT_4 264 |
|---|
| 167 |
#define IDM_WINDOW_I_HGT_5 265 |
|---|
| 168 |
#define IDM_WINDOW_I_HGT_6 266 |
|---|
| 169 |
#define IDM_WINDOW_I_HGT_7 267 |
|---|
| 170 |
|
|---|
| 171 |
#define IDM_WINDOW_D_HGT_0 270 |
|---|
| 172 |
#define IDM_WINDOW_D_HGT_1 271 |
|---|
| 173 |
#define IDM_WINDOW_D_HGT_2 272 |
|---|
| 174 |
#define IDM_WINDOW_D_HGT_3 273 |
|---|
| 175 |
#define IDM_WINDOW_D_HGT_4 274 |
|---|
| 176 |
#define IDM_WINDOW_D_HGT_5 275 |
|---|
| 177 |
#define IDM_WINDOW_D_HGT_6 276 |
|---|
| 178 |
#define IDM_WINDOW_D_HGT_7 277 |
|---|
| 179 |
|
|---|
| 180 |
#define IDM_OPTIONS_GRAPHICS_NONE 400 |
|---|
| 181 |
#define IDM_OPTIONS_GRAPHICS_OLD 401 |
|---|
| 182 |
#define IDM_OPTIONS_GRAPHICS_ADAM 402 |
|---|
| 183 |
#define IDM_OPTIONS_GRAPHICS_DAVID 403 |
|---|
| 184 |
#define IDM_OPTIONS_BIGTILE 409 |
|---|
| 185 |
#define IDM_OPTIONS_LOW_PRIORITY 420 |
|---|
| 186 |
#define IDM_OPTIONS_SAVER 430 |
|---|
| 187 |
#define IDM_OPTIONS_MAP 440 |
|---|
| 188 |
|
|---|
| 189 |
#define IDM_HELP_GENERAL 901 |
|---|
| 190 |
#define IDM_HELP_SPOILERS 902 |
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
#define STRICT |
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
#define NOCOMM |
|---|
| 202 |
#define NOLOGERROR |
|---|
| 203 |
#define NOPROFILER |
|---|
| 204 |
#define NOLFILEIO |
|---|
| 205 |
#define NOOPENFILE |
|---|
| 206 |
#define NORESOURCE |
|---|
| 207 |
#define NOATOM |
|---|
| 208 |
#define NOLANGUAGE |
|---|
| 209 |
#define NOLSTRING |
|---|
| 210 |
#define NODBCS |
|---|
| 211 |
#define NOKEYBOARDINFO |
|---|
| 212 |
#define NOCOLOR |
|---|
| 213 |
#define NODRAWTEXT |
|---|
| 214 |
#define NOSCALABLEFONT |
|---|
| 215 |
#define NOMETAFILE |
|---|
| 216 |
#define NOSYSTEMPARAMSINFO |
|---|
| 217 |
#define NODEFERWINDOWPOS |
|---|
| 218 |
#define NOKEYSTATES |
|---|
| 219 |
#define NOWH |
|---|
| 220 |
#define NOCLIPBOARD |
|---|
| 221 |
#define NOICONS |
|---|
| 222 |
#define NOMDI |
|---|
| 223 |
#define NOHELP |
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
#define WIN32_LEAN_AND_MEAN |
|---|
| 232 |
#define NONLS |
|---|
| 233 |
#define NOSERVICE |
|---|
| 234 |
#define NOKANJI |
|---|
| 235 |
#define NOMCX |
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 |
#include <windows.h> |
|---|
| 241 |
#include <windowsx.h> |
|---|
| 242 |
|
|---|
| 243 |
#ifdef USE_SOUND |
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
#define MMNODRV |
|---|
| 249 |
#define MMNOWAVE |
|---|
| 250 |
#define MMNOMIDI |
|---|
| 251 |
#define MMNOAUX |
|---|
| 252 |
#define MMNOTIMER |
|---|
| 253 |
#define MMNOJOY |
|---|
| 254 |
#define MMNOMCI |
|---|
| 255 |
#define MMNOMMIO |
|---|
| 256 |
#define MMNOMMSYSTEM |
|---|
| 257 |
|
|---|
| 258 |
#include <mmsystem.h> |
|---|
| 259 |
|
|---|
| 260 |
#endif |
|---|
| 261 |
|
|---|
| 262 |
#include <commdlg.h> |
|---|
| 263 |
#include <shellapi.h> |
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
#ifdef USE_GRAPHICS |
|---|
| 269 |
# include "win/readdib.h" |
|---|
| 270 |
#endif |
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
#define INVALID_FILE_NAME (DWORD)0xFFFFFFFF |
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 |
#define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL) |
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
#ifndef WS_EX_TOOLWINDOW |
|---|
| 286 |
# define WS_EX_TOOLWINDOW 0 |
|---|
| 287 |
#endif |
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
#define VID_BLACK 0x00 |
|---|
| 293 |
#define VID_BLUE 0x01 |
|---|
| 294 |
#define VID_GREEN 0x02 |
|---|
| 295 |
#define VID_CYAN 0x03 |
|---|
| 296 |
#define VID_RED 0x04 |
|---|
| 297 |
#define VID_MAGENTA 0x05 |
|---|
| 298 |
#define VID_YELLOW 0x06 |
|---|
| 299 |
#define VID_WHITE 0x07 |
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 |
|
|---|
| 303 |
|
|---|
| 304 |
#define VID_BRIGHT 0x08 |
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
#define VUD_BLACK 0x00 |
|---|
| 310 |
#define VUD_BLUE 0x10 |
|---|
| 311 |
#define VUD_GREEN 0x20 |
|---|
| 312 |
#define VUD_CYAN 0x30 |
|---|
| 313 |
#define VUD_RED 0x40 |
|---|
| 314 |
#define VUD_MAGENTA 0x50 |
|---|
| 315 |
#define VUD_YELLOW 0x60 |
|---|
| 316 |
#define VUD_WHITE 0x70 |
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 |
#define VUD_BRIGHT 0x80 |
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 |
#define DEFAULT_FONT "8X13.FON" |
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
|
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 |
typedef struct _term_data term_data; |
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 |
struct _term_data |
|---|
| 346 |
{ |
|---|
| 347 |
term t; |
|---|
| 348 |
|
|---|
| 349 |
cptr s; |
|---|
| 350 |
|
|---|
| 351 |
HWND w; |
|---|
| 352 |
|
|---|
| 353 |
DWORD dwStyle; |
|---|
| 354 |
DWORD dwExStyle; |
|---|
| 355 |
|
|---|
| 356 |
uint keys; |
|---|
| 357 |
|
|---|
| 358 |
byte rows; |
|---|
| 359 |
byte cols; |
|---|
| 360 |
|
|---|
| 361 |
uint pos_x; |
|---|
| 362 |
uint pos_y; |
|---|
| 363 |
uint size_wid; |
|---|
| 364 |
uint size_hgt; |
|---|
| 365 |
uint size_ow1; |
|---|
| 366 |
uint size_oh1; |
|---|
| 367 |
uint size_ow2; |
|---|
| 368 |
uint size_oh2; |
|---|
| 369 |
|
|---|
| 370 |
bool size_hack; |
|---|
| 371 |
|
|---|
| 372 |
bool xtra_hack; |
|---|
| 373 |
|
|---|
| 374 |
bool visible; |
|---|
| 375 |
bool maximized; |
|---|
| 376 |
|
|---|
| 377 |
bool bizarre; |
|---|
| 378 |
|
|---|
| 379 |
char *font_want; |
|---|
| 380 |
char *font_file; |
|---|
| 381 |
|
|---|
| 382 |
HFONT font_id; |
|---|
| 383 |
|
|---|
| 384 |
uint font_wid; |
|---|
| 385 |
uint font_hgt; |
|---|
| 386 |
|
|---|
| 387 |
uint tile_wid; |
|---|
| 388 |
uint tile_hgt; |
|---|
| 389 |
|
|---|
| 390 |
uint map_tile_wid; |
|---|
| 391 |
uint map_tile_hgt; |
|---|
| 392 |
|
|---|
| 393 |
bool map_active; |
|---|
| 394 |
}; |
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
#define MAX_TERM_DATA 8 |
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
static term_data data[MAX_TERM_DATA]; |
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
static term_data *my_td; |
|---|
| 412 |
|
|---|
| 413 |
|
|---|
| 414 |
|
|---|
| 415 |
|
|---|
| 416 |
bool game_in_progress = FALSE; |
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
bool initialized = FALSE; |
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
bool paletted = FALSE; |
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
bool colors16 = FALSE; |
|---|
| 432 |
|
|---|
| 433 |
static bool low_priority = FALSE; |
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 |
|
|---|
| 437 |
|
|---|
| 438 |
static HINSTANCE hInstance; |
|---|
| 439 |
|
|---|
| 440 |
|
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
static HBRUSH hbrYellow; |
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 |
static HICON hIcon; |
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
static HPALETTE hPal; |
|---|
| 454 |
|
|---|
| 455 |
|
|---|
| 456 |
#ifdef USE_SAVER |
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
static HWND hwndSaver; |
|---|
| 462 |
|
|---|
| 463 |
static bool screensaver = FALSE; |
|---|
| 464 |
static bool screensaver_active = FALSE; |
|---|
| 465 |
|
|---|
| 466 |
static HANDLE screensaverSemaphore; |
|---|
| 467 |
|
|---|
| 468 |
static char saverfilename[1024]; |
|---|
| 469 |
|
|---|
| 470 |
static HMENU main_menu; |
|---|
| 471 |
|
|---|
| 472 |
#define MOUSE_SENS 10 |
|---|
| 473 |
|
|---|
| 474 |
#endif |
|---|
| 475 |
|
|---|
| 476 |
|
|---|
| 477 |
#ifdef USE_GRAPHICS |
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 |
|
|---|
| 481 |
|
|---|
| 482 |
static bool can_use_graphics = FALSE; |
|---|
| 483 |
|
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 |
static DIBINIT infGraph; |
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 |
|
|---|
| 491 |
|
|---|
| 492 |
static DIBINIT infMask; |
|---|
| 493 |
|
|---|
| 494 |
#endif |
|---|
| 495 |
|
|---|
| 496 |
|
|---|
| 497 |
#ifdef USE_SOUND |
|---|
| 498 |
|
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
static bool can_use_sound = FALSE; |
|---|
| 503 |
|
|---|
| 504 |
#define SAMPLE_MAX 16 |
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
static char *sound_file[MSG_MAX][SAMPLE_MAX]; |
|---|
| 510 |
|
|---|
| 511 |
#endif |
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
|
|---|
| 516 |
|
|---|
| 517 |
static char *ini_file = NULL; |
|---|
| 518 |
|
|---|
| 519 |
|
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 |
static cptr AppName = VERSION_NAME; |
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
|
|---|
| 527 |
static cptr AngList = "AngList"; |
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 |
static char *ANGBAND_DIR_XTRA_FONT; |
|---|
| 533 |
static char *ANGBAND_DIR_XTRA_GRAF; |
|---|
| 534 |
static char *ANGBAND_DIR_XTRA_SOUND; |
|---|
| 535 |
static char *ANGBAND_DIR_XTRA_HELP; |
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
static COLORREF win_clr[MAX_COLORS]; |
|---|
| 541 |
|
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 |
|
|---|
| 545 |
|
|---|
| 546 |
|
|---|
| 547 |
|
|---|
| 548 |
|
|---|
| 549 |
|
|---|
| 550 |
|
|---|
| 551 |
|
|---|
| 552 |
static byte win_pal[MAX_COLORS] = |
|---|
| 553 |
{ |
|---|
| 554 |
VID_BLACK, |
|---|
| 555 |
VID_WHITE, |
|---|
| 556 |
VID_CYAN, |
|---|
| 557 |
VID_RED | VID_BRIGHT, |
|---|
| 558 |
VID_RED, |
|---|
| 559 |
VID_GREEN, |
|---|
| 560 |
VID_BLUE, |
|---|
| 561 |
VID_YELLOW, |
|---|
| 562 |
VID_BLACK | VID_BRIGHT, |
|---|
| 563 |
VID_CYAN | VID_BRIGHT, |
|---|
| 564 |
VID_MAGENTA, |
|---|
| 565 |
VID_YELLOW | VID_BRIGHT, |
|---|
| 566 |
VID_MAGENTA | VID_BRIGHT, |
|---|
| 567 |
VID_GREEN | VID_BRIGHT, |
|---|
| 568 |
VID_BLUE | VID_BRIGHT, |
|---|
| 569 |
VID_YELLOW |
|---|
| 570 |
}; |
|---|
| 571 |
|
|---|
| 572 |
|
|---|
| 573 |
#ifdef SUPPORT_GAMMA |
|---|
| 574 |
static int gamma_correction; |
|---|
| 575 |
#endif |
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 |
|
|---|
| 579 |
|
|---|
| 580 |
|
|---|
| 581 |
static bool special_key[256]; |
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 |
|
|---|
| 587 |
|
|---|
| 588 |
|
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 |
|
|---|
| 592 |
|
|---|
| 593 |
|
|---|
| 594 |
static const byte special_key_list[] = |
|---|
| 595 |
{ |
|---|
| 596 |
VK_CLEAR, |
|---|
| 597 |
|
|---|
| 598 |
VK_PAUSE, |
|---|
| 599 |
|
|---|
| 600 |
VK_PRIOR, |
|---|
| 601 |
VK_NEXT, |
|---|
| 602 |
VK_END, |
|---|
| 603 |
VK_HOME, |
|---|
| 604 |
VK_LEFT, |
|---|
| 605 |
VK_UP, |
|---|
| 606 |
VK_RIGHT, |
|---|
| 607 |
VK_DOWN, |
|---|
| 608 |
VK_SELECT, |
|---|
| 609 |
VK_PRINT, |
|---|
| 610 |
VK_EXECUTE, |
|---|
| 611 |
VK_SNAPSHOT, |
|---|
| 612 |
VK_INSERT, |
|---|
| 613 |
VK_DELETE, |
|---|
| 614 |
VK_HELP, |
|---|
| 615 |
|
|---|
| 616 |
#if 0 |
|---|
| 617 |
VK_NUMPAD0, |
|---|
| 618 |
VK_NUMPAD1, |
|---|
| 619 |
VK_NUMPAD2, |
|---|
| 620 |
VK_NUMPAD3, |
|---|
| 621 |
VK_NUMPAD4, |
|---|
| 622 |
VK_NUMPAD5, |
|---|
| 623 |
VK_NUMPAD6, |
|---|
| 624 |
VK_NUMPAD7, |
|---|
| 625 |
VK_NUMPAD8, |
|---|
| 626 |
VK_NUMPAD9, |
|---|
| 627 |
VK_MULTIPLY, |
|---|
| 628 |
VK_ADD, |
|---|
| 629 |
VK_SEPARATOR, |
|---|
| 630 |
VK_SUBTRACT, |
|---|
| 631 |
VK_DECIMAL, |
|---|
| 632 |
VK_DIVIDE, |
|---|
| 633 |
#endif |
|---|
| 634 |
|
|---|
| 635 |
VK_F1, |
|---|
| 636 |
VK_F2, |
|---|
| 637 |
VK_F3, |
|---|
| 638 |
VK_F4, |
|---|
| 639 |
VK_F5, |
|---|
| 640 |
VK_F6, |
|---|
| 641 |
VK_F7, |
|---|
| 642 |
VK_F8, |
|---|
| 643 |
VK_F9, |
|---|
| 644 |
VK_F10, |
|---|
| 645 |
VK_F11, |
|---|
| 646 |
VK_F12, |
|---|
| 647 |
VK_F13, |
|---|
| 648 |
VK_F14, |
|---|
| 649 |
VK_F15, |
|---|
| 650 |
VK_F16, |
|---|
| 651 |
VK_F17, |
|---|
| 652 |
VK_F18, |
|---|
| 653 |
VK_F19, |
|---|
| 654 |
VK_F20, |
|---|
| 655 |
VK_F21, |
|---|
| 656 |
VK_F22, |
|---|
| 657 |
VK_F23, |
|---|
| 658 |
VK_F24, |
|---|
| 659 |
|
|---|
| 660 |
0 |
|---|
| 661 |
}; |
|---|
| 662 |
|
|---|
| 663 |
#include "game-cmd.h" |
|---|
| 664 |
|
|---|
| 665 |
static game_command cmd = { CMD_NULL, 0 }; |
|---|
| 666 |
|
|---|
| 667 |
#if 0 |
|---|
| 668 |
|
|---|
| 669 |
|
|---|
| 670 |
|
|---|
| 671 |
static cptr extract_file_name(cptr s) |
|---|
| 672 |
{ |
|---|
| 673 |
cptr p; |
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 |
p = s + strlen(s) - 1; |
|---|
| 677 |
|
|---|
| 678 |
|
|---|
| 679 |
while ((p >= s) && (*p != ':') && (*p != '\\')) p--; |
|---|
| 680 |
|
|---|
| 681 |
|
|---|
| 682 |
return (p+1); |
|---|
| 683 |
} |
|---|
| 684 |
#endif |
|---|
| 685 |
|
|---|
| 686 |
|
|---|
| 687 |
static void show_win_error(void) |
|---|
| 688 |
{ |
|---|
| 689 |
LPVOID lpMsgBuf; |
|---|
| 690 |
|
|---|
| 691 |
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, |
|---|
| 692 |
NULL, GetLastError(), |
|---|
| 693 |
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|---|
| 694 |
(LPTSTR) &lpMsgBuf, 0, NULL); |
|---|
| 695 |
|
|---|
| 696 |
MessageBox(NULL, lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION); |
|---|
| 697 |
|
|---|
| 698 |
LocalFree(lpMsgBuf); |
|---|
| 699 |
} |
|---|
| 700 |
|
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 |
|
|---|
| 704 |
|
|---|
| 705 |
|
|---|
| 706 |
|
|---|
| 707 |
static char *analyze_font(char *path, int *wp, int *hp) |
|---|
| 708 |
{ |
|---|
| 709 |
int wid, hgt; |
|---|
| 710 |
|
|---|
| 711 |
char *s, *p; |
|---|
| 712 |
|
|---|
| 713 |
|
|---|
| 714 |
p = path + strlen(path) - 1; |
|---|
| 715 |
|
|---|
| 716 |
|
|---|
| 717 |
while ((p >= path) && (*p != ':') && (*p != '\\')) --p; |
|---|
| 718 |
|
|---|
| 719 |
|
|---|
| 720 |
++p; |
|---|
| 721 |
|
|---|
| 722 |
|
|---|
| 723 |
for (s = p; *s; ++s) |
|---|
| 724 |
{ |
|---|
| 725 |
|
|---|
| 726 |
if (islower((unsigned char)*s)) *s = toupper((unsigned char)*s); |
|---|
| 727 |
} |
|---|
| 728 |
|
|---|
| 729 |
|
|---|
| 730 |
s = strchr(p, 'X'); |
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 |
wid = atoi(p); |
|---|
| 734 |
|
|---|
| 735 |
|
|---|
| 736 |
hgt = s ? atoi(s+1) : 0; |
|---|
| 737 |
|
|---|
| 738 |
|
|---|
| 739 |
(*wp) = wid; |
|---|
| 740 |
(*hp) = hgt; |
|---|
| 741 |
|
|---|
| 742 |
|
|---|
| 743 |
return (p); |
|---|
| 744 |
} |
|---|
| 745 |
|
|---|
| 746 |
|
|---|
| 747 |
|
|---|
| 748 |
|
|---|
| 749 |
|
|---|
| 750 |
static bool check_dir(cptr s) |
|---|
| 751 |
{ |
|---|
| 752 |
int i; |
|---|
| 753 |
|
|---|
| 754 |
char path[1024]; |
|---|
| 755 |
|
|---|
| 756 |
DWORD attrib; |
|---|
| 757 |
|
|---|
| 758 |
|
|---|
| 759 |
my_strcpy(path, s, sizeof(path)); |
|---|
| 760 |
|
|---|
| 761 |
|
|---|
| 762 |
i = strlen(path); |
|---|
| 763 |
|
|---|
| 764 |
|
|---|
| 765 |
if (i && (path[i-1] == '\\')) path[--i] = '\0'; |
|---|
| 766 |
|
|---|
| 767 |
|
|---|
| 768 |
attrib = GetFileAttributes(path); |
|---|
| 769 |
|
|---|
| 770 |
|
|---|
| 771 |
if (attrib == INVALID_FILE_NAME) return (FALSE); |
|---|
| 772 |
|
|---|
| 773 |
|
|---|
| 774 |
if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return (FALSE); |
|---|
| 775 |
|
|---|
| 776 |
|
|---|
| 777 |
return (TRUE); |
|---|
| 778 |
} |
|---|
| 779 |
|
|---|
| 780 |
|
|---|
| 781 |
|
|---|
| 782 |
|
|---|
| 783 |
|
|---|
| 784 |
static void validate_file(cptr s) |
|---|
| 785 |
{ |
|---|
| 786 |
|
|---|
| 787 |
if (!file_exists(s)) |
|---|
| 788 |
quit_fmt("Cannot find required file:\n%s", s); |
|---|
| 789 |
} |
|---|
| 790 |
|
|---|
| 791 |
|
|---|
| 792 |
|
|---|
| 793 |
|
|---|
| 794 |
|
|---|
| 795 |
static void validate_dir(cptr s) |
|---|
| 796 |
{ |
|---|
| 797 |
|
|---|
| 798 |
if (!check_dir(s)) |
|---|
| 799 |
{ |
|---|
| 800 |
quit_fmt("Cannot find required directory:\n%s", s); |
|---|
| 801 |
} |
|---|
| 802 |
} |
|---|
| 803 |
|
|---|
| 804 |
|
|---|
| 805 |
|
|---|
| 806 |
|
|---|
| 807 |
|
|---|
| 808 |
static void term_getsize(term_data *td) |
|---|
| 809 |
{ |
|---|
| 810 |
RECT rc; |
|---|
| 811 |
|
|---|
| 812 |
int wid, hgt; |
|---|
| 813 |
|
|---|
| 814 |
|
|---|
| 815 |
if (td->cols < 1) td->cols = 1; |
|---|
| 816 |
if (td->rows < 1) td->rows = 1; |
|---|
| 817 |
|
|---|
| 818 |
|
|---|
| 819 |
wid = td->cols * td->tile_wid + td->size_ow1 + td->size_ow2; |
|---|
| 820 |
hgt = td->rows * td->tile_hgt + td->size_oh1 + td->size_oh2; |
|---|
| 821 |
|
|---|
| 822 |
|
|---|
| 823 |
rc.left = 0; |
|---|
| 824 |
rc.right = rc.left + wid; |
|---|
| 825 |
rc.top = 0; |
|---|
| 826 |
rc.bottom = rc.top + hgt; |
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 |
AdjustWindowRectEx(&rc, td->dwStyle, TRUE, td->dwExStyle); |
|---|
| 830 |
|
|---|
| 831 |
|
|---|
| 832 |
td->size_wid = rc.right - rc.left; |
|---|
| 833 |
td->size_hgt = rc.bottom - rc.top; |
|---|
| 834 |
|
|---|
| 835 |
|
|---|
| 836 |
if (!td->w) return; |
|---|
| 837 |
|
|---|
| 838 |
|
|---|
| 839 |
GetWindowRect(td->w, &rc); |
|---|
| 840 |
|
|---|
| 841 |
|
|---|
| 842 |
td->pos_x = rc.left; |
|---|
| 843 |
td->pos_y = rc.top; |
|---|
| 844 |
} |
|---|
| 845 |
|
|---|
| 846 |
|
|---|
| 847 |
|
|---|
| 848 |
|
|---|
| 849 |
|
|---|
| 850 |
static void save_prefs_aux(term_data *td, cptr sec_name) |
|---|
| 851 |
{ |
|---|
| 852 |
char buf[1024]; |
|---|
| 853 |
|
|---|
| 854 |
RECT rc; |
|---|
| 855 |
|
|---|
| 856 |
WINDOWPLACEMENT lpwndpl; |
|---|
| 857 |
|
|---|
| 858 |
|
|---|
| 859 |
if (!td->w) return; |
|---|
| 860 |
|
|---|
| 861 |
|
|---|
| 862 |
strcpy(buf, td->visible ? "1" : "0"); |
|---|
| 863 |
WritePrivateProfileString(sec_name, "Visible", buf, ini_file); |
|---|
| 864 |
|
|---|
| 865 |
|
|---|
| 866 |
strcpy(buf, td->font_file ? td->font_file : DEFAULT_FONT); |
|---|
| 867 |
WritePrivateProfileString(sec_name, "Font", buf, ini_file); |
|---|
| 868 |
|
|---|
| 869 |
|
|---|
| 870 |
strcpy(buf, td->bizarre ? "1" : "0"); |
|---|
| 871 |
WritePrivateProfileString(sec_name, "Bizarre", buf, ini_file); |
|---|
| 872 |
|
|---|
| 873 |
|
|---|
| 874 |
wsprintf(buf, "%d", td->tile_wid); |
|---|
| 875 |
WritePrivateProfileString(sec_name, "TileWid", buf, ini_file); |
|---|
| 876 |
|
|---|
| 877 |
|
|---|
| 878 |
wsprintf(buf, "%d", td->tile_hgt); |
|---|
| 879 |
WritePrivateProfileString(sec_name, "TileHgt", buf, ini_file); |
|---|
| 880 |
|
|---|
| 881 |
|
|---|
| 882 |
wsprintf(buf, "%d", td->cols); |
|---|
| 883 |
WritePrivateProfileString(sec_name, "NumCols", buf, ini_file); |
|---|
| 884 |
|
|---|
| 885 |
|
|---|
| 886 |
wsprintf(buf, "%d", td->rows); |
|---|
| 887 |
WritePrivateProfileString(sec_name, "NumRows", buf, ini_file); |
|---|
| 888 |
|
|---|
| 889 |
|
|---|
| 890 |
lpwndpl.length = sizeof(WINDOWPLACEMENT); |
|---|
| 891 |
GetWindowPlacement(td->w, &lpwndpl); |
|---|
| 892 |
|
|---|
| 893 |
|
|---|
| 894 |
rc = lpwndpl.rcNormalPosition; |
|---|
| 895 |
|
|---|
| 896 |
|
|---|
| 897 |
if (lpwndpl.flags & SW_SHOWMAXIMIZED) |
|---|
| 898 |
td->maximized = TRUE; |
|---|
| 899 |
else |
|---|
|
|---|