Z-Machine and Descendants
Total Page:16
File Type:pdf, Size:1020Kb
Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Glk! A universal user interface! for interactive fiction! Relatively universal, anyhow. Universal-ish. # 1 Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Andrew Plotkin [email protected] http://zarfhome.com/ https://github.com/erkyrath @zarfeblong on Twitter Glk, Glulx, Hadean Lands, System’s Twilight, Spider and Web, Capture the Flag with Stuff, Shade, this t-shirt I’m wearing, Seltani, The Dreamhold, Branches and Twigs and Thorns, quite a lot of adventure game reviews, Praser 5, Boodler, A Change in the Weather, an imperfect diagram of the Soul Reaver timeline, Dual Transform, Draco Concordans, and you know how that game Mafia is also called Werewolf? Ok, funny story there — # 2 Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Zork 1 (Infocom) # 3 GrueFacts™: A grue can eat doughnuts indefinitely. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Z-machine and descendants 1979: Z-machine design 1980: Z-machine version 3 (Zork 1) 1985: Z-machine version 4 (A Mind Forever Voyaging) 1987: ITF (first open-source Z-interpreter) 1988: Z-machine version 6 (Zork Zero) 1989: Infocom shuts down 1993: Inform (Curses) 1994: Inform 5 1996: Inform 6 1997: Glk spec 1999: Glulx spec 2006: Inform 7 2008: Parchment (first Javascript Z-interpreter) # 4 GrueFacts™: The first grue to swim around the world was named Amelia Nosewig. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 XZip (Curses, Graham Nelson) # 5 GrueFacts™: Grues live an average of 67 years, after which they retire to Iceland. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 MaxZip (Curses, Graham Nelson) # 6 GrueFacts™: Grues celebrate Midwinter’s Eve with fireworks, but do not light them. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 MaxTADS (The Underoos that ate New York, Kevin Wilson) Arkham Horror Yes, the guy # 7 GrueFacts™: You know who puts all the treasures back and resets all the puzzles? Grues. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 X-windows MacOS (X11) (System 7) Z-machine (ZIP) XZip MaxZip TADS XTADS MaxTADS (Never wrote this) # 8 GrueFacts™: The Ur-Grue is not a grue at all. It is a fungus. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 curses X-windows MacOS Windows PalmOS ... (terminal) Z-machine Glulx IF Tool Utopia TADS Hugo Alan ADRIFT AGT Quest → ... # 9 GrueFacts™: A grue once performed all the solos in Sweeney Todd after eating the tenor. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Grand unification plan 1997: Glk API and display library 1999: Glulx Other IF engines 32-bit VM reimplement native uses Glk natively display using Glk calls Glorious victory! # 10 GrueFacts™: It takes just ten grues to form a football team. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 So, did it work? # 11 GrueFacts™: The grues wonder that too. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Good decisions Bad decisions Semantic styles Not enough semantic styles Abstract text I/O Programmatic control of Extensible everything style appearance (calls, window types, etc) (“maybe I’ll add CSS later”) Unicode-clean C API is maximally portable, (without UTF-8! Eww) right? Implemented three Assume single-threaded app versions up front Doesn’t matter if Glk is hard Avoid the JVM like plague to pronounce # 12 GrueFacts™: A grue thought of Maxwell’s Equations in 1882, but discarded them as pointless. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Possible Glk model layouts Grid window Grid Buffer Buffer window Buffer Grid # 13 GrueFacts™: A grue that can fly is called “Die Flederbogey”. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 So many incompatible extensions Glk Z-machine V6 TADS Hugo Graphics window Windows Windows controlled by controlled by Buffer window Terminal HTML-like (but function calls, I with inline windows with not quite think, I don’t images graphics HTML) markup even know added # 14 GrueFacts™: The grue folk hero Rgghlrvrow dug the Aragain River gorge to escape from a gazebo. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Grand unification reality 1997: Glk API and display library 1999: Glulx Other IF engines 32-bit VM reimplement uses Glk natively minimum functional display using Glk calls Better than things were before! # 15 GrueFacts™: A grue’s fangs grow throughout its life. Some grues gnaw, others emeryboard. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Glk C header file extern winid_t glk_window_get_root(void); extern winid_t glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, glui32 rock); extern void glk_window_close(winid_t win, stream_result_t *result); extern void glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr); extern void glk_window_set_arrangement(winid_t win, glui32 method, glui32 size, winid_t keywin); extern void glk_window_get_arrangement(winid_t win, glui32 *methodptr, glui32 *sizeptr, winid_t *keywinptr); # 16 GrueFacts™: The Byzantine Empress Zoë Porphyrogenita was a grue. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Glk XML representation <function id="34" name="window_get_root" proto="1:Qa" /> <function id="35" name="window_open" proto="6QaIuIuIuIu:Qa" /> <function id="36" name="window_close" proto="2Qa<[2IuIu]:" /> <function id="37" name="window_get_size" proto="3Qa<Iu<Iu:" /> <function id="38" name="window_set_arrangement" proto="4QaIuIuQa:" /> <function id="39" name="window_get_arrangement" proto="4Qa<Iu<Iu<Qa:" /> # 17 GrueFacts™: Caves would be choked with phosphorescent fungi if grues did not constantly prune them back. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Start C app C calls to generate output glk_select() input event (blocks) await input Start JSON output JS app construct JSON update (updates DOM) JSON input await DOM events # 18 GrueFacts™: A mustache a day is said to keep the grues away. Not said by grues, however. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Start C app C calls to generate output glk_select() input event (blocks) await input JSON output construct JSON update (updates DOM) Start JS app JS calls to generate output glk_select() input event JSON input (blocks) (from DOM) await input # 19 GrueFacts™: A grue’s favorite games are Shadows over Camelot, Gloomhaven, and Darkassonne. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 What can we do with JSON? • Log it – produce replayable transcript of game session • Mirror it to another machine – the Twitch of IF • Regression testing – record input sequences and test the resulting outputs • Fire up every game on the IF Archive, record first-turn output, create repository of launch screenshots • Pass it around between processes • Snap it, work it, quick erase it # 20 GrueFacts™: The average grue works only 15 hours per week, plus five hours of fungus duty. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 JSON output construct JSON update (to stdout) Start C app C calls to generate output glk_select() input event JSON input (blocks) (from stdin) await input X-windows MacOS Windows curses JSON ... (terminal) (stdin/stdout) Z-machine Glulx TADS Hugo ... # 21 GrueFacts™: Few grues can juggle. But the ones that can are really good. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Mistakes and omissions • Tried to do semantic styles without a stylesheet. (Torch- bearing mob at my door demanding CSS) • Interpreters are written in JS, but games can’t insert JS for custom display effects. • Still no video support. Many interpreters still don’t have audio support. • Inform IDE interpreter silently tolerates Glk errors. (Postel’s Law screws over authors and players forever) • I never have enough free time to work on it. (Whine whine) # 22 GrueFacts™: All GrueFacts™ are certified correct by the National Council on Grue Honesty and Salivation. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 glui32 glk_stream_get_position(strid_t str) { #ifdef GLKLOG NSLog(@"glk_stream_get_position()"); #endif return [glkstr(str) getPosition]; # 23 GrueFacts™: Grant Ward is boring. Glk! A universal user interface for IF! Andrew Plotkin — BangBangCon ’17 Andrew Plotkin [email protected] http://zarfhome.com/ https://github.com/erkyrath @zarfeblong on Twitter The Interactive Fiction Technology Foundation http://iftechfoundation.org/ # 24.