home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / Epoc / Palmtime / files / FrotzS5_src.ZIP / Frotz.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-10  |  14.9 KB  |  492 lines

  1. /*
  2.  * frotz.h
  3.  *
  4.  * Global declarations and definitions
  5.  *
  6.  */
  7.  
  8. #ifndef _FROTZ_H
  9. #define _FROTZ_H
  10.  
  11. #define TRUE 1
  12. #define FALSE 0
  13.  
  14. typedef unsigned char zbyte;
  15. typedef unsigned short zword;
  16.  
  17. enum story {
  18.     BEYOND_ZORK,
  19.     SHERLOCK,
  20.     ZORK_ZERO,
  21.     SHOGUN,
  22.     ARTHUR,
  23.     JOURNEY,
  24.     LURKING_HORROR,
  25.     UNKNOWN
  26. };
  27.  
  28. typedef unsigned char zchar;
  29.  
  30. /*** Constants that may be set at compile time ***/
  31.  
  32. #ifndef MAX_UNDO_SLOTS
  33. #define MAX_UNDO_SLOTS 2
  34. #endif
  35. #ifndef MAX_FILE_NAME
  36. #define MAX_FILE_NAME 128
  37. #endif
  38. #ifndef TEXT_BUFFER_SIZE
  39. #define TEXT_BUFFER_SIZE 200
  40. #endif
  41. #ifndef INPUT_BUFFER_SIZE
  42. #define INPUT_BUFFER_SIZE 200
  43. #endif
  44. #ifndef STACK_SIZE
  45. #define STACK_SIZE 1024
  46. #endif
  47.  
  48. #ifndef DEFAULT_SAVE_NAME
  49. #define DEFAULT_SAVE_NAME "story.sav"
  50. #endif
  51. #ifndef DEFAULT_SCRIPT_NAME
  52. #define DEFAULT_SCRIPT_NAME "story.scr"
  53. #endif
  54. #ifndef DEFAULT_COMMAND_NAME
  55. #define DEFAULT_COMMAND_NAME "story.rec"
  56. #endif
  57. #ifndef DEFAULT_AUXILARY_NAME
  58. #define DEFAULT_AUXILARY_NAME "story.aux"
  59. #endif
  60.  
  61. /*** Story file header format ***/
  62.  
  63. #define H_VERSION 0
  64. #define H_CONFIG 1
  65. #define H_RELEASE 2
  66. #define H_RESIDENT_SIZE 4
  67. #define H_START_PC 6
  68. #define H_DICTIONARY 8
  69. #define H_OBJECTS 10
  70. #define H_GLOBALS 12
  71. #define H_DYNAMIC_SIZE 14
  72. #define H_FLAGS 16
  73. #define H_SERIAL 18
  74. #define H_ABBREVIATIONS 24
  75. #define H_FILE_SIZE 26
  76. #define H_CHECKSUM 28
  77. #define H_INTERPRETER_NUMBER 30
  78. #define H_INTERPRETER_VERSION 31
  79. #define H_SCREEN_ROWS 32
  80. #define H_SCREEN_COLS 33
  81. #define H_SCREEN_WIDTH 34
  82. #define H_SCREEN_HEIGHT 36
  83. #define H_FONT_HEIGHT 38 /* this is the font width in V5 */
  84. #define H_FONT_WIDTH 39 /* this is the font height in V5 */
  85. #define H_FUNCTIONS_OFFSET 40
  86. #define H_STRINGS_OFFSET 42
  87. #define H_DEFAULT_BACKGROUND 44
  88. #define H_DEFAULT_FOREGROUND 45
  89. #define H_TERMINATING_KEYS 46
  90. #define H_LINE_WIDTH 48
  91. #define H_STANDARD_HIGH 50
  92. #define H_STANDARD_LOW 51
  93. #define H_ALPHABET 52
  94. #define H_EXTENSION_TABLE 54
  95. #define H_USER_NAME 56
  96.  
  97. #define HX_TABLE_SIZE 0
  98. #define HX_MOUSE_X 1
  99. #define HX_MOUSE_Y 2
  100. #define HX_UNICODE_TABLE 3
  101.  
  102. /*** Various Z-machine constants ***/
  103.  
  104. #define V1 1
  105. #define V2 2
  106. #define V3 3
  107. #define V4 4
  108. #define V5 5
  109. #define V6 6
  110. #define V7 7
  111. #define V8 8
  112.  
  113. #define CONFIG_BYTE_SWAPPED 0x01 /* Story file is byte swapped         - V3  */
  114. #define CONFIG_TIME         0x02 /* Status line displays time          - V3  */
  115. #define CONFIG_TWODISKS     0x04 /* Story file occupied two disks      - V3  */
  116. #define CONFIG_TANDY        0x08 /* Tandy licensed game                - V3  */
  117. #define CONFIG_NOSTATUSLINE 0x10 /* Interpr can't support status lines - V3  */
  118. #define CONFIG_SPLITSCREEN  0x20 /* Interpr supports split screen mode - V3  */
  119. #define CONFIG_PROPORTIONAL 0x40 /* Interpr uses proportional font     - V3  */
  120.  
  121. #define CONFIG_COLOUR       0x01 /* Interpr supports colour            - V5+ */
  122. #define CONFIG_PICTURES     0x02 /* Interpr supports pictures          - V6  */
  123. #define CONFIG_BOLDFACE     0x04 /* Interpr supports boldface style    - V4+ */
  124. #define CONFIG_EMPHASIS     0x08 /* Interpr supports emphasis style    - V4+ */
  125. #define CONFIG_FIXED        0x10 /* Interpr supports fixed width style - V4+ */
  126. #define CONFIG_TIMEDINPUT   0x80 /* Interpr supports timed input       - V4+ */
  127.  
  128. #define SCRIPTING_FLAG    0x0001 /* Outputting to transscription file  - V1+ */
  129. #define FIXED_FONT_FLAG   0x0002 /* Use fixed width font               - V3+ */
  130. #define REFRESH_FLAG      0x0004 /* Refresh the screen                 - V6  */
  131. #define GRAPHICS_FLAG     0x0008 /* Game wants to use graphics         - V5+ */
  132. #define OLD_SOUND_FLAG    0x0010 /* Game wants to use sound effects    - V3  */
  133. #define UNDO_FLAG         0x0010 /* Game wants to use UNDO feature     - V5+ */
  134. #define MOUSE_FLAG        0x0020 /* Game wants to use a mouse          - V5+ */
  135. #define COLOUR_FLAG       0x0040 /* Game wants to use colours          - V5+ */
  136. #define SOUND_FLAG        0x0080 /* Game wants to use sound effects    - V5+ */
  137. #define MENU_FLAG         0x0100 /* Game wants to use menus            - V6  */
  138.  
  139. #define INTERP_DEC_20 1
  140. #define INTERP_APPLE_IIE 2
  141. #define INTERP_MACINTOSH 3
  142. #define INTERP_AMIGA 4
  143. #define INTERP_ATARI_ST 5
  144. #define INTERP_MSDOS 6
  145. #define INTERP_CBM_128 7
  146. #define INTERP_CBM_64 8
  147. #define INTERP_APPLE_IIC 9
  148. #define INTERP_APPLE_IIGS 10
  149. #define INTERP_TANDY 11
  150. #define INTERP_PSIONS5 6
  151.  
  152. #define REVERSE_STYLE 1
  153. #define BOLDFACE_STYLE 2
  154. #define EMPHASIS_STYLE 4
  155. #define FIXED_WIDTH_STYLE 8
  156.  
  157. #define TEXT_FONT 1
  158. #define PICTURE_FONT 2
  159. #define GRAPHICS_FONT 3
  160. #define FIXED_WIDTH_FONT 4
  161.  
  162. /*** Constants for os_restart_game */
  163.  
  164. #define RESTART_BEGIN 0
  165. #define RESTART_WPROP_SET 1
  166. #define RESTART_END 2
  167.  
  168. /*** Character codes ***/
  169.  
  170. #define ZC_TIME_OUT 0x00
  171. #define ZC_NEW_STYLE 0x01
  172. #define ZC_NEW_FONT 0x02
  173. #define ZC_BACKSPACE 0x08
  174. #define ZC_INDENT 0x09
  175. #define ZC_GAP 0x0b
  176. #define ZC_RETURN 0x0d
  177. #define ZC_HKEY_RECORD 18
  178. #define ZC_HKEY_PLAYBACK 16
  179. #define ZC_HKEY_UNDO 21
  180. #define ZC_HKEY_RESTART 14
  181. #define ZC_HKEY_QUIT 24
  182. #define ZC_HKEY_DEBUG 4
  183. #define ZC_HKEY_HELP 19
  184. #define ZC_ESCAPE 0x1b
  185. #define ZC_ASCII_MIN 0x20
  186. #define ZC_ASCII_MAX 0x7e
  187. #define ZC_BAD 0x7f
  188. #define ZC_ARROW_MIN 129
  189. #define ZC_ARROW_UP 129
  190. #define ZC_ARROW_DOWN 130
  191. #define ZC_ARROW_LEFT 131
  192. #define ZC_ARROW_RIGHT 132
  193. #define ZC_ARROW_MAX 132
  194. #define ZC_FKEY_MIN 0x85
  195. #define ZC_FKEY_MAX 0x90
  196. #define ZC_NUMPAD_MIN 0x91
  197. #define ZC_NUMPAD_MAX 0x9a
  198. #define ZC_SINGLE_CLICK 0x9b
  199. #define ZC_DOUBLE_CLICK 0x9c
  200. #define ZC_MENU_CLICK 0x9d
  201. #define ZC_LATIN1_MIN 0xa0
  202. #define ZC_LATIN1_MAX 0xff
  203. /*** Key Codes for EPOC Arrow Keys ***/
  204. #define ZC_EPOC_RIGHT 0x1008
  205. #define ZC_EPOC_LEFT 0x1007
  206. #define ZC_EPOC_UP 0x1009
  207. #define ZC_EPOC_DOWN 0x100A
  208.  
  209. /*** File types ***/
  210.  
  211. #define FILE_RESTORE 0
  212. #define FILE_SAVE 1
  213. #define FILE_SCRIPT 2
  214. #define FILE_PLAYBACK 3
  215. #define FILE_RECORD 4
  216. #define FILE_LOAD_AUX 5
  217. #define FILE_SAVE_AUX 6
  218.  
  219. /*** Data access macros ***/
  220.  
  221. #define SET_BYTE(addr,v)  { (g->zmp)[addr] = v; }
  222. #define LOW_BYTE(addr,v)  { v = (g->zmp)[addr]; }
  223. #define CODE_BYTE(v)      { v = *((g->pcp)++); }
  224.  
  225. #define lo(v)   ((zbyte *)&v)[0]
  226. #define hi(v)   ((zbyte *)&v)[1]
  227.  
  228. #define SET_WORD(addr,v)  { (g->zmp)[addr] = hi(v); (g->zmp)[addr+1] = lo(v); }
  229. #define LOW_WORD(addr,v)  { v = ((zword) (g->zmp)[addr] << 8) | (zword)((g->zmp)[addr+1]); }
  230. #define HIGH_WORD(addr,v) { v = ((zword) (g->zmp)[addr] << 8) | (zword)((g->zmp)[addr+1]); }
  231. #define CODE_WORD(v)      { v = ((zword) (g->pcp)[0] << 8) | (zword)((g->pcp)[1]); (g->pcp) += 2; }
  232. #define GET_PC(v)         { v = g->pcp - g->zmp; }
  233. #define SET_PC(v)         { g->pcp = g->zmp + v; }
  234.  
  235. /*** Story file header data ***/
  236.  
  237. /*extern zbyte h_version;
  238. extern zbyte h_config;
  239. extern zword h_release;
  240. extern zword h_resident_size;
  241. extern zword h_start_pc;
  242. extern zword h_dictionary;
  243. extern zword h_objects;
  244. extern zword h_globals;
  245. extern zword h_dynamic_size;
  246. extern zword h_flags;
  247. extern zbyte h_serial[6];
  248. extern zword h_abbreviations;
  249. extern zword h_file_size;
  250. extern zword h_checksum;
  251. extern zbyte h_interpreter_number;
  252. extern zbyte h_interpreter_version;
  253. extern zbyte h_screen_rows;
  254. extern zbyte h_screen_cols;
  255. extern zword h_screen_width;
  256. extern zword h_screen_height;
  257. extern zbyte h_font_height;
  258. extern zbyte h_font_width;
  259. extern zword h_functions_offset;
  260. extern zword h_strings_offset;
  261. extern zbyte h_default_background;
  262. extern zbyte h_default_foreground;
  263. extern zword h_terminating_keys;
  264. extern zword h_line_width;
  265. extern zbyte h_standard_high;
  266. extern zbyte h_standard_low;
  267. extern zword h_alphabet;
  268. extern zword h_extension_table;
  269. extern zbyte h_user_name[8];
  270.  
  271. extern zword hx_table_size;
  272. extern zword hx_mouse_x;
  273. extern zword hx_mouse_y;
  274. extern zword hx_unicode_table;
  275. */
  276. /*** Various data ***/
  277.  
  278. /*extern const char *story_name;
  279.  
  280. extern enum story story_id;
  281. extern long story_size;
  282.  
  283. extern zword stack[STACK_SIZE];
  284. extern zword *sp;
  285. extern zword *fp;
  286.  
  287. extern zword zargs[8];
  288. extern short zargc;
  289.  
  290. extern short ostream_screen;
  291. extern short ostream_script;
  292. extern short ostream_memory;
  293. extern short ostream_record;
  294. extern short istream_replay;
  295. extern short message;
  296.  
  297. extern short cwin;
  298. extern short mwin;
  299.  
  300. extern short mouse_x;
  301. extern short mouse_y;
  302.  
  303. extern short enable_wrapping;
  304. extern short enable_scripting;
  305. extern short enable_scrolling;
  306. extern short enable_buffering;
  307.  
  308. extern short option_attribute_assignment;
  309. extern short option_attribute_testing;
  310. extern short option_object_locating;
  311. extern short option_object_movement;
  312. extern short option_context_lines;
  313. extern short option_left_margin;
  314. extern short option_right_margin;
  315. extern short option_ignore_errors;
  316. extern short option_piracy;
  317. extern short option_undo_slots;
  318. extern short option_expand_abbreviations;
  319. extern short option_script_cols;
  320.  
  321. extern long reserve_mem;
  322. */
  323. /*** Z-machine opcodes ***/
  324.  
  325. void    z_add (struct sg *g);
  326. void    z_and (struct sg *g);
  327. void    z_art_shift (struct sg *g);
  328. void    z_buffer_mode (struct sg *g);
  329. void    z_call_n (struct sg *g);
  330. void    z_call_s (struct sg *g);
  331. void    z_catch (struct sg *g);
  332. void    z_check_arg_count (struct sg *g);
  333. void    z_check_unicode (struct sg *g);
  334. void    z_clear_attr (struct sg *g);
  335. void    z_copy_table (struct sg *g);
  336. void    z_dec (struct sg *g);
  337. void    z_dec_chk (struct sg *g);
  338. void    z_div (struct sg *g);
  339. void    z_draw_picture (struct sg *g);
  340. void    z_encode_text (struct sg *g);
  341. void    z_erase_line (struct sg *g);
  342. void    z_erase_picture (struct sg *g);
  343. void    z_erase_window (struct sg *g);
  344. void    z_get_child (struct sg *g);
  345. void    z_get_cursor (struct sg *g);
  346. void    z_get_next_prop (struct sg *g);
  347. void    z_get_parent (struct sg *g);
  348. void    z_get_prop (struct sg *g);
  349. void    z_get_prop_addr (struct sg *g);
  350. void    z_get_prop_len (struct sg *g);
  351. void    z_get_sibling (struct sg *g);
  352. void    z_get_wind_prop (struct sg *g);
  353. void    z_inc (struct sg *g);
  354. void    z_inc_chk (struct sg *g);
  355. void    z_input_stream (struct sg *g);
  356. void    z_insert_obj (struct sg *g);
  357. void    z_je (struct sg *g);
  358. void    z_jg (struct sg *g);
  359. void    z_jin (struct sg *g);
  360. void    z_jl (struct sg *g);
  361. void    z_jump (struct sg *g);
  362. void    z_jz (struct sg *g);
  363. void    z_load (struct sg *g);
  364. void    z_loadb (struct sg *g);
  365. void    z_loadw (struct sg *g);
  366. void    z_log_shift (struct sg *g);
  367. void    z_make_menu (struct sg *g);
  368. void    z_mod (struct sg *g);
  369. void    z_mouse_window (struct sg *g);
  370. void    z_move_window (struct sg *g);
  371. void    z_mul (struct sg *g);
  372. void    z_new_line (struct sg *g);
  373. void    z_nop (struct sg *g);
  374. void    z_not (struct sg *g);
  375. void    z_or (struct sg *g);
  376. void    z_output_stream (struct sg *g);
  377. void    z_picture_data (struct sg *g);
  378. void    z_picture_table (struct sg *g);
  379. void    z_piracy (struct sg *g);
  380. void    z_pop (struct sg *g);
  381. void    z_pop_stack (struct sg *g);
  382. void    z_print (struct sg *g);
  383. void    z_print_addr (struct sg *g);
  384. void    z_print_char (struct sg *g);
  385. void    z_print_form (struct sg *g);
  386. void    z_print_num (struct sg *g);
  387. void    z_print_obj (struct sg *g);
  388. void    z_print_paddr (struct sg *g);
  389. void    z_print_ret (struct sg *g);
  390. void    z_print_table (struct sg *g);
  391. void    z_print_unicode (struct sg *g);
  392. void    z_pull (struct sg *g);
  393. void    z_push (struct sg *g);
  394. void    z_push_stack (struct sg *g);
  395. void    z_put_prop (struct sg *g);
  396. void    z_put_wind_prop (struct sg *g);
  397. void    z_quit (struct sg *g);
  398. void    z_random (struct sg *g);
  399. void    z_read (struct sg *g);
  400. void    z_read_char (struct sg *g);
  401. void    z_read_mouse (struct sg *g);
  402. void    z_remove_obj (struct sg *g);
  403. void    z_restart (struct sg *g);
  404. void    z_restore (struct sg *g);
  405. void    z_restore_undo (struct sg *g);
  406. void    z_ret (struct sg *g);
  407. void    z_ret_popped (struct sg *g);
  408. void    z_rfalse (struct sg *g);
  409. void    z_rtrue (struct sg *g);
  410. void    z_save (struct sg *g);
  411. void    z_save_undo (struct sg *g);
  412. void    z_scan_table (struct sg *g);
  413. void    z_scroll_window (struct sg *g);
  414. void    z_set_attr (struct sg *g);
  415. void    z_set_font (struct sg *g);
  416. void    z_set_colour (struct sg *g);
  417. void    z_set_cursor (struct sg *g);
  418. void    z_set_margins (struct sg *g);
  419. void    z_set_window (struct sg *g);
  420. void    z_set_text_style (struct sg *g);
  421. void    z_show_status (struct sg *g);
  422. void    z_sound_effect (struct sg *g);
  423. void    z_split_window (struct sg *g);
  424. void    z_store (struct sg *g);
  425. void    z_storeb (struct sg *g);
  426. void    z_storew (struct sg *g);
  427. void    z_sub (struct sg *g);
  428. void    z_test (struct sg *g);
  429. void    z_test_attr (struct sg *g);
  430. void    z_throw (struct sg *g);
  431. void    z_tokenise (struct sg *g);
  432. void    z_verify (struct sg *g);
  433. void    z_window_size (struct sg *g);
  434. void    z_window_style (struct sg *g);
  435.  
  436. /*** Various global functions ***/
  437.  
  438. short   translate_from_zscii (struct sg *g, short);
  439. short   translate_to_zscii (struct sg *g, short);
  440.  
  441. void    flush_buffer (struct sg *g);
  442. void    new_line (struct sg *g);
  443. void    print_char (struct sg *g, zchar);
  444. void    print_num (struct sg *g, zword);
  445. void    print_object (struct sg *g, zword);
  446. void    print_string (struct sg *g, const char *);
  447.  
  448. void    stream_mssg_on (struct sg *g);
  449. void    stream_mssg_off (struct sg *g);
  450.  
  451. void    runtime_error (struct sg *g, const char *);
  452.  
  453. void    ret (struct sg *g, zword);
  454. void    store (struct sg *g, zword);
  455. void    branch (struct sg *g, short);
  456.  
  457. void    storeb (struct sg *g, zword, zbyte);
  458. void    storew (struct sg *g, zword, zword);
  459.  
  460. /*** Interface functions ***/
  461.  
  462. void    os_beep (struct sg *g, short);
  463. void    os_display_char (struct sg *g, zchar);
  464. void    os_display_string (struct sg *g, const zchar *);
  465. void    os_draw_picture (struct sg *g, short, short, short);
  466. void    os_erase_area (struct sg *g, short, short, short, short);
  467. void    os_fatal (struct sg *g, const char *);
  468. void    os_finish_with_sample (struct sg *g);
  469. short   os_font_data (struct sg *g, short, short *, short *);
  470. void    os_init_screen (struct sg *g);
  471. void    os_more_prompt (struct sg *g);
  472. short   os_peek_colour (struct sg *g);
  473. short   os_picture_data (struct sg *g, short, short *, short *);
  474. void    os_prepare_sample (struct sg *g, short);
  475. void    os_process_arguments (struct sg *g, short, char *[]);
  476. short   os_random_seed (struct sg *g);
  477. short   os_read_file_name (struct sg *g, char *, const char *, short);
  478. zchar   os_read_key (struct sg *g, short, short);
  479. zchar   os_read_line (struct sg *g, short, zchar *, short, short, short);
  480. void    os_reset_screen (struct sg *g);
  481. void    os_restart_game (struct sg *g, short);
  482. void    os_scroll_area (struct sg *g, short, short, short, short, short);
  483. void    os_set_colour (struct sg *g, short, short);
  484. void    os_set_cursor (struct sg *g, short, short);
  485. void    os_set_font (struct sg *g, short);
  486. void    os_set_text_style (struct sg *g, short);
  487. void    os_start_sample (struct sg *g, short, short, short);
  488. void    os_stop_sample (struct sg *g);
  489. short   os_string_width (struct sg *g, const zchar *);
  490.  
  491. #endif
  492.