c64bridge 0.5.0

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.
Files changed (138) hide show
  1. package/.github/prompts/README.md +6 -0
  2. package/.github/prompts/assembly-routine-session.prompt.md +13 -0
  3. package/.github/prompts/basic-program-session.prompt.md +13 -0
  4. package/.github/prompts/drive-management-session.prompt.md +13 -0
  5. package/.github/prompts/petscii-art-session.prompt.md +13 -0
  6. package/.github/prompts/play-classic-game.prompt.md +13 -0
  7. package/.github/prompts/sid-music-session.prompt.md +13 -0
  8. package/AGENTS.md +173 -0
  9. package/LICENSE +339 -0
  10. package/README.md +582 -0
  11. package/data/README.md +16 -0
  12. package/data/api/basic-api-spec.md +154 -0
  13. package/data/api/kernal-api-spec.md +68 -0
  14. package/data/assembly/assembly-spec.md +196 -0
  15. package/data/assembly/examples/effects/sinewave.asm +5 -0
  16. package/data/assembly/examples/graphics/sprite/mover.asm +15 -0
  17. package/data/assembly/examples/sid-file-structure.md +8 -0
  18. package/data/assembly/examples/sid-overview.md +11 -0
  19. package/data/audio/examples/Biosphere.sid +0 -0
  20. package/data/audio/sid-file-structure.md +91 -0
  21. package/data/audio/sid-programming-best-practices.md +198 -0
  22. package/data/audio/sid-spec.md +166 -0
  23. package/data/audio/sidwave.md +131 -0
  24. package/data/audio/sidwave.schema.json +64 -0
  25. package/data/basic/basic-spec.md +230 -0
  26. package/data/basic/examples/audio/alle-meine-entchen-expressive.bas +41 -0
  27. package/data/basic/examples/audio/c-major-scale-pleasant.bas +29 -0
  28. package/data/basic/examples/io/joystick.bas +5 -0
  29. package/data/basic/examples/video/bounce.bas +8 -0
  30. package/data/basic/examples/video/entchen-petscii.bas +16 -0
  31. package/data/basic/examples/video/hello-world.bas +4 -0
  32. package/data/basic/examples/video/wave.bas +7 -0
  33. package/data/context/bootstrap.md +148 -0
  34. package/data/context/chat.md +36 -0
  35. package/data/drive/drive-spec.md +215 -0
  36. package/data/embeddings_asm.json +1 -0
  37. package/data/embeddings_basic.json +1 -0
  38. package/data/embeddings_hardware.json +1 -0
  39. package/data/embeddings_mixed.json +1 -0
  40. package/data/embeddings_other.json +1 -0
  41. package/data/io/cia-spec.md +115 -0
  42. package/data/io/io-spec.md +124 -0
  43. package/data/memory/kernal-memory-map.md +227 -0
  44. package/data/memory/low-memory-map.md +133 -0
  45. package/data/memory/memory-map.md +186 -0
  46. package/data/printer/printer-commodore-bitmap.md +31 -0
  47. package/data/printer/printer-commodore.md +28 -0
  48. package/data/printer/printer-epson-bitmap.md +29 -0
  49. package/data/printer/printer-epson.md +30 -0
  50. package/data/printer/printer-prompts.md +29 -0
  51. package/data/printer/printer-spec.md +180 -0
  52. package/data/video/character-set.csv +257 -0
  53. package/data/video/vic-spec.md +276 -0
  54. package/dist/assemblyConverter.js +1299 -0
  55. package/dist/audio/record_and_analyze_audio.js +292 -0
  56. package/dist/basicConverter.js +193 -0
  57. package/dist/bootstrap/stdio-logger.js +32 -0
  58. package/dist/c64Client.js +1052 -0
  59. package/dist/chargen.js +197 -0
  60. package/dist/config.js +142 -0
  61. package/dist/context.js +157 -0
  62. package/dist/device.js +413 -0
  63. package/dist/index.js +7 -0
  64. package/dist/knowledge.js +454 -0
  65. package/dist/logger.js +182 -0
  66. package/dist/loggingHttpClient.js +88 -0
  67. package/dist/mcp-server.js +426 -0
  68. package/dist/petscii.js +135 -0
  69. package/dist/petsciiArt.js +356 -0
  70. package/dist/platform.js +82 -0
  71. package/dist/prompts/registry.js +560 -0
  72. package/dist/rag/discover.config.json +41 -0
  73. package/dist/rag/discover.js +401 -0
  74. package/dist/rag/embeddings.js +60 -0
  75. package/dist/rag/externalFetcher.js +934 -0
  76. package/dist/rag/indexer.js +770 -0
  77. package/dist/rag/init.js +139 -0
  78. package/dist/rag/knowledgeIndex.js +361 -0
  79. package/dist/rag/loggingRetriever.js +46 -0
  80. package/dist/rag/rateLimiter.js +127 -0
  81. package/dist/rag/retriever.js +74 -0
  82. package/dist/rag/sources.csv +31 -0
  83. package/dist/rag/types.js +5 -0
  84. package/dist/rag/urlUtils.js +38 -0
  85. package/dist/sidplayRunner.js +240 -0
  86. package/dist/sidwave.js +101 -0
  87. package/dist/sidwaveCompiler.js +329 -0
  88. package/dist/tools/audio.js +944 -0
  89. package/dist/tools/developer.js +515 -0
  90. package/dist/tools/errors.js +59 -0
  91. package/dist/tools/graphics.js +469 -0
  92. package/dist/tools/machineControl.js +267 -0
  93. package/dist/tools/memory.js +224 -0
  94. package/dist/tools/printer.js +482 -0
  95. package/dist/tools/programRunners.js +315 -0
  96. package/dist/tools/rag.js +153 -0
  97. package/dist/tools/registry.js +58 -0
  98. package/dist/tools/responses.js +36 -0
  99. package/dist/tools/schema.js +304 -0
  100. package/dist/tools/storage.js +740 -0
  101. package/dist/tools/streaming.js +132 -0
  102. package/dist/tools/types.js +99 -0
  103. package/dist/viceRunner.js +239 -0
  104. package/doc/MCP_SETUP.md +153 -0
  105. package/doc/README.md +7 -0
  106. package/doc/developer.md +312 -0
  107. package/doc/img/logo.png +0 -0
  108. package/doc/img/prompts/duck_petscii.png +0 -0
  109. package/doc/img/prompts/duck_song.png +0 -0
  110. package/doc/img/vscode/vscode-copilot-c64-chat-mode.png +0 -0
  111. package/doc/img/vscode/vscode-copilot-hello-world.png +0 -0
  112. package/doc/prompts/README.md +96 -0
  113. package/doc/prompts/user-prompt-ideas.md +147 -0
  114. package/doc/rest/c64-openapi.yaml +979 -0
  115. package/doc/rest/c64-rest-api.md +106 -0
  116. package/doc/troubleshooting-mcp.md +177 -0
  117. package/generated/c64/index.js +857 -0
  118. package/mcp.json +106 -0
  119. package/package.json +79 -0
  120. package/scripts/c64-cli.mjs +142 -0
  121. package/scripts/c64-tool.sh +83 -0
  122. package/scripts/check-package.mjs +89 -0
  123. package/scripts/cli.js +61 -0
  124. package/scripts/fetch-external-sources.mjs +67 -0
  125. package/scripts/generate-changelog.mjs +131 -0
  126. package/scripts/postbuild.mjs +101 -0
  127. package/scripts/prepare-release.mjs +58 -0
  128. package/scripts/rag-rebuild.mjs +53 -0
  129. package/scripts/register-ts-node.mjs +6 -0
  130. package/scripts/run-mcp-check.sh +104 -0
  131. package/scripts/run-tests.mjs +195 -0
  132. package/scripts/sid2wav.sh +94 -0
  133. package/scripts/smoke-run.sh +65 -0
  134. package/scripts/start-mock-c64.mjs +51 -0
  135. package/scripts/start-mock.mjs +31 -0
  136. package/scripts/start.mjs +72 -0
  137. package/scripts/update-readme.ts +164 -0
  138. package/scripts/verify-package.mjs +147 -0
