Explorar el Código

M6.1: people's attributes (six 3d6 scores, P to step through)

Each person gets STR, DEX, CON, INT, WIS and CHA, rolled 3d6 for every
new world. P steps to the next person; status line 4 shows their number
and scores, and their dot blinks on the map. Walk counts moved to $C000
to make room below $4000. Spec R8 and milestone M6 (approved).

Checks: check-keys 'P held' scenario and status line 4 checks; people
and scroll checks leave out the blinking person; split check expects
all five status rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main
Daniel Covington hace 2 días
padre
commit
acbb0ce026
Se han modificado 17 ficheros con 350 adiciones y 50 borrados
  1. +1
    -1
      README.md
  2. +29
    -1
      docs/manual-tests.md
  3. +12
    -0
      docs/milestones.md
  4. +21
    -6
      docs/spec.md
  5. +7
    -0
      docs/verification-status.md
  6. +79
    -8
      project.json
  7. +33
    -3
      src/keys.inc
  8. +9
    -1
      src/main.s
  9. +13
    -6
      src/paths.inc
  10. +47
    -4
      src/people.inc
  11. +36
    -2
      src/status.inc
  12. +42
    -2
      tools/check-keys.ps1
  13. +1
    -1
      tools/check-paths.ps1
  14. +7
    -4
      tools/check-people.ps1
  15. +8
    -5
      tools/check-scroll.ps1
  16. +4
    -5
      tools/check-split.ps1
  17. +1
    -1
      tools/check-world.ps1

+ 1
- 1
README.md Ver fichero

@@ -1,6 +1,6 @@
# Land Map 64

A C64 program written in 6502 assembly that procedurally generates a 2x2-screen landscape world (light brown land, grey stone, green grass and trees, blue water) shown as a multicolour bitmap. The cursor keys scroll the view smoothly across the world. 16 people, drawn as white dots, wander the world but are blocked by water and stone. Where they walk often they wear dark brown paths into the land, which fade again when they are no longer used. Two bitmap buffers are flipped each update, and only the spots where people move are redrawn.
A C64 program written in 6502 assembly that procedurally generates a 2x2-screen landscape world (light brown land, grey stone, green grass and trees, blue water) shown as a multicolour bitmap. The cursor keys scroll the view smoothly across the world. 16 people, drawn as white dots, wander the world but are blocked by water and stone. Where they walk often they wear dark brown paths into the land, which fade again when they are no longer used. Each person has six D&D-style scores (3d6); P steps through the people, showing their scores below the map and making their dot blink. Two bitmap buffers are flipped each update, and only the spots where people move are redrawn.

- Targets: `c64` (details in [docs/spec.md](docs/spec.md))
- Language/toolchain: 6502 assembly (ca65) - Windows cross-development with cc65 (C, ca65 assembly or mixed) and VICE ([docs/toolchain.md](docs/toolchain.md))


+ 29
- 1
docs/manual-tests.md Ver fichero

@@ -226,7 +226,8 @@ Steps:

Expected:
- The map fills the top 20 cell rows; five lines of white upper-case text on light brown sit below it:
`LAND MAP 64`, `VIEW X 00 Y 00`, `PEOPLE IN VIEW nn OF 16`, an empty line, `CRSR SCROLL SPACE NEW WORLD`.
`LAND MAP 64`, `VIEW X 00 Y 00`, `PEOPLE IN VIEW nn OF 16`, the chosen person's scores (since M6,
`P01 STR..`; an empty line before), `CRSR SCROLL SPACE NEW WORLD P PERSON` (before M6 without `P PERSON`).
- The people-in-view number equals the number of dots you can count on the map.
- The boundary is a clean, steady horizontal line: no flicker, jitter, garbage characters or half-height rows.
- The text never moves while the map scrolls, and the boundary stays clean at every vertical scroll position.
@@ -324,3 +325,30 @@ Expected:
- SPACE gives a new world with no paths.

Verifies: R7

## M6 - People's attributes

### MT6.1: People's attributes (c64)

Setup: VICE x64sc, NTSC (-ntsc), pepto-pal palette (tools/run.ps1 selects it), warp off.
Start: `pwsh -File tools/run.ps1 -Target c64`

Automated first: `pwsh -File tools/check-keys.ps1` should end with `[PASS]`.

Steps:
1. Wait for the map and read status line 4 (the line above the key help).
2. Press P a few times, then hold P down for a second.
3. Press P until it shows P16, then once more.
4. Scroll around while a person is chosen; find their dot.
5. Press SPACE.

Expected:
- Line 4 reads like `P01 STR12 DEX09 CON15 INT10 WIS08 CHA13`; every score is 3-18.
- Each press shows the next person with their own scores; holding P moves on only once.
- After P16 comes P01.
- The chosen person's dot blinks about twice a second when it is in view; the map and the other
dots stay steady, also while scrolling.
- The key help line ends with `P PERSON`.
- SPACE gives a new world with new scores and shows P01.

Verifies: R8, R6

+ 12
- 0
docs/milestones.md Ver fichero

