Ver código fonte

M3.4: long scrolling runs and measured frame budget; timing bar build

- People movement moved out of the vertical blank (it overran the first map
  line with nearly all 16 people in view); drawn at the next vertical blank.
- Optional timing bar (--asm-define TIMING_BAR, tools/run.ps1 -TimingBar)
  in a separate PRG; hook labels frame_start, frame_done, rebuild_ready.
- tools/check-scroll.ps1: per-frame budget from CPU clocks, rebuild length,
  -Long 5-minute tour with 21 byte-exact stops, -ParseOnly, right-edge fix.
- tools/lib.ps1: asmDefines for ca65 symbols.
- docs: MT3.2 long-run steps, new MT3.4, toolchain, verification status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main
Daniel Covington 2 dias atrás
pai
commit
3a63d55b67
12 arquivos alterados com 299 adições e 42 exclusões
  1. +42
    -2
      docs/manual-tests.md
  2. +1
    -1
      docs/milestones.md
  3. +3
    -1
      docs/toolchain.md
  4. +12
    -1
      docs/verification-status.md
  5. +26
    -4
      project.json
  6. +27
    -2
      src/main.s
  7. +4
    -2
      src/people.inc
  8. +1
    -0
      src/scroll.inc
  9. +12
    -1
      src/status.inc
  10. +157
    -27
      tools/check-scroll.ps1
  11. +1
    -0
      tools/lib.ps1
  12. +13
    -1
      tools/run.ps1

+ 42
- 2
docs/manual-tests.md Ver arquivo

@@ -157,16 +157,56 @@ Verifies: R1, R5
Setup: VICE x64sc, NTSC (-ntsc), warp off.
Start: `pwsh -File tools/run.ps1 -Target c64`

Automated first (M3.4): `pwsh -File tools/check-scroll.ps1 -Long` (takes about 10 minutes)
should print `[PASS] all 4 scroll scenarios: ...`; its `tour` line reports the stops checked
byte for byte.

Steps:
1. Scroll slowly past several people.
2. From M3.4: scroll around the whole world for about 5 minutes (every direction, with
stops), then stop with several people in view and watch them for a minute.
3. From M3.4: find a place where many dots are in view near the top of the map (or wait
for them to gather) and scroll left and right there.

Expected:
- Dots stay on the terrain they walk on
- Dots stay on the terrain they walk on, while scrolling and after long runs
- 16 dots in total across the world
- No trails left behind
- No trails or damaged terrain left behind, even after 5 minutes
- No flicker or tearing of the dots near the top of the map, even with many dots in view

Verifies: R2, R3, R5

### MT3.4: Frame budget timing bar (c64, M3.4)

Setup: VICE x64sc, NTSC (-ntsc), warp off.
Start: `pwsh -File tools/run.ps1 -Target c64 -TimingBar` (a separate build,
`build/land-map-64-timing.prg`; the normal program is not changed).

The border colour shows what the CPU is doing during each frame:

| Border | Work |
|---|---|
| white | scroll step, buffer flip, people restore and draw (vertical blank) |
| yellow | keys, status text, people movement |
| cyan | rebuilding the hidden buffer for the next scroll step |
| red | raster interrupt (the split to the status area, and the top of the frame) |
| brown | idle, waiting for the next frame |

Steps:
1. Leave the view still for a few seconds.
2. Hold a cursor key and watch the border while the map scrolls.

