home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / Epoc / Palmtime / files / FrotzCE2_src.ZIP / FrotzCE / MAIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-09  |  5.3 KB  |  296 lines

  1. /*
  2.  * main.c
  3.  *
  4.  * Frotz V2.22 main function
  5.  *
  6.  * This is an interpreter for Infocom V1 to V6 games. It also supports
  7.  * the recently defined V7 and V8 games. Please report bugs to
  8.  *
  9.  *    jokisch@ls7.informatik.uni-dortmund.de
  10.  *
  11.  * Frotz is freeware. It may be used and distributed freely provided
  12.  * no commercial profit is involved. (c) 1995-1997 Stefan Jokisch
  13.  *
  14.  */
  15.  
  16. #ifndef _WIN32_WCE
  17. #include "frotz.h"
  18. #else
  19. #include "Frotz\Frotz.h"
  20. #endif
  21.  
  22. #include "string.h"
  23.  
  24. #ifndef __MSDOS__
  25. #define cdecl
  26. #endif
  27.  
  28. /* Story file name and size */
  29.  
  30. char *story_name = 0;
  31. long story_size = 0;
  32.  
  33. /* Auto-detection for a few buggy story files */
  34.  
  35. int story_id = 0;
  36.  
  37. /* Story file header data */
  38.  
  39. zbyte h_version = 0;
  40. zbyte h_config = 0;
  41. zword h_release = 0;
  42. zword h_resident_size = 0;
  43. zword h_start_pc = 0;
  44. zword h_dictionary = 0;
  45. zword h_objects = 0;
  46. zword h_globals = 0;
  47. zword h_dynamic_size = 0;
  48. zword h_flags = 0;
  49. zbyte h_serial[6] = { 0, 0, 0, 0, 0, 0 };
  50. zword h_abbreviations = 0;
  51. zword h_file_size = 0;
  52. zword h_checksum = 0;
  53. zbyte h_interpreter_number = 0;
  54. zbyte h_interpreter_version = 0;
  55. zbyte h_screen_rows = 0;
  56. zbyte h_screen_cols = 0;
  57. zword h_screen_width = 0;
  58. zword h_screen_height = 0;
  59. zbyte h_font_height = 1;
  60. zbyte h_font_width = 1;
  61. zword h_functions_offset = 0;
  62. zword h_strings_offset = 0;
  63. zbyte h_default_background = 0;
  64. zbyte h_default_foreground = 0;
  65. zword h_terminating_keys = 0;
  66. zword h_line_width = 0;
  67. zbyte h_standard_high = 0;
  68. zbyte h_standard_low = 2;
  69. zword h_alphabet = 0;
  70. zword h_mouse_table = 0;
  71. zbyte h_user_name[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
  72.  
  73. /* Stack data */
  74.  
  75. zword stack[STACK_SIZE];
  76. zword *sp = 0;
  77. zword *fp = 0;
  78.  
  79. /* IO streams */
  80.  
  81. int ostream_screen = 1;
  82. int ostream_script = 0;
  83. int ostream_memory = 0;
  84. int ostream_record = 0;
  85.  
  86. int istream_replay = 0;
  87.  
  88. /* Current and mouse window */
  89.  
  90. int cwin = 0;
  91. int mwin = 0;
  92.  
  93. /* Mouse data */
  94.  
  95. int mouse_y = 0;
  96. int mouse_x = 0;
  97.  
  98. /* Window attributes */
  99.  
  100. int enable_wrapping = 0;
  101. int enable_scripting = 0;
  102. int enable_scrolling = 0;
  103. int enable_buffering = 0;
  104.  
  105. /* Flag used to fix a problem in The Lurking Horror */
  106.  
  107. int pause_flag = 0;
  108.  
  109. /* User options */
  110.  
  111. int option_attribute_assignment = 0;
  112. int option_attribute_testing = 0;
  113. int option_context_lines = 0;
  114. int option_object_locating = 0;
  115. int option_object_movement = 0;
  116. int option_left_margin = 0;
  117. int option_right_margin = 0;
  118. int option_ignore_errors = 1;
  119. int option_piracy = 0;
  120. int option_undo_slots = MAX_UNDO_SLOTS;
  121. int option_expand_abbreviations = 0;
  122. int option_script_cols = 80;
  123.  
  124. /* Size of memory to reserve (in bytes) */
  125.  
  126. long reserve_mem = 0;
  127.  
  128. /*
  129.  * runtime_error
  130.  *
  131.  * An error has occured. Ignore it or pass it to os_fatal.
  132.  *
  133.  */
  134.  
  135. void runtime_error (const char *s)
  136. {
  137.  
  138.     flush_buffer ();
  139.  
  140.     if (!option_ignore_errors)
  141.     os_fatal (s);
  142.  
  143. }/* runtime_error */
  144.  
  145. /*
  146.  * z_piracy, branch if the story file is a legal copy.
  147.  *
  148.  *    no zargs used
  149.  *
  150.  */
  151.  
  152. void z_piracy (void)
  153. {
  154.  
  155.     branch (!option_piracy);
  156.  
  157. }/* z_piracy */
  158.  
  159. #ifndef _WIN32_WCE
  160.  
  161. /*
  162.  * main
  163.  *
  164.  * Prepare and run the game.
  165.  *
  166.  */
  167.  
  168. int cdecl main (int argc, char *argv[])
  169. {
  170.  
  171.     os_process_arguments (argc, argv);
  172.  
  173.     init_memory ();
  174.  
  175.     os_init_screen ();
  176.  
  177.     init_undo ();
  178.  
  179.     z_restart ();
  180.  
  181.     interpret ();
  182.  
  183.     reset_memory ();
  184.  
  185.     os_reset_screen ();
  186.  
  187.     return 0;
  188.  
  189. }/* main */
  190.  
  191. #else
  192.  
  193. int FrotzGlobalInit()
  194. {
  195.     story_name = 0;
  196.     story_size = 0;
  197.  
  198.     /* Auto-detection for a few buggy story files */
  199.  
  200.     story_id = 0;
  201.  
  202.     /* Story file header data */
  203.  
  204.     h_version = 0;
  205.     h_config = 0;
  206.     h_release = 0;
  207.     h_resident_size = 0;
  208.     h_start_pc = 0;
  209.     h_dictionary = 0;
  210.     h_objects = 0;
  211.     h_globals = 0;
  212.     h_dynamic_size = 0;
  213.     h_flags = 0;
  214.     memset( h_serial, 0, sizeof( h_serial ) );
  215.     h_abbreviations = 0;
  216.     h_file_size = 0;
  217.     h_checksum = 0;
  218.     h_interpreter_number = 0;
  219.     h_interpreter_version = 0;
  220.     h_screen_rows = 0;
  221.     h_screen_cols = 0;
  222.     h_screen_width = 0;
  223.     h_screen_height = 0;
  224.     h_font_height = 1;
  225.     h_font_width = 1;
  226.     h_functions_offset = 0;
  227.     h_strings_offset = 0;
  228.     h_default_background = 0;
  229.     h_default_foreground = 0;
  230.     h_terminating_keys = 0;
  231.     h_line_width = 0;
  232.     h_standard_high = 0;
  233.     h_standard_low = 2;
  234.     h_alphabet = 0;
  235.     h_mouse_table = 0;
  236.     memset( h_user_name, 0, 8 );
  237.  
  238.     /* Stack data */
  239.  
  240.     memset( stack, 0, sizeof( stack ) );
  241.     sp = 0;
  242.     fp = 0;
  243.  
  244.     /* IO streams */
  245.  
  246.     ostream_screen = 1;
  247.     ostream_script = 0;
  248.     ostream_memory = 0;
  249.     ostream_record = 0;
  250.  
  251.     istream_replay = 0;
  252.  
  253.     /* Current and mouse window */
  254.  
  255.     cwin = 0;
  256.     mwin = 0;
  257.  
  258.     /* Mouse data */
  259.  
  260.     mouse_y = 0;
  261.     mouse_x = 0;
  262.  
  263.     /* Window attributes */
  264.  
  265.     enable_wrapping = 0;
  266.     enable_scripting = 0;
  267.     enable_scrolling = 0;
  268.     enable_buffering = 0;
  269.  
  270.     /* Flag used to fix a problem in The Lurking Horror */
  271.  
  272.     pause_flag = 0;
  273.  
  274.     /* User options */
  275.  
  276.     option_attribute_assignment = 0;
  277.     option_attribute_testing = 0;
  278.     option_context_lines = 0;
  279.     option_object_locating = 0;
  280.     option_object_movement = 0;
  281.     option_left_margin = 0;
  282.     option_right_margin = 0;
  283.     option_ignore_errors = 1;
  284.     option_piracy = 0;
  285.     option_undo_slots = MAX_UNDO_SLOTS;
  286.     option_expand_abbreviations = 0;
  287.     option_script_cols = 80;
  288.  
  289.     /* Size of memory to reserve (in bytes) */
  290.  
  291.     reserve_mem = 0;
  292.  
  293.     return 0;
  294. }
  295.  
  296. #endif