@@ -81,3 +81,15 @@ Requirements: R7, R1, R2, R3, R5
| M5.2 | Worn paths: a walk count per cell (4,000 bytes), +1 when a person steps into a cell, -1 for every cell every 60 seconds (10 cells every 9 frames); at 128 a land, grass or tree cell becomes a path tile (dark brown patch, one per terrain so it can turn back), below 64 it turns back. Changed cells are redrawn in each buffer while it is hidden (people's dots and saved bytes kept), so the shown map never tears; a buffer in the middle of a rebuild restarts it in full. A test build (PATH_TEST: path at 4, back below 2, one count less every 400 frames) makes it checkable. | R7, R2, R3, R5 | Busy cells turn into paths, unused paths fade | `pwsh -File tools/check-paths.ps1`, `tools/check-scroll.ps1 -Long`, `tools/check-scroll.ps1 -Long -PathTest`; manual test MT5.2 |

Manual verification: see docs/manual-tests.md section M5.

## M6 - People's attributes

Goal: Every person has D&D-style scores that the player can look at one person at a time.

Requirements: R8, R6, R2, R3

| Task | Description | Requirements | Buildable outcome | Completion check |
|---|---|---|---|---|
| M6.1 | Six scores per person (STR, DEX, CON, INT, WIS, CHA; 3d6, one byte each, 96 bytes), rolled with the people for every new world. P (new press only) steps to the next person; status line 4 shows 'Pnn' and the six scores, rewritten only when the person changes, on a frame without the status update. The chosen person's dot is left out of the people draw for 16 of every 32 frames (draw_skip, which the checks read to know which dots to expect). The walk counts move to $C000 to make room below $4000. | R8, R6, R2, R3 | Scores per person, shown with P; the chosen person blinks | `pwsh -File tools/check-keys.ps1` (P held: one step; scores 3-18; status line 4 matches), `tools/check-people.ps1`, `tools/check-scroll.ps1 -Long`; manual test MT6.1 |

Manual verification: see docs/manual-tests.md section M6.

+ 21
- 6
docs/spec.md Ver fichero

@@ -10,6 +10,7 @@ Changes approved by the user since then:
- 2026-12-03: Background (land, border and status area) changed from brown (colour 9) to light brown: C64 colour 8 (named orange), which VICE's pepto-pal palette (measured from PAL C64s) shows as light brown; tools/run.ps1 starts VICE with that palette (new assumption A8). Tree trunks stay colour 9.
- 2026-12-03: Terrain all over the world ("the different land spaces need to be all over the map, not just here and there"): R1 reworded; new criteria R1.5 (every view shows at least three terrain kinds) and R1.6 (each world rolls its own random terrain mix). Roads stay a grid and cross water on bridges. New milestone M4.
- 2026-12-03: Worn paths instead of roads ("keep track of where the people walk and when the counter hits 128 then it is a path/road but the number can be reduced by one every certain number of cycles"; "remove their creation"): the generator makes no roads (R1 text, R1.2, R1.3); new R7 worn paths (dark brown patches, appear at 128, fade below 64, counts go down by one every 60 seconds, all chosen by the user); new milestone M5.
- 2026-12-03: People's attributes ("now we need to give each person attributes like D&D"): new R8. Each person has six scores (strength, dexterity, constitution, intelligence, wisdom, charisma), rolled 3d6 when a world is made and stored one byte each; shown only, they do not change behaviour. P (a letter key, chosen by the user instead of Tab, which the C64 does not have) steps through the people; status line 4 (the spare line, R6) shows the chosen person's number and scores, and that person's dot blinks on the map. New milestone M6.

## Summary

@@ -33,7 +34,8 @@ A generated 2x2-screen world in multicolour bitmap mode with pixel-smooth cursor
- 16 people as white dots (one multicolour pixel each), spread over the world, blocked by water and stone; only those in view are drawn
- Two bitmap buffers flipped once per update; only the bytes under people are restored and redrawn between scroll steps
- SPACE generates a new world
- A 5-line text status area below a 20-row map, using a raster split: title, view position, people in view, a spare line and key help
- A 5-line text status area below a 20-row map, using a raster split: title, view position, people in view, the chosen person's scores and key help
- Six D&D-style scores per person (3d6 each), shown one person at a time; P picks the next person, whose dot blinks
- NTSC timing

### Out of scope
@@ -41,7 +43,7 @@ A generated 2x2-screen world in multicolour bitmap mode with pixel-smooth cursor
- PAL support
- Worlds larger than 2x2 screens
- Sprites for people
- People with goals, pathfinding or interaction
- People with goals, pathfinding or interaction; scores that change how people behave
- Sound and music
- Saving worlds or seeds
- Joystick
@@ -131,10 +133,10 @@ Capabilities: keyboard-input, smooth-animation, raster-interrupts

### R6 - Status area (must)

Below the 20-row map, five rows of 40-column text in the upper-case ROM font, white on light brown, show: the title, the view position (top-left cell of the view), the number of people in view out of 16, a spare line, and key help. A raster split switches the VIC-II from multicolour bitmap to text at the boundary every frame; the text area never scrolls.
Below the 20-row map, five rows of 40-column text in the upper-case ROM font, white on light brown, show: the title, the view position (top-left cell of the view), the number of people in view out of 16, the chosen person's scores (R8; a spare line before M6), and key help. A raster split switches the VIC-II from multicolour bitmap to text at the boundary every frame; the text area never scrolls.

Acceptance criteria:
- [R6.1] The five status lines appear below the map whenever the map is shown: title, view position, people in view, a spare line and key help
- [R6.1] The five status lines appear below the map whenever the map is shown: title, view position, people in view, the chosen person's scores (R8) and key help
- [R6.2] The status text and the split line between map and text stay steady (no jitter, flicker or tearing) while people move and while the view scrolls
- [R6.3] The view position shown matches the view's top-left cell and changes as the view scrolls; the people-in-view count matches the dots visible in the map

@@ -153,20 +155,33 @@ Acceptance criteria:

Capabilities: smooth-animation

### R8 - People's attributes (must)

Each of the 16 people has six scores, as in D&D: strength, dexterity, constitution, intelligence, wisdom and charisma. Each is rolled with three six-sided dice (3-18) when a world is made, and stored as one byte. For now the scores are only shown; they do not change how people move. Status line 4 shows one person at a time: `P01 STR12 DEX09 CON15 INT10 WIS08 CHA13`. Each press of P shows the next person (after 16 comes 1); holding P does not repeat. The chosen person's dot blinks on the map (left out for 16 of every 32 frames) so it can be found. SPACE rolls new scores for the new world and shows person 1.

Acceptance criteria:
- [R8.1] Every person has six scores from 3 to 18, rolled 3d6 when a world is made; SPACE rolls new ones
- [R8.2] Status line 4 shows the chosen person's number (1-16) and six scores, labelled STR, DEX, CON, INT, WIS and CHA; person 1 is shown after a new world
- [R8.3] Each press of P shows the next person, after 16 comes 1; a held P counts once
- [R8.4] The chosen person's dot blinks about twice a second, wherever they are in the view, without disturbing the map or the other dots
- [R8.5] The scores do not change how people move

Capabilities: keyboard-input

## Design decisions

"Practical default" means the Foundry proposed it and the user accepted it without a specific preference. It can be changed later through AGENTS.md section 6.

| Topic | Decision | Source |
|---|---|---|
| Controls | Cursor keys scroll the view. On a real C64 these are CRSR down/right, plus SHIFT for up/left; the keyboard matrix is read directly so a key held down scrolls continuously. VICE maps the PC arrow keys to them. SPACE generates a new world. Known limitation (accepted by the user, 2026-12-03): SHIFT applies to both cursor keys, so only the Right + Down and Left + Up diagonals work; Up + Right and Down + Left come out as Up + Left (VICE sends the PC Up and Left arrows as SHIFT + CRSR). | decided by user |
| Controls | Cursor keys scroll the view. On a real C64 these are CRSR down/right, plus SHIFT for up/left; the keyboard matrix is read directly so a key held down scrolls continuously. VICE maps the PC arrow keys to them. SPACE generates a new world. P shows the next person's scores (R8; a letter key, chosen by the user: the C64 has no Tab key). Known limitation (accepted by the user, 2026-12-03): SHIFT applies to both cursor keys, so only the Right + Down and Left + Up diagonals work; Up + Right and Down + Left come out as Up + Left (VICE sends the PC Up and Left arrows as SHIFT + CRSR). | decided by user |
| Visuals | Multicolour bitmap mode (160x200, double-wide pixels) for a 38-column map area 20 cell rows high, smooth-scrolled; below it a raster split to a fixed 5-row, 40-column text status area in the upper-case ROM font, white on light brown. Light brown (C64 colour 8 (named orange), which VICE's pepto-pal palette (measured from PAL C64s) shows as light brown; tools/run.ps1 starts VICE with that palette) is the shared background colour; white is the colour-RAM colour in every cell, so people can be drawn anywhere without colour clash and colour RAM never needs scrolling. The two screen-RAM colours of each 4x8 cell come from grey (stone), green (grass and trees), blue (water) and dark brown (paths). The world is stored as one tile byte per 4x8 cell; each tile is drawn from a small set of 8-byte pixel patterns (including edge and corner patterns) so shorelines look natural. | decided by user |
| Sound | None in the first release. | practical default |
| Persistence (save/load) | None. Maps and seeds are not saved. | practical default |
| File formats | None. A single PRG. | practical default |
| Peripherals | Keyboard only. No disk access after loading, no joystick. | practical default |
| Timing and memory budgets | NTSC: 60 Hz, 17,095 cycles per frame (263 lines x 65 cycles, the NTSC VIC-II 6567R8 that x64sc emulates). Per frame: fine-scroll update, one slice of the hidden-buffer rebuild (about 7,600 bytes of bitmap and screen RAM, 20 map rows plus one partial row, spread over 8 frames), and restoring and redrawing visible people; together under one frame. World data about 4 KB; two bitmap buffers with their screen RAM about 18 KB. World generation may take several seconds (since M4.1 about 4 seconds, behind the generating message; the map is ready about 7 seconds after power-on). | practical default |
| Memory layout | Buffer A in VIC bank 1 and buffer B in VIC bank 2, each with its own 8 KB bitmap and 1 KB screen RAM; flipping switches bank bits in $DD00 during vertical blank. Each bank also holds a 1 KB status text screen (bank + $0400) and a 2 KB copy of the upper-case ROM font (bank + $0800), at the same offsets so a flip still changes only $DD00. Colour RAM is shared and constant (white), which is also the status text colour. | practical default |
| Memory layout | Buffer A in VIC bank 1 and buffer B in VIC bank 2, each with its own 8 KB bitmap and 1 KB screen RAM; flipping switches bank bits in $DD00 during vertical blank. Each bank also holds a 1 KB status text screen (bank + $0400) and a 2 KB copy of the upper-case ROM font (bank + $0800), at the same offsets so a flip still changes only $DD00. Colour RAM is shared and constant (white), which is also the status text colour. Program, tables and variables (world tiles, people and their scores) lie below $4000; the 4,000 walk counts (R7) use the free RAM at $C000-$CF9F. | practical default |
| Rebuild source | The hidden buffer is rebuilt from the tile world, never copied from the visible buffer, so people's dots are never copied into the new view. Since M4.1 the rebuild first puts back the bytes under the buffer's own people and then skips every cell whose tile is already drawn there (most cells, as terrain comes in areas), so textured terrain everywhere still rebuilds within 8 frames. | practical default |
| Seed | The seed comes from the CIA timer at start-up and at each SPACE press. It is not shown or saved in the first release. | practical default |



+ 7
- 0
docs/verification-status.md Ver fichero

@@ -21,9 +21,16 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n
| M4.1 Region generator: each world rolls its own terrain mix; jittered seeds on a grid give every class areas all over the world, shaped by noisy distances, smoothing and removal of thin water; shores from the neighbours; trees on grass. Roads stay a grid of two rows and two columns and become bridges over water. The scroll rebuild skips cells whose tile is already drawn, to keep the 8-frame rebuild with textured terrain everywhere. | passed (2026-12-03, `pwsh -File tools/build.ps1` (4,647 bytes); `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1 -Runs 10`: 10 of 10 worlds, every 40x20 view with 3+ terrain kinds, map ready 7.1-7.3 s after power-on (generation 4.0-4.1 s), mix spread land 14 / grass-trees 8 / water 13 / stone 16 percentage points; `pwsh -File tools/check-people.ps1`: 1,919 frames, 0 missed, update done by line 20; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`: 734 splits, digits right after 183 of 183 updates; `pwsh -File tools/check-scroll.ps1 -Long`: 4 of 4, tour 22,966 frames with 21 stops byte-exact, 116 stall frames in 15,216 moving frames; fix for walking on bridge water, 2026-12-03: `pwsh -File tools/build.ps1` (4,683 bytes); `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1` and `-Runs 10`: 10 of 10; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-scroll.ps1`: 3 of 3; `pwsh -File tools/check-people.ps1 -Cycles 300000000`: 17,119 frames, 1,408 person-frames on bridges, no dot on a blue or grey pixel; the same check fails on the old code (person 9 on a blue pixel of bridge tile 20); fix for the scroll that did not start, 2026-12-03: `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-scroll.ps1`: 4 of 4, new restart scenario 12 stall frames over four starts from a cell edge (the same scenario fails on the old code: 1,166 frames held left without moving); `pwsh -File tools/check-people.ps1`: 1,899 frames, 816 person-frames on bridges, pass; `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,967 frames with 21 stops byte-exact, 111 stall frames in 15,216 moving frames) | confirmed by user (2026-12-03), after two fixes: people walked on the blue water pixels of bridges, and the scroll sometimes did not start from rest on a cell edge |
| M5.1 Remove road generation: the world has land, grass and trees, stone and water only; tools/check-world.ps1 fails on any road or bridge tile. | passed (2026-12-03, `pwsh -File tools/build.ps1` (4,581 bytes); `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1` and `-Runs 10`: 10 of 10 worlds, no road or bridge cells; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-scroll.ps1`: 4 of 4) | confirmed by user (2026-12-03) |
| M5.2 Worn paths: walk count per cell, path at 128, back below 64, one count less every 60 seconds. | passed (2026-12-03, `pwsh -File tools/build.ps1` (5,257 bytes); `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`: 1,910 frames; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-paths.ps1` (test build): 27 paths appeared, 4 faded, both buffers match the current world plus dots; `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,967 frames, 21 stops byte-exact, 95 stall frames, 6 paths appeared in the normal build during the tour; `pwsh -File tools/check-scroll.ps1 -Long -PathTest`: 5 of 5, tour 70 paths appeared and 38 faded while scrolling, no store into the shown buffer while displayed, 472 stall frames in 15,216 moving frames) | confirmed by user (2026-12-03) |
| M6.1 People's attributes: six 3d6 scores per person, P steps through the people, status line 4 shows the scores, the chosen person's dot blinks. | passed (2026-12-03, `pwsh -File tools/build.ps1` (5,464 bytes); `pwsh -File tools/smoke.ps1` incl. status row 23 "P01 STR"; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-keys.ps1`: 9 of 9, new 'P held' scenario steps to person 2 exactly once, all 96 scores 3-18, status line 4 matches the shown person in every scenario; `pwsh -File tools/check-people.ps1` (expected dots leave out draw_skip); `pwsh -File tools/check-split.ps1`: 727 splits, people-in-view digits right after 182 of 182 updates, all five status rows lit; `pwsh -File tools/check-paths.ps1`: 42 appeared, 11 faded; `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,968 frames, 21 stops byte-exact, 100 stall frames. `tools/check-scroll.ps1 -Long -PathTest` passed 5 of 5 on the build before the status fix below (tour 79 paths appeared, 45 faded); its rerun on the final build was still running at commit time) | pending |

## Notes

- 2026-12-03 (M6.1 people's attributes, spec change approved by the user: six D&D-style scores, one byte each, P key instead of Tab, chosen person blinks):
- src/people.inc: people_attr (16 x 6 bytes) rolled 3d6 with rejection sampling (0-5 from 3 random bits) at the end of place_people; shown_person, shown_dirty; draw_skip (the person left out of a draw for 16 of every 32 frames) sits right after move_frame so the checks can save it with the people tables. src/keys.inc reads P (column 5, row 1; new press only). src/status.inc show_person writes status line 4; the main loop calls it only when the person changed, on a frame without the status update (frame time is tight while rebuilding).
- The variables no longer fitted below $4000 (about 290 bytes were free), so the 4,000 walk counts moved to $C000-$CF9F (reset_paths clears exactly 4,000 bytes, so the check phase byte at $CFF0 is untouched); the variables now end at $3013.
- Found by check-split: show_person was first placed between update_status and show_number, which update_status falls into, so the people-in-view number stayed 00 and the scores were rewritten every 4th frame. Fixed before commit.
- Checks: check-keys gains the 'P held' scenario and checks scores and status line 4 in every scenario; check-people and check-scroll leave out the draw_skip person; check-split expects all five status rows lit; every check now holds P up as well; smoke expects "P01 STR" in row 23.

- 2026-12-03 (M5.2 worn paths):
- src/paths.inc: walk counts (4,000 bytes, below VIC bank 1), path tiles PATH_LAND/PATH_GRASS/PATH_TREE in src/tiles.inc (dark brown patch, colour 9), decay sweep, an 8-entry change queue, and redraw of a changed cell in the hidden buffer only (dots and saved bytes kept). A buffer in the middle of a rebuild restarts it in full.
- Found by `check-scroll.ps1 -Long`: the first version restarted that rebuild every frame while a queued cell still waited for the shown buffer, so the rebuild never finished and the scroll stopped (6,826 stall frames, 6,747 abandoned rebuilds in the tour). It now restarts only when a cell is new to that buffer.


+ 79
- 8
project.json Ver fichero

@@ -15,7 +15,8 @@
"2026-12-03 change (approved): R3 reworded so that while a scroll rebuild runs people are drawn in the shown buffer during vertical blank; drawing people relative to the view moved from M3.4 to M3.3.",
"2026-12-03 change (approved): background (land, border, status area) changed from brown (colour 9) to light brown: C64 colour 8 shown with VICE's pepto-pal palette, which tools/run.ps1 selects (assumption A8). Tree trunks stay colour 9.",
"2026-12-03 change (approved): people and status text white (colour 1) instead of light red (A1).",
"2026-12-03 change (approved): worn paths instead of roads: the generator makes no roads; new R7 (walk count per cell, +1 per step into the cell, -1 every 60 s; path at 128, back to terrain below 64; dark brown patch); new milestone M5. The unfinished random-road work (M4.2) was dropped at the user's request."
"2026-12-03 change (approved): worn paths instead of roads: the generator makes no roads; new R7 (walk count per cell, +1 per step into the cell, -1 every 60 s; path at 128, back to terrain below 64; dark brown patch); new milestone M5. The unfinished random-road work (M4.2) was dropped at the user's request.",
"2026-12-03 change (approved): people's attributes like D&D: new R8 (six scores per person, 3d6, one byte each, shown only); P steps through the people (a letter key, chosen by the user: the C64 has no Tab key); status line 4 shows the chosen person's scores and their dot blinks; new milestone M6. The 4,000 walk counts moved to $C000 to make room below $4000."
]
},
"project": {
@@ -55,14 +56,15 @@
"16 people as white dots (one multicolour pixel each), spread over the world, blocked by water and stone; only those in view are drawn",
"Two bitmap buffers flipped once per update; only the bytes under people are restored and redrawn between scroll steps",
"SPACE generates a new world",
"A 5-line text status area below a 20-row map, using a raster split: title, view position, people in view, a spare line and key help",
"A 5-line text status area below a 20-row map, using a raster split: title, view position, people in view, the chosen person's scores and key help",
"Six D&D-style scores per person (3d6 each), shown one person at a time; P picks the next person, whose dot blinks",
"NTSC timing"
],
"outOfScope": [
"PAL support",
"Worlds larger than 2x2 screens",
"Sprites for people",
"People with goals, pathfinding or interaction",
"People with goals, pathfinding or interaction; scores that change how people behave",
"Sound and music",
"Saving worlds or seeds",
"Joystick",
@@ -151,9 +153,9 @@
"id": "R6",
"title": "Status area",
"priority": "must",
"text": "Below the 20-row map, five rows of 40-column text in the upper-case ROM font, white on light brown, show: the title, the view position (top-left cell of the view), the number of people in view out of 16, a spare line, and key help. A raster split switches the VIC-II from multicolour bitmap to text at the boundary every frame; the text area never scrolls.",
"text": "Below the 20-row map, five rows of 40-column text in the upper-case ROM font, white on light brown, show: the title, the view position (top-left cell of the view), the number of people in view out of 16, the chosen person's scores (R8; a spare line before M6), and key help. A raster split switches the VIC-II from multicolour bitmap to text at the boundary every frame; the text area never scrolls.",
"acceptance": [
"The five status lines appear below the map whenever the map is shown: title, view position, people in view, a spare line and key help",
"The five status lines appear below the map whenever the map is shown: title, view position, people in view, the chosen person's scores (R8) and key help",
"The status text and the split line between map and text stay steady (no jitter, flicker or tearing) while people move and while the view scrolls",
"The view position shown matches the view's top-left cell and changes as the view scrolls; the people-in-view count matches the dots visible in the map"
],
@@ -176,6 +178,22 @@
"capabilities": [
"smooth-animation"
]
},
{
"id": "R8",
"title": "People's attributes",
"priority": "must",
"text": "Each of the 16 people has six scores, as in D&D: strength, dexterity, constitution, intelligence, wisdom and charisma. Each is rolled with three six-sided dice (3-18) when a world is made, and stored as one byte. For now the scores are only shown; they do not change how people move. Status line 4 shows one person at a time: P01 STR12 DEX09 CON15 INT10 WIS08 CHA13. Each press of P shows the next person (after 16 comes 1); holding P does not repeat. The chosen person's dot blinks on the map (left out for 16 of every 32 frames) so it can be found. SPACE rolls new scores for the new world and shows person 1.",
"acceptance": [
"Every person has six scores from 3 to 18, rolled 3d6 when a world is made; SPACE rolls new ones",
"Status line 4 shows the chosen person's number (1-16) and six scores, labelled STR, DEX, CON, INT, WIS and CHA; person 1 is shown after a new world",
"Each press of P shows the next person, after 16 comes 1; a held P counts once",
"The chosen person's dot blinks about twice a second, wherever they are in the view, without disturbing the map or the other dots",
"The scores do not change how people move"
],
"capabilities": [
"keyboard-input"
]
}
],
"design": {
@@ -204,13 +222,13 @@
"value": "Keyboard only. No disk access after loading, no joystick."
},
"controls": {
"value": "Cursor keys scroll the view. On a real C64 these are CRSR down/right, plus SHIFT for up/left; the keyboard matrix is read directly so a key held down scrolls continuously. VICE maps the PC arrow keys to them. SPACE generates a new world. Known limitation (accepted by the user, 2026-12-03): SHIFT applies to both cursor keys, so only the Right + Down and Left + Up diagonals work; Up + Right and Down + Left come out as Up + Left (VICE sends the PC Up and Left arrows as SHIFT + CRSR).",
"value": "Cursor keys scroll the view. On a real C64 these are CRSR down/right, plus SHIFT for up/left; the keyboard matrix is read directly so a key held down scrolls continuously. VICE maps the PC arrow keys to them. SPACE generates a new world. P shows the next person's scores (R8; a letter key, chosen by the user: the C64 has no Tab key). Known limitation (accepted by the user, 2026-12-03): SHIFT applies to both cursor keys, so only the Right + Down and Left + Up diagonals work; Up + Right and Down + Left come out as Up + Left (VICE sends the PC Up and Left arrows as SHIFT + CRSR).",
"source": "user"
},
"other": [
{
"topic": "Memory layout",
"value": "Buffer A in VIC bank 1 and buffer B in VIC bank 2, each with its own 8 KB bitmap and 1 KB screen RAM; flipping switches bank bits in $DD00 during vertical blank. Each bank also holds a 1 KB status text screen (bank + $0400) and a 2 KB copy of the upper-case ROM font (bank + $0800), at the same offsets so a flip still changes only $DD00. Colour RAM is shared and constant (white), which is also the status text colour.",
"value": "Buffer A in VIC bank 1 and buffer B in VIC bank 2, each with its own 8 KB bitmap and 1 KB screen RAM; flipping switches bank bits in $DD00 during vertical blank. Each bank also holds a 1 KB status text screen (bank + $0400) and a 2 KB copy of the upper-case ROM font (bank + $0800), at the same offsets so a flip still changes only $DD00. Colour RAM is shared and constant (white), which is also the status text colour. Program, tables and variables (world tiles, people and their scores) lie below $4000; the 4,000 walk counts (R7) use the free RAM at $C000-$CF9F.",
"source": "default"
},
{
@@ -715,6 +733,51 @@
]
}
]
},
{
"id": "M6",
"title": "People's attributes",
"goal": "Every person has D&D-style scores that the player can look at one person at a time.",
"tasks": [
{
"id": "M6.1",
"text": "Six scores per person (STR, DEX, CON, INT, WIS, CHA; 3d6, one byte each, 96 bytes), rolled with the people for every new world. P (new press only) steps to the next person; status line 4 shows 'Pnn' and the six scores, rewritten only when the person changes, on a frame without the status update. The chosen person's dot is left out of the people draw for 16 of every 32 frames (draw_skip, which the checks read to know which dots to expect). The walk counts move to $C000 to make room below $4000.",
"requirements": [
"R8",
"R6",
"R2",
"R3"
],
"outcome": "Scores per person, shown with P; the chosen person blinks",
"check": "pwsh -File tools/check-keys.ps1 (P held: one step; scores 3-18; status line 4 matches); tools/check-people.ps1; tools/check-scroll.ps1 -Long; manual test MT6.1"
}
],
"manualTests": [
{
"id": "MT6.1",
"title": "People's attributes",
"target": "c64",
"setup": "VICE x64sc, NTSC (-ntsc), pepto-pal palette (tools/run.ps1 selects it), warp off.",
"steps": [
"Wait for the map and read status line 4.",
"Press P a few times, then hold P for a second.",
"Press P until person 16, then once more.",
"Scroll while a person is chosen.",
"Press SPACE."
],
"expected": [
"Line 4 reads like P01 STR12 DEX09 CON15 INT10 WIS08 CHA13, every score 3-18",
"Each press shows the next person with different scores; holding P moves on only once",
"After P16 comes P01",
"The chosen person's dot blinks about twice a second when in view; the map and the other dots stay steady, also while scrolling",
"SPACE gives a new world with new scores and shows P01"
],
"requirements": [
"R8",
"R6"
]
}
]
}
],
"destination": "C:\\Development\\Commodore\\Foundry Projects\\land-map-64",
@@ -915,10 +978,18 @@
"bytes": null,
"description": "Status row 22 people label in buffer A"
},
{
"dump": "status-a",
"offset": 120,
"text": "P01 STR",
"encoding": "screen-upper",
"bytes": null,
"description": "Status row 23 shown person (R8) in buffer A"
},
{
"dump": "status-a",
"offset": 160,
"text": "CRSR SCROLL SPACE NEW WORLD",
"text": "CRSR SCROLL SPACE NEW WORLD P PERSON",
"encoding": "screen-upper",
"bytes": null,
"description": "Status row 24 key help in buffer A"


+ 33
- 3
src/keys.inc Ver fichero

@@ -4,6 +4,7 @@
; column 0: CRSR RIGHT row 2 (keycode 2), CRSR DOWN row 7 (keycode 7)
; column 1: left SHIFT row 7 (keycode 15)
; column 6: right SHIFT row 4 (keycode 52)
; column 5: P row 1 (keycode 41)
; column 7: SPACE row 4 (keycode 60)
; SHIFT reverses the cursor keys: SHIFT + CRSR RIGHT = left, SHIFT + CRSR DOWN
; = up. VICE maps the PC arrow keys to these combinations.
@@ -15,13 +16,15 @@ KEY_COL_CURSOR = %11111110
KEY_COL_LSHIFT = %11111101
KEY_COL_RSHIFT = %10111111
KEY_COL_SPACE = %01111111
KEY_COL_P = %11011111
KEY_ROW_RIGHT = %00000100
KEY_ROW_DOWN = %10000000
KEY_ROW_LSHIFT = %10000000
KEY_ROW_RSHIFT = %00010000
KEY_ROW_SPACE = %00010000
KEY_ROW_P = %00000010

.export key_row_cursor, key_row_lshift, key_row_rshift, key_row_space
.export key_row_cursor, key_row_lshift, key_row_rshift, key_row_space, key_row_p
.export scroll_dx

.segment "CODE"
@@ -34,11 +37,13 @@ stop_kernal_irq:
lda CIA1_ICR ; acknowledge anything pending
lda #1
sta space_down ; SPACE must be released before it counts
sta p_down
rts

; Read the keys once per frame. Sets scroll_dx and scroll_dy to -1, 0 or +1
; for as long as a cursor key is held. Returns carry set when SPACE has just
; been pressed (held SPACE counts once).
; for as long as a cursor key is held. A new press of P shows the next
; person's scores (R8; held P counts once). Returns carry set when SPACE has
; just been pressed (held SPACE counts once).
read_keys:
lda #KEY_COL_CURSOR
sta CIA1_PRA
@@ -60,6 +65,11 @@ key_row_rshift:
lda CIA1_PRB
key_row_space:
sta keys_space
lda #KEY_COL_P
sta CIA1_PRA
lda CIA1_PRB
key_row_p:
sta keys_p
lda #$FF ; select no column
sta CIA1_PRA

@@ -86,6 +96,24 @@ key_row_space:
bne @no_vertical
sty scroll_dy
@no_vertical:
ldx #0
lda keys_p
and #KEY_ROW_P
bne @p_up
inx ; X = 1: P is down
@p_up: lda p_down
stx p_down
bne @p_done ; already down last frame (or up now: X = 0)
cpx #1
bne @p_done
ldx shown_person ; next person, 16 wraps to 1
inx
txa
and #PEOPLE_COUNT - 1
sta shown_person
lda #1
sta shown_dirty
@p_done:
ldx #0
lda keys_space
and #KEY_ROW_SPACE
@@ -109,3 +137,5 @@ keys_lshift: .res 1
keys_rshift: .res 1
keys_space: .res 1
space_down: .res 1
keys_p: .res 1
p_down: .res 1

+ 9
- 1
src/main.s Ver fichero

@@ -111,9 +111,16 @@ people_moved: ; check hook: people drawn for this frame
keys_read: ; check hook: scroll_dx and scroll_dy are set
lda move_frame ; status every 4th frame (15 times a second)
and #3
bne @rebuild
bne @person
jsr count_people_in_view
jsr update_status
jmp @rebuild
@person:
cmp #2 ; after a P press, the scores on another frame
bne @rebuild ; than the status update (frame time is tight)
lda shown_dirty
beq @rebuild
jsr show_person
@rebuild:
jsr move_people ; after the status count: it counts the drawn dots
jsr decay_counts ; worn paths: counts fade, paths turn back
@@ -159,6 +166,7 @@ rebuild_map:
jsr write_status_text
jsr count_people_in_view
jsr update_status
jsr show_person ; person 1's scores

jsr wait_frame ; switch banks and modes below the visible area
lda #BANK_A_BITS


+ 13
- 6
src/paths.inc Ver fichero

@@ -31,6 +31,11 @@ DECAY_CELLS = 10 ; every count loses one each 3600 frames
CHANGE_SLOTS = 8

cnt_ptr = $56 ; walk count row
; The walk counts live in the free RAM at $C000-$CF9F (no VIC bank uses it):
; below VIC bank 1 there is no room for them next to the program.
walk_counts = $C000
COUNT_BYTES = WORLD_WIDTH * WORLD_HEIGHT
.export walk_counts
ap_bmp = $58 ; cell being redrawn: bitmap
ap_scr = $5A ; screen RAM

@@ -41,15 +46,19 @@ reset_paths:
sta cnt_ptr
lda #>walk_counts
sta cnt_ptr+1
ldx #16 ; pages
ldx #>COUNT_BYTES ; whole pages
lda #0
tay
@clear: sta (cnt_ptr),y ; clears whole pages: walk_counts is followed
iny ; by paths_pad so the last page is its own
@clear: sta (cnt_ptr),y
iny
bne @clear
inc cnt_ptr+1
dex
bne @clear
@rest: sta (cnt_ptr),y ; the last part page: exactly 4,000 bytes, so
iny ; nothing after the counts is touched
cpy #<COUNT_BYTES
bne @rest
sta chg_count
sta decay_cx
sta decay_cy
@@ -374,6 +383,4 @@ ap_pat: .res 1
ap_cur: .res 1
ap_dots: .res 1
ap_first: .res 1
walk_counts: .res WORLD_WIDTH * WORLD_HEIGHT
paths_pad: .res 16 * 256 - WORLD_WIDTH * WORLD_HEIGHT ; reset_paths clears whole pages
.assert * <= SCREEN_A, lderror, "Walk counts must fit below VIC bank 1"
.assert * <= SCREEN_A, lderror, "Path data must fit below VIC bank 1"

+ 47
- 4
src/people.inc Ver fichero

@@ -12,7 +12,7 @@ TURN_TRIES = 5 ; current direction, then all four from a random
.assert WATER_SE + 1 = ROAD_H, error, "Blocking tiles must be contiguous"
.assert BRIDGE_X + 1 = TILE_COUNT, error, "Bridge tiles must come last"

.export people_cx, people_moved, people_in_view
.export people_cx, people_moved, people_in_view, people_attr, shown_person, draw_skip

.segment "CODE"
; Put each person on a random walkable cell; person N goes in sector N mod 4,
@@ -69,6 +69,30 @@ place_people:
inx
cpx #PEOPLE_COUNT
bne @person
; fall through

; Roll every person's six scores (R8): 3d6 each, 3-18. Person 1 is shown.
roll_attributes:
ldy #PEOPLE_COUNT * ATTR_COUNT - 1
@score: lda #0
sta attr_sum
ldx #3 ; three dice
@die: jsr random_byte ; keeps X and Y
and #7
cmp #6
bcs @die ; 6 or 7: roll again, so 0-5 are equally likely
sec ; + 1: 1-6
adc attr_sum
sta attr_sum
dex
bne @die
sta people_attr,y
dey
bpl @score
lda #0
sta shown_person
lda #1
sta shown_dirty
rts

; Move two people per frame: each person takes one pixel step every 8 frames.
@@ -272,9 +296,18 @@ restore_people:
rts

; Draw every person inside buffer people_buf (relative to its top-left world
; cell), saving the byte under each one in that buffer's list.
; Call restore_people first.
; cell), saving the byte under each one in that buffer's list. The person
; shown in the status lines blinks: it is left out (draw_skip) for 16 of
; every 32 frames. Call restore_people first.
draw_people:
lda #$FF
sta draw_skip
lda move_frame
and #16
beq @blink
lda shown_person
sta draw_skip
@blink:
ldx people_buf
lda list_starts,x
sta list_start
@@ -289,6 +322,8 @@ draw_people:
sta draw_rows
ldx #0
@person:
cpx draw_skip
beq @next
lda people_cy,x
sec
sbc draw_cy
@@ -404,13 +439,21 @@ bitmap_row_high:
.endrepeat