Expected:
- View still: the border is mostly brown, with a thin red stripe at the status split
(the white and yellow work happens in lines the border mostly does not show).
- Scrolling: the border is cyan down to near the bottom of the screen (the rebuild uses
the frame's spare time), with the red stripe at the split and a little brown below.
- In both cases the border pattern is steady from frame to frame, not rolling or
jumping: the program keeps up with every frame. (Small specks at colour changes are
normal for a border-colour timing bar.)

Verifies: R3.3, A4 (measured numbers: tools/check-scroll.ps1 budget lines)

### MT3.3: Status area (c64)

Setup: VICE x64sc, NTSC (-ntsc), warp off.


+ 1
- 1
docs/milestones.md Ver arquivo

@@ -53,6 +53,6 @@ Requirements: R5, R6, R3, R2
| M3.1 | Keyboard matrix reading for the cursor keys with SHIFT, held-key repeat. | R5 | Scroll direction from keys | Manual test MT3.1 |
| M3.2 | Split screen: raster interrupts switch to text below a 20-row map and back at the top of the frame; status text screen and ROM font copy in both banks; status lines with the people-in-view count. | R6, R1 | Steady 20-row map with 5 status lines below | Manual test MT3.3 |
| M3.3 | Fine scroll via $D016/$D011 in the 38-column, 20-row map area; rebuild the hidden buffer from tiles over 8 frames and flip on wrap; stop at world edges; show the view position in the status area; draw people relative to the view (in the shown buffer during vertical blank while a rebuild runs). | R5, R3, R6, R2 | Smooth scrolling across the world under a fixed status area, people in place | Manual tests MT3.1, MT3.2 and MT3.3 |
| M3.4 | Check that people stay aligned with the terrain over long scrolling runs; measure the frame budget with a border-colour timing bar. | R2, R3, R5, R6 | People stay aligned with terrain over long runs; budget measured | Manual tests MT3.2 and MT3.3 |
| M3.4 | Check that people stay aligned with the terrain over long scrolling runs; measure the frame budget with a border-colour timing bar. | R2, R3, R5, R6 | People stay aligned with terrain over long runs; budget measured | Manual tests MT3.2, MT3.3 and MT3.4 |

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

+ 3
- 1
docs/toolchain.md Ver arquivo

@@ -40,6 +40,8 @@ Check them with `pwsh -File tools/check-prereqs.ps1`. Lookup order for each tool
| Build all targets | `pwsh -File tools/build.ps1` |
| Build one target | `pwsh -File tools/build.ps1 -Target <id>` |
| Run in VICE | `pwsh -File tools/run.ps1 -Target <id>` (add `-Video ntsc` to try NTSC) |
| Run with the timing bar | `pwsh -File tools/run.ps1 -Target c64 -TimingBar` (assembles with `--asm-define TIMING_BAR` into `build/land-map-64-timing.prg`; cl65's `-D` only defines C symbols, so assembler symbols go in the build's `asmDefines`) |
| Long scrolling run | `pwsh -File tools/check-scroll.ps1 -Long` (adds the 5-minute tour; about 10 minutes; `-ParseOnly -NoBuild` re-checks the last run's logs) |
| Automated smoke test | `pwsh -File tools/smoke.ps1` (exit 0 pass, 1 fail, 2 missing tool, 3 manual only) |

## Target settings and verification status
@@ -59,7 +61,7 @@ Starter configurations marked verified were exercised by the Foundry's automated
- World check: `pwsh -File tools/check-world.ps1` validates the tile data saved by the smoke test.
- Split check: `pwsh -File tools/check-split.ps1` runs VICE headless for 20,000,000 cycles. It logs the raster line and cycle of the three mode writes at `split_store` (src/status.inc) every frame and requires them to start between line 210 cycle 53 and line 210 cycle 64. That window was measured by building with split delays 6-12 under `+autostart-delay-random`: starts at 210:40-51 damaged the last map line, starts at 211:0-11 damaged the first text line, and 210:50-211:1 were clean; the shipped delay starts at 210:55-61 at y-scroll 3. Tracepoints on the `key_row_*` instructions fake "no key" and then scroll down three cells and back up (phase byte at $CFF0, VICE conditional checkpoints), so every map y-scroll value 0-7 is split and checked against the same window (y-scroll 2, a bad line at line 210, uses a shorter delay; measured 2026-12-03: starts at 210:58-64). It also checks that a split happens every frame, that after each status update the people-in-view digits equal the number of people whose dot is at least partly in the visible window (computed by the script from the people table and view), and (coarsely) the screenshot colours at the boundary. Output: `build/check-split/`.
- Key check: `pwsh -File tools/check-keys.ps1` runs eight headless VICE scenarios. VICE's monitor cannot press keys, so tracepoints on the `key_row_*` instructions in `src/keys.inc` replace the port B row bits with those of held keys (`r a = <bits>`). It checks `scroll_dx`/`scroll_dy` for no key, right, left (right SHIFT), down, up (left SHIFT), down-right and up-left, and that SPACE held from frame 60 regenerates exactly once. Output: `build/check-keys/`.
- Scroll check: `pwsh -File tools/check-scroll.ps1` runs three headless VICE scenarios (edges, middle, reverse). Each is a list of phases: fake held keys (as in the key check) until a condition on the program state is met at `people_moved` (a `move_frame` value or a view position). The phase number is kept in free RAM at $CFF0 and moved on by VICE conditional checkpoints (`trace exec $addr if (@cpu:$addr == $nn) && (...)`: the parentheses are needed, and checkpoints at one address run in the order they were defined, so phase changes are defined latest first). Every frame it logs the phase, view, scroll registers, visible buffer, flip state and people table. It checks that the view moves at most one pixel per axis per frame and only in the direction of the keys read the frame before, stays inside 0-336 x 0-244 and stops at the edges, that $D011/$D016 match the fine scroll, that in every frame the shown buffer is complete and built for the view's cell (a half-rebuilt buffer on screen tears the top of the map), that nothing is stored into the shown buffer's map screen RAM or bitmap during raster 55-210, that no frame is missed and the people update ends before raster 55, and reports frames where a held key did not move the view (stalls, allowed up to 40). At the end it compares the buffer about to be shown, byte for byte, with a fresh render of the world at the view plus the people's dots (and, when a flip is pending, the shown buffer with the previous frame's dots). Any monitor script error fails the check. Output: `build/check-scroll/`.
- Scroll check: `pwsh -File tools/check-scroll.ps1` runs three headless VICE scenarios (edges, middle, reverse). Each is a list of phases: fake held keys (as in the key check) until a condition on the program state is met at `people_moved` (a `move_frame` value or a view position). The phase number is kept in free RAM at $CFF0 and moved on by VICE conditional checkpoints (`trace exec $addr if (@cpu:$addr == $nn) && (...)`: the parentheses are needed, and checkpoints at one address run in the order they were defined, so phase changes are defined latest first). Every frame it logs the phase, view, scroll registers, visible buffer, flip state and people table. It checks that the view moves at most one pixel per axis per frame and only in the direction of the keys read the frame before, stays inside 0-336 x 0-244 and stops at the edges, that $D011/$D016 match the fine scroll, that in every frame the shown buffer is complete and built for the view's cell (a half-rebuilt buffer on screen tears the top of the map), that nothing is stored into the shown buffer's map screen RAM or bitmap during raster 55-210, that no frame is missed and the people update ends before raster 55, and reports frames where a held key did not move the view (stalls, allowed up to 40). At the end it compares the buffer about to be shown, byte for byte, with a fresh render of the world at the view plus the people's dots (and, when a flip is pending, the shown buffer with the previous frame's dots). It also logs the CPU clock at `frame_start`, `people_moved`, `frame_done`, the KERNAL interrupt entry ($FF48) and exit ($EA81), `start_rebuild` and `rebuild_ready`, and prints a budget line per scenario: frame period, vertical blank work, main loop busy and idle cycles, interrupt cycles, and how many frames each hidden-buffer rebuild took. With `-Long` it adds a `tour` scenario (about 23,000 frames, six laps over the whole world by rows and by columns, 21 stops) that saves and checks both buffers byte for byte at the end of every stop. Any monitor script error fails the check. Output: `build/check-scroll/`.
- People check: `pwsh -File tools/check-people.ps1` runs VICE headless (NTSC, warp) for 40,000,000 cycles, logs the people table at the `people_moved` hook every frame through the monitor, and checks that all 16 people stay inside the world, never stand on a water or stone tile, move at most one pixel per step, all move, and start spread over the four screens. It also saves both bitmap buffers before people are drawn and at the last frame, and checks byte for byte that the hidden buffer is the clean map plus the current dots and the visible buffer is the clean map plus the previous frame's dots (no trails, no damaged terrain). It checks that the main loop never misses a frame (x64sc NTSC frame: 263 lines x 65 = 17,095 cycles) and that each people update ends before raster line 51, the first visible line. Output: `build/check-people/`.

### How the smoke test works


+ 12
- 1
docs/verification-status.md Ver arquivo

