The Z-Machine Standards Document
Total Page:16
File Type:pdf, Size:1020Kb
The Z-Machine Standards Document Graham Nelson Version 1.0 22nd June 1997 two misprints corrected, 9th August resources appendix updated and discovery added to header table, 4th September Additional appendices: Quetzal: Z-machine Common Save-File Format Standard Martin Frost Version 1.3b Blorb: An IF Resource Collection Format Standard Andrew Plotkin Version 1.1 Z-Machine Standard 1.1 Proposal Kevin Bracey, Jason C. Penney Draft 7 1 Overview The Z-Machine Standards Document...................................................................................... 1 Quetzal: Z-machine Common Save-File Format Standard....................................................... 127 Blorb: An IF Resource Collection Format Standard ................................................................ 141 Z-Machine Standard 1.1 Proposal ........................................................................................... 157 Index ...................................................................................................................................... 175 Contents The Z-Machine Standards Document...................................................................................... 1 Contents ..............................................................................................................................................2 Preface ................................................................................................................................................4 Overview of Z-machine architecture....................................................................................................8 1. The memory map...........................................................................................................................12 2. Numbers and arithmetic.................................................................................................................15 3. How text and characters are encoded..............................................................................................17 4. How instructions are encoded ........................................................................................................26 5. How routines are encoded..............................................................................................................31 6. The game state: storage and routine calls .......................................................................................32 7. Output streams and file handling....................................................................................................36 8. The screen model...........................................................................................................................40 9. Sound effects.................................................................................................................................54 10. Input streams and devices ............................................................................................................57 11. The format of the header..............................................................................................................61 12. The object table ...........................................................................................................................65 13. The dictionary and lexical analysis...............................................................................................68 14. Complete table of opcodes ...........................................................................................................70 15. Dictionary of opcodes..................................................................................................................79 16. Font 3 and character graphics.....................................................................................................105 Appendix A. Error messages and debugging....................................................................................111 Appendix B. Conventional contents of the header............................................................................112 Appendix C. Resources available.....................................................................................................114 Appendix D. A short history of the Z-machine.................................................................................118 Appendix E. Statistics......................................................................................................................121 Appendix F. Canonical Story Files ..................................................................................................124 Quetzal: Z-machine Common Save-File Format Standard ................................................ 127 1. Conventions................................................................................................................................127 2. Overall structure .........................................................................................................................128 3. Content of dynamic memory .......................................................................................................128 4. Content of stacks ........................................................................................................................129 5. Associated story file....................................................................................................................131 2 6. Miscellaneous.............................................................................................................................132 7. Extensions to the format..............................................................................................................133 8. Introduction to the IFF format.....................................................................................................136 9. Resources available.....................................................................................................................138 10. Credits ......................................................................................................................................139 Blorb: An IF Resource Collection Format Standard .......................................................... 141 0. Overall Structure.........................................................................................................................141 1. Contents of the Resource Index Chunk........................................................................................142 2. Picture Resource Chunks ............................................................................................................142 3. Sound Resource Chunks .............................................................................................................143 4. Executable Resource Chunks ......................................................................................................144 5. The Release Number Chunk........................................................................................................144 6. The Game Identifier Chunk.........................................................................................................145 7. The Color Palette Chunk.............................................................................................................145 8. The Resolution Chunk ................................................................................................................146 9. The Looping Chunk ....................................................................................................................149 10. Other Optional Chunks .............................................................................................................149 11. Z-Machine Compatibility Issues................................................................................................150 12. Glk Compatibility Issues...........................................................................................................151 13. The IFF Format.........................................................................................................................151 14. Other Resource Arrangements...................................................................................................151 15. Rationales and Rationalizations.................................................................................................152 Z-Machine Standard 1.1 Proposal ....................................................................................... 157 1. Introduction.................................................................................................................................157 2. Updates / Clarifications................................................................................................................158 3. Additions.....................................................................................................................................166 Index...................................................................................................................................... 175 3 Preface The Z-machine was created on a coffee table in Pittsburgh in 1979. It is an imaginary computer whose programs are adventure games, and is well-adapted to its task, implementing complex games remarkably compactly. They were still perhaps 100K long, too large for the memory of the home computers of their day, and the Z-machine seems