64kramsystem / 64kramsystem/ghidra-vice-connector

Annotate C64 zero-page and system variable addresses

Ouverte
#22 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
priority: medium
Langage dominant
Python
Étoiles
1
Forks
0
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

## Summary

Apply labels and comments to the ~300 well-known C64 KERNAL/BASIC zero-page and system variable addresses in the Ghidra program database. This complements issue #13 (hardware registers) which covers $D000–$DFFF; this issue covers $0000–$03FF.

Sources: [pagetable.com Ultimate C64 Reference](https://www.pagetable.com/c64ref/c64mem/), [sta.c64.org memory map](http://sta.c64.org/cbm64mem.html).

---

## Key address ranges

| Range | Contents |
|-------|----------|
| $0000–$0001 | CPU I/O port direction / data (6510-specific) |
| $0002–$00FF | KERNAL/BASIC zero-page workspace |
| $00FB–$00FE | Free zero-page for user programs |
| $0100–$01FF | 6502 hardware stack |
| $0200–$02FF | BASIC input buffer, KERNAL workspace |
| $0300–$0314 | KERNAL vectors (overridable soft vectors) |
| $0314–$0333 | IRQ/NMI/BRK/RESET vectors (RAM-based) — see also issue #14 |
| $033C–$03FB | Cassette buffer (often used as free scratch RAM by games) |

Notable zero-page addresses:
- `$01` — processor port (bank switching config)
- `$2B`/`$2C` — start of BASIC text
- `$90` — KERNAL status byte
- `$A7`–`$C5` — floating point accumulator
- `$C5`/`$C6` — current key / key count

---

## Implementation

A Ghidra script (Java or Python, alongside `RebaseToC64Load.java` in `data/ghidra-scripts/`) that iterates a built-in table and calls:

```java
// Java (GhidraScript)
Address addr = toAddr(0x0090);
createLabel(addr, "KERNAL_STATUS", true, SourceType.IMPORTED);
setPlateComment(addr, "KERNAL I/O status byte (ST)");
```

The table should be a static list in the script — no external file dependency.

**Run condition:** check `currentProgram.getLanguage().getLanguageID().toString().contains("6502")` before applying, so the script is safe to run against any Ghidra program.

**Integration:** mention in README as a companion script to run after import, alongside `RebaseToC64Load.java`.

---

## Reference data

Full address tables:
- https://www.pagetable.com/c64ref/c64mem/ (machine-readable JSON available)
- http://sta.c64.org/cbm64mem.html

The pagetable.com reference has a JSON export that could be used to generate the label table automatically.

---

## Files to create/change

- `data/ghidra-scripts/LabelC64SystemAddresses.java` — new script (companion to `RebaseToC64Load.java`)
- `README.md` — mention the script in the setup section

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.