The omr2txt.py tool allows extracting the input event log of an openMSX replay (OMR file) to a plain text format. The txt2omr.py tool performs the opposite operation: it reads an input event log in text format and inserts it into an OMR file.
5
6
Together, these tools can be used to view and edit your event logs in a text editor. They can also be used to filter events and align them to frame boundaries. And you could use them if you want to write your own scripts to generate or optimize event logs.
7
8
Another use for these tools is to be able to generate a version of your speedrun in progress that can be stored in a version control system with human-readable diffs.
9
10
The tools require Python version 3.x.
11
12
13
Limitations
14
-----------
15
16
Currently omr2txt.py will only convert key presses listed in its "inputMap" dictionary. If your game uses keys other than the cursors and space, add the name and the keyboard matrix row/column in this dictionary near the top of the script.
17
18
I wrote these tools when working on my King's Valley TAS, so I could replace the recording of one pyramid's solution without having to re-record all pyramids that come after it. While I did implement some rudimentary error handling, don't expect them to be robust to bad input.
19
20
21
Format
22
------
23
24
Empty lines and lines starting with "#" are ignored.
25
26
Lines starting with "=" are processing instructions:
27
28
= base wsx-kv1.omr
29
= base wsx-kv1.xml
30
Specifies the recording to use as a base when converting back to OMR. The initial snapshot of this recording sets up the MSX machine and the game. Both ".omr" (OMR file, which is gzip-ed XML) and ".xml" (uncompressed XML from OMR file) file name extensions are supported.
31
32
= out kings_valley_mth_v0.omr
33
Pathname of the output file that txt2omr.py will write.
34
35
= scale 57346560
36
Number of master clock ticks per time unit (frame). All following time intervals in the event log will be multiplied by this number.
37
38
= input r key 8 7
39
Defines an input name "r" as a key press of keyboard matrix row 8, column 7. Currently key presses are the only supported types of events.
40
41
= include pyramid01.txt
42
Includes another text file. Can be used to store the input events for every level in a separate file, for example.
43
44
All other lines are event log entries. Log entries are whitespace-separated lists, where the first element is a time interval length and the following elements are the input events that are active during that interval.
45
46
For example:
47
2 r
48
1 r s
49
24
50
This will press the "r" input, as defined earlier with a "=input" processing instruction, for two frames. Then it will hold "r" pressed while also pressing the "s" input for one frame. Finally it will release both inputs and wait for 24 frames.