跟 Z-machine 不同的是,使用 32 位数据和地址,所以可以处理 4G 长的游戏文件,并且原生支持 Glk I/O,可以使用任何 Glk 提供的游戏文件。Glulx 也跟 Z-machine 一样提供使用 Inform 语言编写游戏的功能,可以把 Inform 编写的程序编译成 Glulx 游戏文件。
Glulxe (“Glulx Execute”) 是 Glulx 解析器。
Glulxe 使用 C 语言编写,源代码提供在 GitHub:
https://github.com/erkyrath/glulxe
------------------------------------------------------
Glulxe: the Glulx VM interpreter
- Version 0.6.0
- Designed by Andrew Plotkin erkyrath@eblong.com
- Glulx home page
Compiling
Since this is a Glk program, it must be built with a Glk library. See the Glk home page.
The Unix Makefile that comes with this package is designed to link any of the Unix libraries (CheapGlk, GlkTerm, RemGlk, etc.) You'll have to go into the Makefile and set three variables to find the library. There are instructions at the top of the Makefile. Then just type
make glulxe
That should suffice. When the program is built, type
./glulxe filename.ulx
where "filename.ulx" is a Glulx game file to execute.
To build this program with a Mac or Windows interface, or any other interface, you'll need the appropriate Glk library.
This program supports floating-point operations, which are implemented using the standard C99 math functions. The Makefile uses "-lm" to link these in. If your platform does not support these functions, you can comment out the "#define FLOAT_SUPPORT" line in glulxe.h.
If you define the VM_DEBUGGER symbol (uncomment the "#define VM_DEBUGGER" line in glulxe.h), you must include the libxml2 library. See the XMLLIB definition in the Makefile.
Autosave
This interpreter supports autosave if the Glk library does. Currently only two do: RemGlk and IosGlk. (The latter is no longer supported on modern iOS, so RemGlk is your only real option.)
The --autosave option tells the interpreter to write out autosave files at the end of each turn. The --autorestore tells it to load those files at startup time, thus starting the game where it was last autosaved. Note that --autosave will overwrite the autosave files if present, but you should not use --autorestore unless the files exist.
There are two autosave files, by default kept in the current directory and named "autosave.json" and "autosave.glksave". You can change the directory with --autodir and the base filename with --autoname.
In some contexts it is useful for every game to have a unique autosave location. You can do this by giving an --autoname value with a hash mark, e.g.:
./glulxe --autosave --autoname auto-# filename.ulx
The # character will be replaced with a (long) hex string that uniquely identifies the game file. (Pretty uniquely, at least. It's not a cryptographically strong hash.)
Autosave covers two slightly different scenarios:
Hedging against the possibility of process termination
This was how the iOS interpreters work (worked). The app would start and run normally, but it could be killed at any time (when in the background). Therefore, we autosave every turn. At startup time, if autosave files exist, we restore them and continue play.
To operate in this mode in a Unix environment:
./glulxe --autosave --autoskiparrange filename.ulx
The --autosave argument causes an autosave every turn. The --autoskiparrange argument skips this on Arrange (window resize) events. (We may get several Arrange events in a row, and they don't represent progress that a player would care about losing.)
When relaunching, if autosave files exist, do:
./glulxe --autosave --autoskiparrange --autorestore -autometrics filename.ulx
The --autorestore arguments loads the autosave. The -autometrics argument (a RemGlk argument, hence the single dash) tells RemGlk to skip the step of waiting for an Init event with metrics. (This is not needed because the game will already be in progress. But you can send a normal Arrange event if you think your window size might be different from the autosave state.)
Single-turn operation
This mode allows you to play a game without keeping a long-term process active. On every player input, the interpreter will launch, autorestore, process the input, autosave, and exit.
To operate in this mode in a Unix environment:
./glulxe --autosave -singleturn filename.ulx
The -singleturn argument (a RemGlk argument) tells the interpreter to exit as soon as an output stanza is generated. When you pass in the initial Init event, the interpreter will process the start-of-game activity, display the initial window state, and exit.
When relaunching, if autosave files exist, do:
./glulxe --autosave --autorestore -singleturn -autometrics filename.ulx
You should only do this when the UI has a player input ready to process. Launch the game and pass in the input. The interpreter will process it, display the update, and then (without delay) exit.
from https://github.com/erkyrath/glulxe
------------------------------------------------
Quixe:Glulx VM 解析器 (JavaScript)
Quixe 是纯 JavaScript 编写的 Glulx IF 虚拟机解析器,可以在 Web 浏览器运行所有 Glulx 游戏文件 (.ulx 或者 .gblorb),而且不需要服务器组件,完全依赖于浏览器。
Quixe 当前支持文本缓冲区和网格窗口,字符和线性输入,计时器以及超链接。近期刚刚尝试支持图片。暂时还不支持音频和样式。
用户可以通过 Quixe 保存和恢复游戏,如果用户的浏览器支持 HTML5 本地存储特性,那么可以从一个浏览器会话存储文件到下一个。
Quixe 当前测试通过支持 Safari 4-6, Firefox 3 +, MSIE 7 +, Opera 10 和 Chrome 5 +。当前在 Mobile WebKit (iPhone, iPad 和 Android) 浏览器可用,但是效果并不好。
GitHub 地址:https://github.com/erkyrath/quixe
No comments:
Post a Comment