Prepare new maemo release
[maemo-rb.git] / apps / plugins / frotz / main.c
blob22c021bfd15dfe088c4278bf19a9d70cba380db7
1 /* main.c - Frotz V2.40 main function
2 * Copyright (c) 1995-1997 Stefan Jokisch
4 * Changes for Rockbox copyright 2009 Torne Wuff
6 * This file is part of Frotz.
8 * Frotz is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Frotz is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
24 * This is an interpreter for Infocom V1 to V6 games. It also supports
25 * the recently defined V7 and V8 games. Please report bugs to
27 * s.jokisch@avu.de
31 #include "frotz.h"
33 #ifndef MSDOS_16BIT
34 #define cdecl
35 #endif
37 extern void interpret (void);
38 extern void init_memory (void);
39 extern void init_undo (void);
40 extern void reset_memory (void);
41 extern void init_buffer (void);
42 extern void init_sound (void);
43 extern void init_process (void);
44 extern void script_close (void);
45 extern void record_close (void);
46 extern void replay_close (void);
48 /* Story file name, id number and size */
50 const char *story_name = 0;
52 enum story story_id = UNKNOWN;
53 long story_size = 0;
55 /* Story file header data */
57 zbyte h_version = 0;
58 zbyte h_config = 0;
59 zword h_release = 0;
60 zword h_resident_size = 0;
61 zword h_start_pc = 0;
62 zword h_dictionary = 0;
63 zword h_objects = 0;
64 zword h_globals = 0;
65 zword h_dynamic_size = 0;
66 zword h_flags = 0;
67 zbyte h_serial[6] = { 0, 0, 0, 0, 0, 0 };
68 zword h_abbreviations = 0;
69 zword h_file_size = 0;
70 zword h_checksum = 0;
71 zbyte h_interpreter_number = 0;
72 zbyte h_interpreter_version = 0;
73 zbyte h_screen_rows = 0;
74 zbyte h_screen_cols = 0;
75 zword h_screen_width = 0;
76 zword h_screen_height = 0;
77 zbyte h_font_height = 1;
78 zbyte h_font_width = 1;
79 zword h_functions_offset = 0;
80 zword h_strings_offset = 0;
81 zbyte h_default_background = 0;
82 zbyte h_default_foreground = 0;
83 zword h_terminating_keys = 0;
84 zword h_line_width = 0;
85 zbyte h_standard_high = 1;
86 zbyte h_standard_low = 0;
87 zword h_alphabet = 0;
88 zword h_extension_table = 0;
89 zbyte h_user_name[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
91 zword hx_table_size = 0;
92 zword hx_mouse_x = 0;
93 zword hx_mouse_y = 0;
94 zword hx_unicode_table = 0;
96 /* Stack data */
98 zword stack[STACK_SIZE];
99 zword *sp = 0;
100 zword *fp = 0;
101 zword frame_count = 0;
103 /* IO streams */
105 bool ostream_screen = TRUE;
106 bool ostream_script = FALSE;
107 bool ostream_memory = FALSE;
108 bool ostream_record = FALSE;
109 bool istream_replay = FALSE;
110 bool message = FALSE;
112 /* Current window and mouse data */
114 int cwin = 0;
115 int mwin = 0;
117 int mouse_y = 0;
118 int mouse_x = 0;
120 /* Window attributes */
122 bool enable_wrapping = FALSE;
123 bool enable_scripting = FALSE;
124 bool enable_scrolling = FALSE;
125 bool enable_buffering = FALSE;
127 /* User options */
130 int option_attribute_assignment = 0;
131 int option_attribute_testing = 0;
132 int option_context_lines = 0;
133 int option_object_locating = 0;
134 int option_object_movement = 0;
135 int option_left_margin = 0;
136 int option_right_margin = 0;
137 int option_ignore_errors = 0;
138 int option_piracy = 0;
139 int option_undo_slots = MAX_UNDO_SLOTS;
140 int option_expand_abbreviations = 0;
141 int option_script_cols = 80;
142 int option_save_quetzal = 1;
145 int option_sound = 1;
146 char *option_zcode_path;
150 * z_piracy, branch if the story file is a legal copy.
152 * no zargs used
156 void z_piracy (void)
159 branch (!f_setup.piracy);
161 }/* z_piracy */
164 * main
166 * Prepare and run the game.
170 int cdecl frotz_main (void)
173 os_init_setup ();
175 init_buffer ();
177 init_err ();
179 init_memory ();
181 init_process ();
183 init_sound ();
185 os_init_screen ();
187 init_undo ();
189 z_restart ();
191 interpret ();
193 script_close ();
195 record_close ();
197 replay_close ();
199 reset_memory ();
201 os_reset_screen ();
203 return 0;
205 }/* main */