c64bridge 0.9.2 → 1.0.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.
- package/AGENTS.md +24 -3
- package/README.md +271 -161
- package/data/basic/rom-routines.md +269 -0
- package/data/context/bootstrap.md +1 -1
- 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/dist/.tsbuildinfo +1 -1
- package/dist/c64Client.js +127 -12
- package/dist/config.js +34 -8
- package/dist/device.js +75 -45
- package/dist/mcp-server.js +28 -8
- package/dist/platform.js +13 -2
- package/dist/rag/knowledgeIndex.js +54 -9
- package/dist/rag/resourceUris.js +2 -0
- package/dist/tools/audio.js +1 -1
- package/dist/tools/developer.js +6 -6
- package/dist/tools/graphics.js +4 -4
- package/dist/tools/input.js +129 -12
- package/dist/tools/machineControl.js +85 -6
- package/dist/tools/memory.js +1 -1
- package/dist/tools/meta/index.js +1 -1
- package/dist/tools/programRunners.js +5 -5
- package/dist/tools/rag.js +1 -1
- package/dist/tools/registry/batch.js +1 -1
- package/dist/tools/registry/config.js +5 -5
- package/dist/tools/registry/disk.js +2 -2
- package/dist/tools/registry/drive.js +2 -2
- package/dist/tools/registry/graphics.js +2 -2
- package/dist/tools/registry/memory.js +2 -2
- package/dist/tools/registry/platform.js +7 -5
- package/dist/tools/registry/program.js +5 -5
- package/dist/tools/registry/rag.js +1 -1
- package/dist/tools/registry/sound.js +4 -4
- package/dist/tools/registry/system.js +13 -3
- package/dist/tools/storage.js +1 -1
- package/doc/c64u/c64-openapi.yaml +1130 -774
- package/doc/developer.md +3 -2
- package/doc/u2/u2-openapi.yaml +1192 -0
- package/generated/c64/index.js +142 -9
- package/generated/openapi/c64u/index.js +1117 -0
- package/generated/openapi/u2/index.js +929 -0
- package/mcp/resources.json +60 -7
- package/mcp/schemas/c64_graphics.schema.json +3 -3
- package/mcp/schemas/c64_input.schema.json +247 -6
- package/mcp/schemas/c64_memory.schema.json +3 -3
- package/mcp/schemas/c64_program.schema.json +3 -3
- package/mcp/schemas/c64_select_backend.schema.json +2 -0
- package/mcp/schemas/c64_system.schema.json +41 -1
- package/mcp/server.json +1 -1
- package/mcp/tools.json +382 -41
- package/mcp.json +21 -5
- package/package.json +14 -8
- package/scripts/mockC64Server.mjs +40 -0
- package/scripts/prepare-release.mjs +13 -2
- package/scripts/update-readme.ts +19 -30
- package/server.json +2 -2
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# C64 BASIC ROM Routines Memory Map — Compact ($A000-$BFFF, $E000-$E4D2)
|
|
2
|
+
|
|
3
|
+
> Purpose: Token-efficient reference for Commodore 64 BASIC V2 ROM routines, tables, parser/evaluator helpers, numeric/string machinery, statement/function dispatch, and C64-specific BASIC continuation code.
|
|
4
|
+
> Format: Address-first tables; **bold** names indicate the most reusable entry points for machine-language or MCP tooling.
|
|
5
|
+
> Conventions: A=Accumulator, X,Y=Index, C=Carry; “—” = not applicable.
|
|
6
|
+
> Related memory maps: `../memory/memory-map.md`, `../memory/low-memory-map.md`, `../kernal/rom-routines.md`, `../io/io-spec.md`.
|
|
7
|
+
|
|
8
|
+
## Legend
|
|
9
|
+
|
|
10
|
+
Class: A=safe helper, B=usable with guardrails, C=interpreter-coupled, D=non-returning/control-flow, data=table/constant.
|
|
11
|
+
|
|
12
|
+
## Direct-Use Rules
|
|
13
|
+
|
|
14
|
+
- BASIC ROM must be banked in (`$0001` LORAM+HIRAM set). KERNAL ROM must also be visible for I/O and error reporting.
|
|
15
|
+
- Many failures jump to `$A437` (`ERROR`) rather than returning a status code.
|
|
16
|
+
- Prefer KERNAL APIs for files/devices and dynamic keyboard or tokenized program install for statements.
|
|
17
|
+
- Best reusable BASIC targets: `FRMEVL`, `FRMNUM`, `GETBYT`, `GETADR`, `PTRGET`, `FOUT`, `MOVFM`, `MOVMF`, `LNKPRG`, `CLR`.
|
|
18
|
+
- Avoid direct statement entries unless a wrapper controls `TXTPTR`, stack, BASIC vectors, error recovery, and runtime pointers.
|
|
19
|
+
|
|
20
|
+
## Essential BASIC State
|
|
21
|
+
|
|
22
|
+
| Address | Decimal | Name | Function | Notes |
|
|
23
|
+
|:--|:--|:--|:--|:--|
|
|
24
|
+
| `$000C` | 12 | DIMFLG | Array allocation/reference flag | Used by `PTRGET`. |
|
|
25
|
+
| `$000D` | 13 | VALTYP | Current type | `$00` numeric, `$FF` string. |
|
|
26
|
+
| `$000E` | 14 | INTFLG | Numeric subtype | `$00` float, `$80` integer. |
|
|
27
|
+
| `$0014–$0015` | 20–21 | LINNUM | Line/address/number temp | Used by `PEEK`, `POKE`, `WAIT`, `SYS`. |
|
|
28
|
+
| `$0016–$0021` | 22–33 | TEMPPT/TEMPST | Temporary string descriptor stack | Three 3-byte descriptors. |
|
|
29
|
+
| `$002B–$002C` | 43–44 | **TXTTAB** | BASIC program start | Normally `$0801`. |
|
|
30
|
+
| `$002D–$002E` | 45–46 | **VARTAB** | Scalar variable table start | Updated after program changes. |
|
|
31
|
+
| `$002F–$0030` | 47–48 | **ARYTAB** | Array table start | Follows scalars. |
|
|
32
|
+
| `$0031–$0032` | 49–50 | **STREND** | End of arrays / free RAM start | Moves upward. |
|
|
33
|
+
| `$0033–$0034` | 51–52 | **FREETOP** | Bottom of string heap | Strings grow downward. |
|
|
34
|
+
| `$0037–$0038` | 55–56 | **MEMSIZ** | BASIC memory top | Lower then `CLR` to reserve RAM. |
|
|
35
|
+
| `$0039–$003A` | 57–58 | CURLIN | Current BASIC line | High byte `$FF` = direct mode. |
|
|
36
|
+
| `$0041–$0042` | 65–66 | DATPTR | Current DATA item pointer | Reset by `RESTORE`. |
|
|
37
|
+
| `$0045–$0048` | 69–72 | VARNAM/VARPNT | Current variable name/value pointer | Set by `PTRGET`. |
|
|
38
|
+
| `$0050–$0052` | 80–82 | DSCPNT | String descriptor pointer/temp | String functions. |
|
|
39
|
+
| `$0061–$0066` | 97–102 | **FAC1** | Primary floating-point accumulator | Exponent, mantissa, sign. |
|
|
40
|
+
| `$0069–$006E` | 105–110 | FAC2/ARG | Secondary FP accumulator | Arithmetic argument. |
|
|
41
|
+
| `$0070` | 112 | FACOV | FP rounding byte | Used by `ROUND`. |
|
|
42
|
+
| `$0073–$008A` | 115–138 | **CHRGET/CHRGOT** | BASIC scanner in zero page | `CHRGOT` entry at `$0079`. |
|
|
43
|
+
| `$007A–$007B` | 122–123 | **TXTPTR** | BASIC text pointer | Parser/evaluator input. |
|
|
44
|
+
| `$008B–$008F` | 139–143 | RNDX | RND seed | Five-byte FP seed. |
|
|
45
|
+
| `$0300–$030B` | 768–779 | BASIC vectors | Error, warm start, tokenize, LIST, execute, evaluate | Copied from `$E447`. |
|
|
46
|
+
| `$030C–$030F` | 780–783 | SYS save | A, X, Y, status for BASIC `SYS` | Restored after SYS returns. |
|
|
47
|
+
| `$0310–$0311` | 784–785 | USR vector | Target for `USR()` | Default illegal quantity. |
|
|
48
|
+
|
|
49
|
+
## ROM Landmarks
|
|
50
|
+
|
|
51
|
+
| Address | Decimal | Name | Function | Class | Notes |
|
|
52
|
+
|:--|:--|:--|:--|:--|:--|
|
|
53
|
+
| `$A000` | 40960 | Cold vector | Points to `$E394` | data | Do not execute as code. |
|
|
54
|
+
| `$A002` | 40962 | Warm vector | Points to `$E37B` | data | BASIC warm start. |
|
|
55
|
+
| `$A004` | 40964 | CBMBASIC | ROM signature | data | Identification text. |
|
|
56
|
+
| `$A00C` | 40972 | Command table | 35 statement addresses minus 1 | data | Token `$80–$A2`. |
|
|
57
|
+
| `$A052` | 41042 | Function table | 23 function addresses minus 1 | data | Token `$B4–$CA`. |
|
|
58
|
+
| `$A080` | 41088 | Operator table | Precedence + address minus 1 | data | Arithmetic, compare, logical. |
|
|
59
|
+
| `$A09E` | 41118 | Keyword table | Statement keywords | data | High bit marks final char. |
|
|
60
|
+
| `$A129` | 41257 | Reserved-word table | `TAB(`, `TO`, `SPC(`, etc. | data | Tokenizer metadata. |
|
|
61
|
+
| `$A140` | 41280 | Operator keyword table | `+ - * / ^ AND OR > = <` | data | Tokenizer metadata. |
|
|
62
|
+
| `$A14D` | 41293 | Function keyword table | `SGN` through `MID$` | data | Tokenizer metadata. |
|
|
63
|
+
| `$A19E` | 41374 | Error text | BASIC error message strings | data | Indexed by `$A328`. |
|
|
64
|
+
| `$A328` | 41768 | Error pointers | Pointers to error text | data | X = error index. |
|
|
65
|
+
| `$A364` | 41828 | Interpreter text | `OK`, `ERROR IN`, `READY`, `BREAK` | data | Screen messages. |
|
|
66
|
+
| `$BFED` | 49133 | EXP | EXP function body | A/B | Continues at `$E000`. |
|
|
67
|
+
| `$E000–$E4D2` | 57344–58578 | BASIC continuation | EXP/RND/trig, I/O wrappers, init, BASIC vectors | mixed | Located in ROM area often grouped with KERNAL. |
|
|
68
|
+
|
|
69
|
+
## Core Reusable Entries
|
|
70
|
+
|
|
71
|
+
| Address | Decimal | Name | Function | Args/Input | Output | Class | Notes |
|
|
72
|
+
|:--|:--|:--|:--|:--|:--|:--|:--|
|
|
73
|
+
| `$A533` | 42291 | **LNKPRG** | Relink tokenized BASIC program | Program at `TXTTAB` | Forward links rebuilt | B | Use after raw program writes. |
|
|
74
|
+
| `$A57C` | 42364 | CRUNCH | Tokenize input line | BASIC input-buffer state | Tokenized line | B/C | Easier: use keyboard injection. |
|
|
75
|
+
| `$A613` | 42515 | FNDLIN | Find BASIC line | `LINNUM` target | C set if found | B | Program table must be valid. |
|
|
76
|
+
| `$A65E` | 42590 | **CLR** | Clear variables/runtime/string heap | BASIC pointers valid | Runtime reset | B/C | Use after program/memory-bound changes. |
|
|
77
|
+
| `$A68E` | 42638 | STXTPT | Set text pointer to program start | `TXTTAB` valid | `TXTPTR=TXTTAB-1` | B/C | Prepares interpreter scan. |
|
|
78
|
+
| `$A717` | 42775 | LIST helper | Detokenize through output channel | Program text/current channel | Output text | C | Output-channel dependent. |
|
|
79
|
+
| `$AB1E` | 43806 | **STROUT** | Output zero/quote-terminated string | A/Y pointer | Characters output | B | Current output channel used. |
|
|
80
|
+
| `$AB47` | 43847 | CHR output wrapper | Output PETSCII char | A=byte | Character output | B/C | Prefer KERNAL `CHROUT`. |
|
|
81
|
+
| `$AD8A` | 44426 | **FRMNUM** | Evaluate numeric expression | `TXTPTR` at first char | FAC1 numeric | B | String result -> type error. |
|
|
82
|
+
| `$AD8D` | 44429 | **CHKNUM** | Require numeric result | `VALTYP` | Return or error | A | Type mismatch jumps to error. |
|
|
83
|
+
| `$AD8F` | 44431 | CHKSTR | Require string result | `VALTYP` | Return or error | A | Type mismatch jumps to error. |
|
|
84
|
+
| `$AD90` | 44432 | CHKVAL | Type check by carry | C clear=numeric, set=string | Return or error | A | Helper under `CHKNUM/CHKSTR`. |
|
|
85
|
+
| `$AD9E` | 44446 | **FRMEVL** | Evaluate any expression | `TXTPTR` at first char | FAC1 or string result; `VALTYP` | B | Most useful parser entry. |
|
|
86
|
+
| `$AEF7` | 44791 | CHKCLS | Require `)` | Scanner state | Advances or error | B | Syntax helper. |
|
|
87
|
+
| `$AEFA` | 44794 | CHKOPN | Require `(` | Scanner state | Advances or error | B | Syntax helper. |
|
|
88
|
+
| `$AEFD` | 44797 | CHKCOM | Require `,` | Scanner state | Advances or error | B | Syntax helper. |
|
|
89
|
+
| `$AEFF` | 44799 | SYNCHR | Require char in A | A=required char | Advances or error | B | Syntax helper. |
|
|
90
|
+
| `$B08B` | 45195 | **PTRGET** | Find/create variable | `TXTPTR` at var name | `VARPNT`, Y/A value address | B | May allocate or evaluate subscripts. |
|
|
91
|
+
| `$B1AA` | 45482 | FAC→int | Convert FAC1 to signed 16-bit | FAC1 | A=lo,Y=hi | A/B | Range-sensitive. |
|
|
92
|
+
| `$B391` | 45969 | **GIVAYF** | Signed int to FAC1 | A=hi,Y=lo | FAC1 | A | Values >32767 become negative. |
|
|
93
|
+
| `$B3A2` | 45986 | SNGFLT | Byte to FAC1 | Y=byte | FAC1 | A | Sets numeric result. |
|
|
94
|
+
| `$B487` | 46215 | STRLIT | Create string descriptor from literal | A/Y pointer | Temp string descriptor | B | String heap/temps apply. |
|
|
95
|
+
| `$B4F4` | 46324 | GETSPA | Allocate string space | A=bytes | X/Y pointer | B/C | May garbage collect or error. |
|
|
96
|
+
| `$B526` | 46374 | GARBA2 | Garbage collect string heap | BASIC string state | Compacted strings | C | Avoid unless runtime owned. |
|
|
97
|
+
| `$B6DB` | 46811 | FRETMS | Release temp string | A/Y descriptor | Temp stack updated | B/C | Descriptor discipline matters. |
|
|
98
|
+
| `$B79E` | 47006 | **GETBYT** | Parse byte expression | `TXTPTR` expression | X=`0..255` | B | Illegal quantity on range error. |
|
|
99
|
+
| `$B7EB` | 47083 | **GETNUM** | Parse `addr,byte` | `TXTPTR` expression | `$14/$15`, X=byte | B | Useful for POKE-style syntax. |
|
|
100
|
+
| `$B7F1` | 47089 | COMBYT | Parse comma then byte | Current char comma | X=byte | B | Calls comma check. |
|
|
101
|
+
| `$B7F7` | 47095 | **GETADR** | FAC1 to unsigned address | FAC1 | `$14/$15`, A/Y | A/B | `0..65535`. |
|
|
102
|
+
| `$BBA2` | 48034 | **MOVFM** | Load packed float to FAC1 | A/Y pointer | FAC1 | A/B | Read numeric variable/constant. |
|
|
103
|
+
| `$BBD4` | 48084 | **MOVMF** | Store FAC1 as packed float | X/Y destination, FAC1 | 5 bytes written | A/B | Floating scalar vars. |
|
|
104
|
+
| `$BC1B` | 48155 | ROUND | Round FAC1 | FAC1/FACOV | FAC1 | A | Numeric helper. |
|
|
105
|
+
| `$BC2B` | 48171 | SIGN | Sign of FAC1 | FAC1 | A=`0`,`1`,`$FF` | A | Zero/positive/negative. |
|
|
106
|
+
| `$BDDD` | 48605 | **FOUT** | FAC1 to ASCII | FAC1 | A/Y temp string pointer | A/B | Copy text immediately. |
|
|
107
|
+
|
|
108
|
+
## Math Helpers
|
|
109
|
+
|
|
110
|
+
| Address | Decimal | Name | Input | Output | Class | Notes |
|
|
111
|
+
|:--|:--|:--|:--|:--|:--|:--|
|
|
112
|
+
| `$BC39` | 48185 | SGN | FAC1 | FAC1 = -1/0/1 | A | Function token `$B4`. |
|
|
113
|
+
| `$BC58` | 48216 | ABS | FAC1 | FAC1 | A | Clears sign. |
|
|
114
|
+
| `$BCCC` | 48332 | INT | FAC1 | FAC1 | A | BASIC floor semantics. |
|
|
115
|
+
| `$B9EA` | 47594 | LOG | FAC1 > 0 | FAC1 | A/B | Domain errors jump to `ERROR`. |
|
|
116
|
+
| `$BF71` | 49009 | SQR | FAC1 >= 0 | FAC1 | A/B | Uses LOG/EXP path. |
|
|
117
|
+
| `$BFB4` | 49076 | NEGOP | FAC1 | -FAC1 | A | Unary negation. |
|
|
118
|
+
| `$BFED` | 49133 | EXP | FAC1 | FAC1 | A/B | Continues at `$E000`; overflow possible. |
|
|
119
|
+
| `$E097` | 57495 | RND | FAC1 argument | FAC1 | A/B | Positive advances, negative seeds, zero mixes time. |
|
|
120
|
+
| `$E264` | 57956 | COS | FAC1 radians | FAC1 | A/B | Adds PI/2, uses SIN. |
|
|
121
|
+
| `$E26B` | 57963 | SIN | FAC1 radians | FAC1 | A/B | Dispatch entry. |
|
|
122
|
+
| `$E2B4` | 58036 | TAN | FAC1 radians | FAC1 | A/B | SIN/COS division. |
|
|
123
|
+
| `$E30E` | 58126 | ATN | FAC1 | FAC1 radians | A/B | Polynomial approximation. |
|
|
124
|
+
|
|
125
|
+
## Statement Dispatch Entries
|
|
126
|
+
|
|
127
|
+
Statement entries assume live interpreter context unless noted. Prefer text/tokenized program execution over direct calls.
|
|
128
|
+
|
|
129
|
+
| Token | Command | Entry | Class | Direct-use note |
|
|
130
|
+
|:--|:--|:--|:--|:--|
|
|
131
|
+
| `$80` | END | `$A831` | D | Program termination. |
|
|
132
|
+
| `$81` | FOR | `$A742` | C | Requires FOR stack frame. |
|
|
133
|
+
| `$82` | NEXT | `$AD1E` | C | Requires matching FOR frame. |
|
|
134
|
+
| `$83` | DATA | `$A8F8` | C | Statement skipper. |
|
|
135
|
+
| `$84` | INPUT# | `$ABA5` | C | Prefer KERNAL channel I/O. |
|
|
136
|
+
| `$85` | INPUT | `$ABBF` | C | Editor/string context. |
|
|
137
|
+
| `$86` | DIM | `$B081` | C | Allocates arrays. |
|
|
138
|
+
| `$87` | READ | `$AC06` | C | Depends on `DATPTR`. |
|
|
139
|
+
| `$88` | LET | `$A9A5` | C | Prefer `FRMEVL` + `PTRGET` + store helper. |
|
|
140
|
+
| `$89` | GOTO | `$A8A0` | D | Interpreter flow. |
|
|
141
|
+
| `$8A` | RUN | `$A871` | D | Non-local flow. |
|
|
142
|
+
| `$8B` | IF | `$A928` | C | Interpreter-only. |
|
|
143
|
+
| `$8C` | RESTORE | `$A81D` | C | Resets DATA state. |
|
|
144
|
+
| `$8D` | GOSUB | `$A883` | C | Requires BASIC return frame. |
|
|
145
|
+
| `$8E` | RETURN | `$A8D2` | C | Requires GOSUB frame. |
|
|
146
|
+
| `$8F` | REM | `$A93B` | C | Statement skipper. |
|
|
147
|
+
| `$90` | STOP | `$A82F` | D | STOP/BREAK path. |
|
|
148
|
+
| `$91` | ON | `$A94B` | C | Interpreter-only. |
|
|
149
|
+
| `$92` | WAIT | `$B82D` | C | Can hang; avoid for MCP. |
|
|
150
|
+
| `$93` | LOAD | `$E168` | C | Prefer KERNAL `LOAD`. |
|
|
151
|
+
| `$94` | SAVE | `$E156` | C | Prefer KERNAL `SAVE`. |
|
|
152
|
+
| `$95` | VERIFY | `$E165` | C | Prefer KERNAL load/verify. |
|
|
153
|
+
| `$96` | DEF | `$B3B3` | C | DEF FN machinery. |
|
|
154
|
+
| `$97` | POKE | `$B824` | C | Prefer memory write or `GETNUM`. |
|
|
155
|
+
| `$98` | PRINT# | `$AA80` | C | Prefer KERNAL channel output. |
|
|
156
|
+
| `$99` | PRINT | `$AAA0` | C | Output context required. |
|
|
157
|
+
| `$9A` | CONT | `$A857` | D | Requires continuation state. |
|
|
158
|
+
| `$9B` | LIST | `$A69C` | C | Output-channel dependent. |
|
|
159
|
+
| `$9C` | CLR | `$A65E` | B/C | Useful after memory/program edits. |
|
|
160
|
+
| `$9D` | CMD | `$AA86` | C | Prefer KERNAL channel control. |
|
|
161
|
+
| `$9E` | SYS | `$E12A` | C | Parses BASIC `SYS`; direct ML should `JSR/JMP`. |
|
|
162
|
+
| `$9F` | OPEN | `$E1BE` | C | Prefer KERNAL `OPEN`. |
|
|
163
|
+
| `$A0` | CLOSE | `$E1C7` | C | Prefer KERNAL `CLOSE`. |
|
|
164
|
+
| `$A1` | GET | `$AB7B` | C | Assignment/string path. |
|
|
165
|
+
| `$A2` | NEW | `$A642` | D | Destructive. |
|
|
166
|
+
|
|
167
|
+
## Function Dispatch Entries
|
|
168
|
+
|
|
169
|
+
Function entries are normally called by the evaluator. Direct use is safest for simple FAC1 numeric helpers.
|
|
170
|
+
|
|
171
|
+
| Token | Function | Entry | Class | Direct-use note |
|
|
172
|
+
|:--|:--|:--|:--|:--|
|
|
173
|
+
| `$B4` | SGN | `$BC39` | A | FAC1 in/out. |
|
|
174
|
+
| `$B5` | INT | `$BCCC` | A | FAC1 in/out. |
|
|
175
|
+
| `$B6` | ABS | `$BC58` | A | FAC1 in/out. |
|
|
176
|
+
| `$B7` | USR | `$0310` | C | RAM vector. |
|
|
177
|
+
| `$B8` | FRE | `$B37D` | C | Can trigger GC. |
|
|
178
|
+
| `$B9` | POS | `$B39E` | C | Reads cursor/channel state. |
|
|
179
|
+
| `$BA` | SQR | `$BF71` | A/B | FAC1 non-negative. |
|
|
180
|
+
| `$BB` | RND | `$E097` | A/B | FAC1 argument. |
|
|
181
|
+
| `$BC` | LOG | `$B9EA` | A/B | FAC1 positive. |
|
|
182
|
+
| `$BD` | EXP | `$BFED` | A/B | Overflow possible. |
|
|
183
|
+
| `$BE` | COS | `$E264` | A/B | FAC1 radians. |
|
|
184
|
+
| `$BF` | SIN | `$E26B` | A/B | FAC1 radians. |
|
|
185
|
+
| `$C0` | TAN | `$E2B4` | A/B | FAC1 radians. |
|
|
186
|
+
| `$C1` | ATN | `$E30E` | A/B | FAC1 in/out. |
|
|
187
|
+
| `$C2` | PEEK | `$B80D` | C | Parser convention; ML should `LDA`. |
|
|
188
|
+
| `$C3` | LEN | `$B77C` | C | String argument convention. |
|
|
189
|
+
| `$C4` | STR$ | `$B465` | C | String descriptor result. |
|
|
190
|
+
| `$C5` | VAL | `$B7AD` | C | String parser state. |
|
|
191
|
+
| `$C6` | ASC | `$B78B` | C | Errors on empty string. |
|
|
192
|
+
| `$C7` | CHR$ | `$B6EC` | C | String descriptor result. |
|
|
193
|
+
| `$C8` | LEFT$ | `$B700` | C | String function convention. |
|
|
194
|
+
| `$C9` | RIGHT$ | `$B72C` | C | String function convention. |
|
|
195
|
+
| `$CA` | MID$ | `$B737` | C | String function convention. |
|
|
196
|
+
|
|
197
|
+
## Operator Dispatch Entries
|
|
198
|
+
|
|
199
|
+
| Operator | Entry | Precedence | Direct-use note |
|
|
200
|
+
|:--|:--|:--|:--|
|
|
201
|
+
| `+` | `$B86A` | `$79` | Prefer `FRMEVL`. |
|
|
202
|
+
| `-` | `$B853` | `$79` | Prefer `FRMEVL`. |
|
|
203
|
+
| `*` | `$BA2B` | `$7B` | Prefer `FRMEVL`. |
|
|
204
|
+
| `/` | `$BB12` | `$7B` | Prefer `FRMEVL`. |
|
|
205
|
+
| `^` | `$BF7B` | `$7D` | Prefer `FRMEVL`. |
|
|
206
|
+
| `AND` | `$AFE9` | low | Evaluator convention. |
|
|
207
|
+
| `OR` | `$AFE6` | low | Evaluator convention. |
|
|
208
|
+
| comparison | `$B016` | compare | Evaluator convention. |
|
|
209
|
+
| unary `-` | `$BFB4` | unary | FAC1 negation is reasonable. |
|
|
210
|
+
| `NOT` | `$AF0D` | unary | Evaluator convention. |
|
|
211
|
+
|
|
212
|
+
## C64-Specific BASIC Continuation (`$E000–$E4D2`)
|
|
213
|
+
|
|
214
|
+
| Address | Decimal | Name | Function | Class | Notes |
|
|
215
|
+
|:--|:--|:--|:--|:--|:--|
|
|
216
|
+
| `$E000` | 57344 | EXP continuation | Completes EXP from `$BFED` | A/B | Cross-ROM BASIC code. |
|
|
217
|
+
| `$E043` | 57411 | POLY1 | FP polynomial helper | B | FAC1/coefficient state. |
|
|
218
|
+
| `$E059` | 57433 | POLY2 | FP polynomial helper | B | Used by math functions. |
|
|
219
|
+
| `$E08D` | 57485 | RMULC | RND multiply constant | data | Five-byte FP. |
|
|
220
|
+
| `$E092` | 57490 | RADDC | RND add constant | data | Five-byte FP. |
|
|
221
|
+
| `$E097` | 57495 | RND | Random number function | A/B | FAC1 argument. |
|
|
222
|
+
| `$E0F9` | 57593 | BASIC/KERNAL I/O bridge | Checked CHKIN/CHKOUT/CHRIN/CHROUT/GETIN | C/D | May enter BASIC error path. |
|
|
223
|
+
| `$E12A` | 57642 | SYS | BASIC `SYS` parser/executor | C | Uses `$030C–$030F`. |
|
|
224
|
+
| `$E156` | 57686 | SAVE wrapper | BASIC `SAVE` statement | C | Prefer KERNAL API. |
|
|
225
|
+
| `$E165` | 57701 | VERIFY wrapper | BASIC `VERIFY` statement | C | Falls into LOAD path. |
|
|
226
|
+
| `$E168` | 57704 | LOAD wrapper | BASIC `LOAD` statement | C | May relink BASIC program. |
|
|
227
|
+
| `$E1BE` | 57790 | OPEN wrapper | BASIC `OPEN` statement | C | Prefer KERNAL API. |
|
|
228
|
+
| `$E1C7` | 57799 | CLOSE wrapper | BASIC `CLOSE` statement | C | Prefer KERNAL API. |
|
|
229
|
+
| `$E1D4` | 57812 | L/V/S parameter setup | Parse filename/LFN/dev/SA | C | For LOAD/SAVE/VERIFY. |
|
|
230
|
+
| `$E200` | 57856 | Get int to X | Parse comma + integer byte | B/C | Parser helper. |
|
|
231
|
+
| `$E206` | 57862 | Fetch/endline helper | Parser control-flow helper | D | Can unwind caller. |
|
|
232
|
+
| `$E20E` | 57870 | Check comma | Require comma | B/C | Parser helper. |
|
|
233
|
+
| `$E219` | 57881 | O/C parameter setup | Parse OPEN/CLOSE params | C | Sets KERNAL file state. |
|
|
234
|
+
| `$E264` | 57956 | COS | Cosine | A/B | FAC1 radians. |
|
|
235
|
+
| `$E26B` | 57963 | SIN | Sine | A/B | FAC1 radians. |
|
|
236
|
+
| `$E2B4` | 58036 | TAN | Tangent | A/B | FAC1 radians. |
|
|
237
|
+
| `$E30E` | 58126 | ATN | Arctangent | A/B | FAC1 in/out. |
|
|
238
|
+
| `$E37B` | 58235 | Warm BASIC | READY/warm-start path | D | Jump target, not subroutine. |
|
|
239
|
+
| `$E38B` | 58251 | Error message path | Print BASIC error and READY | D | X=error index. |
|
|
240
|
+
| `$E394` | 58260 | Cold BASIC | Power-on BASIC init | D | Reset/init path. |
|
|
241
|
+
| `$E3A2` | 58274 | CHRGET image | Source copied to `$0073` | data | Scanner code image. |
|
|
242
|
+
| `$E3BF` | 58303 | INIT | BASIC zero-page init | C/D | Copies `CHRGET`. |
|
|
243
|
+
| `$E422` | 58402 | Startup messages | Banner and bytes-free output | D | Boot path. |
|
|
244
|
+
| `$E447` | 58439 | BASIC vector table | Defaults for `$0300–$030B` | data | Error, warm, crunch, list, execute, evaluate. |
|
|
245
|
+
| `$E453` | 58451 | Copy BASIC vectors | Restore BASIC RAM vectors | B/C | Mostly init/recovery. |
|
|
246
|
+
| `$E460` | 58464 | Text constants | Startup/message text | data | Constants. |
|
|
247
|
+
|
|
248
|
+
## Compact Workflows
|
|
249
|
+
|
|
250
|
+
| Need | Preferred mechanism | Minimal sequence |
|
|
251
|
+
|:--|:--|:--|
|
|
252
|
+
| Evaluate expression | `FRMNUM`/`FRMEVL` | Set `TXTPTR` to first char, `JSR $AD8A` or `JSR $AD9E`, handle BASIC errors. |
|
|
253
|
+
| Numeric result as text | `FOUT` | FAC1 ready, `JSR $BDDD`, copy A/Y string immediately. |
|
|
254
|
+
| Parse byte/address syntax | `GETBYT`/`GETADR`/`GETNUM` | Use BASIC-compatible expression text and controlled `TXTPTR`. |
|
|
255
|
+
| Read/write numeric scalar | `PTRGET` + `MOVFM`/`MOVMF` | Set `TXTPTR` to var name; use returned `VARPNT`. |
|
|
256
|
+
| Install tokenized program | Raw write + `LNKPRG` + `CLR` | Write at `TXTTAB`, final next pointer `$0000`, `JSR $A533`, `JSR $A65E`. |
|
|
257
|
+
| Execute BASIC statement | Dynamic keyboard or normal interpreter | Avoid direct statement entries unless runtime/error context is controlled. |
|
|
258
|
+
| Reserve high RAM | Lower `MEMSIZ`, then `CLR` | Update `$37/$38`, `JSR $A65E`; keep ML/sprites above new top. |
|
|
259
|
+
|
|
260
|
+
## Avoid as General MCP APIs
|
|
261
|
+
|
|
262
|
+
| Entry | Reason |
|
|
263
|
+
|:--|:--|
|
|
264
|
+
| `$A437` | BASIC error path; non-returning for normal callers. |
|
|
265
|
+
| `$A7AE` | Main interpreter loop; full runtime context required. |
|
|
266
|
+
| `$A7ED` | Command dispatcher; token/stack conventions required. |
|
|
267
|
+
| `$E206` | May skip a return address at end-of-statement. |
|
|
268
|
+
| `$E37B`, `$E394` | Warm/cold BASIC entry paths, not subroutines. |
|
|
269
|
+
| Direct string allocation/GC | Safe only when descriptor stack and movable string heap are controlled. |
|
|
@@ -33,7 +33,7 @@ Do not assume the current backend is correct without checking
|
|
|
33
33
|
|
|
34
34
|
## Memory Map (default RAM layout)
|
|
35
35
|
|
|
36
|
-
For
|
|
36
|
+
For full details see `../memory/memory-map.md`. Use `../memory/low-memory-map.md` for zero page/pages 0-3, `../basic/rom-routines.md` for BASIC ROM routines, `../kernal/rom-routines.md` for KERNAL ROM routines, and `../io/io-spec.md` or `../io/cia-spec.md` for hardware registers.
|
|
37
37
|
|
|
38
38
|
- $0000–$00FF: Zero page
|
|
39
39
|
- $0100–$01FF: Stack
|
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 |
|