.segment "BSS"
; Keep these five tables together: tools/check-people.ps1 saves them as one block.
; Keep these five tables, move_frame and draw_skip together, in this order:
; the checks save them as one block (tools/check-people.ps1, check-split.ps1,
; check-scroll.ps1).
people_cx: .res PEOPLE_COUNT
people_sx: .res PEOPLE_COUNT
people_cy: .res PEOPLE_COUNT
people_sy: .res PEOPLE_COUNT
people_dir: .res PEOPLE_COUNT
move_frame: .res 1
draw_skip: .res 1 ; person left out of the last draw, $FF = none
ATTR_COUNT = 6 ; STR, DEX, CON, INT, WIS, CHA
people_attr: .res PEOPLE_COUNT * ATTR_COUNT ; person * 6 + score
shown_person: .res 1 ; 0-15: whose scores the status lines show
shown_dirty: .res 1 ; nonzero: status line 4 must be rewritten
attr_sum: .res 1
person: .res 1
tries: .res 1
cand_cx: .res 1


+ 36
- 2
src/status.inc Ver fichero

@@ -57,6 +57,8 @@ SPLIT_DELAY_BAD = 1 ; y-scroll 2: line 210 is a bad line, whose DMA
VIEW_X_DIGITS = 1 * 40 + 7 ; row 21: "VIEW X nn"
VIEW_Y_DIGITS = 1 * 40 + 12 ; row 21: "Y nn"
PEOPLE_DIGITS = 2 * 40 + 15 ; row 22, after "PEOPLE IN VIEW "
PERSON_DIGITS = 3 * 40 + 1 ; row 23: "Pnn", the shown person (R8)
ATTR_DIGITS = 3 * 40 + 7 ; row 23: "STRnn", then every 6 characters

