• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

MakefileH A D03-May-20223.3 KiB11830

PREFSH A D13-Apr-200011.5 KiB347253

READMEH A D11-Jul-20009.5 KiB257193

TODOH A D20-Nov-19991.7 KiB5434

gi_blorb.cH A D26-Mar-200016.3 KiB604428

gi_blorb.hH A D26-Mar-20003.4 KiB8949

gi_dispa.cH A D11-Jul-200036.1 KiB952911

gi_dispa.hH A D11-Jul-20003.3 KiB8948

glk.hH A D11-Jul-200011.1 KiB316244

glkstart.cH A D11-Jul-2000694 259

glkstart.hH A D11-Jul-20001.5 KiB5831

greypm.bmH A D06-Jun-1999281 76

main.cH A D06-Jun-1999684 3930

xg_event.cH A D06-Jun-1999860 4327

xg_fileref.cH A D29-Aug-19998 KiB382286

xg_gestalt.cH A D11-Jul-20002.2 KiB11698

xg_internal.hH A D13-Apr-20004.4 KiB170115

xg_misc.cH A D06-Jun-19994.4 KiB198167

xg_schan.cH A D21-Jul-19991.2 KiB6247

xg_stream.cH A D13-Apr-200014.4 KiB742625

xg_style.cH A D13-Apr-200011.4 KiB457373

xg_win_graphics.cH A D06-Jun-19997.6 KiB351283

xg_win_graphics.hH A D06-Jun-19991.2 KiB2421

xg_win_textbuf.cH A D15-Apr-200075.7 KiB2,7542,311

xg_win_textbuf.hH A D06-Jun-19993 KiB5548

xg_win_textgrid.cH A D15-Apr-200041 KiB1,6431,344

xg_win_textgrid.hH A D06-Jun-19991.9 KiB3732

xg_window.cH A D13-Apr-200037.7 KiB1,7481,468

xglk.cH A D13-Apr-200012.6 KiB497391

xglk.hH A D11-Jul-20008.2 KiB281244

xglk_init.cH A D29-Aug-19992.1 KiB9177

xglk_key.cH A D29-Aug-199917.3 KiB740630

xglk_loop.cH A D06-Jun-19996.6 KiB285222

xglk_mono_patchH A D06-Jun-19996 KiB233211

xglk_msg.cH A D13-Apr-20005 KiB273226

xglk_option.hH A D06-Jun-1999559 204

xglk_pict.cH A D03-May-202222.8 KiB1,004832

xglk_prefs.cH A D14-Apr-200017.6 KiB664592

xglk_res.cH A D24-Aug-19991.2 KiB6849

xglk_scrap.cH A D06-Jun-19991.9 KiB10285

xglk_vars.cH A D06-Jun-1999442 2419

xglk_weggie.cH A D06-Jun-19994.8 KiB177153

README

