Bläddra i källkod

M1.1: render terrain tile test view

main
Daniel Covington 3 dagar sedan
förälder
incheckning
aedec30b6d
6 ändrade filer med 169 tillägg och 122 borttagningar
  1. +9
    -2
      docs/manual-tests.md
  2. +1
    -1
      docs/toolchain.md
  3. +1
    -1
      docs/verification-status.md
  4. +7
    -7
      project.json
  5. +61
    -111
      src/main.s
  6. +90
    -0
      src/tiles.inc

+ 9
- 2
docs/manual-tests.md Visa fil

@@ -22,15 +22,22 @@ Steps:
Expected:
- tools/smoke.ps1 prints `[PASS] c64`; screenshot in build/smoke/c64/.
- A multicolour bitmap test screen: brown background with vertical bands of grey, green, blue and black, and a row of light red dots. Every second the buffers flip; buffer B shows the bands shifted by one cell, so the picture visibly alternates, proving both buffers and the flip work. Status mirror in the hidden text screen: row 0 "LAND MAP 64", row 2 "STARTER OK".
- Autostarts, shows a short generating message, then a full-screen multicolour bitmap view of the world: brown land, grey stone, green grass and trees, blue water, black roads. Light red dots move on land and roads. Cursor keys scroll the view smoothly; SPACE generates a new world.

## M1 - World generation and static view

### MT1.1: Generated world looks right (c64)
### MT1.1: Terrain tiles and generated world (c64)

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

At M1.1, wait for the static test view and inspect any of the four matching panels.
Each panel shows brown land, green grass and trees, grey stone, and a blue pool
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:

Steps:
1. Wait for the map view.
2. Inspect the screen.


+ 1
- 1
docs/toolchain.md Visa fil

@@ -53,7 +53,7 @@ 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
- Starter reached its ready point
- Terrain tile view reached its ready point (`TILES READY` at M1.1)
- C64 KERNAL reset vector at $FFFC (machine is in C64 mode)

### How the smoke test works


+ 1
- 1
docs/verification-status.md Visa fil

@@ -9,7 +9,7 @@ manual = `pending`, `confirmed by user (<date>)`, `problem reported (<date>): <n
| Item | Automated check | Manual verification by user |
|---|---|---|
| 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. | not run | pending |
| 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`) | 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. | not run | 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 |


+ 7
- 7
project.json Visa fil

@@ -268,7 +268,7 @@
},
"starter": {
"screenTitle": "LAND MAP 64",
"expectedScreen": "A multicolour bitmap test screen: brown background with vertical bands of grey, green, blue and black, and a row of light red dots. Every second the buffers flip; buffer B shows the bands shifted by one cell, so the picture visibly alternates, proving both buffers and the flip work. Status mirror in the hidden text screen: row 0 \"LAND MAP 64\", row 2 \"STARTER OK\".",
"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\".",
"smokeChecks": [
{
"row": 0,
@@ -279,8 +279,8 @@
{
"row": 2,
"col": 0,
"text": "STARTER OK",
"description": "Starter reached its ready point"
"text": "TILES READY",
"description": "Terrain tile view reached its ready point"
}
],
"requirements": [
@@ -636,10 +636,10 @@
{
"dump": "screen",
"offset": 80,
"text": "STARTER OK",
"text": "TILES READY",
"encoding": "screen-upper",
"bytes": null,
"description": "Starter reached its ready point"
"description": "Terrain tile view reached its ready point"
},
{
"dump": "vector",
@@ -650,7 +650,7 @@
"description": "C64 KERNAL reset vector at $FFFC (machine is in C64 mode)"
}
],
"expectedScreen": "A multicolour bitmap test screen: brown background with vertical bands of grey, green, blue and black, and a row of light red dots. Every second the buffers flip; buffer B shows the bands shifted by one cell, so the picture visibly alternates, proving both buffers and the flip work. Status mirror in the hidden text screen: row 0 \"LAND MAP 64\", row 2 \"STARTER OK\"."
"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\"."
},
"recipeStatus": "verified",
"validationPlan": []
@@ -675,4 +675,4 @@
"https://vice-emu.sourceforge.io/vice_12.html"
]
}
}
}

+ 61
- 111
src/main.s Visa fil