.assert ((SCREEN_A + TEXT1_OFFSET) & $03FF) = 0, error, "Text screen must be 1 KB aligned"
.assert (FONT_A & $07FF) = 0, error, "Font must be 2 KB aligned"
@@ -131,6 +133,36 @@ show_number:
sta TEXT_B2,y
rts

; Status line 4: the shown person's number (1-16) and six scores.
show_person:
lda #0
sta shown_dirty
lda shown_person
clc
adc #1
ldy #PERSON_DIGITS
jsr show_number
lda shown_person ; first score: person * 6
asl a
sta attr_index
asl a
adc attr_index
sta attr_index
lda #ATTR_DIGITS
sta attr_pos
@score: ldx attr_index
lda people_attr,x
ldy attr_pos
jsr show_number
inc attr_index
lda attr_pos
clc
adc #6
sta attr_pos
cmp #ATTR_DIGITS + 6 * ATTR_COUNT
bne @score
rts

install_raster_irq:
sei
lda #<raster_irq
@@ -226,9 +258,11 @@ status_text:
.byte "LAND MAP 64 "
.byte "VIEW X 00 Y 00 "
.byte "PEOPLE IN VIEW 00 OF 16 "
.byte " "
.byte "CRSR SCROLL SPACE NEW WORLD "
.byte "P01 STR00 DEX00 CON00 INT00 WIS00 CHA00 "
.byte "CRSR SCROLL SPACE NEW WORLD P PERSON "
.assert * - status_text = STATUS_ROWS * 40, error, "Status text size"

