1 Git is an interpreter for the Glulx virtual machine. Its homepage is here:
\r
3 http://diden.net/if/git
\r
5 Git's main goal in life is to be fast. It's about five times faster than Glulxe,
\r
6 and about twice as fast as Frotz (using the same Inform source compiled for the
\r
7 Z-machine). It also tries to be reasonably careful with memory: it's possible to
\r
8 trade speed off against memory by changing the sizes of Git's internal buffers.
\r
10 I wrote Git because I want people to be able to write huge games or try out
\r
11 complicated algorithms without worrying about how fast their games are going to
\r
12 run. I want to play City of Secrets on a Palm without having to wait ten seconds
\r
13 between each prompt.
\r
15 Have fun, and let me know what you think!
\r
20 --------------------------------------------------------------------------------
\r
22 * Building and installing Git
\r
24 This is just source code, not a usable application. You'll have to do a bit of
\r
25 work before you can start playing games with it. If you're not confident about
\r
26 compiling stuff yourself, you probably want to wait until somebody uploads a
\r
27 compiled version of Git for your own platform.
\r
29 Git needs to be linked with a Glk library in order to run. This can be easy or
\r
30 hard, depending on what kind of computer you're using and whether you want Git
\r
31 to be able to display graphics and play sounds. To find a suitable Glk library,
\r
34 http://eblong.com/zarf/glk
\r
36 Exactly how you build and link everything depends on what platform you're on and
\r
37 which Glk library you're using. The supplied Makefile should work on any Unix
\r
38 machine (including Macs with OS X), but you'll probably want to tweak it to
\r
39 account for your particular setup. If you're not using Unix, I'm afraid you'll
\r
40 have to play it by ear. If the Glk library you chose comes with instructions,
\r
41 that's probably a good place to start.
\r
43 On Unix, git_unix.c contains the startup code required by the Glk library.
\r
44 git_mac.c and git_windows.c contain startup code for MacGlk and WinGlk
\r
45 respectively, but I can't guarantee that they're fully up-to-date.
\r
47 It should be possible to build Git with any C compiler, but it works best with
\r
48 GCC, because that has a non-standard extension that Git can use for a big speed
\r
49 boost. GCC 2.95 actually generates faster code than GCC 3, so if you have a
\r
50 choice, use the former. (On OS X, this means compiling with 'gcc2'.)
\r
52 --------------------------------------------------------------------------------
\r
56 There are several configuration options you can use when compiling Git. Have a
\r
57 look at config.h and see which ones look applicable to your platform. The
\r
58 Makefile includes settings to configure Git for maximum speed on Mac OS X; the
\r
59 best settings for other Unix platforms should be similar.
\r
61 The most important setting is USE_DIRECT_THREADING, which makes the interpreter
\r
62 engine use GCC's labels-as-values extension, but this only works with GCC 2.95.
\r
64 --------------------------------------------------------------------------------
\r
66 * Porting to a new platform
\r
68 To do a new port, you first need to find a suitable Glk library, or write a new
\r
69 one. Then you need to write the startup code. Start with a copy of git_unix.c,
\r
70 git_mac.c or git_windows.c and modify it appropriately.
\r
72 The startup code needs to implement the following functions:
\r
74 void glk_main() // Standard Glk entrypoint
\r
75 void fatalError(const char* s) // Display error message and quit
\r
77 In glk_main(), you need to locate the game file somehow. Then you have two
\r
78 options. You can open the game as a Glk stream and pass it to this function:
\r
80 extern void gitWithStream (strid_t stream,
\r
81 git_uint32 cacheSize,
\r
82 git_uint32 undoSize);
\r
84 Or you can load the game yourself, and just pass Git a pointer to your buffer:
\r
86 extern void git (const git_uint8 * game,
\r
87 git_uint32 gameSize,
\r
88 git_uint32 cacheSize,
\r
89 git_uint32 undoSize);
\r
91 If the operating system provides some way of memory-mapping files (such as
\r
92 Unix's mmap() system call), you should do that and call git(), because it will
\r
93 allow the game to start up much more quickly. If you can't do memory-mapping,
\r
94 you should just open the game as a file stream and call gitWithStream(). Note
\r
95 that some Glk libraries, such as xglk, aren't compatible with memory-mapped
\r
98 "cacheSize" and "undoSize" tell Git what size to use for its two main internal
\r
99 buffers. Both sizes are in bytes. You may want to make these values
\r
100 user-configurable, or you may just want to pick values that make sense for your
\r
101 platform and use those. (My Unix version currently uses fixed values, but I'm
\r
102 going to add some optional command-line parameters to override these defaults.)
\r
104 "cacheSize" is the size of the buffer used to store Glulx code that Git has
\r
105 recompiled into its internal format. Git will run faster with a larger buffer,
\r
106 but using a huge buffer is just a waste of memory; 256KB is plenty.
\r
108 "undoSize" is the maximum amount of memory used to remember previous moves. The
\r
109 larger you make it, the more levels of undo will be available. The amount of
\r
110 memory required to remember one undo position varies from a few KB up to tens of
\r
111 KB. 256KB is usually enough to store dozens of moves.
\r
113 --------------------------------------------------------------------------------
\r
117 GCC 3 has bigger problems than I thought. On PowerPC, the direct threading
\r
118 option results in much slower code; and on x86, terp.c crashes GCC itself if
\r
119 direct threading is used. Therefore, I recommend that you use GCC 2.95 if
\r
120 possible. If you only have GCC 3, don't define USE_DIRECT_THREADING, at least
\r
121 until the compiler bug is fixed.
\r
123 Since the previous update, GCC 4 has been released, but I haven't evaluated it
\r
124 yet. If you want to give it a try, let me know how you get on!
\r
126 Some Glk libraries, such as xglk, can't deal with memory-mapped files. You can
\r
127 tell that this is happening if Git can open .ulx files, but complains that .blb
\r
128 files are invalid. The solution is to use gitWithStream() rather than git() in
\r
129 your startup file, and make sure you're giving it a file stream rather than a
\r
130 memory stream. If you're using the git_unix.c startup file, just make sure
\r
131 USE_MMAP isn't defined.
\r
133 1-byte and 2-byte local variables are not implemented yet. This means git can't
\r
134 currently play games created with the Superglus system. This will be fixed at
\r
137 In the search opcodes, direct keys don't work unless they're exactly 4 bytes
\r
140 --------------------------------------------------------------------------------
\r
142 * Copyright information
\r
144 Note: previous versions of Git used an informal freeware license, but I've
\r
145 decided it's worth formalising. As of version 1.2.3, I've switched to the
\r
148 Copyright (c) 2003 Iain Merrick
\r
150 Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
151 this software and associated documentation files (the "Software"), to deal in
\r
152 the Software without restriction, including without limitation the rights to
\r
153 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
154 the Software, and to permit persons to whom the Software is furnished to do so,
\r
155 subject to the following conditions:
\r
157 The above copyright notice and this permission notice shall be included in all
\r
158 copies or substantial portions of the Software.
\r
160 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
161 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
162 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
163 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
164 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
165 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
167 --------------------------------------------------------------------------------
\r
171 Andrew Plotkin invented Glulx, so obviously Git wouldn't exist without him. I
\r
172 also reused some code from his Glulxe interpreter (glkop.c and search.c), which
\r
173 saved me a lot of time and let me concentrate on the more interesting stuff.
\r
175 Many thanks are due to John Cater, who not only persuaded me to use source
\r
176 control, but let me use his own CVS server. John also provided lots of useful
\r
177 advice and encouragement, as did Sean Barrett.
\r
179 Thanks also to Joe Mason, Adam Thornton, Simon Baldwin and Joonas Pihlaja who
\r
180 were among the first to try it out and complain that it wasn't working. Joonas
\r
181 also gets special brownie points for trying out more bizarre boundary cases than
\r
182 I realised existed in the first place.
\r
184 Tor Andersson was apparently the first person to use setmemsize, since he also
\r
185 explained why it didn't work and contributed a fix. Thanks, Tor!
\r
187 David Kinder has done a stellar job of maintaining the code recently. Thanks
\r
188 also to Eliuk Blau for tracking down bugs in the memory management opcodes.
\r
190 --------------------------------------------------------------------------------
\r
194 1.2.8 2010-08-25 Fixed a problem with 'undo' when compiled as 64 bit,
\r
195 contributed by Ben Cressey.
\r
196 Fixed a sign problem for the @fceil opcode, following a
\r
197 similar fix in Glulxe.
\r
199 1.2.7 2010-08-20 Floating point opcode support (VM spec 3.1.2).
\r
200 Restart does not now discard undo information, so that a
\r
201 restart can be undone.
\r
203 1.2.6 2010-02-09 Imported fix for retained Glk array handling from Glulxe.
\r
205 1.2.5 2009-11-21 Fixes for problems shown by Andrew Plotkin's glulxercise test
\r
206 cases, from David Kinder.
\r
208 1.2.4 2009-04-02 More David Kinder! Accelerated opcode support (VM spec 3.1.1).
\r
210 1.2.3 2009-02-22 David Kinder and Eliuk Blau fixed some memory management bugs.
\r
211 Added a regression test (thanks to Emily Short for assistance)
\r
212 Switched to MIT-style license (see above).
\r
214 1.2.2 2009-01-21 malloc & mfree contributed by the most excellent David Kinder.
\r
216 1.2.1 2008-09-14 Support for 64-bit machines, contributed by Alexander Beels.
\r
217 Fix for crashing bug in RESTORE, contributed by David Kinder.
\r
218 Non-Unicode display bug fix, contributed by Jeremy Bernstein.
\r
220 1.2 2008-01-06 Minor version increment for VM spec 3.1.
\r
221 Implemented mzero and mcopy, but not malloc and mfree (yet).
\r
223 1.1.3 2006-10-04 Fixed a bug in the cache logic that broke the game Floatpoint.
\r
224 Added some other caching tweaks and put in a few more asserts.
\r
226 1.1.2 2006-08-22 streamnum in filter I/O mode no longer prints a garbage char.
\r
227 Merged in David Kinder's updated Windows startup code.
\r
229 1.1.1 2006-08-17 Wow, over a year since the last update.
\r
230 Rolled in Tor Andersson's fix for setmemsize.
\r
232 1.1 2004-12-22 Minor version increment because we now implement VM spec 3.0.
\r
233 Implemented new Unicode opcodes and string types.
\r
235 1.0.6 2004-12-10 Random number generator now handles random(0) correctly.
\r
236 Code cache now tracks the number of function calls properly.
\r
237 Fixed a bug that could hang the terp when the cache filled up.
\r
239 1.0.5 2004-05-31 Random number generator is now initialised properly.
\r
240 Some source files had Mac line-endings, now fixed.
\r
241 Version number is now set in the Makefile, not in git.h.
\r
242 Merged David Kinder's Windows Git code into main distribution.
\r
244 1.0.4 2004-03-13 Fixed a silly bug in direct threading mode that broke stkroll.
\r
245 Memory access bounds checking has been tightened up slightly.
\r
246 aload and astore now work correctly with negative offsets.
\r
247 Rewrote the shift opcodes a bit more defensively.
\r
248 Implemented the "verify" opcode.
\r
249 Code in RAM is no longer cached by default.
\r
250 Adding some special opcodes to control the code cache.
\r
251 Bad instructions are now caught in the terp, not the compiler.
\r
252 Now passes all of Joonas' indirect string decoding tests.
\r
254 1.0.3 2004-01-22 No longer hangs when using streamnum in the "filter" I/O mode.
\r
255 setstringtbl opcode now works correctly.
\r
257 1.0.2 2003-10-25 Stupid bug in 1.0.1 -- gitWithStream() was broken and wasn't
\r
258 able to load Blorb files. Now it's *really* fixed.
\r
260 1.0.1 2003-10-23 Fixed a bug where strings were printed as "[string]"
\r
261 Fixed a bug in tailcall
\r
262 Implemented setmemsize
\r
263 Implemented protect
\r
264 Moved git_init_dispatch() call out of startup code, into git.c
\r
265 Added divide-by-zero check
\r
266 Compiler now stops when it finds a 'quit' or 'restart'
\r
267 Added gitWithStream() as a workaround for xglk
\r
269 1.0 2003-10-18 First public release
\r