@@ -1,11 +1,11 @@
; Land Map 64 - starter (milestone M0), generated by the C64/C128 Dev Foundry (ca65).
; Land Map 64 - terrain tile test view (ca65).
; Built with: cl65 -t c64 -C c64-asm.cfg -u __EXEHDR__ (BASIC SYS line included).
;
; Proves the display foundation the rest of the program is built on:
; Multicolour bitmap palette and VIC bank layout:
; - multicolour bitmap mode with the Land Map 64 colour scheme
; background ($D021) brown (pixel %00)
; screen RAM high nibble terrain (pixel %01) grey, green, blue or black
; screen RAM low nibble terrain (pixel %10) unused by this test pattern
; screen RAM low nibble terrain (pixel %10)
; colour RAM light red (pixel %11) people; constant, never flipped
; - two complete buffers in separate VIC banks, flipped through $DD00:
; buffer A: VIC bank 1, screen RAM $4000, bitmap $6000
@@ -13,10 +13,7 @@
; Both use $D018 = $08 (screen at bank+$0000, bitmap at bank+$2000), so a flip
; changes only the two bank bits in $DD00.
;
; Test picture: vertical bands of grey, green, blue and black (5 cells wide) with a
; brown line at the bottom of every cell row and a dotted light red line on cell row
; 12. Buffer B has the bands shifted one cell to the left, and the program flips
; buffers once a second (60 NTSC frames), so the picture visibly steps back and forth.
; The static test picture draws the terrain tile table into buffer A.
;
; The text screen at $0400 is not displayed in bitmap mode. The program writes a
; status mirror there for the smoke test (row 0 title, row 2 status).
@@ -40,17 +37,12 @@ TEXT_SCREEN = $0400

SCREEN_A = $4000
BITMAP_A = $6000
SCREEN_B = $8000
BITMAP_B = $A000

BANK_A_BITS = %00000010 ; VIC bank 1 ($4000-$7FFF)
BANK_B_BITS = %00000001 ; VIC bank 2 ($8000-$BFFF)

COL_BLACK = 0
COL_BROWN = 9
COL_LIGHT_RED = 10

FRAMES_PER_FLIP = 60 ; one second on NTSC
FLIP_RASTER = 251 ; below the visible area on NTSC and PAL

; Zero page: $FB-$FE are free for user programs.
@@ -62,6 +54,8 @@ scr = $FD ; pointer into the screen RAM being drawn
.charmap $41 + I, $01 + I
.endrepeat

.include "tiles.inc"

.segment "CODE"
start:
lda #$36 ; BASIC ROM out, KERNAL and I/O in: the CPU can
@@ -69,19 +63,7 @@ start:

jsr write_status

lda #<BITMAP_A ; buffer A, bands not shifted
ldx #>BITMAP_A
ldy #>SCREEN_A
jsr set_targets
lda #0
jsr draw_test_buffer

lda #<BITMAP_B ; buffer B, bands shifted one cell
ldx #>BITMAP_B
ldy #>SCREEN_B
jsr set_targets
lda #1
jsr draw_test_buffer
jsr draw_tile_view

jsr fill_color_ram

@@ -97,26 +79,10 @@ start:
jsr set_bank
lda #$3B ; bitmap mode, display on, 25 rows, y-scroll 3
sta VIC_CTRL1
lda #0
sta shown ; buffer A is visible

smoke_ready: ; buffers drawn, bitmap display on
smoke_ready: ; test view drawn, bitmap display on
nop

main_loop:
ldx #FRAMES_PER_FLIP
@wait: jsr wait_frame
dex
bne @wait
lda shown ; flip: show the other buffer
eor #1
sta shown
beq @show_a
lda #BANK_B_BITS
bne @set
@show_a:
lda #BANK_A_BITS
@set: jsr set_bank ; we are just past FLIP_RASTER: no tearing
jmp main_loop

; ---------------------------------------------------------------- routines
@@ -143,46 +109,51 @@ set_bank:
sta CIA2_PRA
rts

; A/X = bitmap address (low/high), Y = screen RAM page.
set_targets:
draw_tile_view:
lda #<BITMAP_A
sta bmp
stx bmp+1
lda #0
lda #>BITMAP_A
sta bmp+1
lda #<SCREEN_A
sta scr
sty scr+1
lda #>SCREEN_A
sta scr+1
lda #0
sta panel_row
lda #25
sta screen_rows
@row: jsr draw_panel_row
jsr draw_panel_row
lda panel_index
cmp #TEST_PANEL_SIZE
bne @next_row
lda #0
@next_row:
sta panel_row
dec screen_rows
bne @row
rts

