TerminalEmuSuite is a collection of utilities I've made towards or in the process of the goal of accurate VT320 emulation for games:
- VT320Translator, an application to re-encode unrecognized characters in a running program as Dynamically Redefined Character Set glyphs and keep out invalid sequences that get the VT320 stuck, so any modern application that doesn't respect TERM properly can still run on your terminal. I've mostly dogfooded this on codex, with an additional codex plugin included to make the status bar nicer. Also includes a glyph editor in case your rendered glyph doesn't look quite right - the application is bundled with a set of glyphs including some I hand-edited to look best on the real thing.
- Gif320Sharp, an upgrade and conversion of gif320 into C# with additional capabilities and responsiveness. I also include a fork of gif320 that contains only minimal changes to fix bad memory access behavior that prevented it from working on modern machines and to update it to C99.
- (Not yet released) InGameTerminal, for rendering and interacting with highly accurate terminals (focused only on VT320 at the moment) in Unity, with a focus on high accuracy in terms of pill-style line drawing, phosphor fade, serial baud rate emulation, etc. as well as efficiency. Any output that should work on the real thing should work in InGameTerminal, including gif320 output.
Pictured: InGameTerminal with Jetpac loaded as the custom font, the font having been loaded the same way it would have been on the real thing
Architecture:
- At the core of the emulator's usefulness is being able to apply incoming bytes to an emulator state to get a new state, and being able to generate optimized diffs between any two emulator states.
- An updated C# conversion of VTParse is at the core of the VT320 implementation's state transitions, with higher-level state kept in the VT320EmuSharp state container alongside. It's been extensively tested against real hardware, but there are always more edge cases to find. A useful thing here is that you can set up a second serial port to connect to the VT320's printer output and use it in automated test cases to check the output against the expectation.
- The diff generator, which I called "Difference Engine" as a callback to Babbage, compares two states to try to find the most efficient way to get from one to the other, through a series of heuristics such as "it looks like if I cleared the screen and added a line at the top, it would take less bytes than writing spaces everywhere". This is highly important if you want to run certain programs fast (or even tolerably) on real hardware - somewhat understandably, not many TUI authors care about optimizing terminal output byte count anymore. For example, this means that if codex is running in vt320t, it doesn't matter how many spurious commands it sends, since vt320t will take a snapshot of the internal buffer it's keeping, translate it into VT320-suitable state, take another snapshot once the first state is done being sent over to the terminal, and find an optimized diff between those two buffers. The VT320Sharp DifferenceEngine also takes care of "state B has new DRCS glyphs that state A doesn't" by adding the commands to define the DRCS to the diff.
- README's are located in individual repositories with more detail on each, though they are typically mostly generated/reviewed as opposed to this one which is hand-written.
Quick pull/install for VT320Translator:
- git clone --recurse-submodules git@github.com:ldyeax/TerminalEmuSuite.git
- bash install-vt320t-cli.sh
Special thanks to vt100.net - this would have been significantly harder without their extensive documentation and resources.