diff options
Diffstat (limited to 'apps/plugins/frotz/main.c')
-rw-r--r-- | apps/plugins/frotz/main.c | 205 |
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 | |||
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); | ||
47 | |||
48 | /* Story file name, id number and size */ | ||
49 | |||
50 | const char *story_name = 0; | ||
51 | |||
52 | enum story story_id = UNKNOWN; | ||
53 | long story_size = 0; | ||
54 | |||
55 | /* Story file header data */ | ||
56 | |||
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 }; | ||
90 | |||
91 | zword hx_table_size = 0; | ||
92 | zword hx_mouse_x = 0; | ||
93 | zword hx_mouse_y = 0; | ||
94 | zword hx_unicode_table = 0; | ||
95 | |||
96 | /* Stack data */ | ||
97 | |||
98 | zword stack[STACK_SIZE]; | ||
99 | zword *sp = 0; | ||
100 | zword *fp = 0; | ||
101 | zword frame_count = 0; | ||
102 | |||
103 | /* IO streams */ | ||
104 | |||
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; | ||
111 | |||
112 | /* Current window and mouse data */ | ||
113 | |||
114 | int cwin = 0; | ||
115 | int mwin = 0; | ||
116 | |||
117 | int mouse_y = 0; | ||
118 | int mouse_x = 0; | ||
119 | |||
120 | /* Window attributes */ | ||
121 | |||
122 | bool enable_wrapping = FALSE; | ||
123 | bool enable_scripting = FALSE; | ||
124 | bool enable_scrolling = FALSE; | ||
125 | bool enable_buffering = FALSE; | ||
126 | |||
127 | /* User options */ | ||
128 | |||
129 | /* | ||
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; | ||
143 | */ | ||
144 | |||
145 | int option_sound = 1; | ||
146 | char *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 | |||
156 | void 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 | |||
170 | int 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 */ | ||