@@ -17,10 +17,21 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n
| M3.1 Keyboard matrix reading for the cursor keys with SHIFT, held-key repeat. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-keys.ps1`: 8 of 8 scenarios, SPACE held = 1 regeneration) | confirmed by user (2026-12-03) |
| M3.2 Split screen: raster interrupts switch to text below a 20-row map and back at the top of the frame; status text screen and ROM font copy in both banks; status lines with the people-in-view count. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1` incl. status text in both banks; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`; `pwsh -File tools/check-keys.ps1`; `pwsh -File tools/check-split.ps1`: 955 splits in 955 frames, writes start at 210:55-61, digits right in every frame) | confirmed by user (2026-12-03) |
| M3.3 Fine scroll via $D016/$D011 in the 38-column, 20-row map area; rebuild the hidden buffer from tiles over 8 frames and flip on wrap; stop at world edges; show the view position in the status area; draw people relative to the view (in the shown buffer during vertical blank while a rebuild runs). | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`: 2,127 frames, 0 missed, update done by line 36; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`: 964 splits in 964 frames, all y-scroll values 0-7, starts 210:55-64, digits right after 240 of 240 status updates; `pwsh -File tools/check-scroll.ps1`: 3 of 3 scenarios, edges reached and held, 1-5 stall frames per scenario, both buffers byte-exact at the end) | confirmed by user (2026-12-03), after the fix for the reported tear ("the top of the screen tears a little when I go left or right") |
| M3.4 Check that people stay aligned with the terrain over long scrolling runs; measure the frame budget with a border-colour timing bar. | not run | pending |
| M3.4 Check that people stay aligned with the terrain over long scrolling runs; measure the frame budget with a border-colour timing bar. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`; `pwsh -File tools/check-people.ps1`: 2,130 frames, update done by line 21; `pwsh -File tools/check-keys.ps1`: 8 of 8; `pwsh -File tools/check-split.ps1`: 962 splits, digits 241/241; `pwsh -File tools/check-scroll.ps1 -Long`: 4 of 4, tour 23,195 frames (about 6.4 minutes NTSC) with 21 stops byte-exact, people update done by line 45 at the latest; timing build `--asm-define TIMING_BAR` built and screenshot in VICE) | pending (MT3.2, MT3.3, MT3.4) |

## Notes

- 2026-12-03 (M3.4): Frame budget measured with tools/check-scroll.ps1 (CPU clock at frame_start, people_moved, frame_done, interrupt entry/exit, start_rebuild, rebuild_ready), all in VICE x64sc NTSC:
- Frame start to frame start: 16,758-17,109 cycles (17,095 per frame; wait_frame returns anywhere in lines 251-262). No frame was missed in any run.
- Raster interrupts (top of frame and status split, including the split's wait for line 210): 411-416 cycles per frame.
- Vertical blank work (scroll step, flip, people restore and draw): average 1,062-1,564, worst 3,701 cycles, done by raster line 45 at the latest (first map line 55). R3.3 holds.
- Problem found and fixed in this task: with people movement inside the vertical blank, the first tour run took up to 4,426 cycles and ended at raster lines 55 and 56 twice, with two stores into the shown bitmap at line 55, when nearly all 16 people were in view near the top of the map. People movement now runs in the main loop after the status update and is drawn at the next vertical blank (src/people.inc, src/main.s); nothing visible changes.
- Main loop while rebuilding: busy up to 17,055 cycles, idle at least 43, done by line 250: the rebuild uses the frame's spare time as designed.
- A4 (rebuild over 8 frames allows 1 pixel per frame): partly met. Of 1,911 rebuilds in the tour, 222 took 7 frames, 1,581 took 8, 98 took 9 and 10 took 10. A rebuild over 8 frames delays the next cell step by a frame (a stall): 257 stall frames in 15,216 moving frames (1.7%), plus a short wait when a scroll starts from rest. The short scenarios (edges, middle, reverse) needed 8 frames every time.
- Long runs (R5.3, R3.2): the tour (six laps over the whole world by rows and by columns, 21 stops) found both buffers equal to the world plus the right dots at every stop and at the end; the per-frame checks found no half-built buffer on screen and no stores into the shown map while displayed.
- Timing bar: `pwsh -File tools/run.ps1 -Target c64 -TimingBar` assembles with `--asm-define TIMING_BAR` into build/land-map-64-timing.prg (cl65 -D does not reach ca65; tools/lib.ps1 now passes `asmDefines`). Headless screenshot while scrolling: cyan border through the map and status area, red stripe at the split, brown at the bottom. The normal build has no timing-bar code.
- The knowledge system was not available (Docker/PostgreSQL not running).

- 2026-12-03 (M3.3 fix): The user reported a small tear at the top of the screen when scrolling left or right. Cause: when a scroll started from rest, choose_rebuild_target restarted the rebuild of the hidden buffer in the same frame that people had been drawn into it with a flip pending; the next vertical blank showed that half-rebuilt buffer (top rows already one cell on) for up to 8 frames, until the next cell crossing. It happened for every direction, not only left and right. Fix (src/scroll.inc): no rebuild restart while people_flip_pending is set; the other buffer is rebuilt from the next frame. tools/check-scroll.ps1 now checks in every frame that the shown buffer is complete and built for the view's cell: on the old code it failed in all three scenarios (frames 30-37, ready 0, origin one cell on); it also checks that nothing is stored into the shown buffer's map while the map is displayed (no such store was found, before or after the fix).

- 2026-12-03 (M3.3, resumed and finished): tools/check-scroll.ps1 now drives each scenario as phases (phase byte at $CFF0, VICE conditional checkpoints on people_moved; frame counts with "ignore" did not work). VICE 3.10 needs parentheses around each comparison joined with && (without them the condition never fired), and runs checkpoints at one address in definition order in the same hit, so phase changes are defined latest first. A rejected checkpoint shifts the numbers of the later ones, so both new checks fail on any monitor "ERROR". The check found a mistake in itself, not in the program: while the view is still, people are drawn into the hidden buffer and shown at the next flip, so the shown buffer holds the previous frame's dots; the final comparison now checks both buffers byte for byte (dots included).


+ 26
- 4
project.json Ver arquivo

@@ -489,7 +489,7 @@
"R6"
],
"outcome": "People stay aligned with terrain over long runs; budget measured",
"check": "Manual tests MT3.2 and MT3.3"
"check": "Manual tests MT3.2, MT3.3 and MT3.4"
}
],
"manualTests": [
@@ -517,12 +517,15 @@
"target": "c64",
"setup": "VICE x64sc, NTSC (-ntsc), warp off.",
"steps": [
"Scroll slowly past several people."
"Scroll slowly past several people.",
"From M3.4: scroll around the whole world for about 5 minutes, then stop with several people in view and watch them for a minute.",
"From M3.4: with many dots in view near the top of the map, scroll left and right."
],
"expected": [
"Dots stay on the terrain they walk on",
"Dots stay on the terrain they walk on, also after long runs",
"16 dots in total across the world",
"No trails left behind"
"No trails or damaged terrain left behind, even after 5 minutes",
"No flicker or tearing of the dots near the top of the map"
],
"requirements": [
"R2",
@@ -551,6 +554,25 @@
"R6",
"R1"
]
},
{
"id": "MT3.4",
"title": "Frame budget timing bar",
"target": "c64",
"setup": "VICE x64sc, NTSC (-ntsc), warp off. Start with pwsh -File tools/run.ps1 -Target c64 -TimingBar (separate timing build).",
"steps": [
"Leave the view still for a few seconds.",
"Hold a cursor key and watch the border while the map scrolls."
],
"expected": [
"Still: mostly brown border with a thin red stripe at the status split",
"Scrolling: cyan (rebuild) down to near the bottom, red stripe at the split, a little brown below",
"The border pattern is steady from frame to frame (no rolling): every frame is kept"
],
"requirements": [
"R3",
"R5"
]
}
]
}


