ZXSpectrum
ZXSpectrum(zx: DotNetZXSpectrum | None = None, emulator_type: EmulatorType | None = None, screen_type: ScreenType | None = None)A 48K ZX Spectrum with access to its CPU, keyboard, memory and screen.
With no arguments, creates a fast emulator and fast screen. Set emulator_type or screen_type to choose another implementation. The zx argument wraps an existing .NET emulator and cannot be combined with those options.
Properties
cpu
cpu: Z80The machine CPU and its registers.
keyboard
keyboard: KeyboardThe machine keyboard.
memory
memory: MemoryThe 64K address space, indexed by byte address.
screen
screen: ScreenThe machine display.
type
type: EmulatorTypeThe selected CPU execution model.
Methods
dump
dump(path: str | PathLike, exception: Exception | DotNetException | None = None)Write an HTML diagnostic dump to the supplied path.
A .NET exception can be included in the dump. Python exceptions are not passed through to the underlying .NET dump.
execute_frame
execute_frame() -> ExecutionResultExecute one frame and return whether execution completed or hit a breakpoint.
execute_frames
execute_frames(frames: int) -> ExecutionResultExecute the requested number of frames, stopping early at a breakpoint.
get_screen_memory
get_screen_memory() -> np.ndarray[typing.Any, np.dtype[np.uint8]]Return a NumPy view of a copy of the 6912 screen-memory bytes.
Changing the returned array does not change emulator memory.
load
load(path: str | PathLike) -> NoneLoad a ZX Spectrum file, for example a snapshot, into the emulator. Compressed files, for example .z80.zst, are decompressed automatically.
reset
reset() -> NoneReset the machine, clearing its RAM and CPU state.
run_until_address
run_until_address(address: int) -> NoneExecute until the CPU reaches the given address.
save_z80_snapshot
save_z80_snapshot(directory: str | PathLike, name: str, compression: CompressionFormat = CompressionFormat.NONE) -> PathSave a Z80 snapshot as name.z80 in the given directory, optionally compressed, and return the path of the saved file.