| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
#include "angband.h" |
|---|
| 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 |
#ifdef USE_GCU |
|---|
| 51 |
|
|---|
| 52 |
#include "main.h" |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
#undef bool |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
#define term System_term |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
#ifdef USE_NCURSES |
|---|
| 67 |
# ifdef HAVE_STDBOOL_H |
|---|
| 68 |
# define NCURSES_ENABLE_STDBOOL_H 0 |
|---|
| 69 |
# endif |
|---|
| 70 |
|
|---|
| 71 |
# include <ncurses.h> |
|---|
| 72 |
#else |
|---|
| 73 |
# include <curses.h> |
|---|
| 74 |
#endif |
|---|
| 75 |
|
|---|
| 76 |
#undef term |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
#define USE_TPOSIX |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
#if defined(WIN32_CONSOLE_MODE) |
|---|
| 92 |
# undef USE_TPOSIX |
|---|
| 93 |
_stdcall void Sleep(int); |
|---|
| 94 |
#define usleep(v) Sleep(v / 1000) |
|---|
| 95 |
#endif |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
#ifdef USE_TPOSIX |
|---|
| 101 |
# include <termios.h> |
|---|
| 102 |
#endif |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
#define USE_CURS_SET |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
#ifdef USE_TPOSIX |
|---|
| 127 |
|
|---|
| 128 |
static struct termios norm_termios; |
|---|
| 129 |
static struct termios game_termios; |
|---|
| 130 |
|
|---|
| 131 |
#endif |
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
typedef struct term_data |
|---|
| 138 |
{ |
|---|
| 139 |
term t; |
|---|
| 140 |
WINDOW *win; |
|---|
| 141 |
} term_data; |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
#define MAX_TERM_DATA 4 |
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
static term_data data[MAX_TERM_DATA]; |
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
static int active = 0; |
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
#ifdef A_COLOR |
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
#ifndef A_BRIGHT |
|---|
| 161 |
# define A_BRIGHT A_BOLD |
|---|
| 162 |
#endif |
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
static int can_use_color = FALSE; |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
static int can_fix_color = FALSE; |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
static int colortable[BASIC_COLORS]; |
|---|
| 178 |
|
|---|
| 179 |
#endif |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
static void keymap_norm(void) |
|---|
| 187 |
{ |
|---|
| 188 |
|
|---|
| 189 |
#ifdef USE_TPOSIX |
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
(void)tcsetattr(0, TCSAFLUSH, &norm_termios); |
|---|
| 193 |
|
|---|
| 194 |
#endif |
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
} |
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
static void keymap_game(void) |
|---|
| 204 |
{ |
|---|
| 205 |
|
|---|
| 206 |
#ifdef USE_TPOSIX |
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
(void)tcsetattr(0, TCSAFLUSH, &game_termios); |
|---|
| 210 |
|
|---|
| 211 |
#endif |
|---|
| 212 |
} |
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
static void keymap_norm_prepare(void) |
|---|
| 219 |
{ |
|---|
| 220 |
|
|---|
| 221 |
#ifdef USE_TPOSIX |
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 |
tcgetattr(0, &norm_termios); |
|---|
| 225 |
|
|---|
| 226 |
#endif |
|---|
| 227 |
|
|---|
| 228 |
} |
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 |
static void keymap_game_prepare(void) |
|---|
| 235 |
{ |
|---|
| 236 |
|
|---|
| 237 |
#ifdef USE_TPOSIX |
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 |
tcgetattr(0, &game_termios); |
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
game_termios.c_cc[VINTR] = (char)3; |
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
game_termios.c_cc[VSUSP] = (char)26; |
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
game_termios.c_cc[VQUIT] = (char)-1; |
|---|
| 252 |
game_termios.c_cc[VERASE] = (char)-1; |
|---|
| 253 |
game_termios.c_cc[VKILL] = (char)-1; |
|---|
| 254 |
game_termios.c_cc[VEOF] = (char)-1; |
|---|
| 255 |
game_termios.c_cc[VEOL] = (char)-1; |
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
game_termios.c_cc[VMIN] = 1; |
|---|
| 259 |
game_termios.c_cc[VTIME] = 0; |
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
game_termios.c_iflag &= ~IXON; |
|---|
| 263 |
|
|---|
| 264 |
#endif |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
} |
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
static errr Term_xtra_gcu_alive(int v) |
|---|
| 276 |
{ |
|---|
| 277 |
int x, y; |
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
if (!v) |
|---|
| 282 |
{ |
|---|
| 283 |
|
|---|
| 284 |
keymap_norm(); |
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
nocbreak(); |
|---|
| 288 |
echo(); |
|---|
| 289 |
nl(); |
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
Term_xtra(TERM_XTRA_SHAPE, 1); |
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
(void)refresh(); |
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 |
getyx(curscr, y, x); |
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
mvcur(y, x, LINES - 1, 0); |
|---|
| 302 |
|
|---|
| 303 |
|
|---|
| 304 |
endwin(); |
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
(void)fflush(stdout); |
|---|
| 308 |
} |
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
else |
|---|
| 312 |
{ |
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
cbreak(); |
|---|
| 319 |
noecho(); |
|---|
| 320 |
nonl(); |
|---|
| 321 |
|
|---|
| 322 |
|
|---|
| 323 |
keymap_game(); |
|---|
| 324 |
} |
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
return (0); |
|---|
| 328 |
} |
|---|
| 329 |
|
|---|
| 330 |
|
|---|
| 331 |
#ifdef USE_NCURSES |
|---|
| 332 |
const char help_gcu[] = "NCurses, for terminal console, subopts -b(ig screen)"; |
|---|
| 333 |
#else |
|---|
| 334 |
const char help_gcu[] = "Curses, for terminal console, subopts -b(ig screen)"; |
|---|
| 335 |
#endif |
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
static void Term_init_gcu(term *t) |
|---|
| 342 |
{ |
|---|
| 343 |
term_data *td = (term_data *)(t->data); |
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 |
|
|---|
| 349 |
wrefresh(stdscr); |
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 |
if (active++ != 0) return; |
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
(void)wclear(td->win); |
|---|
| 356 |
|
|---|
| 357 |
|
|---|
| 358 |
(void)wmove(td->win, 0, 0); |
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
(void)wrefresh(td->win); |
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 |
keymap_game(); |
|---|
| 365 |
} |
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 |
static void Term_nuke_gcu(term *t) |
|---|
| 372 |
{ |
|---|
| 373 |
int x, y; |
|---|
| 374 |
term_data *td = (term_data *)(t->data); |
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
delwin(td->win); |
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 |
if (--active != 0) return; |
|---|
| 381 |
|
|---|
| 382 |
|
|---|
| 383 |
Term_xtra(TERM_XTRA_SHAPE, 1); |
|---|
| 384 |
|
|---|
| 385 |
#ifdef A_COLOR |
|---|
| 386 |
|
|---|
| 387 |
start_color(); |
|---|
| 388 |
#endif |
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 |
getyx(curscr, y, x); |
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 |
mvcur(y, x, LINES - 1, 0); |
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 |
(void)refresh(); |
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
endwin(); |
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
(void)fflush(stdout); |
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
keymap_norm(); |
|---|
| 407 |
} |
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
|
|---|
| 412 |
|
|---|
| 413 |
|
|---|
| 414 |
|
|---|
| 415 |
static errr Term_xtra_gcu_event(int v) |
|---|
| 416 |
{ |
|---|
| 417 |
int i, k; |
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
if (v) |
|---|
| 421 |
{ |
|---|
| 422 |
|
|---|
| 423 |
nodelay(stdscr, FALSE); |
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
i = getch(); |
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
for (k = 0; (k < 10) && (i == ERR); k++) i = getch(); |
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 |
if (i == ERR) exit_game_panic(); |
|---|
| 433 |
if (i == EOF) exit_game_panic(); |
|---|
| 434 |
} |
|---|
| 435 |
|
|---|
| 436 |
|
|---|
| 437 |
else |
|---|
| 438 |
{ |
|---|
| 439 |
|
|---|
| 440 |
nodelay(stdscr, TRUE); |
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
i = getch(); |
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
nodelay(stdscr, FALSE); |
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 |
if (i == ERR) return (1); |
|---|
| 450 |
if (i == EOF) return (1); |
|---|
| 451 |
} |
|---|
| 452 |
|
|---|
| 453 |
#ifdef KEY_DOWN |
|---|
| 454 |
|
|---|
| 455 |
switch (i) |
|---|
| 456 |
{ |
|---|
| 457 |
case KEY_DOWN: i = ARROW_DOWN; break; |
|---|
| 458 |
case KEY_UP: i = ARROW_UP; break; |
|---|
| 459 |
case KEY_LEFT: i = ARROW_LEFT; break; |
|---|
| 460 |
case KEY_RIGHT: i = ARROW_RIGHT; break; |
|---|
| 461 |
} |
|---|
| 462 |
#endif |
|---|
| 463 |
|
|---|
| 464 |
|
|---|
| 465 |
Term_keypress(i); |
|---|
| 466 |
|
|---|
| 467 |
|
|---|
| 468 |
return (0); |
|---|
| 469 |
} |
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
|
|---|
| 475 |
static errr Term_xtra_gcu_react(void) |
|---|
| 476 |
{ |
|---|
| 477 |
|
|---|
| 478 |
#ifdef A_COLOR |
|---|
| 479 |
|
|---|
| 480 |
int i; |
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 |
if (!can_fix_color) return (0); |
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
for (i = 0; i < BASIC_COLORS; i++) |
|---|
| 487 |
{ |
|---|
| 488 |
|
|---|
| 489 |
init_color(i, angband_color_table[i][1] * 1000 / 255, |
|---|
| 490 |
angband_color_table[i][2] * 1000 / 255, |
|---|
| 491 |
angband_color_table[i][3] * 1000 / 255); |
|---|
| 492 |
} |
|---|
| 493 |
|
|---|
| 494 |
#endif |
|---|
| 495 |
|
|---|
| 496 |
|
|---|
| 497 |
return (0); |
|---|
| 498 |
} |
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
static errr Term_xtra_gcu(int n, int v) |
|---|
| 505 |
{ |
|---|
| 506 |
term_data *td = (term_data *)(Term->data); |
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
switch (n) |
|---|
| 510 |
{ |
|---|
| 511 |
|
|---|
| 512 |
case TERM_XTRA_CLEAR: |
|---|
| 513 |
touchwin(td->win); |
|---|
| 514 |
(void)wclear(td->win); |
|---|
| 515 |
return (0); |
|---|
| 516 |
|
|---|
| 517 |
|
|---|
| 518 |
case TERM_XTRA_NOISE: |
|---|
| 519 |
(void)write(1, "\007", 1); |
|---|
| 520 |
return (0); |
|---|
| 521 |
|
|---|
| 522 |
|
|---|
| 523 |
case TERM_XTRA_FRESH: |
|---|
| 524 |
(void)wrefresh(td->win); |
|---|
| 525 |
return (0); |
|---|
| 526 |
|
|---|
| 527 |
#ifdef USE_CURS_SET |
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
case TERM_XTRA_SHAPE: |
|---|
| 531 |
curs_set(v); |
|---|
| 532 |
return (0); |
|---|
| 533 |
|
|---|
| 534 |
#endif |
|---|
| 535 |
|
|---|
| 536 |
|
|---|
| 537 |
case TERM_XTRA_ALIVE: |
|---|
| 538 |
return (Term_xtra_gcu_alive(v)); |
|---|
| 539 |
|
|---|
| 540 |
|
|---|
| 541 |
case TERM_XTRA_EVENT: |
|---|
| 542 |
return (Term_xtra_gcu_event(v)); |
|---|
| 543 |
|
|---|
| 544 |
|
|---|
| 545 |
case TERM_XTRA_FLUSH: |
|---|
| 546 |
while (!Term_xtra_gcu_event(FALSE)); |
|---|
| 547 |
return (0); |
|---|
| 548 |
|
|---|
| 549 |
|
|---|
| 550 |
case TERM_XTRA_DELAY: |
|---|
| 551 |
if (v > 0) |
|---|
| 552 |
usleep(1000 * v); |
|---|
| 553 |
return (0); |
|---|
| 554 |
|
|---|
| 555 |
|
|---|
| 556 |
case TERM_XTRA_REACT: |
|---|
| 557 |
Term_xtra_gcu_react(); |
|---|
| 558 |
return (0); |
|---|
| 559 |
} |
|---|
| 560 |
|
|---|
| 561 |
|
|---|
| 562 |
return (1); |
|---|
| 563 |
} |
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
|
|---|
| 569 |
static errr Term_curs_gcu(int x, int y) |
|---|
| 570 |
{ |
|---|
| 571 |
term_data *td = (term_data *)(Term->data); |
|---|
| 572 |
|
|---|
| 573 |
|
|---|
| 574 |
wmove(td->win, y, x); |
|---|
| 575 |
|
|---|
| 576 |
|
|---|
| 577 |
return (0); |
|---|
| 578 |
} |
|---|
| 579 |
|
|---|
| 580 |
|
|---|
| 581 |
|
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 |
static errr Term_wipe_gcu(int x, int y, int n) |
|---|
| 586 |
{ |
|---|
| 587 |
term_data *td = (term_data *)(Term->data); |
|---|
| 588 |
char buf[1024]; |
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 |
wmove(td->win, y, x); |
|---|
| 592 |
|
|---|
| 593 |
|
|---|
| 594 |
if (x + n >= td->t.wid) |
|---|
| 595 |
{ |
|---|
| 596 |
wclrtoeol(td->win); |
|---|
| 597 |
} |
|---|
| 598 |
|
|---|
| 599 |
|
|---|
| 600 |
else |
|---|
| 601 |
{ |
|---|
| 602 |
|
|---|
| 603 |
strnfmt(buf, sizeof(buf), "%*c", n, ' '); |
|---|
| 604 |
|
|---|
| 605 |
|
|---|
| 606 |
waddstr(td->win, buf); |
|---|
| 607 |
} |
|---|
| 608 |
|
|---|
| 609 |
|
|---|
| 610 |
return (0); |
|---|
| 611 |
} |
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| 614 |
|
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 |
static errr Term_text_gcu(int x, int y, int n, byte a, cptr s) |
|---|
| 618 |
{ |
|---|
| 619 |
term_data *td = (term_data *)(Term->data); |
|---|
| 620 |
char buf[1024]; |
|---|
| 621 |
|
|---|
| 622 |
#ifdef A_COLOR |
|---|
| 623 |
|
|---|
| 624 |
if (can_use_color) wattrset(td->win, colortable[a & (BASIC_COLORS-1)]); |
|---|
| 625 |
#endif |
|---|
| 626 |
|
|---|
| 627 |
|
|---|
| 628 |
wmove(td->win, y, x); |
|---|
| 629 |
|
|---|
| 630 |
|
|---|
| 631 |
strnfmt(buf, sizeof(buf), "%.*s", n, s); |
|---|
| 632 |
|
|---|
| 633 |
|
|---|
| 634 |
waddstr(td->win, buf); |
|---|
| 635 |
|
|---|
| 636 |
#ifdef A_COLOR |
|---|
| 637 |
|
|---|
| 638 |
if (can_use_color) wattrset(td->win, 0); |
|---|
| 639 |
#endif |
|---|
| 640 |
|
|---|
| 641 |
|
|---|
| 642 |
return (0); |
|---|
| 643 |
} |
|---|
| 644 |
|
|---|
| 645 |
|
|---|
| 646 |
|
|---|
| 647 |
|
|---|
| 648 |
|
|---|
| 649 |
|
|---|
| 650 |
|
|---|
| 651 |
static errr term_data_init_gcu(term_data *td, int rows, int cols, int y, int x) |
|---|
| 652 |
{ |
|---|
| 653 |
term *t = &td->t; |
|---|
| 654 |
|
|---|
| 655 |
|
|---|
| 656 |
td->win = newwin(rows, cols, y, x); |
|---|
| 657 |
|
|---|
| 658 |
|
|---|
| 659 |
if (!td->win) |
|---|
| 660 |
{ |
|---|
| 661 |
|
|---|
| 662 |
quit("Failed to setup curses window."); |
|---|
| 663 |
} |
|---|
| 664 |
|
|---|
| 665 |
|
|---|
| 666 |
term_init(t, cols, rows, 256); |
|---|
| 667 |
|
|---|
| 668 |
|
|---|
| 669 |
t->icky_corner = TRUE; |
|---|
| 670 |
|
|---|
| 671 |
|
|---|
| 672 |
t->attr_blank = TERM_WHITE; |
|---|
| 673 |
t->char_blank = ' '; |
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 |
t->init_hook = Term_init_gcu; |
|---|
| 677 |
t->nuke_hook = Term_nuke_gcu; |
|---|
| 678 |
|
|---|
| 679 |
|
|---|
| 680 |
t->text_hook = Term_text_gcu; |
|---|
| 681 |
t->wipe_hook = Term_wipe_gcu; |
|---|
| 682 |
t->curs_hook = Term_curs_gcu; |
|---|
| 683 |
t->xtra_hook = Term_xtra_gcu; |
|---|
| 684 |
|
|---|
| 685 |
|
|---|
| 686 |
t->data = td; |
|---|
| 687 |
|
|---|
| 688 |
|
|---|
| 689 |
Term_activate(t); |
|---|
| 690 |
|
|---|
| 691 |
|
|---|
| 692 |
return (0); |
|---|
| 693 |
} |
|---|
| 694 |
|
|---|
| 695 |
|
|---|
| 696 |
static void hook_quit(cptr str) |
|---|
| 697 |
{ |
|---|
| 698 |
|
|---|
| 699 |
(void)str; |
|---|
| 700 |
|
|---|
| 701 |
|
|---|
| 702 |
endwin(); |
|---|
| 703 |
} |
|---|
| 704 |
|
|---|
| 705 |
|
|---|
| 706 |
|
|---|
| 707 |
|
|---|
| 708 |
|
|---|
| 709 |
|
|---|
| 710 |
|
|---|
| 711 |
|
|---|
| 712 |
|
|---|
| 713 |
|
|---|
| 714 |
errr init_gcu(int argc, char **argv) |
|---|
| 715 |
{ |
|---|
| 716 |
int i; |
|---|
| 717 |
|
|---|
| 718 |
int num_term = MAX_TERM_DATA, next_win = 0; |
|---|
| 719 |
|
|---|
| 720 |
bool use_big_screen = FALSE; |
|---|
| 721 |
|
|---|
| 722 |
|
|---|
| 723 |
|
|---|
| 724 |
for (i = 1; i < argc; i++) |
|---|
| 725 |
{ |
|---|
| 726 |
if (prefix(argv[i], "-b")) |
|---|
| 727 |
{ |
|---|
| 728 |
use_big_screen = TRUE; |
|---|
| 729 |
continue; |
|---|
| 730 |
} |
|---|
| 731 |
|
|---|
| 732 |
plog_fmt("Ignoring option: %s", argv[i]); |
|---|
| 733 |
} |
|---|
| 734 |
|
|---|
| 735 |
|
|---|
| 736 |
|
|---|
| 737 |
keymap_norm_prepare(); |
|---|
| 738 |
|
|---|
| 739 |
|
|---|
| 740 |
if (initscr() == NULL) return (-1); |
|---|
| 741 |
|
|---|
| 742 |
|
|---|
| 743 |
quit_aux = hook_quit; |
|---|
| 744 |
|
|---|
| 745 |
|
|---|
| 746 |
if ((LINES < 24) || (COLS < 80)) |
|---|
| 747 |
{ |
|---|
| 748 |
quit("Angband needs at least an 80x24 'curses' screen"); |
|---|
| 749 |
} |
|---|
| 750 |
|
|---|
| 751 |
|
|---|
| 752 |
#ifdef A_COLOR |
|---|
| 753 |
|
|---|
| 754 |
|
|---|
| 755 |
|
|---|
| 756 |
|
|---|
| 757 |
can_use_color = ((start_color() != ERR) && has_colors() && |
|---|
| 758 |
(COLORS >= 8) && (COLOR_PAIRS >= 8)); |
|---|
| 759 |
|
|---|
| 760 |
#ifdef HAVE_CAN_CHANGE_COLOR |
|---|
| 761 |
|
|---|
| 762 |
|
|---|
| 763 |
can_fix_color = (can_use_color && can_change_color() && |
|---|
| 764 |
(COLORS >= 16) && (COLOR_PAIRS > 8)); |
|---|
| 765 |
|
|---|
| 766 |
#endif |
|---|
| 767 |
|
|---|
| 768 |
|
|---|
| 769 |
if (can_fix_color) |
|---|
| 770 |
{ |
|---|
| 771 |
|
|---|
| 772 |
for (i = 0; i < (BASIC_COLORS / 2); i++) |
|---|
| 773 |
{ |
|---|
| 774 |
|
|---|
| 775 |
if (init_pair(i + 1, i, 0) == ERR) |
|---|
| 776 |
{ |
|---|
| 777 |
quit("Color pair init failed"); |
|---|
| 778 |
} |
|---|
| 779 |
|
|---|
| 780 |
|
|---|
| 781 |
colortable[i] = (COLOR_PAIR(i + 1) | A_NORMAL); |
|---|
| 782 |
colortable[i + (BASIC_COLORS / 2)] = (COLOR_PAIR(i + 1) | A_BRIGHT); |
|---|
| 783 |
} |
|---|
| 784 |
|
|---|
| 785 |
|
|---|
| 786 |
|
|---|
| 787 |
|
|---|
| 788 |
Term_xtra_gcu_react(); |
|---|
| 789 |
} |
|---|
| 790 |
|
|---|
| 791 |
|
|---|
| 792 |
else if (can_use_color) |
|---|
| 793 |
{ |
|---|
| 794 |
|
|---|
| 795 |
|
|---|
| 796 |
|
|---|
| 797 |
init_pair(1, COLOR_RED, COLOR_BLACK); |
|---|
| 798 |
init_pair(2, COLOR_GREEN, COLOR_BLACK); |
|---|
| 799 |
init_pair(3, COLOR_YELLOW, COLOR_BLACK); |
|---|
| 800 |
init_pair(4, COLOR_BLUE, COLOR_BLACK); |
|---|
| 801 |
init_pair(5, COLOR_MAGENTA, COLOR_BLACK); |
|---|
| 802 |
init_pair(6, COLOR_CYAN, COLOR_BLACK); |
|---|
| 803 |
init_pair(7, COLOR_BLACK, COLOR_BLACK); |
|---|
| 804 |
|
|---|
| 805 |
|
|---|
| 806 |
colortable[0] = (COLOR_PAIR(7) | A_NORMAL); |
|---|
| 807 |
colortable[1] = (COLOR_PAIR(0) | A_BRIGHT); |
|---|
| 808 |
colortable[2] = (COLOR_PAIR(0) | A_NORMAL); |
|---|
| 809 |
colortable[3] = (COLOR_PAIR(1) | A_BRIGHT); |
|---|
| 810 |
colortable[4] = (COLOR_PAIR(1) | A_NORMAL); |
|---|
| 811 |
colortable[5] = (COLOR_PAIR(2) | A_NORMAL); |
|---|
| 812 |
colortable[6] = (COLOR_PAIR(4) | A_NORMAL); |
|---|
| 813 |
colortable[7] = (COLOR_PAIR(3) | A_NORMAL); |
|---|
| 814 |
colortable[8] = (COLOR_PAIR(7) | A_BRIGHT); |
|---|
| 815 |
colortable[9] = (COLOR_PAIR(0) | A_NORMAL); |
|---|
| 816 |
colortable[10] = (COLOR_PAIR(5) | A_NORMAL); |
|---|
| 817 |
colortable[11] = (COLOR_PAIR(3) | A_BRIGHT); |
|---|
| 818 |
colortable[12] = (COLOR_PAIR(5) | A_BRIGHT); |
|---|
| 819 |
colortable[13] = (COLOR_PAIR(2) | A_BRIGHT); |
|---|
| 820 |
colortable[14] = (COLOR_PAIR(4) | A_BRIGHT); |
|---|
| 821 |
colortable[15] = (COLOR_PAIR(3) | A_NORMAL); |
|---|
| 822 |
} |
|---|
| 823 |
|
|---|
| 824 |
#endif |
|---|
| 825 |
|
|---|
| 826 |
|
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 |
|
|---|
| 830 |
nodelay(stdscr, FALSE); |
|---|
| 831 |
|
|---|
| 832 |
|
|---|
| 833 |
cbreak(); |
|---|
| 834 |
noecho(); |
|---|
| 835 |
nonl(); |
|---|
| 836 |
|
|---|
| 837 |
#ifdef PDCURSES |
|---|
| 838 |
keypad(stdscr, TRUE); |
|---|
| 839 |
#endif |
|---|
| 840 |
|
|---|
| 841 |
|
|---|
| 842 |
keymap_game_prepare(); |
|---|
| 843 |
|
|---|
| 844 |
|
|---|
| 845 |
|
|---|
| 846 |
|
|---|
| 847 |
|
|---|
| 848 |
if (use_big_screen) |
|---|
| 849 |
{ |
|---|
| 850 |
|
|---|
| 851 |
term_data_init_gcu(&data[0], LINES, COLS, 0, 0); |
|---|
| 852 |
|
|---|
| 853 |
|
|---|
| 854 |
angband_term[0] = &data[0].t; |
|---|
| 855 |
} |
|---|
| 856 |
|
|---|
| 857 |
|
|---|
| 858 |
else |
|---|
| 859 |
{ |
|---|
| 860 |
|
|---|
| 861 |
for (i = 0; i < num_term; i++) |
|---|
| 862 |
{ |
|---|
| 863 |
int rows, cols, y, x; |
|---|
| 864 |
|
|---|
| 865 |
|
|---|
| 866 |
switch (i) |
|---|
| 867 |
{ |
|---|
| 868 |
|
|---|
| 869 |
case 0: |
|---|
| 870 |
{ |
|---|
| 871 |
rows = 24; |
|---|
| 872 |
cols = 80; |
|---|
| 873 |
y = x = 0; |
|---|
| 874 |
break; |
|---|
| 875 |
} |
|---|
| 876 |
|
|---|
| 877 |
|
|---|
| 878 |
case 1: |
|---|
| 879 |
{ |
|---|
| 880 |
rows = LINES - 25; |
|---|
| 881 |
cols = 80; |
|---|
| 882 |
y = 25; |
|---|
| 883 |
x = 0; |
|---|
| 884 |
break; |
|---|
| 885 |
} |
|---|
| 886 |
|
|---|
| 887 |
|
|---|
| 888 |
case 2: |
|---|
| 889 |
{ |
|---|
| 890 |
rows = 24; |
|---|
| 891 |
cols = COLS - 81; |
|---|
| 892 |
y = 0; |
|---|
| 893 |
x = 81; |
|---|
| 894 |
break; |
|---|
| 895 |
} |
|---|
| 896 |
|
|---|
| 897 |
|
|---|
| 898 |
case 3: |
|---|
| 899 |
{ |
|---|
| 900 |
rows = LINES - 25; |
|---|
| 901 |
cols = COLS - 81; |
|---|
| 902 |
y = 25; |
|---|
| 903 |
x = 81; |
|---|
| 904 |
break; |
|---|
| 905 |
} |
|---|
| 906 |
|
|---|
| 907 |
|
|---|
| 908 |
default: |
|---|
| 909 |
{ |
|---|
| 910 |
rows = cols = y = x = 0; |
|---|
| 911 |
break; |
|---|
| 912 |
} |
|---|
| 913 |
} |
|---|
| 914 |
|
|---|
| 915 |
|
|---|
| 916 |
if (rows <= 0 || cols <= 0) continue; |
|---|
| 917 |
|
|---|
| 918 |
|
|---|
| 919 |
term_data_init_gcu(&data[next_win], rows, cols, y, x); |
|---|
| 920 |
|
|---|
| 921 |
|
|---|
| 922 |
angband_term[next_win] = &data[next_win].t; |
|---|
| 923 |
|
|---|
| 924 |
|
|---|
| 925 |
next_win++; |
|---|
| 926 |
} |
|---|
| 927 |
} |
|---|
| 928 |
|
|---|
| 929 |
|
|---|
| 930 |
Term_activate(&data[0].t); |
|---|
| 931 |
|
|---|
| 932 |
|
|---|
| 933 |
term_screen = &data[0].t; |
|---|
| 934 |
|
|---|
| 935 |
|
|---|
| 936 |
return (0); |
|---|
| 937 |
} |
|---|
| 938 |
|
|---|
| 939 |
|
|---|
| 940 |
#endif |
|---|