Predict the update before planning the addresses
The score starts at $0200 after three rounds. The rule adds 3 to the round count and returns 6 points. The new score is $0206 after round 4. The application owns the score record. The DLL only receives one byte and returns one byte, so the same rule can serve a caller with a different storage layout.
- Acquire the scoring rule from disk.
- Bring the score record from REU into a C64 scratch arena.
- Call the rule through the execution window and update the local record.
- Flush the record, reset scratch, and verify the new score with a far read.
Reserve a separate range for each owner
| Range starts at | Owner | When it is in use |
|---|---|---|
C64 $6000 | Execution window | While the scoring rule is active. |
C64 $8000 | Near arena | While the materialized score is live. |
C64 $9000 | Disk staging | While the loader reads the payload. |
C64 $c800 | Software stack | While the scoring call has a live frame. |
REU $010000 | Score arena | Until the application resets the far arena. |
REU $030000 | Module loader | While the registry's payloads occupy their cache slots. |
The two REU regions have distinct owners. A write-back to the score arena never needs to touch the cached DLL. The near score stays live while the export runs, so scratch RAM and the execution window also need separate ranges.
Follow the score through the rule call
if (table.materialize(scratch)) |local| {
var score = local.get(0);
if (FixedMath.bias(score.rounds)) |points| {
score.total += @as(u16, points);
score.rounds += 1;
local.set(0, score);
table.flush(local);
scratch.reset();
const saved = table.get(0);
scores.reset();
FixedMath.release();
return saved.total == 0x0206 and saved.rounds == roundLimit();
}
}
The producer exports bias as a stack-frame function. The caller declares the same u8 → u8 signature. The rule sees only the current round count. The application widens the returned points before adding them to the word total. After the flush it resets scratch and reads the score back from the far table.
Complete scoring rule · Complete score application
Expect MEMORY PLAN OK and a green border.
Build the scoring rule and boot the score disk
Change the score_reu region base to $030000 and rebuild the caller. Its data region would overlap the module cache, so the compiler rejects the declaration. Restore the base before trying a runtime failure such as a disk with no fixedmath entry. The guide's repair exercise also checks an ABI mismatch.