From a0b4a1a6107e4dc905b21858d8ac76c47293cfb4 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 21 Feb 2024 12:02:14 +0200 Subject: Add emu --- atk16_emu/cli.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 atk16_emu/cli.py (limited to 'atk16_emu/cli.py') diff --git a/atk16_emu/cli.py b/atk16_emu/cli.py new file mode 100644 index 0000000..dd06f67 --- /dev/null +++ b/atk16_emu/cli.py @@ -0,0 +1,50 @@ +import sys +from dataclasses import dataclass +from emu import Machine + +@dataclass +class Options: + rom_image_path: str | None + debugger_enabled: bool + +options = Options( + rom_image_path=None, + debugger_enabled=False, +) + +def print_help(): + print("Usage: emu_cli.py [-d] [-h|--help] ") + print("") + print("Options:") + print(" : path to the rom image") + print(" -h: print help") + print(" -d: enable debugger") + +for arg in sys.argv[1:]: + if arg == "-d": + options.debugger_enabled = True + elif arg == "-h" or arg == "--help" or arg == "-?": + print_help() + sys.exit(0) + elif arg[0] == "-": + print(f"Unknown option: {arg}") + print_help() + sys.exit(1) + else: + options.rom_image_path = arg + +if options.rom_image_path is None: + print_help() + sys.exit(1) + +def load_rom_image_from_path(path: str) -> bytearray: + with open(path, "rb") as f: + return bytearray(f.read()) + +rom_image = load_rom_image_from_path(options.rom_image_path) + +machine = Machine() +machine.load_rom_image(rom_image) +machine.reset() +machine.run_until_halted() +print(machine.get_system_state()) -- cgit v1.3