2 * Copyright 2010-2012 Chris Spiegel.
4 * This file is part of Bocfel.
6 * Bocfel is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version
8 * 2 or 3, as published by the Free Software Foundation.
10 * Bocfel is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Bocfel. If not, see <http://www.gnu.org/licenses/>.
20 #include <libchimara/garglk.h>
22 /* Even on Win32, Gargoyle provides a glkunix startup. */
23 #if defined(ZTERP_UNIX) || defined(GARGLK)
32 glkunix_argumentlist_t glkunix_arguments[] =
34 { "-a", glkunix_arg_NumberValue, "-a N set the size of the evaluation stack" },
35 { "-A", glkunix_arg_NumberValue, "-A N set the size of the call stack" },
36 { "-c", glkunix_arg_NoValue, "-c disable color" },
37 { "-C", glkunix_arg_NoValue, "-C disable the use of a config file" },
38 { "-d", glkunix_arg_NoValue, "-d disable timed input" },
39 { "-D", glkunix_arg_NoValue, "-D disable sound effects" },
40 { "-e", glkunix_arg_NoValue, "-e enable ANSI escapes in the transcript" },
41 { "-E", glkunix_arg_ValueFollows, "-E string set the escape string for -e" },
42 { "-f", glkunix_arg_NoValue, "-f disable fixed-width fonts" },
43 { "-F", glkunix_arg_NoValue, "-F assume font is fixed-width" },
44 { "-g", glkunix_arg_NoValue, "-g disable the character graphics font" },
45 { "-G", glkunix_arg_NoValue, "-G enable alternative box-drawing character graphics" },
46 { "-i", glkunix_arg_NoValue, "-i display the id of the story file and exit" },
47 { "-k", glkunix_arg_NoValue, "-k disable the use of terminating keys (notably used in Beyond Zork)" },
48 { "-l", glkunix_arg_NoValue, "-l disable utf-8 transcripts" },
49 { "-L", glkunix_arg_NoValue, "-L force utf-8 transcrips" },
50 { "-m", glkunix_arg_NoValue, "-m disable meta commands" },
51 { "-n", glkunix_arg_NumberValue, "-n N set the interpreter number (see 11.1.3 in The Z-machine Standards Document 1.0)" },
52 { "-N", glkunix_arg_NumberValue, "-N N set the interpreter version (see 11.1.3.1 in The Z-machine Standards Document 1.0)" },
53 { "-r", glkunix_arg_NoValue, "-r start the story by replaying a command record" },
54 { "-R", glkunix_arg_NoValue, "-R filename set the filename to be used if replaying a command record" },
55 { "-s", glkunix_arg_NoValue, "-s start the story with command recording on" },
56 { "-S", glkunix_arg_NoValue, "-S filename set the filename to be used if command recording is turned on" },
57 { "-t", glkunix_arg_NoValue, "-t start the story with transcripting on" },
58 { "-T", glkunix_arg_ValueFollows, "-T filename set the filename to be used if transcription is turned on" },
59 { "-u", glkunix_arg_NumberValue, "-u N set the maximum number of undo slots" },
60 { "-U", glkunix_arg_NoValue, "-U disable compression in undo slots" },
61 { "-v", glkunix_arg_NoValue, "-v display version information" },
62 { "-x", glkunix_arg_NoValue, "-x disable expansion of abbreviations" },
63 { "-X", glkunix_arg_NoValue, "-X enable tandy censorship" },
64 { "-y", glkunix_arg_NoValue, "-y when opening a transcript, overwrite rather than append to an existing file" },
65 { "-z", glkunix_arg_NumberValue, "-z N set initial random seed" },
66 { "-Z", glkunix_arg_ValueFollows, "-Z device read initial random seed from device" },
67 { "", glkunix_arg_ValueFollows, "filename file to load" },
69 { NULL, glkunix_arg_End, NULL }
73 int glkunix_startup_code(glkunix_startup_t *data)
75 if(!process_arguments(data->argc, data->argv)) return 0;
78 garglk_set_program_name("Bocfel");
81 char *p = strrchr(game_file, '/');
82 garglk_set_story_name(p == NULL ? game_file : p + 1);
88 #elif defined(ZTERP_WIN32)
95 int InitGlk(unsigned int);
98 int WINAPI WinMain(HINSTANCE instance, HINSTANCE previnstance, LPSTR cmdline, int cmdshow)
100 /* This works (with a linker message) under MinGW, but I don’t
101 * know if it’s supposed to; I am unfamiliar with how Windows
102 * handles command-line arguments.
105 extern char **__argv;
107 if(!InitGlk(0x00000700)) exit(EXIT_FAILURE);
109 if(!process_arguments(__argc, __argv)) exit(EXIT_FAILURE);
111 winglk_app_set_name("Bocfel");
119 #error Glk on this platform is not supported.