@@ -0,0 +1,215 @@
1
+ # Commodore Disk Drives — 1541, 1571, 1581
2
+
3
+ **Scope:** Commodore floppy drives used with the C64/C128 via the IEC serial bus.
4
+ Each drive contains an internal 6502 CPU and DOS ROM implementing a self‑contained filesystem.
5
+ Main reference drive: **1541 (DOS 2.6)**; extensions for **1571 (DOS 3.0)** and **1581 (DOS 10.0)** below.
6
+
7
+ ---
8
+
9
+ ## 1541 — Disk Format and DOS 2.6
10
+
11
+ **Medium:** 5¼″ single‑sided DD, 35 tracks (17–21 sectors per track).
12
+ **Capacity:** 174 848 B (683 × 256 B); 664 free (169 984 B).
13
+ **Directory:** Track 18 Sectors 1–17; BAM = Track 18 Sector 0.
14
+ **Max files:** 144 (no subdirs). **DOS:** v2.6.
15
+
16
+ ### File Types
17
+
18
+ | Type | Description | Max Size | Notes |
19
+ |:--|:--|:--|:--|
20
+ | **PRG** | Program (LOAD/SAVE) | ~202 blocks | Loadable code |
21
+ | **SEQ** | Sequential file | 168 656 B | Text/data |
22
+ | **USR** | User file | ≈SEQ | App‑defined |
23
+ | **REL** | Relative file | 167 132 B / 65 535 records | Random access |
24
+ | **DEL** | Deleted entry | — | Hidden or invalid |
25
+
26
+ Flags: `<` = locked (read‑only); `*` = not closed (use VALIDATE).
27
+
28
+ ### Track Layout (256‑B sectors)
29
+
30
+ | Tracks | Sectors/Track | Total Sectors |
31
+ |:--|:--|:--|
32
+ | 1–17 | 21 | 357 |
33
+ | 18 | 19 (Dir/BAM) | 19 |
34
+ | 19–24 | 18 | 108 |
35
+ | 25–35 | 17 | 187 |
36
+ | **Total** |  | **683** |
37
+
38
+ Tracks 40–41 exist physically but unused by DOS 2.6.
39
+
40
+ ### BAM (Track 18 Sector 0)
41
+
42
+ | Bytes | Purpose |
43
+ |:--|:--|
44
+ | 0–1 | DOS version ("A0") |
45
+ | 2–3 | First dir T/S (18/1) |
46
+ | 4–143 | 4 bytes per track (free bitmap + count) |
47
+ | 144–159 | Disk name (16 B PETSCII) |
48
+ | 162–163 | ID (2 B) + type "2A" |
49
+
50
+ ### Directory Entries (32 B each)
51
+
52
+ | Offset | Field | Size | Notes |
53
+ |:--|:--|:--|:--|
54
+ | 0 | Type/status byte | 1 | bit 7=used, bits 0‑3=file type |
55
+ | 1–2 | Start T/S | 2 | first block |
56
+ | 3–18 | File name | 16 | PETSCII A0‑padded |
57
+ | 30–31 | Blocks used | 2 | file size in blocks |
58
+
59
+ ### DOS 2.6 Commands (via channel 15)
60
+
61
+ | Action | Command | Example |
62
+ |:--|:--|:--|
63
+ | Format disk | `N0:name,ID` | `OPEN15,8,15,"N0:DISK,01"` |
64
+ | Validate | `V0` | `PRINT#15,"V0"` |
65
+ | Initialize | `I0` | `PRINT#15,"I0"` |
66
+ | Reset | `UI0` | `PRINT#15,"UI0"` |
67
+ | Copy file | `C0:new=old` | `PRINT#15,"C0:NEW=OLD"` |
68
+ | Rename | `R0:new=old` | `PRINT#15,"R0:NEW=OLD"` |
69
+ | Delete | `S0:mask` | `PRINT#15,"S0:*"` |
70
+ | Concatenate | `C0:new=a,b` | `PRINT#15,"C0:MERGE=A,B"` |
71
+ | Replace (file overwrite) | `@0:name` | `SAVE"@0:FILE",8` ⚠ bug on 1541‑I |
72
+ | Memory write | `M-W addrL addrH size data` | Direct RAM write |
73
+ | Position (REL) | `P ch recL recH pos` | Record seek |
74
+
75
+ ---
76
+
77
+ ## Programming Interface (BASIC & Assembly)
78
+
79
+ The following applies to all drives.
80
+
81
+ ### Relevant BASIC / KERNAL APIs
82
+
83
+ | Operation | BASIC Keyword | KERNAL Routine | Addr (hex) | Notes |
84
+ |---|---|---|---|---|
85
+ | Open channel | `OPEN` | `SETLFS` / `SETNAM` / `OPEN` | $FFBA / $FFBD / $FFC0 | Set device, secondary, file name |
86
+ | Print data | `PRINT#` | `CHKOUT` / `CHROUT` | $FFC9 / $FFD2 | Write bytes to drive |
87
+ | Read data | `GET#`, `INPUT#` | `CHKIN` / `CHRIN` | $FFC6 / $FFCF | Read bytes |
88
+ | Close file | `CLOSE` | `CLOSE` / `CLRCHN` | $FFC3 / $FFCC | Release channel |
89
+ | Load file | `LOAD` | `LOAD` | $FFD5 | Load PRG from disk |
90
+ | Save file | `SAVE` | `SAVE` | $FFD8 | Write PRG to disk |
91
+ | Read status | `PRINT STATUS` | `READST` | $FFB7 | Check error/status flags |
92
+
93
+ ---
94
+
95
+ ### BASIC Examples
96
+
97
+ ```basic
98
+ REM --- PRINT DIRECTORY ---
99
+ LOAD"$",8:LIST
100
+
101
+ REM --- LOAD FILE ---
102
+ LOAD"HELLO.PRG",8,1
103
+
104
+ REM --- SAVE FILE ---
105
+ SAVE"HELLO.PRG",8
106
+ ```
107
+
108
+ ---
109
+
110
+ ### Assembly Examples
111
+
112
+ #### Print Directory
113
+
114
+ ```asm
115
+ lda #<dir
116
+ ldx #>dir
117
+ ldy #len
118
+ jsr $ffbd ; SETNAM
119
+ lda #1 ; logical
120
+ ldx #8 ; device
121
+ ldy #0 ; secondary
122
+ jsr $ffba ; SETLFS
123
+ jsr $ffd5 ; LOAD (LOAD"$",8)
124
+ dir: .text "$"
125
+ len = *-dir
126
+ ```
127
+
128
+ #### Load File
129
+
130
+ ```asm
131
+ lda #<name
132
+ ldx #>name
133
+ ldy #len
134
+ jsr $ffbd
135
+ lda #0 ; LFN=0
136
+ ldx #8 ; device
137
+ ldy #1 ; SA=1
138
+ jsr $ffba
139
+ lda #0
140
+ jsr $ffd5 ; LOAD (A=0=load)
141
+ name: .text "HELLO.PRG"
142
+ len = *-name
143
+ ```
144
+
145
+ #### Save File
146
+
147
+ ```asm
148
+ lda #<name
149
+ ldx #>name
150
+ ldy #len
151
+ jsr $ffbd
152
+ lda #0
153
+ ldx #8
154
+ ldy #1
155
+ jsr $ffba
156
+ lda #0
157
+ jsr $ffd8 ; SAVE
158
+ name: .text "HELLO.PRG"
159
+ len = *-name
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 1571 — Double‑Sided Drive (DOS 3.0)
165
+
166
+ **Medium:** 5¼″ double‑sided DD, 70 tracks (35 × 2).
167
+ **Capacity:** ~349 KB (1368 blocks). **DOS:** 3.0.
168
+ Reads/writes 1541 disks (side A only); auto‑flips heads; supports burst mode with C128.
169
+
170
+ ### Key Differences
171
+
172
+ - Dual BAMs (one per side, merged view).
173
+ - Identical file types and commands to 1541.
174
+ - Burst protocol ≈ 2× speed vs 1541.
175
+ - Optional MFM mode for CP/M.
176
+
177
+ **Geometry:** Same sector zones per side as 1541.
178
+
179
+ ---
180
+
181
+ ## 1581 — 3½″ Drive (DOS 10.0)
182
+
183
+ **Medium:** 3½″ DS/DD, 80 tracks, 40 sectors/track (512 B).
184
+ **Capacity:** 316 416 B (316 logical blocks × 256 B).
185
+ Supports subdirectories and partitions. Compatible with C64 and C128 via IEC. I/O ≈ 4× 1541 speed.
186
+
187
+ ### Command Summary
188
+
189
+ | Action | Command | Example |
190
+ |---|---|---|
191
+ | Format disk | `N0:NAME,ID` | `OPEN15,8,15,"N0:WORK,01"` |
192
+ | Create directory | `MD:NAME` | `PRINT#15,"MD:DATA"` |
193
+ | Change directory | `CD:NAME` | `PRINT#15,"CD:DATA"` |
194
+ | Delete file/dir | `S0:NAME` | `PRINT#15,"S0:OLD"` |
195
+ | Validate | `V0` | `PRINT#15,"V0"` |
196
+
197
+ ### Notes
198
+
199
+ - MS‑DOS‑like directory tree and BAM per partition.
200
+ - Geometry: 80 × 40 × 512 B = 1.6 MB raw (≈800 KB used).
201
+ - DOS 10 implements subdir navigation and hierarchical file lookup.
202
+
203
+ ---
204
+
205
+ ## Drive Comparison Summary
206
+
207
+ | Drive | DOS | Sides | Tracks | Sectors/Track | Capacity (bytes) | Notes |
208
+ |:--|:--|:--|:--|:--|:--|:--|
209
+ | **1541** | 2.6 | 1 | 35 | 17–21 | 174 848 (664 free blocks) | Standard C64 drive |
210
+ | **1571** | 3.0 | 2 | 70 | 17–21 per side | 349 696 | Burst mode, dual BAM |
211
+ | **1581** | 10.0 | 2 (3½″) | 80 | 40 @ 512 B | 316 416 (316 KB free) | Subdirs, partitions |
212
+
213
+ ---
214
+
215
+ **Cross‑Refs:** [`io/cia-spec.md`](../io/cia-spec.md) · [`printer/printer-spec.md`](../printer/printer-spec.md)