zxt:format
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
zxt:format [2021/07/02 18:03] – asie | zxt:format [2021/08/08 09:10] – asie | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== ZXT Extended World Format ====== | + | ====== ZXT Extension |
<WRAP center round important 50%> | <WRAP center round important 50%> | ||
- | This is a draft! | + | This page is for draft work! For the latest official version of the ZXT specification, please |
- | + | ||
- | To discuss | + | |
</ | </ | ||
+ | |||
+ | Version ?.?.? | ||
+ | |||
+ | By Adrian " | ||
+ | |||
+ | Special thanks: endgame, GreaseMonkey, | ||
+ | |||
+ | The specification follows a MAJOR.MINOR.PATCH numbering scheme, where: | ||
+ | |||
+ | * Changes to the MAJOR number are expected to introduce breaking changes, resulting in a change of the extension header magic number; | ||
+ | * Changes to the MINOR number are expected to introduce changes which don't break backwards compatibility, | ||
+ | * Changes to the PATCH number are expected to introduce changes which don't impact the meaning of the specification, | ||
+ | |||
+ | For example, a ZXT 1.1.x world which doesn' | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Over the past thirty years, many ideas have been theorized and approaches tried with regards to extending | + | Extending |
+ | |||
+ | * The lack of source code greatly increased the difficulty of performing non-trivial modifications. | ||
+ | * The requirement for special batch scripts or modified executables, | ||
+ | * No consistent means of signaling required extensions was devised. For most worlds, this made them indistinguishable from ZZT 3.2-compatible ones for the end user or reimplementations, | ||
+ | |||
+ | However, | ||
- | A common format for declaring extensions will allow: | + | The following use cases were considered: |
- | * Creating forks and source ports of ZZT which support | + | * Creating forks and source ports of ZZT which can support |
- | * Mixing and matching extensions | + | * Mixing and matching extensions |
- | * Broader editor support for handling extended worlds. | + | * Usage of extensions within typical ZZT game operations (playing, saving, editing). |
- | The game world types that the ZXT format considers are as follows: | + | The following categories of worlds were considered: |
- | * Creating completely | + | * Completely |
- | * Creating games which can benefit from enhanced functionality, | + | * Creating games which can benefit from enhanced functionality, |
* Standardizing pre-fork games which modify ZZT or Super ZZT in an incompatible way. Example: "ZZT Enhancer", | * Standardizing pre-fork games which modify ZZT or Super ZZT in an incompatible way. Example: "ZZT Enhancer", | ||
- | * Standardizing pre-fork games which modify ZZT or Super ZZT in partially or fully compatible | + | * Standardizing pre-fork games which modify ZZT or Super ZZT in ways which are technically compatible. Example: " |
+ | |||
+ | ===== Coverage ===== | ||
+ | |||
+ | The specification covers: | ||
+ | |||
+ | * The format of extension header data and resulting world files, | ||
+ | * Rules for processing extension data and handling identified edge cases, | ||
+ | * Expectations placed upon game engines implementing the specification. | ||
+ | |||
+ | Notably, the specification currently does **NOT** cover: | ||
+ | |||
+ | * The format of save (.SAV) files. We have decided not to mandate this at this time. | ||
+ | * The format of board (.BRD) files. This is due to the niche nature of the subject, and is likely to be expanded upon in a future version of the specification. | ||
===== Definitions ===== | ===== Definitions ===== | ||
Line 43: | Line 74: | ||
* **plstring** - a Pascal-style long string; a length u16 (N, of range between 0 and 65535) followed by N characters. | * **plstring** - a Pascal-style long string; a length u16 (N, of range between 0 and 65535) followed by N characters. | ||
- | Things marked "// | + | Where the specification |
- | ===== File Types ===== | + | ===== File Format |
+ | |||
+ | ==== Attachment | ||
The extension data can be provided in one of two ways: | The extension data can be provided in one of two ways: | ||
- | * Providing a .ZAX file with the same filename as a world file (for instance, TOWN.ZZT and TOWN.ZAX), containing only the Extension Header. | + | * Providing a .ZAX file with the same filename as a world file (for instance, TOWN.ZZT and TOWN.ZAX) |
- | * Providing a .ZXT file, being formed as a concatenation of an Extension Header and a world file ('' | + | * Providing a .ZXT file, being formed as a concatenation of an Extension Header and a world file ('' |
- | This is done because neither solution is strictly superior: | + | The two approaches are made with specific intents in mind, but may be used in any way the creator sees fit: |
- | * .ZAX files can be used to extend games with additional functionality (keybind shortcuts, metadata, etc.) without | + | * The intent of .ZAX files is to extend games with additional functionality (keybind shortcuts, metadata, etc.), while preserving compatibility with the ZZT game engine. (They can also serve as patches on top of an otherwise unmodified |
- | * A .ZXT file cannot be understood | + | * The intent of .ZXT files is to contain a modified ZZT game within one world file. This is especially useful for games which cannot be supported |
- | * Distributing | + | |
- | ===== Extension Header | + | If a .ZXT file is being loaded, a .ZAX file should be ignored - .ZAX files apply for .ZZT files, not .ZXT files. |
+ | |||
+ | The behaviour of multiple concatenated extension headers contained within one .ZXT or .ZAX file is undefined; distributed .ZXT or .ZAX files MUST NOT rely on it. | ||
+ | |||
+ | ==== Extension Header ==== | ||
The extension header' | The extension header' | ||
^ Offset ^ Type ^ Name ^ Description ^ | ^ Offset ^ Type ^ Name ^ Description ^ | ||
- | | 0 | u16 | magic | 0xF227 for ZZT-style worlds, 0xF527 for Super ZZT-style worlds | | + | | 0 | u16 | magic | 0xF227 for ZZT-style worlds, 0xF527 for Super ZZT-style worlds, 0xB227 for ZZT-style boards, 0xB527 for Super ZZT-style boards. |
| 2 | u32 | block_count | The number of extension blocks which immediately follow. | | | 2 | u32 | block_count | The number of extension blocks which immediately follow. | | ||
Line 70: | Line 106: | ||
^ Offset ^ Type ^ Name ^ Description ^ | ^ Offset ^ Type ^ Name ^ Description ^ | ||
| 0 | u16 | flags | Extension flags; defined below. | | | 0 | u16 | flags | Extension flags; defined below. | | ||
- | | 2 | u32 | owner_id | Extension owner ID | | + | | 2 | u32 | owner_id | Extension owner ID. | |
- | | 6 | u16 | selector_id | Extension selector ID | | + | | 6 | u16 | selector_id | Extension selector ID. | |
- | | 8 | u8 | reserved_0 | Reserved. | | + | | 8 | u8 | reserved_0 | Reserved; must be set to 0. | |
- | | 9 | u16 | field_length | Field length. | + | | 9 | u16 | field_length | Field length. |
| 11 | u8[field_length] | field_data | Field data. Extension-defined. | | | 11 | u8[field_length] | field_data | Field data. Extension-defined. | | ||
Line 88: | Line 124: | ||
| 5 | editing_should | Recommended for editing. | If set, an implementation which does not understand this extension SHOULD signal this to the end user if an attempt at editing the world is made. An engine does not have to make any effort to support such a world further. | Non-format-breaking (format-breaking go into writing_must, | | 5 | editing_should | Recommended for editing. | If set, an implementation which does not understand this extension SHOULD signal this to the end user if an attempt at editing the world is made. An engine does not have to make any effort to support such a world further. | Non-format-breaking (format-breaking go into writing_must, | ||
| 6 | preserve_should | Recommended to preserve on resave. | If set, an implementation SHOULD preserve the extension unchanged upon resave; if cleared, an implementation MUST NOT do so, and MUST discard the extension. | Generally, you want this set to 1 - unless the field data relies on other board, world or extension data outside itself. Meant in particular for metadata. | | | 6 | preserve_should | Recommended to preserve on resave. | If set, an implementation SHOULD preserve the extension unchanged upon resave; if cleared, an implementation MUST NOT do so, and MUST discard the extension. | Generally, you want this set to 1 - unless the field data relies on other board, world or extension data outside itself. Meant in particular for metadata. | | ||
- | | 7 .. 15 | reserved | Reserved. | If set, an implementation MUST NOT continue parsing of the extension block. | | | + | | 7 | vanilla_behavior | Is this extension something ZZT does anyway? | If set, an unmodified implementation of ZZT 3.2 or Super ZZT 2.0 may be assumed to support the '' |
+ | | 8 .. 15 | reserved | Reserved. | If set, an implementation MUST NOT continue parsing of the extension block. | | | ||
- | It is important to note that the flags can be distinct from the ID pair; for instance, the same ZZT-OOP extension can be defined as " | + | It is important to note that the flags can be distinct from the ID pair; for instance, the same ZZT-OOP extension can be defined as " |
- | ===== Interactions between multiple extensions | + | ===== Extension IDs ===== |
- | * **Header/ | + | Extension IDs are allocated on a per-owner ID basis. Within one owner ID, selector |
- | * **Repeated Extensions: | + | |
- | * defining multiple variants of an extension - custom, | + | |
- | * defining multiple flag variants for the extension. For example, a stat limit change extension could set a different mandatory (playing_must) and optional (playing_should) limit. | + | |
- | * //TODO: Should the extension list be enforced as an ordered list? Is there a strong enough use-case?// | + | |
- | Any interactions not listed above are undefined behaviour and MUST NOT be relied upon. Here's an example | + | ==== Owner ID Ranges ==== |
+ | |||
+ | * The range '' | ||
+ | * The range '' | ||
+ | * The range '' | ||
+ | |||
+ | ===== Interactions ===== | ||
+ | |||
+ | ==== Cross-Extension Interactions ==== | ||
+ | |||
+ | * **Extension Order:** Extensions MAY depend on their order of definition in the file. Implementations MUST, as such, preserve the order of extension definition when writing a ZXT file. | ||
+ | * **Repeated Extensions: | ||
+ | |||
+ | Any interactions not explicitly defined and not part of any enabled extension' | ||
* One extension is defined as " | * One extension is defined as " | ||
Line 106: | Line 152: | ||
* It is not certain what should happen if both extensions are in place, unless additional detail is provided. One could interpret it as only allowing the seven vanilla ZZT Keys to be held multiple at a time, or as allowing all sixteen to do so. | * It is not certain what should happen if both extensions are in place, unless additional detail is provided. One could interpret it as only allowing the seven vanilla ZZT Keys to be held multiple at a time, or as allowing all sixteen to do so. | ||
- | ===== Reserved extension owner IDs ==== | + | ==== World Format |
- | * The range '' | + | * **Header/Data Expansion:** If an extension extends the board header, the world header, the tile data, the stat data, or any other existing in-file structure outside of the extension block, the order of parsing MUST be in ascending order of the 32-bit owner ID, then the 16-bit selector ID. |
- | * The range '' | + | * **Incompatible Format Changes:** |
+ | * If any change which sets the reading_must flag to 1 is present, the implementation SHOULD set the world ID to 0xE227. Rare omissions are permitted, if the set of world format changes corresponds 1:1 to another non-standard | ||
+ | * If a ZXT or ZAX file is present, the implementation MUST ignore the world ID present in the file itself, and trust the ZXT/ZAX file instead. | ||
- | ===== Considerations for .ZXT worlds and engines ===== | + | ==== Engine Extension Scope ==== |
- | * An implementation consuming a .ZXT world, or a world with a .ZAX file, MUST NOT be expected to preserve ZZT' | + | * ZXT standard compliance concerns only the game engine' |
- | * If you're relying on out-of-bounds memory writes, consider making an extension standard | + | * An implementation MAY choose to be compatible only with ZXT worlds containing certain extensions. Compatibility with un-extended ZZT worlds |
- | ===== Unfinalized questions | + | ==== Engine Accuracy |
+ | |||
+ | Engines are expected to be accurate to the ZZT game engine' | ||
+ | |||
+ | * Implementations MUST emulate the Black Key. The behaviour, including the gem value change and the message duration, MUST be preserved, although the specific text message emitted MAY be changed. | ||
+ | * Implementations MUST support reading the state of stat -1. While the state of stat -1 in ZZT may change in rare circumstances, | ||
+ | |||
+ | ^ Field ^ Value ^ | ||
+ | | X | 0 | | ||
+ | | Y | 1 | | ||
+ | | Step X | 256 | | ||
+ | | Step Y | 256 | | ||
+ | | Cycle | 256 | | ||
+ | | P1 | 0 | | ||
+ | | P2 | 1 | | ||
+ | | P3 | 0 | | ||
+ | | Follower | 1 | | ||
+ | | Leader | 1 | | ||
+ | | Under | Element 1, Color 0x00 | | ||
+ | | Data Pos | 1 | | ||
+ | | Data Len | 1 | | ||
+ | |||
+ | Note that any feature which crashes regular ZZT (or causes double-frees, | ||
+ | |||
+ | Of course, any of the assumptions in this section can be overridden by an extension. | ||
+ | |||
+ | ===== Best Practices ===== | ||
+ | |||
+ | This is not a formal part of the specification - it's more of an " | ||
+ | |||
+ | ==== World Developers ==== | ||
+ | |||
+ | * Distributing the world as a single .ZXT allows for greater user-friendliness than having to carry around two files, especially for non-ZZT-compatible worlds. | ||
+ | * Once you opt into the .ZXT format, ZZT tricks relying on memory/ | ||
+ | * Most out-of-bounds memory reads and writes, | ||
+ | * The argTile2 trick pioneered in “Wake Up and Unlock The Door". | ||
- | These questions/ | + | ==== Extension Specification Authors ==== |
- | | + | * As soon as your extension |
- | - Should extension definitions allow for the same extension to be present multiple times in the same file? This will complicate implementation, | + | * Use an ID inside |
- | - Should there be any considerations on preserving extension information as part of save files? | + | * Mark your public specification as "Draft" |
- | | + | * If your extension |
- | * Low-memory platforms may be hindered by requiring to load a lot of unnecessary extension data and keep it in memory. (For example, character sets.) | + | |
- | * However, so long as the complete data is unnecessary to play the world, does it really hurt a //save file//? | + | |
- | * Maybe we could allow a save file to be augmented with a .ZXT or .ZAX to restore blocks which are missing? | + | |
- | * This would be best done with a " | + | |
- | * The compromise route, with no clear drawbacks, is to define save file rules as a SHOULD but not a MUST, allowing implementation-specific variants but encouraging a route for typical implementations. | + | |
- | - The use-case of ZAXes was defined as being strictly for worlds whose .ZZT file is compatible with ZZT 3.2. However, zzo38 pointed out that he'd prefer to use ZAXes even for worlds incompatible with ZZT 3.2. Should the ZXT format reserve magic world IDs for this scenario? | + | |
- | * Proposal A: | + | |
- | * Define a world ID (f.e. 0xE227) which means "this world file requires a ZXT header or ZAX file to be correctly parsed", | + | |
- | * Implementations must ignore | + | |
- | * The drawback is that using a valid, but incorrect ZAX will break loading... but a valid, but incorrect ZAX is possible anyway (OOP changes, element changes, etc). | + | |
- | * Proposal B: | + | |
- | * Allow extensions | + | |
- | * Drawback: doesn't handle multiple world format changes | + | |
- | - How should extensions changing the world format (board header, world header, etc.) be handled? | + | |
- | * Proposal A: In order of definition (see "allowing depending on order of placement") | + | |
- | * Proposal B: In ascending order of extension | + | |
- | - Should there be more or fewer restrictions | + | |
- | * The current ones are solely to not force implementations to emulate | + | |
- | ===== Implementations ===== | + | ==== Engine Developers |
- | ==== Final specification ==== | + | * Not every ZXT-compliant engine implementation must provide every extension! Don't fall neck-deep into code bloat, especially on your first try. Focus on the ones you care about, or which games you enjoy utilize. |
+ | * Remember that your save files need to be aware of which extensions ought to be enabled in order to correctly restore a gameplay session. An easy way for this is to do what ZZT itself does, and share the code for creating world files and save files. | ||
- | As the specification has not been finalized, no such implementations exist yet. | + | ===== Side Notes ===== |
- | ==== Draft specification | + | This is not a formal part of the specification |
- | * [[https://github.com/ | + | * I am aware that the "owner/selector ID" system is not ideal. However, other alternatives considered had flaws deemed more important: |
- | * [[http:// | + | * A linear ID allocation system would most likely cause conflicts; |
+ | * A string-based ID system would increase implementation difficult, particularly on older compilers; | ||
+ | * The owner/selector divide was introduced after the decision to faciliate 48-bit IDs on older compilers, particularly Turbo Pascal. While 32-bit IDs were considered, they were rejected as potentially being too constraining. | ||
+ | * Save files are not mandated by the specification for two key reasons: | ||
+ | * Some extensions may require data specific to save files, and implementations may wish to have the freedom to decide how to store them in this case; | ||
+ | * Some implementations may store ZZT data in a custom format internally, and removing this requirement can make their code simpler. | ||
+ | * Multiple concatenated extension headers may be used as a feature in the future - for example, for faciliating multi-patch application for ZZT worlds. | ||
===== Comments ===== | ===== Comments ===== | ||
~~DISCUSSION~~ | ~~DISCUSSION~~ |
zxt/format.txt · Last modified: 2021/08/10 13:00 by asie