| 1 | /** |
| 2 | * \file main-xxx.c |
| 3 | * \brief Outline how to make a new "main-xxx" file. |
| 4 | * |
| 5 | * Copyright (c) 1997 Ben Harrison |
| 6 | * |
| 7 | * This work is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of either: |
| 9 | * |
| 10 | * a) the GNU General Public License as published by the Free Software |
| 11 | * Foundation, version 2, or |
| 12 | * |
| 13 | * b) the "Angband licence": |
| 14 | * This software may be copied and distributed for educational, research, |
| 15 | * and not for profit purposes provided that this copyright and statement |
| 16 | * are included in all such copies. Other copyrights may also apply. |
| 17 | */ |
| 18 | #include "angband.h" |
| 19 | #include "init.h" |
| 20 | |
| 21 | /** |
| 22 | * This file helps Angband work on non-existant computers. |
| 23 | * |
| 24 | * To use this file, use "Makefile.xxx", which defines USE_XXX. |
| 25 | * |
| 26 | * |
| 27 | * This file is intended to show one way to build a "visual module" |
| 28 | * for Angband to allow it to work with a new system. It does not |
| 29 | * actually work, but if the code near "XXX XXX XXX" comments were |
| 30 | * replaced with functional code, then it probably would. |
| 31 | * |
| 32 | * See "ui-term.c" for info on the concept of the "generic terminal", |
| 33 | * and for more comments about what this file must supply. |
| 34 | * |
| 35 | * There are two basic ways to port Angband to a new system. The |
| 36 | * first involves modifying the "main-gcu.c" and/or "main-x11.c" |
| 37 | * files to support some version of "curses" and/or "X11" on your |
| 38 | * machine, and to compile with the "USE_GCU" and/or "USE_X11" |
| 39 | * compilation flags defined. The second involves creating a |
| 40 | * new "main-xxx.c" file, based on this sample file (or on any |
| 41 | * existing "main-xxx.c" file), and comes in two flavors, based |
| 42 | * on whether it contains a "main()" function (as in "main-mac.c" |
| 43 | * and "main-win.c") or not (as in "main-gcu.c" or "main-x11.c"). |
| 44 | * |
| 45 | * If the "main-xxx.c" file includes its own "main()" function, |
| 46 | * then you should NOT link in the "main.c" file, and your "main()" |
| 47 | * function must process any command line arguments, initialize the |
| 48 | * "visual system", and call "play_game()" with appropriate arguments. |
| 49 | * |
| 50 | * If the "main-xxx.c" file does not include its own "main()" |
| 51 | * function, then you must add some code to "main.c" which, if |
| 52 | * the appropriate "USE_XXX" compilation flag is defined, will |
| 53 | * attempt to call the "init_xxx()" function in the "main-xxx.c" |
| 54 | * file, which should initialize the "visual system" and return |
| 55 | * zero if it was successful. The "main()" function in "main.c" |
| 56 | * will take care of processing command line arguments and then |
| 57 | * calling "play_game()" with appropriate arguments. |
| 58 | * |
| 59 | * Note that the "util.c" file often contains functions which must |
| 60 | * be modified in small ways for various platforms, even if you are |
| 61 | * able to use the existing "main-gcu.c" and/or "main-x11.c" files, |
| 62 | * in particular, the "file handling" functions may not work on all |
| 63 | * systems. |
| 64 | * |
| 65 | * When you complete a port to a new system, you should email any |
| 66 | * newly created files, and any changes made to existing files, |
| 67 | * including "h-config.h", "config.h", and any of the "Makefile" |
| 68 | * files, to "[email protected]" for inclusion in the next version. |
| 69 | * |
| 70 | * Always choose a "three letter" naming scheme for "main-xxx.c" |
| 71 | * and "Makefile.xxx" and such for consistency and simplicity. |
| 72 | * |
| 73 | * |
| 74 | * Initial framework (and all code) by Ben Harrison ([email protected]). |
| 75 | */ |
| 76 | |
| 77 | |
| 78 | #ifdef USE_XXX |
| 79 | |
| 80 | #include "main.h" |
| 81 | |
| 82 | /** |
| 83 | * Extra data to associate with each "window" |
| 84 | * |
| 85 | * Each "window" is represented by a "term_data" structure, which |
| 86 | * contains a "term" structure, which contains a pointer (t->data) |
| 87 | * back to the term_data structure. |
| 88 | */ |
| 89 | |
| 90 | typedef struct term_data term_data; |
| 91 | |
| 92 | struct term_data |
| 93 | { |
| 94 | term t; |
| 95 | |
| 96 | /* Other fields if needed XXX XXX XXX */ |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | |
| 101 | /** |
| 102 | * Number of "term_data" structures to support XXX XXX XXX |
| 103 | * |
| 104 | * You MUST support at least one "term_data" structure, and the |
| 105 | * game will currently use up to eight "term_data" structures if |
| 106 | * they are available. |
| 107 | * |
| 108 | * Actually, MAX_TERM_DATA is now defined as eight in 'defines.h'. |
| 109 | * |
| 110 | * If only one "term_data" structure is supported, then a lot of |
| 111 | * the things that would normally go into a "term_data" structure |
| 112 | * could be made into global variables instead. |
| 113 | */ |
| 114 | #define MAX_XXX_TERM 1 |
| 115 | |
| 116 | |
| 117 | /** |
| 118 | * An array of "term_data" structures, one for each "sub-window" |
| 119 | */ |
| 120 | static term_data data[MAX_XXX_TERM]; |
| 121 | |
| 122 | |
| 123 | #if 0 |
| 124 | |
| 125 | /** |
| 126 | * Often, it is helpful to create an array of "color data" containing |
| 127 | * a representation of the "angband_color_table" array in some "local" form. |
| 128 | * |
| 129 | * Often, the "Term_xtra(TERM_XTRA_REACT, 0)" hook is used to initialize |
| 130 | * "color_data" from "angband_color_table". XXX XXX XXX |
| 131 | */ |
| 132 | static local_color_data_type color_data[MAX_COLORS]; |
| 133 | |
| 134 | #endif |
| 135 | |
| 136 | |
| 137 | /** |
| 138 | * ------------------------------------------------------------------------ |
| 139 | * Function hooks needed by "Term" |
| 140 | * ------------------------------------------------------------------------ */ |
| 141 | |
| 142 | |
| 143 | /** |
| 144 | * Init a new "term" |
| 145 | * |
| 146 | * This function should do whatever is necessary to prepare a new "term" |
| 147 | * for use by the "ui-term.c" package. This may include clearing the window, |
| 148 | * preparing the cursor, setting the font/colors, etc. Usually, this |
| 149 | * function does nothing, and the "init_xxx()" function does it all. |
| 150 | */ |
| 151 | static void Term_init_xxx(term *t) |
| 152 | { |
| 153 | term_data *td = (term_data*)(t->data); |
| 154 | |
| 155 | /* XXX XXX XXX */ |
| 156 | } |
| 157 | |
| 158 | |
| 159 | |
| 160 | /** |
| 161 | * Nuke an old "term" |
| 162 | * |
| 163 | * This function is called when an old "term" is no longer needed. It should |
| 164 | * do whatever is needed to clean up before the program exits, such as wiping |
| 165 | * the screen, restoring the cursor, fixing the font, etc. Often this function |
| 166 | * does nothing and lets the operating system clean up when the program quits. |
| 167 | */ |
| 168 | static void Term_nuke_xxx(term *t) |
| 169 | { |
| 170 | term_data *td = (term_data*)(t->data); |
| 171 | |
| 172 | /* XXX XXX XXX */ |
| 173 | } |
| 174 | |
| 175 | |
| 176 | |
| 177 | /** |
| 178 | * Do a "special thing" to the current "term" |
| 179 | * |
| 180 | * This function must react to a large number of possible arguments, each |
| 181 | * corresponding to a different "action request" by the "ui-term.c" package, |
| 182 | * or by the application itself. |
| 183 | * |
| 184 | * The "action type" is specified by the first argument, which must be a |
| 185 | * constant of the form "TERM_XTRA_*" as given in "ui-term.h", and the second |
| 186 | * argument specifies the "information" for that argument, if any, and will |
| 187 | * vary according to the first argument. |
| 188 | * |
| 189 | * In general, this function should return zero if the action is successfully |
| 190 | * handled, and non-zero if the action is unknown or incorrectly handled. |
| 191 | */ |
| 192 | static errr Term_xtra_xxx(int n, int v) |
| 193 | { |
| 194 | term_data *td = (term_data*)(Term->data); |
| 195 | |
| 196 | /* Analyze */ |
| 197 | switch (n) |
| 198 | { |
| 199 | case TERM_XTRA_EVENT: |
| 200 | { |
| 201 | /* |
| 202 | * Process some pending events XXX XXX XXX |
| 203 | * |
| 204 | * Wait for at least one event if "v" is non-zero |
| 205 | * otherwise, if no events are ready, return at once. |
| 206 | * When "keypress" events are encountered, the "ascii" |
| 207 | * value corresponding to the key should be sent to the |
| 208 | * "Term_keypress()" function. Certain "bizarre" keys, |
| 209 | * such as function keys or arrow keys, may send special |
| 210 | * sequences of characters, such as control-underscore, |
| 211 | * plus letters corresponding to modifier keys, plus an |
| 212 | * underscore, plus carriage return, which can be used by |
| 213 | * the main program for "macro" triggers. This action |
| 214 | * should handle as many events as is efficiently possible |
| 215 | * but is only required to handle a single event, and then |
| 216 | * only if one is ready or "v" is true. |
| 217 | * |
| 218 | * This action is required. |
| 219 | */ |
| 220 | |
| 221 | return (0); |
| 222 | } |
| 223 | |
| 224 | case TERM_XTRA_FLUSH: |
| 225 | { |
| 226 | /* |
| 227 | * Flush all pending events XXX XXX XXX |
| 228 | * |
| 229 | * This action should handle all events waiting on the |
| 230 | * queue, optionally discarding all "keypress" events, |
| 231 | * since they will be discarded anyway in "ui-term.c". |
| 232 | * |
| 233 | * This action is required, but may not be "essential". |
| 234 | */ |
| 235 | |
| 236 | return (0); |
| 237 | } |
| 238 | |
| 239 | case TERM_XTRA_CLEAR: |
| 240 | { |
| 241 | /* |
| 242 | * Clear the entire window XXX XXX XXX |
| 243 | * |
| 244 | * This action should clear the entire window, and redraw |
| 245 | * any "borders" or other "graphic" aspects of the window. |
| 246 | * |
| 247 | * This action is required. |
| 248 | */ |
| 249 | |
| 250 | return (0); |
| 251 | } |
| 252 | |
| 253 | case TERM_XTRA_SHAPE: |
| 254 | { |
| 255 | /* |
| 256 | * Set the cursor visibility XXX XXX XXX |
| 257 | * |
| 258 | * This action should change the visibility of the cursor, |
| 259 | * if possible, to the requested value (0=off, 1=on) |
| 260 | * |
| 261 | * This action is optional, but can improve both the |
| 262 | * efficiency (and attractiveness) of the program. |
| 263 | */ |
| 264 | |
| 265 | return (0); |
| 266 | } |
| 267 | |
| 268 | case TERM_XTRA_FROSH: |
| 269 | { |
| 270 | /* |
| 271 | * Flush a row of output XXX XXX XXX |
| 272 | * |
| 273 | * This action should make sure that row "v" of the "output" |
| 274 | * to the window will actually appear on the window. |
| 275 | * |
| 276 | * This action is optional, assuming that "Term_text_xxx()" |
| 277 | * (and similar functions) draw directly to the screen, or |
| 278 | * that the "TERM_XTRA_FRESH" entry below takes care of any |
| 279 | * necessary flushing issues. |
| 280 | */ |
| 281 | |
| 282 | return (0); |
| 283 | } |
| 284 | |
| 285 | case TERM_XTRA_FRESH: |
| 286 | { |
| 287 | /* |
| 288 | * Flush output XXX XXX XXX |
| 289 | * |
| 290 | * This action should make sure that all "output" to the |
| 291 | * window will actually appear on the window. |
| 292 | * |
| 293 | * This action is optional, assuming that "Term_text_xxx()" |
| 294 | * (and similar functions) draw directly to the screen, or |
| 295 | * that the "TERM_XTRA_FROSH" entry above takes care of any |
| 296 | * necessary flushing issues. |
| 297 | */ |
| 298 | |
| 299 | return (0); |
| 300 | } |
| 301 | |
| 302 | case TERM_XTRA_NOISE: |
| 303 | { |
| 304 | /* |
| 305 | * Make a noise XXX XXX XXX |
| 306 | * |
| 307 | * This action should produce a "beep" noise. |
| 308 | * |
| 309 | * This action is optional, but convenient. |
| 310 | */ |
| 311 | |
| 312 | return (0); |
| 313 | } |
| 314 | |
| 315 | case TERM_XTRA_BORED: |
| 316 | { |
| 317 | /* |
| 318 | * Handle random events when bored XXX XXX XXX |
| 319 | * |
| 320 | * This action is optional, and normally not important |
| 321 | */ |
| 322 | |
| 323 | return (0); |
| 324 | } |
| 325 | |
| 326 | case TERM_XTRA_REACT: |
| 327 | { |
| 328 | /* |
| 329 | * React to global changes XXX XXX XXX |
| 330 | * |
| 331 | * For example, this action can be used to react to |
| 332 | * changes in the global "angband_color_table[MAX_COLORS][4]" array. |
| 333 | * |
| 334 | * This action is optional, but can be very useful for |
| 335 | * handling "color changes" and the "arg_sound" and/or |
| 336 | * "arg_graphics" options. |
| 337 | */ |
| 338 | |
| 339 | return (0); |
| 340 | } |
| 341 | |
| 342 | case TERM_XTRA_ALIVE: |
| 343 | { |
| 344 | /* |
| 345 | * Change the "hard" level XXX XXX XXX |
| 346 | * |
| 347 | * This action is used if the program changes "aliveness" |
| 348 | * by being either "suspended" (v=0) or "resumed" (v=1) |
| 349 | * This action is optional, unless the computer uses the |
| 350 | * same "physical screen" for multiple programs, in which |
| 351 | * case this action should clean up to let other programs |
| 352 | * use the screen, or resume from such a cleaned up state. |
| 353 | * |
| 354 | * This action is currently only used by "main-gcu.c", |
| 355 | * on UNIX machines, to allow proper "suspending". |
| 356 | */ |
| 357 | |
| 358 | return (0); |
| 359 | } |
| 360 | |
| 361 | case TERM_XTRA_LEVEL: |
| 362 | { |
| 363 | /* |
| 364 | * Change the "soft" level XXX XXX XXX |
| 365 | * |
| 366 | * This action is used when the term window changes "activation" |
| 367 | * either by becoming "inactive" (v=0) or "active" (v=1) |
| 368 | * |
| 369 | * This action can be used to do things like activate the proper |
| 370 | * font / drawing mode for the newly active term window. This |
| 371 | * action should NOT change which window has the "focus", which |
| 372 | * window is "raised", or anything like that. |
| 373 | * |
| 374 | * This action is optional if all the other things which depend |
| 375 | * on what term is active handle activation themself, or if only |
| 376 | * one "term_data" structure is supported by this file. |
| 377 | */ |
| 378 | |
| 379 | return (0); |
| 380 | } |
| 381 | |
| 382 | case TERM_XTRA_DELAY: |
| 383 | { |
| 384 | /* |
| 385 | * Delay for some milliseconds XXX XXX XXX |
| 386 | * |
| 387 | * This action is useful for proper "timing" of certain |
| 388 | * visual effects, such as breath attacks. |
| 389 | * |
| 390 | * This action is optional, but may be required by this file, |
| 391 | * especially if special "macro sequences" must be supported. |
| 392 | */ |
| 393 | |
| 394 | return (0); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | /* Unknown or Unhandled action */ |
| 399 | return (1); |
| 400 | } |
| 401 | |
| 402 | |
| 403 | /** |
| 404 | * Display the cursor |
| 405 | * |
| 406 | * This routine should display the cursor at the given location |
| 407 | * (x,y) in some manner. On some machines this involves actually |
| 408 | * moving the physical cursor, on others it involves drawing a fake |
| 409 | * cursor in some form of graphics mode. Note the "soft_cursor" |
| 410 | * flag which tells "ui-term.c" to treat the "cursor" as a "visual" |
| 411 | * thing and not as a "hardware" cursor. |
| 412 | * |
| 413 | * You may assume "valid" input if the window is properly sized. |
| 414 | * |
| 415 | * You may use the "Term_what(x, y, &a, &c)" function, if needed, |
| 416 | * to determine what attr/char should be "under" the new cursor, |
| 417 | * for "inverting" purposes or whatever. |
| 418 | */ |
| 419 | static errr Term_curs_xxx(int x, int y) |
| 420 | { |
| 421 | term_data *td = (term_data*)(Term->data); |
| 422 | |
| 423 | /* XXX XXX XXX */ |
| 424 | |
| 425 | /* Success */ |
| 426 | return (0); |
| 427 | } |
| 428 | |
| 429 | |
| 430 | /** |
| 431 | * Erase some characters |
| 432 | * |
| 433 | * This function should erase "n" characters starting at (x,y). |
| 434 | * |
| 435 | * You may assume "valid" input if the window is properly sized. |
| 436 | */ |
| 437 | static errr Term_wipe_xxx(int x, int y, int n) |
| 438 | { |
| 439 | term_data *td = (term_data*)(Term->data); |
| 440 | |
| 441 | /* XXX XXX XXX */ |
| 442 | |
| 443 | /* Success */ |
| 444 | return (0); |
| 445 | } |
| 446 | |
| 447 | |
| 448 | /** |
| 449 | * Draw some text on the screen |
| 450 | * |
| 451 | * This function should actually display an array of characters |
| 452 | * starting at the given location, using the given "attribute", |
| 453 | * and using the given string of characters, which contains |
| 454 | * exactly "n" characters and which is NOT null-terminated. |
| 455 | * |
| 456 | * You may assume "valid" input if the window is properly sized. |
| 457 | * |
| 458 | * You must be sure that the string, when written, erases anything |
| 459 | * (including any visual cursor) that used to be where the text is |
| 460 | * drawn. On many machines this happens automatically, on others, |
| 461 | * you must first call "Term_wipe_xxx()" to clear the area. |
| 462 | * |
| 463 | * In color environments, you should activate the color contained |
| 464 | * in "color_data[a & (MAX_COLORS - 1)]", if needed, before drawing anything. |
| 465 | * |
| 466 | * You may ignore the "attribute" if you are only supporting a |
| 467 | * monochrome environment, since this routine is normally never |
| 468 | * called to display "black" (invisible) text, including the |
| 469 | * default "spaces", and all other colors should be drawn in |
| 470 | * the "normal" color in a monochrome environment. |
| 471 | * |
| 472 | * Note that this function must correctly handle "black" text if |
| 473 | * the "always_text" flag is set, if this flag is not set, all the |
| 474 | * "black" text will be handled by the "Term_wipe_xxx()" hook. |
| 475 | */ |
| 476 | static errr Term_text_xxx(int x, int y, int n, int a, const char *cp) |
| 477 | { |
| 478 | term_data *td = (term_data*)(Term->data); |
| 479 | |
| 480 | /* XXX XXX XXX */ |
| 481 | |
| 482 | /* Success */ |
| 483 | return (0); |
| 484 | } |
| 485 | |
| 486 | |
| 487 | /** |
| 488 | * Draw some attr/char pairs on the screen |
| 489 | * |
| 490 | * This routine should display the given "n" attr/char pairs at |
| 491 | * the given location (x,y). This function is only used if one |
| 492 | * of the flags "always_pict" or "higher_pict" is defined. |
| 493 | * |
| 494 | * You must be sure that the attr/char pairs, when displayed, will |
| 495 | * erase anything (including any visual cursor) that used to be at |
| 496 | * the given location. On many machines this is automatic, but on |
| 497 | * others, you must first call "Term_wipe_xxx(x, y, 1)". |
| 498 | * |
| 499 | * With the "higher_pict" flag, this function can be used to allow |
| 500 | * the display of "pseudo-graphic" pictures, for example, by using |
| 501 | * the attr/char pair as an encoded index into a pixmap of special |
| 502 | * "pictures". |
| 503 | * |
| 504 | * With the "always_pict" flag, this function can be used to force |
| 505 | * every attr/char pair to be drawn by this function, which can be |
| 506 | * very useful if this file can optimize its own display calls. |
| 507 | * |
| 508 | * This function is often associated with the "arg_graphics" flag. |
| 509 | * |
| 510 | * This function is only used if one of the "higher_pict" and/or |
| 511 | * "always_pict" flags are set. |
| 512 | */ |
| 513 | static errr Term_pict_xxx(int x, int y, int n, const int *ap, const wchar_t *cp, |
| 514 | const int *tap, const wchar_t *tcp) |
| 515 | { |
| 516 | term_data *td = (term_data*)(Term->data); |
| 517 | |
| 518 | /* XXX XXX XXX */ |
| 519 | |
| 520 | /* Success */ |
| 521 | return (0); |
| 522 | } |
| 523 | |
| 524 | |
| 525 | |
| 526 | /** |
| 527 | * ------------------------------------------------------------------------ |
| 528 | * Internal Functions |
| 529 | * ------------------------------------------------------------------------ */ |
| 530 | |
| 531 | |
| 532 | /** |
| 533 | * Instantiate a "term_data" structure |
| 534 | * |
| 535 | * This is one way to prepare the "term_data" structures and to |
| 536 | * "link" the various informational pieces together. |
| 537 | * |
| 538 | * This function assumes that every window should be 80x24 in size |
| 539 | * (the standard size) and should be able to queue 256 characters. |
| 540 | * Technically, only the "main screen window" needs to queue any |
| 541 | * characters, but this method is simple. One way to allow some |
| 542 | * variation is to add fields to the "term_data" structure listing |
| 543 | * parameters for that window, initialize them in the "init_xxx()" |
| 544 | * function, and then use them in the code below. |
| 545 | * |
| 546 | * Note that "activation" calls the "Term_init_xxx()" hook for |
| 547 | * the "term" structure, if needed. |
| 548 | */ |
| 549 | static void term_data_link(int i) |
| 550 | { |
| 551 | term_data *td = &data[i]; |
| 552 | term *t = &td->t; |
| 553 | |
| 554 | /* Initialize the term */ |
| 555 | term_init(t, 80, 24, 256); |
| 556 | |
| 557 | /* Choose "soft" or "hard" cursor XXX XXX XXX */ |
| 558 | /* A "soft" cursor must be explicitly "drawn" by the program */ |
| 559 | /* while a "hard" cursor has some "physical" existance and is */ |
| 560 | /* moved whenever text is drawn on the screen. See "ui-term.c". */ |
| 561 | /* t->soft_cursor = true; */ |
| 562 | |
| 563 | /* Avoid the "corner" of the window XXX XXX XXX */ |
| 564 | /* t->icky_corner = true; */ |
| 565 | |
| 566 | /* Use "Term_pict()" for all attr/char pairs XXX XXX XXX */ |
| 567 | /* See the "Term_pict_xxx()" function above. */ |
| 568 | /* t->always_pict = true; */ |
| 569 | |
| 570 | /* Use "Term_pict()" for some attr/char pairs XXX XXX XXX */ |
| 571 | /* See the "Term_pict_xxx()" function above. */ |
| 572 | /* t->higher_pict = true; */ |
| 573 | |
| 574 | /* Use "Term_text()" even for "black" text XXX XXX XXX */ |
| 575 | /* See the "Term_text_xxx()" function above. */ |
| 576 | /* t->always_text = true; */ |
| 577 | |
| 578 | /* Ignore the "TERM_XTRA_BORED" action XXX XXX XXX */ |
| 579 | /* This may make things slightly more efficient. */ |
| 580 | /* t->never_bored = true; */ |
| 581 | |
| 582 | /* Ignore the "TERM_XTRA_FROSH" action XXX XXX XXX */ |
| 583 | /* This may make things slightly more efficient. */ |
| 584 | /* t->never_frosh = true; */ |
| 585 | |
| 586 | /* Prepare the init/nuke hooks */ |
| 587 | t->init_hook = Term_init_xxx; |
| 588 | t->nuke_hook = Term_nuke_xxx; |
| 589 | |
| 590 | /* Prepare the template hooks */ |
| 591 | t->xtra_hook = Term_xtra_xxx; |
| 592 | t->curs_hook = Term_curs_xxx; |
| 593 | t->wipe_hook = Term_wipe_xxx; |
| 594 | t->text_hook = Term_text_xxx; |
| 595 | t->pict_hook = Term_pict_xxx; |
| 596 | |
| 597 | /* Remember where we came from */ |
| 598 | t->data = td; |
| 599 | |
| 600 | /* Activate it */ |
| 601 | Term_activate(t); |
| 602 | |
| 603 | /* Global pointer */ |
| 604 | angband_term[i] = t; |
| 605 | } |
| 606 | |
| 607 | |
| 608 | /** |
| 609 | * Help message. |
| 610 | * 1st line = max 68 chars. |
| 611 | * Start next lines with 11 spaces |
| 612 | */ |
| 613 | const char help_xxx[] = "Describe XXX, subopts -describe suboptions here"; |
| 614 | |
| 615 | |
| 616 | /** |
| 617 | * Initialization function |
| 618 | */ |
| 619 | errr init_xxx(int argc, char **argv) |
| 620 | { |
| 621 | int i; |
| 622 | |
| 623 | /* Initialize globals XXX XXX XXX */ |
| 624 | |
| 625 | /* Initialize "term_data" structures XXX XXX XXX */ |
| 626 | |
| 627 | /* Initialize the "color_data" array XXX XXX XXX */ |
| 628 | |
| 629 | /* Create windows (backwards!) */ |
| 630 | for (i = MAX_XXX_TERM; i-- > 0; ) |
| 631 | { |
| 632 | /* Link */ |
| 633 | term_data_link(i); |
| 634 | } |
| 635 | |
| 636 | /* Success */ |
| 637 | return (0); |
| 638 | } |
| 639 | |
| 640 | |
| 641 | #ifdef INTERNAL_MAIN |
| 642 | |
| 643 | |
| 644 | /** |
| 645 | * Some special machines need their own "main()" function, which they |
| 646 | * can provide here, making sure NOT to compile the "main.c" file. |
| 647 | * |
| 648 | * These systems usually have some form of "event loop", run forever |
| 649 | * as the last step of "main()", which handles things like menus and |
| 650 | * window movement, and calls "play_game(GAME_LOAD)" to load a game after |
| 651 | * initializing "savefile" to a filename, or "play_game(GAME_NEW)" to make |
| 652 | * a new game. The event loop would also be triggered by "Term_xtra()" |
| 653 | * (the TERM_XTRA_EVENT action), in which case the event loop would not |
| 654 | * actually "loop", but would run once and return. |
| 655 | */ |
| 656 | |
| 657 | |
| 658 | /** |
| 659 | * An event handler XXX XXX XXX |
| 660 | * |
| 661 | * You may need an event handler, which can be used by both |
| 662 | * by the "TERM_XTRA_BORED" and "TERM_XTRA_EVENT" entries in |
| 663 | * the "Term_xtra_xxx()" function, and also to wait for the |
| 664 | * user to perform whatever user-interface operation is needed |
| 665 | * to request the start of a new game or the loading of an old |
| 666 | * game, both of which should launch the "play_game()" function. |
| 667 | */ |
| 668 | static bool CheckEvents(bool wait) |
| 669 | { |
| 670 | /* XXX XXX XXX */ |
| 671 | |
| 672 | return (0); |
| 673 | } |
| 674 | |
| 675 | |
| 676 | |
| 677 | /** |
| 678 | * Make a sound. |
| 679 | * |
| 680 | * This action should produce sound number "v", where the |
| 681 | * "name" of that sound is "sound_names[v]". |
| 682 | * |
| 683 | * This action is optional, and not very important. |
| 684 | */ |
| 685 | static void xxx_sound(game_event_type type, game_event_data *data, void *user) |
| 686 | { |
| 687 | int v = data->message.type; |
| 688 | |
| 689 | return; |
| 690 | } |
| 691 | |
| 692 | |
| 693 | /** |
| 694 | * Init some stuff |
| 695 | * |
| 696 | * This function is used to keep the "path" variable off the stack. |
| 697 | */ |
| 698 | static void init_stuff(void) |
| 699 | { |
| 700 | char path[1024]; |
| 701 | |
| 702 | /* Prepare the path XXX XXX XXX */ |
| 703 | /* This must in some way prepare the "path" variable */ |
| 704 | /* so that it points at the "lib" directory. Every */ |
| 705 | /* machine handles this in a different way... */ |
| 706 | my_strcpy(path, "XXX XXX XXX", sizeof(path)); |
| 707 | |
| 708 | /* Prepare the filepaths */ |
| 709 | init_file_paths(path, path, path); |
| 710 | |
| 711 | /* Set up sound hook */ |
| 712 | event_add_handler(EVENT_SOUND, xxx_sound, NULL); |
| 713 | } |
| 714 | |
| 715 | |
| 716 | /** |
| 717 | * Main function |
| 718 | * |
| 719 | * This function must do a lot of stuff. |
| 720 | */ |
| 721 | int main(int argc, char *argv[]) |
| 722 | { |
| 723 | /* Initialize the machine itself XXX XXX XXX */ |
| 724 | |
| 725 | /* Process command line arguments XXX XXX XXX */ |
| 726 | |
| 727 | /* Initialize the windows */ |
| 728 | if (init_xxx(argc, argv) != 0) quit("Oops!"); |
| 729 | |
| 730 | /* XXX XXX XXX */ |
| 731 | ANGBAND_SYS = "xxx"; |
| 732 | |
| 733 | /* Initialize some stuff */ |
| 734 | init_stuff(); |
| 735 | |
| 736 | /* Initialize */ |
| 737 | init_angband(); |
| 738 | |
| 739 | /* Allow auto-startup XXX XXX XXX */ |
| 740 | |
| 741 | /* Event loop forever XXX XXX XXX */ |
| 742 | while (true) CheckEvents(true); |
| 743 | } |
| 744 | |
| 745 | |
| 746 | #endif /* INTERNAL_MAIN */ |
| 747 | |
| 748 | |
| 749 | #endif /* USE_XXX */ |