Snapshots and diagnostics
Save a snapshot
python
from pathlib import Path
from mrkwatkins.oakemu.zxspectrum import ZXSpectrum
spectrum = ZXSpectrum()
spectrum.execute_frames(10)
output = Path("snapshots")
output.mkdir(exist_ok=True)
snapshot = spectrum.save_z80_snapshot(output, "after-ten-frames")
print(snapshot)This writes after-ten-frames.z80 and returns its path.
Add compression
python
from mrkwatkins.oakemu.zxspectrum import CompressionFormat
snapshot = spectrum.save_z80_snapshot(
output,
"compressed",
CompressionFormat.ZSTANDARD,
)The result has a .z80.zst extension. The available compression choices are NONE, ZIP, GZIP, BROTLI and ZSTANDARD.
Reload a saved snapshot into another machine:
python
restored = ZXSpectrum()
restored.load(snapshot)Copy machine state in Python
python
from copy import deepcopy
copy = deepcopy(spectrum)The copied machine has independent state. The wrapper also supports Python's pickle protocol for use within compatible Python and OakEmu environments. Use a snapshot file when exchanging state with other emulator tools.
Write a diagnostic dump
python
spectrum.dump("diagnostics.html")The HTML dump shows the underlying OakEmu machine state. A .NET exception can be supplied as the second argument; Python exception details are not included in the dump.