; Draw the test pattern into the buffer set by set_targets.
; A = band shift in cells (0 for buffer A, 1 for buffer B).
draw_test_buffer:
sta shift
lda #0
sta cell_row
@row: ldx #0 ; X = cell column 0-39
@cell: txa ; screen RAM: band colour in the high nibble
clc
adc shift
tay
lda band_colors,y
pha
txa
tay
pla
; Draw the same panel row in either half of the screen.
draw_panel_row:
lda panel_row
sta panel_index
lda #TEST_PANEL_WIDTH
sta panel_cells
@cell: ldx panel_index
lda test_panel,x
tax
ldy #0
lda tile_colors,x
sta (scr),y

ldy #0 ; bitmap: 8 bytes for this cell
@line: lda cell_pattern,y
cpy #3 ; line 3 of cell row 12: one light red pixel
bne @store
pha
lda cell_row
cmp #12
bne @plain
pla
lda #%11010101 ; leftmost pixel %11 = colour RAM = light red
jmp @store
@plain: pla
@store: sta (bmp),y
txa
asl a
asl a
asl a
tax
@line: lda tile_patterns,x
sta (bmp),y
inx
iny
cpy #8
bne @line
@@ -191,23 +162,16 @@ draw_test_buffer:
clc
adc #8
sta bmp
bcc @next
bcc @advance_screen
inc bmp+1
@next: inx
cpx #40
bne @cell

lda scr ; next cell row: screen pointer + 40
clc
adc #40
sta scr
bcc @rowdone
@advance_screen:
inc scr
bne @advance_panel
inc scr+1
@rowdone:
inc cell_row
lda cell_row
cmp #25
bne @row
@advance_panel:
inc panel_index
dec panel_cells
bne @cell
rts

; Colour RAM is shared by both buffers: light red everywhere (pixel %11 = people).
@@ -248,26 +212,12 @@ write_status:
@done: rts

.segment "RODATA"
; One cell: 6 lines of pixel %01 (band colour), then 2 lines of %00 (brown).
cell_pattern:
.byte %01010101, %01010101, %01010101, %01010101
.byte %01010101, %01010101, %00000000, %00000000

; Screen RAM byte per column (index = column + shift): band colour in the high
; nibble. Bands of 5 cells: grey (12), green (5), blue (6), black (0).
band_colors:
.repeat 9
.byte $C0, $C0, $C0, $C0, $C0
.byte $50, $50, $50, $50, $50
.byte $60, $60, $60, $60, $60
.byte $00, $00, $00, $00, $00
.endrepeat

title_text: .byte "LAND MAP 64", 0
status_text: .byte "STARTER OK", 0
status_text: .byte "TILES READY", 0

.segment "BSS"
shown: .res 1 ; 0 = buffer A visible, 1 = buffer B
bank_bits: .res 1
shift: .res 1
cell_row: .res 1
panel_row: .res 1 ; starting index of the current test panel row
panel_index: .res 1
panel_cells: .res 1
screen_rows: .res 1

+ 90
- 0
src/tiles.inc Visa fil

@@ -0,0 +1,90 @@
; Tile IDs index matching 8-byte bitmap patterns and screen RAM colour pairs.
; Pixel pairs: 00 brown, 01 high nibble, 10 low nibble, 11 reserved for people.
.enum
LAND
GRASS
TREE
STONE
WATER
WATER_N
WATER_S
WATER_W
WATER_E
WATER_NW
WATER_NE
WATER_SW
WATER_SE
ROAD_H
ROAD_V
ROAD_NE
ROAD_NW
ROAD_SE
ROAD_SW
ROAD_X
TILE_COUNT
.endenum