+ 27
- 2
src/main.s Ver arquivo

@@ -17,6 +17,7 @@
; that text screen is hidden and holds the smoke test status mirror.

.export smoke_ready, visible, keys_read, space_ready
.export frame_start, frame_done

; ---------------------------------------------------------------- hardware
VIC_CTRL1 = $D011 ; bit 5 bitmap mode, bit 4 display on, bit 3 25 rows
@@ -47,6 +48,22 @@ COL_LIGHT_RED = 10

FLIP_RASTER = 251 ; below the visible area on NTSC and PAL

; Timing bar (assemble with --asm-define TIMING_BAR: tools/run.ps1 -TimingBar): the
; border colour shows what the CPU is doing. Off in the normal build: writing
; $D020 mid-frame would disturb the steady border and status area (R6.2).
BAR_VBLANK = 1 ; white: scroll step, flip, people restore and draw
BAR_KEYS = 7 ; yellow: keys, status text, people movement
BAR_REBUILD = 3 ; cyan: hidden-buffer rebuild
BAR_IRQ = 2 ; red: raster interrupt (status split)
BAR_IDLE = COL_BROWN ; brown: waiting for the next frame

.macro TIMING_BAR_COLOR colour
.ifdef TIMING_BAR
lda #colour
sta VIC_BORDER
.endif
.endmacro

; Zero page: $FB-$FE are free for user programs.
bmp = $FB ; pointer into the bitmap being drawn
scr = $FD ; pointer into the screen RAM being drawn
@@ -76,13 +93,17 @@ smoke_ready: ; first generated world is on screen

; 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 (scroll.inc, people.inc). After that, with time to
; spare: read the keys, show the status and rebuild part of the hidden buffer.
; 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.
main_loop:
jsr wait_frame
frame_start: ; check hook: vertical blank work starts
TIMING_BAR_COLOR BAR_VBLANK
jsr apply_view
jsr people_vblank
people_moved: ; check hook: people drawn for this frame
TIMING_BAR_COLOR BAR_KEYS
jsr read_keys ; carry set: SPACE just pressed
bcs new_world
keys_read: ; check hook: scroll_dx and scroll_dy are set
@@ -92,9 +113,13 @@ keys_read: ; check hook: scroll_dx and scroll_dy are set
jsr count_people_in_view
jsr update_status
@rebuild:
jsr move_people ; after the status count: it counts the drawn dots
TIMING_BAR_COLOR BAR_REBUILD
jsr choose_rebuild_target
jsr restore_hidden_people
jsr rebuild_slices
frame_done: ; check hook: this frame's work is done
TIMING_BAR_COLOR BAR_IDLE
jmp main_loop
new_world:
jsr rebuild_map


+ 4
- 2
src/people.inc Ver arquivo

@@ -67,6 +67,10 @@ place_people:
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_people:
inc move_frame
lda move_frame
@@ -206,7 +210,6 @@ people_vblank:
bne @shown
stx people_buf
jsr restore_people
jsr move_people
jsr draw_people
lda #1
sta people_flip_pending
@@ -214,7 +217,6 @@ people_vblank:
@shown: lda visible
sta people_buf
jsr restore_people
jsr move_people
jmp draw_people

; When people are drawn in the shown buffer, the hidden one may still carry


+ 1
- 0
src/scroll.inc Ver arquivo

@@ -463,6 +463,7 @@ rb_same_page:
lda rb_row
cmp buf_rows,x
bne rb_chunk_done
rebuild_ready: ; check hook: buffer rb_buf is complete
lda #1
sta buf_ready,x
rb_chunk_done:


+ 12
- 1
src/status.inc Ver arquivo

@@ -161,6 +161,12 @@ stop_raster_irq:
rts

raster_irq:
.ifdef TIMING_BAR
lda VIC_BORDER
pha
lda #BAR_IRQ
sta VIC_BORDER
.endif
lda #1
sta VIC_IRQ_FLAGS
lda irq_phase
@@ -181,7 +187,7 @@ raster_irq:
lda #SPLIT_IRQ_LINE
sta VIC_RASTER
inc irq_phase
jmp KERNAL_IRQ_EXIT
jmp irq_exit
@split: lda #SPLIT_LINE - 1
@wait: cmp VIC_RASTER ; start of the last map pixel line
bne @wait
@@ -202,6 +208,11 @@ split_done:
sta VIC_RASTER
lda #0
sta irq_phase
irq_exit:
.ifdef TIMING_BAR
pla
sta VIC_BORDER
.endif
jmp KERNAL_IRQ_EXIT

.segment "RODATA"


+ 157
- 27
tools/check-scroll.ps1 Ver arquivo

@@ -17,6 +17,11 @@
middle down, then right, then release in the middle of the world
reverse right, reverse to left in the frame after a cell step, right again;
then down, reverse to up right after a cell step; release
tour (-Long only) about 5 minutes: six laps over the whole world, alternately
row by row (right, down, left, ...; then diagonally up-left home) and
column by column (down, right, up, ...), with still stops between legs.
At the end of every stop both buffers are saved and checked like the
final frame (people aligned with the terrain, no trails: R5.3, R3.2).

