Tasks are tracked in the tasks/ directory. Each task is a Markdown file:
- Format:
NNN_short_name.md(e.g.,001_main_gameplay_loop.md) - Status values:
Todo,In Progress,Done,Blocked - Priorities: Adjusted by renumbering or noting in the task file
Workflow:
- Pick a task, change its status to
In Progress - Work on the task in
river-raid.ctl - If new tasks emerge (e.g., deeper documentation needed), create the next task with the next available number (e.g.
007_new_task.md) - Mark task
Donewhen acceptance criteria are met - Commit task file changes together with code changes
To see current tasks: ls tasks/
| Metric | Value |
|---|---|
| Documentation coverage | 16% (37/229 routines have descriptions) |
| Global variables | 75 (well-documented) |
| Constants defined | 100+ (good coverage) |
| Build status | Passing (byte-identical output) |
Goal 1 (reassemblable source) is complete. Goal 2 (document internal mechanics) is 16% complete.
These control overall game flow and execute millions of times per game session:
| Address | Name | Description | Priority |
|---|---|---|---|
| $5F91 | Main gameplay loop | Central state machine orchestrating all subsystems | Critical |
| $6136 | Collision dispatcher | Routes collision detections to appropriate handlers | Critical |
| $6BDB | NMI handler | Frame timing and interrupt-driven updates | Critical |
| $6BED | Process controls | Input → action → sound pipeline | Critical |
| $60A5 | Render plane/terrain | Top-level render orchestration | Critical |
| $683B | Island rendering | Core visual update system | Critical |
| System | Routines | Status |
|---|---|---|
| Input handling | $5FDA, $600A, $6039, $6068 | Undocumented |
| Enemy AI/spawning | $6FE6, $6FF6, $76AF, $76DA | Undocumented |
| Sound effects | 11 routines ($6C31-$8A02) | Undocumented |
| Bridge system | $68E9, $693C, $694D, $6927 | Partially documented |
| Terrain/islands | $696B, $6A4F, $6990, $6AA3 | Partially documented |
Terrain rendering pipeline, sprite rendering helpers, coordinate transformations, scroll/attribute updates.
Supporting functions, data transformations, specialized helpers.
From profiling data (river-raid.prof), the most executed code:
- $6859-$68C0 – Core rendering hot path (~300M+ executions)
- $5F91 – Main loop (~171M executions)
- $6136 – Collision dispatch (~54M executions)
- $6BED – Control processing (~43M executions)
- $683B – Island rendering (~38M executions)
These routines have minimal documentation despite being the most critical.
Document the six Tier 1 routines that form the game's backbone:
| Task | Address | Description |
|---|---|---|
| 001 | $5F91 | Main gameplay loop structure |
| 002 | $6136 | Collision detection dispatch mechanism |
| 003 | $6BDB | NMI handler and timing |
| 004 | $6BED | Control state processing |
| 005 | $60A5 | Render orchestration |
| 006 | $683B | Island/scroll system |
Deliverable: High-level understanding of game architecture.
Document major game subsystems:
- Input system pipeline (4 routines)
- Enemy spawning and AI (8+ routines)
- Sound effect system (11 routines)
- Bridge progression system (five routines)
- Terrain generation system (6+ routines)
Deliverable: Complete documentation of all major game features.
Document rendering and calculation routines:
- Sprite rendering pipeline ($8B1E, $8B3C, $8B70)
- Terrain rendering details
- Coordinate transformation operations
- Attribute/color update routines
- Scrolling mechanics
Deliverable: Algorithmic understanding sufficient for reimplementation.
Fill remaining gaps:
- Utility functions
- Edge cases and minor handlers
- Data structure documentation
- Cross-reference verification
Deliverable: 100% routine documentation coverage.
| Phase | Hours | Routines |
|---|---|---|
| Phase 1 | 5-10 | 6 |
| Phase 2 | 12-25 | 25 |
| Phase 3 | 15-30 | 60 |
| Phase 4 | 10-25 | 100 |
| Total | 42-90 | 192 |
All documentation should follow the patterns established in CLAUDE.md:
- Multi-paragraph N directives for complex algorithms
- Register annotations (I:, O:) for function parameters
- Cross-references using #R$XXXX format
- Game-level color constants (COLOR_PLAYER_1, COLOR_RIVER, etc.)
- Concise EXT_ATTR comments (AT row,col, INK COLOR, PAPER COLOR)
- Algorithm descriptions sufficient for higher-level reimplementation
- Data structure tables documented inline when first encountered
- Skip routines with unclear purposes rather than speculating
- All routines with clear purposes have D (description) blocks
- All hot-path routines have N (narrative) blocks explaining algorithms
- All data structures are documented when first encountered
- Cross-references are consistent and complete
- Someone unfamiliar with Z80 could understand the game logic
-
Priority ordering: Functional grouping (not execution frequency). Work through related routines together.
-
Depth vs breadth: Breadth first. Achieve complete shallow coverage before deep dives into complex algorithms.
-
Verification approach: Compare documented behavior against the actual disassembly code.
-
Data structures: Document as they emerge. When code references a data structure, document it immediately.
-
Unknown routines: Skip routines with unclear purposes. Do not speculate; only document what is understood.