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