Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

13KB

Stonehold 64 - Specification

Approved by Daniel Covington on 2026-11-26. Changes to this file follow AGENTS.md section 6.

Summary

An original colony-simulation game for the Commodore 64 in the fortress-building genre. The player does not control dwarves directly: they designate tiles to dig and a small crew of dwarves walks over and mines them on their own, revealing a randomly generated underground map. The view is a top-down tile map, drawn with an original custom character set, that scrolls over a world much larger than the screen.

Original idea, as given:

Dwarf Fortress clone

Smallest useful version: One randomly generated 128x128 underground level, three dwarves, a cursor (mouse, joystick or keyboard) to mark rock for digging; dwarves path to marked tiles and mine them, each mined tile yields one stone shown in a counter; the game runs in real time and can be paused.

First release

One randomly generated 128x128 underground level (soft rock, hard rock, a few caverns and a starting cave), shown through a scrolling 40x23 map view drawn with an original custom character set. The player marks rock tiles for digging with a Commodore 1351 mouse (the dig cursor sits under the pointer), a joystick in port 2 or the keyboard. Three autonomous dwarves pick marked tiles within about 32 tiles, walk there, and mine them; each mined tile becomes floor and adds one stone to a counter. Real-time with pause, SID sound effects, same game speed on PAL and NTSC.

In scope

  • Randomly generated 128x128 tile map with a visible seed, new layout each game
  • Scrolling 40x23 map view
  • Original custom character set for terrain, dwarves and cursor
  • Dig designation with a 1351 mouse, a joystick or the keyboard
  • Three autonomous dwarves with local pathfinding to designated tiles
  • Mining turns rock into floor and adds stone to a counter; hard rock takes longer
  • Real-time simulation with pause
  • SID sound effects

Out of scope

  • Food, drink, needs and moods
  • Building walls, doors or furniture
  • Stockpiles and hauling
  • Combat and enemies
  • More than one z-level
  • Saving and loading
  • Music

Targets

Target Machine / mode Display Video Artifact Expected behavior
c64 Commodore 64 VIC-II 40x25 text/graphics screen (C64, or C128 40-column) pal-ntsc build/stonehold-64.prg Autostarts to the Stonehold screen drawn with the custom character set: title on row 0, a map view on rows 1-23, status line (stone counter, seed, RUN/PAUSED) on row 24. Three dwarves move on their own to mine tiles the player marks with the mouse, joystick or keyboard.

Dual-target and mode notes

Single target.

Display notes

  • c64: VIC-II 40x25 screen. Screen RAM at $0400 by default.

Testing environment

  • Reference emulator: VICE (exact options in docs/toolchain.md).
  • Real hardware: Not requested for this release. VICE is the reference environment; real-hardware steps in docs/manual-tests.md are optional.

Requirements and acceptance criteria

Each criterion is observable. Criteria IDs (for example R1.2) are referenced by milestones and manual tests.

R1 - Original character set and screen layout (must)

The game switches the VIC-II to an original custom character set: letters, digits and punctuation keep their usual shapes (copied from ROM at start), and new glyphs are defined for soft rock, hard rock, floor, marked rock, dwarf and cursor. Screen layout: row 0 title, rows 1-23 map view, row 24 status line.

Acceptance criteria:

  • [R1.1] After autostart in VICE x64sc (PAL) the screen appears within 5 seconds and row 0 reads ‘STONEHOLD 64’
  • [R1.2] Rock, floor, dwarves and marked rock are drawn with the game's own glyphs, visibly different from stock PETSCII graphics
  • [R1.3] Text on rows 0 and 24 is readable in the normal uppercase letter shapes

Capabilities: text-ui, custom-charset

R2 - Random map generation (must)

At the start of each game a 128x128 map is generated from a 16-bit seed: mostly soft rock, veins of hard rock, several random caverns, and an open starting cave near the centre where the three dwarves start. The same seed always gives the same map. The seed is shown on the status line.

Acceptance criteria:

  • [R2.1] Row 24 shows ‘SEED nnnnn’
  • [R2.2] Two new games (restart or reload) show different seeds and different map layouts
  • [R2.3] A fixed seed set in the debug build gives an identical map in two runs (compare screenshots)
  • [R2.4] The dwarves start on floor tiles inside an open cave

