@henols/c64-re-tools 2.7.1 → 2.8.0-rc.2
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/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +23 -38
- package/skills/c64-assembler/scripts/assembler.ts +137 -17
- package/skills/c64-basic/SKILL.md +11 -31
- package/skills/c64-basic/scripts/basic.ts +4 -1
- package/skills/c64-development/SKILL.md +2 -2
- package/skills/c64-disk/SKILL.md +11 -32
- package/skills/c64-docs/SKILL.md +27 -45
- package/skills/c64-docs/references/page-types.md +20 -18
- package/skills/c64-docs/references/style.md +10 -4
- package/skills/c64-docs/scripts/docs.ts +13 -2
- package/skills/c64-docs/scripts/lib/reference.ts +47 -5
- package/skills/c64-knowledge/SKILL.md +138 -267
- package/skills/c64-knowledge/references/batches.md +48 -0
- package/skills/c64-knowledge/references/coverage.md +29 -0
- package/skills/c64-knowledge/references/source-knowledge.md +72 -0
- package/skills/c64-knowledge/references/start-screen.md +44 -0
- package/skills/c64-knowledge/scripts/knowledge.ts +266 -61
- package/skills/c64-knowledge/scripts/lib/check.ts +133 -0
- package/skills/c64-knowledge/scripts/lib/listing.ts +71 -8
- package/skills/c64-memory-map/SKILL.md +11 -32
- package/skills/c64-packer/SKILL.md +11 -31
- package/skills/c64-provenance/SKILL.md +43 -64
- package/skills/c64-provenance/scripts/lib/leftovers.ts +8 -3
- package/skills/c64-provenance/scripts/provenance.ts +65 -56
- package/skills/c64-reverse-engineering/SKILL.md +20 -47
- package/skills/c64-reverse-engineering/references/comment-check.md +42 -0
- package/skills/c64-reverse-engineering/references/versions.md +47 -0
- package/skills/c64-source/SKILL.md +48 -237
- package/skills/c64-source/references/export.md +50 -0
- package/skills/c64-source/references/loader.md +78 -0
- package/skills/c64-source/references/source-format.md +46 -0
- package/skills/c64-source/scripts/lib/export.ts +28 -13
- package/skills/c64-source/scripts/lib/loader.ts +4 -82
- package/skills/c64-source/scripts/lib/source.ts +3 -5
- package/skills/c64-source/scripts/source.ts +48 -51
- package/skills/c64-static-analysis/SKILL.md +52 -52
- package/skills/c64-static-analysis/scripts/lib/coverage.ts +55 -2
- package/skills/c64-static-analysis/scripts/lib/idioms.ts +43 -17
- package/skills/c64-static-analysis/scripts/static-analysis.ts +79 -15
- package/skills/c64-testing/SKILL.md +72 -58
- package/skills/c64-testing/references/recording-format.md +5 -80
- package/skills/c64-testing/references/scenario-format.md +4 -12
- package/skills/c64-testing/scripts/lib/play.ts +16 -8
- package/skills/c64-testing/scripts/lib/recording.ts +74 -9
- package/skills/c64-testing/scripts/lib/replay.ts +4 -0
- package/skills/c64-testing/scripts/lib/runs.ts +112 -1
- package/skills/c64-testing/scripts/lib/scenario.ts +12 -6
- package/skills/c64-testing/scripts/lib/start-screen.ts +27 -0
- package/skills/c64-testing/scripts/testing.ts +34 -13
- package/skills/c64-unpacker/SKILL.md +10 -30
- package/skills/emulator/SKILL.md +7 -36
- package/src/build-name.ts +12 -1
- package/src/c64.ts +16 -0
- package/src/knowledge/history.ts +8 -0
- package/src/knowledge/program.ts +84 -4
- package/src/knowledge/read.ts +46 -2
- package/src/knowledge/recording-files.ts +32 -0
- package/src/knowledge/schema.ts +3 -1
- package/src/knowledge/separate.ts +165 -11
- package/src/knowledge/start-screen.ts +99 -17
- package/src/knowledge/text.ts +2 -1
- package/src/knowledge/write.ts +15 -8
- package/src/loader.ts +167 -0
- package/src/native/decompiler/analyze.ts +7 -6
- package/src/native/decompiler/walk.ts +32 -2
- package/src/native/dxa.ts +4 -4
- package/src/native/types.ts +34 -4
- package/src/script.ts +102 -25
- package/skills/c64-export/SKILL.md +0 -63
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: c64-source
|
|
3
|
-
description: Generates ACME source code for a C64 program from the project knowledge. It checks that the source assembles to the same bytes as the program. It can also write a loader that sets the entry state of an unpacked program. It can also export the program as the start of a new program. The export is a new project with one value for each switch and without unused code. Use it to make a rebuild of a program. Use it when the source must show new names, comments, regions, modules, macros or patches of the knowledge. Use it to start a new
|
|
3
|
+
description: Generates ACME source code for a C64 program from the project knowledge. It checks that the source assembles to the same bytes as the program. It can also write a loader that sets the entry state of an unpacked program. It can also export the program as the start of a new program. The export is a new project with one value for each switch and without unused code. Use it to make a rebuild of a program. Use it when the source must show new names, comments, regions, modules, macros or patches of the knowledge. Use it when the user asks to "export the project", "start a new game from this rebuild" or "make a clean package of the code". It does not change the project knowledge. It does not build or test the program.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Generate source
|
|
@@ -56,12 +56,11 @@ To get the command list, run the script with no arguments.
|
|
|
56
56
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
57
57
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
58
58
|
- Write each file that you make for your work in `.c64-re-tools/local/` of the project. Git ignores that folder. Examples are results, batches, step files, runs, snapshots and memory dumps.
|
|
59
|
-
- The script refuses an `--out` path in `.c64-re-tools/knowledge
|
|
59
|
+
- The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
|
|
60
60
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
61
61
|
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
62
|
-
- A coverage map can stay in `.c64-re-tools/local/`.
|
|
63
|
-
-
|
|
64
|
-
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
62
|
+
- A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
|
|
63
|
+
- To keep a run as evidence, use the command that keeps a run. It copies the run, its results and its snapshot files into `runs/<name>/`, and it changes the paths in the copy. Then git keeps them, and another person can do the run again.
|
|
65
64
|
- A shell redirect (`>`) is relative to the working directory, not to the project folder. From the folder above the project, write `<folder>/.c64-re-tools/local/result.json`.
|
|
66
65
|
|
|
67
66
|
---
|
|
@@ -90,15 +89,15 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
90
89
|
### `generate --out <dir>`
|
|
91
90
|
|
|
92
91
|
The command writes the source files in `--out`. Then it checks them.
|
|
93
|
-
The folder `--out` gets only source files. The
|
|
94
|
-
The same knowledge always gives the same source.
|
|
92
|
+
The folder `--out` gets only source files. The same knowledge always gives the same source.
|
|
95
93
|
Do not edit the generated files. The next run writes over them. The values in `config.asm` are the one exception.
|
|
96
94
|
To make the source better, change the project knowledge. Then generate again.
|
|
95
|
+
`<skill>/references/source-format.md` gives the files, the names and the lines of the source.
|
|
97
96
|
|
|
98
97
|
`body` holds these fields:
|
|
99
98
|
|
|
100
99
|
- `result`: `PASS` when every check passes, else `FAIL`.
|
|
101
|
-
- `files`: the files that the command wrote, each with `out`, `bytes` and `sha256`.
|
|
100
|
+
- `files`: the files that the command wrote, each with `out`, `bytes` and `sha256`.
|
|
102
101
|
- `removed`: the files of an earlier run that the script removed.
|
|
103
102
|
- `instructions`, `dataBytes` and `undecodedBytes`.
|
|
104
103
|
- `labels`: `named` labels from the knowledge, and `generated` labels `l_xxxx`.
|
|
@@ -109,16 +108,22 @@ To make the source better, change the project knowledge. Then generate again.
|
|
|
109
108
|
- `dataOnly`: the knowledge has no entry, no routine, no code region and no executed address in the space.
|
|
110
109
|
- `entriesInData`: each `--entry` in a data region, with the `region` and its `origin`.
|
|
111
110
|
- `asBytes`: the instructions that the source has as bytes.
|
|
112
|
-
- `notExecuted`: with coverage, the count of instructions that no run executed, and their ranges.
|
|
111
|
+
- `notExecuted`: with coverage, the count of instructions that no run executed, and their ranges. Each range has its source `file` and the `routine` before it.
|
|
113
112
|
- `unusedModules`: modules whose start is in no segment of the program. Often the program does not hold the code that the knowledge describes.
|
|
114
113
|
- `leftovers`: the bytes that nothing uses, with `bytes` and each range with its `file`. See "The leftovers". `noCoverage` tells that the knowledge has no coverage, so no range is a leftover. `changed` gives the ranges that are `added` to the leftovers and `removed` from them since the earlier run in `--out`.
|
|
114
|
+
- `unknownCode`: code that nothing reaches and that no run executed, which is not a leftover. A flow in `unresolved` can go to it. Each flow has `at` and `kind`:
|
|
115
|
+
- `indirect-jump`: a JMP through a vector. The bytes of the program do not give the value of the vector.
|
|
116
|
+
- `written-operand`: a JMP or JSR whose address a run wrote.
|
|
117
|
+
- `pushed-return`: an RTS or RTI to an address that the code pushed.
|
|
118
|
+
|
|
119
|
+
The default build and the loader keep this code. Find the targets of each flow in the emulator. Record a jump reference from the flow to each target in the project knowledge. When the flow goes outside the program, for example a crash through the I/O area, record the reference to that address. Then generate again.
|
|
115
120
|
- `operandExpressions`: the count of instructions with an operand expression.
|
|
116
121
|
- `operandsAsNumbers`: each operand expression that the source has as a number, with its `address`, `expression` and `reason`.
|
|
117
122
|
- `macroUses`: the count of macro uses in the source.
|
|
118
123
|
- `macrosAsInstructions`: each macro use that the source has as instructions, with its `start`, `end`, `macro` and `reason`.
|
|
119
124
|
- `patchesNotWritten`: each patch that the source does not have, with its range, `switch` and `reason`.
|
|
120
125
|
- `switches`, `default`, `releases`: the checks of the switches. See "Switches and releases".
|
|
121
|
-
- `loader`: the
|
|
126
|
+
- `loader`: the loader program and its check. `<skill>/references/loader.md` gives its fields and the action for each result.
|
|
122
127
|
- `staleLoader`: a run without `--loader` kept `loader.asm` and the loader program of another knowledge revision, or of another version of the toolkit. `files` gives the files. `revision` gives the revision of `loader.asm`, and `version` its toolkit version. Without `revision`, `loader.asm` does not give one. `noEntryState: true` tells that the knowledge has no entry state for a new loader. A change in a space that the loader does not hold does not make the loader stale. The loader holds space `c64` and the space of the stage of the start screen.
|
|
123
128
|
- `staleReference`: each reference folder of the project that has pages of this source from an earlier knowledge revision. Each item has the `folder` and the `revision` of its pages.
|
|
124
129
|
|
|
@@ -147,63 +152,20 @@ Do these actions for the findings:
|
|
|
147
152
|
| `entriesInData` | An analyzer region of data hides the code at the entry. If the entry is code, record a code region at the entry in the project knowledge. A region of the user or the LLM replaces the analyzer region. |
|
|
148
153
|
| `invalid-input` that names a symbol or a module | Change that symbol or module in the project knowledge. |
|
|
149
154
|
| `conflict` | The knowledge has conflicts from a git merge. Merge the open changes of the project knowledge. Then run the command again. |
|
|
150
|
-
| A list with `rest` | Give a larger `--max-listed`.
|
|
155
|
+
| A list with `rest` | Give a larger `--max-listed`. |
|
|
156
|
+
| `loader.verified: false` | Do the action of `<skill>/references/loader.md` for the `reason`. |
|
|
151
157
|
| `staleLoader` | The loader can copy bytes that are not the bytes of the source. Run `nextAction`, which generates with `--loader`. With `noEntryState: true`, remove the files when the build does not use them. |
|
|
152
158
|
| `staleReference` | The reference pages do not agree with the new source. When you do not change the knowledge again, generate the reference pages again from this source into each `folder`. |
|
|
153
159
|
|
|
154
|
-
#### The source files
|
|
155
|
-
|
|
156
|
-
- `main.asm` sets the address of each segment. It includes the files in address order.
|
|
157
|
-
- Each module in the knowledge is one file. A module starts at its address. It stops at the next module or at the end of its segment. The file of a module can be in a folder, for example `music/driver.asm`. Without modules, each segment is one file, `segments/segment_xxxx.asm`.
|
|
158
|
-
- `constants.asm` holds the names of addresses outside the program, for example `EXTCOL = $d020`. It also holds the register names in the program, for example `RASTER = $d012`. The names are in groups by memory area, in address order. Drive code and banks have one group only.
|
|
159
|
-
- The side comment of a constant is the knowledge comment of the address. Without a comment, it is the platform meaning. When the knowledge name is not the platform name, the platform name comes first. For an I/O mirror without a meaning, the comment gives the register that the mirror repeats.
|
|
160
|
-
- After the side comment, `Used:` counts how the source uses the name. The kinds are `read`, `written`, `modified`, `called`, `jumped to`, `jumped through`, `branched to`, `pointer`, `address`, `table` and `macro argument`. `address` is an immediate operand expression. `table` is an entry in a table of addresses. A macro line counts one `macro argument` for each name in its args. The other bytes that the macro reads or writes, for example the high byte of a 16-bit value, count for no name.
|
|
161
|
-
- `config.asm` holds the value of each switch, for example `PROTECTION = 0`. The switches are in groups by kind. The side comment gives the releases that have the switch on, the ranges of its patches and the comment of the switch.
|
|
162
|
-
- You can change a value in `config.asm` to 0 or 1. The next run keeps the values of the file. It adds a new switch with its default. It removes a switch that the knowledge does not have.
|
|
163
|
-
- When the knowledge has a start screen, `config.asm` also has `START_SCREEN = 1`. Set it to 0 to start the program at once. Then assemble `loader.asm` again.
|
|
164
|
-
- `start_screen.asm` is the code that shows the start screen and waits. It is the same for each program. `loader.asm` gives it the values of the start screen.
|
|
165
|
-
- `switches.asm` holds each release of the knowledge. `main.asm` and `loader.asm` include it first. The script writes it only when the knowledge has switches or releases, or when the source has leftovers. For each release, a block `!ifdef RELEASE_<label>` gives each switch the value of that release.
|
|
166
|
-
- `leftovers/leftover_xxxx.asm` holds a range of leftovers. See "The leftovers".
|
|
167
|
-
- `macros.asm` holds the macros of the knowledge. `main.asm` and `loader.asm` include it.
|
|
168
|
-
|
|
169
|
-
#### Names in the source
|
|
170
|
-
|
|
171
|
-
- A label or a constant gets the name of the address in the knowledge.
|
|
172
|
-
- Without a knowledge name, it gets the platform name, for example `EXTCOL` or `CHROUT`. A platform name wins over an analyzer name (`dxa`, `decompiler` or `heuristic`), for example `EXTCOL` over `ld020`. A `user` or `llm` name wins over a platform name.
|
|
173
|
-
- An address in the program without a name gets `l_xxxx`.
|
|
174
|
-
- A read or a write in the I/O area `$d000-$dfff` uses the register, also when the program has RAM there. For example, `lda $dd0e` is `lda CI2CRA` and `sta $d012` is `sta RASTER`. `constants.asm` has these names. An address without a platform name stays a number, for example `sta $d800,x`. The data label of the RAM stays at its data. A `user` or `llm` name of the address wins over the register.
|
|
175
|
-
- A platform name in an operand expression of the knowledge stays in the source. When the program has the address, `constants.asm` has the name, and the RAM there keeps its label.
|
|
176
|
-
- The source uses the names of a ROM only when the program uses that ROM. With coverage, the program uses a ROM when a run executed code of it. A read of ROM bytes as data does not count. Without coverage, `$01` of the entry state tells which ROMs are in.
|
|
177
|
-
- When the program uses no ROM, the zero page and pages 2 and 3 get no system names. An operand expression or a macro use with such a name gets that reason.
|
|
178
|
-
|
|
179
|
-
#### Lines in the source
|
|
180
|
-
|
|
181
|
-
- `sta $d011 ; $d011: yScroll 3, rows 25, displayEnabled` is a store of an immediate to a register with a known meaning. The side comment gives the decoded value. A side comment in the knowledge replaces it.
|
|
182
|
-
- Code regions, and the decoded instructions outside of data regions, become instructions.
|
|
183
|
-
- Data regions become data by their type: `!byte`, `!word`, `!pet`, `!scr`, `!fill`, tables of labels, and sprite bytes in binary.
|
|
184
|
-
- `lda+2 $0012` is an absolute operand below $0100. `+1` is a zero-page operand with a label.
|
|
185
|
-
- `sta NMINV+1` is an address inside a platform entry of more than one byte, for example the high byte of a vector.
|
|
186
|
-
- `lda room_colours+5` is an address inside a data region with a named start. The address has no name of its own.
|
|
187
|
-
- `name = * + 1` is a label inside an instruction, for example for code that changes its own operand.
|
|
188
|
-
- `lda #<irq_handler` and `lda bar_colours-1,x` are operand expressions of the knowledge. An expression in a non-immediate mode that starts with a bracket gets `0+` before it. ACME reads `(...)` as indirect.
|
|
189
|
-
- `; = <irq_handler` at the end of an instruction with a number: the source cannot use this operand expression. `operandsAsNumbers` gives the reason.
|
|
190
|
-
- `!byte` with an instruction as its comment: ACME writes this instruction with a different opcode. The bytes keep the source identical.
|
|
191
|
-
- `not decoded` marks bytes in a code region that the script did not decode.
|
|
192
|
-
- `; not executed $xxxx-$yyyy` starts code that no run of the coverage executed. The range is the same as in `not_executed.json`.
|
|
193
|
-
- `+inc16 ptr` is a use of a macro of the knowledge. The comments inside a use go to its side comment.
|
|
194
|
-
- `!zone patch_PROTECTION_100e` starts a patch. The condition is the switch state that the program does not have. It is `!if TRAINER` when the base release has the switch off. It is `!if PROTECTION = 0` when the base release has it on.
|
|
195
|
-
- A patch block has the code of the patch and NOP to the end of the range. `else` has the code of the base release. The labels inside the range come before the zone as `name = * + n`.
|
|
196
|
-
- Alternatives are patches of two or more switches at one range. They follow as `} else { !if FIX_B {`. A line before them stops the build with `!error` when two of them are in.
|
|
197
|
-
|
|
198
160
|
#### The leftovers
|
|
199
161
|
|
|
200
|
-
A leftover is a range of the program that nothing uses: unused code, old copies and old data. The
|
|
162
|
+
A leftover is a range of the program that nothing uses: unused code, old copies and old data. The start screen, the patches and the addresses that the code of a patch names are never leftovers. A macro use in code that nothing uses is in the leftover with that code. A leftover never cuts a macro use in two.
|
|
201
163
|
|
|
202
164
|
- Each range of leftovers is a file `leftovers/leftover_xxxx.asm`. When a range cuts a module, the module continues after the range in `<module>_xxxx.asm`, in the folder of the module. The module in the knowledge does not change.
|
|
203
165
|
- `main.asm` builds a leftover file only when `LEFTOVERS` is 1. When it is 0, the build skips the bytes. Thus the addresses after the range do not change.
|
|
204
166
|
- `config.asm` has `LEFTOVERS = 0`. Thus the default build is the clean program, without the leftovers.
|
|
205
167
|
- Each release has `LEFTOVERS = 1`. Thus the build of a release gives the bytes of the release.
|
|
206
|
-
- The loader program never has the leftovers. The
|
|
168
|
+
- The loader program never has the leftovers. The memory of a leftover range does not hold the bytes of the program.
|
|
207
169
|
- Without coverage, no range is a leftover. Put the coverage of the runs into the project knowledge. Then generate again.
|
|
208
170
|
- When `leftovers.changed` has ranges, the default build and the loader program now leave out other bytes. A test that observes the `added` bytes on the loader program gets other values there. Fill the `added` ranges in the test of the leftovers. In a test that compares them, exclude them with the reason that they are leftovers.
|
|
209
171
|
- A leftover can be wrong when the coverage does not show a use. For example, the VIC-II reads a range, or the program reads a range before it writes it. Then a test of the loader program fails. Record the region in the project knowledge, or put the coverage of more runs into it. Do not change the source.
|
|
@@ -229,120 +191,18 @@ Each item of `switches` has `name`, `kind`, `default`, `base`, `define` and the
|
|
|
229
191
|
|
|
230
192
|
`default` has `in`, `result` and `changedBytes`, as in `switches`. When `default` has `overflow` and the message `turn on one of them`, two alternatives are in the default build. Give one of the switches the default of the base release.
|
|
231
193
|
|
|
232
|
-
Each item of `releases` has `label`, `base`, `define` and `result`. The check compares the build with each segment of the release.
|
|
194
|
+
Each item of `releases` has `label`, `base`, `define` and `result`. The check compares the build with each segment of the release.
|
|
233
195
|
|
|
234
196
|
- `identical`: the build gives the bytes of each segment of the release.
|
|
235
197
|
- `different`: the release has bytes that no patch gives. Compare the release with the program. Then record a switch and a patch for each difference.
|
|
236
198
|
- `does not assemble`: read the ACME diagnostics.
|
|
237
199
|
- `notInRelease`: the ranges of the program that the release does not have. The check does not compare them.
|
|
238
200
|
|
|
239
|
-
The script writes a patch only when its range is complete items of one file. A patch cannot cut an instruction. Its switch name cannot be a name of the source.
|
|
240
|
-
The script writes a macro use only when the use gives the bytes of the program. A label inside the range of a use also keeps the instructions. The macro line has no place for the label.
|
|
241
|
-
|
|
242
201
|
Build the program from the source in these ways:
|
|
243
202
|
|
|
244
203
|
- The build of `config.asm`: no option. With the defaults, this is the default build, without the leftovers.
|
|
245
204
|
- A release: the build option `--release FIRESTAR`.
|
|
246
|
-
-
|
|
247
|
-
|
|
248
|
-
#### The loader
|
|
249
|
-
|
|
250
|
-
`--loader` writes `loader.asm` in `--out`. It assembles `loader.asm` to the loader program in `build/`. Git ignores `build/`. The name of the loader program tells its build:
|
|
251
|
-
|
|
252
|
-
- `clean_loader.prg`: each value of `config.asm` is its default. This is the clean program.
|
|
253
|
-
- `custom_<switches>_loader.prg`: the names of the switches that are not at their default. A switch that is off has `no_` before its name, for example `custom_no_start_screen_loader.prg`.
|
|
254
|
-
|
|
255
|
-
The symbols of the loader program are in `build/symbols/<name>.json`, for example `build/symbols/clean_loader.json`. They hold the labels of `loader.asm`, `main.asm` and `start_screen_stage.asm`. Give this file to a test of the loader program as its symbols. When the name changes, the script removes the loader program of the earlier run and its symbols.
|
|
256
|
-
|
|
257
|
-
The loader does these steps:
|
|
258
|
-
|
|
259
|
-
1. `10 SYS 2061` starts it.
|
|
260
|
-
2. It stops the interrupts and makes all RAM visible. It moves its copier to two free pages.
|
|
261
|
-
3. It copies each segment without the leftovers, and the pages $0002-$03ff of the entry state, into place. It also copies the 1000 colours of the colour RAM of the entry state to free RAM. No copy writes over the packed bytes of a copy that has not run yet.
|
|
262
|
-
4. When the knowledge has a start screen and `START_SCREEN` is 1, it shows the start screen. It waits until the user releases all keys and fire buttons. Then it waits for a key, or for a fire button on joystick port 1 or 2, and for its release. A move of a joystick is not a key.
|
|
263
|
-
5. It sets the colour RAM from the entry state. The start screen writes the colour RAM, thus this step comes after it.
|
|
264
|
-
6. It sets the screen registers of the VIC-II and the VIC bank from the entry state. Then it waits for the raster line of the entry.
|
|
265
|
-
7. It sets the CIA timers, their latches and the interrupt masks from the entry state. A running timer gets the value that counts down to the timer value at the entry.
|
|
266
|
-
8. It sets $00/$01, the stack pointer, A, X, Y and the flags. Then it jumps to the entry.
|
|
267
|
-
|
|
268
|
-
The copy table, the copier and the jump use labels, not numbers. `loader_from_xxxx` and `loader_end_xxxx` are around each packed segment. `loader_to_xxxx` is its first address in place. Thus a segment can change its length, and the loader still works.
|
|
269
|
-
|
|
270
|
-
The loader changes the free stack byte below the stack pointer (`stackByte`). It does not set the SID, the time of day of the CIAs, the CIA interrupt flags or the interrupt registers of the VIC-II. A program that reads SID voice 3 for random numbers can thus give a different result. When you compare the reference and the rebuild, observe after the program sets its own random numbers.
|
|
271
|
-
|
|
272
|
-
The script builds and checks the loader program with the values of `config.asm`. With the defaults, the loader program is the clean program: no copy protection, all corrections and no leftovers. The entry state is the state of the base release. For a loader of a release, build `loader.asm` with the build option `--release <label>`. That loader also does not have the leftovers.
|
|
273
|
-
|
|
274
|
-
The start screen:
|
|
275
|
-
|
|
276
|
-
- The start screen needs the VIC-II values of the entry state. Its screen, bitmap, charset and colours must be in a segment of the program, or in a captured stage. See "The start screen of a captured stage".
|
|
277
|
-
- With a start screen, the copier uses three pages, not two.
|
|
278
|
-
- The start screen is part of the clean build only. The loader program always shows it. A release build has no start screen, and `LEFTOVERS = 1` also turns it off.
|
|
279
|
-
- To start the program at once, set `START_SCREEN = 0` in `config.asm`, and assemble `loader.asm`. Do not define `START_SCREEN` on the command line of the build: `config.asm` sets it.
|
|
280
|
-
- A test that runs the loader program stops at the start screen, because the start screen waits for a key. Run until `loader_start_screen_wait`. Then set the PC to `loader_start_screen_continue`.
|
|
281
|
-
|
|
282
|
-
`loader` holds these fields:
|
|
283
|
-
|
|
284
|
-
- `program`, the `copies` in their order, `copier` and `stackByte`.
|
|
285
|
-
- `verified: true`: the check ran the loader program to its jump to the entry. There, the memory, $00/$01, the registers, the VIC-II and the colour RAM are equal to the entry state. The raster line and the CIA values are also equal. An interrupt can run right at the entry, as in the program of the base release.
|
|
286
|
-
- `limits`: each CIA value that the loader cannot set as it was at the entry. An old capture has no CIA values or no colour RAM. Then capture the program again at its entry point.
|
|
287
|
-
When no free RAM outside the segments has room for the 1000 colours, the loader does not set the colour RAM, and `limits` tells this. Then the program starts with other colours where it does not write them.
|
|
288
|
-
- `startScreen`: with a start screen, `shown: true` when the VIC-II had the values of the start screen, and `waits: true` when the start screen waited without a key. `wait` and `continue` are the addresses of the wait and of the code after it. The check sets the PC to `continue`, and then runs the loader to its jump.
|
|
289
|
-
- `packed`: `packedBytes` and `unpackedBytes` of the packed form. With a start screen of a captured stage, this is the packed program in the loader program.
|
|
290
|
-
- `stage`: the show stage of a start screen of a captured stage. It has the `space` of the stage and the address of the show `code`. It also has the `bytes` of the stage in the loader program, the `stash` copies, `packedBytes` and `unpackedBytes`. `startScreen.stage` names the space.
|
|
291
|
-
- When the check of the loader program cannot run, the script does not write a loader program. The loader program of an earlier run stays as it was. `loader.asm` is new. `reason` tells why the check did not run.
|
|
292
|
-
- `kept`: when the result has no new loader program, the paths of the loader programs of an earlier run. They are not of this source.
|
|
293
|
-
|
|
294
|
-
Do these actions when `verified` is `false`:
|
|
295
|
-
|
|
296
|
-
| Field | Action |
|
|
297
|
-
|---|---|
|
|
298
|
-
| `reason` about the copy order, the free pages or the count of copies | The reason gives the ranges. Capture the program again with fewer segments, or write the loader by hand. |
|
|
299
|
-
| `reason` about the packed form | If a tool is missing, stop the task and give the message to the user. If the free ranges are too small, write the loader by hand. If the check of the unpack fails, give the reason to the user. |
|
|
300
|
-
| `reason` that the source does not assemble | Correct the source first. The loader includes the source. |
|
|
301
|
-
| `reason` about the start screen | Correct the start screen in the project knowledge, or capture the program again with the start screen in memory. If the start screen is not necessary, remove it from the project knowledge. |
|
|
302
|
-
| `reason` about the show stage | If the reason names the coverage of the stage, run the stage with coverage. Put the map into the project knowledge in the space of the stage. If the memory is too small, capture the stage again with less memory. If a tool is missing, stop the task and give the message to the user. If `start_screen_stage.asm` does not assemble, stop the task and give the reason to the user. The reason names the file in `.c64-re-tools/local/` with the source that failed. |
|
|
303
|
-
| `reason` that the check of the loader program did not run | Stop the task and give the reason to the user. When the user tells you that the emulator is available, run the same command again. |
|
|
304
|
-
| `differences` | The loader ran. The list gives the bytes and the registers that are not equal. |
|
|
305
|
-
| `stop` | The loader did not get to its copier or its jump. `stop` gives the address and `port`, the value of $01. `history` gives the last 16 instructions. `cause` gives the first byte of the copier or of a copy that is not correct. |
|
|
306
|
-
|
|
307
|
-
#### The start screen of a captured stage
|
|
308
|
-
|
|
309
|
-
Often the loading stage of a program shows a picture that is not in memory at the entry. Then the knowledge has the picture in the captured stage of the space `loading`. `--stage` of the start screen names that space. `--call` names a routine of the stage, for example the routine that starts the loading tune.
|
|
310
|
-
|
|
311
|
-
The loader then always has the packed form, and the start screen is a program of its own in front of it:
|
|
312
|
-
|
|
313
|
-
1. Exomizer packs the program with the copier. This is the packed loader.
|
|
314
|
-
2. Exomizer packs the packed loader, the bytes of the stage and the show code into the loader program.
|
|
315
|
-
3. When the loader program starts, Exomizer unpacks these parts. The program stays packed. The bytes of the packed loader under the stage go to a stash in free memory.
|
|
316
|
-
4. The show code shows the start screen with `start_screen.asm`. With a call, it sets $01 to $37, starts the interrupts and calls the routine.
|
|
317
|
-
5. It waits for a key or a fire button, as the start screen in the program does.
|
|
318
|
-
6. It stops the interrupts and the sound, and it stops the screen. It sets the CIA timers as RUN leaves them.
|
|
319
|
-
7. It copies the stash back to the packed loader. Then it starts the packed loader, which unpacks the program over the start screen.
|
|
320
|
-
|
|
321
|
-
The program is packed while the screen shows. Thus the picture and the tune have more free memory.
|
|
322
|
-
|
|
323
|
-
- The script puts everything in memory. It does not matter where the stage keeps its bytes, if the memory has enough room.
|
|
324
|
-
- The loader program has only the bytes of the stage that the start screen uses. These are the screen, the bitmap and the charset. With a call, they are also each byte of the stage that is not free from the call, as in "The free ranges". A call thus needs the coverage of the stage.
|
|
325
|
-
- With colours from the colour RAM of the capture, the show code holds the 1000 colours. It copies them to the colour RAM.
|
|
326
|
-
- The patches of the stage are in at the defaults of their switches. Thus a patch under a switch can remove the text of a crack from the picture.
|
|
327
|
-
- `start_screen_stage.asm` holds the show code and the bytes of the stage. Do not edit it. To make the loader program again, run `generate --out <dir> --loader`.
|
|
328
|
-
- The show stage needs Exomizer. The show code needs free memory in $0400-$9fff or $c000-$cfff. When the memory is too small, the reason gives the largest free ranges.
|
|
329
|
-
- The check runs the loader program to `loader_start_screen_wait` of the show stage. There, it compares the VIC-II with the start screen, the screen bytes in memory with the stage, and the colour RAM with the capture. Then it sets the PC to `loader_start_screen_continue`, and it checks the loader as usual.
|
|
330
|
-
|
|
331
|
-
#### The packed loader
|
|
332
|
-
|
|
333
|
-
A loader file that loads into $d000 or higher writes the I/O area. When the program is too large for one loader file, `loader.asm` has the packed form:
|
|
334
|
-
|
|
335
|
-
- `loader.asm` holds only the copier and the bytes below $0400. The segments at $0400 and higher are not in `loader.asm`. Between its free ranges, `loader.asm` holds the bytes of the program.
|
|
336
|
-
- The loader program is the build of `main.asm` from $0400 and the build of `loader.asm`, packed into one file. Where the two builds overlap, the loader program has the bytes of `loader.asm`.
|
|
337
|
-
- The jump to the entry uses the address of the entry, not its label.
|
|
338
|
-
|
|
339
|
-
To make the packed loader for other switch values, do these steps:
|
|
340
|
-
|
|
341
|
-
1. Assemble `main.asm` without an output path. The build name of the program tells the switch values, for example `build/custom_trainer.prg`. The leftovers are $00 in this build.
|
|
342
|
-
2. Assemble `loader.asm` without an output path, for example to `build/custom_trainer_copier.prg`. This is the copier. The build name has `copier` in place of `loader`, so the build does not write over the loader program.
|
|
343
|
-
3. Pack the two files into `build/custom_trainer_packed.prg`. The start address is the copier address in the comment at the start of `loader.asm`. The memory configuration at the exit is `$34`.
|
|
344
|
-
|
|
345
|
-
These steps do not work when a segment starts below $0400. They also do not work when a patch is between the free ranges of `loader.asm`. In these cases, use `generate --out <dir> --loader` for the base release.
|
|
205
|
+
- Other switch values: the build option `--switch TRAINER=1`, one time for each switch. `config.asm` does not change. With a loader, this build also gives the loader program of these switch values. See "The loader of other switch values".
|
|
346
206
|
|
|
347
207
|
---
|
|
348
208
|
|
|
@@ -352,6 +212,7 @@ These steps do not work when a segment starts below $0400. They also do not work
|
|
|
352
212
|
|
|
353
213
|
The command writes the program of the knowledge as the start of a new program: a new project folder and a zip file of it. A person changes the source of the new project directly.
|
|
354
214
|
First, make sure that `generate` gives `PASS`. The command writes nothing until all its checks pass.
|
|
215
|
+
`<skill>/references/export.md` gives the free ranges and the files of the new project.
|
|
355
216
|
|
|
356
217
|
The command sets each switch to its export value:
|
|
357
218
|
|
|
@@ -369,6 +230,7 @@ The build with these values can change bytes only in the patches. Then the comma
|
|
|
369
230
|
- `switches`: each switch with `kind`, `base` and the export `value`.
|
|
370
231
|
- `free`: the count of free bytes, and each free range with `bytes`, `what` and `label`.
|
|
371
232
|
- `unreachableExecuted`: each range of executed code that the entry does not get to, with the `routine` before it and its `drop` value.
|
|
233
|
+
- `unknownCode`: code that nothing reaches and that no run executed, which stays because a flow in `unresolved` can go to it. Record the targets of each flow as for `generate`. Then export again.
|
|
372
234
|
- `knowledge`: the counts of the rows of the new knowledge.
|
|
373
235
|
- `tests`: the `written` tests, and the `leftOut` tests with the reason.
|
|
374
236
|
- `loader`: the copies, the copier, `stackByte` and `simulated: true`. The export does not run the loader.
|
|
@@ -386,60 +248,21 @@ On `FAIL`, `hint` gives the action for the stage:
|
|
|
386
248
|
| `export` | This is a defect of the script. Give the result to the user. |
|
|
387
249
|
| `loader` | Read `reason`, and give it to the user. The export does not make the packed form of the loader. |
|
|
388
250
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
- The command refuses a folder that is not empty, and a zip file that exists. Remove the folder and the zip file of an earlier export, or give another folder.
|
|
392
|
-
- The command refuses two switches that change one range. The export puts both alternatives in. In the project knowledge, give all but one of them the kind `change`, with the default of the base release.
|
|
393
|
-
- The command refuses a `--drop` range that code which stays goes to or reads. The message names that code. It also refuses a range that cuts code or a region.
|
|
394
|
-
|
|
395
|
-
#### The free ranges
|
|
396
|
-
|
|
397
|
-
A block of code stops after RTS, RTI, JMP, BRK or a JAM, and before a gap. A block of code becomes free only when both of these are true:
|
|
398
|
-
|
|
399
|
-
- No run of the coverage executed it.
|
|
400
|
-
- No path gets to it from the entry, the hardware vectors or the code that stays. A path is a call, a jump, a branch, a reference of the knowledge or an operand expression. An entry of a table, and two immediate operands that give its address, are paths too.
|
|
401
|
-
|
|
402
|
-
Two immediate operands give an address only in these cases:
|
|
403
|
-
|
|
404
|
-
- The code stores the low byte and the high byte to two adjacent addresses outside $d000-$dfff.
|
|
405
|
-
- The code calls a routine with the low byte and the high byte in two registers.
|
|
406
|
-
- The code pushes the high byte and then the low byte onto the stack.
|
|
407
|
-
|
|
408
|
-
An operand expression of the knowledge at an immediate operand replaces these cases for that operand. Thus an operand expression with a constant stops a wrong address.
|
|
409
|
-
|
|
410
|
-
A call or a jump to ROM is not a path. The coverage shows where the CPU sees ROM. Without coverage, $01 of the entry state shows it. Known code of the knowledge is never ROM.
|
|
411
|
-
|
|
412
|
-
Code that a run executed always stays. `unreachableExecuted` lists the executed code that the entry and the vectors do not get to. An example is a copy check whose call the export removed. Give its `drop` value to `export` to make it free.
|
|
413
|
-
|
|
414
|
-
Data becomes free only when all of these are true:
|
|
415
|
-
|
|
416
|
-
- Its region type is `bytes`, `words`, a table of addresses, `petscii`, `workspace` or `unused`.
|
|
417
|
-
- No run read, wrote or executed a byte of it.
|
|
418
|
-
- No code that stays reads it or names it. No table that stays has an entry in it.
|
|
419
|
-
- It is not in the BASIC line that starts the program, and not at $fffa-$ffff.
|
|
420
|
-
- No `charset`, `sprite`, `bitmap` or `screen` region has a byte of it. For example, `unused` bytes in a bitmap stay.
|
|
251
|
+
Each range of `unreachableExecuted` is code that a run executed and that the entry does not get to now. Find the code that calls the range in the project knowledge:
|
|
421
252
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
253
|
+
| Caller | Action |
|
|
254
|
+
|---|---|
|
|
255
|
+
| Only code that the export removed, for example a copy check | Drop the range. |
|
|
256
|
+
| Code that the knowledge does not show, for example a call through a pointer | Keep the range. |
|
|
257
|
+
| You are not sure | Ask the user. |
|
|
425
258
|
|
|
426
|
-
|
|
259
|
+
To drop a range, remove the folder and the zip file of the export. Then export again, and give `--drop` with each range. When a test of the new project gives `FAIL`, the export dropped a range that the program uses. Remove the folder and the zip file. Export again without that range in `--drop`.
|
|
427
260
|
|
|
428
|
-
|
|
429
|
-
README.md the steps to build and test, the free ranges and the origin
|
|
430
|
-
src/ main.asm, constants.asm, macros.asm, the modules in their folders and loader.asm
|
|
431
|
-
baseline/<name>.prg the exported program, and baseline/<name>.json with its symbols
|
|
432
|
-
tests/ the tests of the project, changed for the new program
|
|
433
|
-
.c64-re-tools/knowledge/ the knowledge of the new program
|
|
434
|
-
```
|
|
261
|
+
Traps of the command:
|
|
435
262
|
|
|
436
|
-
- The
|
|
437
|
-
- The
|
|
438
|
-
-
|
|
439
|
-
- A run file of `tests/` runs the build of the new project. Scenarios and run files take the names from the symbol files.
|
|
440
|
-
- The export leaves out a test that restores a snapshot. It also leaves out a test with a name that the new program does not have, or with an address in a free range.
|
|
441
|
-
- The export does not copy recordings, record files or `runs/`.
|
|
442
|
-
- The zip file holds the folder without `.c64-re-tools/local/`.
|
|
263
|
+
- The command refuses a folder that is not empty, and a zip file that exists. Remove the folder and the zip file of an earlier export, or give another folder. Remove only the folder and the zip file that this task made.
|
|
264
|
+
- The command refuses two switches that change one range. The export puts both alternatives in. In the project knowledge, give all but one of them the kind `change`, with the default of the base release.
|
|
265
|
+
- The command refuses a `--drop` range that code which stays goes to or reads. The message names that code. It also refuses a range that cuts code or a region.
|
|
443
266
|
|
|
444
267
|
---
|
|
445
268
|
|
|
@@ -452,8 +275,9 @@ tests/ the tests of the project, changed for the new program
|
|
|
452
275
|
5. Record names, comments, regions and modules in the project knowledge.
|
|
453
276
|
6. Run `generate` again. Do steps 4 to 6 again until the source is clear.
|
|
454
277
|
7. Assemble `main.asm` to a program. This is the default build. For a release, give the build option `--release <label>`.
|
|
455
|
-
8. For an unpacked program, run `generate --out <dir> --loader` at the end. Compare the loader program with the program of the base release in a test.
|
|
456
|
-
9. To start a new program from the rebuild, run `export
|
|
278
|
+
8. For an unpacked program, run `generate --out <dir> --loader` at the end. Compare the loader program with the program of the base release in a test. The loader program is in `loader.program`, and its symbols file is in `loader.symbols`.
|
|
279
|
+
9. To start a new program from the rebuild, tell the user the export value of each switch. If the user wants another value, change the kind or the default of the switch in the project knowledge. Then run `export`, and build and test the new project as its `README.md` tells.
|
|
280
|
+
10. Give the user the folder and the zip file, the value of each switch, the free ranges, and each test with its result.
|
|
457
281
|
|
|
458
282
|
---
|
|
459
283
|
|
|
@@ -461,24 +285,15 @@ tests/ the tests of the project, changed for the new program
|
|
|
461
285
|
|
|
462
286
|
Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
|
|
463
287
|
|
|
464
|
-
On success, the exit code is 0:
|
|
465
|
-
|
|
466
|
-
```json
|
|
467
|
-
{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
On failure, the exit code is 2:
|
|
471
|
-
|
|
472
|
-
```json
|
|
473
|
-
{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
|
|
474
|
-
```
|
|
475
|
-
|
|
288
|
+
- On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
|
|
289
|
+
- On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
|
|
476
290
|
- `body` holds the result. The section of each command gives the fields of its body.
|
|
477
291
|
- A check gives its verdict in `body.result`: `PASS`, `FAIL` or `INCONCLUSIVE`. The exit code is 0 for each verdict. Thus read `body.result`, not the exit code.
|
|
478
|
-
- `error` is one sentence. It tells what is wrong.
|
|
479
|
-
- `
|
|
480
|
-
- `
|
|
481
|
-
- `
|
|
292
|
+
- `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
|
|
293
|
+
- `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
|
|
294
|
+
- A list has `count`, `listed` and `rest`. `listed` holds at most `--max-listed` items. `rest` tells how to get the other items. A file that the command wrote has `out`, `bytes` and `sha256`.
|
|
295
|
+
- To get only some fields of `body`, give `--fields <path>,<path>`, for example `--fields count,listed.start`. A path through a list gives that field of each item. Do not write code to filter an envelope.
|
|
296
|
+
- To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
|
|
482
297
|
|
|
483
298
|
| `code` | Action |
|
|
484
299
|
|---|---|
|
|
@@ -487,12 +302,8 @@ On failure, the exit code is 2:
|
|
|
487
302
|
| `operation-failed` | Give `error` and `hint` to the user. |
|
|
488
303
|
| Another code | Do as `hint` tells. |
|
|
489
304
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
| Field | Meaning |
|
|
493
|
-
|---|---|
|
|
494
|
-
| `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
|
|
495
|
-
| `count`, `listed`, `rest` | A list. `count` is the number of items. `listed` holds the first items, at most `--max-listed`. `rest` tells how to get the other items. |
|
|
305
|
+
## Reference
|
|
496
306
|
|
|
497
|
-
|
|
498
|
-
|
|
307
|
+
- `<skill>/references/source-format.md`: the files of the source, the names in the source and the lines in the source.
|
|
308
|
+
- `<skill>/references/loader.md`: the loader program, the start screen and the loader of other switch values. It also gives the fields of `loader`, and the action when the loader is not verified.
|
|
309
|
+
- `<skill>/references/export.md`: the free ranges of an export and the files of the new project.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Export
|
|
2
|
+
|
|
3
|
+
This file gives the free ranges of an export and the files of the new project. For the command, see the section "Export a new program" of `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
## The free ranges
|
|
6
|
+
|
|
7
|
+
A block of code stops after RTS, RTI, JMP, BRK or a JAM, and before a gap. A block of code becomes free only when both of these are true:
|
|
8
|
+
|
|
9
|
+
- No run of the coverage executed it.
|
|
10
|
+
- No path gets to it from the entry, the hardware vectors or the code that stays. A path is a call, a jump, a branch, a reference of the knowledge or an operand expression. An entry of a table, and two immediate operands that give its address, are paths too.
|
|
11
|
+
|
|
12
|
+
Two immediate operands give an address only in these cases:
|
|
13
|
+
|
|
14
|
+
- The code stores the low byte and the high byte to two adjacent addresses outside $d000-$dfff.
|
|
15
|
+
- The code calls a routine with the low byte and the high byte in two registers.
|
|
16
|
+
- The code pushes the high byte and then the low byte onto the stack.
|
|
17
|
+
|
|
18
|
+
An operand expression of the knowledge at an immediate operand replaces these cases for that operand. Thus an operand expression with a constant stops a wrong address.
|
|
19
|
+
|
|
20
|
+
Code that a run executed always stays. `unreachableExecuted` lists the executed code that the entry and the vectors do not get to. An example is a copy check whose call the export removed. Give its `drop` value to `export` to make it free.
|
|
21
|
+
|
|
22
|
+
Data becomes free only when all of these are true:
|
|
23
|
+
|
|
24
|
+
- Its region type is `bytes`, `words`, a table of addresses, `petscii`, `workspace` or `unused`.
|
|
25
|
+
- No run read, wrote or executed a byte of it.
|
|
26
|
+
- No code that stays reads it or names it. No table that stays has an entry in it.
|
|
27
|
+
- It is not in the BASIC line that starts the program, and not at $fffa-$ffff.
|
|
28
|
+
- No `charset`, `sprite`, `bitmap` or `screen` region has a byte of it. For example, `unused` bytes in a bitmap stay.
|
|
29
|
+
|
|
30
|
+
The coverage does not show the reads of the VIC-II. Thus `charset`, `sprite`, `bitmap` and `screen` data stay, unless `--drop` names them. The bytes of the start screen always stay. Bytes without a region also stay.
|
|
31
|
+
|
|
32
|
+
The entry is the entry of the knowledge. Without it, the entry is the address of the first SYS in the BASIC line of the program. Without coverage, nothing becomes free without `--drop`. Without an entry and without the hardware vectors in the program, no code is unreachable.
|
|
33
|
+
|
|
34
|
+
## The new project
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
README.md the steps to build and test, the free ranges and the origin
|
|
38
|
+
src/ main.asm, constants.asm, macros.asm, the modules in their folders and loader.asm
|
|
39
|
+
baseline/<name>.prg the exported program, and baseline/<name>.json with its symbols
|
|
40
|
+
tests/ the tests of the project, changed for the new program
|
|
41
|
+
.c64-re-tools/knowledge/ the knowledge of the new program
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- The source has no mark line, no `switches.asm` or `config.asm`, no patch zones and no `; not executed` lines. A start screen stays in the loader. Build with `-DSTART_SCREEN=0` to start the program at once. It keeps the names, the comments, the operand expressions and the macros. A line comment at each changed patch gives the switch, its kind, its value and the comments.
|
|
45
|
+
- The knowledge has one revision `export`. It holds the program, the entry and its state, the names, the comments, the regions, the modules and the start screen. It has no history, analyzer names, references, operand expressions, macros, patches, switches, releases or coverage.
|
|
46
|
+
- A scenario of `tests/` compares the build of the new project with the baseline. Both sides are the same program. Thus a step of the reference side alone goes. A step of the rebuild side alone runs on both sides.
|
|
47
|
+
- A run file of `tests/` runs the build of the new project. Scenarios and run files take the names from the symbol files.
|
|
48
|
+
- The export leaves out a test that restores a snapshot. It also leaves out a test with a name that the new program does not have, or with an address in a free range.
|
|
49
|
+
- The export does not copy recordings, record files or `runs/`.
|
|
50
|
+
- The zip file holds the folder without `.c64-re-tools/local/`.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# The loader
|
|
2
|
+
|
|
3
|
+
This file gives the loader program of `generate --out <dir> --loader`, the fields of `loader` in its result, and the action for each result. For the command, see the section "Generate the source" of `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
## The loader program
|
|
6
|
+
|
|
7
|
+
`--loader` writes `loader.asm` in `--out`. It also writes the loader program and its symbols in `build/`. Git ignores `build/`.
|
|
8
|
+
|
|
9
|
+
- `loader.program` is the loader program. `loader.symbols` is its symbols file. The symbols file holds the labels of `loader.asm`, `main.asm` and `start_screen_stage.asm`. Give the two files to a test of the loader program.
|
|
10
|
+
- The loader program has the switch values of `config.asm`. With the defaults, it is the clean program: no copy protection, all corrections and no leftovers. The entry state is the state of the base release.
|
|
11
|
+
- The name of the loader program changes with the switch values. Then the script removes the loader program of the earlier run and its symbols.
|
|
12
|
+
- The loader program sets the entry state of the capture and jumps to the entry. It sets the memory, $00/$01, the registers, the VIC-II, the colour RAM, the raster line and the CIA timers.
|
|
13
|
+
- The loader changes the free stack byte below the stack pointer (`stackByte`). It does not set the SID, the time of day of the CIAs, the CIA interrupt flags or the interrupt registers of the VIC-II. A program that reads SID voice 3 for random numbers can thus give a different result. When you compare the reference and the rebuild, observe after the program sets its own random numbers.
|
|
14
|
+
- For the loader program of a release, build `loader.asm` with the build option `--release <label>`. This is possible only when `loader.packed` is not in the result. That loader program also does not have the leftovers.
|
|
15
|
+
|
|
16
|
+
## The start screen
|
|
17
|
+
|
|
18
|
+
- When the knowledge has a start screen and `START_SCREEN` is 1, the loader program shows the start screen. It waits until the user releases all keys and fire buttons. Then it waits for a key, or for a fire button on joystick port 1 or 2, and for its release. A move of a joystick is not a key.
|
|
19
|
+
- The start screen needs the VIC-II values of the entry state. Its screen, bitmap, charset and colours must be in a segment of the program, or in a captured stage. See "The start screen of a captured stage".
|
|
20
|
+
- The start screen is part of the clean build only. A release build has no start screen. `LEFTOVERS = 1` also turns it off.
|
|
21
|
+
- To start the program at once, build the source with the switch value `START_SCREEN=0`. The build then also gives its loader program. See "The loader of other switch values".
|
|
22
|
+
- A test, a run and a replay of the loader program pass the start screen.
|
|
23
|
+
|
|
24
|
+
## The loader of other switch values
|
|
25
|
+
|
|
26
|
+
To get the loader program of other switch values, build `main.asm` of the source with these switch values, for example `TRAINER=1`. `config.asm` does not change. The build result then has the loader program in `loader.out` and its symbols file in `loader.symbolsFile.out`. No check of this loader program runs, so `loader.verified` is `false`. Test the loader program before you trust it.
|
|
27
|
+
|
|
28
|
+
The build refuses the loader program in these cases:
|
|
29
|
+
|
|
30
|
+
- A segment of the program starts below $0400.
|
|
31
|
+
- The switch values change a byte that `loader.asm` holds between its free ranges.
|
|
32
|
+
- The start screen is of a captured stage.
|
|
33
|
+
|
|
34
|
+
In these cases, set the switch values in `config.asm`. Then run `generate --out <dir> --loader`.
|
|
35
|
+
|
|
36
|
+
## The fields of the loader
|
|
37
|
+
|
|
38
|
+
`loader` holds these fields:
|
|
39
|
+
|
|
40
|
+
- `program` and `symbols`: the loader program and its symbols file.
|
|
41
|
+
- The `copies` in their order, `copier` and `stackByte`.
|
|
42
|
+
- `verified: true`: the check ran the loader program to its jump to the entry. There, the memory, $00/$01, the registers, the VIC-II and the colour RAM are equal to the entry state. The raster line and the CIA values are also equal. An interrupt can run right at the entry, as in the program of the base release.
|
|
43
|
+
- `limits`: each CIA value that the loader cannot set as it was at the entry. An old capture has no CIA values or no colour RAM. Then capture the program again at its entry point.
|
|
44
|
+
When no free RAM outside the segments has room for the 1000 colours, the loader does not set the colour RAM, and `limits` tells this. Then the program starts with other colours where it does not write them.
|
|
45
|
+
- `startScreen`: with a start screen, `shown: true` when the VIC-II had the values of the start screen, and `waits: true` when the start screen waited without a key.
|
|
46
|
+
- `packed`: `packedBytes` and `unpackedBytes` of the packed form. A program that is too large for one loader file gets the packed form. With a start screen of a captured stage, this is the packed program in the loader program.
|
|
47
|
+
- `stage`: the show stage of a start screen of a captured stage. It has the `space` of the stage and the address of the show `code`. It also has the `bytes` of the stage in the loader program, the `stash` copies, `packedBytes` and `unpackedBytes`. `startScreen.stage` names the space.
|
|
48
|
+
- When the check of the loader program cannot run, the script does not write a loader program. The loader program of an earlier run stays as it was. `loader.asm` is new. `reason` tells why the check did not run.
|
|
49
|
+
- `kept`: when the result has no new loader program, the paths of the loader programs of an earlier run. They are not of this source.
|
|
50
|
+
|
|
51
|
+
## When the loader is not verified
|
|
52
|
+
|
|
53
|
+
Do these actions when `verified` is `false`:
|
|
54
|
+
|
|
55
|
+
| Field | Action |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `reason` about the copy order, the free pages or the count of copies | The reason gives the ranges. Capture the program again with fewer segments. If this is not possible, stop the task and give the reason to the user. |
|
|
58
|
+
| `reason` about the packed form | If a tool is missing, stop the task and give the message to the user. If the free ranges are too small, stop the task and give the reason to the user. If the check of the unpack fails, give the reason to the user. |
|
|
59
|
+
| `reason` that the source does not assemble | Correct the source first. The loader includes the source. |
|
|
60
|
+
| `reason` about the start screen | Correct the start screen in the project knowledge, or capture the program again with the start screen in memory. If the start screen is not necessary, remove it from the project knowledge. |
|
|
61
|
+
| `reason` about the show stage | If the reason names the coverage of the stage, run the stage with coverage. Put the map into the project knowledge in the space of the stage. If the memory is too small, capture the stage again with less memory. If a tool is missing, stop the task and give the message to the user. If `start_screen_stage.asm` does not assemble, stop the task and give the reason to the user. The reason names the file in `.c64-re-tools/local/` with the source that failed. |
|
|
62
|
+
| `reason` that the check of the loader program did not run | Stop the task and give the reason to the user. When the user tells you that the emulator is available, run the same command again. |
|
|
63
|
+
| `differences` | The loader ran. The list gives the bytes and the registers that are not equal. |
|
|
64
|
+
| `stop` | The loader did not get to its copier or its jump. `stop` gives the address and `port`, the value of $01. `history` gives the last 16 instructions. `cause` gives the first byte of the copier or of a copy that is not correct. |
|
|
65
|
+
|
|
66
|
+
## The start screen of a captured stage
|
|
67
|
+
|
|
68
|
+
Often the loading stage of a program shows a picture that is not in memory at the entry. Then the knowledge has the picture in the captured stage of the space `loading`. `--stage` of the start screen names that space. `--call` names a routine of the stage, for example the routine that starts the loading tune.
|
|
69
|
+
|
|
70
|
+
The loader program then shows the start screen before it unpacks the program. The program stays packed while the screen shows. Thus the picture and the tune have more free memory.
|
|
71
|
+
|
|
72
|
+
- The script puts everything in memory. It does not matter where the stage keeps its bytes, if the memory has enough room.
|
|
73
|
+
- The loader program has only the bytes of the stage that the start screen uses. These are the screen, the bitmap and the charset. With a call, they are also each byte of the stage that is not free from the call, as in "The free ranges". A call thus needs the coverage of the stage.
|
|
74
|
+
- With colours from the colour RAM of the capture, the loader program sets the colour RAM to these colours.
|
|
75
|
+
- The patches of the stage are in at the defaults of their switches. Thus a patch under a switch can remove the text of a crack from the picture.
|
|
76
|
+
- `start_screen_stage.asm` holds the show code and the bytes of the stage. Do not edit it. To make the loader program again, run `generate --out <dir> --loader`.
|
|
77
|
+
- The show stage needs Exomizer. The show code needs free memory in $0400-$9fff or $c000-$cfff. When the memory is too small, the reason gives the largest free ranges.
|
|
78
|
+
- The check also compares the VIC-II, the screen bytes and the colour RAM with the start screen.
|