Checks, per scenario:
- the view moves at most one pixel per axis per frame, only in the direction of the
@@ -34,14 +39,22 @@
- at the end, the buffer about to be shown (bitmap and screen RAM) equals a fresh
render of the world from the view's top-left cell (39 columns, 21 rows) with this
frame's dots ORed in; when a flip is pending, the shown buffer has last frame's dots
- frame budget (from the CPU clock at frame_start, people_moved, frame_done, the
raster interrupt's entry $FF48 and exit $EA81, start_rebuild and rebuild_ready):
reported per scenario: frame start to frame start (17,095 cycles give or take the
wait loop's exit point), the vertical blank work (scroll step, flip, people update),
the main loop's busy and idle cycles, the interrupt cycles, and how many frames each
hidden-buffer rebuild took (assumption A4: 8 frames allow 1 pixel per frame).

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

.EXAMPLE
pwsh -File tools/check-scroll.ps1
pwsh -File tools/check-scroll.ps1 -Long # also the 5-minute tour (several minutes)
pwsh -File tools/check-scroll.ps1 -Long -ParseOnly -NoBuild # re-check the last run's logs
#>
[CmdletBinding()]
param([switch]$NoBuild, [int]$TimeoutSeconds = 300, [int]$MaxStallFrames = 40)
param([switch]$NoBuild, [switch]$Long, [switch]$ParseOnly, [int]$TimeoutSeconds = 300, [int]$MaxStallFrames = 40)
. (Join-Path $PSScriptRoot 'lib.ps1')

function Get-Label([hashtable]$Target, [string]$Symbol) {
@@ -89,7 +102,10 @@ $tiles = Get-TileData
$L = @{}
foreach ($s in 'smoke_ready', 'people_moved', 'world_tiles', 'people_cx', 'visible', 'view_cx', 'map_d011', 'map_d016',
'move_frame', 'people_flip_pending', 'buf_cx', 'buf_cy', 'buf_ready', 'view_fx', 'view_cy', 'view_fy',
'frame_start', 'frame_done', 'start_rebuild', 'rebuild_ready',
'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { $L[$s] = Get-Label $target $s }
$IRQ_ENTRY = 0xFF48; $IRQ_EXIT = 0xEA81 # KERNAL IRQ entry and the exit our handler jumps to
$FRAME_CYCLES = 17095

# Key bits (active low): cursor column RIGHT = bit 2, DOWN = bit 7; left SHIFT = bit 7.
$RIGHT_DOWN = '7b'; $DOWN = '7f'; $RIGHTK = 'fb'; $NONE = 'ff'; $SHIFT = '7f'
@@ -124,13 +140,44 @@ $scenarios = @(
@{ cursor = $DOWN; lshift = $SHIFT; until = (View -1 0 2 1) }
@{ cursor = $NONE; lshift = $NONE }) }
)
if ($Long) {
$R = @{ cursor = $RIGHTK; lshift = $NONE }; $Lf = @{ cursor = $RIGHTK; lshift = $SHIFT }
$D = @{ cursor = $DOWN; lshift = $NONE }; $U = @{ cursor = $DOWN; lshift = $SHIFT }
$UL = @{ cursor = $RIGHT_DOWN; lshift = $SHIFT }
$tour = [System.Collections.Generic.List[hashtable]]::new()
$leg = { param($keys, $until) $tour.Add(@{ cursor = $keys.cursor; lshift = $keys.lshift; until = $until }) }
$stop = { $tour.Add(@{ cursor = $NONE; lshift = $NONE; until = (Frame ((61 * $tour.Count + 17) % 256)); snap = $true }) }
$tour.Add(@{ cursor = $NONE; lshift = $NONE; until = (Frame 30) })
for ($lap = 0; $lap -lt 6; $lap++) {
if ($lap % 2 -eq 0) { # rows: ends at the top-left
foreach ($row in 5, 10, 15, 20, 25) {
$right = (($row / 5) % 2) -eq 1
if ($right) { & $leg $R (View 42 0 -1 0) } else { & $leg $Lf (View 0 0 -1 0) }
& $leg $D (View -1 0 $row 0)
if ($row % 10 -eq 0) { & $stop }
}
& $leg $Lf (View 0 0 -1 0); & $leg $D (View -1 0 30 4); & $leg $R (View 42 0 -1 0); & $stop
& $leg $UL (View 0 0 0 0); & $stop
} else { # columns: ends at the top-left
foreach ($col in 8, 16, 24, 32, 42) {
$down = (($col -eq 8) -or ($col -eq 24) -or ($col -eq 42))
if ($down) { & $leg $D (View -1 0 30 4) } else { & $leg $U (View -1 0 0 0) }
& $leg $R (View $col 0 -1 0)
if ($col -eq 16 -or $col -eq 42) { & $stop }
}
& $leg $U (View -1 0 0 0); & $leg $Lf (View 0 0 -1 0); & $stop
}
}
$tour.Add(@{ cursor = $NONE; lshift = $NONE })
$scenarios += @{ name = 'tour'; cycles = 400000000; timeout = 3600; phases = $tour.ToArray(); maxStalls = 6 * $tour.Count }
}

$root = Get-RepoPath 'build/check-scroll'
if (Test-Path -LiteralPath $root) { Remove-Item -LiteralPath $root -Recurse -Force }
if ((Test-Path -LiteralPath $root) -and -not $ParseOnly) { Remove-Item -LiteralPath $root -Recurse -Force }
$failedScenarios = 0
foreach ($sc in $scenarios) {
$dir = Join-Path $root $sc.name
New-Item -ItemType Directory -Force -Path $dir | Out-Null
if (-not $ParseOnly) { New-Item -ItemType Directory -Force -Path $dir | Out-Null }
$mon = [System.Collections.Generic.List[string]]::new()
$mon.Add('logname "monitor.log"'); $mon.Add('log on')
$n = 0
@@ -149,6 +196,15 @@ foreach ($sc in $scenarios) {
if ($k.cursor -ne $NONE) { & $add $L.key_row_cursor "r a = $($k.cursor)" @(, @($PHASE, $ph)) }
if ($k.lshift -ne $NONE) { & $add $L.key_row_lshift "r a = $($k.lshift)" @(, @($PHASE, $ph)) }
}
# Snapshots at the end of each "snap" stop: before the phase changes, so they run in the same hit.
$saves = @('bitmap-a.bin 6000 7a3f', 'bitmap-b.bin a000 ba3f', 'screen-a.bin 4000 4347', 'screen-b.bin 8000 8347')
for ($ph = 0; $ph -lt $lastPhase; $ph++) {
if (-not $sc.phases[$ph].snap) { continue }
foreach ($save in $saves) {
$f = $save -split ' '
& $add $L.people_moved ('bsave \"snap{3}-{0}\" 0 {1} {2}' -f $f[0], $f[1], $f[2], $ph) (@(, @($PHASE, $ph)) + $sc.phases[$ph].until)
}
}
for ($ph = $lastPhase - 1; $ph -ge 0; $ph--) { # descending, so one hit moves on at most one phase
& $add $L.people_moved ('> {0:x4} {1:x2}' -f $PHASE, ($ph + 1)) (@(, @($PHASE, $ph)) + $sc.phases[$ph].until)
}
@@ -162,7 +218,7 @@ foreach ($sc in $scenarios) {
& $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.buf_ready, ($L.buf_ready + 1)) $null
& $add $L.people_moved ('m {0:x4} {0:x4}' -f $PHASE) $null
& $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.people_cx, ($L.people_cx + 79)) $null
foreach ($save in @('bitmap-a.bin 6000 7a3f', 'bitmap-b.bin a000 ba3f', 'screen-a.bin 4000 4347', 'screen-b.bin 8000 8347')) {
foreach ($save in $saves) {
$f = $save -split ' '
& $add $L.people_moved ('bsave \"{0}\" 0 {1} {2}' -f $f[0], $f[1], $f[2]) @(, @($PHASE, $lastPhase))
}
@@ -176,6 +232,13 @@ foreach ($sc in $scenarios) {
}
$lastStore = $n
for ($c = $firstStore; $c -le $lastStore; $c++) { & $add $L.smoke_ready "enable $c" $null }
# Timing events: a trace without a command prints the raster position and the CPU clock.
$events = @{}
foreach ($ev in @(@('start', $L.frame_start), @('done', $L.frame_done), @('irq', $IRQ_ENTRY), @('irqexit', $IRQ_EXIT),
@('rbstart', $L.start_rebuild), @('rbready', $L.rebuild_ready))) {
$n++; $mon.Add(('trace exec ${0:x4}' -f $ev[1])); $events[$n] = $ev[0]
}
if (-not $ParseOnly) {
Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $mon
Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value ''
$vargs = @('-config', 'vicerc', '-default', '-sounddev', 'dummy', '-warp', '-minimized') + (Get-VideoArgs $target)
@@ -183,16 +246,28 @@ foreach ($sc in $scenarios) {
$quoted = $vargs | ForEach-Object { if ($_ -match '[\s"]') { '"' + $_ + '"' } else { $_ } }
$p = Start-Process -FilePath $emu -ArgumentList $quoted -WorkingDirectory $dir -PassThru `
-RedirectStandardOutput (Join-Path $dir 'vice.log') -RedirectStandardError (Join-Path $dir 'vice.err')
if (-not $p.WaitForExit($TimeoutSeconds * 1000)) { $p.Kill($true) }
$limit = if ($sc.timeout) { [Math]::Max($sc.timeout, $TimeoutSeconds) } else { $TimeoutSeconds }
if (-not $p.WaitForExit($limit * 1000)) { $p.Kill($true) }
}

# Parse frames: view (4 bytes), d011/d016, visible, people table; clock and raster line.
$frames = [System.Collections.Generic.List[hashtable]]::new()
$cur = $null; $want = $false
foreach ($line in Get-Content -LiteralPath (Join-Path $dir 'monitor.log') -Encoding Latin1) {
if ($line -match "^#$viewCheckpoint \(Trace\s+exec [0-9a-fA-F]+\)\s+(\d+)/") {
$cur = @{ line = [int]$Matches[1]; people = [System.Collections.Generic.List[byte]]::new() }; $frames.Add($cur); $want = $true; continue
$timeline = [System.Collections.Generic.List[object]]::new() # (kind, clock, line)
$cur = $null; $want = $null; $wantLine = 0
foreach ($line in [IO.File]::ReadLines((Join-Path $dir 'monitor.log'), [Text.Encoding]::Latin1)) {
if ($line.StartsWith('#') -and $line -match '^#(\d+) \(Trace\s+exec [0-9a-fA-F]+\)\s+(\d+)/') {
$num = [int]$Matches[1]
if ($num -eq $viewCheckpoint) {
$cur = @{ line = [int]$Matches[2]; people = [System.Collections.Generic.List[byte]]::new() }; $frames.Add($cur); $want = 'view'; continue
}
if ($events.ContainsKey($num)) { $want = $events[$num]; $wantLine = [int]$Matches[2] }
continue
}
if ($want -and $line -match '^\.C:.*\s(\d+)\s*$') {
if ($want -eq 'view') { $cur.clock = [long]$Matches[1]; $timeline.Add(@('view', $cur.clock, $cur.line)) }
else { $timeline.Add(@($want, [long]$Matches[1], $wantLine)) }
$want = $null; continue
}
if ($want -and $line -match '^\.C:.*\s(\d+)\s*$') { $cur.clock = [long]$Matches[1]; $want = $false; continue }
if ($null -eq $cur -or $line -notmatch '^>C:([0-9a-fA-F]{4}) ((?:[0-9a-fA-F]{2} )+)') { continue }
$addr = [Convert]::ToInt32($Matches[1], 16)
$bytes = @($Matches[2].Trim() -split ' ' | ForEach-Object { [Convert]::ToByte($_, 16) })
@@ -206,6 +281,13 @@ foreach ($sc in $scenarios) {
elseif ($addr -eq $L.buf_ready) { $cur.ready = $bytes[0..1] }
elseif ($addr -ge $L.people_cx -and $addr -lt $L.people_cx + 80) { foreach ($b in $bytes) { if ($cur.people.Count -lt 80) { $cur.people.Add($b) } } }
}
# The run stops at a cycle limit, possibly while the last frame was being logged.
$fields = 'cx', 'd011', 'visible', 'pending', 'bufcx', 'bufcy', 'ready', 'phase', 'clock'
while ($frames.Count -gt 0) {
$lf = $frames[$frames.Count - 1]
if ($lf.people.Count -eq 80 -and -not @($fields | Where-Object { $null -eq $lf[$_] })) { break }
$frames.RemoveAt($frames.Count - 1)
}
$failures = [System.Collections.Generic.List[string]]::new()
# A rejected checkpoint shifts the numbers of the ones after it, so commands would land on the wrong ones.
$monErrors = @(Select-String -LiteralPath (Join-Path $dir 'monitor.log') -Pattern '^ERROR|not a valid checkpoint' | Select-Object -First 3)
@@ -263,7 +345,36 @@ foreach ($sc in $scenarios) {
if ($maxVx -ne 336 -or $maxVy -ne 244) { $failures.Add("did not reach the bottom-right edge (max vx $maxVx, vy $maxVy)") }
if ($minAfterMaxVx -ne 0 -or $minAfterMaxVy -ne 0) { $failures.Add("did not return to the top-left edge (min vx $minAfterMaxVx, vy $minAfterMaxVy)") }
}
if ($stalls -gt $MaxStallFrames) { $failures.Add("$stalls stall frames (allowed $MaxStallFrames)") }
$allowedStalls = if ($sc.maxStalls) { $sc.maxStalls } else { $MaxStallFrames }
if ($stalls -gt $allowedStalls) { $failures.Add("$stalls stall frames (allowed $allowedStalls)") }

# Frame budget from the timeline. Events before the first frame_start (start-up) are skipped.
$fr = $null; $budget = [System.Collections.Generic.List[hashtable]]::new(); $irqAt = $null
$rebuilds = [System.Collections.Generic.List[int]]::new(); $abandoned = 0; $rbOpen = $null
foreach ($e in $timeline) {
switch ($e[0]) {
'start' { if ($fr) { $fr.period = $e[1] - $fr.start }; $fr = @{ start = $e[1]; irq = 0 }; $budget.Add($fr) }
'view' { if ($fr) { $fr.vblank = $e[1] - $fr.start; $fr.viewLine = $e[2] } }
'done' { if ($fr) { $fr.busy = $e[1] - $fr.start; $fr.doneLine = $e[2] } }
'irq' { $irqAt = $e[1] }
'irqexit' { if ($fr -and $null -ne $irqAt) { $fr.irq += $e[1] - $irqAt + 7 + 22 }; $irqAt = $null } # + interrupt entry, + exit code
'rbstart' { if ($fr) { if ($null -ne $rbOpen) { $abandoned++ }; $rbOpen = $budget.Count } }
'rbready' { if ($fr -and $null -ne $rbOpen) { $rebuilds.Add($budget.Count - $rbOpen + 1); $rbOpen = $null } }
}
}
$full = @($budget | Where-Object { $null -ne $_.period -and $null -ne $_.busy -and $null -ne $_.vblank })
if ($full.Count -lt 100) { $failures.Add("only $($full.Count) frames with complete timing") }
$periods = $full | ForEach-Object { $_.period } | Measure-Object -Minimum -Maximum
$stat = { param($key) $v = @($full | ForEach-Object { $_[$key] }); @{ max = ($v | Measure-Object -Maximum).Maximum; avg = [int](($v | Measure-Object -Average).Average) } }
$sv = & $stat 'vblank'; $sb = & $stat 'busy'; $si = & $stat 'irq'
$idle = @($full | ForEach-Object { $_.period - $_.busy }); $minIdle = ($idle | Measure-Object -Minimum).Minimum
$maxDone = ($full | ForEach-Object { $_.doneLine } | Measure-Object -Maximum).Maximum
$rbMax = if ($rebuilds.Count) { ($rebuilds | Measure-Object -Maximum).Maximum } else { 0 }
$rbAvg = if ($rebuilds.Count) { [Math]::Round(($rebuilds | Measure-Object -Average).Average, 1) } else { 0 }
$rbHist = ($rebuilds | Group-Object | Sort-Object { [int]$_.Name } | ForEach-Object { "$($_.Name):$($_.Count)" }) -join ' '
$budgetText = ("budget: frame start to frame start {12}-{13} cycles; vblank work max {0} avg {1}; main loop busy max {2} avg {3}, idle min {4}, done by line {5}; " +
"IRQ max {6} avg {7}; {8} rebuilds, frames each (frames:count) {14}, {11} abandoned") -f $sv.max, $sv.avg, $sb.max, $sb.avg, $minIdle, $maxDone, $si.max, $si.avg,
$rebuilds.Count, $rbMax, $rbAvg, $abandoned, $periods.Minimum, $periods.Maximum, $rbHist

# Final frames: at people_moved, the buffer that will be shown (the hidden one when a flip is
# pending, otherwise the shown one) must equal a fresh render at the view origin plus this
@@ -271,23 +382,25 @@ foreach ($sc in $scenarios) {
$world = [IO.File]::ReadAllBytes((Join-Path $dir 'world.bin'))
$last = $frames[$frames.Count - 1]
$checkBuffer = {
param([int]$buf, $people, [string]$what)
param([string]$prefix, [int]$buf, $at, $people, [string]$what)
$suffix = @('a', 'b')[$buf]
$bitmap = [IO.File]::ReadAllBytes((Join-Path $dir "bitmap-$suffix.bin"))
$screen = [IO.File]::ReadAllBytes((Join-Path $dir "screen-$suffix.bin"))
$bitmap = [IO.File]::ReadAllBytes((Join-Path $dir "${prefix}bitmap-$suffix.bin"))
$screen = [IO.File]::ReadAllBytes((Join-Path $dir "${prefix}screen-$suffix.bin"))
$dots = @{}
for ($i = 0; $i -lt 16; $i++) {
$col = $people[$i] - $last.cx; $row = $people[32 + $i] - $last.cy
$col = $people[$i] - $at.cx; $row = $people[32 + $i] - $at.cy
if ($col -ge 0 -and $col -lt 39 -and $row -ge 0 -and $row -lt 21) {
$o = $row * 320 + $col * 8 + $people[48 + $i]
$dots[$o] = [int]$dots[$o] -bor (0xC0 -shr (2 * $people[16 + $i]))
}
}
$badBitmap = 0; $badScreen = 0
$rows = [Math]::Min(21, 50 - $last.cy)
# Only cells inside the world: at the bottom edge row 21, at the right edge (view cell 42) the
# 39th column lie outside it; neither is ever visible there (fine scroll is 0 at those edges).
$rows = [Math]::Min(21, 50 - $at.cy); $cols = [Math]::Min(39, 80 - $at.cx)
for ($r = 0; $r -lt $rows; $r++) {
for ($c = 0; $c -lt 39; $c++) {
$t = $world[($last.cy + $r) * 80 + $last.cx + $c]
for ($c = 0; $c -lt $cols; $c++) {
$t = $world[($at.cy + $r) * 80 + $at.cx + $c]
if ($screen[$r * 40 + $c] -ne $tiles.colors[$t]) { $badScreen++ }
for ($k = 0; $k -lt 8; $k++) {
$o = $r * 320 + $c * 8 + $k
@@ -295,18 +408,34 @@ foreach ($sc in $scenarios) {
}
}
}
if ($badBitmap -gt 0 -or $badScreen -gt 0) { $failures.Add("buffer $suffix ($what) differs from the world plus dots: $badBitmap bitmap bytes, $badScreen colour bytes") }
if ($badBitmap -gt 0 -or $badScreen -gt 0) { $failures.Add("${prefix}buffer $suffix ($what) at view cell ($($at.cx),$($at.cy)) differs from the world plus dots: $badBitmap bitmap bytes, $badScreen colour bytes") }
}
if ($last.pending) {
& $checkBuffer (1 - $last.visible) $last.people 'shown next frame'
$prev = $frames[$frames.Count - 2]
if ($prev.cx -eq $last.cx -and $prev.cy -eq $last.cy) { & $checkBuffer $last.visible $prev.people 'shown, previous dots' }
} else {
& $checkBuffer $last.visible $last.people 'shown'
$checkFrame = {
param([string]$prefix, [int]$i)
$at = $frames[$i]; $prev = $frames[$i - 1]
if ($at.pending) {
& $checkBuffer $prefix (1 - $at.visible) $at $at.people 'shown next frame'
if ($prev.cx -eq $at.cx -and $prev.cy -eq $at.cy) { & $checkBuffer $prefix $at.visible $at $prev.people 'shown, previous dots' }
} else {
& $checkBuffer $prefix $at.visible $at $at.people 'shown'
}
}
& $checkFrame '' ($frames.Count - 1)
# Snapshots: saved in the hit that ended stop k, which is logged as the first frame of phase k+1.
$snaps = 0
for ($ph = 0; $ph -lt $lastPhase; $ph++) {
if (-not $sc.phases[$ph].snap) { continue }
$i = -1
for ($j = 1; $j -lt $frames.Count; $j++) { if ($frames[$j].phase -eq $ph + 1 -and $frames[$j - 1].phase -eq $ph) { $i = $j; break } }
if ($i -lt 0 -or -not (Test-Path -LiteralPath (Join-Path $dir "snap$ph-bitmap-a.bin"))) { $failures.Add("stop $ph was not reached or not saved"); continue }
& $checkFrame "snap$ph-" $i
$snaps++
}

$summary = "{0}: {1} frames (per phase {9}), {2} moving, {3} stall frames, update done by line {4}, final view ({5},{6}) cell ({7},{8})" -f `
$sc.name, $frames.Count, $steps, $stalls, $lastLine, $last.vx, $last.vy, $last.cx, $last.cy, ($phaseFrames -join '/')
$perPhase = if ($phaseFrames.Count -le 12) { $phaseFrames -join '/' } else { "$($phaseFrames.Count) phases" }
$snapText = if ($snaps) { ", $snaps stops checked byte for byte" } else { '' }
$summary = "{0}: {1} frames ({9}), {2} moving, {3} stall frames, update done by line {4}, final view ({5},{6}) cell ({7},{8}){10}" -f `
$sc.name, $frames.Count, $steps, $stalls, $lastLine, $last.vx, $last.vy, $last.cx, $last.cy, $perPhase, $snapText
if ($failures.Count -gt 0) {
$failedScenarios++
Write-Host " FAIL $summary" -ForegroundColor Red
@@ -314,6 +443,7 @@ foreach ($sc in $scenarios) {
} else {
Write-Host " ok $summary"
}
Write-Host " $budgetText"
}
if ($failedScenarios -gt 0) { Write-Host "[FAIL] $failedScenarios of $($scenarios.Count) scroll scenarios" -ForegroundColor Red; exit 1 }
Write-Host "[PASS] all $($scenarios.Count) scroll scenarios: smooth one-pixel steps, edges respected, shown buffer matches the world" -ForegroundColor Green


+ 1
- 0
tools/lib.ps1 Ver arquivo

@@ -183,6 +183,7 @@ function Invoke-TargetBuild([hashtable]$Project, [hashtable]$Target, [hashtable]
$toolArgs = @('-t', $build.cc65Target, '-g')
if ($build.config) { $toolArgs += @('-C', $build.config, '-u', '__EXEHDR__') } else { $toolArgs += '-O' }
foreach ($d in @($build.defines)) { if ($d) { $toolArgs += @('-D', $d) } }
foreach ($d in @($build.asmDefines)) { if ($d) { $toolArgs += @('--asm-define', $d) } } # ca65 symbols (cl65 -D is for C only)
foreach ($dir in @($build.sourceDirs)) { $toolArgs += @('-I', (Get-RepoPath $dir)) }
$toolArgs += @('-o', $artifact, '-Ln', (Get-RepoPath $build.labels), '-m', (Get-RepoPath $build.map))
$toolArgs += $sources


+ 13
- 1
tools/run.ps1 Ver arquivo

@@ -10,18 +10,30 @@
.EXAMPLE
pwsh -File tools/run.ps1
pwsh -File tools/run.ps1 -Target c128-80
pwsh -File tools/run.ps1 -Target c64 -TimingBar
.PARAMETER TimingBar
Build with the assembler symbol TIMING_BAR into a separate program (<name>-timing.prg) whose border colour
shows the CPU's work in each frame (see src/main.s). The normal build is not touched.
#>
[CmdletBinding()]
param(
[string]$Target,
[switch]$NoBuild,
[ValidateSet('pal', 'ntsc')][string]$Video
[ValidateSet('pal', 'ntsc')][string]$Video,
[switch]$TimingBar
)
. (Join-Path $PSScriptRoot 'lib.ps1')

try {
$project = Get-ProjectConfig
$t = if ($Target) { Get-ProjectTargets $project $Target } else { @($project.resolved.targets)[0] }
if ($TimingBar) {
if ($t.build.kind -ne 'cc65') { throw "-TimingBar needs a cc65 target." }
$t.build.asmDefines = @(@($t.build.asmDefines) + 'TIMING_BAR' | Where-Object { $_ })
foreach ($k in 'labels', 'map') { $t.build[$k] = $t.build[$k] -replace '(\.\w+)$', '-timing$1' }
$t.artifact = $t.artifact -replace '(\.\w+)$', '-timing$1'
$t.disk = $null
}
if (-not $NoBuild) { Invoke-TargetBuild $project $t @{} }
if ($t.build.kind -eq 'none' -and -not $t.disk) { throw "Target $($t.id) is built on the Commodore; follow docs/toolchain.md to load it." }
$emu = Get-ToolPath $project $t.emulator.binary


Carregando…
Cancelar
Salvar

Powered by TurnKey Linux.