Capabilities: text-ui

R3 - Scrolling map view (must)

The 40x23 map view shows part of the 128x128 map. Moving the cursor within 2 tiles of a view edge scrolls the view one tile in that direction, stopping at the map borders. The view is redrawn by an assembly routine callable from C.

Acceptance criteria:

  • [R3.1] Holding a direction scrolls the map steadily until the map edge, where scrolling stops
  • [R3.2] All four map edges can be reached
  • [R3.3] A full-view redraw completes within one frame (border-colour timing bar check)

Capabilities: text-ui, custom-charset

R4 - Dig designation by keyboard and joystick (must)

Cursor keys or W/A/S/D move the dig cursor one tile; D marks or unmarks the rock tile under the cursor. A joystick in port 2 moves the cursor (with key repeat), and fire marks or unmarks. Floor tiles cannot be marked.

Acceptance criteria:

  • [R4.1] Pressing D on a rock tile changes it to the marked-rock glyph; pressing D again restores it
  • [R4.2] Pressing D on a floor tile changes nothing
  • [R4.3] The joystick in port 2 moves the cursor and fire marks/unmarks exactly like D

Capabilities: keyboard-input, joystick-input

R5 - Commodore 1351 mouse (must)

A 1351 mouse in control port 1 (proportional mode) moves a sprite pointer. The dig cursor is always the map tile under the pointer. The left button marks or unmarks that tile. Holding the pointer at a view edge scrolls the map. The mouse can be used at the same time as the joystick and keyboard.

Acceptance criteria:

  • [R5.1] With VICE 1351 mouse emulation on port 1, moving the mouse moves the pointer smoothly by the pixel
  • [R5.2] The highlighted dig cursor tile is always the tile under the pointer tip
  • [R5.3] Left click on a rock tile marks it; left click again unmarks it
  • [R5.4] Holding the pointer at the right edge scrolls the map right

Capabilities: mouse-1351, sprites

R6 - Autonomous dwarves (must)

Three dwarves act on their own. An idle dwarf searches (breadth-first, within about 32 tiles) for the nearest marked tile that has a walkable neighbour, walks there at 2-4 steps per second, and mines it: soft rock takes about 1 second, hard rock about 3 seconds. Two dwarves never claim the same tile. A marked tile no dwarf can reach stays marked.

Acceptance criteria:

  • [R6.1] Marking a rock tile next to the starting cave makes a dwarf walk to it and mine it within about 5 seconds
  • [R6.2] The mined tile changes to floor
  • [R6.3] With three adjacent marked tiles, the three dwarves mine different tiles
  • [R6.4] Hard rock visibly takes longer to mine than soft rock
  • [R6.5] A marked tile with no path to it stays marked and no dwarf freezes

Capabilities: text-ui

R7 - Stone counter (must)

Each mined tile adds one stone. The total is shown on row 24 as ‘STONE nnn’.

Acceptance criteria:

  • [R7.1] The game starts with ‘STONE 000’ on row 24
  • [R7.2] Each mined tile increments the counter by exactly 1

Capabilities: text-ui

R8 - Pause (must)

SPACE pauses and resumes the simulation. While paused, dwarves and mining stop, the status line shows ‘PAUSED’, and the player can still scroll and mark tiles.

Acceptance criteria:

  • [R8.1] SPACE shows ‘PAUSED’ on row 24 and all dwarves stop
  • [R8.2] Tiles can be marked while paused
  • [R8.3] SPACE again shows ‘RUN’ and the dwarves continue

Capabilities: keyboard-input

R9 - Sound effects (should)

SID effects: a short click when a tile is marked or unmarked, and a pick strike on each mining blow. No music.

Acceptance criteria:

  • [R9.1] A click is heard on each mark or unmark
  • [R9.2] Pick strikes are heard while a dwarf mines, and stop when mining ends or the game is paused

Capabilities: sid-sound

R10 - PAL and NTSC (must)

The game detects PAL or NTSC at start and scales its timers so that dwarf speed and mining time are the same in seconds on both.

Acceptance criteria:

  • [R10.1] In VICE with -pal and with -ntsc, a dwarf takes the same time (within 10%) to walk 10 tiles

Capabilities: text-ui

Design decisions

“Practical default” means the Foundry proposed it and the user accepted it without a specific preference. It can be changed later through AGENTS.md section 6.