.segment "BSS"
irq_phase: .res 1
attr_index: .res 1
attr_pos: .res 1

+ 42
- 2
tools/check-keys.ps1 Ver fichero

@@ -11,7 +11,10 @@
direction indicator was removed in M3.3, so the border is no longer checked.)

Scenarios: no key, right, left (right SHIFT), down, up (left SHIFT), down-right,
up-left, and SPACE held from frame 60 on (must regenerate exactly once).
up-left, SPACE held from frame 60 on (must regenerate exactly once), and P held from
frame 60 on (R8: must step to the next person exactly once). In every scenario the
people's scores must be 3-18 and status line 4 (text screen 1 of buffer A) must show
the shown person's number and six scores.

Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing.

@@ -41,7 +44,8 @@ try {
}

$hooks = @{}
foreach ($s in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'keys_read', 'space_ready', 'scroll_dx') {
foreach ($s in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p', 'keys_read', 'space_ready', 'scroll_dx',
'people_attr', 'shown_person') {
$hooks[$s] = Get-Label $target $s
}

@@ -56,7 +60,9 @@ $scenarios = @(
@{ name = 'CRSR RIGHT+DOWN'; cursor = '7b'; lshift = 'ff'; rshift = 'ff'; dx = 1; dy = 1 }
@{ name = 'left SHIFT+RIGHT+DOWN'; cursor = '7b'; lshift = '7f'; rshift = 'ff'; dx = -1; dy = -1 }
@{ name = 'SPACE held'; cursor = 'ff'; lshift = 'ff'; rshift = 'ff'; space = 'ef'; spaceAfter = 60; dx = 0; dy = 0; regenerations = 1 }
@{ name = 'P held'; cursor = 'ff'; lshift = 'ff'; rshift = 'ff'; p = 'fd'; pAfter = 60; dx = 0; dy = 0; person = 1 }
)
$STATUS_LINE4 = 0x4000 + 0x0400 + 23 * 40 # buffer A, text screen 1, row 23 (src/status.inc)

$root = Get-RepoPath 'build/check-keys'
if (Test-Path -LiteralPath $root) { Remove-Item -LiteralPath $root -Recurse -Force }
@@ -83,7 +89,16 @@ foreach ($sc in $scenarios) {
} else {
& $add $hooks.key_row_space 'r a = ff'
}
if ($sc.p) {
& $add $hooks.key_row_p "r a = $($sc.p)"
$mon.Add(('ignore {0} {1}' -f $n, $sc.pAfter))
} else {
& $add $hooks.key_row_p 'r a = ff'
}
& $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $hooks.scroll_dx, ($hooks.scroll_dx + 1))
& $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $hooks.people_attr, ($hooks.people_attr + 95))
& $add $hooks.keys_read ('m {0:x4} {0:x4}' -f $hooks.shown_person)
& $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $STATUS_LINE4, ($STATUS_LINE4 + 39))
$spaceCheckpoint = $n + 1
& $add $hooks.space_ready 'r'
Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $mon
@@ -99,8 +114,17 @@ foreach ($sc in $scenarios) {

$log = Join-Path $dir 'monitor.log'
$scroll = $null; $frames = 0; $regenerations = 0
$dumps = @{}; $dumpAddr = -1 # last frame's dumps: address -> bytes (a dump spans several lines)
if (Test-Path -LiteralPath $log) {
foreach ($line in Get-Content -LiteralPath $log) {
if ($line -match '^>C:([0-9a-f]{4})\s+((?:[0-9a-f]{2} )+)') {
$a = [Convert]::ToInt32($Matches[1], 16)
$bytes = @($Matches[2].Trim() -split ' ' | ForEach-Object { [Convert]::ToByte($_, 16) })
if ($a -in $hooks.people_attr, $hooks.shown_person, $STATUS_LINE4) { $dumpAddr = $a; $dumps[$a] = [System.Collections.Generic.List[byte]]::new() }
elseif ($a -ne $hooks.scroll_dx -and $dumpAddr -ge 0 -and $a -eq $dumpAddr + $dumps[$dumpAddr].Count) { }
else { $dumpAddr = -1 }
if ($dumpAddr -ge 0) { $dumps[$dumpAddr].AddRange([byte[]]$bytes) }
}
if ($line -match ('^#{0} \(Trace' -f $spaceCheckpoint)) { $regenerations++ }
elseif ($line -match ('^>C:{0:x4}\s+([0-9a-f]{{2}}) ([0-9a-f]{{2}})' -f $hooks.scroll_dx)) {
$scroll = @([Convert]::ToByte($Matches[1], 16), [Convert]::ToByte($Matches[2], 16)) | ForEach-Object { if ($_ -ge 128) { $_ - 256 } else { [int]$_ } }; $frames++
@@ -110,6 +134,21 @@ foreach ($sc in $scenarios) {
$problems = @()
if ($frames -lt 30) { $problems += "only $frames frames reached keys_read" }
elseif ($scroll[0] -ne $sc.dx -or $scroll[1] -ne $sc.dy) { $problems += "scroll ($($scroll[0]),$($scroll[1])), expected ($($sc.dx),$($sc.dy))" }
# R8: scores 3-18; status line 4 shows "Pnn" and the six scores of the shown person.
$wantPerson = if ($sc.person) { $sc.person } else { 0 }
if (@($hooks.people_attr, $hooks.shown_person, $STATUS_LINE4) | Where-Object { -not $dumps.ContainsKey($_) -or $dumps[$_].Count -eq 0 }) { $problems += 'scores or status line 4 not logged' }
else {
$attr = $dumps[$hooks.people_attr]; $shown = $dumps[$hooks.shown_person][0]; $line4 = $dumps[$STATUS_LINE4]
$bad = @($attr[0..95] | Where-Object { $_ -lt 3 -or $_ -gt 18 })
if ($bad.Count) { $problems += "$($bad.Count) scores outside 3-18" }
if ($shown -ne $wantPerson) { $problems += "shown person $($shown + 1), expected $($wantPerson + 1)" }
$digits = { param($at) ($line4[$at] - 0x30) * 10 + ($line4[$at + 1] - 0x30) }
if ((& $digits 1) -ne $shown + 1) { $problems += "status shows person $(& $digits 1), expected $($shown + 1)" }
for ($k = 0; $k -lt 6; $k++) {
if ((& $digits (7 + 6 * $k)) -ne $attr[6 * $shown + $k]) { $problems += "status score $($k + 1) shows $(& $digits (7 + 6 * $k)), expected $($attr[6 * $shown + $k])"; break }
}
$scoresText = ($attr[(6 * $shown)..(6 * $shown + 5)] -join ' ')
}
$wantRegen = if ($sc.regenerations) { $sc.regenerations } else { 0 }
if ($regenerations -ne $wantRegen) { $problems += "$regenerations regenerations, expected $wantRegen" }
if ($problems.Count -gt 0) {
@@ -117,6 +156,7 @@ foreach ($sc in $scenarios) {
Write-Host (" FAIL {0}: {1}" -f $sc.name, ($problems -join '; ')) -ForegroundColor Red
} else {
$extra = if ($sc.space) { ", $regenerations regeneration while held" } else { '' }
$extra += ", person $($wantPerson + 1) shown: $scoresText"
Write-Host (" ok {0}: scroll ({1},{2}), {3} frames{4}" -f $sc.name, $scroll[0], $scroll[1], $frames, $extra)
}
}


+ 1
- 1
tools/check-paths.ps1 Ver fichero

@@ -128,7 +128,7 @@ Add-Trace $L.people_moved (& $bsave 'counts2.bin' $L.drawn_count 2) $every
Add-Trace $L.people_moved (& $bsave 'lists.bin' $L.drawn_low 32) $every
Add-Trace $L.people_moved (& $bsave 'listh.bin' $L.drawn_high 32) $every
Add-Trace $L.people_moved (& $bsave 'listb.bin' $L.drawn_byte 32) $every
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { Add-Trace $L[$row] 'r a = ff' $null }
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p') { Add-Trace $L[$row] 'r a = ff' $null }
Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $mon
Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value ''



+ 7
- 4
tools/check-people.ps1 Ver fichero

@@ -87,7 +87,9 @@ $moved = Get-Label $target 'people_moved'
$world = Get-Label $target 'world_tiles'
$people = Get-Label $target 'people_cx'
$visibleFlag = Get-Label $target 'visible'
$tableEnd = $people + 5 * $count - 1
# The five people tables, then move_frame and draw_skip (src/people.inc keeps them together).
$tableSize = 5 * $count + 2
$tableEnd = $people + $tableSize - 1
$bitmapSize = 20 * 320 # the 20 map rows; rows 20-24 lie under the status text
$buffers = @(0x6000, 0xA000) # bitmaps of buffers A and B (src/main.s)
$monitor = [System.Collections.Generic.List[string]]::new()
@@ -109,7 +111,7 @@ Add-Trace $moved ('bsave \"final-a.bin\" 0 {0:x4} {1:x4}' -f $buffers[0], ($buff
Add-Trace $moved ('bsave \"final-b.bin\" 0 {0:x4} {1:x4}' -f $buffers[1], ($buffers[1] + $bitmapSize - 1))
# No key is held during this check: keys typed on the PC while VICE has focus
# would otherwise reach the program (the arrow keys scroll the view).
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { Add-Trace (Get-Label $target $row) 'r a = ff' }
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p') { Add-Trace (Get-Label $target $row) 'r a = ff' }
Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $monitor
Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value ''

@@ -147,9 +149,9 @@ foreach ($line in Get-Content -LiteralPath $logFile) {
if ($addr -eq $visibleFlag) { $visibleLog.Add([Convert]::ToInt32($hexBytes[0], 16)); continue }
if ($addr -eq $people) { $current.Clear() }
foreach ($hex in $hexBytes) {
if ($current.Count -lt 5 * $count) { $current.Add([Convert]::ToByte($hex, 16)) }
if ($current.Count -lt $tableSize) { $current.Add([Convert]::ToByte($hex, 16)) }
}
if ($current.Count -eq 5 * $count) { $frames.Add($current.ToArray()); $current.Clear() }
if ($current.Count -eq $tableSize) { $frames.Add($current.ToArray()); $current.Clear() }
}
if ($frames.Count -lt 60) { Write-Host "[FAIL] Only $($frames.Count) frames logged." -ForegroundColor Red; exit 1 }

@@ -201,6 +203,7 @@ function Get-ExpectedBitmap([byte[]]$Clean, [byte[]]$Table) {
$bitmap = [byte[]]$Clean.Clone()
$masks = 0xC0, 0x30, 0x0C, 0x03
for ($i = 0; $i -lt $count; $i++) {
if ($i -eq $Table[5 * $count + 1]) { continue } # draw_skip: the shown person blinks (R8)
$cx = $Table[$i]; $cy = $Table[32 + $i]
if ($cx -ge 39 -or $cy -ge 20) { continue } # 39 drawn columns; the dumps hold the 20 map rows
$offset = $cy * 320 + $cx * 8 + $Table[48 + $i]


+ 8
- 5
tools/check-scroll.ps1 Ver fichero

@@ -126,8 +126,10 @@ $L = @{}
foreach ($s in 'smoke_ready', 'people_moved', 'world_tiles', 'people_cx', 'visible', 'view_cx', 'map_d011', 'map_d016',
'move_frame', 'people_flip_pending', 'buf_cx', 'buf_cy', 'buf_ready', 'view_fx', 'view_cy', 'view_fy',
'frame_start', 'frame_done', 'start_rebuild', 'rebuild_ready',
'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { $L[$s] = Get-Label $target $s }
'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p') { $L[$s] = Get-Label $target $s }
$CHANGE_SLOTS = 8 # src/paths.inc
$PEOPLE_BLOCK = 82 # five people tables, move_frame, draw_skip (src/people.inc keeps them together)
if ((Get-Label $target 'draw_skip') -ne $L.people_cx + 81) { throw 'draw_skip must follow the people tables and move_frame (src/people.inc)' }
foreach ($s in 'chg_count', 'chg_done', 'path_changed') { $L[$s] = Get-Label $target $s }
$IRQ_ENTRY = 0xFF48; $IRQ_EXIT = 0xEA81 # KERNAL IRQ entry and the exit our handler jumps to
$FRAME_CYCLES = 17095
@@ -228,7 +230,7 @@ foreach ($sc in $scenarios) {
$lastPhase = $sc.phases.Count - 1
& $add $L.smoke_ready ('bsave \"world.bin\" 0 {0:x4} {1:x4}' -f $L.world_tiles, ($L.world_tiles + 3999)) $null
& $add $L.smoke_ready ('> {0:x4} 00' -f $PHASE) $null
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { & $add $L[$row] 'r a = ff' $null }
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p') { & $add $L[$row] 'r a = ff' $null }
for ($ph = 0; $ph -le $lastPhase; $ph++) { # later checkpoints at one address run after earlier ones
$k = $sc.phases[$ph]
if ($k.cursor -ne $NONE) { & $add $L.key_row_cursor "r a = $($k.cursor)" @(, @($PHASE, $ph)) }
@@ -258,7 +260,7 @@ foreach ($sc in $scenarios) {
& $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.buf_cy, ($L.buf_cy + 1)) $null
& $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.buf_ready, ($L.buf_ready + 1)) $null
& $add $L.people_moved ('m {0:x4} {0:x4}' -f $PHASE) $null
& $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.people_cx, ($L.people_cx + 79)) $null
& $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.people_cx, ($L.people_cx + $PEOPLE_BLOCK - 1)) $null
foreach ($save in $saves) {
$f = $save -split ' '
& $add $L.people_moved ('bsave \"{0}\" 0 {1} {2}' -f $f[0], $f[1], $f[2]) @(, @($PHASE, $lastPhase))
@@ -326,13 +328,13 @@ foreach ($sc in $scenarios) {
elseif ($addr -eq $L.buf_cx) { $cur.bufcx = $bytes[0..1] }
elseif ($addr -eq $L.buf_cy) { $cur.bufcy = $bytes[0..1] }
elseif ($addr -eq $L.buf_ready) { $cur.ready = $bytes[0..1] }
elseif ($addr -ge $L.people_cx -and $addr -lt $L.people_cx + 80) { foreach ($b in $bytes) { if ($cur.people.Count -lt 80) { $cur.people.Add($b) } } }
elseif ($addr -ge $L.people_cx -and $addr -lt $L.people_cx + $PEOPLE_BLOCK) { foreach ($b in $bytes) { if ($cur.people.Count -lt $PEOPLE_BLOCK) { $cur.people.Add($b) } } }
}
# The run stops at a cycle limit, possibly while the last frame was being logged.
$fields = 'cx', 'd011', 'visible', 'pending', 'bufcx', 'bufcy', 'ready', 'phase', 'clock'
while ($frames.Count -gt 0) {
$lf = $frames[$frames.Count - 1]
if ($lf.people.Count -eq 80 -and -not @($fields | Where-Object { $null -eq $lf[$_] })) { break }
if ($lf.people.Count -eq $PEOPLE_BLOCK -and -not @($fields | Where-Object { $null -eq $lf[$_] })) { break }
$frames.RemoveAt($frames.Count - 1)
}
$failures = [System.Collections.Generic.List[string]]::new()
@@ -443,6 +445,7 @@ foreach ($sc in $scenarios) {
$screen = [IO.File]::ReadAllBytes((Join-Path $dir "${prefix}screen-$suffix.bin"))
$dots = @{}
for ($i = 0; $i -lt 16; $i++) {
if ($i -eq $people[81]) { continue } # draw_skip: the shown person blinks (R8)
$col = $people[$i] - $at.cx; $row = $people[32 + $i] - $at.cy
if ($col -ge 0 -and $col -lt 39 -and $row -ge 0 -and $row -lt 21) {
$o = $row * 320 + $col * 8 + $people[48 + $i]


+ 4
- 5
tools/check-split.ps1 Ver fichero

@@ -25,7 +25,7 @@
(24-row, 38-column display; buffer pixel rows fy..fy+155 and hires pixel columns
fx..fx+303), counted here from the people table and view of the updating frame;
- in the exit screenshot, the 40 text lines (raster 211-250) contain only the background colour
and white, status rows 20, 21, 22 and 24 are lit and row 23 is empty, and
and white, all five status rows 20-24 are lit (row 23: the shown person's scores, R8), and
the last map line (raster 210) uses no colour foreign to the map. This is a
coarse check: in the delay sweep it caught damage from writes at 210:40-46 but
not subtler damage, so the timing window above is the main guard.
@@ -62,7 +62,7 @@ New-Item -ItemType Directory -Force -Path $dir | Out-Null

$L = @{}
foreach ($sym in 'split_store', 'split_delay', 'people_moved', 'smoke_ready', 'people_cx', 'map_d011', 'move_frame', 'view_cx', 'view_cy', 'view_fy',
'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { $L[$sym] = Get-Label $target $sym }
'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p') { $L[$sym] = Get-Label $target $sym }
$digits = @(0x4400, 0x8400) | ForEach-Object { $_ + 22 * 40 + 15 } # row 22, after "PEOPLE IN VIEW "
$PHASE = 0xCFF0 # free RAM: scroll phase 0 still, 1 down, 2 up, 3 still
$cond = { param($pairs) ($pairs | ForEach-Object { '(@cpu:${0:x4} == ${1:x2})' -f $_[0], $_[1] }) -join ' && ' }
@@ -79,7 +79,7 @@ $mon = @(
('trace exec ${0:x4}' -f $L.smoke_ready), ('command 7 "> {0:x4} 00"' -f $PHASE)
)
$n = 7
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') {
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p') {
$n++; $mon += ('trace exec ${0:x4}' -f $L[$row]); $mon += ('command {0} "r a = ff"' -f $n)
}
$n++; $mon += ('trace exec ${0:x4} if {1}' -f $L.key_row_cursor, (& $cond @(, @($PHASE, 1)))); $mon += ('command {0} "r a = 7f"' -f $n)
@@ -179,8 +179,7 @@ if (-not (Test-Path -LiteralPath $shot)) { $failures.Add('no exit screenshot') }
}
}
if ($textColours.Count -gt 1) { $failures.Add("status area shows $($textColours.Count) colours besides the background (expected white only)") }
foreach ($row in 0, 1, 2, 4) { if (-not $textLit.ContainsKey($row)) { $failures.Add("status row $($row + 20) is empty in the screenshot") } }
if ($textLit.ContainsKey(3)) { $failures.Add('the spare status row 23 is not empty') }
foreach ($row in 0..4) { if (-not $textLit.ContainsKey($row)) { $failures.Add("status row $($row + 20) is empty in the screenshot") } }
# Map colours: background, white, grey, green, blue, black as rendered in the map area above.
$mapColours = @{}
for ($y = 51 - 28; $y -le 209 - 28; $y++) { for ($x = 0; $x -lt $bmp.Width; $x++) { $mapColours[$bmp.GetPixel($x, $y).ToArgb()] = 1 } }


+ 1
- 1
tools/check-world.ps1 Ver fichero

@@ -163,7 +163,7 @@ if ($Runs -le 0) {
('trace exec ${0:x4}' -f $labels.generate_world))
$n = 2
# No key may reach the program: keys typed on the PC while VICE has focus would.
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') {
foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p') {
$n++; $mon += ('trace exec ${0:x4}' -f $labels[$row]); $mon += ('command {0} "r a = ff"' -f $n)
}
Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $mon


Cargando…
Cancelar
Guardar

Powered by TurnKey Linux.