1XGlk: X Windows Implementation of the Glk API.
2
3XGlk Library: version 0.4.11
4Glk API which this implements: version 0.6.1.
5Designed by Andrew Plotkin <erkyrath@eblong.com>
6http://www.eblong.com/zarf/glk/index.html
7
8This is source code for an implementation of the Glk library which runs
9under X windows.
10
11* Command-line arguments and X resources:
12
13XGlk can accept command-line arguments both for itself and on behalf
14of the underlying program. The ones it accepts for itself are taken
15both from X resources and from command-line options. See the PREFS
16file for complete information.
17
18* Bugs:
19
20Image display is experimental (read: "probably not broken, but I'm not
21guaranteeing anything".)
22
23Images only display on displays with 32 bits per pixel, 24, 16, 8, or
241 (monochrome.) On other displays, images just won't display. Nothing
25will appear at all, and glk_image_draw() will return false.
26
27(Note: "16" actually includes 15 bits per pixels (5 per color
28component), as well as the extremely weird NeXT color display, which
29has 12 bpp.)
30
31I've tested images on displays with all the above depths. However, I
32haven't tried a very wide range, nor have I tested each depth with
33both endiannesses. I would not be surprised to learn that it fails on
34some systems. If you see images displaying badly or not at all,
35please do "setenv XGLK_DEBUG", run the program again, and email me
36with (1) the command-line output, (2) your machine type and OS, (3)
37what you saw. Thanks.
38
39On 8-bit paletted displays, XGlk tries to allocate a 6x6x6 color cube
40(the Palette of the Beast), plus assorted text and border colors. If it
41can't get all of these, the display goes badly wrong.
42
43* Notes on building this mess:
44
45This is set up for a fairly generic ANSI C compiler. If you get it to
46compile under some particular system, please send me mail, and I'll
47stick in the relevant #ifdefs and whatnot.
48
49If your compiler can't find X11 headers or libraries, change the
50definitions of XLIB and XINCLUDE in the Makefile. There are some
51sample values there. If you find other values that work on particular
52operating systems, send me email.
53
54If your compiler can't find PNG headers or libraries, change the
55definitions of PNGLIB and PNGINCLUDE. If you don't have pnglib
56installed on your system at all, uncomment the definition of
57-DNO_PNG_AVAILABLE. I am told that pnglib version 0.96 is too old to
58work with XGlk. I've tested it with pnglib 1.0.1 and 1.0.3, both of
59which are fine.
60
61If your compiler can't find JPEG headers or libraries, change the
62definitions of JPEGLIB and JPEGINCLUDE. If you don't have libjpeg
63installed on your system at all, uncomment the definition of
64-DNO_JPEG_AVAILABLE.
65
66If you get errors in xio.c about fd_set or FD_SET being undefined, put
67"-DNEEDS_SELECT_H" in the SYSTEMFLAGS line, as has been done for the
68RS6000.
69
70There are a few compile-time options. These are defined in xglk_option.h.
71Before you compile, you should go into xglk_option.h and make any changes
72necessary. You may also need to edit some include and library paths in
73the Makefile.
74
75See the top of the Makefile for comments on installation.
76
77When you compile a Glk program and link it with GlkTerm, you must supply
78one more file: you must define a function called glkunix_startup_code(),
79and an array glkunix_arguments[]. These set up various Unix-specific
80options used by the Glk library. There is a sample "glkstart.c" file
81included in this package; you should modify it to your needs.
82
83The glkunix_arguments[] array is a list of command-line arguments that
84your program can accept. The library will sort these out of the command
85line and pass them on to your code. The array structure looks like this:
86
87typedef struct glkunix_argumentlist_struct {
88    char *name;
89    int argtype;
90    char *desc;
91} glkunix_argumentlist_t;
92
93extern glkunix_argumentlist_t glkunix_arguments[];
94
95In each entry, name is the option as it would appear on the command line
96(including the leading dash, if any.) The desc is a description of the
97argument; this is used when the library is printing a list of options.
98And argtype is one of the following constants:
99
100    glkunix_arg_NoValue: The argument appears by itself.
101    glkunix_arg_ValueFollows: The argument must be followed by another
102argument (the value).
103    glkunix_arg_ValueCanFollow: The argument may be followed by a value,
104optionally. (If the next argument starts with a dash, it is taken to be
105a new argument, not the value of this one.)
106    glkunix_arg_NumberValue: The argument must be followed by a number,
107which may be the next argument or part of this one. (That is, either
108"-width 20" or "-width20" will be accepted.)
109    glkunix_arg_End: The glkunix_arguments[] array must be terminated
110with an entry containing this value.
111
112To accept arbitrary arguments which lack dashes, specify a name of ""
113and an argtype of glkunix_arg_ValueFollows.
114
115If you don't care about command-line arguments, you must still define an
116empty arguments list, as follows:
117
118glkunix_argumentlist_t glkunix_arguments[] = {
119    { NULL, glkunix_arg_End, NULL }
120};
121
122Here is a more complete sample list:
123
124glkunix_argumentlist_t glkunix_arguments[] = {
125    { "", glkunix_arg_ValueFollows, "filename: The game file to load."
126},
127    { "-hum", glkunix_arg_ValueFollows, "-hum NUM: Hum some NUM." },
128    { "-bom", glkunix_arg_ValueCanFollow, "-bom [ NUM ]: Do a bom (on
129the NUM, if given)." },
130    { "-goo", glkunix_arg_NoValue, "-goo: Find goo." },
131    { "-wob", glkunix_arg_NumberValue, "-wob NUM: Wob NUM times." },
132    { NULL, glkunix_arg_End, NULL }
133};
134
135This would match the arguments "thingfile -goo -wob8 -bom -hum song".
136
137After the library parses the command line, it does various occult
138rituals of initialization, and then calls glkunix_startup_code().
139
140int glkunix_startup_code(glkunix_startup_t *data);
141
142This should return TRUE if everything initializes properly. If it
143returns FALSE, the library will shut down without ever calling your
144glk_main() function.
145
146The data structure looks like this:
147
148typedef struct glkunix_startup_struct {
149    int argc;
150    char **argv;
151} glkunix_startup_t;
152
153The fields are a standard Unix (argc, argv) list, which contain the
154arguments you requested from the command line. In deference to custom,
155argv[0] is always the program name.
156
157You can put other startup code in glkunix_startup_code(). This should
158generally be limited to finding and opening data files. There are a few
159Unix Glk library functions which are convenient for this purpose:
160
161strid_t glkunix_stream_open_pathname(char *pathname, glui32 textmode,
162    glui32 rock);
163
164This opens an arbitrary file, in read-only mode. Note that this function
165is *only* available during glkunix_startup_code(). It is inherent
166non-portable; it should not and cannot be called from inside glk_main().
167
168void glkunix_set_base_file(char *filename);
169
170This sets the library's idea of the "current directory" for the executing
171program. The argument should be the name of a file (not a directory).
172When this is set, fileref_create_by_name() will create files in the same
173directory as that file, and create_by_prompt() will base default filenames
174off of the file. If this is not called, the library works in the Unix
175current working directory, and picks reasonable default defaults.
176
177* Notes on the source code:
178
179Functions which begin with glk_ are, of course, Glk API functions. These
180are declared in glk.h.
181
182Functions which begin with gli_, xglk_, and other prefixes are
183internal to the XGlk library implementation. They don't exist in every
184Glk library, because different libraries implement things in different
185ways. (In fact, they may be declared differently, or have different
186meanings, in different Glk libraries.) These gli_ functions (and other
187internal constants and structures) are declared in xg_internal.h and
188xglk.h.
189
190As you can see from the code, I've kept a policy of catching every error
191that I can possibly catch, and printing visible warnings.
192
193Thanks to Torbjorn Andersson for monochrome display patches.
194
195* Permissions
196
197The source code in this package is copyright 1998-9 by Andrew Plotkin. You
198may copy and distribute it freely, by any means and under any conditions,
199as long as the code and documentation is not changed. You may also
200incorporate this code into your own program and distribute that, or modify
201this code and use and distribute the modified version, as long as you retain
202a notice in your program or documentation which mentions my name and the
203URL shown above.
204
205* Version history:
206
2070.4.11:
208    Upgraded to Glk API version 0.6.1; i.e., a couple of new gestalt
209    selectors.
210    Fixed dispatch bug for glk_get_char_stream.
211
2120.4.10:
213    Fixed a couple of display bugs (one that could cause freezes)
214
2150.4.9:
216    Added hyperlink code, and other changes for Glk 0.6.0.
217    Improved mouse-clicking code for textgrids.
218
2190.4.8:
220    Changed the default save game name to "game.sav".
221    Added "-defprompt" switch, to suppress default file names.
222    Added glkunix_set_base_file().
223    Added support for function keys.
224
2250.4.7:
226    Fixed a small bug in image code, sometimes prevented JPEGs from loading.
227
2280.4.6:
229    Fixed various problems with Blorb support.
230
2310.4.5:
232    Added JPEG image support.
233
2340.4.4:
235    Updated for Glk API 0.5.2; that is, added sound channel stubs.
236    Made the license a bit friendlier.
237
2380.4.3, 0.4.2:
239    Image display slowly nears acceptable functionality.
240
2410.4.1:
242    Fixed display of images on 8-bit displays. Also added a -ditherimage
243switch and resource (default is "true")
244    Fixed text flowing around margin images.
245
2460.4:
247    Updated for Glk API 0.5.1.
248
2490.3:
250    Updated for Glk API 0.5.
251
2520.2:
253    The one true Unix Glk Makefile system.
254    Startup code and command-line argument system.
255
2560.1 alpha: initial release.
257