summaryrefslogtreecommitdiff
path: root/apps/plugins/frotz/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/frotz/main.c')
-rw-r--r--apps/plugins/frotz/main.c205
1 files changed, 205 insertions, 0 deletions
diff --git a/apps/plugins/frotz/main.c b/apps/plugins/frotz/main.c
new file mode 100644
index 0000000000..22c021bfd1
--- /dev/null
+++ b/apps/plugins/frotz/main.c
@@ -0,0 +1,205 @@
1/* main.c - Frotz V2.40 main function
2 * Copyright (c) 1995-1997 Stefan Jokisch
3 *
4 * Changes for Rockbox copyright 2009 Torne Wuff
5 *
6 * This file is part of Frotz.
7 *
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.
12 *
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.
17 *
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
21 */
22
23/*
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
26 *
27 * s.jokisch@avu.de
28 *
29 */
30
31#include "frotz.h"
32
33#ifndef MSDOS_16BIT
34#define cdecl
35#endif
36
37extern void interpret (void);
38extern void init_memory (void);
39extern void init_undo (void);
40extern void reset_memory (void);
41extern void init_buffer (void);
42extern void init_sound (void);
43extern void init_process (void);
44extern void script_close (void);
45extern void record_close (void);
46extern void replay_close (void);
47
48/* Story file name, id number and size */
49
50const char *story_name = 0;
51
52enum story story_id = UNKNOWN;
53long story_size = 0;
54
55/* Story file header data */
56
57zbyte h_version = 0;
58zbyte h_config = 0;
59zword h_release = 0;
60zword h_resident_size = 0;
61zword h_start_pc = 0;
62zword h_dictionary = 0;
63zword h_objects = 0;
64zword h_globals = 0;
65zword h_dynamic_size = 0;
66zword h_flags = 0;
67zbyte h_serial[6] = { 0, 0, 0, 0, 0, 0 };
68zword h_abbreviations = 0;
69zword h_file_size = 0;
70zword h_checksum = 0;
71zbyte h_interpreter_number = 0;
72zbyte h_interpreter_version = 0;
73zbyte h_screen_rows = 0;
74zbyte h_screen_cols = 0;
75zword h_screen_width = 0;
76zword h_screen_height = 0;
77zbyte h_font_height = 1;
78zbyte h_font_width = 1;
79zword h_functions_offset = 0;
80zword h_strings_offset = 0;
81zbyte h_default_background = 0;
82zbyte h_default_foreground = 0;
83zword h_terminating_keys = 0;
84zword h_line_width = 0;
85zbyte h_standard_high = 1;
86zbyte h_standard_low = 0;
87zword h_alphabet = 0;
88zword h_extension_table = 0;
89zbyte h_user_name[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
90
91zword hx_table_size = 0;
92zword hx_mouse_x = 0;
93zword hx_mouse_y = 0;
94zword hx_unicode_table = 0;
95
96/* Stack data */
97
98zword stack[STACK_SIZE];
99zword *sp = 0;
100zword *fp = 0;
101zword frame_count = 0;
102
103/* IO streams */
104
105bool ostream_screen = TRUE;
106bool ostream_script = FALSE;
107bool ostream_memory = FALSE;
108bool ostream_record = FALSE;
109bool istream_replay = FALSE;
110bool message = FALSE;
111
112/* Current window and mouse data */
113
114int cwin = 0;
115int mwin = 0;
116
117int mouse_y = 0;
118int mouse_x = 0;
119
120/* Window attributes */
121
122bool enable_wrapping = FALSE;
123bool enable_scripting = FALSE;
124bool enable_scrolling = FALSE;
125bool enable_buffering = FALSE;
126
127/* User options */
128
129/*
130int option_attribute_assignment = 0;
131int option_attribute_testing = 0;
132int option_context_lines = 0;
133int option_object_locating = 0;
134int option_object_movement = 0;
135int option_left_margin = 0;
136int option_right_margin = 0;
137int option_ignore_errors = 0;
138int option_piracy = 0;
139int option_undo_slots = MAX_UNDO_SLOTS;
140int option_expand_abbreviations = 0;
141int option_script_cols = 80;
142int option_save_quetzal = 1;
143*/
144
145int option_sound = 1;
146char *option_zcode_path;
147
148
149/*
150 * z_piracy, branch if the story file is a legal copy.
151 *
152 * no zargs used
153 *
154 */
155
156void z_piracy (void)
157{
158
159 branch (!f_setup.piracy);
160
161}/* z_piracy */
162
163/*
164 * main
165 *
166 * Prepare and run the game.
167 *
168 */
169
170int cdecl frotz_main (void)
171{
172
173 os_init_setup ();
174
175 init_buffer ();
176
177 init_err ();
178
179 init_memory ();
180
181 init_process ();
182
183 init_sound ();
184
185 os_init_screen ();
186
187 init_undo ();
188
189 z_restart ();
190
191 interpret ();
192
193 script_close ();
194
195 record_close ();
196
197 replay_close ();
198
199 reset_memory ();
200
201 os_reset_screen ();
202
203 return 0;
204
205}/* main */