1 /* main.c - Frotz V2.40 main function
2 * Copyright (c) 1995-1997 Stefan Jokisch
4 * This file is part of Frotz.
6 * Frotz is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Frotz is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 * This is an interpreter for Infocom V1 to V6 games. It also supports
23 * the recently defined V7 and V8 games. Please report bugs to
35 extern void interpret (void);
36 extern void init_memory (void);
37 extern void init_proc (void);
38 extern void init_sound (void);
39 extern void init_text (void);
40 extern void init_undo (void);
41 extern void reset_memory (void);
43 /* Story file name, id number and size */
47 enum story story_id = UNKNOWN;
50 /* Story file header data */
55 zword h_resident_size = 0;
57 zword h_dictionary = 0;
60 zword h_dynamic_size = 0;
62 zbyte h_serial[6] = { 0, 0, 0, 0, 0, 0 };
63 zword h_abbreviations = 0;
64 zword h_file_size = 0;
66 zbyte h_interpreter_number = 0;
67 zbyte h_interpreter_version = 0;
68 zbyte h_screen_rows = 0;
69 zbyte h_screen_cols = 0;
70 zword h_screen_width = 0;
71 zword h_screen_height = 0;
72 zbyte h_font_height = 1;
73 zbyte h_font_width = 1;
74 zword h_functions_offset = 0;
75 zword h_strings_offset = 0;
76 zbyte h_default_background = 0;
77 zbyte h_default_foreground = 0;
78 zword h_terminating_keys = 0;
79 zword h_line_width = 0;
80 zbyte h_standard_high = 1;
81 zbyte h_standard_low = 1;
83 zword h_extension_table = 0;
84 zbyte h_user_name[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
86 zword hx_table_size = 0;
89 zword hx_unicode_table = 0;
91 zword hx_fore_colour = 0;
92 zword hx_back_colour = 0;
96 zword stack[STACK_SIZE];
99 zword frame_count = 0;
103 bool ostream_screen = TRUE;
104 bool ostream_script = FALSE;
105 bool ostream_memory = FALSE;
106 bool ostream_record = FALSE;
107 bool istream_replay = FALSE;
108 bool message = FALSE;
110 /* Current window and mouse data */
117 int menu_selected = 0;
119 /* Window attributes */
121 bool enable_wrapping = FALSE;
122 bool enable_scripting = TRUE;
123 bool enable_scrolling = FALSE;
124 bool enable_buffering = FALSE;
128 int option_attribute_assignment = 0;
129 int option_attribute_testing = 0;
130 int option_context_lines = 0;
131 int option_object_locating = 0;
132 int option_object_movement = 0;
133 int option_left_margin = 0;
134 int option_right_margin = 0;
135 int option_ignore_errors = 0;
136 int option_piracy = 0;
137 int option_undo_slots = MAX_UNDO_SLOTS;
138 int option_expand_abbreviations = 0;
139 int option_script_cols = 80;
140 int option_save_quetzal = 1;
141 int option_err_report_mode = ERR_DEFAULT_REPORT_MODE;
143 int option_sound = 1;
144 char *option_zcode_path;
147 /* Size of memory to reserve (in bytes) */
149 long reserve_mem = 0;
152 * z_piracy, branch if the story file is a legal copy.
161 branch (!option_piracy);
168 * Prepare and run the game.
173 #include "glkstart.h"
176 static char **myargv;
178 glkunix_argumentlist_t glkunix_arguments[] =
180 { "-a", glkunix_arg_NoValue, "-a: watch attribute setting" },
181 { "-A", glkunix_arg_NoValue, "-A: watch attribute testing" },
182 { "-i", glkunix_arg_NoValue, "-i: ignore fatal errors" },
183 { "-o", glkunix_arg_NoValue, "-o: watch object movement" },
184 { "-O", glkunix_arg_NoValue, "-O: watch object locating" },
185 { "-P", glkunix_arg_NoValue, "-P: alter piracy opcode" },
186 { "-Q", glkunix_arg_NoValue, "-Q: use old-style save format" },
187 { "-t", glkunix_arg_NoValue, "-t: set Tandy bit" },
188 { "-x", glkunix_arg_NoValue, "-x: expand abbreviations g/x/z" },
189 { "-s", glkunix_arg_NumberValue, "-s: random number seed value" },
190 { "-S", glkunix_arg_NumberValue, "-S: transcript width" },
191 { "-u", glkunix_arg_NumberValue, "-u: slots for multiple undo" },
192 { "-Z", glkunix_arg_NumberValue, "-Z: error checking mode" },
193 { "", glkunix_arg_ValueFollows, "filename: The game file to load." },
194 { NULL, glkunix_arg_End, NULL }
197 int glkunix_startup_code(glkunix_startup_t *data)
203 os_process_arguments (myargc, myargv);