.segment "RODATA"
tile_patterns:
.byte $00,$00,$00,$00,$00,$00,$00,$00 ; land
.byte $44,$11,$44,$11,$44,$11,$44,$11 ; grass
.byte $00,$14,$55,$55,$55,$14,$08,$08 ; tree, brown trunk in low nibble
.byte $14,$55,$45,$55,$51,$55,$54,$10 ; stone
.byte $55,$55,$55,$55,$55,$55,$55,$55 ; open water
.byte $00,$00,$04,$51,$55,$55,$55,$55 ; north shore
.byte $55,$55,$55,$55,$15,$40,$00,$00 ; south shore
.byte $15,$15,$05,$15,$15,$15,$05,$15 ; west shore
.byte $54,$54,$50,$54,$54,$54,$50,$54 ; east shore
.byte $00,$00,$04,$11,$15,$15,$05,$15 ; northwest shore
.byte $00,$00,$10,$50,$54,$54,$50,$54 ; northeast shore
.byte $15,$15,$05,$15,$15,$04,$00,$00 ; southwest shore
.byte $54,$54,$50,$54,$54,$10,$00,$00 ; southeast shore
.byte $00,$00,$00,$55,$55,$00,$00,$00 ; east-west road
.byte $14,$14,$14,$14,$14,$14,$14,$14 ; north-south road
.byte $14,$14,$14,$15,$15,$00,$00,$00 ; north-east bend
.byte $14,$14,$14,$54,$54,$00,$00,$00 ; north-west bend
.byte $00,$00,$00,$15,$15,$14,$14,$14 ; south-east bend
.byte $00,$00,$00,$54,$54,$14,$14,$14 ; south-west bend
.byte $14,$14,$14,$55,$55,$14,$14,$14 ; crossing
.assert * - tile_patterns = TILE_COUNT * 8, error, "Tile bitmap table size"
.assert TILE_COUNT <= 32, error, "Tile bitmap offsets must fit in X"

tile_colors:
.byte $99, $59, $59, $C9
.repeat 9
.byte $69
.endrepeat
.repeat 7
.byte $09
.endrepeat
.assert * - tile_colors = TILE_COUNT, error, "Tile colour table size"

; The test view repeats this 20x12 panel twice in each direction.
TEST_PANEL_WIDTH = 20
test_panel:
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, ROAD_V, LAND
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND
.byte LAND, LAND, TREE, GRASS, GRASS, GRASS, TREE, LAND, ROAD_V, LAND
.byte WATER_NW, WATER_N, WATER_N, WATER_N, WATER_NE, LAND, LAND, LAND, LAND, LAND
.byte LAND, LAND, GRASS, GRASS, GRASS, TREE, GRASS, LAND, ROAD_V, LAND
.byte WATER_W, WATER, WATER, WATER, WATER_E, LAND, STONE, STONE, LAND, LAND
.byte LAND, LAND, GRASS, GRASS, TREE, GRASS, GRASS, LAND, ROAD_V, LAND
.byte WATER_W, WATER, WATER, WATER, WATER_E, LAND, STONE, STONE, LAND, LAND
.byte LAND, LAND, GRASS, TREE, GRASS, GRASS, GRASS, LAND, ROAD_V, LAND
.byte WATER_W, WATER, WATER, WATER, WATER_E, LAND, STONE, STONE, LAND, LAND
.byte LAND, LAND, TREE, GRASS, GRASS, GRASS, TREE, LAND, ROAD_V, LAND
.byte WATER_SW, WATER_S, WATER_S, WATER_S, WATER_SE, LAND, LAND, LAND, LAND, LAND
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, ROAD_V, LAND
.byte LAND, LAND, LAND, LAND, LAND, ROAD_SE, ROAD_H, ROAD_H, ROAD_SW, LAND
.byte LAND, ROAD_H, ROAD_H, ROAD_H, ROAD_H, ROAD_H, ROAD_H, ROAD_H, ROAD_X, ROAD_H
.byte ROAD_H, ROAD_H, ROAD_H, ROAD_H, ROAD_H, ROAD_X, ROAD_H, ROAD_H, ROAD_X, LAND
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, ROAD_V, LAND
.byte LAND, LAND, LAND, LAND, LAND, ROAD_V, LAND, LAND, ROAD_V, LAND
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, ROAD_V, LAND
.byte LAND, LAND, LAND, LAND, LAND, ROAD_NE, ROAD_H, ROAD_H, ROAD_NW, LAND
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND
.byte LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND, LAND
TEST_PANEL_SIZE = * - test_panel
.assert TEST_PANEL_SIZE = TEST_PANEL_WIDTH * 12, error, "Test panel size"

Laddar…
Avbryt
Spara

Powered by TurnKey Linux.