64kramsystem / 64kramsystem/ghidra-vice-connector

Save and restore VICE machine state snapshots (BMP 0x41/0x42)

Open
#24 0 comments 0 reactions 0 assignees View on GitHub
priority: medium
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Summary

Save the full VICE machine state (RAM, registers, chip state, drive state) to a `.vsf` snapshot file from Ghidra, and restore it later. This enables fast iteration: save state at a specific game screen, freely experiment with breakpoints and memory edits, then restore to retry.

Source: RetroDebugger Timeline Save/Load; VICE BMP `Dump` (0x41) and `Undump` (0x42).

---

## BMP protocol details

**`CMD_DUMP = 0x41`** — save snapshot

Request payload:
```
save_roms (1) — 1 = include ROM contents in snapshot
save_disks (1) — 1 = include disk image contents
filename_len (2 LE)
filename (filename_len bytes, ASCII path accessible to VICE process)
```

Response: standard ACK (error byte = 0 on success).

**`CMD_UNDUMP = 0x42`** — restore snapshot

Request payload:
```
filename_len (2 LE)
filename (filename_len bytes)
```

Response body:
```
pc (2 LE) — PC value after restore
```

After `undump`, the trace state is stale — call `populate_initial_state()` or at minimum `on_stop()` to resync registers and memory.

---

## Implementation plan

### 1. `util.py`

```python
CMD_DUMP = 0x41
CMD_UNDUMP = 0x42

def dump(self, path: str, save_roms: bool = False, save_disks: bool = False):
enc = path.encode('ascii')
payload = struct.pack(' int:
enc = path.encode('ascii')
payload = struct.pack('

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.