saturnus-host 0.12.1

Host-side pieces shared by the Saturnus emulator's front ends: the emulator with its key queue, command-line typing, hidden Kermit transfers, key layouts and skins, ROM identification
Documentation

saturnus-host

What every front end of Saturnus needs around the emulator core (saturnus-core): the app's WebAssembly bindings, the desktop app and the command-line tool's control API all use it. No bindings, no I/O and no threads: like the core it builds for wasm32-unknown-unknown.

  • protocol: the front ends' command/event protocol and its wall-clock pacing as one state machine, Engine: commands and the host's clock in, replies, events and "call me again at" out, so a host is a thin driver (a Web Worker's timers, a native thread's channel).
  • Emulator: one machine run in emulated milliseconds, with change-detected frame and keys events, and the user memory read from RAM (variables, stack, flags; 48SX, 48GX, 49G). Answers are typed values, serializable to the JSON the front ends use; failures are one Error type.
  • host: the key queue that times presses and types letters in emulated time, so a key is held as long as the calculator needs to see it.
  • typing: typing text into the calculator's command line (insert, run, replace) and reading the line back from RAM.
  • layout and skins: each model's keys in their places and its drawn calculator, as data (serializable for the app).
  • romid: which model a ROM file belongs to, by SHA-256 or by size.

Usage

use saturnus_core::Model;
use saturnus_host::Emulator;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let rom = std::fs::read("sxrom-j")?;
    let mut emu = Emulator::new(Model::Hp48sx, &rom)?;

    // Boot and answer "Try To Recover Memory?" with NO (menu key F)...
    emu.run_ms(3000.0)?;
    emu.type_keys("f");
    while emu.keys_busy() {
        emu.run_slice(10.0, true)?;
    }
    emu.run_ms(2000.0)?;

    // ...then 2 ENTER 3 +, each key held as long as the ROM needs.
    emu.type_keys("2 enter 3 plus");
    while emu.keys_busy() {
        emu.run_slice(10.0, true)?;
    }
    emu.run_ms(500.0)?;

    // The display as text, one character per pixel.
    println!("{}", emu.machine().lcd().to_text());
    Ok(())
}

No ROM is included; see the Saturnus repository for where to get one legitimately.

Licence

MIT. Parts of the code were generated by AI systems under human supervision; see the repository's AI_NOTICE.