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,186 @@
1
+ # C64 Memory Map (Quick Reference)
2
+
3
+ All addresses are shown as `hex` / `dec`. Group related entries to minimise token usage while keeping lookup simple.
4
+
5
+ ## Zero Page ($0000-$00FF)
6
+
7
+ | Label | Address | Purpose |
8
+ | --- | --- | --- |
9
+ | D6510 | $0000 / 0 | 6510 data direction register. |
10
+ | R6510 | $0001 / 1 | 6510 on-chip I/O bits (LORAM, HIRAM, CHAREN, cassette). |
11
+ | TEMP | $0002 / 2 | Free. |
12
+ | ADRAY1 | $0003-$0004 / 3-4 | FAC β†’ integer jump vector ($B1AA). |
13
+ | ADRAY2 | $0005-$0006 / 5-6 | Integer β†’ FAC jump vector ($B391). |
14
+ | CHARAC | $0007 / 7 | Search char / temp integer. |
15
+ | ENDCHR | $0008 / 8 | Quote scan flag (string end). |
16
+ | TRMPOS | $0009 / 9 | TAB column. |
17
+ | VERCK | $000A / 10 | Load (0) / verify (1). |
18
+ | COUNT | $000B / 11 | Input buffer pointer / subscript count. |
19
+ | DIMFLG | $000C / 12 | Default array dimension flag. |
20
+ | VALTYP | $000D / 13 | Data type: $00 numeric, $FF string. |
21
+ | INTFLG | $000E / 14 | $00 float, $80 integer. |
22
+ | GARBFL | $000F / 15 | DATA scan / list quote / GC flags. |
23
+ | SUBFLG | $0010 / 16 | Subscript ref / user function call flag. |
24
+ | INPFLG | $0011 / 17 | INPUT/GET/READ selector. |
25
+ | TANSGN | $0012 / 18 | TAN sign / compare result. |
26
+ | CHANNL | $0013 / 19 | Current input file number. |
27
+ | LINNUM | $0014-$0015 / 20-21 | Temporary integer value. |
28
+ | TEMPPT | $0016 / 22 | Temp string stack pointer. |
29
+ | LASTPT | $0017-$0018 / 23-24 | Last temp string address. |
30
+ | TEMPST | $0019-$0021 / 25-33 | Temp string stack. |
31
+ | INDEX1/2 | $0022-$0025 / 34-37 | Utility pointers. |
32
+ | RESHO | $0026-$002A / 38-42 | FP multiply/divide product. |
33
+ | TXTTAB | $002B-$002C / 43-44 | BASIC text start ($0801). |
34
+ | VARTAB | $002D-$002E / 45-46 | BASIC variables start. |
35
+ | ARYTAB | $002F-$0030 / 47-48 | BASIC arrays start. |
36
+ | STREND | $0031-$0032 / 49-50 | BASIC arrays end + 1. |
37
+ | FRETOP | $0033-$0034 / 51-52 | String heap bottom. |
38
+ | FRESPC | $0035-$0036 / 53-54 | Utility string pointer. |
39
+ | MEMSIZ | $0037-$0038 / 55-56 | BASIC memory top ($A000). |
40
+ | CURLIN | $0039-$003A / 57-58 | Current BASIC line. |
41
+ | OLDLIN | $003B-$003C / 59-60 | Previous BASIC line. |
42
+ | OLDTXT | $003D-$003E / 61-62 | CONT statement pointer. |
43
+ | DATLIN | $003F-$0040 / 63-64 | Current DATA line. |
44
+ | DATPTR | $0041-$0042 / 65-66 | Current DATA item address. |
45
+ | INPPTR | $0043-$0044 / 67-68 | INPUT pointer temp. |
46
+ | VARNAM | $0045-$0046 / 69-70 | Variable name lookup. |
47
+ | VARPNT | $0047-$0048 / 71-72 | Pointer to variable value/descriptor. |
48
+ | FORPNT | $0049-$004A / 73-74 | FOR/NEXT index pointer. |
49
+ | VARTXT | $004B-$004C / 75-76 | TXTPTR temp for READ/INPUT/GET. |
50
+ | OPMASK | $004D / 77 | FRMEVL mask. |
51
+ | TEMPF1-3 | $004E-$0060 / 78-96 | FP temporaries. |
52
+ | FAC / AFAC | $0061-$006E / 97-110 | FP accumulators, exponent, mantissa, sign. |
53
+ | ARISGN | $006F / 111 | Arithmetic result sign. |
54
+ | FACOV | $0070 / 112 | Rounding byte. |
55
+ | FBUFPT | $0071-$0072 / 113-114 | CRUNCH/ASCII pointers. |
56
+ | CHRGET | $0073-$008A / 115-138 | BASIC text fetch routine. |
57
+ | CHRGOT | $0079 / 121 | Re-read current char entry. |
58
+ | TXTPTR | $007A-$007B / 122-123 | BASIC text pointer. |
59
+ | RNDX | $008B-$008F / 139-143 | RND seed. |
60
+ | STATUS | $0090 / 144 | Kernal I/O status (ST). |
61
+ | STKEY | $0091 / 145 | STOP key flag ($7F). |
62
+ | SVXT | $0092 / 146 | Tape timing constant. |
63
+ | VERCKK | $0093 / 147 | Load/verify flag. |
64
+ | C3PO / BSOUR | $0094-$0095 / 148-149 | Serial bus buffers. |
65
+ | SYNO | $0096 / 150 | Cassette sync number. |
66
+ | TEMPX/Y | $0097 / 151 | X/Y register temp (CHRIN/RS232). |
67
+ | LDTND | $0098 / 152 | Open files count / index. |
68
+ | DFLTN/O | $0099-$009A / 153-154 | Default input/output devices. |
69
+ | PRTY / DPSW | $009B-$009C / 155-156 | Tape parity & state. |
70
+ | MSGFLG | $009D / 157 | Error message mode. |
71
+ | FNMIDX / PTR1 / PTR2 | $009E-$009F / 158-159 | Tape filename/error log. |
72
+ | TIME | $00A0-$00A2 / 160-162 | Jiffy clock (UDTIMK). |
73
+ | TSFCNT / TBTCNT / CNTDN | $00A3-$00A5 / 163-165 | Tape counters. |
74
+ | BUFPNT | $00A6 / 166 | Tape buffer pointer. |
75
+ | INBIT-ROPRTY | $00A7-$00BD / 167-189 | RS232/tape temporaries. |
76
+ | FSBLK | $00BE / 190 | Tape block count. |
77
+ | MYCH | $00BF / 191 | Serial word buffer. |
78
+ | CAS1 | $00C0 / 192 | Tape motor switch. |
79
+ | STAL/EAL | $00C1-$00C2 / 193-194 | Load start/end. |
80
+ | MEMUSS | $00C3-$00C4 / 195-196 | Tape type 3/general pointer. |
81
+ | LSTX | $00C5 / 197 | Last key matrix value. |
82
+ | Keyboard/editor | $00C6-$00F2 / 198-242 | Buffer, cursor, quote, insert, link table. |
83
+ | USER | $00F3-$00F4 / 243-244 | Colour RAM pointer. |
84
+ | KEYTAB | $00F5-$00F6 / 245-246 | Keyboard decode vector ($EB81). |
85
+ | RIBUF / ROBUF | $00F7-$00FA / 247-250 | RS232 buffer pointers. |
86
+ | FREKZP | $00FB-$00FE / 251-254 | Free ZP workspace. |
87
+ | BASZPT | $00FF / 255 | BASIC temp / FP→ASCII area. |
88
+
89
+ ## Page $0100-$03FF Highlights
90
+
91
+ - $0100-$01FF: CPU stack ($0100-$01FF), BASIC stack overlay.
92
+ - $0200-$0258: Screen input buffer.
93
+ - $0259-$0276: Kernal file tables (LAT/FAT/SAT).
94
+ - $0277-$0280: Keyboard FIFO.
95
+ - $0281-$0284: OS memory bounds.
96
+ - $0285-$029E: Keyboard repeat, shift flags, RS232 state.
97
+ - $029F-$02A6: IRQ/tape temporaries.
98
+ - $02A7-$02FF: Unused block (sprite data when remapped).
99
+ - $0300-$0333: BASIC + Kernal vectors (errors, LIST, LOAD/SAVE, IRQ/NMI, USR).
100
+ - $0334-$033B: Unused.
101
+ - $033C-$03FB: Tape buffer.
102
+ - $0340-$03FE: Sprite data areas (#13-15).
103
+ - $0400-$07E7: Screen RAM; $07F8-$07FF sprite pointers.
104
+
105
+ ## Main RAM / ROM Banks
106
+
107
+ | Range | Decimal | Notes |
108
+ | --- | --- | --- |
109
+ | $0800-$9FFF | 2048-40959 | BASIC program RAM. |
110
+ | $8000-$9FFF | 32768-40959 | Cartridge ROM (optional). |
111
+ | $A000-$BFFF | 40960-49151 | BASIC ROM or banked RAM. |
112
+ | $C000-$CFFF | 49152-53247 | RAM. |
113
+ | $D000-$DFFF | 53248-57343 | I/O, Colour RAM, or char ROM (banked). |
114
+ | $E000-$FFFF | 57344-65535 | BASIC/Kernal ROM or RAM (banked). |
115
+
116
+ ## Control Bits
117
+
118
+ - `$0000`: DDR (1 = output, 0 = input). Default `xx101111`.
119
+ - `$0001`: `/LORAM`, `/HIRAM`, `/CHAREN`, cassette data, sense, motor.
120
+ - `$DD00` bits 0-1: VIC bank select.
121
+
122
+ ## VIC-II ($D000-$D02E)
123
+
124
+ | Address | Meaning |
125
+ | --- | --- |
126
+ | $D000-$D00F | Sprite 0-7 X/Y (with $D010 MSBs). |
127
+ | $D011 | Control: 25-row, bitmap, Y scroll, raster bit 8. |
128
+ | $D012 | Raster compare. |
129
+ | $D013-$D014 | Light-pen latch X/Y. |
130
+ | $D015 | Sprite enable bits. |
131
+ | $D016 | Control: 40-column, X scroll, multicolour bit. |
132
+ | $D017 | Sprite Y expand. |
133
+ | $D018 | Matrix/charset base select. |
134
+ | $D019 | IRQ flags (raster, s-sprite, s-bg, light pen). |
135
+ | $D01A | IRQ mask. |
136
+ | $D01B | Sprite/background priority. |
137
+ | $D01C | Sprite multicolour enable. |
138
+ | $D01D | Sprite X expand. |
139
+ | $D01E-$D01F | Sprite collision flags. |
140
+ | $D020-$D024 | Border + background colours 0-3. |
141
+ | $D025-$D026 | Sprite shared multicolours. |
142
+ | $D027-$D02E | Sprite colours 0-7. |
143
+
144
+ ## SID ($D400-$D41C)
145
+
146
+ - Voices 1-3: freq ($D400/$01, $D407/$08, $D40E/$0F), pulse width ($D402-$D403 etc.), control ($D404,$D40B,$D412), ADSR ($D405-$D406 etc.).
147
+ - Filter: cutoff ($D415-$D416), resonance/mix ($D417), mode+volume ($D418).
148
+ - Extras: paddles ($D419-$D41A), noise/LFSR ($D41B), envelope 3 output ($D41C).
149
+ - Mirrors: $D500-$D7FF (SID image), colour RAM $D800-$DBFF.
150
+
151
+ ## CIA #1 ($DC00-$DC0F)
152
+
153
+ | Address | Role |
154
+ | --- | --- |
155
+ | $DC00 | Port A: keyboard columns, joystick A, paddles select. |
156
+ | $DC01 | Port B: keyboard rows, joystick B, timer outputs. |
157
+ | $DC02-$DC03 | DDR for ports. |
158
+ | $DC04-$DC07 | Timers A/B low/high. |
159
+ | $DC08-$DC0B | Time-of-day clock (tenths, sec, min, hour). |
160
+ | $DC0C | Serial buffer. |
161
+ | $DC0D | IRQ control (FLAG1, serial, TOD alarm, timers). |
162
+ | $DC0E-$DC0F | Timer control (frequency, one-shot, toggle, start). |
163
+
164
+ ## CIA #2 ($DD00-$DD0F)
165
+
166
+ | Address | Role |
167
+ | --- | --- |
168
+ | $DD00 | Port A: serial bus lines, VIC bank select, user port. |
169
+ | $DD01 | Port B: user/RS-232 control lines. |
170
+ | $DD02-$DD03 | DDR for ports. |
171
+ | $DD04-$DD07 | Timers A/B. |
172
+ | $DD08-$DD0B | Time-of-day clock. |
173
+ | $DD0C | Serial buffer. |
174
+ | $DD0D | NMI control (serial, timers). |
175
+ | $DD0E-$DD0F | Timer control (same layout as CIA1). |
176
+
177
+ ## Miscellaneous
178
+
179
+ - $DE00-$DFFF: Reserved expansion I/O.
180
+ - Sprite pointers: `$07F8-$07FF`, value Γ— 64 (+ bank) gives sprite data address.
181
+ - To map sprite 0 to `$02C0`: `POKE 1024+1016,11` (pointer 11 β‡’ `$02C0`).
182
+ - Colour RAM: `$D800-$DBFF`, lower nybble only.
183
+
184
+ ---
185
+
186
+ This layout keeps the essential Commodore 64 addresses compact for LLM consumption while retaining full coverage of the supplied map.
@@ -0,0 +1,31 @@
1
+ # Commodore MPS β€” Bitmap Images (Bit Image Mode)
2
+
3
+ **Enter:** `CHR$(8)` | **Exit:** `CHR$(15)` (or any printable char)
4
+ **Data model:** 1 byte per **column**, **7 active bits** (LSB=top). **Set bit7=1** (add 128) so data prints. Typical ~60 dpi H, 72 dpi V. Up to ~480 dots per line.
5
+
6
+ ## Commands
7
+
8
+ | Action | Bytes to send | Notes |
9
+ |:--|:--|:--|
10
+ | Enter Bit Image | `CHR$(8)` | Subsequent bytes are columns |
11
+ | Repeat next data byte | `CHR$(26);CHR$(n);CHR$(byte)` | Repeats `byte` **n** times |
12
+ | Position by dots | `CHR$(27);CHR$(16);HP;LP` | Absolute dot column 0–479 |
13
+ | Exit Bit Image | `CHR$(15)` | Or send a printable character |
14
+
15
+ ## Minimal pattern example
16
+
17
+ ```basic
18
+ 10 OPEN1,4
19
+ 20 A$="":FOR I=1 TO 16:READ B:A$=A$+CHR$(B):NEXT
20
+ 30 PRINT#1,CHR$(8);A$;A$;A$; : REM 16 columns Γ— 3 rows
21
+ 40 PRINT#1,CHR$(15); : PRINT#1,CHR$(12):CLOSE1
22
+ 50 DATA 136,148,162,193,162,148,136,136,156,186,255,186,156,136,235,136
23
+ ```
24
+
25
+ **Tips**
26
+
27
+ - Pre-add **128** to each data byte (bit7=1) before sending.
28
+ - For vertical tiling, reprint the same 16 columns with CR/LF between rows.
29
+ - Keep within line buffer; printer auto-prints when ~480 dots are filled.
30
+
31
+ **Cross‑ref:** Basic text controls in `printer-commodore.md`; overview in `printer-spec.md`.
@@ -0,0 +1,28 @@
1
+ # Commodore MPS Printing (Text) β€” PETSCII + MPS Protocol
2
+
3
+ **Device:** `4` | **Secondary address (sa):** `0`=upper/graphics (default), `7`=lower/upper.
4
+ **Open/Print/Close:** `OPEN ch,4[,sa]` β†’ `PRINT#ch, ...` β†’ `CLOSE ch` (or `CMD ch` to route `PRINT`/`LIST`).
5
+
6
+ ## Controls (concise)
7
+
8
+ | Feature | Code (send via `PRINT#`) | Notes |
9
+ |:--|:--|:--|
10
+ | Standard width | `CHR$(15)` | Also exits Bit Image Mode |
11
+ | Double width | `CHR$(14)` | Affects subsequent text |
12
+ | Reverse video ON/OFF | `CHR$(18)` / `CHR$(146)` | Invert foreground/background |
13
+ | Cursor mode local (graphic/business) | `CHR$(145)` / `CHR$(17)` | Temporary charset toggles until CR |
14
+ | Carriage return / line feed / form feed | `CHR$(13)` / `CHR$(10)` / `CHR$(12)` | Use CR+LF if overprinting occurs |
15
+ | Horizontal tab | `CHR$(9)` | Tab stops |
16
+ | Position by columns | `CHR$(16);CHR$(n)` | `n` = column (0–79 standard) |
17
+ | Position by dots | `CHR$(27);CHR$(16);HP;LP` | Dot address = `(HP<<8)|LP` (0–479) |
18
+ | Bit Image Mode (enter/exit) | `CHR$(8)` / `CHR$(15)` | See bitmap doc for data rules |
19
+
20
+ ### Quick examples
21
+
22
+ ```basic
23
+ 10 OPEN1,4,7
24
+ 20 PRINT#1,CHR$(27);"-";CHR$(1);"UNDERLINED";CHR$(27);"-";CHR$(0)
25
+ 30 PRINT#1,CHR$(16);CHR$(20);"COL 20",CHR$(13);CHR$(10);CHR$(12):CLOSE1
26
+ ```
27
+
28
+ **See also:** `printer-commodore-bitmap.md` for images and repetition (`CHR$(26)`), and `printer-spec.md` for routing & differences.
@@ -0,0 +1,29 @@
1
+ # Epson FX-80 (ESC/P) β€” Bitmap Graphics
2
+
3
+ **Data model:** 1 byte per **column**, **8 dots** (MSB=top). Send graphics command + **byte count** `(n + 256*m)` then data. Set line spacing for 8‑dot rows, e.g., `ESC A 8`.
4
+
5
+ ## Graphics commands
6
+
7
+ | Mode | Sequence | Density (H) |
8
+ |:--|:--|:--|
9
+ | Normal | `ESC K n m ...data...` | ~60 dpi |
10
+ | Double | `ESC L n m ...` | ~120 dpi |
11
+ | Double (hi‑speed)* | `ESC Y n m ...` | ~120 dpi (maps to L on some emus) |
12
+ | Quadruple | `ESC Z n m ...` | ~240 dpi |
13
+ | Explicit | `ESC * d n m ...` | `d`=0:60,1:120,2:120(hi),3:240,4:80,5:72,6:90 dpi |
14
+ | 9‑pin strips | `ESC ^ d n m h1 l1 ...` | `d` in {0,1} |
15
+
16
+ \* Ultimate‑II may treat `Y` as `L`. Always match `n,m` to **exact** data length.
17
+
18
+ ### Minimal example
19
+
20
+ ```basic
21
+ 10 OPEN1,4
22
+ 20 A$=CHR$(27)+"K"+CHR$(16)+CHR$(0)
23
+ 30 FOR I=1 TO 16:READ B:A$=A$+CHR$(B):NEXT
24
+ 40 PRINT#1,CHR$(27);"A";CHR$(8) : REM 8/72"
25
+ 50 PRINT#1,A$;A$;A$; : PRINT#1,CHR$(12):CLOSE1
26
+ 60 DATA 60,66,129,129,129,66,60,24,60,126,255,126,60,24,235,24
27
+ ```
28
+
29
+ **Cross‑ref:** Text controls `printer-epson.md`; overview `printer-spec.md`.
@@ -0,0 +1,30 @@
1
+ # Epson FX-80 (ESC/P) β€” Text Controls
2
+
3
+ **Protocol:** ASCII with ESC sequences (`ESC` = `CHR$(27)`).
4
+
5
+ ## Controls (concise)
6
+
7
+ | Feature | ESC/P sequence | Notes |
8
+ |:--|:--|:--|
9
+ | Reset | `ESC @` | Clear modes between jobs |
10
+ | Pitch | `ESC M` (12 cpi), `ESC P` (10 cpi) | |
11
+ | Width | `SO` (`CHR$(14)`) on / `DC4` (`CHR$(20)`) off, or `ESC W n` | `n=1` on, `0` off |
12
+ | Condensed | `SI` (`CHR$(15)`) on / `DC2` (`CHR$(18)`) off | |
13
+ | Bold | `ESC E` on / `ESC F` off | |
14
+ | Italic | `ESC 4` on / `ESC 5` off | |
15
+ | Underline | `ESC - n` | `n=1` on, `0` off |
16
+ | Quality | `ESC x n` | `n=1` NLQ, `0` Draft |
17
+ | Line spacing | `ESC 0/1/2`, `ESC 3 n`, `ESC A n` | `n` in 1/216" or 1/72" |
18
+ | Tabs/margins | `ESC D` (HT), `ESC B` (VT), `ESC l` (left), `ESC Q` (right) | |
19
+ | Paper | `LF=10`, `CR=13`, `FF=12`, `ESC J n` (fwd n/216"), `ESC j n` (rev n/216") | |
20
+
21
+ ### Example
22
+
23
+ ```basic
24
+ 10 OPEN1,4
25
+ 20 PRINT#1,CHR$(27);"@";CHR$(27);"x";CHR$(1);CHR$(27);"M"
26
+ 30 PRINT#1,CHR$(27);"-";CHR$(1);"UNDER";CHR$(27);"-";CHR$(0)
27
+ 40 PRINT#1,CHR$(12):CLOSE1
28
+ ```
29
+
30
+ **Cross‑ref:** Bitmap (`printer-epson-bitmap.md`); overview & routing (`printer-spec.md`).
@@ -0,0 +1,29 @@
1
+ # Printing Prompts and Routing (for LLM prompt construction)
2
+
3
+ ## Routing
4
+
5
+ - Unspecified or unknown printer β†’ **Commodore MPS** (PETSCII).
6
+ - Mentions β€œCommodore”, β€œMPS” β†’ use Commodore docs.
7
+ - Mentions β€œEpson”, β€œFX”, β€œESC/P” β†’ use Epson docs.
8
+
9
+ ## Prompt templates
10
+
11
+ **Text (Commodore/Epson)**
12
+ > Print the following text on my [Commodore|Epson] printer: <text>. Ensure CR/LF and page eject.
13
+
14
+ **Bitmap (Commodore/Epson)**
15
+ > Print this bitmap at [density]. Provide columns as bytes and desired repeats/line spacing.
16
+
17
+ **Custom chars (Commodore only)**
18
+ > Define downloadable chars (DLL) and print <text>.
19
+
20
+ ## Tooling guidance
21
+
22
+ - Always `OPEN ch,4[,sa]` β†’ `PRINT#` β†’ `CLOSE ch`.
23
+ - Add `FF` (`CHR$(12)`) at job end for eject.
24
+ - Commodore bitmap: enter `CHR$(8)`, **repeat** with `CHR$(26)`, **exit** with `CHR$(15)`; **bit7 must be 1** in data.
25
+ - Epson bitmap: choose `ESC K/L/Y/Z/*/^`; compute `(n,m)` length; set `ESC A 8` for 8‑dot rows.
26
+
27
+ ## Cross‑refs
28
+
29
+ See `printer-spec.md` (overview), `printer-commodore*.md`, `printer-epson*.md` for details.
@@ -0,0 +1,180 @@
1
+ # Printing with Commodore MPS and Epson FX
2
+
3
+ **Scope:** C64 β†’ Printer via serial device **4**. Two protocols:
4
+
5
+ - **Commodore MPS** (PETSCII + MPS-801 protocol; all later MPS follow this)
6
+ - **Epson FX (ESC/P)** (ASCII + ESC sequences; widely compatible)
7
+
8
+ **Defaults & Routing:** If user/printer is unspecified β†’ **Commodore MPS**.
9
+ See `printer-prompts.md` for routing logic and prompt templates.
10
+
11
+ ---
12
+
13
+ ## Quick Start β€” Text Output Examples
14
+
15
+ ### Commodore BASIC
16
+
17
+ ```basic
18
+ 10 OPEN1,4,0 : REM Commodore MPS, PETSCII upper/graphics (sa=0)
19
+ 20 PRINT#1,"HELLO"
20
+ 30 PRINT#1,CHR$(13);CHR$(10)
21
+ 40 PRINT#1,CHR$(12)
22
+ 50 CLOSE1
23
+ ```
24
+
25
+ ### Epson FX BASIC
26
+
27
+ ```basic
28
+ 10 OPEN1,4 : REM Epson FX (ESC/P), ASCII
29
+ 20 PRINT#1,CHR$(27);"E";"BOLD ON";CHR$(27);"F"
30
+ 30 PRINT#1,"HELLO"
31
+ 40 PRINT#1,CHR$(12)
32
+ 50 CLOSE1
33
+ ```
34
+
35
+ ---
36
+
37
+ ## ✳️ Writing Assembly Code to Talk to the Printer
38
+
39
+ The C64 KERNAL provides complete device-independent I/O through standardized entry points.
40
+
41
+ ### (A) Commodore BASIC Equivalent in Assembly
42
+
43
+ ```asm
44
+ ; Print "HELLO" to printer device #4 via KERNAL
45
+
46
+ lda #4 ; Device number (printer)
47
+ ldx #0 ; Secondary address
48
+ ldy #1 ; Logical file number
49
+ jsr $ffba ; SETLFS
50
+
51
+ lda #<msg
52
+ ldx #>msg
53
+ ldy #5 ; Length of message
54
+ jsr $ffbd ; SETNAM
55
+
56
+ jsr $ffc0 ; OPEN
57
+ lda #1
58
+ jsr $ffc9 ; CHKOUT (select output channel)
59
+
60
+ ldx #0
61
+ next:
62
+ lda msg,x
63
+ jsr $ffd2 ; CHROUT (send character)
64
+ inx
65
+ cpx #5
66
+ bne next
67
+
68
+ jsr $ffcc ; CLRCHN (restore I/O)
69
+ lda #1
70
+ jsr $ffc3 ; CLOSE
71
+ rts
72
+
73
+ msg: .text "HELLO"
74
+ ```
75
+
76
+ ### (B) Epson FX Version in Assembly
77
+
78
+ Same code as above, but `msg` should contain **ASCII** (not PETSCII) characters.
79
+ For example, to print bold text before HELLO:
80
+
81
+ ```asm
82
+ msg: .byte 27,"E",'H','E','L','L','O',27,"F"
83
+ ```
84
+
85
+ ### Relevant KERNAL API Calls
86
+
87
+ | Routine | Addr | Purpose |
88
+ |:--|:--|:--|
89
+ | **SETLFS** | `$FFBA` | Define Logical File, Device, Secondary Address |
90
+ | **SETNAM** | `$FFBD` | Define Filename/Command String |
91
+ | **OPEN** | `$FFC0` | Open logical file on device |
92
+ | **CHKOUT** | `$FFC9` | Select output channel |
93
+ | **CHROUT** | `$FFD2` | Send single character to output |
94
+ | **CLRCHN** | `$FFCC` | Restore default I/O devices |
95
+ | **CLOSE** | `$FFC3` | Close logical file |
96
+ | **READST** | `$FFB7` | Read status flags (I/O errors, device busy) |
97
+
98
+ ---
99
+
100
+ ## 🧩 Printer Command Cheat Sheet β€” Commodore & Epson (BASIC + Assembly)
101
+
102
+ | Operation | Commodore BASIC | Commodore Assembly (hex) | Epson FX BASIC | Epson FX Assembly (hex) |
103
+ |:--|:--|:--|:--|:--|
104
+ | **Reset / Init** | β€” | β€” | `ESC @` | `1B 40` |
105
+ | **Carriage Return** | `CHR$(13)` | `0D` | `CHR$(13)` | `0D` |
106
+ | **Line Feed** | `CHR$(10)` | `0A` | `CHR$(10)` | `0A` |
107
+ | **Form Feed / Page Eject** | `CHR$(12)` | `0C` | `CHR$(12)` | `0C` |
108
+ | **Horizontal Tab** | `CHR$(9)` | `09` | `CHR$(9)` | `09` |
109
+ | **Standard Width** | `CHR$(15)` | `0F` | `DC4` / `ESC W 0` | `14` / `1B 57 00` |
110
+ | **Double Width** | `CHR$(14)` | `0E` | `SO` / `ESC W 1` | `0E` / `1B 57 01` |
111
+ | **Condensed / Elite (12 cpi)** | β€” | β€” | `ESC M` | `1B 4D` |
112
+ | **Pica (10 cpi)** | β€” | β€” | `ESC P` | `1B 50` |
113
+ | **Bold ON / OFF** | β€” | β€” | `ESC E` / `ESC F` | `1B 45` / `1B 46` |
114
+ | **Italic ON / OFF** | β€” | β€” | `ESC 4` / `ESC 5` | `1B 34` / `1B 35` |
115
+ | **Underline ON / OFF** | β€” | β€” | `ESC - 1` / `ESC - 0` | `1B 2D 01` / `1B 2D 00` |
116
+ | **Reverse Video ON / OFF** | `CHR$(18)` / `CHR$(146)` | `12` / `92` | β€” | β€” |
117
+ | **Set Line Spacing (nΓ—1/72")** | β€” | β€” | `ESC A n` | `1B 41 nn` |
118
+ | **Set Left Margin** | β€” | β€” | `ESC l n` | `1B 6C nn` |
119
+ | **Set Right Margin** | β€” | β€” | `ESC Q n` | `1B 51 nn` |
120
+ | **Horizontal Position (col)** | `CHR$(16);CHR$(n)` | `10 nn` | `ESC $ nL nH` | `1B 24 nL nH` |
121
+ | **Horizontal Position (dots)** | `ESC(27);CHR$(16);HP;LP` | `1B 10 HP LP` | `ESC $ nL nH` | `1B 24 nL nH` |
122
+ | **Enter Bit Image Mode** | `CHR$(8)` | `08` | `ESC K/L/Y/Z/*/^ n m ...` | `1B 4B/4C/59/5A/2A/5E nn mm ...` |
123
+ | **Repeat Next Data Byte (MPS only)** | `CHR$(26);CHR$(n);CHR$(byte)` | `1A nn dd` | β€” | β€” |
124
+ | **Exit Bit Image Mode** | `CHR$(15)` | `0F` | Any printable char or `LF` | β€” |
125
+ | **Graphics Data Format** | 7 bits/byte (**bit7=1**) | β€” | 8 bits/byte (MSB=top) | β€” |
126
+ | **Vertical Line Spacing (8-dot rows)** | CR + LF | `0D 0A` | `ESC A 8` | `1B 41 08` |
127
+ | **Switch Charset (upper/lower)** | `sa=0` or `7` | β€” | `ESC t n` | `1B 74 nn` |
128
+ | **Reset / End Job** | `CLOSE ch` | β€” | `ESC @` + `FF` + `CLOSE ch` | `1B 40 0C` |
129
+
130
+ ---
131
+
132
+ **Notes**
133
+
134
+ - Always `OPEN ch,4[,sa]` β†’ `PRINT#` β†’ `CLOSE ch`.
135
+ - Add `CHR$(12)` (Form Feed) before closing to eject the page.
136
+ - For MPS bitmap output, add **128** to each data byte (bit7=1).
137
+ - For Epson, compute `(n + 256Β·m)` bytes per graphics line.
138
+ - `$033C–$03FB` (cassette buffer) can store small print buffers.
139
+
140
+ **Cross‑refs:**
141
+ [`printer-commodore.md`](printer-commodore.md) Β· [`printer-commodore-bitmap.md`](printer-commodore-bitmap.md) Β· [`printer-epson.md`](printer-epson.md) Β· [`printer-epson-bitmap.md`](printer-epson-bitmap.md) Β· [`printer-prompts.md`](printer-prompts.md)
142
+
143
+ ---
144
+
145
+ ## Protocol Differences (critical)
146
+
147
+ - **Character set:** MPS expects **PETSCII**; Epson expects **ASCII** with ESC/P sequences.
148
+ - **Mode switching:** MPS uses single-byte PETSCII controls; Epson uses multi-byte ESC (27) commands.
149
+ - **Graphics:** MPS Bit Image = 7-dot columns (bit7=1); Epson = 8-dot columns `(n,m)` pairs.
150
+ - **Line endings:** Always send CR (13); often LF (10). FF (12) for page eject.
151
+
152
+ ---
153
+
154
+ ## Commodore MPS Essentials (Text)
155
+
156
+ - **Open:** `OPEN ch,4[,sa]` (`sa=0` upper/graphics, `7` lower/upper).
157
+ - **Print:** `PRINT#ch,…` or `CMD ch`.
158
+ - **Close:** `CLOSE ch`.
159
+ - **Bit Image:** Enter `CHR$(8)`; repeat `CHR$(26);count;byte`; exit `CHR$(15)`.
160
+
161
+ ---
162
+
163
+ ## Epson FX Essentials (Text)
164
+
165
+ - **Pitch:** `ESC M` (12 cpi), `ESC P` (10 cpi). **Bold:** `ESC E`/`ESC F`.
166
+ - **Underline:** `ESC - n`. **Spacing:** `ESC A n`. **Reset:** `ESC @`.
167
+
168
+ ---
169
+
170
+ ## Graphics Summary
171
+
172
+ - **MPS:** 7 dots/byte; bit7=1; β‰ˆ60Γ—72 dpi; max ~480 dots/line.
173
+ - **Epson:** 8 dots/byte; multiple densities via `ESC K/L/Y/Z/*/^`; use `ESC A 8` for 8-dot rows.
174
+
175
+ ---
176
+
177
+ ## Emulation Notes
178
+
179
+ - **C64 Ultimate Printer Emulation:** supports both PETSCII (MPS) and ESC/P (Epson).
180
+ Ignores advanced DLL commands; `ESC Y` behaves like `ESC L`. Prefer FF (12) for eject.