Builds; check-people passes. check-scroll unfinished. See the M3.3 pause note in docs/verification-status.md for the next steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>main
| @@ -16,11 +16,18 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n | |||
| | M2.2 Per-buffer saved-byte lists: restore the bytes under people from two frames ago, draw people in view, flip in vertical blank. | 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,117 frames, 0 missed flips, update done by raster line 26 at the latest, both final bitmaps byte-exact against clean map plus dots) | confirmed by user (2026-12-03) | | |||
| | 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). | not run | pending | | |||
| | 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). | in progress (paused 2026-12-03); not verified | 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. | not run | pending | | |||
| ## Notes | |||
| - 2026-12-03 PAUSED IN M3.3 (work in progress, committed as "M3.3 WIP"). State when paused: | |||
| - Code written and building: src/scroll.inc (view position, fine scroll, cell steps with flip, diagonal phase lock, edge stops, chunked hidden-buffer rebuild), people drawn relative to each buffer's origin (src/people.inc), status view position and people-in-view count, split choosing text screen 1 or 2 and the delay by y-scroll (src/status.inc), temporary M3.1 border indicator removed. | |||
| - Rebuild speed: after optimisation, straight scrolling stalls only at start-up (about 18 frames per scenario); diagonal down-right was smooth in the one run seen. Assumption A4 looks met but is not yet confirmed. | |||
| - tools/check-people.ps1 passes (now forces "no key" on the key rows: keys typed on the PC while a headless VICE has focus reached the program and scrolled the view). | |||
| - tools/check-scroll.ps1 (new) is not finished: its key schedule used VICE "ignore" counts, which do not count one per frame. Next step: drive scenarios with a phase byte at $CFF0 and conditional checkpoints (VICE 3.10 accepts "if @cpu:$addr == $nn"), one checkpoint per key row per phase. | |||
| - Still to do for M3.3: finish check-scroll; add the "no key" guard and a scrolling scenario to tools/check-split.ps1 so every y-scroll value is checked (split delay for y-scroll 2 is 1, not yet measured); run check-keys, smoke and all checks; update docs/manual-tests.md (MT3.1 still describes the removed border colours; MT3.3 step 4) and docs/toolchain.md; then ask for manual tests MT3.1-MT3.3. | |||
| - 2026-12-03: Spec change approved by the user: R3 reworded for scrolling (people drawn in the shown buffer during vertical blank while a scroll rebuild runs), and drawing people relative to the view moved from M3.4 to M3.3. Acceptance criteria unchanged. | |||
| - 2026-12-03 (M3.2): A7 partly checked in VICE: with the map at y-scroll 3, the split's mode writes land in the measured border window every frame (tools/check-split.ps1). Under vertical fine scroll it is not checked yet (M3.3). Fixed while doing M3.2: the temporary M3.1 border indicator wrote $D020 every frame, which showed a single light grey pixel in the bottom border (consistent with the VIC-II grey-dot effect of a colour-register write mid-line); it now writes only when the colour changes, and the pixel is gone from the smoke and split-check screenshots. tools/check-people.ps1 now compares only the 20 map rows of each bitmap. | |||
| @@ -101,34 +101,6 @@ key_row_space: | |||
| clc | |||
| rts | |||
| ; Temporary M3.1 indicator, replaced by real scrolling in M3.2: the border | |||
| ; colour shows the direction that is held. | |||
| show_scroll_direction: | |||
| lda scroll_dx ; index = (dx + 1) * 3 + (dy + 1) | |||
| clc | |||
| adc #1 | |||
| sta direction_index | |||
| asl a | |||
| clc | |||
| adc direction_index | |||
| clc | |||
| adc scroll_dy | |||
| clc | |||
| adc #1 | |||
| tax | |||
| lda direction_colors,x | |||
| cmp border_shown ; write only on a change: each write to a | |||
| beq @same ; colour register can show a grey dot | |||
| sta border_shown | |||
| sta VIC_BORDER | |||
| @same: rts | |||
| .segment "RODATA" | |||
| direction_colors: | |||
| .byte 14, 3, 12 ; dx -1: up-left light blue, left cyan, (down-left) | |||
| .byte 1, COL_BROWN, 7 ; dx 0: up white, none brown, down yellow | |||
| .byte 12, 13, 8 ; dx +1: (up-right), right light green, down-right orange | |||
| .segment "BSS" | |||
| scroll_dx: .res 1 ; keep scroll_dx and scroll_dy together | |||
| scroll_dy: .res 1 | |||
| @@ -137,5 +109,3 @@ keys_lshift: .res 1 | |||
| keys_rshift: .res 1 | |||
| keys_space: .res 1 | |||
| space_down: .res 1 | |||
| direction_index: .res 1 | |||
| border_shown: .res 1 ; last colour written by show_scroll_direction | |||
| @@ -35,8 +35,8 @@ SCREEN_A = $4000 | |||
| BITMAP_A = $6000 | |||
| SCREEN_B = $8000 | |||
| BITMAP_B = $A000 | |||
| VIEW_WIDTH = 40 | |||
| VIEW_HEIGHT = 20 ; map rows; the status area (status.inc) is below | |||
| MAP_COLS_DRAWN = 39 ; column 39 is never visible in 38-column mode | |||
| BUF_ROWS = 21 ; 20 map rows plus the partly visible row below | |||
| BANK_TEXT_BITS = %00000011 ; VIC bank 0 ($0000-$3FFF) | |||
| BANK_A_BITS = %00000010 ; VIC bank 1 ($4000-$7FFF) | |||
| @@ -74,27 +74,27 @@ start: | |||
| smoke_ready: ; first generated world is on screen | |||
| nop | |||
| ; Each frame: in the hidden buffer, restore the bytes under the people drawn | |||
| ; there two frames ago, move the people, draw them, then flip that buffer into | |||
| ; view during vertical blank. | |||
| ; 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. | |||
| main_loop: | |||
| lda visible | |||
| eor #1 | |||
| sta hidden | |||
| jsr restore_people | |||
| jsr move_people | |||
| jsr draw_people | |||
| jsr update_people_count | |||
| people_moved: ; check hook: hidden buffer holds the new step | |||
| jsr wait_frame | |||
| ldx hidden | |||
| lda buffer_bank_bits,x | |||
| jsr set_bank | |||
| stx visible | |||
| jsr apply_view | |||
| jsr people_vblank | |||
| people_moved: ; check hook: people drawn for this frame | |||
| jsr read_keys ; carry set: SPACE just pressed | |||
| bcs new_world | |||
| jsr show_scroll_direction | |||
| keys_read: ; check hook: scroll_dx and scroll_dy are set | |||
| lda move_frame ; status every 4th frame (15 times a second) | |||
| and #3 | |||
| bne @rebuild | |||
| jsr count_people_in_view | |||
| jsr update_status | |||
| @rebuild: | |||
| jsr choose_rebuild_target | |||
| jsr restore_hidden_people | |||
| jsr rebuild_slices | |||
| jmp main_loop | |||
| new_world: | |||
| jsr rebuild_map | |||
| @@ -108,7 +108,6 @@ rebuild_map: | |||
| lda #COL_BROWN | |||
| sta VIC_BORDER | |||
| sta VIC_BG0 | |||
| sta border_shown | |||
| jsr wait_frame ; below the map: stop the split before | |||
| jsr stop_raster_irq ; showing the message | |||
| lda #BANK_TEXT_BITS | |||
| @@ -122,22 +121,23 @@ rebuild_map: | |||
| jsr generate_world_from_timer | |||
| jsr place_people | |||
| lda #>SCREEN_A | |||
| jsr draw_world_view | |||
| lda #>SCREEN_B | |||
| jsr draw_world_view | |||
| jsr write_status_text | |||
| lda #0 | |||
| sta visible ; buffer A is shown first | |||
| lda #1 | |||
| sta hidden | |||
| jsr reset_view ; view at 0,0; both buffers drawn | |||
| jsr write_status_text | |||
| jsr count_people_in_view | |||
| jsr update_status | |||
| jsr wait_frame ; switch banks and modes below the visible area | |||
| lda #BANK_A_BITS | |||
| jsr set_bank | |||
| lda #MAP_D018 | |||
| sta VIC_MEMPTR | |||
| lda #MAP_D016 | |||
| lda map_d016 | |||
| sta VIC_CTRL2 | |||
| lda #MAP_D011 | |||
| lda map_d011 | |||
| sta VIC_CTRL1 | |||
| jsr start_raster_irq ; status area from this frame on | |||
| ldx #STATUS_LENGTH-1 | |||
| @@ -173,67 +173,6 @@ set_bank: | |||
| sta CIA2_PRA | |||
| rts | |||
| ; Render the first 40 columns of each of the first 25 world rows into one | |||
| ; buffer. A = high byte of its screen RAM; its bitmap is $2000 above that. | |||
| draw_world_view: | |||
| sta scr+1 | |||
| clc | |||
| adc #>(BITMAP_A - SCREEN_A) | |||
| sta bmp+1 | |||
| lda #0 | |||
| sta bmp | |||
| sta scr | |||
| lda #0 | |||
| sta view_row | |||
| @row: ldx view_row | |||
| ; Set the source operand once per row. Both zero-page pointers | |||
| ; remain dedicated to the two output streams. | |||
| lda world_row_low,x | |||
| sta @source+1 | |||
| lda world_row_high,x | |||
| sta @source+2 | |||
| lda #0 | |||
| sta view_column | |||
| @cell: ldy view_column | |||
| @source: | |||
| lda world_tiles,y | |||
| tax | |||
| ldy #0 | |||
| lda tile_colors,x | |||
| sta (scr),y | |||
| txa | |||
| asl a | |||
| asl a | |||
| asl a | |||
| tax | |||
| @line: lda tile_patterns,x | |||
| sta (bmp),y | |||
| inx | |||
| iny | |||
| cpy #8 | |||
| bne @line | |||
| lda bmp ; next cell: bitmap pointer + 8 | |||
| clc | |||
| adc #8 | |||
| sta bmp | |||
| bcc @advance_screen | |||
| inc bmp+1 | |||
| @advance_screen: | |||
| inc scr | |||
| bne @advance_column | |||
| inc scr+1 | |||
| @advance_column: | |||
| inc view_column | |||
| lda view_column | |||
| cmp #VIEW_WIDTH | |||
| bne @cell | |||
| inc view_row | |||
| lda view_row | |||
| cmp #VIEW_HEIGHT | |||
| bne @row | |||
| rts | |||
| ; Colour RAM is shared by both buffers: light red everywhere (pixel %11 = people). | |||
| fill_color_ram: | |||
| lda #COL_LIGHT_RED | |||
| @@ -281,11 +220,10 @@ ready_text: .byte "MAP READY " | |||
| .segment "BSS" | |||
| bank_bits: .res 1 | |||
| visible: .res 1 ; buffer on screen: 0 = A, 1 = B | |||
| hidden: .res 1 ; buffer being drawn: visible EOR 1 | |||
| view_row: .res 1 | |||
| view_column: .res 1 | |||
| hidden: .res 1 ; the other buffer: visible EOR 1 | |||
| .include "world.inc" | |||
| .include "people.inc" | |||
| .include "keys.inc" | |||
| .include "status.inc" | |||
| .include "scroll.inc" | |||
| @@ -11,7 +11,7 @@ TURN_TRIES = 5 ; current direction, then all four from a random | |||
| .assert STONE + 1 = WATER, error, "Blocking tiles must be contiguous" | |||
| .assert WATER_SE + 1 = ROAD_H, error, "Blocking tiles must be contiguous" | |||
| .export people_cx, people_moved | |||
| .export people_cx, people_moved, people_in_view | |||
| .segment "CODE" | |||
| ; Put each person on a random walkable cell; person N goes in sector N mod 4, | |||
| @@ -187,11 +187,51 @@ candidate_blocked: | |||
| @open: clc | |||
| rts | |||
| ; Put back the bitmap bytes saved when people were last drawn into the hidden | |||
| ; buffer (two frames ago), newest first, so people that share a byte restore | |||
| ; correctly. Only those bytes change: the rest of the map is never redrawn. | |||
| restore_people: | |||
| ; 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 | |||
| ldx hidden | |||
| lda buf_ready,x | |||
| beq @shown | |||
| lda buf_cx,x | |||
| cmp view_cx | |||
| bne @shown | |||
| lda buf_cy,x | |||
| cmp view_cy | |||
| bne @shown | |||
| stx people_buf | |||
| jsr restore_people | |||
| jsr move_people | |||
| jsr draw_people | |||
| lda #1 | |||
| sta people_flip_pending | |||
| rts | |||
| @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 | |||
| ; 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 | |||
| ; 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. | |||
| restore_people: | |||
| ldx people_buf | |||
| lda list_starts,x | |||
| sta list_start | |||
| clc | |||
| @@ -209,33 +249,44 @@ restore_people: | |||
| sta (bmp),y | |||
| cpx list_start | |||
| bne @loop | |||
| @done: ldx hidden | |||
| @done: ldx people_buf | |||
| lda #0 | |||
| sta drawn_count,x | |||
| rts | |||
| ; Draw every person inside the view (the top-left screen) into the hidden | |||
| ; buffer, saving the byte under each one in that buffer's list. | |||
| ; Draw every person inside buffer people_buf (relative to its top-left world | |||
| ; cell), saving the byte under each one in that buffer's list. | |||
| ; Call restore_people first. | |||
| draw_people: | |||
| ldx hidden | |||
| ldx people_buf | |||
| lda list_starts,x | |||
| sta list_start | |||
| sta list_pos | |||
| lda buffer_bitmap_offsets,x | |||
| sta bitmap_offset | |||
| lda buf_cx,x | |||
| sta draw_cx | |||
| lda buf_cy,x | |||
| sta draw_cy | |||
| lda buf_rows,x | |||
| sta draw_rows | |||
| ldx #0 | |||
| @person: | |||
| lda people_cy,x | |||
| cmp #VIEW_HEIGHT | |||
| sec | |||
| sbc draw_cy | |||
| cmp draw_rows ; also rejects people above the buffer | |||
| bcs @next | |||
| tay | |||
| tay ; Y = buffer row | |||
| lda people_cx,x | |||
| cmp #VIEW_WIDTH | |||
| sec | |||
| sbc draw_cx | |||
| cmp #MAP_COLS_DRAWN | |||
| bcs @next | |||
| lda #0 ; bmp = row base + cx * 8 + sy | |||
| sta draw_col | |||
| lda #0 ; bmp = row base + col * 8 + sy | |||
| sta bmp+1 | |||
| lda people_cx,x | |||
| lda draw_col | |||
| asl a | |||
| rol bmp+1 | |||
| asl a | |||
| @@ -271,20 +322,67 @@ draw_people: | |||
| lda list_pos | |||
| sec | |||
| sbc list_start | |||
| ldx hidden | |||
| ldx people_buf | |||
| sta drawn_count,x | |||
| rts | |||
| ; people_in_view = people whose pixel is inside the visible map window | |||
| ; (hires x vx-1..vx+303 for the 2-pixel-wide dot, lines vy..vy+155). | |||
| count_people_in_view: | |||
| lda #0 | |||
| sta people_in_view | |||
| ldx #PEOPLE_COUNT-1 | |||
| @person: | |||
| lda people_cy,x ; rows: 8 * (cy - view_cy) + sy - fy in 0..155 | |||
| sec | |||
| sbc view_cy | |||
| cmp #BUF_ROWS | |||
| bcs @next | |||
| asl a | |||
| asl a | |||
| asl a | |||
| ora people_sy,x | |||
| sec | |||
| sbc view_fy | |||
| bcc @next | |||
| cmp #156 | |||
| bcs @next | |||
| lda people_cx,x ; columns 1-37 are fully visible | |||
| sec | |||
| sbc view_cx | |||
| cmp #MAP_COLS_DRAWN | |||
| bcs @next | |||
| cmp #0 | |||
| beq @left | |||
| cmp #MAP_COLS_DRAWN - 1 | |||
| bne @count | |||
| lda people_sx,x ; column 38: visible if 2 * sx + 1 <= fx | |||
| asl a | |||
| ora #1 | |||
| cmp view_fx | |||
| beq @count | |||
| bcs @next | |||
| bcc @count | |||
| @left: lda people_sx,x ; column 0: visible if 2 * sx + 1 >= fx | |||
| asl a | |||
| ora #1 | |||
| cmp view_fx | |||
| bcc @next | |||
| @count: inc people_in_view | |||
| @next: dex | |||
| bpl @person | |||
| rts | |||
| .segment "RODATA" | |||
| pixel_masks: .byte $C0, $30, $0C, $03 | |||
| list_starts: .byte 0, PEOPLE_COUNT | |||
| buffer_bitmap_offsets: .byte 0, >(BITMAP_B - BITMAP_A) | |||
| bitmap_row_low: | |||
| .repeat VIEW_HEIGHT, row | |||
| .repeat BUF_ROWS, row | |||
| .byte <(BITMAP_A + 320 * row) | |||
| .endrepeat | |||
| bitmap_row_high: | |||
| .repeat VIEW_HEIGHT, row | |||
| .repeat BUF_ROWS, row | |||
| .byte >(BITMAP_A + 320 * row) | |||
| .endrepeat | |||
| @@ -310,4 +408,10 @@ drawn_byte: .res 2 * PEOPLE_COUNT | |||
| list_start: .res 1 | |||
| list_pos: .res 1 | |||
| bitmap_offset: .res 1 | |||
| people_buf: .res 1 ; buffer that restore/draw_people work on | |||
| draw_cx: .res 1 | |||
| draw_cy: .res 1 | |||
| draw_rows: .res 1 | |||
| draw_col: .res 1 | |||
| people_in_view: .res 1 | |||
| .assert * <= SCREEN_A, lderror, "People data must fit below VIC bank 1" | |||
| @@ -0,0 +1,520 @@ | |||
| ; Pixel-smooth scrolling of the 20-row map area. | |||
| ; | |||
| ; The view is a hires pixel position in the world: vx = 8 * view_cx + view_fx | |||
| ; (0-336) and vy = 8 * view_cy + view_fy (0-244). The visible buffer always holds | |||
| ; the world from cell (view_cx, view_cy); the fine scroll registers show it | |||
| ; shifted: XSCROLL = 7 - view_fx, YSCROLL = 7 - view_fy (38 columns, 24-row mode | |||
| ; for the map area; the status split restores 40 columns and 25 rows below it). | |||
| ; | |||
| ; Each buffer remembers the world cell at its top-left (buf_cx, buf_cy) and | |||
| ; whether it is complete (buf_ready). Moving across a cell edge flips to the | |||
| ; hidden buffer, which must already be complete for the new origin; it is | |||
| ; rebuilt from the tile world in small chunks during the frames before | |||
| ; (rebuild_slices). If it is not ready yet, that axis waits a frame. | |||
| ; Scrolling diagonally, the axis that would cross its cell edge first waits | |||
| ; until both cross together, so one rebuild serves both. | |||
| MAX_VIEW_CX = 42 ; vx 336 = 80 * 8 - 304 visible hires pixels | |||
| MAX_VIEW_CY = 30 | |||
| MAX_VIEW_FY = 4 ; vy 244 = 50 * 8 - 156 visible lines | |||
| CHUNK8_CUTOFF = 228 ; start an 8-cell chunk only before this line | |||
| CHUNK4_CUTOFF = 238 ; and a 4-cell chunk only before this one | |||
| ; Zero page for the rebuild's inner loop ($40-$4F: BASIC's area, unused here). | |||
| rb_col = $40 | |||
| rb_count = $41 | |||
| rb_boff = $42 | |||
| rb_page = $43 | |||
| .assert MAX_VIEW_CX * 8 = WORLD_WIDTH * 8 - 304, error, "View width" | |||
| .assert MAX_VIEW_CY * 8 + MAX_VIEW_FY = WORLD_HEIGHT * 8 - 156, error, "View height" | |||
| .export view_cx, rebuild_slices, apply_view | |||
| .segment "CODE" | |||
| ; View at the top-left of the world; build both buffers there completely. | |||
| reset_view: | |||
| lda #0 | |||
| sta view_cx | |||
| sta view_fx | |||
| sta view_cy | |||
| sta view_fy | |||
| sta people_flip_pending | |||
| sta rb_tx | |||
| sta rb_ty | |||
| ldx #0 | |||
| jsr build_buffer_now | |||
| ldx #1 | |||
| jsr build_buffer_now | |||
| jmp set_scroll_regs | |||
| ; X = buffer. Rebuild it for (rb_tx, rb_ty) without a time limit. | |||
| build_buffer_now: | |||
| jsr start_rebuild | |||
| @chunk: ldy #MAP_COLS_DRAWN | |||
| jsr rebuild_chunk | |||
| ldx rb_buf | |||
| lda buf_ready,x | |||
| beq @chunk | |||
| rts | |||
| ; X = buffer. Begin rebuilding it for origin (rb_tx, rb_ty). Its saved | |||
| ; people bytes are dropped: every row is redrawn from the tiles. | |||
| start_rebuild: | |||
| stx rb_buf | |||
| lda rb_tx | |||
| sta buf_cx,x | |||
| lda rb_ty | |||
| sta buf_cy,x | |||
| lda #0 | |||
| sta buf_ready,x | |||
| sta drawn_count,x | |||
| sta rb_row | |||
| sta rb_col | |||
| lda #WORLD_HEIGHT | |||
| sec | |||
| sbc rb_ty | |||
| cmp #BUF_ROWS | |||
| bcc @rows | |||
| lda #BUF_ROWS | |||
| @rows: sta buf_rows,x | |||
| rts | |||
| ; Vertical blank: take this frame's step from the keys read last frame. | |||
| ; Crossing a cell edge flips to the hidden buffer if it is ready for the new | |||
| ; origin; otherwise that axis waits. Sets view_moved when the view changed. | |||
| apply_view: | |||
| lda people_flip_pending ; still view: show the people drawn last frame | |||
| beq @steps | |||
| lda #0 | |||
| sta people_flip_pending | |||
| jsr flip_buffers | |||
| @steps: jsr get_steps ; step_x, step_y after edges and phase lock | |||
| lda view_cx | |||
| sta new_cx | |||
| lda view_fx | |||
| sta new_fx | |||
| lda view_cy | |||
| sta new_cy | |||
| lda view_fy | |||
| sta new_fy | |||
| lda #0 | |||
| sta wrap | |||
| lda step_x | |||
| beq @y | |||
| bmi @left | |||
| inc new_fx | |||
| lda new_fx | |||
| cmp #8 | |||
| bne @y | |||
| lda #0 | |||
| sta new_fx | |||
| inc new_cx | |||
| lda #1 | |||
| sta wrap | |||
| bne @y | |||
| @left: dec new_fx | |||
| bpl @y | |||
| lda #7 | |||
| sta new_fx | |||
| dec new_cx | |||
| lda #1 | |||
| sta wrap | |||
| @y: lda step_y | |||
| beq @check | |||
| bmi @up | |||
| inc new_fy | |||
| lda new_fy | |||
| cmp #8 | |||
| bne @check | |||
| lda #0 | |||
| sta new_fy | |||
| inc new_cy | |||
| lda wrap | |||
| ora #2 | |||
| sta wrap | |||
| bne @check | |||
| @up: dec new_fy | |||
| bpl @check | |||
| lda #7 | |||
| sta new_fy | |||
| dec new_cy | |||
| lda wrap | |||
| ora #2 | |||
| sta wrap | |||
| @check: lda wrap | |||
| beq @commit | |||
| ldx hidden ; the hidden buffer must be ready for the new origin | |||
| lda buf_ready,x | |||
| beq @hold | |||
| lda new_cx | |||
| cmp buf_cx,x | |||
| bne @hold | |||
| lda new_cy | |||
| cmp buf_cy,x | |||
| bne @hold | |||
| jsr flip_buffers | |||
| jmp @commit | |||
| @hold: lda wrap ; not ready: the crossing axis waits | |||
| lsr a | |||
| bcc @hold_y | |||
| lda view_cx | |||
| sta new_cx | |||
| lda view_fx | |||
| sta new_fx | |||
| @hold_y: | |||
| lda wrap | |||
| and #2 | |||
| beq @commit | |||
| lda view_cy | |||
| sta new_cy | |||
| lda view_fy | |||
| sta new_fy | |||
| @commit: | |||
| lda #0 | |||
| sta view_moved | |||
| lda new_cx | |||
| cmp view_cx | |||
| bne @moved | |||
| lda new_fx | |||
| cmp view_fx | |||
| bne @moved | |||
| lda new_cy | |||
| cmp view_cy | |||
| bne @moved | |||
| lda new_fy | |||
| cmp view_fy | |||
| beq @regs | |||
| @moved: inc view_moved | |||
| lda new_cx | |||
| sta view_cx | |||
| lda new_fx | |||
| sta view_fx | |||
| lda new_cy | |||
| sta view_cy | |||
| lda new_fy | |||
| sta view_fy | |||
| @regs: ; fall through | |||
| ; Fine scroll values for the map area; the raster interrupt writes them at | |||
| ; the top of the next frame. | |||
| set_scroll_regs: | |||
| lda #7 | |||
| sec | |||
| sbc view_fx | |||
| ora #$10 ; multicolour, 38 columns | |||
| sta map_d016 | |||
| lda #7 | |||
| sec | |||
| sbc view_fy | |||
| ora #$30 ; bitmap, display on, 24 rows | |||
| sta map_d011 | |||
| rts | |||
| flip_buffers: | |||
| ldx hidden | |||
| lda buffer_bank_bits,x | |||
| jsr set_bank | |||
| lda visible | |||
| stx visible | |||
| sta hidden | |||
| rts | |||
| ; step_x, step_y from scroll_dx, scroll_dy: zero at the world edges, and | |||
| ; while scrolling diagonally hold the axis that would cross its cell edge | |||
| ; first, so that both cross in the same frame. | |||
| get_steps: | |||
| lda scroll_dx | |||
| sta step_x | |||
| beq @y | |||
| bmi @x_low | |||
| lda view_cx ; right edge: vx = 336 | |||
| cmp #MAX_VIEW_CX | |||
| bne @y | |||
| lda #0 | |||
| sta step_x | |||
| beq @y | |||
| @x_low: lda view_cx ; left edge: vx = 0 | |||
| ora view_fx | |||
| bne @y | |||
| sta step_x | |||
| @y: lda scroll_dy | |||
| sta step_y | |||
| beq @lock | |||
| bmi @y_low | |||
| lda view_cy ; bottom edge: vy = 244 | |||
| cmp #MAX_VIEW_CY | |||
| bne @lock | |||
| lda view_fy | |||
| cmp #MAX_VIEW_FY | |||
| bne @lock | |||
| lda #0 | |||
| sta step_y | |||
| beq @lock | |||
| @y_low: lda view_cy ; top edge: vy = 0 | |||
| ora view_fy | |||
| bne @lock | |||
| sta step_y | |||
| @lock: lda step_x | |||
| beq @done | |||
| lda step_y | |||
| beq @done | |||
| jsr frames_to_cross ; X = frames for x, Y = frames for y, C clear = both can cross | |||
| bcs @done | |||
| stx lock_frames | |||
| cpy lock_frames | |||
| beq @done | |||
| bcc @hold_y ; y crosses sooner: hold y | |||
| lda #0 ; x crosses sooner: hold x | |||
| sta step_x | |||
| rts | |||
| @hold_y: | |||
| lda #0 | |||
| sta step_y | |||
| @done: rts | |||
| ; For nonzero step_x and step_y: X, Y = steps until each axis crosses a cell | |||
| ; edge. Carry set if either axis will reach a world edge first. | |||
| frames_to_cross: | |||
| lda step_x | |||
| bmi @x_left | |||
| lda view_cx | |||
| cmp #MAX_VIEW_CX | |||
| bcs @no | |||
| lda #7 | |||
| sec | |||
| sbc view_fx | |||
| tax | |||
| jmp @y | |||
| @x_left: | |||
| lda view_cx | |||
| beq @no | |||
| ldx view_fx | |||
| @y: lda step_y | |||
| bmi @y_up | |||
| lda view_cy | |||
| cmp #MAX_VIEW_CY | |||
| bcs @no | |||
| lda #7 | |||
| sec | |||
| sbc view_fy | |||
| tay | |||
| clc | |||
| rts | |||
| @y_up: lda view_cy | |||
| beq @no | |||
| ldy view_fy | |||
| clc | |||
| rts | |||
| @no: sec | |||
| rts | |||
| ; After the keys are read: the hidden buffer should hold the origin of the | |||
| ; next cell crossing in the held direction, or the current origin when the | |||
| ; view is still (then people flip every frame again). Restart its rebuild | |||
| ; when the target changes. | |||
| choose_rebuild_target: | |||
| lda view_cx | |||
| sta rb_tx | |||
| lda view_cy | |||
| sta rb_ty | |||
| lda scroll_dx | |||
| sta step_x | |||
| lda scroll_dy | |||
| sta step_y | |||
| lda step_x ; x: only if a crossing is possible | |||
| beq @y | |||
| bmi @x_left | |||
| lda view_cx | |||
| cmp #MAX_VIEW_CX | |||
| bcs @y | |||
| inc rb_tx | |||
| bne @y | |||
| @x_left: | |||
| lda view_cx | |||
| beq @y | |||
| dec rb_tx | |||
| @y: lda step_y | |||
| beq @set | |||
| bmi @y_up | |||
| lda view_cy | |||
| cmp #MAX_VIEW_CY | |||
| bcs @set | |||
| inc rb_ty | |||
| bne @set | |||
| @y_up: lda view_cy | |||
| beq @set | |||
| dec rb_ty | |||
| @set: ldx hidden | |||
| lda rb_tx | |||
| cmp buf_cx,x | |||
| bne @restart | |||
| lda rb_ty | |||
| cmp buf_cy,x | |||
| beq @keep | |||
| @restart: | |||
| jmp start_rebuild | |||
| @keep: rts | |||
| ; Rebuild chunks of the hidden buffer until it is complete or the raster | |||
| ; nears the bottom of the frame (the people update must start on time): | |||
| ; 8 cells per chunk before CHUNK8_CUTOFF, 4 before CHUNK4_CUTOFF. | |||
| rebuild_slices: | |||
| @next: ldx rb_buf | |||
| lda buf_ready,x | |||
| bne @done | |||
| bit VIC_CTRL1 ; lines 256-262 | |||
| bmi @done | |||
| lda VIC_RASTER | |||
| cmp #CHUNK4_CUTOFF | |||
| bcs @done | |||
| ldy #4 | |||
| cmp #CHUNK8_CUTOFF | |||
| bcs @chunk | |||
| ldy #8 | |||
| @chunk: jsr rebuild_chunk | |||
| jmp @next | |||
| @done: rts | |||
| ; Y = cells to draw (at most). Draws the next cells of buffer rb_buf, row | |||
| ; rb_row, from rb_col: the screen RAM colour and 8 bitmap bytes per cell. | |||
| ; The bitmap stores are page-aligned (rb_fK/rb_gK = page + K) and indexed by | |||
| ; rb_boff; when rb_boff passes 255 the stores move to the next page. | |||
| rebuild_chunk: | |||
| sty rb_count | |||
| ldx rb_buf | |||
| lda rb_col | |||
| bne @count | |||
| lda buf_cy,x ; new row: source, screen and bitmap addresses | |||
| clc | |||
| adc rb_row | |||
| tay | |||
| lda world_row_low,y | |||
| clc | |||
| adc buf_cx,x | |||
| sta rb_src+1 | |||
| lda world_row_high,y | |||
| adc #0 | |||
| sta rb_src+2 | |||
| ldy rb_row | |||
| lda screen_row_low,y | |||
| sta rb_scr+1 | |||
| lda screen_row_high,y | |||
| clc | |||
| adc buffer_screen_high,x | |||
| sta rb_scr+2 | |||
| lda bitmap_row_low,y | |||
| sta rb_boff | |||
| lda bitmap_row_high,y | |||
| clc | |||
| adc buffer_bitmap_offsets,x | |||
| jsr set_store_page | |||
| @count: lda #MAP_COLS_DRAWN ; no further than the end of the row | |||
| sec | |||
| sbc rb_col | |||
| cmp rb_count | |||
| bcs rb_cell | |||
| sta rb_count | |||
| rb_cell: | |||
| ldy rb_col | |||
| rb_src: ldx $FFFF,y ; X = tile | |||
| lda tile_colors,x | |||
| rb_scr: sta $FFFF,y | |||
| ldy rb_boff | |||
| lda tile_fill,x | |||
| bmi rb_pattern ; $FF: the bytes differ | |||
| .repeat 8, K ; all eight bytes the same | |||
| .ident(.sprintf("rb_f%d", K)): | |||
| sta $FF00 + K,y | |||
| .endrepeat | |||
| jmp rb_advance | |||
| rb_pattern: | |||
| lda tile_times8,x | |||
| tax | |||
| .repeat 8, K | |||
| lda tile_patterns + K,x | |||
| .ident(.sprintf("rb_g%d", K)): | |||
| sta $FF00 + K,y | |||
| .endrepeat | |||
| rb_advance: | |||
| inc rb_col | |||
| tya | |||
| clc | |||
| adc #8 | |||
| sta rb_boff | |||
| bcc rb_same_page | |||
| lda rb_page | |||
| adc #0 ; carry is set: next page | |||
| jsr set_store_page | |||
| rb_same_page: | |||
| dec rb_count | |||
| bne rb_cell | |||
| lda rb_col | |||
| cmp #MAP_COLS_DRAWN | |||
| bne rb_chunk_done | |||
| lda #0 | |||
| sta rb_col | |||
| inc rb_row | |||
| ldx rb_buf | |||
| lda rb_row | |||
| cmp buf_rows,x | |||
| bne rb_chunk_done | |||
| lda #1 | |||
| sta buf_ready,x | |||
| rb_chunk_done: | |||
| rts | |||
| ; A = bitmap page for the 16 stores of rebuild_chunk. | |||
| set_store_page: | |||
| sta rb_page | |||
| .repeat 8, K | |||
| sta .ident(.sprintf("rb_f%d", K)) + 2 | |||
| sta .ident(.sprintf("rb_g%d", K)) + 2 | |||
| .endrepeat | |||
| rts | |||
| .segment "RODATA" | |||
| .repeat BUF_ROWS, row | |||
| .assert ((BITMAP_A + 320 * row) & 7) = 0, error, "Cells must not straddle a page" | |||
| .endrepeat | |||
| .repeat TILE_COUNT, t | |||
| .assert t * 8 < 256, error, "Tile pattern offsets must fit in X" | |||
| .endrepeat | |||
| screen_row_low: | |||
| .repeat BUF_ROWS, row | |||
| .byte <(40 * row) | |||
| .endrepeat | |||
| screen_row_high: | |||
| .repeat BUF_ROWS, row | |||
| .byte >(40 * row) | |||
| .endrepeat | |||
| buffer_screen_high: .byte >SCREEN_A, >SCREEN_B | |||
| tile_times8: | |||
| .repeat TILE_COUNT, t | |||
| .byte t * 8 | |||
| .endrepeat | |||
| .segment "BSS" | |||
| ; Keep view_cx..view_fy together: the checks read them as one block. | |||
| view_cx: .res 1 | |||
| view_fx: .res 1 | |||
| view_cy: .res 1 | |||
| view_fy: .res 1 | |||
| view_moved: .res 1 | |||
| buf_cx: .res 2 | |||
| buf_cy: .res 2 | |||
| buf_ready: .res 2 | |||
| buf_rows: .res 2 | |||
| map_d011: .res 1 | |||
| map_d016: .res 1 | |||
| people_flip_pending: .res 1 | |||
| step_x: .res 1 | |||
| step_y: .res 1 | |||
| new_cx: .res 1 | |||
| new_fx: .res 1 | |||
| new_cy: .res 1 | |||
| new_fy: .res 1 | |||
| wrap: .res 1 | |||
| lock_frames: .res 1 | |||
| rb_tx: .res 1 | |||
| rb_ty: .res 1 | |||
| rb_buf: .res 1 | |||
| rb_row: .res 1 | |||
| @@ -1,25 +1,35 @@ | |||
| ; Status area: a raster split shows five rows of text below the 20-row map. | |||
| ; | |||
| ; Each VIC bank holds, at the same offsets, so a flip still changes only $DD00: | |||
| ; bank + $0000 map screen RAM (bitmap colours) | |||
| ; bank + $0400 status text screen (rows 20-24 are shown) | |||
| ; bank + $0800 copy of the upper-case ROM font (2 KB) | |||
| ; bank + $0000 map screen RAM (bitmap colours, 21 rows) | |||
| ; bank + $0400 text screen 1: status lines in rows 20-24 | |||
| ; bank + $0800 text screen 2: the same lines in rows 19-23 | |||
| ; bank + $1000 upper-case font: a RAM copy in bank 1 ($5000); in bank 2 the | |||
| ; VIC-II sees the character ROM itself at $9000 | |||
| ; bank + $2000 map bitmap | |||
| ; Colour RAM is light red everywhere, which is also the text colour. | |||
| ; | |||
| ; Why two text screens: text row 20 starts at line 211 with y-scroll 3. When | |||
| ; the map's y-scroll is 4-7, map row 19 is still being shown at line 210 and | |||
| ; the VIC-II's row counter has not moved on, so the first text row is fetched | |||
| ; from screen row 19. With y-scroll 0-3 it is fetched from row 20. | |||
| ; | |||
| ; Raster interrupt, two phases per frame: | |||
| ; TOP_IRQ_LINE (vertical blank) multicolour bitmap, map screen RAM | |||
| ; SPLIT_IRQ_LINE waits for line SPLIT_LINE - 1, the last pixel line of map | |||
| ; row 19, then switches to text after that line's last pixel | |||
| ; and before the text row's first fetch at SPLIT_LINE. | |||
| ; TOP_IRQ_LINE (vertical blank) map registers for this frame's scroll; | |||
| ; chooses the text screen and split delay for its y-scroll | |||
| ; SPLIT_IRQ_LINE waits for line SPLIT_LINE - 1, the last map pixel line, | |||
| ; then switches to text in the border after that line's last | |||
| ; pixel and before the first text fetch at SPLIT_LINE. | |||
| STATUS_ROW = 20 | |||
| STATUS_ROWS = 5 | |||
| TEXT_OFFSET = $0400 | |||
| FONT_OFFSET = $0800 | |||
| TEXT_A = SCREEN_A + TEXT_OFFSET | |||
| TEXT_B = SCREEN_B + TEXT_OFFSET | |||
| TEXT1_OFFSET = $0400 | |||
| TEXT2_OFFSET = $0800 | |||
| FONT_OFFSET = $1000 | |||
| TEXT_A1 = SCREEN_A + TEXT1_OFFSET + STATUS_ROW * 40 | |||
| TEXT_A2 = SCREEN_A + TEXT2_OFFSET + (STATUS_ROW - 1) * 40 | |||
| TEXT_B1 = SCREEN_B + TEXT1_OFFSET + STATUS_ROW * 40 | |||
| TEXT_B2 = SCREEN_B + TEXT2_OFFSET + (STATUS_ROW - 1) * 40 | |||
| FONT_A = SCREEN_A + FONT_OFFSET | |||
| FONT_B = SCREEN_B + FONT_OFFSET | |||
| CHAR_ROM = $D000 | |||
| CPU_PORT_CHARS = $32 ; BASIC out, KERNAL in, character ROM at $D000 | |||
| @@ -28,28 +38,34 @@ VIC_IRQ_ENABLE = $D01A | |||
| IRQ_VECTOR = $0314 ; KERNAL jumps here after saving A, X and Y | |||
| KERNAL_IRQ_EXIT = $EA81 ; restores Y, X, A and returns from interrupt | |||
| MAP_D011 = $3B ; bitmap, display on, 25 rows, y-scroll 3 | |||
| MAP_D016 = $18 ; multicolour, 40 columns, x-scroll 0 | |||
| MAP_D011 = $3B ; first frame: bitmap, display on, 25 rows, y-scroll 3 | |||
| MAP_D016 = $18 ; first frame: multicolour, 40 columns, x-scroll 0 | |||
| MAP_D018 = $08 ; screen at bank + $0000, bitmap at bank + $2000 | |||
| TEXT_D011 = $1B ; text, display on, 25 rows, y-scroll 3 | |||
| TEXT_D016 = $08 ; single colour, 40 columns | |||
| TEXT_D018 = ((TEXT_OFFSET / $0400) << 4) | ((FONT_OFFSET / $0800) << 1) | |||
| TEXT1_D018 = ((TEXT1_OFFSET / $0400) << 4) | ((FONT_OFFSET / $0800) << 1) | |||
| TEXT2_D018 = ((TEXT2_OFFSET / $0400) << 4) | ((FONT_OFFSET / $0800) << 1) | |||
| FIRST_TEXT_LINE = 51 ; first display line with y-scroll 3 | |||
| SPLIT_LINE = FIRST_TEXT_LINE + STATUS_ROW * 8 ; 211: first line of row 20 | |||
| SPLIT_IRQ_LINE = SPLIT_LINE - 3 | |||
| TOP_IRQ_LINE = 16 | |||
| 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 | |||
| ; stalls the CPU until about cycle 55 | |||
| VIEW_X_DIGITS = 1 * 40 + 7 ; row 21: "VIEW X nn" | |||
| VIEW_Y_DIGITS = 1 * 40 + 12 ; row 21: "Y nn" | |||
| PEOPLE_DIGITS = 2 * 40 + 15 ; row 22, after "PEOPLE IN VIEW " | |||
| .assert (TEXT_A & $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" | |||
| .assert (FONT_A & $07FF) = 0, error, "Font must be 2 KB aligned" | |||
| .assert SCREEN_B + FONT_OFFSET = $9000, error, "Bank 2 uses the character ROM image at $9000" | |||
| .export split_store, split_done, raster_irq | |||
| .segment "CODE" | |||
| ; Copy the upper-case half of the character ROM into both banks. | |||
| ; Copy the upper-case half of the character ROM into bank 1. | |||
| copy_font: | |||
| sei | |||
| lda #CPU_PORT_CHARS | |||
| @@ -57,12 +73,10 @@ copy_font: | |||
| ldx #0 | |||
| @page: lda CHAR_ROM,x | |||
| sta FONT_A,x | |||
| sta FONT_B,x | |||
| inx | |||
| bne @page | |||
| inc @page+2 ; next 256 bytes of source and both targets | |||
| inc @page+2 ; next 256 bytes of source and target | |||
| inc @page+5 | |||
| inc @page+8 | |||
| lda @page+2 | |||
| cmp #>(CHAR_ROM + $0800) | |||
| bne @page | |||
| @@ -71,36 +85,50 @@ copy_font: | |||
| cli | |||
| rts | |||
| ; Write the five status lines into both text screens. | |||
| ; Write the five status lines into all four text screen copies. | |||
| write_status_text: | |||
| ldx #STATUS_ROWS * 40 - 1 | |||
| @copy: lda status_text,x | |||
| sta TEXT_A + STATUS_ROW * 40,x | |||
| sta TEXT_B + STATUS_ROW * 40,x | |||
| sta TEXT_A1,x | |||
| sta TEXT_A2,x | |||
| sta TEXT_B1,x | |||
| sta TEXT_B2,x | |||
| dex | |||
| cpx #$FF | |||
| bne @copy | |||
| rts | |||
| ; Show the number of people drawn into the hidden buffer in its text screen. | |||
| update_people_count: | |||
| ldx hidden | |||
| lda drawn_count,x | |||
| ldy #'0' | |||
| ; Show the view's top-left cell and the number of people in view. | |||
| update_status: | |||
| lda view_cx | |||
| ldy #VIEW_X_DIGITS | |||
| jsr show_number | |||
| lda view_cy | |||
| ldy #VIEW_Y_DIGITS | |||
| jsr show_number | |||
| lda people_in_view | |||
| ldy #PEOPLE_DIGITS | |||
| ; fall through | |||
| ; A = 0-99, Y = offset in the status lines. Text is fetched once per | |||
| ; character row, so a change never shows half-drawn. | |||
| show_number: | |||
| ldx #'0' | |||
| @tens: cmp #10 | |||
| bcc @ones | |||
| sbc #10 | |||
| iny | |||
| inx | |||
| bne @tens | |||
| @ones: ora #'0' | |||
| ldx hidden | |||
| bne @buffer_b | |||
| sty TEXT_A + STATUS_ROW * 40 + PEOPLE_DIGITS | |||
| sta TEXT_A + STATUS_ROW * 40 + PEOPLE_DIGITS + 1 | |||
| rts | |||
| @buffer_b: | |||
| sty TEXT_B + STATUS_ROW * 40 + PEOPLE_DIGITS | |||
| sta TEXT_B + STATUS_ROW * 40 + PEOPLE_DIGITS + 1 | |||
| sta TEXT_A1+1,y | |||
| sta TEXT_A2+1,y | |||
| sta TEXT_B1+1,y | |||
| sta TEXT_B2+1,y | |||
| txa | |||
| sta TEXT_A1,y | |||
| sta TEXT_A2,y | |||
| sta TEXT_B1,y | |||
| sta TEXT_B2,y | |||
| rts | |||
| install_raster_irq: | |||
| @@ -137,12 +165,19 @@ raster_irq: | |||
| sta VIC_IRQ_FLAGS | |||
| lda irq_phase | |||
| bne @split | |||
| lda #MAP_D011 ; top of frame: map in multicolour bitmap | |||
| lda map_d011 ; top of frame: map with this frame's scroll | |||
| sta VIC_CTRL1 | |||
| lda #MAP_D016 | |||
| lda map_d016 | |||
| sta VIC_CTRL2 | |||
| lda #MAP_D018 | |||
| sta VIC_MEMPTR | |||
| lda map_d011 ; patch the split for this y-scroll; immediate | |||
| and #7 ; operands keep its timing exact | |||
| tax | |||
| lda split_d018_for_y,x | |||
| sta split_d018+1 | |||
| lda split_delay_for_y,x | |||
| sta split_delay+1 | |||
| lda #SPLIT_IRQ_LINE | |||
| sta VIC_RASTER | |||
| inc irq_phase | |||
| @@ -150,10 +185,12 @@ raster_irq: | |||
| @split: lda #SPLIT_LINE - 1 | |||
| @wait: cmp VIC_RASTER ; start of the last map pixel line | |||
| bne @wait | |||
| split_delay: | |||
| ldx #SPLIT_DELAY | |||
| @delay: dex | |||
| bne @delay | |||
| lda #TEXT_D018 | |||
| split_d018: | |||
| lda #TEXT1_D018 | |||
| ldx #TEXT_D011 | |||
| ldy #TEXT_D016 | |||
| split_store: ; check hook: these three writes must land in | |||
| @@ -168,6 +205,12 @@ split_done: | |||
| jmp KERNAL_IRQ_EXIT | |||
| .segment "RODATA" | |||
| split_d018_for_y: | |||
| .byte TEXT1_D018, TEXT1_D018, TEXT1_D018, TEXT1_D018 | |||
| .byte TEXT2_D018, TEXT2_D018, TEXT2_D018, TEXT2_D018 | |||
| split_delay_for_y: | |||
| .byte SPLIT_DELAY, SPLIT_DELAY, SPLIT_DELAY_BAD, SPLIT_DELAY | |||
| .byte SPLIT_DELAY, SPLIT_DELAY, SPLIT_DELAY, SPLIT_DELAY | |||
| status_text: | |||
| .byte "LAND MAP 64 " | |||
| .byte "VIEW X 00 Y 00 " | |||
| @@ -49,6 +49,21 @@ tile_patterns: | |||
| .assert * - tile_patterns = TILE_COUNT * 8, error, "Tile bitmap table size" | |||
| .assert TILE_COUNT <= 32, error, "Tile bitmap offsets must fit in X" | |||
| ; Tiles whose eight bitmap bytes are all the same: that byte, else $FF. | |||
| ; The scroll rebuild stores these without reading the pattern table. | |||
| tile_fill: | |||
| .repeat TILE_COUNT, t | |||
| .if t = LAND | |||
| .byte $00 | |||
| .elseif t = WATER | |||
| .byte $55 | |||
| .elseif t = ROAD_V | |||
| .byte $14 | |||
| .else | |||
| .byte $FF | |||
| .endif | |||
| .endrepeat | |||
| tile_colors: | |||
| .byte $99, $59, $59, $C9 | |||
| .repeat 9 | |||
| @@ -83,6 +83,9 @@ $peopleCheckpoint = $n | |||
| 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-b.bin\" 0 {0:x4} {1:x4}' -f $buffers[1], ($buffers[1] + $bitmapSize - 1)) | |||
| # No key is held during this check: keys typed on the PC while VICE has focus | |||
| # would otherwise reach the program (the arrow keys scroll the view). | |||
| foreach ($row in 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { Add-Trace (Get-Label $target $row) 'r a = ff' } | |||
| Set-Content -LiteralPath (Join-Path $dir 'monitor.txt') -Value $monitor | |||
| Set-Content -LiteralPath (Join-Path $dir 'vicerc') -Value '' | |||
| @@ -167,7 +170,7 @@ function Get-ExpectedBitmap([byte[]]$Clean, [byte[]]$Table) { | |||
| $masks = 0xC0, 0x30, 0x0C, 0x03 | |||
| for ($i = 0; $i -lt $count; $i++) { | |||
| $cx = $Table[$i]; $cy = $Table[32 + $i] | |||
| if ($cx -ge 40 -or $cy -ge 20) { continue } | |||
| if ($cx -ge 39 -or $cy -ge 21) { continue } # 39 drawn columns, 21 buffer rows | |||
| $offset = $cy * 320 + $cx * 8 + $Table[48 + $i] | |||
| $bitmap[$offset] = $bitmap[$offset] -bor $masks[$Table[16 + $i]] | |||
| } | |||
| @@ -175,7 +178,9 @@ function Get-ExpectedBitmap([byte[]]$Clean, [byte[]]$Table) { | |||
| } | |||
| $clean = 'clean-a.bin', 'clean-b.bin' | ForEach-Object { , [IO.File]::ReadAllBytes((Join-Path $dir $_)) } | |||
| $final = 'final-a.bin', 'final-b.bin' | ForEach-Object { , [IO.File]::ReadAllBytes((Join-Path $dir $_)) } | |||
| if ((Format-Hex $clean[0]) -ne (Format-Hex $clean[1])) { $failures.Add('buffers A and B differ before people are drawn') } | |||
| # Column 39 is never drawn (never visible in 38-column mode): skip its bytes. | |||
| $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 } } | |||
| $shown = $visibleLog[$visibleLog.Count - 1] | |||
| $hiddenIndex = 1 - $shown | |||
| $expectHidden = Get-ExpectedBitmap $clean[$hiddenIndex] $frames[$frames.Count - 1] | |||
| @@ -184,11 +189,11 @@ $dots = 0 | |||
| foreach ($pair in @(@($final[$hiddenIndex], $expectHidden, 'hidden'), @($final[$shown], $expectShown, 'visible'))) { | |||
| $bad = 0 | |||
| for ($b = 0; $b -lt $bitmapSize; $b++) { | |||
| if ($pair[0][$b] -ne $pair[1][$b]) { $bad++ } | |||
| if ($pair[0][$b] -ne $pair[1][$b] -and ($b % 320) -lt 312) { $bad++ } | |||
| } | |||
| if ($bad -gt 0) { $failures.Add("final $($pair[2]) bitmap has $bad bytes that differ from clean map plus people") } | |||
| } | |||
| for ($b = 0; $b -lt $bitmapSize; $b++) { if ($final[$hiddenIndex][$b] -ne $clean[$hiddenIndex][$b]) { $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") } | |||
| @@ -0,0 +1,235 @@ | |||
| <# | |||
| .SYNOPSIS | |||
| Check pixel-smooth scrolling of the C64 build headless in VICE. | |||
| .DESCRIPTION | |||
| Each scenario holds keys on a schedule (faked as in tools/check-keys.ps1: tracepoints | |||
| on the key_row_* instructions set the row bits; host key presses cannot interfere), | |||
| logs the view position, buffer state and scroll registers at people_moved every frame, | |||
| and saves both buffers (bitmap and screen RAM) each frame; the last save is checked. | |||
| Scenarios: | |||
| edges right+down until the bottom-right corner, then SHIFT (up+left) until | |||
| the top-left corner, then release | |||
| middle down, then right, then release in the middle of the world | |||
| reverse right for a while, reverse to left right after a cell step, release | |||
| Checks, per scenario: | |||
| - the view moves at most one pixel per axis per frame and stays inside | |||
| vx 0-336, vy 0-244; the fine-scroll registers match the view | |||
| - edges: the view reaches vx 336 and vy 244, then 0 and 0, and stops there | |||
| - the main loop never misses a frame and the people update ends before raster 55 | |||
| - frames where a held key did not move the view although no edge was reached are | |||
| counted as stalls and reported (they happen while the hidden buffer is not ready) | |||
| - at the end, the shown buffer's bitmap and screen RAM equal a fresh render of the | |||
| world from the view's top-left cell (39 columns, 21 rows), except bytes with dots | |||
| Exit codes: 0 = pass, 1 = fail, 2 = a tool is missing. | |||
| .EXAMPLE | |||
| pwsh -File tools/check-scroll.ps1 | |||
| #> | |||
| [CmdletBinding()] | |||
| param([switch]$NoBuild, [int]$TimeoutSeconds = 300, [int]$MaxStallFrames = 40) | |||
| . (Join-Path $PSScriptRoot 'lib.ps1') | |||
| function Get-Label([hashtable]$Target, [string]$Symbol) { | |||
| foreach ($line in Get-Content -LiteralPath (Get-RepoPath $Target.build.labels)) { | |||
| $parts = $line -split '\s+' | |||
| if ($parts.Count -ge 3 -and $parts[2].TrimStart('.') -eq $Symbol) { return [Convert]::ToInt32($parts[1], 16) } | |||
| } | |||
| throw "Symbol '$Symbol' not found in $($Target.build.labels)." | |||
| } | |||
| # Tile data from src/tiles.inc: patterns in file order, colours as declared there. | |||
| function Get-TileData { | |||
| $src = Get-Content -LiteralPath (Get-RepoPath 'src/tiles.inc') -Raw | |||
| $block = $src.Substring($src.IndexOf('tile_patterns:')) | |||
| $block = $block.Substring(0, $block.IndexOf('.assert * - tile_patterns')) | |||
| $patterns = @(foreach ($m in [regex]::Matches($block, '(?m)^\s*\.byte\s+([^;\r\n]+)')) { | |||
| , @($m.Groups[1].Value -split ',' | ForEach-Object { [Convert]::ToByte($_.Trim().TrimStart('$'), 16) }) | |||
| }) | |||
| $colors = [System.Collections.Generic.List[byte]]::new() | |||
| $cblock = $src.Substring($src.IndexOf('tile_colors:')) | |||
| $cblock = $cblock.Substring(0, $cblock.IndexOf('.assert * - tile_colors')) | |||
| $repeat = 1 | |||
| foreach ($line in $cblock -split "`n") { | |||
| if ($line -match '\.repeat\s+(\d+)') { $repeat = [int]$Matches[1]; continue } | |||
| if ($line -match '\.endrepeat') { $repeat = 1; continue } | |||
| if ($line -match '\.byte\s+([^;\r\n]+)') { | |||
| $vals = $Matches[1] -split ',' | ForEach-Object { [Convert]::ToByte($_.Trim().TrimStart('$'), 16) } | |||
| for ($r = 0; $r -lt $repeat; $r++) { foreach ($v in $vals) { $colors.Add($v) } } | |||
| } | |||
| } | |||
| @{ patterns = $patterns; colors = $colors.ToArray() } | |||
| } | |||
| try { | |||
| $project = Get-ProjectConfig | |||
| $target = Get-ProjectTargets $project 'c64' | |||
| if (-not $NoBuild) { Invoke-TargetBuild $project $target @{} } | |||
| $emu = Get-ToolPath $project $target.emulator.binary | |||
| } catch [MissingToolException] { | |||
| Write-Host $_.Exception.Message -ForegroundColor Yellow | |||
| exit 2 | |||
| } | |||
| $tiles = Get-TileData | |||
| $L = @{} | |||
| foreach ($s in 'smoke_ready', 'people_moved', 'world_tiles', 'people_cx', 'visible', 'view_cx', 'map_d011', 'map_d016', | |||
| 'key_row_cursor', 'key_row_lshift', 'key_row_rshift', 'key_row_space') { $L[$s] = Get-Label $target $s } | |||
| # 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' | |||
| $scenarios = @( | |||
| @{ name = 'edges'; cycles = 30000000; schedule = @( | |||
| @{ at = 30; cursor = $RIGHT_DOWN; lshift = $NONE } | |||
| @{ at = 520; cursor = $RIGHT_DOWN; lshift = $SHIFT } | |||
| @{ at = 1010; cursor = $NONE; lshift = $NONE }) } | |||
| @{ name = 'middle'; cycles = 12000000; schedule = @( | |||
| @{ at = 30; cursor = $DOWN; lshift = $NONE } | |||
| @{ at = 130; cursor = $RIGHTK; lshift = $NONE } | |||
| @{ at = 263; cursor = $NONE; lshift = $NONE }) } | |||
| @{ name = 'reverse'; cycles = 12000000; schedule = @( | |||
| @{ at = 30; cursor = $RIGHTK; lshift = $NONE } | |||
| @{ at = 104; cursor = $RIGHTK; lshift = $SHIFT } | |||
| @{ at = 200; cursor = $NONE; lshift = $NONE }) } | |||
| ) | |||
| $root = Get-RepoPath 'build/check-scroll' | |||
| if (Test-Path -LiteralPath $root) { 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 | |||
| $mon = [System.Collections.Generic.List[string]]::new() | |||
| $mon.Add('logname "monitor.log"'); $mon.Add('log on') | |||
| $n = 0 | |||
| $add = { param($addr, $cmd, $ignore) | |||
| $script:n++ | |||
| $mon.Add(('trace exec ${0:x4}' -f $addr)); $mon.Add(('command {0} "{1}"' -f $script:n, $cmd)) | |||
| if ($ignore) { $mon.Add(('ignore {0} {1}' -f $script:n, $ignore)) } | |||
| } | |||
| & $add $L.smoke_ready ('bsave \"world.bin\" 0 {0:x4} {1:x4}' -f $L.world_tiles, ($L.world_tiles + 3999)) 0 | |||
| & $add $L.key_row_cursor 'r a = ff' 0 | |||
| & $add $L.key_row_lshift 'r a = ff' 0 | |||
| & $add $L.key_row_rshift 'r a = ff' 0 | |||
| & $add $L.key_row_space 'r a = ff' 0 | |||
| foreach ($step in $sc.schedule) { # later checkpoints run after earlier ones at the same address | |||
| & $add $L.key_row_cursor "r a = $($step.cursor)" $step.at | |||
| & $add $L.key_row_lshift "r a = $($step.lshift)" $step.at | |||
| } | |||
| $viewCheckpoint = $n + 1 | |||
| & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.view_cx, ($L.view_cx + 3)) 0 | |||
| & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.map_d011, ($L.map_d016)) 0 | |||
| & $add $L.people_moved ('m {0:x4} {0:x4}' -f $L.visible) 0 | |||
| & $add $L.people_moved ('m {0:x4} {1:x4}' -f $L.people_cx, ($L.people_cx + 79)) 0 | |||
| & $add $L.people_moved 'bsave \"bitmap-a.bin\" 0 6000 7a3f' 0 | |||
| & $add $L.people_moved 'bsave \"bitmap-b.bin\" 0 a000 ba3f' 0 | |||
| & $add $L.people_moved 'bsave \"screen-a.bin\" 0 4000 4347' 0 | |||
| & $add $L.people_moved 'bsave \"screen-b.bin\" 0 8000 8347' 0 | |||
| 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) | |||
| $vargs += @('-limitcycles', [string]$sc.cycles, '-exitscreenshot', 'screen.png', '-moncommands', 'monitor.txt', '-autostartprgmode', '1', '-autostart', (Get-AutostartFile $target)) | |||
| $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) } | |||
| # 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 | |||
| } | |||
| 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) }) | |||
| if ($addr -eq $L.view_cx) { $cur.cx = $bytes[0]; $cur.fx = $bytes[1]; $cur.cy = $bytes[2]; $cur.fy = $bytes[3] } | |||
| elseif ($addr -eq $L.map_d011) { $cur.d011 = $bytes[0]; $cur.d016 = $bytes[1] } | |||
| elseif ($addr -eq $L.visible) { $cur.visible = $bytes[0] } | |||
| 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) } } } | |||
| } | |||
| $failures = [System.Collections.Generic.List[string]]::new() | |||
| if ($frames.Count -lt 100) { $failures.Add("only $($frames.Count) frames logged") } | |||
| $stalls = 0; $steps = 0; $late = 0; $lastLine = 0 | |||
| $maxVx = 0; $maxVy = 0; $minAfterMaxVx = 999; $minAfterMaxVy = 999 | |||
| $keysFor = { param($i) $k = @{ cursor = $NONE; lshift = $NONE }; foreach ($s in $sc.schedule) { if ($i -ge $s.at) { $k = $s } }; $k } | |||
| for ($i = 0; $i -lt $frames.Count; $i++) { | |||
| $f = $frames[$i] | |||
| $vx = 8 * $f.cx + $f.fx; $vy = 8 * $f.cy + $f.fy | |||
| $f.vx = $vx; $f.vy = $vy | |||
| if ($vx -gt 336 -or $vy -gt 244 -or $f.fx -gt 7 -or $f.fy -gt 7) { $failures.Add("frame ${i}: view out of range ($vx,$vy)") } | |||
| if ($f.d016 -ne (0x10 -bor (7 - $f.fx)) -or $f.d011 -ne (0x30 -bor (7 - $f.fy))) { $failures.Add(("frame {0}: registers d011={1:x2} d016={2:x2} do not match view fine scroll ({3},{4})" -f $i, $f.d011, $f.d016, $f.fx, $f.fy)) } | |||
| if ($f.line -ge 55 -and $f.line -lt 251) { $failures.Add("frame ${i}: people update ended at raster line $($f.line)") } | |||
| elseif ($f.line -lt 55) { $lastLine = [Math]::Max($lastLine, $f.line) } | |||
| if ($i -gt 0) { | |||
| $p = $frames[$i - 1] | |||
| $dx = $vx - $p.vx; $dy = $vy - $p.vy | |||
| if ([Math]::Abs($dx) -gt 1 -or [Math]::Abs($dy) -gt 1) { $failures.Add("frame ${i}: view jumped by ($dx,$dy)") } | |||
| if ($dx -ne 0 -or $dy -ne 0) { $steps++ } | |||
| if ($f.clock - $p.clock -gt 1.5 * 17095) { $late++ } | |||
| # Keys read in frame i-2 drive the step applied in frame i-1's vertical blank... the | |||
| # key row hooks count from the first read; allow two frames of latency. | |||
| $k = & $keysFor ($i - 2) | |||
| if ($i -ge 2 -and $k.cursor -ne $NONE) { | |||
| $wantX = if (([Convert]::ToByte($k.cursor, 16) -band 0x04) -eq 0) { if ($k.lshift -eq $SHIFT) { -1 } else { 1 } } else { 0 } | |||
| $wantY = if (([Convert]::ToByte($k.cursor, 16) -band 0x80) -eq 0) { if ($k.lshift -eq $SHIFT) { -1 } else { 1 } } else { 0 } | |||
| $canX = ($wantX -gt 0 -and $p.vx -lt 336) -or ($wantX -lt 0 -and $p.vx -gt 0) | |||
| $canY = ($wantY -gt 0 -and $p.vy -lt 244) -or ($wantY -lt 0 -and $p.vy -gt 0) | |||
| if (($canX -or $canY) -and $dx -eq 0 -and $dy -eq 0) { $stalls++ } | |||
| } | |||
| } | |||
| if ($vx -gt $maxVx) { $maxVx = $vx; $minAfterMaxVx = $vx } | |||
| if ($vy -gt $maxVy) { $maxVy = $vy; $minAfterMaxVy = $vy } | |||
| if ($vx -lt $minAfterMaxVx) { $minAfterMaxVx = $vx } | |||
| if ($vy -lt $minAfterMaxVy) { $minAfterMaxVy = $vy } | |||
| } | |||
| if ($late -gt 0) { $failures.Add("the main loop missed $late frame(s)") } | |||
| if ($sc.name -eq 'edges') { | |||
| 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)") } | |||
| # Final frame: shown buffer = fresh render at the view origin, except dot bytes. | |||
| $last = $frames[$frames.Count - 1] | |||
| $suffix = @('a', 'b')[$last.visible] | |||
| $bitmap = [IO.File]::ReadAllBytes((Join-Path $dir "bitmap-$suffix.bin")) | |||
| $screen = [IO.File]::ReadAllBytes((Join-Path $dir "screen-$suffix.bin")) | |||
| $world = [IO.File]::ReadAllBytes((Join-Path $dir 'world.bin')) | |||
| $dotBytes = @{} | |||
| for ($i = 0; $i -lt 16; $i++) { | |||
| $col = $last.people[$i] - $last.cx; $row = $last.people[32 + $i] - $last.cy | |||
| if ($col -ge 0 -and $col -lt 39 -and $row -ge 0 -and $row -lt 21) { $dotBytes[$row * 320 + $col * 8 + $last.people[48 + $i]] = 1 } | |||
| } | |||
| $badBitmap = 0; $badScreen = 0 | |||
| $rows = [Math]::Min(21, 50 - $last.cy) | |||
| for ($r = 0; $r -lt $rows; $r++) { | |||
| for ($c = 0; $c -lt 39; $c++) { | |||
| $t = $world[($last.cy + $r) * 80 + $last.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 | |||
| if ($bitmap[$o] -ne $tiles.patterns[$t][$k] -and -not $dotBytes.ContainsKey($o)) { $badBitmap++ } | |||
| } | |||
| } | |||
| } | |||
| if ($badBitmap -gt 0 -or $badScreen -gt 0) { $failures.Add("final shown buffer differs from the world at the view: $badBitmap bitmap bytes, $badScreen colour bytes") } | |||
| $summary = "{0}: {1} frames, {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 | |||
| if ($failures.Count -gt 0) { | |||
| $failedScenarios++ | |||
| Write-Host " FAIL $summary" -ForegroundColor Red | |||
| $failures | Select-Object -First 8 | ForEach-Object { Write-Host " $_" } | |||
| } else { | |||
| Write-Host " ok $summary" | |||
| } | |||
| } | |||
| 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 | |||
| exit 0 | |||
Powered by TurnKey Linux.