| @@ -36,7 +36,13 @@ with shoreline edges and corners. The black roads meet at crossings and bend | |||
| around a small loop on the right. Check that roads join without gaps and that | |||
| the terrain shows only its intended colours. | |||
| Once the generated world is displayed: | |||
| At M1.2, run `pwsh -File tools/smoke.ps1 -Target c64` and then | |||
| `pwsh -File tools/check-world.ps1 -ShowMap`. Expect `MAP READY` in the smoke | |||
| output and an 80×50 grid in the terminal. Look for water (`~`), stone (`#`), | |||
| grass (`g`), trees (`T`), land (`.`), and four road intersections (`+`). | |||
| The VICE window still shows the static tile test view for this task. | |||
| Starting at M1.3, when the generated world is displayed: | |||
| Steps: | |||
| 1. Wait for the map view. | |||
| @@ -53,8 +53,9 @@ Starter configurations marked verified were exercised by the Foundry's automated | |||
| - Emulator: `x64sc -ntsc -autostart build/land-map-64.prg` | |||
| - Smoke test: `pwsh -File tools/smoke.ps1 -Target c64`. It runs VICE headless for 30000000 cycles, saves memory when the program reaches `smoke_ready`, and checks: | |||
| - Title in the status mirror | |||
| - Terrain tile view reached its ready point (`TILES READY` at M1.1) | |||
| - World generation reached its ready point (`MAP READY`) | |||
| - C64 KERNAL reset vector at $FFFC (machine is in C64 mode) | |||
| - World check: `pwsh -File tools/check-world.ps1` validates the tile data saved by the smoke test. | |||
| ### How the smoke test works | |||
| @@ -10,7 +10,7 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n | |||
| |---|---|---| | |||
| | M0.1 Run tools/check-prereqs.ps1, then tools/smoke.ps1 for every target. | passed (2026-12-03, `pwsh -File tools/check-prereqs.ps1`; `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`) | confirmed by user (2026-12-03) | | |||
| | M1.1 Tile set: 8-byte multicolour patterns for land, grass, trees, stone, water and roads, including edge and corner patterns, with per-tile screen-RAM colour pairs. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`) | confirmed by user (2026-12-03) | | |||
| | M1.2 Seeded generator: 80x50 tile world with water, stone, grass with trees, and connected roads; enforce the at-most-two-colours-per-cell rule. | not run | pending | | |||
| | M1.2 Seeded generator: 80x50 tile world with water, stone, grass with trees, and connected roads; enforce the at-most-two-colours-per-cell rule. | passed (2026-12-03, `pwsh -File tools/build.ps1`; `pwsh -File tools/smoke.ps1`; `pwsh -File tools/check-world.ps1`) | pending | | |||
| | M1.3 Render the top-left screen of the world into the visible buffer; SPACE regenerates. | not run | pending | | |||
| | M2.1 People table (world x, y, direction) and movement rules; water and stone block. | not run | pending | | |||
| | M2.2 Per-buffer saved-byte lists: restore the bytes under people from two frames ago, draw people in view, flip in vertical blank. | not run | pending | | |||
| @@ -268,7 +268,7 @@ | |||
| }, | |||
| "starter": { | |||
| "screenTitle": "LAND MAP 64", | |||
| "expectedScreen": "A static multicolour bitmap test view with four matching panels of brown land, green grass and trees, grey stone, blue shorelines, and black road bends and crossings. Status mirror in the hidden text screen: row 0 \"LAND MAP 64\", row 2 \"TILES READY\".", | |||
| "expectedScreen": "The seeded 80x50 tile world is in RAM. VICE displays the static terrain tile test view. The hidden text screen shows \"LAND MAP 64\" and \"MAP READY\".", | |||
| "smokeChecks": [ | |||
| { | |||
| "row": 0, | |||
| @@ -279,8 +279,8 @@ | |||
| { | |||
| "row": 2, | |||
| "col": 0, | |||
| "text": "TILES READY", | |||
| "description": "Terrain tile view reached its ready point" | |||
| "text": "MAP READY", | |||
| "description": "World generation reached its ready point" | |||
| } | |||
| ], | |||
| "requirements": [ | |||
| @@ -617,6 +617,12 @@ | |||
| "address": "0400", | |||
| "length": 1000 | |||
| }, | |||
| { | |||
| "name": "world", | |||
| "symbol": "world_tiles", | |||
| "address": null, | |||
| "length": 4000 | |||
| }, | |||
| { | |||
| "name": "vector", | |||
| "symbol": null, | |||
| @@ -636,10 +642,10 @@ | |||
| { | |||
| "dump": "screen", | |||
| "offset": 80, | |||
| "text": "TILES READY", | |||
| "text": "MAP READY", | |||
| "encoding": "screen-upper", | |||
| "bytes": null, | |||
| "description": "Terrain tile view reached its ready point" | |||
| "description": "World generation reached its ready point" | |||
| }, | |||
| { | |||
| "dump": "vector", | |||
| @@ -650,7 +656,7 @@ | |||
| "description": "C64 KERNAL reset vector at $FFFC (machine is in C64 mode)" | |||
| } | |||
| ], | |||
| "expectedScreen": "A static multicolour bitmap test view with four matching panels of brown land, green grass and trees, grey stone, blue shorelines, and black road bends and crossings. Status mirror in the hidden text screen: row 0 \"LAND MAP 64\", row 2 \"TILES READY\"." | |||
| "expectedScreen": "The seeded 80x50 tile world is in RAM. VICE displays the static terrain tile test view. The hidden text screen shows \"LAND MAP 64\" and \"MAP READY\"." | |||
| }, | |||
| "recipeStatus": "verified", | |||
| "validationPlan": [] | |||
| @@ -61,8 +61,7 @@ start: | |||
| lda #$36 ; BASIC ROM out, KERNAL and I/O in: the CPU can | |||
| sta CPU_PORT ; read buffer B's bitmap at $A000 (needed from M2) | |||
| jsr write_status | |||
| jsr generate_world_from_timer | |||
| jsr draw_tile_view | |||
| jsr fill_color_ram | |||
| @@ -79,7 +78,8 @@ start: | |||
| jsr set_bank | |||
| lda #$3B ; bitmap mode, display on, 25 rows, y-scroll 3 | |||
| sta VIC_CTRL1 | |||
| smoke_ready: ; test view drawn, bitmap display on | |||
| jsr write_status | |||
| smoke_ready: ; world generated, test view on screen | |||
| nop | |||
| main_loop: | |||
| @@ -213,7 +213,7 @@ write_status: | |||
| .segment "RODATA" | |||
| title_text: .byte "LAND MAP 64", 0 | |||
| status_text: .byte "TILES READY", 0 | |||
| status_text: .byte "MAP READY", 0 | |||
| .segment "BSS" | |||
| bank_bits: .res 1 | |||
| @@ -221,3 +221,5 @@ panel_row: .res 1 ; starting index of the current test panel row | |||
| panel_index: .res 1 | |||
| panel_cells: .res 1 | |||
| screen_rows: .res 1 | |||
| .include "world.inc" | |||
| @@ -0,0 +1,277 @@ | |||
| ; One tile ID per 4x8 multicolour cell, in row-major order. | |||
| WORLD_WIDTH = 80 | |||
| WORLD_HEIGHT = 50 | |||
| SECTOR_WIDTH = WORLD_WIDTH / 2 | |||
| SECTOR_HEIGHT = WORLD_HEIGHT / 2 | |||
| CIA1_TIMER_A = $DC04 | |||
| world_ptr = bmp ; generator runs before bitmap drawing | |||
| .export world_tiles, generate_world | |||
| .segment "CODE" | |||
| ; Read the running KERNAL timer. Fall through to the fixed-seed entry point. | |||
| generate_world_from_timer: | |||
| lda CIA1_TIMER_A | |||
| ldx CIA1_TIMER_A+1 | |||
| ; A/X = low/high seed. Zero is mapped to one for the LFSR. | |||
| generate_world: | |||
| sta seed_low | |||
| stx seed_high | |||
| ora seed_high | |||
| bne @seeded | |||
| inc seed_low | |||
| @seeded: | |||
| ldx #0 | |||
| @clear_row: | |||
| jsr point_world_row | |||
| lda #LAND | |||
| ldy #WORLD_WIDTH-1 | |||
| @clear_cell: | |||
| sta (world_ptr),y | |||
| dey | |||
| bpl @clear_cell | |||
| inx | |||
| cpx #WORLD_HEIGHT | |||
| bne @clear_row | |||
| lda #0 | |||
| sta sector | |||
| @terrain: | |||
| ldx sector | |||
| lda sector_left,x | |||
| sta origin_x | |||
| lda sector_top,x | |||
| sta origin_y | |||
| jsr random_byte | |||
| and #1 | |||
| sta water_side | |||
| ldx water_side | |||
| lda #WATER | |||
| ldy #2 | |||
| jsr stamp_patch | |||
| lda water_side | |||
| eor #1 | |||
| tax | |||
| lda #GRASS | |||
| ldy #2 | |||
| jsr stamp_patch | |||
| ldx water_side | |||
| lda #STONE | |||
| ldy #17 | |||
| jsr stamp_patch | |||
| jsr random_byte | |||
| and #1 | |||
| beq @next_sector | |||
| lda water_side | |||
| eor #1 | |||
| tax | |||
| lda #GRASS | |||
| ldy #17 | |||
| jsr stamp_patch | |||
| @next_sector: | |||
| inc sector | |||
| lda sector | |||
| cmp #4 | |||
| bne @terrain | |||
| ; Lay down two east-west trunks and two north-south trunks. | |||
| ; The trunks are in the gaps between patches, so no tile has to mix | |||
| ; road and shoreline pixels. Every intersection becomes a crossing. | |||
| jsr random_byte | |||
| and #3 | |||
| clc | |||
| adc #10 | |||
| tax | |||
| jsr draw_horizontal_road | |||
| jsr random_byte | |||
| and #3 | |||
| clc | |||
| adc #SECTOR_HEIGHT+10 | |||
| tax | |||
| jsr draw_horizontal_road | |||
| jsr random_byte | |||
| and #7 | |||
| clc | |||
| adc #16 | |||
| tay | |||
| jsr draw_vertical_road | |||
| jsr random_byte | |||
| and #7 | |||
| clc | |||
| adc #SECTOR_WIDTH+16 | |||
| tay | |||
| jmp draw_vertical_road | |||
| ; A = terrain type, X = side within sector, Y = base row within sector. | |||
| ; Patch bounds are exclusive on the right and bottom. | |||
| stamp_patch: | |||
| sta patch_type | |||
| jsr random_byte | |||
| and #3 | |||
| clc | |||
| adc plot_left,x | |||
| adc origin_x | |||
| sta patch_left | |||
| jsr random_byte | |||
| and #3 | |||
| clc | |||
| adc #6 | |||
| adc patch_left | |||
| sta patch_right | |||
| jsr random_byte | |||
| and #1 | |||
| sty patch_top | |||
| clc | |||
| adc patch_top | |||
| adc origin_y | |||
| sta patch_top | |||
| tax | |||
| jsr random_byte | |||
| and #1 | |||
| clc | |||
| adc #4 | |||
| adc patch_top | |||
| sta patch_bottom | |||
| @row: jsr point_world_row | |||
| lda #3 | |||
| cpx patch_top | |||
| bne @bottom_edge | |||
| lda #0 | |||
| beq @row_index | |||
| @bottom_edge: | |||
| inx | |||
| cpx patch_bottom | |||
| bne @middle | |||
| lda #6 | |||
| @middle: | |||
| dex | |||
| @row_index: | |||
| sta shore_row | |||
| ldy patch_left | |||
| @cell: lda patch_type | |||
| cmp #WATER | |||
| beq @water | |||
| cmp #GRASS | |||
| bne @store | |||
| cpy patch_left | |||
| beq @store ; guarantee grass even for a dense grove | |||
| jsr random_byte | |||
| and #3 | |||
| bne @grass | |||
| lda #TREE | |||
| jmp @store | |||
| @grass: lda #GRASS | |||
| jmp @store | |||
| @water: | |||
| ; Select the west, middle or east tile for this shore row. | |||
| lda shore_row | |||
| cpy patch_left | |||
| beq @shore | |||
| iny | |||
| cpy patch_right ; carry is set only for the east edge | |||
| dey | |||
| adc #1 ; middles add 1, east edge adds 2 | |||
| @shore: | |||
| stx patch_row | |||
| tax | |||
| lda shore_tiles,x | |||
| ldx patch_row | |||
| @store: sta (world_ptr),y | |||
| iny | |||
| cpy patch_right | |||
| bne @cell | |||
| inx | |||
| cpx patch_bottom | |||
| bne @row | |||
| lda patch_type | |||
| cmp #GRASS | |||
| bne @done | |||
| ldy patch_left | |||
| iny | |||
| lda #TREE ; guarantee a tree in every grass patch | |||
| sta (world_ptr),y | |||
| @done: rts | |||
| draw_horizontal_road: | |||
| jsr point_world_row | |||
| ldy #WORLD_WIDTH-1 | |||
| lda #ROAD_H | |||
| @cell: sta (world_ptr),y | |||
| dey | |||
| bpl @cell | |||
| rts | |||
| draw_vertical_road: | |||
| ldx #0 | |||
| @row: jsr point_world_row | |||
| lda (world_ptr),y | |||
| cmp #ROAD_H | |||
| bne @straight | |||
| lda #ROAD_X | |||
| bne @store | |||
| @straight: | |||
| lda #ROAD_V | |||
| @store: sta (world_ptr),y | |||
| inx | |||
| cpx #WORLD_HEIGHT | |||
| bne @row | |||
| rts | |||
| ; X = world row. Preserves X and Y. | |||
| point_world_row: | |||
| lda world_row_low,x | |||
| sta world_ptr | |||
| lda world_row_high,x | |||
| sta world_ptr+1 | |||
| rts | |||
| ; 16-bit right-shifting Galois LFSR, polynomial mask $B400. | |||
| ; Return a mix of both state bytes in A. Preserves X and Y. | |||
| random_byte: | |||
| lsr seed_high | |||
| ror seed_low | |||
| bcc @mix | |||
| lda seed_high | |||
| eor #$B4 | |||
| sta seed_high | |||
| @mix: lda seed_high | |||
| eor seed_low | |||
| rts | |||
| .segment "RODATA" | |||
| sector_left: .byte 0, SECTOR_WIDTH, 0, SECTOR_WIDTH | |||
| sector_top: .byte 0, 0, SECTOR_HEIGHT, SECTOR_HEIGHT | |||
| plot_left: .byte 2, 25 | |||
| shore_tiles: | |||
| .byte WATER_NW, WATER_N, WATER_NE | |||
| .byte WATER_W, WATER, WATER_E | |||
| .byte WATER_SW, WATER_S, WATER_SE | |||
| world_row_low: | |||
| .repeat WORLD_HEIGHT, row | |||
| .byte <(world_tiles + WORLD_WIDTH * row) | |||
| .endrepeat | |||
| world_row_high: | |||
| .repeat WORLD_HEIGHT, row | |||
| .byte >(world_tiles + WORLD_WIDTH * row) | |||
| .endrepeat | |||
| .segment "BSS" | |||
| seed_low: .res 1 | |||
| seed_high: .res 1 | |||
| sector: .res 1 | |||
| origin_x: .res 1 | |||
| origin_y: .res 1 | |||
| water_side: .res 1 | |||
| patch_type: .res 1 | |||
| patch_left: .res 1 | |||
| patch_right: .res 1 | |||
| patch_top: .res 1 | |||
| patch_bottom: .res 1 | |||
| patch_row: .res 1 | |||
| shore_row: .res 1 | |||
| world_tiles: .res WORLD_WIDTH * WORLD_HEIGHT | |||
| .assert * <= SCREEN_A, lderror, "World must fit below VIC bank 1" | |||
| @@ -0,0 +1,59 @@ | |||
| <# Verifies the generated C64 tile world captured by tools/smoke.ps1. #> | |||
| [CmdletBinding()] | |||
| param( | |||
| [string]$Path = (Join-Path $PSScriptRoot '../build/smoke/c64/world.bin'), | |||
| [switch]$ShowMap | |||
| ) | |||
| $ErrorActionPreference = 'Stop' | |||
| $width = 80 | |||
| $height = 50 | |||
| $tiles = [IO.File]::ReadAllBytes((Resolve-Path -LiteralPath $Path).Path) | |||
| if ($tiles.Length -ne $width * $height) { | |||
| throw "Expected an 80x50 tile map, got $($tiles.Length) bytes." | |||
| } | |||
| # Tile IDs from src/tiles.inc. M1.2 uses straight roads and four-way crossings. | |||
| $roadH = 13 | |||
| $roadV = 14 | |||
| $roadCross = 19 | |||
| $glyphs = '.gT#~~~~~~~~~-|+++++' | |||
| $counts = [int[]]::new($glyphs.Length) | |||
| foreach ($tile in $tiles) { | |||
| if ($tile -ge $glyphs.Length) { throw "Invalid terrain tile ID $tile." } | |||
| $counts[$tile]++ | |||
| } | |||
| foreach ($tile in 0..12) { | |||
| if ($counts[$tile] -eq 0) { throw "Missing terrain tile ID $tile." } | |||
| } | |||
| # Find the road columns and rows from their endpoints on the world edges. | |||
| $roadColumns = @(0..($width - 1) | Where-Object { $tiles[$_] -eq $roadV }) | |||
| $roadRows = @(0..($height - 1) | Where-Object { $tiles[($_ * $width)] -eq $roadH }) | |||
| if ($roadColumns.Count -ne 2 -or $roadRows.Count -ne 2) { | |||
| throw "Expected two east-west and two north-south roads." | |||
| } | |||
| for ($y = 0; $y -lt $height; $y++) { | |||
| for ($x = 0; $x -lt $width; $x++) { | |||
| $tile = $tiles[$y * $width + $x] | |||
| $horizontal = $y -in $roadRows | |||
| $vertical = $x -in $roadColumns | |||
| if ($horizontal -or $vertical) { | |||
| $expected = if ($horizontal -and $vertical) { $roadCross } | |||
| elseif ($horizontal) { $roadH } | |||
| else { $roadV } | |||
| if ($tile -ne $expected) { | |||
| throw "Broken road at ($x,$y): expected tile $expected, got $tile." | |||
| } | |||
| } elseif ($tile -ge $roadH) { | |||
| throw "Disconnected road tile at ($x,$y)." | |||
| } | |||
| } | |||
| if ($ShowMap) { | |||
| $start = $y * $width | |||
| -join ($tiles[$start..($start + $width - 1)] | ForEach-Object { $glyphs[$_] }) | |||
| } | |||
| } | |||
| Write-Output '[PASS] 80x50 world has all terrain types and four connected road crossings.' | |||
Powered by TurnKey Linux.