Topic Decision Source
Controls Commodore 1351 mouse in control port 1 (proportional mode): a sprite pointer, the dig cursor is the tile under the pointer, the left button marks/unmarks, the pointer at a view edge scrolls the map. Joystick in port 2: move the cursor, fire marks/unmarks. Keyboard: cursor keys or W/A/S/D move, D marks/unmarks, SPACE pauses/resumes. All three can be used together. decided by user
Visuals Character mode with an original custom character set at $3800 (VIC bank 0, screen at $0400): codes 0-127 copied from the lower/upper-case ROM set so conio text (capital letters at screen codes 65-90) stays readable, codes 128+ hold the game's own glyphs (soft rock, hard rock, floor, marked rock, dwarf, cursor). Colours: rock brown, hard rock grey, floor dark grey, marked rock yellow, dwarves orange, cursor white, on a black background. The mouse pointer is hardware sprite 0. decided by user
Sound SID effects only: a mark/unmark click and a pick strike while mining. No music. decided by user
Persistence (save/load) None. Nothing is saved in the first release. not applicable
File formats None. A single PRG. not applicable
Peripherals Commodore 1351 mouse in control port 1; joystick in control port 2 (optional; keyboard works alone). No disk access after loading. decided by user
Timing and memory budgets Map 128x128 at one byte per tile (16 KB: tile type plus marked/claimed flags in the same byte). Pathfinding is a breadth-first search limited to a 65x65 window around the dwarf (about 4.2 KB scratch, shared by all dwarves, one search per frame at most). Dwarves move 2-4 steps per second. View redraw (40x23 tiles) in assembly within one frame. Input polled every frame. Program plus data must fit below $D000 with the charset at $3800. decided by user
Map generation 128x128 tiles from a visible 16-bit seed: mostly soft rock, veins of hard rock, several random caverns, a starting cave near the centre. Hard rock takes about three times as long to mine. decided by user
Language split C for game logic, map generation and pathfinding; ca65 assembly functions with C prototypes for the speed-critical parts (view redraw, frame wait, later anything profiling shows is too slow). decided by user

Required capabilities

  • text-ui: Text screens, menus and status lines (PRINT / conio / KERNAL CHROUT).
  • keyboard-input: Reading keys from the keyboard.
  • joystick-input: Reading a joystick in control port 1 or 2.
  • custom-charset: Redefined character sets.
  • sprites: VIC-II hardware sprites.
  • sid-sound: Sound effects or music through the SID.
  • mouse-1351: Commodore 1351 mouse in proportional mode in control port 1 (cc65 drivers c64_1351_mou / c128_1351_mou, or POT reads in assembly). VICE emulates it on control port 1.

Assumptions

ID Assumption Status
A1 cc65's statically linked 1351 driver (c64_1351_mou, mouse_install with mouse_def_callbacks) drives sprite 0 as the pointer and works alongside joystick reads on port 2. The Foundry verified (test brief mouse-1351-c) that the driver links and installs in VICE 3.10 with a 1351 on control port 1; pointer movement together with joystick and keyboard input is still to be checked by hand. unverified
A2 VICE emulates the 1351 on control port 1 with -controlport1device 3 (added to tools/run.ps1 and tools/smoke.ps1 automatically by the mouse-1351 capability). The host mouse must be grabbed with Alt+M (or -mouse) for the pointer to move. confirmed
A3 Memory map: screen $0400, custom charset $3800-$3FFF in VIC bank 0. Once the program (code, data, BSS including the 16 KB map) grows past $3800, the map or the charset must move (for example map at a fixed address above the program, or a custom ld65 config that reserves $3800-$3FFF and updating tools/build.ps1). The starter checks at run time that its BSS ends below $3800 and shows ‘MEMORY CLASH’ if not. unverified
A4 A breadth-first search over a 65x65 window, at most one search per frame, is fast enough that dwarves start walking within a second of a tile being marked. unverified
A5 Video standard is detected at start with get_tv(); timers are counted in frames and scaled for 50 Hz (PAL) and 60 Hz (NTSC). default
A6 VICE x64sc with default C64 model settings is a faithful reference for timing. default

Unresolved decisions

  • None. Every decision in this spec is settled.

Powered by TurnKey Linux.