~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to terps/frotz/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Beucler
  • Date: 2009-09-11 20:09:43 UTC
  • Revision ID: james.westby@ubuntu.com-20090911200943-idgzoyupq6650zpn
Tags: upstream-2009-08-25
ImportĀ upstreamĀ versionĀ 2009-08-25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* main.c - Frotz V2.40 main function
 
2
 *      Copyright (c) 1995-1997 Stefan Jokisch
 
3
 *
 
4
 * This file is part of Frotz.
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
19
 */
 
20
 
 
21
/*
 
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
 
24
 *
 
25
 *    s.jokisch@avu.de
 
26
 *
 
27
 */
 
28
 
 
29
#include "frotz.h"
 
30
 
 
31
#ifndef MSDOS_16BIT
 
32
#define cdecl
 
33
#endif
 
34
 
 
35
extern void interpret (void);
 
36
extern void init_memory (void);
 
37
extern void init_undo (void);
 
38
extern void reset_memory (void);
 
39
 
 
40
/* Story file name, id number and size */
 
41
 
 
42
char *story_name = 0;
 
43
 
 
44
enum story story_id = UNKNOWN;
 
45
long story_size = 0;
 
46
 
 
47
/* Story file header data */
 
48
 
 
49
zbyte h_version = 0;
 
50
zbyte h_config = 0;
 
51
zword h_release = 0;
 
52
zword h_resident_size = 0;
 
53
zword h_start_pc = 0;
 
54
zword h_dictionary = 0;
 
55
zword h_objects = 0;
 
56
zword h_globals = 0;
 
57
zword h_dynamic_size = 0;
 
58
zword h_flags = 0;
 
59
zbyte h_serial[6] = { 0, 0, 0, 0, 0, 0 };
 
60
zword h_abbreviations = 0;
 
61
zword h_file_size = 0;
 
62
zword h_checksum = 0;
 
63
zbyte h_interpreter_number = 0;
 
64
zbyte h_interpreter_version = 0;
 
65
zbyte h_screen_rows = 0;
 
66
zbyte h_screen_cols = 0;
 
67
zword h_screen_width = 0;
 
68
zword h_screen_height = 0;
 
69
zbyte h_font_height = 1;
 
70
zbyte h_font_width = 1;
 
71
zword h_functions_offset = 0;
 
72
zword h_strings_offset = 0;
 
73
zbyte h_default_background = 0;
 
74
zbyte h_default_foreground = 0;
 
75
zword h_terminating_keys = 0;
 
76
zword h_line_width = 0;
 
77
zbyte h_standard_high = 1;
 
78
zbyte h_standard_low = 0;
 
79
zword h_alphabet = 0;
 
80
zword h_extension_table = 0;
 
81
zbyte h_user_name[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 
82
 
 
83
zword hx_table_size = 0;
 
84
zword hx_mouse_x = 0;
 
85
zword hx_mouse_y = 0;
 
86
zword hx_unicode_table = 0;
 
87
 
 
88
/* Stack data */
 
89
 
 
90
zword stack[STACK_SIZE];
 
91
zword *sp = 0;
 
92
zword *fp = 0;
 
93
zword frame_count = 0;
 
94
 
 
95
/* IO streams */
 
96
 
 
97
bool ostream_screen = TRUE;
 
98
bool ostream_script = FALSE;
 
99
bool ostream_memory = FALSE;
 
100
bool ostream_record = FALSE;
 
101
bool istream_replay = FALSE;
 
102
bool message = FALSE;
 
103
 
 
104
/* Current window and mouse data */
 
105
 
 
106
int cwin = 0;
 
107
int mwin = 0;
 
108
 
 
109
int mouse_y = 0;
 
110
int mouse_x = 0;
 
111
 
 
112
/* Window attributes */
 
113
 
 
114
bool enable_wrapping = FALSE;
 
115
bool enable_scripting = TRUE;
 
116
bool enable_scrolling = FALSE;
 
117
bool enable_buffering = FALSE;
 
118
 
 
119
/* User options */
 
120
 
 
121
/*
 
122
int option_attribute_assignment = 0;
 
123
int option_attribute_testing = 0;
 
124
int option_context_lines = 0;
 
125
int option_object_locating = 0;
 
126
int option_object_movement = 0;
 
127
int option_left_margin = 0;
 
128
int option_right_margin = 0;
 
129
int option_ignore_errors = 0;
 
130
int option_piracy = 0;
 
131
int option_undo_slots = MAX_UNDO_SLOTS;
 
132
int option_expand_abbreviations = 0;
 
133
int option_script_cols = 80;
 
134
int option_save_quetzal = 1;
 
135
*/
 
136
 
 
137
int option_sound = 1;
 
138
char *option_zcode_path;
 
139
 
 
140
 
 
141
/* Size of memory to reserve (in bytes) */
 
142
 
 
143
long reserve_mem = 0;
 
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 (!f_setup.piracy);
 
156
 
 
157
}/* z_piracy */
 
158
 
 
159
/*
 
160
 * main
 
161
 *
 
162
 * Prepare and run the game.
 
163
 *
 
164
 */
 
165
 
 
166
#include "glk.h"
 
167
#include "glkstart.h"
 
168
 
 
169
static int myargc;
 
170
static char **myargv;
 
171
 
 
172
glkunix_argumentlist_t glkunix_arguments[] =
 
173
{
 
174
{ "-a", glkunix_arg_NoValue, "-a: watch attribute setting" },
 
175
{ "-A", glkunix_arg_NoValue, "-A: watch attribute testing" },
 
176
{ "-i", glkunix_arg_NoValue, "-i: ignore fatal errors" },
 
177
{ "-o", glkunix_arg_NoValue, "-o: watch object movement" },
 
178
{ "-O", glkunix_arg_NoValue, "-O: watch object locating" },
 
179
{ "-P", glkunix_arg_NoValue, "-P: alter piracy opcode" },
 
180
{ "-Q", glkunix_arg_NoValue, "-Q: use old-style save format" },
 
181
{ "-t", glkunix_arg_NoValue, "-t: set Tandy bit" },
 
182
{ "-x", glkunix_arg_NoValue, "-x: expand abbreviations g/x/z" },
 
183
{ "-I", glkunix_arg_NumberValue, "-I: interpreter number" },
 
184
{ "-s", glkunix_arg_NumberValue, "-s: random number seed value" },
 
185
{ "-S", glkunix_arg_NumberValue, "-S: transcript width" },
 
186
{ "-u", glkunix_arg_NumberValue, "-u: slots for multiple undo" },
 
187
{ "-Z", glkunix_arg_NumberValue, "-Z: error checking mode" },
 
188
{ "", glkunix_arg_ValueFollows, "filename: The game file to load." },
 
189
{ NULL, glkunix_arg_End, NULL }
 
190
};
 
191
 
 
192
int glkunix_startup_code(glkunix_startup_t *data)
 
193
{
 
194
        myargc = data->argc;
 
195
        myargv = data->argv;
 
196
 
 
197
    os_init_setup ();
 
198
    os_process_arguments (myargc, myargv);
 
199
 
 
200
    init_buffer ();
 
201
    init_err ();
 
202
    init_memory ();
 
203
    init_process ();
 
204
    init_sound ();
 
205
 
 
206
    os_init_screen ();
 
207
 
 
208
    init_undo ();
 
209
    z_restart ();
 
210
    return TRUE;
 
211
}
 
212
 
 
213
void glk_main (void)
 
214
{
 
215
    interpret ();
 
216
    reset_memory ();
 
217
}
 
218