- M7.1: people tables as one 256-byte page per field in free video-bank RAM - M7.2: people drawn only into the hidden buffer and flipped in - M7.3: + adds and - removes people (repeat when held); status P001/016; raster IRQ frame count lets people catch up when frames drop - Checks: check-keys +/- scenarios, check-people -People N, check-paths reads buffer variables by label Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>main
| @@ -1,6 +1,6 @@ | |||||
| # Land Map 64 | # 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. Each person has a random name, a sex (M or F) and six D&D-style scores (3d6); P steps through the people, showing the chosen one below the map and making their dot blink. 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 at first, 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 a random name, a sex (M or F) and six D&D-style scores (3d6); P steps through the people, showing the chosen one below the map and making their dot blink. + adds a person and - removes the last one (1 to 255 people; with many, the picture updates less often but people keep their speed). 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)) | - 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)) | - Language/toolchain: 6502 assembly (ca65) - Windows cross-development with cc65 (C, ca65 assembly or mixed) and VICE ([docs/toolchain.md](docs/toolchain.md)) | ||||
| @@ -377,3 +377,29 @@ Expected: | |||||
| - Cursor keys, SPACE and P still work; SPACE gives new names, sexes and scores and shows P01. | - Cursor keys, SPACE and P still work; SPACE gives new names, sexes and scores and shows P01. | ||||
| Verifies: R8, R6 | Verifies: R8, R6 | ||||
| ## M7 - A changing number of people | |||||
| ### MT7.1: Adding and removing people (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` and `pwsh -File tools/check-people.ps1 -People 255` | |||||
| should end with `[PASS]`. | |||||
| Steps: | |||||
| 1. Wait for the map and read status line 1. | |||||
| 2. Press + a few times, then hold + until the count passes 100. | |||||
| 3. Hold + until it stops, then scroll around. | |||||
| 4. Press P a few times, then hold - until it stops. | |||||
| 5. Press SPACE. | |||||
| Expected: | |||||
| - Line 1 reads like `P001/016 ALDRIC M` | |||||
| - Each + press adds one to the count and a new dot appears somewhere in the world; held, the count climbs about 12 a second | |||||
| - The count stops at 255; the map gets less smooth, but people walk at the same speed and no trails or broken terrain appear | |||||
| - The - key removes people down to `P001/001`; the shown person changes to the last one when they are removed | |||||
| - SPACE gives a new world with 16 people: `P001/016` | |||||
| Verifies: R2, R3, R8 | |||||
| @@ -94,3 +94,17 @@ Requirements: R8, R6, R2, R3 | |||||
| | M6.2 | Status area shows only the chosen person, who gets a random name and sex: sex 50/50 (people_sex), name from a start syllable, half the time a middle one, and a male or female end syllable (people_name, 10 letters, space padded), rolled with the scores. Row 20 'Pnn' + name + M/F, row 21 the scores, rows 22-24 blank; the title, view position, people-in-view count and key help (and the per-frame status update and people-in-view count) are removed. All keys still work. | R8, R6 | Status area shows the chosen person's name, sex and scores only | `pwsh -File tools/check-keys.ps1` (names 3-10 letters, sex 0/1, rows 20-21 match the shown person), `tools/check-split.ps1` (rows 20-21 lit, 22-24 blank, person 01 in both banks), `tools/smoke.ps1`; manual test MT6.2 | | | M6.2 | Status area shows only the chosen person, who gets a random name and sex: sex 50/50 (people_sex), name from a start syllable, half the time a middle one, and a male or female end syllable (people_name, 10 letters, space padded), rolled with the scores. Row 20 'Pnn' + name + M/F, row 21 the scores, rows 22-24 blank; the title, view position, people-in-view count and key help (and the per-frame status update and people-in-view count) are removed. All keys still work. | R8, R6 | Status area shows the chosen person's name, sex and scores only | `pwsh -File tools/check-keys.ps1` (names 3-10 letters, sex 0/1, rows 20-21 match the shown person), `tools/check-split.ps1` (rows 20-21 lit, 22-24 blank, person 01 in both banks), `tools/smoke.ps1`; manual test MT6.2 | | ||||
| Manual verification: see docs/manual-tests.md section M6. | Manual verification: see docs/manual-tests.md section M6. | ||||
| ## M7 - A changing number of people | |||||
| Goal: 1 to 255 people, 16 in a new world; + and - change the number while the program runs; people keep their speed. | |||||
| Requirements: R2, R3, R8 | |||||
| | Task | Description | Requirements | Buildable outcome | Completion check | | |||||
| |---|---|---|---|---| | |||||
| | M7.1 | Memory layout that grows: every people table becomes one 256-byte page per field, indexed by person 0-254 (positions $4C00-$4FFF; direction, sex and the six scores $5800-$5FFF; saved bytes under the dots of both buffers $8C00-$91FF; the ten name letters $9200-$9BFF), so no table moves when the number changes. people_count (1-255) replaces the fixed 16 everywhere: placing, moving (every 8th person per frame), drawing, P, the status line. | R2, R8 | Same program with 16 people, its tables ready for up to 255 | `pwsh -File tools/smoke.ps1`, `tools/check-world.ps1`, `tools/check-keys.ps1`, `tools/check-people.ps1`, `tools/check-split.ps1`, `tools/check-paths.ps1` | | |||||
| | M7.2 | People are drawn only into the hidden buffer (people_update in the main loop, once the hidden buffer is complete; buf_dots marks it) and flipped in at the next vertical blank, which now does no people work. A scroll step that crosses a cell waits until the rebuilt buffer has its people too. | R3, R5 | Vertical blank work no longer grows with the number of people | `pwsh -File tools/check-people.ps1` (both buffers hold the clean map plus the right dots), `tools/check-scroll.ps1 -Long and -Long -PathTest` | | |||||
| | M7.3 | + adds a person at a random walkable spot with a new name, sex and scores (up to 255); - removes the last one (down to 1; if they were shown, the new last person is shown). Held, both repeat after 30 frames, then every 5th frame. Status line 1 shows P001/016 (person / number of people). The raster IRQ counts frames, so when the main loop takes longer than a frame the people catch up on the missed frames (up to 4) and keep their speed. | R2, R8, R3 | + and - change the number of people while it runs | `pwsh -File tools/check-keys.ps1` (+ held: the count climbs past 40, `- held: stops at 1`, `status shows P001/nnn)`, `tools/check-people.ps1 -People 255`, `tools/smoke.ps1`, manual test MT7.1 | | |||||
| Manual verification: see docs/manual-tests.md section M7. | |||||
| @@ -12,10 +12,11 @@ Changes approved by the user since then: | |||||
| - 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: 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. | - 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. | ||||
| - 2026-12-04: Status area shows only the chosen person, who also gets a name and a sex ("we dont need land map 64 text, view, or people in view or the directions on how to move the screen or new world or person; we do want the person's attributes; also every person needs a random name and needs to be male or female"): the title, view position, people-in-view count and key help are removed from the status area (R6); the keys all still work. R8 adds a random sex (50/50, shown as M or F) and a random name of 2-3 syllables from male or female syllable lists (up to 10 letters); line 1 shows number, name and sex, line 2 the scores, lines 3-5 are blank (layout chosen by the user). New task M6.2. | - 2026-12-04: Status area shows only the chosen person, who also gets a name and a sex ("we dont need land map 64 text, view, or people in view or the directions on how to move the screen or new world or person; we do want the person's attributes; also every person needs a random name and needs to be male or female"): the title, view position, people-in-view count and key help are removed from the status area (R6); the keys all still work. R8 adds a random sex (50/50, shown as M or F) and a random name of 2-3 syllables from male or female syllable lists (up to 10 letters); line 1 shows number, name and sex, line 2 the scores, lines 3-5 are blank (layout chosen by the user). New task M6.2. | ||||
| - 2026-12-04: A changing number of people ("if I make the people count 32 it messes up memory location and attributes dont show correctly"; "# of people can be dynamic so the memory needs to place in a way that it can expand or contract"): R2 now has 1-255 people, 16 in a new world; + adds a person and - removes the last one while the program runs (keys, maximum and change-while-running chosen by the user). The people's tables move to one 256-byte page per field in free RAM inside the video banks. R3: people are drawn only into the hidden buffer and flipped in; with many people the main loop may take more than a frame, and then the picture (and the scroll) updates less often while every person keeps walking at the same speed ("keep speed, drop frames", chosen by the user). R8: status line 1 shows `P001/016`: the person's number and the number of people. New milestone M7. | |||||
| ## Summary | ## Summary | ||||
| 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 at first (1-255, + and - change the number), 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. | |||||
| Original idea, as given: | Original idea, as given: | ||||
| @@ -25,14 +26,14 @@ Smallest useful version: A 2x2-screen world generated from a seed at start-up, s | |||||
| ## First release | ## First release | ||||
| A generated 2x2-screen world in multicolour bitmap mode with pixel-smooth cursor-key scrolling, a 5-line status area below the map showing the chosen person, 16 moving people blocked by water and stone, double-buffered partial redraw, and SPACE for a new world. | |||||
| A generated 2x2-screen world in multicolour bitmap mode with pixel-smooth cursor-key scrolling, a 5-line status area below the map showing the chosen person, 16 moving people (1-255 with + and -) blocked by water and stone, double-buffered partial redraw, and SPACE for a new world. | |||||
| ### In scope | ### In scope | ||||
| - Procedural generation of a 2x2-screen world (80x50 cells of 4x8 multicolour pixels) from a seed | - Procedural generation of a 2x2-screen world (80x50 cells of 4x8 multicolour pixels) from a seed | ||||
| - Terrain colours: light brown land (background), grey stone, green grass and trees, blue water, dark brown paths worn in by the people | - Terrain colours: light brown land (background), grey stone, green grass and trees, blue water, dark brown paths worn in by the people | ||||
| - Pixel-smooth scrolling of the view with the cursor keys, using the VIC-II fine-scroll registers and a double-buffered coarse shift | - Pixel-smooth scrolling of the view with the cursor keys, using the VIC-II fine-scroll registers and a double-buffered coarse shift | ||||
| - 16 people as white dots (one multicolour pixel each), spread over the world, blocked by water and stone; only those in view are drawn | |||||
| - 16 people as white dots (one multicolour pixel each), spread over the world, blocked by water and stone; only those in view are drawn (since M7: 1-255 people, + and - while running) | |||||
| - Two bitmap buffers flipped once per update; only the bytes under people are restored and redrawn between scroll steps | - Two bitmap buffers flipped once per update; only the bytes under people are restored and redrawn between scroll steps | ||||
| - SPACE generates a new world | - SPACE generates a new world | ||||
| - A 5-line text status area below a 20-row map, using a raster split: the chosen person's number, name, sex and scores | - A 5-line text status area below a 20-row map, using a raster split: the chosen person's number, name, sex and scores | ||||
| @@ -88,31 +89,32 @@ Acceptance criteria: | |||||
| Capabilities: smooth-animation | Capabilities: smooth-animation | ||||
| ### R2 - 16 moving people (must) | |||||
| ### R2 - Moving people, 1 to 255 (must) | |||||
| 16 people, each a single white multicolour pixel, are spread over the world and move on their own. Water and stone block them: they walk only on land, grass, trees and paths. People inside the view are drawn; others keep moving unseen. | |||||
| A new world starts with 16 people, each a single white multicolour pixel, spread over the world; they move on their own. Water and stone block them: they walk only on land, grass, trees and paths. People inside the view are drawn; others keep moving unseen. While the program runs, + adds a person (a new name, sex and scores, on a random walkable spot) and - removes the last one; there are always 1 to 255 people. Held, + and - repeat. Each person steps every 8 frames however many people there are; with many people the picture updates less often instead (R3). | |||||
| Acceptance criteria: | Acceptance criteria: | ||||
| - [R2.1] Scrolling around the world shows 16 white dots in total | |||||
| - [R2.2] Each visible dot moves at least once per second | |||||
| - [R2.1] Scrolling around a new world shows 16 white dots in total | |||||
| - [R2.2] Each visible dot moves at least once per second, also with 255 people | |||||
| - [R2.3] No dot ever enters a blue (water) or grey (stone) pixel | - [R2.3] No dot ever enters a blue (water) or grey (stone) pixel | ||||
| - [R2.4] + adds one person (up to 255) and - removes the last one (down to 1); held, they repeat; the status line shows the new number of people (R8.2) and the new person's dot appears and moves | |||||
| Capabilities: smooth-animation | Capabilities: smooth-animation | ||||
| ### R3 - Flicker-free double buffering, partial redraw (must) | ### R3 - Flicker-free double buffering, partial redraw (must) | ||||
| While the view is still, people are drawn into the hidden bitmap buffer, which is then flipped into view during vertical blank. While the view scrolls, the hidden buffer is being rebuilt for the next scroll step, so people are restored and drawn in the shown buffer during vertical blank, before the first map line, and the rebuilt buffer is flipped in at the scroll step. Each update restores only the bitmap bytes under people at their previous positions in that buffer and draws them at their new positions; apart from the scroll rebuild, the rest of the map is never redrawn. | |||||
| People are drawn only into the hidden bitmap buffer, never into the shown one, and the hidden buffer is flipped into view during vertical blank. While the view scrolls, the hidden buffer is rebuilt for the next scroll step; once it is complete the people are drawn into it, and it is flipped in at the scroll step. Each update restores only the bitmap bytes under people at their previous positions in that buffer and draws them at their new positions; apart from the scroll rebuild and changed path cells, the rest of the map is never redrawn. (Since M7; before, people were drawn into the shown buffer during vertical blank while a rebuild ran, which does not scale beyond about 16 people.) With up to about 64 people every frame is a new picture; with more, the main loop takes longer than a frame and the picture and the scroll update every 2nd to 4th frame, while people keep their walking speed. | |||||
| Acceptance criteria: | Acceptance criteria: | ||||
| - [R3.1] No flicker or tearing of the dots is visible in VICE at normal speed | - [R3.1] No flicker or tearing of the dots is visible in VICE at normal speed | ||||
| - [R3.2] After 5 minutes of running and scrolling, the map has no leftover white trails or damaged terrain | - [R3.2] After 5 minutes of running and scrolling, the map has no leftover white trails or damaged terrain | ||||
| - [R3.3] A people update (restore, draw, flip) completes within one NTSC frame | |||||
| - [R3.3] With 16 people a people update (restore, draw, flip) completes within one NTSC frame; with more people the vertical blank work still ends before the first map line, and people keep their speed | |||||
| Capabilities: smooth-animation, raster-interrupts | Capabilities: smooth-animation, raster-interrupts | ||||
| ### R4 - New world on SPACE (must) | ### R4 - New world on SPACE (must) | ||||
| Pressing SPACE generates and shows a different world, with the 16 people placed on it. | |||||
| Pressing SPACE generates and shows a different world, with 16 people placed on it (however many there were before). | |||||
| Acceptance criteria: | Acceptance criteria: | ||||
| - [R4.1] Pressing SPACE replaces the world with a visibly different one | - [R4.1] Pressing SPACE replaces the world with a visibly different one | ||||
| @@ -158,12 +160,12 @@ Capabilities: smooth-animation | |||||
| ### R8 - People's attributes (must) | ### R8 - People's attributes (must) | ||||
| Each of the 16 people is male or female (at random, 50/50) and has a random name of two or three syllables from a male or female syllable list (up to 10 letters), and six scores, as in D&D: strength, dexterity, constitution, intelligence, wisdom and charisma. Each score 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. The status lines show one person at a time: `P01 ALDRIC M` and `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 names, sexes and scores for the new world and shows person 1. | |||||
| Each person is male or female (at random, 50/50) and has a random name of two or three syllables from a male or female syllable list (up to 10 letters), and six scores, as in D&D: strength, dexterity, constitution, intelligence, wisdom and charisma. Each score 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. The status lines show one person at a time: `P001/016 ALDRIC M` (person number / number of people, since M7) and `STR12 DEX09 CON15 INT10 WIS08 CHA13`. Each press of P shows the next person (after the last comes 1); holding P does not repeat. If the shown person is removed with -, the new last person is shown. 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 names, sexes and scores for the new world and shows person 1. | |||||
| Acceptance criteria: | 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.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 1 shows the chosen person's number (1-16), name and M or F; line 2 their 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.2] Status line 1 shows the chosen person's number and the number of people (`P001/016`), name and M or F; line 2 their 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 the last 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.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 | - [R8.5] The scores do not change how people move | ||||
| - [R8.6] Every person is male or female at random and has a random name of 2-3 syllables (up to 10 letters) from the male or female syllable list; SPACE gives new ones | - [R8.6] Every person is male or female at random and has a random name of 2-3 syllables (up to 10 letters) from the male or female syllable list; SPACE gives new ones | ||||
| @@ -176,14 +178,14 @@ Capabilities: keyboard-input | |||||
| | Topic | Decision | Source | | | 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. 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 | | |||||
| | 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). + adds a person and - removes the last one (R2, M7; held, they repeat after half a second, about 12 times a second). 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 | | | 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 | | | Sound | None in the first release. | practical default | | ||||
| | Persistence (save/load) | None. Maps and seeds are not saved. | practical default | | | Persistence (save/load) | None. Maps and seeds are not saved. | practical default | | ||||
| | File formats | None. A single PRG. | practical default | | | File formats | None. A single PRG. | practical default | | ||||
| | Peripherals | Keyboard only. No disk access after loading, no joystick. | 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. 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 | | |||||
| | 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 with up to about 64 people (measured in M7: 128 people take 2 frames per main-loop pass, 255 take 4; people keep their speed, M7). 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. Program, tables and variables (world tiles) lie below $4000; the 4,000 walk counts (R7) use the free RAM at $C000-$CF9F. The people's tables (since M7) are one 256-byte page per field, indexed by person 0-254, in the RAM the video banks leave free: positions $4C00-$4FFF, direction, sex and the six scores $5800-$5FFF, the saved bytes under the dots of both buffers $8C00-$91FF, and the ten name letters $9200-$9BFF (the VIC sees the character ROM at $9000-$9FFF in bank 2, so the CPU RAM there is free). | 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 | | | 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 | | | 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 | | ||||
| @@ -23,9 +23,20 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n | |||||
| | 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) | | | 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 committed build failed only on stall frames (752, allowed 606; screens byte-exact). Fix for that, 2026-12-03: `pwsh -File tools/check-paths.ps1`; `pwsh -File tools/check-scroll.ps1 -Long -PathTest`: 5 of 5, tour 272 stall frames, 66 paths appeared and 34 faded, 21 stops byte-exact; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-keys.ps1`: 9 of 9; `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,964 frames, 99 stall frames, 21 stops byte-exact) | 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 committed build failed only on stall frames (752, allowed 606; screens byte-exact). Fix for that, 2026-12-03: `pwsh -File tools/check-paths.ps1`; `pwsh -File tools/check-scroll.ps1 -Long -PathTest`: 5 of 5, tour 272 stall frames, 66 paths appeared and 34 faded, 21 stops byte-exact; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-keys.ps1`: 9 of 9; `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,964 frames, 99 stall frames, 21 stops byte-exact) | confirmed by user (2026-12-03) | | ||||
| | M6.2 Status area shows only the chosen person: number, random name and M/F on row 20, scores on row 21, rows 22-24 blank; title, view position, people in view and key help removed. | passed (2026-12-04, `pwsh -File tools/build.ps1` (5,729 bytes); `pwsh -File tools/smoke.ps1`: rows 20-21 "P01 " and "STR" in both banks, row 22 blank; `pwsh -File tools/check-keys.ps1`: 9 of 9, every name 3-10 letters, sexes 0/1 (5-11 of 16 female across scenarios), rows 20-21 match the shown person; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-split.ps1`: 740 splits, person 01 in both banks in 739 of 739 frames, rows 22-24 blank; `pwsh -File tools/check-paths.ps1`: 20 appeared, 2 faded. `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,965 frames, 114 stall frames, 21 stops byte-exact; `pwsh -File tools/check-scroll.ps1 -Long -PathTest`: 5 of 5, tour 218 stall frames, 83 paths appeared and 48 faded, 21 stops byte-exact) | confirmed by user (2026-12-04) | | | M6.2 Status area shows only the chosen person: number, random name and M/F on row 20, scores on row 21, rows 22-24 blank; title, view position, people in view and key help removed. | passed (2026-12-04, `pwsh -File tools/build.ps1` (5,729 bytes); `pwsh -File tools/smoke.ps1`: rows 20-21 "P01 " and "STR" in both banks, row 22 blank; `pwsh -File tools/check-keys.ps1`: 9 of 9, every name 3-10 letters, sexes 0/1 (5-11 of 16 female across scenarios), rows 20-21 match the shown person; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-split.ps1`: 740 splits, person 01 in both banks in 739 of 739 frames, rows 22-24 blank; `pwsh -File tools/check-paths.ps1`: 20 appeared, 2 faded. `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,965 frames, 114 stall frames, 21 stops byte-exact; `pwsh -File tools/check-scroll.ps1 -Long -PathTest`: 5 of 5, tour 218 stall frames, 83 paths appeared and 48 faded, 21 stops byte-exact) | confirmed by user (2026-12-04) | | ||||
| | M7.1 Memory layout that grows: people tables as one 256-byte page per field (person 0-254) in free RAM inside the video banks; people_count replaces the fixed 16. | passed (2026-12-04, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-keys.ps1`: 9 of 9; `pwsh -File tools/check-people.ps1`: 1,904 frames, 0 missed; `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-paths.ps1`) | pending | | |||||
| | M7.2 People drawn only into the hidden buffer (main loop) and flipped in; the vertical blank does no people work; a crossing scroll step waits for the people to be drawn. | passed (2026-12-04, `pwsh -File tools/check-people.ps1`: vertical blank work done by line -8; `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,964 frames, 123 stall frames, 21 stops byte-exact) | pending | | |||||
| | M7.3 + and - add and remove people (1-255, repeat when held); status line 1 `P001/016`; people keep their speed when frames drop (raster IRQ frame count, catch-up up to 4 frames). | passed (2026-12-04, `pwsh -File tools/build.ps1` (5,923 bytes); `pwsh -File tools/smoke.ps1`: rows 20 "P001/016 " in both banks; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-keys.ps1`: 11 of 11, new '+ held' (16 to 45 people in about 200 frames) and '- held' (stops at 1); `pwsh -File tools/check-split.ps1`; `pwsh -File tools/check-paths.ps1`: 36 appeared, 4 faded, 9 dot bytes checked; `pwsh -File tools/check-people.ps1`: 1,896 frames, 0 missed; `-People 32` and `-People 64`: one frame per pass; `-People 128`: 2 frames per pass, 233 steps each in 31.2 s; `-People 255`: 4.03 frames per pass, 228-229 steps each in 30.8 s (16 people: 236-237 in 31.7 s), all pass; `pwsh -File tools/check-scroll.ps1 -Long`: 5 of 5, tour 22,959 frames, 120 stall frames, 21 stops byte-exact; `pwsh -File tools/check-scroll.ps1 -Long -PathTest`: 5 of 5, tour 229 stall frames, 82 paths appeared and 54 faded, 21 stops byte-exact) | pending | | |||||
| ## Notes | ## Notes | ||||
| - 2026-12-04 (M7, spec change approved by the user: 1-255 people, + and -, keep speed and drop frames): | |||||
| - src/people.inc: every people table is one page per field (positions $4C00-$4FFF; direction, sex, scores $5800-$5FFF; saved dot lists of both buffers $8C00-$91FF; name letters $9200-$9BFF), asserts keep them clear of the text screens, fonts and bitmaps. The old layout broke at 32 people (person * 10 past 255, a bpl loop starting at 191, only 16 moved, vertical blank time). | |||||
| - M7.2: people_update draws into the hidden buffer only once it is complete (buf_dots) and asks for a flip when the view is still; apply_view waits for buf_dots before a crossing step. people_vblank and restore_hidden_people are gone. | |||||
| - M7.3: key_repeat (+ and -: act on the press, then after 30 frames every 5th frame), add_person, remove_person; show_number3; irq_frames counted in the top-of-frame IRQ, move_people catches up to 4 missed frames. PEOPLE_START can be set at build time (`--asm-define PEOPLE_START=N`) for checks. | |||||
| - Bug found by check-keys: `ldx` between the `and` and `jsr key_repeat` cleared the Z flag test, so people were added every frame with no key held. Fixed before commit. | |||||
| - Checks: check-keys gains '+ held' and '- held' and checks the 3-digit number and the count (the count may lag up to 3 while it climbs: the status is redrawn every 4th frame); check-people gains -People N (a build variant; missed frames reported, not failed, above 16); check-paths read buffer variables by fixed offsets and, after buf_dots was added in M7.2, took buf_dots for buf_rows and checked only row 0 (0 dot bytes): it now reads each variable by its label. | |||||
| - With many people the scroll also slows (one pixel per main-loop pass: about a quarter of normal speed with 255 people); walking speed is kept as chosen. | |||||
| - 2026-12-04 (M6.2, spec change approved by the user: status area shows only the chosen person; random names and sex): | - 2026-12-04 (M6.2, spec change approved by the user: status area shows only the chosen person; random names and sex): | ||||
| - src/people.inc roll_names: sex 50/50 into people_sex; name = start syllable (16), half the time a middle syllable (8, at most 2 letters), and an end syllable from 16 male or 16 female ones, so at most 10 letters (people_name, space padded). Syllables are 4-byte entries in one table (SYL macro). count_people_in_view and people_in_view removed. | - src/people.inc roll_names: sex 50/50 into people_sex; name = start syllable (16), half the time a middle syllable (8, at most 2 letters), and an end syllable from 16 male or 16 female ones, so at most 10 letters (people_name, space padded). Syllables are 4-byte entries in one table (SYL macro). count_people_in_view and people_in_view removed. | ||||
| - src/status.inc: update_status (view position, people in view) removed; show_person writes row 20 (Pnn, name, M/F) and row 21 (scores); the main loop calls it only when the person changed, on every 4th frame as before. The start-up screen ("LAND MAP 64", "GENERATING...", then "MAP READY" in the hidden text screen) is unchanged: the smoke test reads it (A5). | - src/status.inc: update_status (view position, people in view) removed; show_person writes row 20 (Pnn, name, M/F) and row 21 (scores); the main loop calls it only when the person changed, on every 4th frame as before. The start-up screen ("LAND MAP 64", "GENERATING...", then "MAP READY" in the hidden text screen) is unchanged: the smoke test reads it (A5). | ||||
| @@ -17,14 +17,15 @@ | |||||
| "2026-12-03 change (approved): people and status text white (colour 1) instead of light red (A1).", | "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.", | "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.", | ||||
| "2026-12-04 change (approved): the status area shows only the chosen person (number, name, M or F; then the six scores; lines 3-5 blank); title, view position, people-in-view count and key help removed, keys unchanged. Every person gets a random sex (50/50) and a random 2-3 syllable name from male or female syllable lists (up to 10 letters). New task M6.2." | |||||
| "2026-12-04 change (approved): the status area shows only the chosen person (number, name, M or F; then the six scores; lines 3-5 blank); title, view position, people-in-view count and key help removed, keys unchanged. Every person gets a random sex (50/50) and a random 2-3 syllable name from male or female syllable lists (up to 10 letters). New task M6.2.", | |||||
| "2026-12-04 change (approved): a changing number of people: 1-255, 16 in a new world, + adds a person and - removes the last one while running (R2); the people's tables are one 256-byte page per field in free RAM inside the video banks; people are drawn only into the hidden buffer, and with many people the picture updates less often while people keep their speed (R3, 'keep speed, drop frames'); status line 1 shows P001/016 (R8). New milestone M7." | |||||
| ] | ] | ||||
| }, | }, | ||||
| "project": { | "project": { | ||||
| "name": "Land Map 64", | "name": "Land Map 64", | ||||
| "slug": "land-map-64", | "slug": "land-map-64", | ||||
| "idea": "okay I want to start a c64 project in assembly that will procedurally generate a hi res color bitmap of a map of a land with brown land grey stone green grass and trees and black for roads colors. I would like to see if we can add people as tan dots and use buffer fliping to show movent of the people on the map .. you can ask me questions if this is not cleaar", | "idea": "okay I want to start a c64 project in assembly that will procedurally generate a hi res color bitmap of a map of a land with brown land grey stone green grass and trees and black for roads colors. I would like to see if we can add people as tan dots and use buffer fliping to show movent of the people on the map .. you can ask me questions if this is not cleaar", | ||||
| "summary": "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.", | |||||
| "summary": "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 at first (1-255, + and - change the number), 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.", | |||||
| "kind": "demo", | "kind": "demo", | ||||
| "smallestUsefulVersion": "A 2x2-screen world generated from a seed at start-up, shown one screen at a time in multicolour bitmap mode, pixel-smooth scrolling with the cursor keys, 16 white people moving over land, grass, trees and paths (not water or stone), flicker-free via two flipped buffers with only the people's spots redrawn, and SPACE for a new world." | "smallestUsefulVersion": "A 2x2-screen world generated from a seed at start-up, shown one screen at a time in multicolour bitmap mode, pixel-smooth scrolling with the cursor keys, 16 white people moving over land, grass, trees and paths (not water or stone), flicker-free via two flipped buffers with only the people's spots redrawn, and SPACE for a new world." | ||||
| }, | }, | ||||
| @@ -92,13 +93,14 @@ | |||||
| ] | ] | ||||
| }, | }, | ||||
| { | { | ||||
| "title": "16 moving people", | |||||
| "text": "16 people, each a single white multicolour pixel, are spread over the world and move on their own. Water and stone block them: they walk only on land, grass, trees and paths. People inside the view are drawn; others keep moving unseen.", | |||||
| "title": "Moving people, 1 to 255", | |||||
| "text": "A new world starts with 16 people, each a single white multicolour pixel, spread over the world; they move on their own. Water and stone block them: they walk only on land, grass, trees and paths. People inside the view are drawn; others keep moving unseen. While the program runs, + adds a person (a new name, sex and scores, on a random walkable spot) and - removes the last one; there are always 1 to 255 people. Held, + and - repeat. Each person steps every 8 frames however many people there are; with many people the picture updates less often instead (R3).", | |||||
| "priority": "must", | "priority": "must", | ||||
| "acceptance": [ | "acceptance": [ | ||||
| "Scrolling around the world shows 16 white dots in total", | |||||
| "Each visible dot moves at least once per second", | |||||
| "No dot ever enters a blue (water) or grey (stone) pixel" | |||||
| "Scrolling around a new world shows 16 white dots in total", | |||||
| "Each visible dot moves at least once per second, also with 255 people", | |||||
| "No dot ever enters a blue (water) or grey (stone) pixel", | |||||
| "+ adds one person (up to 255) and - removes the last one (down to 1); held, they repeat; the status line shows the new number of people (R8.2) and the new person's dot appears and moves" | |||||
| ], | ], | ||||
| "id": "R2", | "id": "R2", | ||||
| "capabilities": [ | "capabilities": [ | ||||
| @@ -107,12 +109,12 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "title": "Flicker-free double buffering, partial redraw", | "title": "Flicker-free double buffering, partial redraw", | ||||
| "text": "While the view is still, people are drawn into the hidden bitmap buffer, which is then flipped into view during vertical blank. While the view scrolls, the hidden buffer is being rebuilt for the next scroll step, so people are restored and drawn in the shown buffer during vertical blank, before the first map line, and the rebuilt buffer is flipped in at the scroll step. Each update restores only the bitmap bytes under people at their previous positions in that buffer and draws them at their new positions; apart from the scroll rebuild, the rest of the map is never redrawn.", | |||||
| "text": "People are drawn only into the hidden bitmap buffer, never into the shown one, and the hidden buffer is flipped into view during vertical blank. While the view scrolls, the hidden buffer is rebuilt for the next scroll step; once it is complete the people are drawn into it, and it is flipped in at the scroll step. Each update restores only the bitmap bytes under people at their previous positions in that buffer and draws them at their new positions; apart from the scroll rebuild and changed path cells, the rest of the map is never redrawn. (Since M7; before, people were drawn into the shown buffer during vertical blank while a rebuild ran, which does not scale beyond about 16 people.) With up to about 64 people every frame is a new picture; with more, the main loop takes longer than a frame and the picture and the scroll update every 2nd to 4th frame, while people keep their walking speed.", | |||||
| "priority": "must", | "priority": "must", | ||||
| "acceptance": [ | "acceptance": [ | ||||
| "No flicker or tearing of the dots is visible in VICE at normal speed", | "No flicker or tearing of the dots is visible in VICE at normal speed", | ||||
| "After 5 minutes of running and scrolling, the map has no leftover white trails or damaged terrain", | "After 5 minutes of running and scrolling, the map has no leftover white trails or damaged terrain", | ||||
| "A people update (restore, draw, flip) completes within one NTSC frame" | |||||
| "With 16 people a people update (restore, draw, flip) completes within one NTSC frame; with more people the vertical blank work still ends before the first map line, and people keep their speed" | |||||
| ], | ], | ||||
| "id": "R3", | "id": "R3", | ||||
| "capabilities": [ | "capabilities": [ | ||||
| @@ -122,7 +124,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "title": "New world on SPACE", | "title": "New world on SPACE", | ||||
| "text": "Pressing SPACE generates and shows a different world, with the 16 people placed on it.", | |||||
| "text": "Pressing SPACE generates and shows a different world, with 16 people placed on it (however many there were before).", | |||||
| "priority": "must", | "priority": "must", | ||||
| "acceptance": [ | "acceptance": [ | ||||
| "Pressing SPACE replaces the world with a visibly different one", | "Pressing SPACE replaces the world with a visibly different one", | ||||
| @@ -184,11 +186,11 @@ | |||||
| "id": "R8", | "id": "R8", | ||||
| "title": "People's attributes", | "title": "People's attributes", | ||||
| "priority": "must", | "priority": "must", | ||||
| "text": "Each of the 16 people is male or female (at random, 50/50) and has a random name of two or three syllables from a male or female syllable list (up to 10 letters), and six scores, as in D&D: strength, dexterity, constitution, intelligence, wisdom and charisma. Each score 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. The status lines show one person at a time: P01 ALDRIC M and 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 names, sexes and scores for the new world and shows person 1.", | |||||
| "text": "Each person is male or female (at random, 50/50) and has a random name of two or three syllables from a male or female syllable list (up to 10 letters), and six scores, as in D&D: strength, dexterity, constitution, intelligence, wisdom and charisma. Each score 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. The status lines show one person at a time: P001/016 ALDRIC M (person number / number of people, since M7) and STR12 DEX09 CON15 INT10 WIS08 CHA13. Each press of P shows the next person (after the last comes 1); holding P does not repeat. If the shown person is removed with -, the new last person is shown. 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 names, sexes and scores for the new world and shows person 1.", | |||||
| "acceptance": [ | "acceptance": [ | ||||
| "Every person has six scores from 3 to 18, rolled 3d6 when a world is made; SPACE rolls new ones", | "Every person has six scores from 3 to 18, rolled 3d6 when a world is made; SPACE rolls new ones", | ||||
| "Status line 1 shows the chosen person's number (1-16), name and M or F; line 2 their 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", | |||||
| "Status line 1 shows the chosen person's number and the number of people (P001/016), name and M or F; line 2 their 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 the last 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 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", | "The scores do not change how people move", | ||||
| "Every person is male or female at random and has a random name of 2-3 syllables (up to 10 letters) from the male or female syllable list; SPACE gives new ones" | "Every person is male or female at random and has a random name of 2-3 syllables (up to 10 letters) from the male or female syllable list; SPACE gives new ones" | ||||
| @@ -812,6 +814,71 @@ | |||||
| ] | ] | ||||
| } | } | ||||
| ] | ] | ||||
| }, | |||||
| { | |||||
| "id": "M7", | |||||
| "title": "A changing number of people", | |||||
| "goal": "1 to 255 people, 16 in a new world; + and - change the number while the program runs; people keep their speed.", | |||||
| "tasks": [ | |||||
| { | |||||
| "id": "M7.1", | |||||
| "text": "Memory layout that grows: every people table becomes one 256-byte page per field, indexed by person 0-254 (positions $4C00-$4FFF; direction, sex and the six scores $5800-$5FFF; saved bytes under the dots of both buffers $8C00-$91FF; the ten name letters $9200-$9BFF), so no table moves when the number changes. people_count (1-255) replaces the fixed 16 everywhere: placing, moving (every 8th person per frame), drawing, P, the status line.", | |||||
| "requirements": [ | |||||
| "R2", | |||||
| "R8" | |||||
| ], | |||||
| "outcome": "Same program with 16 people, its tables ready for up to 255", | |||||
| "check": "pwsh -File tools/smoke.ps1; tools/check-world.ps1; tools/check-keys.ps1; tools/check-people.ps1; tools/check-split.ps1; tools/check-paths.ps1" | |||||
| }, | |||||
| { | |||||
| "id": "M7.2", | |||||
| "text": "People are drawn only into the hidden buffer (people_update in the main loop, once the hidden buffer is complete; buf_dots marks it) and flipped in at the next vertical blank, which now does no people work. A scroll step that crosses a cell waits until the rebuilt buffer has its people too.", | |||||
| "requirements": [ | |||||
| "R3", | |||||
| "R5" | |||||
| ], | |||||
| "outcome": "Vertical blank work no longer grows with the number of people", | |||||
| "check": "pwsh -File tools/check-people.ps1 (both buffers hold the clean map plus the right dots); tools/check-scroll.ps1 -Long and -Long -PathTest" | |||||
| }, | |||||
| { | |||||
| "id": "M7.3", | |||||
| "text": "+ adds a person at a random walkable spot with a new name, sex and scores (up to 255); - removes the last one (down to 1; if they were shown, the new last person is shown). Held, both repeat after 30 frames, then every 5th frame. Status line 1 shows P001/016 (person / number of people). The raster IRQ counts frames, so when the main loop takes longer than a frame the people catch up on the missed frames (up to 4) and keep their speed.", | |||||
| "requirements": [ | |||||
| "R2", | |||||
| "R8", | |||||
| "R3" | |||||
| ], | |||||
| "outcome": "+ and - change the number of people while it runs", | |||||
| "check": "pwsh -File tools/check-keys.ps1 (+ held: the count climbs past 40; - held: stops at 1; status shows P001/nnn); tools/check-people.ps1 -People 255; tools/smoke.ps1; manual test MT7.1" | |||||
| } | |||||
| ], | |||||
| "manualTests": [ | |||||
| { | |||||
| "id": "MT7.1", | |||||
| "title": "Adding and removing people", | |||||
| "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 1.", | |||||
| "Press + a few times, then hold + until the count passes 100.", | |||||
| "Hold + until it stops, then scroll around.", | |||||
| "Press P a few times, then hold - until it stops.", | |||||
| "Press SPACE." | |||||
| ], | |||||
| "expected": [ | |||||
| "Line 1 reads like P001/016 ALDRIC M", | |||||
| "Each + press adds one to the count and a new dot appears somewhere in the world; held, the count climbs about 12 a second", | |||||
| "The count stops at 255; the map gets less smooth, but people walk at the same speed and no trails or broken terrain appear", | |||||
| "The - key removes people down to P001/001; the shown person changes to the last one when they are removed", | |||||
| "SPACE gives a new world with 16 people: P001/016" | |||||
| ], | |||||
| "requirements": [ | |||||
| "R2", | |||||
| "R3", | |||||
| "R8" | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | } | ||||
| ], | ], | ||||
| "destination": "C:\\Development\\Commodore\\Foundry Projects\\land-map-64", | "destination": "C:\\Development\\Commodore\\Foundry Projects\\land-map-64", | ||||
| @@ -991,7 +1058,7 @@ | |||||
| { | { | ||||
| "dump": "status-a", | "dump": "status-a", | ||||
| "offset": 0, | "offset": 0, | ||||
| "text": "P01 ", | |||||
| "text": "P001/016 ", | |||||
| "encoding": "screen-upper", | "encoding": "screen-upper", | ||||
| "bytes": null, | "bytes": null, | ||||
| "description": "Status row 20 in buffer A: person 1 (number, then name and sex, R8)" | "description": "Status row 20 in buffer A: person 1 (number, then name and sex, R8)" | ||||
| @@ -1015,7 +1082,7 @@ | |||||
| { | { | ||||
| "dump": "status-b", | "dump": "status-b", | ||||
| "offset": 0, | "offset": 0, | ||||
| "text": "P01 ", | |||||
| "text": "P001/016 ", | |||||
| "encoding": "screen-upper", | "encoding": "screen-upper", | ||||
| "bytes": null, | "bytes": null, | ||||
| "description": "Status row 20 in buffer B's text screen: person 1" | "description": "Status row 20 in buffer B's text screen: person 1" | ||||
| @@ -4,7 +4,7 @@ | |||||
| ; column 0: CRSR RIGHT row 2 (keycode 2), CRSR DOWN row 7 (keycode 7) | ; column 0: CRSR RIGHT row 2 (keycode 2), CRSR DOWN row 7 (keycode 7) | ||||
| ; column 1: left SHIFT row 7 (keycode 15) | ; column 1: left SHIFT row 7 (keycode 15) | ||||
| ; column 6: right SHIFT row 4 (keycode 52) | ; column 6: right SHIFT row 4 (keycode 52) | ||||
| ; column 5: P row 1 (keycode 41) | |||||
| ; column 5: + row 0 (keycode 40), P row 1 (keycode 41), - row 3 (keycode 43) | |||||
| ; column 7: SPACE row 4 (keycode 60) | ; column 7: SPACE row 4 (keycode 60) | ||||
| ; SHIFT reverses the cursor keys: SHIFT + CRSR RIGHT = left, SHIFT + CRSR DOWN | ; SHIFT reverses the cursor keys: SHIFT + CRSR RIGHT = left, SHIFT + CRSR DOWN | ||||
| ; = up. VICE maps the PC arrow keys to these combinations. | ; = up. VICE maps the PC arrow keys to these combinations. | ||||
| @@ -23,6 +23,10 @@ KEY_ROW_LSHIFT = %10000000 | |||||
| KEY_ROW_RSHIFT = %00010000 | KEY_ROW_RSHIFT = %00010000 | ||||
| KEY_ROW_SPACE = %00010000 | KEY_ROW_SPACE = %00010000 | ||||
| KEY_ROW_P = %00000010 | KEY_ROW_P = %00000010 | ||||
| KEY_ROW_PLUS = %00000001 | |||||
| KEY_ROW_MINUS = %00001000 | |||||
| REPEAT_DELAY = 30 ; + and - held: repeat after 30 frames, | |||||
| REPEAT_RATE = 4 ; then every 5th frame | |||||
| .export key_row_cursor, key_row_lshift, key_row_rshift, key_row_space, key_row_p | .export key_row_cursor, key_row_lshift, key_row_rshift, key_row_space, key_row_p | ||||
| .export scroll_dx | .export scroll_dx | ||||
| @@ -38,11 +42,15 @@ stop_kernal_irq: | |||||
| lda #1 | lda #1 | ||||
| sta space_down ; SPACE must be released before it counts | sta space_down ; SPACE must be released before it counts | ||||
| sta p_down | sta p_down | ||||
| lda #0 | |||||
| sta key_held | |||||
| sta key_held+1 | |||||
| rts | rts | ||||
| ; Read the keys once per frame. Sets scroll_dx and scroll_dy to -1, 0 or +1 | ; 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. A new press of P shows the next | ; 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 | |||||
| ; person's scores (R8; held P counts once). + adds a person and - removes | |||||
| ; the last one (M7.3; held, they repeat). Returns carry set when SPACE has | |||||
| ; just been pressed (held SPACE counts once). | ; just been pressed (held SPACE counts once). | ||||
| read_keys: | read_keys: | ||||
| lda #KEY_COL_CURSOR | lda #KEY_COL_CURSOR | ||||
| @@ -106,14 +114,30 @@ key_row_p: | |||||
| bne @p_done ; already down last frame (or up now: X = 0) | bne @p_done ; already down last frame (or up now: X = 0) | ||||
| cpx #1 | cpx #1 | ||||
| bne @p_done | bne @p_done | ||||
| ldx shown_person ; next person, 16 wraps to 1 | |||||
| ldx shown_person ; next person, the last wraps to the first | |||||
| inx | inx | ||||
| txa | |||||
| and #PEOPLE_COUNT - 1 | |||||
| sta shown_person | |||||
| cpx people_count | |||||
| bcc @p_next | |||||
| ldx #0 | |||||
| @p_next: | |||||
| stx shown_person | |||||
| lda #1 | lda #1 | ||||
| sta shown_dirty | sta shown_dirty | ||||
| @p_done: | @p_done: | ||||
| ldx #0 ; + : add a person | |||||
| lda keys_p | |||||
| and #KEY_ROW_PLUS | |||||
| jsr key_repeat | |||||
| bcc @no_plus | |||||
| jsr add_person | |||||
| @no_plus: | |||||
| ldx #1 ; - : remove the last person | |||||
| lda keys_p | |||||
| and #KEY_ROW_MINUS | |||||
| jsr key_repeat | |||||
| bcc @no_minus | |||||
| jsr remove_person | |||||
| @no_minus: | |||||
| ldx #0 | ldx #0 | ||||
| lda keys_space | lda keys_space | ||||
| and #KEY_ROW_SPACE | and #KEY_ROW_SPACE | ||||
| @@ -129,7 +153,32 @@ key_row_p: | |||||
| clc | clc | ||||
| rts | rts | ||||
| ; A = the key's row bits (0 = down; Z flag set from them), X = 0 for +, 1 for -. Carry set when | |||||
| ; the key acts this frame: a new press, then while held every REPEAT_RATE + 1 | |||||
| ; frames after REPEAT_DELAY frames. | |||||
| key_repeat: | |||||
| bne @up | |||||
| lda key_held,x | |||||
| beq @first | |||||
| cmp #REPEAT_DELAY | |||||
| bcc @count | |||||
| lda #REPEAT_DELAY - REPEAT_RATE | |||||
| sta key_held,x | |||||
| sec | |||||
| rts | |||||
| @first: inc key_held,x | |||||
| sec | |||||
| rts | |||||
| @count: inc key_held,x | |||||
| clc | |||||
| rts | |||||
| @up: lda #0 | |||||
| sta key_held,x | |||||
| clc | |||||
| rts | |||||
| .segment "BSS" | .segment "BSS" | ||||
| key_held: .res 2 ; frames + and - have been held | |||||
| scroll_dx: .res 1 ; keep scroll_dx and scroll_dy together | scroll_dx: .res 1 ; keep scroll_dx and scroll_dy together | ||||
| scroll_dy: .res 1 | scroll_dy: .res 1 | ||||
| keys_cursor: .res 1 | keys_cursor: .res 1 | ||||
| @@ -94,17 +94,17 @@ smoke_ready: ; first generated world is on screen | |||||
| nop | nop | ||||
| ; Each frame, in vertical blank (before the first map line at raster 55): | ; Each frame, in vertical blank (before the first map line at raster 55): | ||||
| ; scroll one step if a cursor key is held, flipping buffers at a cell edge, | |||||
| ; then the people update: restore and draw (scroll.inc, people.inc). After | |||||
| ; that, with time to spare: read the keys, show the status, move two people | |||||
| ; (drawn at the next vertical blank) and rebuild part of the hidden buffer. | |||||
| ; scroll one step if a cursor key is held, flipping buffers at a cell edge or | |||||
| ; to show the people drawn last frame (scroll.inc). Then, outside the | |||||
| ; vertical blank: read the keys, show the status, move every eighth person, | |||||
| ; choose the hidden buffer's target, draw the people into the hidden buffer | |||||
| ; if it is complete (people.inc, M7.2) and rebuild part of it. | |||||
| main_loop: | main_loop: | ||||
| jsr wait_frame | jsr wait_frame | ||||
| frame_start: ; check hook: vertical blank work starts | frame_start: ; check hook: vertical blank work starts | ||||
| TIMING_BAR_COLOR BAR_VBLANK | TIMING_BAR_COLOR BAR_VBLANK | ||||
| jsr apply_view | jsr apply_view | ||||
| jsr people_vblank | |||||
| people_moved: ; check hook: people drawn for this frame | |||||
| people_moved: ; check hook: the vertical blank work is done | |||||
| TIMING_BAR_COLOR BAR_KEYS | TIMING_BAR_COLOR BAR_KEYS | ||||
| jsr read_keys ; carry set: SPACE just pressed | jsr read_keys ; carry set: SPACE just pressed | ||||
| bcs new_world | bcs new_world | ||||
| @@ -116,12 +116,12 @@ keys_read: ; check hook: scroll_dx and scroll_dy are set | |||||
| beq @rebuild | beq @rebuild | ||||
| jsr show_person | jsr show_person | ||||
| @rebuild: | @rebuild: | ||||
| jsr move_people ; moved now, drawn at the next vertical blank | |||||
| jsr move_people ; moved now, drawn below into the hidden buffer | |||||
| jsr decay_counts ; worn paths: counts fade, paths turn back | jsr decay_counts ; worn paths: counts fade, paths turn back | ||||
| jsr apply_changes ; changed cells into the hidden buffer | jsr apply_changes ; changed cells into the hidden buffer | ||||
| TIMING_BAR_COLOR BAR_REBUILD | TIMING_BAR_COLOR BAR_REBUILD | ||||
| jsr choose_rebuild_target | jsr choose_rebuild_target | ||||
| jsr restore_hidden_people | |||||
| jsr people_update ; people into the hidden buffer, if complete | |||||
| jsr rebuild_slices | jsr rebuild_slices | ||||
| frame_done: ; check hook: this frame's work is done | frame_done: ; check hook: this frame's work is done | ||||
| TIMING_BAR_COLOR BAR_IDLE | TIMING_BAR_COLOR BAR_IDLE | ||||
| @@ -327,27 +327,24 @@ redraw_cell: | |||||
| dey | dey | ||||
| bpl @byte | bpl @byte | ||||
| ldx ap_buf ; saved bytes under dots in this cell | ldx ap_buf ; saved bytes under dots in this cell | ||||
| lda list_starts,x | |||||
| sta ap_first | |||||
| clc | |||||
| adc drawn_count,x | |||||
| tax | |||||
| @saved: cpx ap_first | |||||
| jsr point_lists | |||||
| ldy drawn_count,x | |||||
| @saved: tya | |||||
| beq @done | beq @done | ||||
| dex | |||||
| lda drawn_high,x | |||||
| dey | |||||
| lda (lst_high),y | |||||
| cmp ap_bmp+1 | cmp ap_bmp+1 | ||||
| bne @saved | bne @saved | ||||
| lda drawn_low,x | |||||
| lda (lst_low),y | |||||
| sec | sec | ||||
| sbc ap_bmp | sbc ap_bmp | ||||
| cmp #8 ; cells never straddle a page | cmp #8 ; cells never straddle a page | ||||
| bcs @saved | bcs @saved | ||||
| clc | clc | ||||
| adc ap_pat | adc ap_pat | ||||
| tay | |||||
| lda tile_patterns,y | |||||
| sta drawn_byte,x | |||||
| tax | |||||
| lda tile_patterns,x | |||||
| sta (lst_byte),y | |||||
| jmp @saved | jmp @saved | ||||
| @done: rts | @done: rts | ||||
| @@ -376,5 +373,4 @@ ap_tile: .res 1 | |||||
| ap_pat: .res 1 | ap_pat: .res 1 | ||||
| ap_cur: .res 1 | ap_cur: .res 1 | ||||
| ap_dots: .res 1 | ap_dots: .res 1 | ||||
| ap_first: .res 1 | |||||
| .assert * <= SCREEN_A, lderror, "Path data must fit below VIC bank 1" | .assert * <= SCREEN_A, lderror, "Path data must fit below VIC bank 1" | ||||
| @@ -1,7 +1,45 @@ | |||||
| ; People: 16 walkers stored as world positions, one multicolour pixel each. | |||||
| ; A position is a world cell (cx 0-79, cy 0-49) plus the pixel inside it | |||||
| ; (sx 0-3 across, sy 0-7 down). Water and stone tiles block movement. | |||||
| PEOPLE_COUNT = 16 | |||||
| ; People: up to 255 walkers stored as world positions, one multicolour pixel | |||||
| ; each; people_count of them exist (16 in a new world). A position is a world | |||||
| ; cell (cx 0-79, cy 0-49) plus the pixel inside it (sx 0-3 across, sy 0-7 | |||||
| ; down). Water and stone tiles block movement. | |||||
| ; | |||||
| ; Memory (M7.1): every field is its own 256-byte table indexed by person, so | |||||
| ; any count up to 255 needs no other change. The tables sit in RAM the VIC-II | |||||
| ; never shows: the gaps in the two video banks (see the asserts below). | |||||
| PEOPLE_MAX = 255 | |||||
| .ifndef PEOPLE_START | |||||
| PEOPLE_START = 16 ; people in a new world (checks may build with more) | |||||
| .endif | |||||
| .assert PEOPLE_START >= 1 .and PEOPLE_START <= PEOPLE_MAX, error, "PEOPLE_START must be 1-255" | |||||
| ATTR_COUNT = 6 ; STR, DEX, CON, INT, WIS, CHA | |||||
| NAME_LENGTH = 10 | |||||
| people_cx = $4C00 ; bank 1, after the second text screen | |||||
| people_sx = $4D00 | |||||
| people_cy = $4E00 | |||||
| people_sy = $4F00 | |||||
| people_dir = $5800 ; bank 1, after the font | |||||
| people_sex = $5900 ; 0 = male, 1 = female | |||||
| people_attr = $5A00 ; one page per score: STR at $5A00 ... CHA at $5F00 | |||||
| drawn_low_a = $8C00 ; bank 2, after its second text screen: saved-byte | |||||
| drawn_high_a = $8D00 ; lists, three pages per buffer (B = A + 3 pages) | |||||
| drawn_byte_a = $8E00 | |||||
| drawn_low_b = $8F00 | |||||
| people_name = $9200 ; one page per letter: letter K of person N at | |||||
| ; people_name + K * 256 + N (screen codes) | |||||
| LIST_PAGES = 3 | |||||
| .assert people_cx >= SCREEN_A + $0C00, error, "People tables overlap bank 1's text screens" | |||||
| .assert people_sy + $100 <= FONT_A, error, "People tables overlap bank 1's font" | |||||
| .assert people_dir >= FONT_A + $0800, error, "People tables overlap bank 1's font" | |||||
| .assert people_attr + ATTR_COUNT * $100 <= BITMAP_A, error, "People tables overlap bitmap A" | |||||
| .assert drawn_low_a >= SCREEN_B + $0C00, error, "People tables overlap bank 2's text screens" | |||||
| .assert drawn_low_b = drawn_low_a + LIST_PAGES * $100, error, "List layout" | |||||
| .assert people_name >= drawn_low_b + LIST_PAGES * $100, error, "Names overlap the lists" | |||||
| .assert people_name + NAME_LENGTH * $100 <= BITMAP_B, error, "Names overlap bitmap B" | |||||
| ; Zero page ($44-$4B: BASIC's area, unused here). | |||||
| lst_low = $44 ; saved-byte list of one buffer: addresses | |||||
| lst_high = $46 | |||||
| lst_byte = $48 ; and the bytes under the dots | |||||
| tab_ptr = $4A ; a score or name-letter table | |||||
| DIR_N = 0 | DIR_N = 0 | ||||
| DIR_E = 1 | DIR_E = 1 | ||||
| DIR_S = 2 | DIR_S = 2 | ||||
| @@ -12,18 +50,36 @@ TURN_TRIES = 5 ; current direction, then all four from a random | |||||
| .assert WATER_SE + 1 = ROAD_H, error, "Blocking tiles must be contiguous" | .assert WATER_SE + 1 = ROAD_H, error, "Blocking tiles must be contiguous" | ||||
| .assert BRIDGE_X + 1 = TILE_COUNT, error, "Bridge tiles must come last" | .assert BRIDGE_X + 1 = TILE_COUNT, error, "Bridge tiles must come last" | ||||
| .export people_cx, people_moved, people_attr, people_name, people_sex, shown_person, draw_skip | |||||
| .export people_cx, people_sx, people_cy, people_sy, people_dir, people_moved, people_attr | |||||
| .export people_name, people_sex, shown_person, draw_skip, people_count, move_frame | |||||
| .export drawn_low_a, drawn_high_a, drawn_byte_a, drawn_low_b | |||||
| .segment "CODE" | .segment "CODE" | ||||
| ; Put each person on a random walkable cell; person N goes in sector N mod 4, | |||||
| ; so the 16 people are spread over all four screens of the world. | |||||
| ; New world: PEOPLE_START people, each on a random walkable cell; person N | |||||
| ; goes in sector N mod 4, so they are spread over all four screens of the | |||||
| ; world. Person 1 is shown. | |||||
| place_people: | place_people: | ||||
| lda #0 | lda #0 | ||||
| sta drawn_count | sta drawn_count | ||||
| sta drawn_count+1 | sta drawn_count+1 | ||||
| sta move_frame | sta move_frame | ||||
| tax | |||||
| @person: | |||||
| sta shown_person | |||||
| lda irq_frames ; no catching up on the time spent making the world | |||||
| sta moved_frames | |||||
| lda #PEOPLE_START | |||||
| sta people_count | |||||
| ldx #0 | |||||
| @next: jsr new_person | |||||
| inx | |||||
| cpx people_count | |||||
| bne @next | |||||
| lda #1 | |||||
| sta shown_dirty | |||||
| rts | |||||
| ; X = person: a random walkable position in sector X mod 4, a direction, a | |||||
| ; sex, a name and six scores. Returns X = person. | |||||
| new_person: | |||||
| stx person | stx person | ||||
| @retry_x: | @retry_x: | ||||
| jsr random_byte | jsr random_byte | ||||
| @@ -31,7 +87,7 @@ place_people: | |||||
| cmp #SECTOR_WIDTH | cmp #SECTOR_WIDTH | ||||
| bcs @retry_x | bcs @retry_x | ||||
| sta cand_cx | sta cand_cx | ||||
| txa | |||||
| lda person | |||||
| and #3 | and #3 | ||||
| tax | tax | ||||
| lda cand_cx | lda cand_cx | ||||
| @@ -53,8 +109,8 @@ place_people: | |||||
| and #7 | and #7 | ||||
| sta cand_sy | sta cand_sy | ||||
| jsr candidate_blocked | jsr candidate_blocked | ||||
| bcs @retry_x | |||||
| ldx person | ldx person | ||||
| bcs @person | |||||
| lda cand_cx | lda cand_cx | ||||
| sta people_cx,x | sta people_cx,x | ||||
| lda cand_sx | lda cand_sx | ||||
| @@ -66,14 +122,45 @@ place_people: | |||||
| jsr random_byte | jsr random_byte | ||||
| and #3 | and #3 | ||||
| sta people_dir,x | sta people_dir,x | ||||
| inx | |||||
| cpx #PEOPLE_COUNT | |||||
| bne @person | |||||
| ; fall through | |||||
| jsr roll_attributes | |||||
| jsr roll_name | |||||
| ldx person | |||||
| rts | |||||
| ; + key (M7.3): one more person, if fewer than PEOPLE_MAX. | |||||
| add_person: | |||||
| ldx people_count | |||||
| cpx #PEOPLE_MAX | |||||
| bcs @full | |||||
| jsr new_person | |||||
| inc people_count | |||||
| lda #1 | |||||
| sta shown_dirty | |||||
| @full: rts | |||||
| ; - key (M7.3): remove the last person, keeping at least one. Their dot goes | |||||
| ; when each buffer's saved bytes are next put back (people_update). | |||||
| remove_person: | |||||
| ldx people_count | |||||
| cpx #2 | |||||
| bcc @last | |||||
| dex | |||||
| stx people_count | |||||
| cpx shown_person ; the shown person was the last: show the new last | |||||
| bne @shown | |||||
| dex | |||||
| stx shown_person | |||||
| @shown: lda #1 | |||||
| sta shown_dirty | |||||
| @last: rts | |||||
| ; Roll every person's six scores (R8): 3d6 each, 3-18. Person 1 is shown. | |||||
| ; Roll person's six scores (R8): 3d6 each, 3-18. | |||||
| roll_attributes: | roll_attributes: | ||||
| ldy #PEOPLE_COUNT * ATTR_COUNT - 1 | |||||
| lda #0 | |||||
| sta tab_ptr | |||||
| lda #>people_attr | |||||
| sta tab_ptr+1 | |||||
| ldy person | |||||
| @score: lda #0 | @score: lda #0 | ||||
| sta attr_sum | sta attr_sum | ||||
| ldx #3 ; three dice | ldx #3 ; three dice | ||||
| @@ -86,41 +173,33 @@ roll_attributes: | |||||
| sta attr_sum | sta attr_sum | ||||
| dex | dex | ||||
| bne @die | bne @die | ||||
| sta people_attr,y | |||||
| dey | |||||
| bpl @score | |||||
| jsr roll_names | |||||
| lda #0 | |||||
| sta shown_person | |||||
| lda #1 | |||||
| sta shown_dirty | |||||
| sta (tab_ptr),y | |||||
| inc tab_ptr+1 ; next score's page | |||||
| lda tab_ptr+1 | |||||
| cmp #>people_attr + ATTR_COUNT | |||||
| bne @score | |||||
| rts | rts | ||||
| ; Give every person a sex (0 = male, 1 = female, 50/50) and a name (R8): a | |||||
| ; start syllable, half the time a middle one, and an end syllable from the | |||||
| ; male or female list; at most 4 + 2 + 4 = 10 letters, padded with spaces. | |||||
| roll_names: | |||||
| ldx #0 | |||||
| @person: | |||||
| stx name_person | |||||
| txa ; name_pos = person * 10 | |||||
| asl a | |||||
| sta name_pos | |||||
| asl a | |||||
| asl a | |||||
| adc name_pos ; carry is clear (at most 150) | |||||
| sta name_pos | |||||
| tay | |||||
| ; Give person a sex (0 = male, 1 = female, 50/50) and a name (R8): a start | |||||
| ; syllable, half the time a middle one, and an end syllable from the male or | |||||
| ; female list; at most 4 + 2 + 4 = 10 letters, padded with spaces. | |||||
| roll_name: | |||||
| lda #0 | |||||
| sta tab_ptr | |||||
| lda #>people_name | |||||
| sta tab_ptr+1 | |||||
| ldy person | |||||
| lda #' ' | lda #' ' | ||||
| ldx #NAME_LENGTH | |||||
| @blank: sta people_name,y | |||||
| iny | |||||
| dex | |||||
| @blank: sta (tab_ptr),y | |||||
| inc tab_ptr+1 | |||||
| ldx tab_ptr+1 | |||||
| cpx #>people_name + NAME_LENGTH | |||||
| bne @blank | bne @blank | ||||
| lda #0 | |||||
| sta name_pos | |||||
| jsr random_byte | jsr random_byte | ||||
| and #1 | and #1 | ||||
| ldx name_person | |||||
| sta people_sex,x | |||||
| sta people_sex,y | |||||
| jsr random_byte | jsr random_byte | ||||
| and #15 | and #15 | ||||
| jsr add_syllable ; start: syllables 0-15 | jsr add_syllable ; start: syllables 0-15 | ||||
| @@ -131,51 +210,69 @@ roll_names: | |||||
| jsr add_syllable | jsr add_syllable | ||||
| @end: jsr random_byte | @end: jsr random_byte | ||||
| and #15 | and #15 | ||||
| ldx name_person | |||||
| ldy people_sex,x | |||||
| ldy person | |||||
| ldx people_sex,y | |||||
| clc | clc | ||||
| adc syl_end_base,y ; end: male 24-39, female 40-55 | |||||
| jsr add_syllable | |||||
| ldx name_person | |||||
| inx | |||||
| cpx #PEOPLE_COUNT | |||||
| bne @person | |||||
| rts | |||||
| adc syl_end_base,x ; end: male 24-39, female 40-55 | |||||
| ; fall through | |||||
| ; A = syllable number: append its letters (up to 4) at people_name + name_pos. | |||||
| ; A = syllable number: append its letters (up to 4) to person's name at | |||||
| ; letter name_pos. | |||||
| add_syllable: | add_syllable: | ||||
| asl a | asl a | ||||
| asl a | asl a | ||||
| tax | tax | ||||
| lda #4 | lda #4 | ||||
| sta syl_left | sta syl_left | ||||
| ldy name_pos | |||||
| @char: lda syllables,x | |||||
| @char: lda name_pos | |||||
| clc | |||||
| adc #>people_name | |||||
| sta tab_ptr+1 | |||||
| lda syllables,x | |||||
| beq @done | beq @done | ||||
| sta people_name,y | |||||
| iny | |||||
| ldy person | |||||
| sta (tab_ptr),y | |||||
| inc name_pos | |||||
| inx | inx | ||||
| dec syl_left | dec syl_left | ||||
| bne @char | bne @char | ||||
| @done: sty name_pos | |||||
| rts | |||||
| @done: rts | |||||
| ; Move two people per frame: each person takes one pixel step every 8 frames. | |||||
| ; Called from the main loop after the status update, outside the vertical | |||||
| ; blank: the new positions are drawn at the next vertical blank. (Moving in | |||||
| ; the vertical blank made the update overrun the first map line when nearly | |||||
| ; all 16 people were in view; see docs/verification-status.md, M3.4.) | |||||
| ; Move every eighth person per frame, starting with person move_frame mod 8: | |||||
| ; each person takes one pixel step every 8 frames, however many there are | |||||
| ; (more people take more time; the user chose speed over frame rate, M7). | |||||
| ; Called from the main loop, outside the vertical blank. | |||||
| ; Every frame one eighth of the people step, so each person steps every 8 | |||||
| ; frames. If the main loop took longer than a frame (many people), the frames | |||||
| ; it missed are caught up here, up to MOVE_CATCH_UP of them, so people keep | |||||
| ; their speed while the picture updates less often (M7.3). | |||||
| MOVE_CATCH_UP = 4 | |||||
| move_people: | move_people: | ||||
| inc move_frame | |||||
| lda irq_frames | |||||
| sec | |||||
| sbc moved_frames ; frames since the last call | |||||
| beq @done | |||||
| cmp #MOVE_CATCH_UP + 1 | |||||
| bcc @due | |||||
| lda #MOVE_CATCH_UP | |||||
| @due: sta move_due | |||||
| lda irq_frames | |||||
| sta moved_frames | |||||
| @frame: inc move_frame | |||||
| lda move_frame | lda move_frame | ||||
| and #7 | and #7 | ||||
| @next: cmp people_count | |||||
| bcs @last | |||||
| sta move_index | |||||
| tax | tax | ||||
| jsr move_person | jsr move_person | ||||
| lda move_frame | |||||
| and #7 | |||||
| ora #8 | |||||
| tax | |||||
| ; fall through | |||||
| lda move_index | |||||
| clc | |||||
| adc #8 | |||||
| bcc @next ; past 255: done | |||||
| @last: dec move_due | |||||
| bne @frame | |||||
| @done: rts | |||||
| ; X = person. Occasionally pick a new direction; if the step is blocked by | ; X = person. Occasionally pick a new direction; if the step is blocked by | ||||
| ; water, stone or the world edge, try other directions. Never steps onto a | ; water, stone or the world edge, try other directions. Never steps onto a | ||||
| @@ -292,68 +389,72 @@ candidate_blocked: | |||||
| @open: clc | @open: clc | ||||
| rts | rts | ||||
| ; Vertical blank people update. With the view still and the hidden buffer | |||||
| ; complete at the same origin, people are drawn into the hidden buffer and it | |||||
| ; is flipped in at the next vertical blank. Otherwise (scrolling, or the hidden | |||||
| ; buffer is being rebuilt) they are drawn straight into the shown buffer now, | |||||
| ; before the first map line. | |||||
| people_vblank: | |||||
| lda view_moved | |||||
| bne @shown | |||||
| lda step_x ; a step is wanted but waits for the rebuild: | |||||
| ora step_y ; the hidden buffer must be free to rebuild | |||||
| bne @shown ; (else the flip and the wait repeat forever) | |||||
| ; Main loop, every frame, after the rebuild target is chosen (M7.2): people | |||||
| ; are drawn only into the hidden buffer, never into the shown one, so the | |||||
| ; vertical blank does no people work however many there are. If the hidden | |||||
| ; buffer is complete, its old dots are put back and everyone in it is drawn | |||||
| ; again (buf_dots marks it). A crossing scroll step waits for buf_dots (see | |||||
| ; apply_view). With the view still, no step wanted and the hidden buffer at | |||||
| ; the view's own cell, it is flipped in at the next vertical blank. | |||||
| people_update: | |||||
| ldx hidden | ldx hidden | ||||
| lda buf_ready,x | lda buf_ready,x | ||||
| beq @shown | |||||
| beq @done ; being rebuilt: drawn once it is complete | |||||
| stx people_buf | |||||
| jsr restore_people | |||||
| jsr draw_people | |||||
| ldx hidden | |||||
| lda #1 | |||||
| sta buf_dots,x | |||||
| jsr get_steps ; this frame's keys, zero at the world edges | |||||
| lda view_moved | |||||
| ora step_x ; a step is wanted: the hidden buffer must | |||||
| ora step_y ; stay free for that crossing's rebuild | |||||
| bne @done | |||||
| ldx hidden | |||||
| lda buf_cx,x | lda buf_cx,x | ||||
| cmp view_cx | cmp view_cx | ||||
| bne @shown | |||||
| bne @done | |||||
| lda buf_cy,x | lda buf_cy,x | ||||
| cmp view_cy | cmp view_cy | ||||
| bne @shown | |||||
| stx people_buf | |||||
| jsr restore_people | |||||
| jsr draw_people | |||||
| bne @done | |||||
| lda #1 | lda #1 | ||||
| sta people_flip_pending | sta people_flip_pending | ||||
| rts | |||||
| @shown: lda visible | |||||
| sta people_buf | |||||
| jsr restore_people | |||||
| jmp draw_people | |||||
| @done: rts | |||||
| ; When people are drawn in the shown buffer, the hidden one may still carry | |||||
| ; dots from when it was shown: put its saved bytes back (a buffer that is | |||||
| ; being rebuilt has an empty list). | |||||
| restore_hidden_people: | |||||
| lda people_flip_pending | |||||
| bne @keep ; those dots are about to be shown | |||||
| lda hidden | |||||
| sta people_buf | |||||
| jmp restore_people | |||||
| @keep: rts | |||||
| ; X = buffer: point lst_low, lst_high and lst_byte at its saved-byte list. | |||||
| ; Keeps X and Y. | |||||
| point_lists: | |||||
| lda #0 | |||||
| sta lst_low | |||||
| sta lst_high | |||||
| sta lst_byte | |||||
| lda list_page_offset,x | |||||
| clc | |||||
| adc #>drawn_low_a | |||||
| sta lst_low+1 | |||||
| adc #1 ; carry is clear | |||||
| sta lst_high+1 | |||||
| adc #1 | |||||
| sta lst_byte+1 | |||||
| rts | |||||
| ; Put back the bitmap bytes saved when people were last drawn into buffer | ; Put back the bitmap bytes saved when people were last drawn into buffer | ||||
| ; people_buf, newest first, so people that share a byte restore correctly. | ; people_buf, newest first, so people that share a byte restore correctly. | ||||
| restore_people: | restore_people: | ||||
| ldx people_buf | ldx people_buf | ||||
| lda list_starts,x | |||||
| sta list_start | |||||
| clc | |||||
| adc drawn_count,x | |||||
| tax ; X = one past the newest saved byte | |||||
| cpx list_start | |||||
| jsr point_lists | |||||
| ldy drawn_count,x | |||||
| beq @done | beq @done | ||||
| @loop: dex | |||||
| lda drawn_low,x | |||||
| ldx #0 | |||||
| @loop: dey | |||||
| lda (lst_low),y | |||||
| sta bmp | sta bmp | ||||
| lda drawn_high,x | |||||
| lda (lst_high),y | |||||
| sta bmp+1 | sta bmp+1 | ||||
| lda drawn_byte,x | |||||
| ldy #0 | |||||
| sta (bmp),y | |||||
| cpx list_start | |||||
| lda (lst_byte),y | |||||
| sta (bmp,x) ; X = 0 | |||||
| tya | |||||
| bne @loop | bne @loop | ||||
| @done: ldx people_buf | @done: ldx people_buf | ||||
| lda #0 | lda #0 | ||||
| @@ -373,10 +474,10 @@ draw_people: | |||||
| lda shown_person | lda shown_person | ||||
| sta draw_skip | sta draw_skip | ||||
| @blink: | @blink: | ||||
| ldx people_buf | |||||
| lda list_starts,x | |||||
| sta list_start | |||||
| lda #0 | |||||
| sta list_pos | sta list_pos | ||||
| ldx people_buf | |||||
| jsr point_lists | |||||
| lda buffer_bitmap_offsets,x | lda buffer_bitmap_offsets,x | ||||
| sta bitmap_offset | sta bitmap_offset | ||||
| lda buf_cx,x | lda buf_cx,x | ||||
| @@ -422,23 +523,21 @@ draw_people: | |||||
| ldy #0 | ldy #0 | ||||
| lda (bmp),y | lda (bmp),y | ||||
| ldy list_pos | ldy list_pos | ||||
| sta drawn_byte,y | |||||
| sta (lst_byte),y | |||||
| lda bmp | lda bmp | ||||
| sta drawn_low,y | |||||
| sta (lst_low),y | |||||
| lda bmp+1 | lda bmp+1 | ||||
| sta drawn_high,y | |||||
| lda drawn_byte,y | |||||
| sta (lst_high),y | |||||
| lda (lst_byte),y | |||||
| ldy people_sx,x | ldy people_sx,x | ||||
| ora pixel_masks,y ; pixel %11 = colour RAM = white | ora pixel_masks,y ; pixel %11 = colour RAM = white | ||||
| ldy #0 | ldy #0 | ||||
| sta (bmp),y | sta (bmp),y | ||||
| inc list_pos | inc list_pos | ||||
| @next: inx | @next: inx | ||||
| cpx #PEOPLE_COUNT | |||||
| bne @person | |||||
| cpx people_count | |||||
| bcc @person | |||||
| lda list_pos | lda list_pos | ||||
| sec | |||||
| sbc list_start | |||||
| ldx people_buf | ldx people_buf | ||||
| sta drawn_count,x | sta drawn_count,x | ||||
| rts | rts | ||||
| @@ -512,7 +611,7 @@ syllables: | |||||
| SYL "IE" | SYL "IE" | ||||
| .assert * - syllables = 56 * 4, error, "56 syllables" | .assert * - syllables = 56 * 4, error, "56 syllables" | ||||
| syl_end_base: .byte 24, 40 | syl_end_base: .byte 24, 40 | ||||
| list_starts: .byte 0, PEOPLE_COUNT | |||||
| list_page_offset: .byte 0, LIST_PAGES | |||||
| buffer_bitmap_offsets: .byte 0, >(BITMAP_B - BITMAP_A) | buffer_bitmap_offsets: .byte 0, >(BITMAP_B - BITMAP_A) | ||||
| bitmap_row_low: | bitmap_row_low: | ||||
| .repeat BUF_ROWS, row | .repeat BUF_ROWS, row | ||||
| @@ -524,25 +623,15 @@ bitmap_row_high: | |||||
| .endrepeat | .endrepeat | ||||
| .segment "BSS" | .segment "BSS" | ||||
| ; 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 | |||||
| people_count: .res 1 ; 1-255 people exist: persons 0 .. people_count - 1 | |||||
| move_frame: .res 1 | move_frame: .res 1 | ||||
| moved_frames: .res 1 ; irq_frames at the last move_people | |||||
| move_due: .res 1 | |||||
| move_index: .res 1 | |||||
| draw_skip: .res 1 ; person left out of the last draw, $FF = none | 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 | |||||
| shown_person: .res 1 ; whose name and scores the status lines show | |||||
| shown_dirty: .res 1 ; nonzero: the status lines must be rewritten | |||||
| attr_sum: .res 1 | attr_sum: .res 1 | ||||
| NAME_LENGTH = 10 | |||||
| people_name: .res PEOPLE_COUNT * NAME_LENGTH ; person * 10, screen codes, space padded | |||||
| people_sex: .res PEOPLE_COUNT ; 0 = male, 1 = female | |||||
| name_person: .res 1 | |||||
| name_pos: .res 1 | name_pos: .res 1 | ||||
| syl_left: .res 1 | syl_left: .res 1 | ||||
| person: .res 1 | person: .res 1 | ||||
| @@ -551,12 +640,7 @@ cand_cx: .res 1 | |||||
| cand_sx: .res 1 | cand_sx: .res 1 | ||||
| cand_cy: .res 1 | cand_cy: .res 1 | ||||
| cand_sy: .res 1 | cand_sy: .res 1 | ||||
| ; Saved-byte lists: entries 0-15 belong to buffer A, 16-31 to buffer B. | |||||
| drawn_count: .res 2 | |||||
| drawn_low: .res 2 * PEOPLE_COUNT | |||||
| drawn_high: .res 2 * PEOPLE_COUNT | |||||
| drawn_byte: .res 2 * PEOPLE_COUNT | |||||
| list_start: .res 1 | |||||
| drawn_count: .res 2 ; entries in each buffer's saved-byte list | |||||
| list_pos: .res 1 | list_pos: .res 1 | ||||
| bitmap_offset: .res 1 | bitmap_offset: .res 1 | ||||
| people_buf: .res 1 ; buffer that restore/draw_people work on | people_buf: .res 1 ; buffer that restore/draw_people work on | ||||
| @@ -87,6 +87,7 @@ start_rebuild: | |||||
| sta buf_cy,x | sta buf_cy,x | ||||
| lda #0 | lda #0 | ||||
| sta buf_ready,x | sta buf_ready,x | ||||
| sta buf_dots,x ; people are drawn again once it is complete | |||||
| sta drawn_count,x | sta drawn_count,x | ||||
| sta rb_row | sta rb_row | ||||
| sta rb_col | sta rb_col | ||||
| @@ -163,8 +164,10 @@ apply_view: | |||||
| sta wrap | sta wrap | ||||
| @check: lda wrap | @check: lda wrap | ||||
| beq @commit | beq @commit | ||||
| ldx hidden ; the hidden buffer must be ready for the new origin | |||||
| lda buf_ready,x | |||||
| ldx hidden ; the hidden buffer must be ready for the new origin, | |||||
| lda buf_ready,x ; with the people drawn in it (people_update) | |||||
| beq @hold | |||||
| lda buf_dots,x | |||||
| beq @hold | beq @hold | ||||
| lda new_cx | lda new_cx | ||||
| cmp buf_cx,x | cmp buf_cx,x | ||||
| @@ -560,6 +563,7 @@ view_moved: .res 1 | |||||
| buf_cx: .res 2 | buf_cx: .res 2 | ||||
| buf_cy: .res 2 | buf_cy: .res 2 | ||||
| buf_ready: .res 2 | buf_ready: .res 2 | ||||
| buf_dots: .res 2 ; 1: people drawn in it since its rebuild (M7.2) | |||||
| buf_rows: .res 2 | buf_rows: .res 2 | ||||
| map_d011: .res 1 | map_d011: .res 1 | ||||
| map_d016: .res 1 | map_d016: .res 1 | ||||
| @@ -54,13 +54,14 @@ SPLIT_DELAY = 9 ; delay loop count; see tools/check-split.ps1 | |||||
| SPLIT_DELAY_BAD = 1 ; y-scroll 2: line 210 is a bad line, whose DMA | SPLIT_DELAY_BAD = 1 ; y-scroll 2: line 210 is a bad line, whose DMA | ||||
| ; stalls the CPU until about cycle 55 | ; stalls the CPU until about cycle 55 | ||||
| ; The status area shows only the chosen person (R8, M6.2): | |||||
| ; row 20 "P01 ALDRIC M" number, name (10 letters), M or F | |||||
| ; The status area shows only the chosen person (R8, M6.2, M7.3): | |||||
| ; row 20 "P001/016 ALDRIC M" number / people count, name (10 letters), M or F | |||||
| ; row 21 "STR12 DEX09 CON15 INT10 WIS08 CHA13" | ; row 21 "STR12 DEX09 CON15 INT10 WIS08 CHA13" | ||||
| ; rows 22-24 blank | ; rows 22-24 blank | ||||
| PERSON_DIGITS = 1 ; row 20: "Pnn" | |||||
| NAME_COLUMN = 4 ; row 20: the name | |||||
| SEX_COLUMN = 15 ; row 20: M or F | |||||
| PERSON_DIGITS = 1 ; row 20: "Pnnn" | |||||
| COUNT_DIGITS = 5 ; row 20: "/nnn" | |||||
| NAME_COLUMN = 9 ; row 20: the name | |||||
| SEX_COLUMN = 20 ; row 20: M or F | |||||
| ATTR_DIGITS = 1 * 40 + 3 ; row 21: "STRnn", then every 6 characters | ATTR_DIGITS = 1 * 40 + 3 ; row 21: "STRnn", then every 6 characters | ||||
| .assert ((SCREEN_A + TEXT1_OFFSET) & $03FF) = 0, error, "Text screen must be 1 KB aligned" | .assert ((SCREEN_A + TEXT1_OFFSET) & $03FF) = 0, error, "Text screen must be 1 KB aligned" | ||||
| @@ -112,6 +113,23 @@ show_char: | |||||
| sta TEXT_B2,y | sta TEXT_B2,y | ||||
| rts | rts | ||||
| ; A = 0-255, Y = offset in the status lines: three digits. | |||||
| show_number3: | |||||
| ldx #'0' | |||||
| @hund: cmp #100 | |||||
| bcc @rest | |||||
| sbc #100 ; carry is set | |||||
| inx | |||||
| bne @hund | |||||
| @rest: pha | |||||
| txa | |||||
| jsr show_char | |||||
| pla | |||||
| iny | |||||
| jsr show_number | |||||
| dey | |||||
| rts | |||||
| ; A = 0-99, Y = offset in the status lines. Text is fetched once per | ; A = 0-99, Y = offset in the status lines. Text is fetched once per | ||||
| ; character row, so a change never shows half-drawn. | ; character row, so a change never shows half-drawn. | ||||
| show_number: | show_number: | ||||
| @@ -141,22 +159,24 @@ show_person: | |||||
| clc | clc | ||||
| adc #1 | adc #1 | ||||
| ldy #PERSON_DIGITS | ldy #PERSON_DIGITS | ||||
| jsr show_number | |||||
| lda shown_person ; name: person * 10 | |||||
| asl a | |||||
| sta attr_index | |||||
| asl a | |||||
| asl a | |||||
| adc attr_index ; carry is clear | |||||
| tax | |||||
| ldy #NAME_COLUMN | |||||
| lda #NAME_LENGTH | |||||
| jsr show_number3 | |||||
| lda people_count | |||||
| ldy #COUNT_DIGITS | |||||
| jsr show_number3 | |||||
| lda #0 ; name: one table per letter | |||||
| sta tab_ptr | |||||
| lda #>people_name | |||||
| sta tab_ptr+1 | |||||
| lda #NAME_COLUMN | |||||
| sta attr_pos | sta attr_pos | ||||
| @name: lda people_name,x | |||||
| @name: ldy shown_person | |||||
| lda (tab_ptr),y | |||||
| ldy attr_pos | |||||
| jsr show_char | jsr show_char | ||||
| iny | |||||
| inx | |||||
| dec attr_pos | |||||
| inc attr_pos | |||||
| inc tab_ptr+1 | |||||
| lda tab_ptr+1 | |||||
| cmp #>people_name + NAME_LENGTH | |||||
| bne @name | bne @name | ||||
| ldx shown_person | ldx shown_person | ||||
| lda people_sex,x | lda people_sex,x | ||||
| @@ -164,19 +184,15 @@ show_person: | |||||
| lda sex_letters,x | lda sex_letters,x | ||||
| ldy #SEX_COLUMN | ldy #SEX_COLUMN | ||||
| jsr show_char | jsr show_char | ||||
| lda shown_person ; first score: person * 6 | |||||
| asl a | |||||
| sta attr_index | |||||
| asl a | |||||
| adc attr_index | |||||
| sta attr_index | |||||
| lda #>people_attr ; scores: one table per score | |||||
| sta tab_ptr+1 | |||||
| lda #ATTR_DIGITS | lda #ATTR_DIGITS | ||||
| sta attr_pos | sta attr_pos | ||||
| @score: ldx attr_index | |||||
| lda people_attr,x | |||||
| @score: ldy shown_person | |||||
| lda (tab_ptr),y | |||||
| ldy attr_pos | ldy attr_pos | ||||
| jsr show_number | jsr show_number | ||||
| inc attr_index | |||||
| inc tab_ptr+1 | |||||
| lda attr_pos | lda attr_pos | ||||
| clc | clc | ||||
| adc #6 | adc #6 | ||||
| @@ -225,6 +241,7 @@ raster_irq: | |||||
| sta VIC_IRQ_FLAGS | sta VIC_IRQ_FLAGS | ||||
| lda irq_phase | lda irq_phase | ||||
| bne @split | bne @split | ||||
| inc irq_frames ; people keep their speed when frames drop | |||||
| lda map_d011 ; top of frame: map with this frame's scroll | lda map_d011 ; top of frame: map with this frame's scroll | ||||
| sta VIC_CTRL1 | sta VIC_CTRL1 | ||||
| lda map_d016 | lda map_d016 | ||||
| @@ -278,7 +295,7 @@ split_delay_for_y: | |||||
| .byte SPLIT_DELAY, SPLIT_DELAY, SPLIT_DELAY, SPLIT_DELAY | .byte SPLIT_DELAY, SPLIT_DELAY, SPLIT_DELAY, SPLIT_DELAY | ||||
| sex_letters: .byte "MF" | sex_letters: .byte "MF" | ||||
| status_text: | status_text: | ||||
| .byte "P01 " | |||||
| .byte "P001/016 " | |||||
| .byte "STR00 DEX00 CON00 INT00 WIS00 CHA00 " | .byte "STR00 DEX00 CON00 INT00 WIS00 CHA00 " | ||||
| .byte " " | .byte " " | ||||
| .byte " " | .byte " " | ||||
| @@ -287,5 +304,5 @@ status_text: | |||||
| .segment "BSS" | .segment "BSS" | ||||
| irq_phase: .res 1 | irq_phase: .res 1 | ||||
| attr_index: .res 1 | |||||
| irq_frames: .res 1 ; +1 every frame, at the top-of-frame IRQ (M7.3) | |||||
| attr_pos: .res 1 | attr_pos: .res 1 | ||||
| @@ -11,11 +11,14 @@ | |||||
| direction indicator was removed in M3.3, so the border is no longer checked.) | 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, | Scenarios: no key, right, left (right SHIFT), down, up (left SHIFT), down-right, | ||||
| 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 | |||||
| up-left, SPACE held from frame 60 on (must regenerate exactly once), P held from | |||||
| frame 60 on (R8: must step to the next person exactly once), + held from frame 60 on | |||||
| (M7.3: repeats, so the people count must climb well past 16; the status count may | |||||
| lag by up to 3 while it climbs) and - held from frame 60 | |||||
| on (must stop at 1 person). In every scenario the | |||||
| people's scores must be 3-18, every name 3-10 letters (screen codes A-Z, then spaces) | people's scores must be 3-18, every name 3-10 letters (screen codes A-Z, then spaces) | ||||
| and every sex 0 or 1; status rows 20-21 (text screen 1 of buffer A) must show the | and every sex 0 or 1; status rows 20-21 (text screen 1 of buffer A) must show the | ||||
| shown person's number, name, M or F, and six scores. | |||||
| shown person's number, the people count, name, M or F, and six scores. | |||||
| Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing. | Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing. | ||||
| @@ -46,7 +49,7 @@ try { | |||||
| $hooks = @{} | $hooks = @{} | ||||
| foreach ($s in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p', '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', 'people_name', 'people_sex') { | |||||
| 'people_attr', 'shown_person', 'people_name', 'people_sex', 'people_count') { | |||||
| $hooks[$s] = Get-Label $target $s | $hooks[$s] = Get-Label $target $s | ||||
| } | } | ||||
| @@ -62,8 +65,14 @@ $scenarios = @( | |||||
| @{ name = 'left SHIFT+RIGHT+DOWN'; cursor = '7b'; lshift = '7f'; 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 = '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 } | @{ name = 'P held'; cursor = 'ff'; lshift = 'ff'; rshift = 'ff'; p = 'fd'; pAfter = 60; dx = 0; dy = 0; person = 1 } | ||||
| @{ name = '+ held'; cursor = 'ff'; lshift = 'ff'; rshift = 'ff'; p = 'fe'; pAfter = 60; dx = 0; dy = 0; countMin = 40; countMax = 255; statusLag = 3 } | |||||
| @{ name = '- held'; cursor = 'ff'; lshift = 'ff'; rshift = 'ff'; p = 'f7'; pAfter = 60; dx = 0; dy = 0; countMin = 1; countMax = 1 } | |||||
| ) | ) | ||||
| $STATUS_LINE4 = 0x4000 + 0x0400 + 20 * 40 # buffer A, text screen 1, rows 20-21 (src/status.inc) | $STATUS_LINE4 = 0x4000 + 0x0400 + 20 * 40 # buffer A, text screen 1, rows 20-21 (src/status.inc) | ||||
| # Scores and names: one page per score and per letter, indexed by person (src/people.inc). | |||||
| $attrPages = @(0..5 | ForEach-Object { $hooks.people_attr + 256 * $_ }) | |||||
| $namePages = @(0..9 | ForEach-Object { $hooks.people_name + 256 * $_ }) | |||||
| $dumpStarts = @($hooks.shown_person, $STATUS_LINE4, $hooks.people_sex, $hooks.people_count) + $attrPages + $namePages | |||||
| $root = Get-RepoPath 'build/check-keys' | $root = Get-RepoPath 'build/check-keys' | ||||
| if (Test-Path -LiteralPath $root) { Remove-Item -LiteralPath $root -Recurse -Force } | if (Test-Path -LiteralPath $root) { Remove-Item -LiteralPath $root -Recurse -Force } | ||||
| @@ -97,10 +106,11 @@ foreach ($sc in $scenarios) { | |||||
| & $add $hooks.key_row_p 'r a = ff' | & $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.scroll_dx, ($hooks.scroll_dx + 1)) | ||||
| & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $hooks.people_attr, ($hooks.people_attr + 95)) | |||||
| foreach ($pg in $attrPages) { & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $pg, ($pg + 15)) } | |||||
| & $add $hooks.keys_read ('m {0:x4} {0:x4}' -f $hooks.shown_person) | & $add $hooks.keys_read ('m {0:x4} {0:x4}' -f $hooks.shown_person) | ||||
| & $add $hooks.keys_read ('m {0:x4} {0:x4}' -f $hooks.people_count) | |||||
| & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $STATUS_LINE4, ($STATUS_LINE4 + 79)) | & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $STATUS_LINE4, ($STATUS_LINE4 + 79)) | ||||
| & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $hooks.people_name, ($hooks.people_name + 159)) | |||||
| foreach ($pg in $namePages) { & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $pg, ($pg + 15)) } | |||||
| & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $hooks.people_sex, ($hooks.people_sex + 15)) | & $add $hooks.keys_read ('m {0:x4} {1:x4}' -f $hooks.people_sex, ($hooks.people_sex + 15)) | ||||
| $spaceCheckpoint = $n + 1 | $spaceCheckpoint = $n + 1 | ||||
| & $add $hooks.space_ready 'r' | & $add $hooks.space_ready 'r' | ||||
| @@ -123,7 +133,7 @@ foreach ($sc in $scenarios) { | |||||
| if ($line -match '^>C:([0-9a-f]{4})\s+((?:[0-9a-f]{2} )+)') { | if ($line -match '^>C:([0-9a-f]{4})\s+((?:[0-9a-f]{2} )+)') { | ||||
| $a = [Convert]::ToInt32($Matches[1], 16) | $a = [Convert]::ToInt32($Matches[1], 16) | ||||
| $bytes = @($Matches[2].Trim() -split ' ' | ForEach-Object { [Convert]::ToByte($_, 16) }) | $bytes = @($Matches[2].Trim() -split ' ' | ForEach-Object { [Convert]::ToByte($_, 16) }) | ||||
| if ($a -in $hooks.people_attr, $hooks.shown_person, $STATUS_LINE4, $hooks.people_name, $hooks.people_sex) { $dumpAddr = $a; $dumps[$a] = [System.Collections.Generic.List[byte]]::new() } | |||||
| if ($a -in $dumpStarts) { $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) { } | elseif ($a -ne $hooks.scroll_dx -and $dumpAddr -ge 0 -and $a -eq $dumpAddr + $dumps[$dumpAddr].Count) { } | ||||
| else { $dumpAddr = -1 } | else { $dumpAddr = -1 } | ||||
| if ($dumpAddr -ge 0) { $dumps[$dumpAddr].AddRange([byte[]]$bytes) } | if ($dumpAddr -ge 0) { $dumps[$dumpAddr].AddRange([byte[]]$bytes) } | ||||
| @@ -139,32 +149,48 @@ foreach ($sc in $scenarios) { | |||||
| elseif ($scroll[0] -ne $sc.dx -or $scroll[1] -ne $sc.dy) { $problems += "scroll ($($scroll[0]),$($scroll[1])), expected ($($sc.dx),$($sc.dy))" } | 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, names and sexes; rows 20-21 show "Pnn", name, M/F and the six scores. | # R8: scores 3-18, names and sexes; rows 20-21 show "Pnn", name, M/F and the six scores. | ||||
| $wantPerson = if ($sc.person) { $sc.person } else { 0 } | $wantPerson = if ($sc.person) { $sc.person } else { 0 } | ||||
| if (@($hooks.people_attr, $hooks.shown_person, $STATUS_LINE4, $hooks.people_name, $hooks.people_sex) | Where-Object { -not $dumps.ContainsKey($_) -or $dumps[$_].Count -eq 0 }) { $problems += 'scores, names or status lines not logged' } | |||||
| if (@($dumpStarts | Where-Object { -not $dumps.ContainsKey($_) -or $dumps[$_].Count -eq 0 }) ) { $problems += 'scores, names or status lines not logged' } | |||||
| else { | 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 }) | |||||
| # Back to the old flat layouts: scores person * 6 + k, names person * 10 + letter. | |||||
| $attr = [byte[]]::new(96); $names = [byte[]]::new(160) | |||||
| for ($i = 0; $i -lt 16; $i++) { | |||||
| for ($k = 0; $k -lt 6; $k++) { $attr[6 * $i + $k] = $dumps[$attrPages[$k]][$i] } | |||||
| for ($k = 0; $k -lt 10; $k++) { $names[10 * $i + $k] = $dumps[$namePages[$k]][$i] } | |||||
| } | |||||
| $shown = $dumps[$hooks.shown_person][0]; $line4 = $dumps[$STATUS_LINE4] | |||||
| $count = $dumps[$hooks.people_count][0] | |||||
| $wantMin = if ($sc.countMin) { $sc.countMin } else { 16 } | |||||
| $wantMax = if ($sc.countMax) { $sc.countMax } else { 16 } | |||||
| if ($count -lt $wantMin -or $count -gt $wantMax) { $problems += "$count people, expected $wantMin-$wantMax" } | |||||
| $known = [Math]::Min(16, [int]$count) # people whose tables were logged | |||||
| $bad = @($attr[0..(6 * $known - 1)] | Where-Object { $_ -lt 3 -or $_ -gt 18 }) | |||||
| if ($bad.Count) { $problems += "$($bad.Count) scores outside 3-18" } | if ($bad.Count) { $problems += "$($bad.Count) scores outside 3-18" } | ||||
| if ($shown -ne $wantPerson) { $problems += "shown person $($shown + 1), expected $($wantPerson + 1)" } | if ($shown -ne $wantPerson) { $problems += "shown person $($shown + 1), expected $($wantPerson + 1)" } | ||||
| $digits = { param($at) ($line4[$at] - 0x30) * 10 + ($line4[$at + 1] - 0x30) } | $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)" } | |||||
| $digits3 = { param($at) ($line4[$at] - 0x30) * 100 + (& $digits ($at + 1)) } | |||||
| if ((& $digits3 1) -ne $shown + 1) { $problems += "status shows person $(& $digits3 1), expected $($shown + 1)" } | |||||
| if ($line4[4] -ne 0x2f) { $problems += "status has no / after the person number" } | |||||
| $lag = if ($sc.statusLag) { $sc.statusLag } else { 0 } # the status is refreshed every 4th frame | |||||
| $shownCount = & $digits3 5 | |||||
| if ($shownCount -gt $count -or $shownCount -lt $count - $lag) { $problems += "status shows $shownCount people, expected $count" } | |||||
| for ($k = 0; $k -lt 6; $k++) { | for ($k = 0; $k -lt 6; $k++) { | ||||
| if ((& $digits (43 + 6 * $k)) -ne $attr[6 * $shown + $k]) { $problems += "status score $($k + 1) shows $(& $digits (43 + 6 * $k)), expected $($attr[6 * $shown + $k])"; break } | if ((& $digits (43 + 6 * $k)) -ne $attr[6 * $shown + $k]) { $problems += "status score $($k + 1) shows $(& $digits (43 + 6 * $k)), expected $($attr[6 * $shown + $k])"; break } | ||||
| } | } | ||||
| $names = $dumps[$hooks.people_name]; $sexes = $dumps[$hooks.people_sex] | |||||
| $sexes = $dumps[$hooks.people_sex] | |||||
| $toText = { param($codes) -join ($codes | ForEach-Object { if ($_ -ge 1 -and $_ -le 26) { [char](0x40 + $_) } elseif ($_ -eq 0x20) { ' ' } else { '?' } }) } | $toText = { param($codes) -join ($codes | ForEach-Object { if ($_ -ge 1 -and $_ -le 26) { [char](0x40 + $_) } elseif ($_ -eq 0x20) { ' ' } else { '?' } }) } | ||||
| for ($i = 0; $i -lt 16; $i++) { | |||||
| for ($i = 0; $i -lt $known; $i++) { | |||||
| $n = & $toText $names[(10 * $i)..(10 * $i + 9)] | $n = & $toText $names[(10 * $i)..(10 * $i + 9)] | ||||
| if ($n -cnotmatch '^[A-Z]{3,10} *$') { $problems += "person $($i + 1) name '$n' is not 3-10 letters"; break } | if ($n -cnotmatch '^[A-Z]{3,10} *$') { $problems += "person $($i + 1) name '$n' is not 3-10 letters"; break } | ||||
| if ($sexes[$i] -gt 1) { $problems += "person $($i + 1) sex $($sexes[$i])"; break } | if ($sexes[$i] -gt 1) { $problems += "person $($i + 1) sex $($sexes[$i])"; break } | ||||
| } | } | ||||
| $shownName = & $toText $names[(10 * $shown)..(10 * $shown + 9)] | $shownName = & $toText $names[(10 * $shown)..(10 * $shown + 9)] | ||||
| $statusName = & $toText $line4[4..13] | |||||
| $statusName = & $toText $line4[9..18] | |||||
| if ($statusName -ne $shownName) { $problems += "status name '$statusName', expected '$shownName'" } | if ($statusName -ne $shownName) { $problems += "status name '$statusName', expected '$shownName'" } | ||||
| $sexIndex = [Math]::Min(1, [int]$sexes[$shown]) | $sexIndex = [Math]::Min(1, [int]$sexes[$shown]) | ||||
| $wantSex = @(13, 6)[$sexIndex] # screen codes M, F | $wantSex = @(13, 6)[$sexIndex] # screen codes M, F | ||||
| if ($line4[15] -ne $wantSex) { $problems += "status sex letter $($line4[15]), expected $wantSex" } | |||||
| $females = @($sexes[0..15] | Where-Object { $_ -eq 1 }).Count | |||||
| $scoresText = '{0} {1}, {2}; {3} male, {4} female' -f $shownName.Trim(), 'MF'[$sexIndex], ($attr[(6 * $shown)..(6 * $shown + 5)] -join ' '), (16 - $females), $females | |||||
| if ($line4[20] -ne $wantSex) { $problems += "status sex letter $($line4[20]), expected $wantSex" } | |||||
| $females = @($sexes[0..($known - 1)] | Where-Object { $_ -eq 1 }).Count | |||||
| $scoresText = '{0} {1}, {2}; {3} people, first {5}: {4} female' -f $shownName.Trim(), 'MF'[$sexIndex], ($attr[(6 * $shown)..(6 * $shown + 5)] -join ' '), $count, $females, $known | |||||
| } | } | ||||
| $wantRegen = if ($sc.regenerations) { $sc.regenerations } else { 0 } | $wantRegen = if ($sc.regenerations) { $sc.regenerations } else { 0 } | ||||
| if ($regenerations -ne $wantRegen) { $problems += "$regenerations regenerations, expected $wantRegen" } | if ($regenerations -ne $wantRegen) { $problems += "$regenerations regenerations, expected $wantRegen" } | ||||
| @@ -91,7 +91,7 @@ foreach ($line in Get-Content -LiteralPath (Get-RepoPath $target.build.labels)) | |||||
| if ($parts.Count -ge 3) { $L[$parts[2].TrimStart('.')] = [Convert]::ToInt32($parts[1], 16) } | if ($parts.Count -ge 3) { $L[$parts[2].TrimStart('.')] = [Convert]::ToInt32($parts[1], 16) } | ||||
| } | } | ||||
| foreach ($s in 'smoke_ready', 'people_moved', 'path_changed', 'world_tiles', 'walk_counts', 'chg_count', 'chg_done', 'move_frame', | foreach ($s in 'smoke_ready', 'people_moved', 'path_changed', 'world_tiles', 'walk_counts', 'chg_count', 'chg_done', 'move_frame', | ||||
| 'buf_cx', 'buf_rows', 'drawn_count', 'drawn_low', 'drawn_high', 'drawn_byte', 'list_starts') { | |||||
| 'buf_cx', 'buf_cy', 'buf_ready', 'buf_rows', 'drawn_count', 'drawn_low_a') { | |||||
| if (-not $L.ContainsKey($s)) { Write-Host "[FAIL] label $s not found" -ForegroundColor Red; exit 1 } | if (-not $L.ContainsKey($s)) { Write-Host "[FAIL] label $s not found" -ForegroundColor Red; exit 1 } | ||||
| } | } | ||||
| $tileData = Get-TileData | $tileData = Get-TileData | ||||
| @@ -123,11 +123,11 @@ Add-Trace $L.people_moved (& $bsave 'bitmap-a.bin' 0x6000 6400) $every | |||||
| Add-Trace $L.people_moved (& $bsave 'bitmap-b.bin' 0xA000 6400) $every | Add-Trace $L.people_moved (& $bsave 'bitmap-b.bin' 0xA000 6400) $every | ||||
| Add-Trace $L.people_moved (& $bsave 'screen-a.bin' 0x4000 800) $every | Add-Trace $L.people_moved (& $bsave 'screen-a.bin' 0x4000 800) $every | ||||
| Add-Trace $L.people_moved (& $bsave 'screen-b.bin' 0x8000 800) $every | Add-Trace $L.people_moved (& $bsave 'screen-b.bin' 0x8000 800) $every | ||||
| Add-Trace $L.people_moved (& $bsave 'bufs.bin' $L.buf_cx 8) $every | |||||
| $bufVars = $L.buf_rows + 2 - $L.buf_cx # buf_cx .. buf_rows (2 bytes each; read by label below) | |||||
| Add-Trace $L.people_moved (& $bsave 'bufs.bin' $L.buf_cx $bufVars) $every | |||||
| Add-Trace $L.people_moved (& $bsave 'counts2.bin' $L.drawn_count 2) $every | 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 | |||||
| # Saved-byte lists (src/people.inc): six pages from drawn_low_a: low, high, byte for buffer A, then B. | |||||
| Add-Trace $L.people_moved (& $bsave 'lists.bin' $L.drawn_low_a (6 * 256)) $every | |||||
| 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 } | 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 'monitor.txt') -Value $mon | ||||
| Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value '' | Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value '' | ||||
| @@ -145,7 +145,7 @@ $start = & $read 'start-world.bin'; $world = & $read 'world.bin'; $counts = & $r | |||||
| if (-not $start -or -not $world -or -not $counts -or -not $queue) { Write-Host '[FAIL] the program did not reach the save points (smoke_ready, people_moved at move_frame 0).' -ForegroundColor Red; exit 1 } | if (-not $start -or -not $world -or -not $counts -or -not $queue) { Write-Host '[FAIL] the program did not reach the save points (smoke_ready, people_moved at move_frame 0).' -ForegroundColor Red; exit 1 } | ||||
| $bitmaps = @((& $read 'bitmap-a.bin'), (& $read 'bitmap-b.bin')); $screens = @((& $read 'screen-a.bin'), (& $read 'screen-b.bin')) | $bitmaps = @((& $read 'bitmap-a.bin'), (& $read 'bitmap-b.bin')); $screens = @((& $read 'screen-a.bin'), (& $read 'screen-b.bin')) | ||||
| $bufs = & $read 'bufs.bin'; $drawnCount = & $read 'counts2.bin' | $bufs = & $read 'bufs.bin'; $drawnCount = & $read 'counts2.bin' | ||||
| $listLow = & $read 'lists.bin'; $listHigh = & $read 'listh.bin'; $listByte = & $read 'listb.bin' | |||||
| $lists = & $read 'lists.bin' | |||||
| $failures = [System.Collections.Generic.List[string]]::new() | $failures = [System.Collections.Generic.List[string]]::new() | ||||
| # Change events: the trace's register line gives A = the new tile. | # Change events: the trace's register line gives A = the new tile. | ||||
| @@ -190,17 +190,18 @@ for ($i = 0; $i -lt 4000; $i++) { | |||||
| } | } | ||||
| } | } | ||||
| # Buffers: origin (buf_cx[2], buf_cy[2], buf_ready[2], buf_rows[2]). | |||||
| # Buffers: origin, ready flag and rows built, each read at its label (buf_cx .. buf_rows). | |||||
| $dotsChecked = 0 | $dotsChecked = 0 | ||||
| for ($b = 0; $b -lt 2; $b++) { | for ($b = 0; $b -lt 2; $b++) { | ||||
| $ox = $bufs[$b]; $oy = $bufs[2 + $b]; $ready = $bufs[4 + $b]; $rows = [math]::Min(20, $bufs[6 + $b]) | |||||
| $at = { param($name) $bufs[$L[$name] - $L.buf_cx + $b] } | |||||
| $ox = & $at 'buf_cx'; $oy = & $at 'buf_cy'; $ready = & $at 'buf_ready'; $rows = [math]::Min(20, (& $at 'buf_rows')) | |||||
| if (-not $ready) { $failures.Add("buffer $b is not complete at the save"); continue } | if (-not $ready) { $failures.Add("buffer $b is not complete at the save"); continue } | ||||
| $base = @(0x6000, 0xA000)[$b] | $base = @(0x6000, 0xA000)[$b] | ||||
| $listed = @{} # address offset -> oldest saved byte | $listed = @{} # address offset -> oldest saved byte | ||||
| for ($k = $drawnCount[$b] - 1; $k -ge 0; $k--) { | for ($k = $drawnCount[$b] - 1; $k -ge 0; $k--) { | ||||
| $e = 16 * $b + $k | |||||
| $addr = $listLow[$e] + 256 * $listHigh[$e] - $base | |||||
| $listed[$addr] = $listByte[$e] # ends with the oldest entry | |||||
| $page = 3 * 256 * $b + $k | |||||
| $addr = $lists[$page] + 256 * $lists[$page + 256] - $base | |||||
| $listed[$addr] = $lists[$page + 512] # ends with the oldest entry | |||||
| } | } | ||||
| $badCells = 0; $badDots = 0 | $badCells = 0; $badDots = 0 | ||||
| for ($r = 0; $r -lt $rows; $r++) { | for ($r = 0; $r -lt $rows; $r++) { | ||||
| @@ -1,6 +1,6 @@ | |||||
| <# | <# | ||||
| .SYNOPSIS | .SYNOPSIS | ||||
| Run the C64 build headless in VICE and check that the 16 people move, never | |||||
| Run the C64 build headless in VICE and check that the people (16, or -People) move, never | |||||
| stand on water or stone, and are redrawn in both buffers without trails. | stand on water or stone, and are redrawn in both buffers without trails. | ||||
| .DESCRIPTION | .DESCRIPTION | ||||
| @@ -10,7 +10,7 @@ | |||||
| before the flip): print the people table and the visible-buffer flag to the | before the flip): print the people table and the visible-buffer flag to the | ||||
| monitor log, and save both bitmaps (each frame overwrites the last). | monitor log, and save both bitmaps (each frame overwrites the last). | ||||
| VICE quits after -Cycles cycles. The script then checks every logged frame: | VICE quits after -Cycles cycles. The script then checks every logged frame: | ||||
| 16 people inside the 80x50 world, every one on a walkable tile (not water or stone) | |||||
| every person inside the 80x50 world, every one on a walkable tile (not water or stone) | |||||
| and on a pixel that is not blue or grey (the water pixels of bridge tiles), | and on a pixel that is not blue or grey (the water pixels of bridge tiles), | ||||
| every step at most one pixel, and every person moving during the run. It checks | every step at most one pixel, and every person moving during the run. It checks | ||||
| that the main loop never misses a frame (x64sc NTSC frame = 263 lines x 65 = | that the main loop never misses a frame (x64sc NTSC frame = 263 lines x 65 = | ||||
| @@ -19,20 +19,27 @@ | |||||
| dots and the visible bitmap equals the clean map plus the previous frame's dots: | dots and the visible bitmap equals the clean map plus the previous frame's dots: | ||||
| no trails, no damaged terrain. | no trails, no damaged terrain. | ||||
| -People N builds a variant that starts with N people (PEOPLE_START, 1-255; | |||||
| build/land-map-64-peopleN.prg). With more than 16 the main loop may take longer | |||||
| than a frame (M7.3: people keep their speed, frames drop): missed frames are then | |||||
| reported, not failed, and the number of frames per main-loop pass is shown. | |||||
| Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing. | Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing. | ||||
| .EXAMPLE | .EXAMPLE | ||||
| pwsh -File tools/check-people.ps1 | pwsh -File tools/check-people.ps1 | ||||
| pwsh -File tools/check-people.ps1 -People 255 | |||||
| #> | #> | ||||
| [CmdletBinding()] | [CmdletBinding()] | ||||
| param( | param( | ||||
| [int]$Cycles = 40000000, | [int]$Cycles = 40000000, | ||||
| [switch]$NoBuild, | [switch]$NoBuild, | ||||
| [int]$TimeoutSeconds = 180 | |||||
| [int]$TimeoutSeconds = 180, | |||||
| [ValidateRange(1, 255)][int]$People = 16 | |||||
| ) | ) | ||||
| . (Join-Path $PSScriptRoot 'lib.ps1') | . (Join-Path $PSScriptRoot 'lib.ps1') | ||||
| $count = 16 | |||||
| $count = $People | |||||
| $width = 80 | $width = 80 | ||||
| $height = 50 | $height = 50 | ||||
| $blocking = 3..12 # STONE..WATER_SE in src/tiles.inc | $blocking = 3..12 # STONE..WATER_SE in src/tiles.inc | ||||
| @@ -71,6 +78,7 @@ function Get-Label([hashtable]$Target, [string]$Symbol) { | |||||
| try { | try { | ||||
| $project = Get-ProjectConfig | $project = Get-ProjectConfig | ||||
| $target = Get-ProjectTargets $project 'c64' | $target = Get-ProjectTargets $project 'c64' | ||||
| if ($People -ne 16) { Set-TargetVariant $target "PEOPLE_START=$People" "people$People" } | |||||
| if (-not $NoBuild) { Invoke-TargetBuild $project $target @{} } | if (-not $NoBuild) { Invoke-TargetBuild $project $target @{} } | ||||
| $emu = Get-ToolPath $project $target.emulator.binary | $emu = Get-ToolPath $project $target.emulator.binary | ||||
| } catch [MissingToolException] { | } catch [MissingToolException] { | ||||
| @@ -85,11 +93,14 @@ New-Item -ItemType Directory -Force -Path $dir | Out-Null | |||||
| $ready = Get-Label $target 'smoke_ready' | $ready = Get-Label $target 'smoke_ready' | ||||
| $moved = Get-Label $target 'people_moved' | $moved = Get-Label $target 'people_moved' | ||||
| $world = Get-Label $target 'world_tiles' | $world = Get-Label $target 'world_tiles' | ||||
| $people = Get-Label $target 'people_cx' | |||||
| $peopleCx = Get-Label $target 'people_cx' | |||||
| $visibleFlag = Get-Label $target 'visible' | $visibleFlag = Get-Label $target 'visible' | ||||
| # The five people tables, then move_frame and draw_skip (src/people.inc keeps them together). | |||||
| # Logged per frame, in this order: the first $count entries of people_cx, people_sx, people_cy, | |||||
| # people_sy and people_dir (one page each, src/people.inc), then move_frame and draw_skip. | |||||
| $tableSize = 5 * $count + 2 | $tableSize = 5 * $count + 2 | ||||
| $tableEnd = $people + $tableSize - 1 | |||||
| $peopleDumps = @('people_cx', 'people_sx', 'people_cy', 'people_sy', 'people_dir' | ForEach-Object { | |||||
| $a = Get-Label $target $_; 'm {0:x4} {1:x4}' -f $a, ($a + $count - 1) }) | |||||
| $peopleDumps += @('move_frame', 'draw_skip' | ForEach-Object { 'm {0:x4} {0:x4}' -f (Get-Label $target $_) }) | |||||
| $bitmapSize = 20 * 320 # the 20 map rows; rows 20-24 lie under the status text | $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) | $buffers = @(0x6000, 0xA000) # bitmaps of buffers A and B (src/main.s) | ||||
| $monitor = [System.Collections.Generic.List[string]]::new() | $monitor = [System.Collections.Generic.List[string]]::new() | ||||
| @@ -104,8 +115,9 @@ function Add-Trace([int]$Address, [string]$Command) { | |||||
| Add-Trace $ready ('bsave \"world.bin\" 0 {0:x4} {1:x4}' -f $world, ($world + $width * $height - 1)) | Add-Trace $ready ('bsave \"world.bin\" 0 {0:x4} {1:x4}' -f $world, ($world + $width * $height - 1)) | ||||
| Add-Trace $ready ('bsave \"clean-a.bin\" 0 {0:x4} {1:x4}' -f $buffers[0], ($buffers[0] + $bitmapSize - 1)) | Add-Trace $ready ('bsave \"clean-a.bin\" 0 {0:x4} {1:x4}' -f $buffers[0], ($buffers[0] + $bitmapSize - 1)) | ||||
| Add-Trace $ready ('bsave \"clean-b.bin\" 0 {0:x4} {1:x4}' -f $buffers[1], ($buffers[1] + $bitmapSize - 1)) | Add-Trace $ready ('bsave \"clean-b.bin\" 0 {0:x4} {1:x4}' -f $buffers[1], ($buffers[1] + $bitmapSize - 1)) | ||||
| Add-Trace $moved ('m {0:x4} {1:x4}' -f $people, $tableEnd) | |||||
| Add-Trace $moved $peopleDumps[0] | |||||
| $peopleCheckpoint = $n | $peopleCheckpoint = $n | ||||
| foreach ($d in $peopleDumps[1..($peopleDumps.Count - 1)]) { Add-Trace $moved $d } | |||||
| Add-Trace $moved ('m {0:x4} {0:x4}' -f $visibleFlag) | Add-Trace $moved ('m {0:x4} {0:x4}' -f $visibleFlag) | ||||
| Add-Trace $moved ('bsave \"final-a.bin\" 0 {0:x4} {1:x4}' -f $buffers[0], ($buffers[0] + $bitmapSize - 1)) | Add-Trace $moved ('bsave \"final-a.bin\" 0 {0:x4} {1:x4}' -f $buffers[0], ($buffers[0] + $bitmapSize - 1)) | ||||
| Add-Trace $moved ('bsave \"final-b.bin\" 0 {0:x4} {1:x4}' -f $buffers[1], ($buffers[1] + $bitmapSize - 1)) | Add-Trace $moved ('bsave \"final-b.bin\" 0 {0:x4} {1:x4}' -f $buffers[1], ($buffers[1] + $bitmapSize - 1)) | ||||
| @@ -147,7 +159,7 @@ foreach ($line in Get-Content -LiteralPath $logFile) { | |||||
| $addr = [Convert]::ToInt32($Matches[1], 16) | $addr = [Convert]::ToInt32($Matches[1], 16) | ||||
| $hexBytes = $Matches[2].Trim() -split ' ' | $hexBytes = $Matches[2].Trim() -split ' ' | ||||
| if ($addr -eq $visibleFlag) { $visibleLog.Add([Convert]::ToInt32($hexBytes[0], 16)); continue } | if ($addr -eq $visibleFlag) { $visibleLog.Add([Convert]::ToInt32($hexBytes[0], 16)); continue } | ||||
| if ($addr -eq $people) { $current.Clear() } | |||||
| if ($addr -eq $peopleCx) { $current.Clear() } | |||||
| foreach ($hex in $hexBytes) { | foreach ($hex in $hexBytes) { | ||||
| if ($current.Count -lt $tableSize) { $current.Add([Convert]::ToByte($hex, 16)) } | if ($current.Count -lt $tableSize) { $current.Add([Convert]::ToByte($hex, 16)) } | ||||
| } | } | ||||
| @@ -163,7 +175,7 @@ $moves = [int[]]::new($count) | |||||
| $previous = $null | $previous = $null | ||||
| foreach ($f in $frames) { | foreach ($f in $frames) { | ||||
| for ($i = 0; $i -lt $count; $i++) { | for ($i = 0; $i -lt $count; $i++) { | ||||
| $cx = $f[$i]; $sx = $f[16 + $i]; $cy = $f[32 + $i]; $sy = $f[48 + $i]; $heading = $f[64 + $i] | |||||
| $cx = $f[$i]; $sx = $f[$count + $i]; $cy = $f[2 * $count + $i]; $sy = $f[3 * $count + $i]; $heading = $f[4 * $count + $i] | |||||
| if ($cx -ge $width -or $cy -ge $height -or $sx -gt 3 -or $sy -gt 7 -or $heading -gt 3) { | if ($cx -ge $width -or $cy -ge $height -or $sx -gt 3 -or $sy -gt 7 -or $heading -gt 3) { | ||||
| $failures.Add("person $i out of range: cell ($cx,$cy) pixel ($sx,$sy) dir $heading"); continue | $failures.Add("person $i out of range: cell ($cx,$cy) pixel ($sx,$sy) dir $heading"); continue | ||||
| } | } | ||||
| @@ -175,7 +187,7 @@ foreach ($f in $frames) { | |||||
| if ($color -in $waterColors) { $failures.Add("person $i on a colour $color pixel of tile $tile at cell ($cx,$cy) pixel ($sx,$sy)") } | if ($color -in $waterColors) { $failures.Add("person $i on a colour $color pixel of tile $tile at cell ($cx,$cy) pixel ($sx,$sy)") } | ||||
| if ($tile -ge $bridgeFirst) { $onBridge++ } | if ($tile -ge $bridgeFirst) { $onBridge++ } | ||||
| if ($previous) { | if ($previous) { | ||||
| $x0 = $previous[$i] * 4 + $previous[16 + $i]; $y0 = $previous[32 + $i] * 8 + $previous[48 + $i] | |||||
| $x0 = $previous[$i] * 4 + $previous[$count + $i]; $y0 = $previous[2 * $count + $i] * 8 + $previous[3 * $count + $i] | |||||
| $dx = [Math]::Abs($cx * 4 + $sx - $x0); $dy = [Math]::Abs($cy * 8 + $sy - $y0) | $dx = [Math]::Abs($cx * 4 + $sx - $x0); $dy = [Math]::Abs($cy * 8 + $sy - $y0) | ||||
| if ($dx + $dy -gt 1) { $failures.Add("person $i jumped $dx,$dy pixels") } | if ($dx + $dy -gt 1) { $failures.Add("person $i jumped $dx,$dy pixels") } | ||||
| if ($dx + $dy -eq 1) { $moves[$i]++ } | if ($dx + $dy -eq 1) { $moves[$i]++ } | ||||
| @@ -193,21 +205,27 @@ $frameCycles = 17095 | |||||
| $late = 0 | $late = 0 | ||||
| for ($k = 1; $k -lt $clocks.Count; $k++) { if ($clocks[$k] - $clocks[$k - 1] -gt 1.5 * $frameCycles) { $late++ } } | for ($k = 1; $k -lt $clocks.Count; $k++) { if ($clocks[$k] - $clocks[$k - 1] -gt 1.5 * $frameCycles) { $late++ } } | ||||
| if ($clocks.Count -lt $frames.Count) { $failures.Add("only $($clocks.Count) hook clocks for $($frames.Count) frames") } | if ($clocks.Count -lt $frames.Count) { $failures.Add("only $($clocks.Count) hook clocks for $($frames.Count) frames") } | ||||
| if ($late -gt 0) { $failures.Add("the main loop missed $late frame(s)") } | |||||
| if ($late -gt 0 -and $count -le 16) { $failures.Add("the main loop missed $late frame(s)") } | |||||
| $passFrames = if ($clocks.Count -gt 1) { [Math]::Round(($clocks[$clocks.Count - 1] - $clocks[0]) / ($clocks.Count - 1) / $frameCycles, 2) } else { 0 } | |||||
| # The flip happens from line 251; the update must end before the visible area (line 51). | # The flip happens from line 251; the update must end before the visible area (line 51). | ||||
| $lastLine = ($lines | Where-Object { $_ -lt 200 } | Measure-Object -Maximum).Maximum | |||||
| if (@($lines | Where-Object { $_ -ge 51 }).Count -gt 0) { $failures.Add('a people update ran into the visible area (hook at raster line 51 or later)') } | |||||
| # Since M7.2 the vertical blank does no people work, so the hook is usually reached at line | |||||
| # 251-262, before the raster wraps to 0; those count as early (shown as negative: line - 263). | |||||
| $vblankLines = @($lines | ForEach-Object { if ($_ -ge 251) { $_ - 263 } else { $_ } }) | |||||
| $lastLine = ($vblankLines | Measure-Object -Maximum).Maximum | |||||
| if (@($vblankLines | Where-Object { $_ -ge 51 }).Count -gt 0) { $failures.Add('the vertical blank work ran into the visible area (hook at raster line 51 or later)') } | |||||
| # Final frame: hidden buffer = clean + current dots, visible buffer = clean + previous dots. | |||||
| # Final frame, at people_moved (after the vertical blank flip; M7.2): the people were drawn into | |||||
| # the now visible buffer last frame, after the moves, so it holds clean + the dots of the table | |||||
| # logged now; the now hidden buffer was drawn the frame before: clean + the previous table's dots. | |||||
| function Get-ExpectedBitmap([byte[]]$Clean, [byte[]]$Table) { | function Get-ExpectedBitmap([byte[]]$Clean, [byte[]]$Table) { | ||||
| $bitmap = [byte[]]$Clean.Clone() | $bitmap = [byte[]]$Clean.Clone() | ||||
| $masks = 0xC0, 0x30, 0x0C, 0x03 | $masks = 0xC0, 0x30, 0x0C, 0x03 | ||||
| for ($i = 0; $i -lt $count; $i++) { | for ($i = 0; $i -lt $count; $i++) { | ||||
| if ($i -eq $Table[5 * $count + 1]) { continue } # draw_skip: the shown person blinks (R8) | if ($i -eq $Table[5 * $count + 1]) { continue } # draw_skip: the shown person blinks (R8) | ||||
| $cx = $Table[$i]; $cy = $Table[32 + $i] | |||||
| $cx = $Table[$i]; $cy = $Table[2 * $count + $i] | |||||
| if ($cx -ge 39 -or $cy -ge 20) { continue } # 39 drawn columns; the dumps hold the 20 map rows | 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] | |||||
| $bitmap[$offset] = $bitmap[$offset] -bor $masks[$Table[16 + $i]] | |||||
| $offset = $cy * 320 + $cx * 8 + $Table[3 * $count + $i] | |||||
| $bitmap[$offset] = $bitmap[$offset] -bor $masks[$Table[$count + $i]] | |||||
| } | } | ||||
| , $bitmap | , $bitmap | ||||
| } | } | ||||
| @@ -218,8 +236,8 @@ $drawnByte = { param($b) ($b % 320) -lt 312 } | |||||
| for ($b = 0; $b -lt $bitmapSize; $b++) { if ((& $drawnByte $b) -and $clean[0][$b] -ne $clean[1][$b]) { $failures.Add('buffers A and B differ before people are drawn'); break } } | for ($b = 0; $b -lt $bitmapSize; $b++) { if ((& $drawnByte $b) -and $clean[0][$b] -ne $clean[1][$b]) { $failures.Add('buffers A and B differ before people are drawn'); break } } | ||||
| $shown = $visibleLog[$visibleLog.Count - 1] | $shown = $visibleLog[$visibleLog.Count - 1] | ||||
| $hiddenIndex = 1 - $shown | $hiddenIndex = 1 - $shown | ||||
| $expectHidden = Get-ExpectedBitmap $clean[$hiddenIndex] $frames[$frames.Count - 1] | |||||
| $expectShown = Get-ExpectedBitmap $clean[$shown] $frames[$frames.Count - 2] | |||||
| $expectHidden = Get-ExpectedBitmap $clean[$hiddenIndex] $frames[$frames.Count - 2] | |||||
| $expectShown = Get-ExpectedBitmap $clean[$shown] $frames[$frames.Count - 1] | |||||
| $dots = 0 | $dots = 0 | ||||
| foreach ($pair in @(@($final[$hiddenIndex], $expectHidden, 'hidden'), @($final[$shown], $expectShown, 'visible'))) { | foreach ($pair in @(@($final[$hiddenIndex], $expectHidden, 'hidden'), @($final[$shown], $expectShown, 'visible'))) { | ||||
| $bad = 0 | $bad = 0 | ||||
| @@ -230,16 +248,18 @@ foreach ($pair in @(@($final[$hiddenIndex], $expectHidden, 'hidden'), @($final[$ | |||||
| } | } | ||||
| for ($b = 0; $b -lt $bitmapSize; $b++) { if ($final[$hiddenIndex][$b] -ne $clean[$hiddenIndex][$b] -and ($b % 320) -lt 312) { $dots++ } } | for ($b = 0; $b -lt $bitmapSize; $b++) { if ($final[$hiddenIndex][$b] -ne $clean[$hiddenIndex][$b] -and ($b % 320) -lt 312) { $dots++ } } | ||||
| $sectors = @(0..($count - 1) | ForEach-Object { [int]($first[$_] -ge 40) + 2 * [int]($first[32 + $_] -ge 25) } | Sort-Object -Unique) | |||||
| if ($sectors.Count -ne 4) { $failures.Add("people start in only $($sectors.Count) of 4 screens") } | |||||
| $sectors = @(0..($count - 1) | ForEach-Object { [int]($first[$_] -ge 40) + 2 * [int]($first[2 * $count + $_] -ge 25) } | Sort-Object -Unique) | |||||
| if ($sectors.Count -ne [Math]::Min(4, $count)) { $failures.Add("people start in only $($sectors.Count) of 4 screens") } | |||||
| $seconds = [Math]::Round($frames.Count / 60.0, 1) | $seconds = [Math]::Round($frames.Count / 60.0, 1) | ||||
| Write-Host ("Buffer flips: {0} frames, {1} missed; people update done by raster line {2} at the latest. Final hidden buffer: {3}, {4} bytes carry dots." -f $clocks.Count, $late, $lastLine, ('A', 'B')[$hiddenIndex], $dots) | |||||
| Write-Host ("Logged {0} movement frames (~{1} s NTSC). Steps per person: {2}. Person-frames on bridges: {3}." -f $frames.Count, $seconds, ($moves -join ' '), $onBridge) | |||||
| Write-Host ("Main loop passes: {0}, {1} longer than a frame ({2} frames per pass on average); vertical blank work done by raster line {3} at the latest. Final hidden buffer: {4}, {5} bytes carry dots." -f $clocks.Count, $late, $passFrames, $lastLine, ('A', 'B')[$hiddenIndex], $dots) | |||||
| if ($clocks.Count -gt 1) { $seconds = [Math]::Round(($clocks[$clocks.Count - 1] - $clocks[0]) / 1022727.0, 1) } | |||||
| $stepText = if ($count -le 16) { $moves -join ' ' } else { 'min {0}, max {1}' -f ($moves | Measure-Object -Minimum).Minimum, ($moves | Measure-Object -Maximum).Maximum } | |||||
| Write-Host ("Logged {0} movement frames (~{1} s NTSC). Steps per person: {2}. Person-frames on bridges: {3}." -f $frames.Count, $seconds, $stepText, $onBridge) | |||||
| if ($failures.Count -gt 0) { | if ($failures.Count -gt 0) { | ||||
| $failures | Select-Object -First 10 | ForEach-Object { Write-Host " $_" } | $failures | Select-Object -First 10 | ForEach-Object { Write-Host " $_" } | ||||
| Write-Host '[FAIL] people check' -ForegroundColor Red | Write-Host '[FAIL] people check' -ForegroundColor Red | ||||
| exit 1 | exit 1 | ||||
| } | } | ||||
| Write-Host '[PASS] 16 people spread over 4 screens move one pixel at a time, never stand on water or stone (tiles or blue/grey bridge pixels); both buffers hold only the clean map plus the right dots; one flip per frame.' -ForegroundColor Green | |||||
| Write-Host "[PASS] $count people spread over the screens move one pixel at a time, never stand on water or stone (tiles or blue/grey bridge pixels); both buffers hold only the clean map plus the right dots; one flip per frame$(if ($count -gt 16) { ' (or per main-loop pass)' })." -ForegroundColor Green | |||||
| exit 0 | exit 0 | ||||
| @@ -128,8 +128,13 @@ foreach ($s in 'smoke_ready', 'people_moved', 'world_tiles', 'people_cx', 'visib | |||||
| 'frame_start', 'frame_done', 'start_rebuild', 'rebuild_ready', | 'frame_start', 'frame_done', 'start_rebuild', 'rebuild_ready', | ||||
| 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space', 'key_row_p') { $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 | $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)' } | |||||
| # Logged per frame, in this order: 16 entries of people_cx, people_sx, people_cy, people_sy and | |||||
| # people_dir (one page each, src/people.inc), then move_frame and draw_skip: 82 bytes, indexed | |||||
| # as before (cx at 0, sx at 16, cy at 32, sy at 48, draw_skip at 81). | |||||
| $PEOPLE_BLOCK = 82 | |||||
| $peopleRanges = @(foreach ($t in 'people_cx', 'people_sx', 'people_cy', 'people_sy', 'people_dir') { $a = Get-Label $target $t; , @($a, 16) }) + | |||||
| @(foreach ($t in 'move_frame', 'draw_skip') { , @((Get-Label $target $t), 1) }) | |||||
| $inPeople = { param([int]$addr) foreach ($r in $peopleRanges) { if ($addr -ge $r[0] -and $addr -lt $r[0] + $r[1]) { return $true } }; $false } | |||||
| foreach ($s in 'chg_count', 'chg_done', 'path_changed') { $L[$s] = Get-Label $target $s } | 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 | $IRQ_ENTRY = 0xFF48; $IRQ_EXIT = 0xEA81 # KERNAL IRQ entry and the exit our handler jumps to | ||||
| $FRAME_CYCLES = 17095 | $FRAME_CYCLES = 17095 | ||||
| @@ -260,7 +265,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_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} {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} {0:x4}' -f $PHASE) $null | ||||
| & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.people_cx, ($L.people_cx + $PEOPLE_BLOCK - 1)) $null | |||||
| foreach ($r in $peopleRanges) { & $add $L.people_moved ('m {0:x4} {1:x4}' -f $r[0], ($r[0] + $r[1] - 1)) $null } | |||||
| foreach ($save in $saves) { | foreach ($save in $saves) { | ||||
| $f = $save -split ' ' | $f = $save -split ' ' | ||||
| & $add $L.people_moved ('bsave \"{0}\" 0 {1} {2}' -f $f[0], $f[1], $f[2]) @(, @($PHASE, $lastPhase)) | & $add $L.people_moved ('bsave \"{0}\" 0 {1} {2}' -f $f[0], $f[1], $f[2]) @(, @($PHASE, $lastPhase)) | ||||
| @@ -328,7 +333,7 @@ foreach ($sc in $scenarios) { | |||||
| elseif ($addr -eq $L.buf_cx) { $cur.bufcx = $bytes[0..1] } | 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_cy) { $cur.bufcy = $bytes[0..1] } | ||||
| elseif ($addr -eq $L.buf_ready) { $cur.ready = $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 + $PEOPLE_BLOCK) { foreach ($b in $bytes) { if ($cur.people.Count -lt $PEOPLE_BLOCK) { $cur.people.Add($b) } } } | |||||
| elseif (& $inPeople $addr) { 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. | # 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' | $fields = 'cx', 'd011', 'visible', 'pending', 'bufcx', 'bufcy', 'ready', 'phase', 'clock' | ||||
| @@ -11,7 +11,7 @@ | |||||
| while a headless VICE has focus would otherwise reach the program), then holds | while a headless VICE has focus would otherwise reach the program), then holds | ||||
| CRSR DOWN from frame 30 until the view is at cell row 3, then SHIFT+CRSR DOWN | CRSR DOWN from frame 30 until the view is at cell row 3, then SHIFT+CRSR DOWN | ||||
| until it is back at row 0, then no key, so every map y-scroll value (0-7) is split; | until it is back at row 0, then no key, so every map y-scroll value (0-7) is split; | ||||
| - at people_moved: logs the view position, the people table with move_frame, and the | |||||
| - at people_moved: logs the view position, move_frame, and the | |||||
| shown person's number (status row 20) of text screen 1 in both banks. | shown person's number (status row 20) of text screen 1 in both banks. | ||||
| Then checks: | Then checks: | ||||
| - every split starts between line 210 cycle 53 and line 210 cycle 64, for every | - every split starts between line 210 cycle 53 and line 210 cycle 64, for every | ||||
| @@ -60,16 +60,15 @@ New-Item -ItemType Directory -Force -Path $dir | Out-Null | |||||
| $L = @{} | $L = @{} | ||||
| foreach ($sym in 'split_store', 'split_delay', 'people_moved', 'smoke_ready', 'people_cx', 'map_d011', 'move_frame', 'view_cx', 'view_cy', 'view_fy', | 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', 'key_row_p') { $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 { $_ + 20 * 40 + 1 } # row 20, after "P" | |||||
| $digits = @(0x4400, 0x8400) | ForEach-Object { $_ + 20 * 40 + 2 } # row 20, last two digits of "P001" | |||||
| $PHASE = 0xCFF0 # free RAM: scroll phase 0 still, 1 down, 2 up, 3 still | $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 ' && ' } | $cond = { param($pairs) ($pairs | ForEach-Object { '(@cpu:${0:x4} == ${1:x2})' -f $_[0], $_[1] }) -join ' && ' } | ||||
| if ($L.move_frame -ne $L.people_cx + 80) { throw 'move_frame must follow the five people tables (src/people.inc)' } | |||||
| # Checkpoints 1-5 keep their numbers: the parser below relies on them. | # Checkpoints 1-5 keep their numbers: the parser below relies on them. | ||||
| $mon = @( | $mon = @( | ||||
| 'logname "monitor.log"', 'log on' | 'logname "monitor.log"', 'log on' | ||||
| ('trace exec ${0:x4}' -f $L.split_store), ('command 1 "m {0:x4} {0:x4}"' -f $L.map_d011) | ('trace exec ${0:x4}' -f $L.split_store), ('command 1 "m {0:x4} {0:x4}"' -f $L.map_d011) | ||||
| ('trace exec ${0:x4}' -f $L.people_moved), ('command 2 "m {0:x4} {1:x4}"' -f $L.view_cx, ($L.view_cx + 3)) | ('trace exec ${0:x4}' -f $L.people_moved), ('command 2 "m {0:x4} {1:x4}"' -f $L.view_cx, ($L.view_cx + 3)) | ||||
| ('trace exec ${0:x4}' -f $L.people_moved), ('command 3 "m {0:x4} {1:x4}"' -f $L.people_cx, ($L.people_cx + 80)) | |||||
| ('trace exec ${0:x4}' -f $L.people_moved), ('command 3 "m {0:x4} {0:x4}"' -f $L.move_frame) | |||||
| ('trace exec ${0:x4}' -f $L.people_moved), ('command 4 "m {0:x4} {1:x4}"' -f $digits[0], ($digits[0] + 1)) | ('trace exec ${0:x4}' -f $L.people_moved), ('command 4 "m {0:x4} {1:x4}"' -f $digits[0], ($digits[0] + 1)) | ||||
| ('trace exec ${0:x4}' -f $L.people_moved), ('command 5 "m {0:x4} {1:x4}"' -f $digits[1], ($digits[1] + 1)) | ('trace exec ${0:x4}' -f $L.people_moved), ('command 5 "m {0:x4} {1:x4}"' -f $digits[1], ($digits[1] + 1)) | ||||
| ('trace exec ${0:x4}' -f $L.split_store), ('command 6 "m {0:x4} {0:x4}"' -f ($L.split_delay + 1)) | ('trace exec ${0:x4}' -f $L.split_store), ('command 6 "m {0:x4} {0:x4}"' -f ($L.split_delay + 1)) | ||||
| @@ -124,7 +123,6 @@ foreach ($line in Get-Content -LiteralPath $log) { | |||||
| if ($lastCheckpoint -eq 6 -and $null -ne $split) { $split.delay = $bytes[0] } | if ($lastCheckpoint -eq 6 -and $null -ne $split) { $split.delay = $bytes[0] } | ||||
| if ($null -eq $frame) { continue } | if ($null -eq $frame) { continue } | ||||
| if ($lastCheckpoint -eq 2) { $frame.cx = $bytes[0]; $frame.fx = $bytes[1]; $frame.cy = $bytes[2]; $frame.fy = $bytes[3] } | if ($lastCheckpoint -eq 2) { $frame.cx = $bytes[0]; $frame.fx = $bytes[1]; $frame.cy = $bytes[2]; $frame.fy = $bytes[3] } | ||||
| if ($lastCheckpoint -eq 3) { foreach ($b in $bytes) { if ($frame.people.Count -lt 81) { $frame.people.Add($b) } } } | |||||
| if ($lastCheckpoint -eq 4 -or $lastCheckpoint -eq 5) { $frame.digits += , (($bytes[0] - 0x30) * 10 + ($bytes[1] - 0x30)) } | if ($lastCheckpoint -eq 4 -or $lastCheckpoint -eq 5) { $frame.digits += , (($bytes[0] - 0x30) * 10 + ($bytes[1] - 0x30)) } | ||||
| if ($lastCheckpoint -eq 5) { | if ($lastCheckpoint -eq 5) { | ||||
| $moveFrames++ | $moveFrames++ | ||||
Powered by TurnKey Linux.