c64bridge 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +5 -0
- package/README.md +115 -15
- package/data/assembly/assembly-spec.md +1 -1
- package/data/basic/rom-routines.md +269 -0
- package/data/context/bootstrap.md +4 -4
- package/data/context/fast-paths.md +3 -1
- package/data/graphics/petscii-style-guide.md +1 -1
- package/data/graphics/sprite-charset-best-practices.md +14 -13
- package/data/io/cia-spec.md +2 -2
- package/data/{memory/kernal-memory-map.md → kernal/rom-routines.md} +3 -2
- package/data/memory/low-memory-map.md +1 -0
- package/data/memory/memory-map.md +13 -0
- package/data/sound/sid-file-structure.md +5 -5
- package/data/sound/sid-programming-best-practices.md +5 -5
- package/data/vice/vice-binary-monitor-spec.md +5 -6
- package/dist/.tsbuildinfo +1 -1
- package/dist/c64Client.js +33 -15
- package/dist/config.js +22 -0
- package/dist/mcp-server.js +17 -5
- package/dist/rag/knowledgeIndex.js +54 -9
- package/dist/rag/resourceUris.js +2 -0
- package/dist/sidwaveCompiler.js +1 -1
- package/dist/tools/input.js +5 -7
- package/dist/tools/memory.js +11 -2
- package/dist/tools/programRunners.js +3 -3
- package/dist/tools/responses.js +14 -1
- package/dist/tools/{assember.js → translation/assembler.js} +56 -162
- package/dist/tools/{basicTokenizer.js → translation/basicTokenizer.js} +1 -1
- package/dist/tools/translation/disassembler.js +150 -0
- package/dist/tools/translation/opcodeInventory.js +126 -0
- package/doc/developer.md +3 -2
- package/doc/reviews/audit.md +143 -0
- package/mcp/resources.json +60 -7
- package/mcp/schemas/c64_input.schema.json +231 -113
- package/mcp/server.json +1 -1
- package/mcp/tools.json +234 -115
- package/mcp.json +8 -4
- package/package.json +12 -8
- package/scripts/c64-cli.mjs +2 -2
- package/scripts/run-coverage.mjs +54 -3
- package/scripts/run-tests.mjs +1 -0
- package/scripts/run-tests.ts +1 -0
- package/scripts/update-readme.ts +1 -0
- package/server.json +3 -3
- package/dist/tools/disassembler.js +0 -478
- /package/dist/tools/{symbolRegistry.js → translation/symbolRegistry.js} +0 -0
|
@@ -246,13 +246,14 @@ Custom charsets have minimal performance impact:
|
|
|
246
246
|
### Using render_sprite
|
|
247
247
|
|
|
248
248
|
```javascript
|
|
249
|
-
{
|
|
250
|
-
|
|
249
|
+
await callTool("c64_graphics", {
|
|
250
|
+
op: "render_sprite",
|
|
251
|
+
sprite: "base64-encoded-63-bytes",
|
|
251
252
|
x: 160, // Center horizontally
|
|
252
253
|
y: 100, // Center vertically
|
|
253
|
-
|
|
254
|
+
color: 1, // White
|
|
254
255
|
multicolour: false
|
|
255
|
-
}
|
|
256
|
+
})
|
|
256
257
|
```
|
|
257
258
|
|
|
258
259
|
The tool:
|
|
@@ -270,26 +271,26 @@ When working with sprites and charsets:
|
|
|
270
271
|
1. Use memory ranges documented in c64://memory/map
|
|
271
272
|
2. Avoid BASIC program area ($0801-$9FFF) unless controlling it
|
|
272
273
|
3. Preserve zero page ($0000-$00FF) and stack ($0100-$01FF)
|
|
273
|
-
4. Use
|
|
274
|
+
4. Use `c64_memory` with `op: "read"` and `op: "write"` for safe access
|
|
274
275
|
|
|
275
276
|
## Example Workflows
|
|
276
277
|
|
|
277
278
|
### Simple Sprite Display
|
|
278
279
|
|
|
279
280
|
1. Prepare 24×21 sprite bitmap
|
|
280
|
-
2. Call `
|
|
281
|
+
2. Call `c64_graphics` with `op: "render_sprite"` and sprite data
|
|
281
282
|
3. Tool writes sprite data and patches VIC-II state automatically
|
|
282
|
-
4. Use `read_screen` to verify appearance
|
|
283
|
-
5. Optionally call `c64_memory` `write` to adjust position/colour
|
|
283
|
+
4. Use `c64_memory` with `op: "read_screen"` to verify appearance
|
|
284
|
+
5. Optionally call `c64_memory` with `op: "write"` to adjust position/colour
|
|
284
285
|
|
|
285
286
|
### Custom Charset Installation
|
|
286
287
|
|
|
287
288
|
1. Design character set (full or partial)
|
|
288
289
|
2. Encode to 8-byte-per-char format
|
|
289
|
-
3. Use `c64_memory` `write` to copy the charset to $2000
|
|
290
|
+
3. Use `c64_memory` with `op: "write"` to copy the charset to $2000
|
|
290
291
|
4. POKE $D018 to point VIC-II at new charset
|
|
291
|
-
5. Use `upload_run_basic` to test character display
|
|
292
|
-
6. Verify with `read_screen`
|
|
292
|
+
5. Use `c64_program` with `op: "upload_run_basic"` to test character display
|
|
293
|
+
6. Verify with `c64_memory` and `op: "read_screen"`
|
|
293
294
|
|
|
294
295
|
### Animated Sprite Sequence
|
|
295
296
|
|
|
@@ -297,13 +298,13 @@ When working with sprites and charsets:
|
|
|
297
298
|
2. Upload all frames to consecutive memory locations
|
|
298
299
|
3. Generate BASIC program that cycles sprite pointer
|
|
299
300
|
4. Use raster timing for smooth animation
|
|
300
|
-
5. Verify frame timing with `c64_memory` `read` checks
|
|
301
|
+
5. Verify frame timing with `c64_memory` and `op: "read"` checks
|
|
301
302
|
|
|
302
303
|
## Best Practices Summary
|
|
303
304
|
|
|
304
305
|
1. **Plan Memory Layout**: Map out sprite and charset locations before coding
|
|
305
306
|
2. **Test Incrementally**: Display one sprite/char before adding more
|
|
306
|
-
3. **Use Tools**: Leverage `render_sprite` and
|
|
307
|
+
3. **Use Tools**: Leverage `c64_graphics` with `op: "render_sprite"` and `c64_memory` operations
|
|
307
308
|
4. **Document State**: Note which sprites/chars are active
|
|
308
309
|
5. **Handle Errors**: Check return values and screen output
|
|
309
310
|
6. **Optimize Last**: Get it working, then optimize if needed
|
package/data/io/cia-spec.md
CHANGED
|
@@ -105,11 +105,11 @@ User‑port mapping for CIA2 PRB and PRA b2 is defined in `io-spec.md` (pin lett
|
|
|
105
105
|
|
|
106
106
|
- **System I/O (IEC, tape, user/expansion ports, keyboard algorithm):** `io-spec.md`
|
|
107
107
|
- **Printers:** `data/printer/printer-spec.md`
|
|
108
|
-
- **KERNAL vector/entry points:**
|
|
108
|
+
- **KERNAL vector/entry points:** `../kernal/rom-routines.md`
|
|
109
109
|
|
|
110
110
|
---
|
|
111
111
|
|
|
112
112
|
**Provenance:**
|
|
113
113
|
|
|
114
114
|
- [C64 Programmer’s Reference Guide](https://www.zimmers.net/cbmpics/cbm/c64/c64prg.txt)
|
|
115
|
-
- [Mapping the C64](https://www.zimmers.net/anonftp/pub/cbm/c64/manuals/mapping-c64_txt)
|
|
115
|
+
- [Mapping the C64](https://www.zimmers.net/anonftp/pub/cbm/c64/manuals/mapping-c64_txt)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
# C64 KERNAL Memory Map — Complete ($E000–$FFFF)
|
|
1
|
+
# C64 KERNAL ROM Routines Memory Map — Complete ($E000–$FFFF)
|
|
2
2
|
|
|
3
3
|
> Purpose: Exhaustive sequential map of KERNAL ROM: callable routines, internal subroutines, constants, tables, IRQ/NMI handlers, and vectors.
|
|
4
4
|
> Format: One table row per symbol; **bold** names indicate callable/public API (also present in `data/api/kernal-api-spec.md`).
|
|
5
5
|
> Conventions: A=Accumulator, X,Y=Index, C=Carry; “—” not applicable.
|
|
6
|
+
> Related memory maps: `../memory/memory-map.md`, `../memory/low-memory-map.md`, `../basic/rom-routines.md`, `../io/io-spec.md`.
|
|
6
7
|
|
|
7
8
|
| Address | Decimal | Name | Function | Args | Input | Output | Notes |
|
|
8
9
|
|:--------|:--------|:-----|:---------|:-----|:------|:-------|:------|
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
| `$E38B` | 58251 | Error msg | BASIC error/READY printing | X=index | Vector `$0302` next | — | — |
|
|
38
39
|
| `$E394` | 58260 | Cold BASIC | Power‑on BASIC init | — | — | — | Copies vectors to RAM |
|
|
39
40
|
| `$E3A2` | 58274 | INITAT | CHRGET text (to $0073) | — | — | — | Moved to ZP |
|
|
40
|
-
| `$E3BA` |
|
|
41
|
+
| `$E3BA` | 58298 | RND seed | Initial RND seed (5‑byte) | — | — | — | Constant |
|
|
41
42
|
| `$E3BF` | 58303 | INIT | BASIC ZP init; copy CHRGET | — | — | — | — |
|
|
42
43
|
| `$E422` | 58402 | Startup msgs | Print banner & BYTES FREE | — | — | — | — |
|
|
43
44
|
| `$E447` | 58439 | BASIC vec tbl | ROM vector table (→RAM $0300) | — | — | — | — |
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
> Style: Same compact table schema used in your KERNAL/BASIC specs. **Hex + decimal** addresses. **Bold** = key/callable vectors.
|
|
6
6
|
|
|
7
7
|
> Hints: Zero page gives **1‑byte addressing** → faster code; keep ML temporaries in $FB–$FE. If **tape is unused**, the **cassette buffer $033C–$03FB (828–1019)** is ideal for **small ML helpers** or even **sprite/char data** (e.g., sprite blocks 13 @ $0340–$037F, 14 @ $0380–$03BF). Keyboard buffering enables **“dynamic keyboard”** input injection. Adjust **LORAM/HIRAM/CHAREN** via $0001 for ROM/RAM banking.
|
|
8
|
+
> Related memory maps: `memory-map.md`, `../basic/rom-routines.md`, `../kernal/rom-routines.md`, `../io/io-spec.md`.
|
|
8
9
|
|
|
9
10
|
## Legend
|
|
10
11
|
|
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All addresses are shown as `hex` / `dec`. Group related entries to minimise token usage while keeping lookup simple.
|
|
4
4
|
|
|
5
|
+
## Memory Map Reference Routing
|
|
6
|
+
|
|
7
|
+
Use this quick map to select the narrowest reference before coding or patching memory.
|
|
8
|
+
|
|
9
|
+
| Need | MCP resource | File |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Whole 64 KB layout, RAM/ROM/I/O banks, VIC/SID/CIA ranges | `c64://memory/map` | `data/memory/memory-map.md` |
|
|
12
|
+
| Zero page, stack, page-2 buffers, page-3 vectors, cassette buffer | `c64://memory/zero-page-and-workspace` | `data/memory/low-memory-map.md` |
|
|
13
|
+
| BASIC ROM routines, parser/evaluator helpers, variables, strings, token dispatch | `c64://basic/rom-routines` | `data/basic/rom-routines.md` |
|
|
14
|
+
| KERNAL ROM routines, jump table, vectors, serial/tape/screen services | `c64://kernal/rom-routines` | `data/kernal/rom-routines.md` |
|
|
15
|
+
| Hardware register map for VIC-II, SID, CIA, colour RAM, expansion I/O | `c64://io/spec` | `data/io/io-spec.md` |
|
|
16
|
+
| CIA timer, keyboard, serial, TOD, IRQ/NMI register details | `c64://io/cia/spec` | `data/io/cia-spec.md` |
|
|
17
|
+
|
|
5
18
|
## Zero Page ($0000-$00FF)
|
|
6
19
|
|
|
7
20
|
| Label | Address | Purpose |
|
|
@@ -5,12 +5,12 @@ This guide summarizes the High Voltage SID Collection (HVSC) "PSID file format"
|
|
|
5
5
|
- A header containing metadata and playback parameters
|
|
6
6
|
- The actual 6502 machine code and data that the player runs on the C64
|
|
7
7
|
|
|
8
|
-
You can play a SID file on a connected device
|
|
8
|
+
You can play a SID file on a connected device with the MCP tool `c64_sound` and `op: "play_sid_file"`.
|
|
9
9
|
|
|
10
|
-
## Quick start: play a SID via
|
|
10
|
+
## Quick start: play a SID via MCP
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
12
|
+
- Tool: `c64_sound`
|
|
13
|
+
- Arguments: `{ "op": "play_sid_file", "path": "/flash/music/Example.sid", "songnr": 1 }` (optional `songnr`)
|
|
14
14
|
|
|
15
15
|
Refer to `doc/c64u/c64-rest-api.md` for the underlying device endpoint and options.
|
|
16
16
|
|
|
@@ -85,7 +85,7 @@ SID files do not embed duration. HVSC ships a `Songlengths.md5` database mapping
|
|
|
85
85
|
|
|
86
86
|
## Related API and tools
|
|
87
87
|
|
|
88
|
-
- Play from device filesystem: `
|
|
88
|
+
- Play from device filesystem: `c64_sound` with `op: "play_sid_file"` (see generated `mcp/tools.json` and `mcp/schemas/c64_sound.schema.json`)
|
|
89
89
|
- Low-level SID register programming: see `data/sound/sid-spec.md`
|
|
90
90
|
|
|
91
91
|
References for further reading: HVSC PSID v2NG file format (spec), community resources, and project notes from implementations like SIDman.
|
|
@@ -126,18 +126,18 @@ This solution was developed through:
|
|
|
126
126
|
|
|
127
127
|
```bash
|
|
128
128
|
curl -X POST -H 'Content-Type: application/json' \
|
|
129
|
-
-d '{"program": "... BASIC program ..."}' \
|
|
130
|
-
http://localhost:8000/tools/
|
|
129
|
+
-d '{"op": "upload_run_basic", "program": "... BASIC program ..."}' \
|
|
130
|
+
http://localhost:8000/tools/c64_program
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
### Future Audio Analysis
|
|
134
134
|
|
|
135
|
-
The working scale can now be used with
|
|
135
|
+
The working scale can now be used with `c64_sound` and `op: "analyze"`:
|
|
136
136
|
|
|
137
137
|
```bash
|
|
138
138
|
curl -X POST -H 'Content-Type: application/json' \
|
|
139
|
-
-d '{"request": "verify the scale sounds correct"}' \
|
|
140
|
-
http://localhost:8000/tools/
|
|
139
|
+
-d '{"op": "analyze", "request": "verify the scale sounds correct"}' \
|
|
140
|
+
http://localhost:8000/tools/c64_sound
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
## Musical Expression Example: "Alle meine Entchen"
|
|
@@ -15,7 +15,7 @@ Recommended C64 Bridge entry points:
|
|
|
15
15
|
| Debug registers and checkpoints | `c64_debug` | `get_registers`, `set_registers`, `create_checkpoint`, `list_checkpoints`, `step`, `step_return` |
|
|
16
16
|
| Send keyboard or joystick input | `c64_input` | `write_text`, `key`, `joystick` |
|
|
17
17
|
| Capture emulator display | `c64_graphics` | `capture_frame` |
|
|
18
|
-
| Reset or
|
|
18
|
+
| Reset or continue execution | `c64_system`, `c64_debug` | `reset`, `continue_execution` |
|
|
19
19
|
| Read or write VICE resources | `c64_vice` | `resource_get`, `resource_set` |
|
|
20
20
|
|
|
21
21
|
---
|
|
@@ -633,7 +633,7 @@ C64 Bridge mapping:
|
|
|
633
633
|
|
|
634
634
|
| MCP tool | Operation |
|
|
635
635
|
| ------------ | --------- |
|
|
636
|
-
| `
|
|
636
|
+
| `c64_debug` | `continue_execution` |
|
|
637
637
|
|
|
638
638
|
---
|
|
639
639
|
|
|
@@ -797,7 +797,7 @@ Usually emitted with `request_id = 0xffffffff`.
|
|
|
797
797
|
| Palette Get | `0x91` | `0x91` | internal display support |
|
|
798
798
|
| Joyport Set | `0xa2` | `0xa2` | `c64_input.joystick` |
|
|
799
799
|
| Userport Set | `0xb2` | `0xb2` | internal or unmapped |
|
|
800
|
-
| Exit | `0xaa` | `0xaa` | `
|
|
800
|
+
| Exit | `0xaa` | `0xaa` | `c64_debug.continue_execution` |
|
|
801
801
|
| Quit | `0xbb` | `0xbb` | managed VICE lifecycle |
|
|
802
802
|
| Reset | `0xcc` | `0xcc` | `c64_system.reset`, `c64_system.reboot`, `c64_drive.reset` |
|
|
803
803
|
| Autostart / Autoload | `0xdd` | `0xdd` | `c64_program.run_prg`, `c64_program.upload_run_basic`, `c64_program.upload_run_asm` |
|
|
@@ -827,17 +827,16 @@ Examples:
|
|
|
827
827
|
| Read PC and A | `c64_debug` with `op = get_registers` |
|
|
828
828
|
| Step one instruction | `c64_debug` with `op = step` |
|
|
829
829
|
| Step until return | `c64_debug` with `op = step_return` |
|
|
830
|
-
| Continue execution | `
|
|
830
|
+
| Continue execution | `c64_debug` with `op = continue_execution` |
|
|
831
831
|
| Reset VICE | `c64_system` with `op = reset` |
|
|
832
832
|
| Change a VICE setting | `c64_vice` with `op = resource_set` |
|
|
833
833
|
|
|
834
834
|
## Backend Selection
|
|
835
835
|
|
|
836
|
-
If both C64 Ultimate and VICE are configured,
|
|
836
|
+
If both C64 Ultimate and VICE are configured, call `c64_select_backend` with these arguments before making VICE-specific requests:
|
|
837
837
|
|
|
838
838
|
```json
|
|
839
839
|
{
|
|
840
|
-
"tool": "c64_select_backend",
|
|
841
840
|
"op": "select",
|
|
842
841
|
"backend": "vice"
|
|
843
842
|
}
|