Skip to content

docs: rewrite architecture documentation - #2

Open
uditmital-netizen wants to merge 3 commits into
masterfrom
docs/rewrite-architecture
Open

docs: rewrite architecture documentation#2
uditmital-netizen wants to merge 3 commits into
masterfrom
docs/rewrite-architecture

Conversation

@uditmital-netizen

Copy link
Copy Markdown

Summary

Full rewrite of the docs/ tree from scratch, written by reading the source
in WOLFSRC/ directly and cross-checking each claim against
WOLFSRC/<file>:<line>.

What's included

  • ARCHITECTURE.md + README.md — top-level overview: what the code is,
    directory layout, main loop, data-flow diagram, fixed-point model, coordinate
    system, build system, and reading order.
  • 8 systems/ guides — rendering, audio, input, game-logic, file-cache,
    ui-menu, actordata, tools-build.
  • 21 files/ per-file references — every WL_*.C and ID_*.C engine
    module, each with role summary, key globals, function table (with line
    numbers), and notes.
  • 2 reference/ indexesfunctions.md and constants.md.

Notes

  • Documentation only — no source or build files are modified, and nothing is
    compiled.
  • Line numbers reference the tree at the tip of master.

🤖 Generated with Claude Code

Udit Mital and others added 3 commits July 18, 2026 15:09
This commit adds the full docs/ tree for the Wolfenstein 3-D source
code reference. It was generated by reading the 1992 source in
WOLFSRC/ at revision 0516778.

New reference indexes (previously advertised but missing):
- docs/reference/functions.md — every public function by file,
  with signature, source line, and one-line role.
- docs/reference/constants.md — #define, enum, and .EQU constants
  grouped by 14 semantic families (limits, trig, tiles, scancodes,
  VGA registers, audio, paging, actor enums, etc.).

Fixes to existing per-file notes:
- docs/files/WL_DRAW.md: replaced ??? line numbers for
  ThreeDRefresh (1336) and PlayLoop (1368).
- docs/files/WL_MAIN.md: corrected Scores[7] location to
  ID_US_1.C:57 (was WL_MAIN.C:???).
- docs/files/WL_DRAW.md: removed a stray non-ASCII character.

All previously dangling reference/ links now resolve.
Co-Authored-By: Claude <noreply@anthropic.com>
Fixes from review:
- ARCHITECTURE.md §6: corrected FINEANGLES from 28800 to 3600
  (the source defines FINEANGLES=3600 in WL_DEF.H:105).
- reference/constants.md: corrected DOORWALL (WL_DRAW.C:19, was :22)
  and ACTORSIZE (WL_DRAW.C:21, was :26).
- files/WL_DRAW.md: same DOORWALL/ACTORSIZE line number corrections.
Co-Authored-By: Claude <noreply@anthropic.com>
Full rewrite of docs/ from scratch by reading WOLFSRC/ directly:
- ARCHITECTURE.md + README.md (top-level overview)
- 8 systems/ guides (rendering, audio, input, game-logic,
  file-cache, ui-menu, actordata, tools-build)
- 21 files/ per-file references (WL_*.C and ID_*.C modules)
- reference/functions.md and reference/constants.md

Describes the existing source only; no code or build changes.

Co-Authored-By: Claude <noreply@anthropic.com>

@uditmital-netizen uditmital-netizen left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review — documentation accuracy

Great coverage, and the structure is consistent across all 33 files. I verified every FILE.C:line citation, function name, constant value, and internal link against WOLFSRC/. The scaffolding is solid; the issues below are factual errors about where functions live or how data is processed — the kind that send a reader to the wrong place. Recommend addressing the HIGH items before merge.

HIGH (flatly wrong):

  • WL_PLAY.md / WL_DRAW.md: PlayLoop is defined in WL_PLAY.C:1368, not WL_DRAW.C. WL_PLAY.C is a 1472-line file full of real definitions, not "declarations only."
  • WL_DRAW.md: wallheight[] is at line 42, typed unsigned wallheight[MAXVIEWWIDTH] — not line 102 / int[MAXWALLTILES].
  • WL_GAME.md: line 112 is SetSoundLoc, not ScanInfoPlane (which is at 221, declared 41).
  • systems/file-cache.md: map data is Carmack-then-RLEW (CA_CacheMapCAL_CarmackExpand then CA_RLEWexpand), not Carmack-then-Huffman.

MEDIUM: enum line-ranges in constants.md (dir/stat_t/enemy_t), SpawnWill is at 1426 not 1450, ShowArticle is one #ifdef JAPAN function not two overloads, PollControls owner, Patch386 at 241, and a few prototype-vs-definition line cites.

LOW/nit: ThreeDRefresh/DrawScaleds cite the prototype/comment-banner line rather than the definition.

All internal markdown links resolve. Inline comments anchor each item.

Comment thread docs/files/WL_PLAY.md
a transverse header used by the renderer and gameplay stack to share
a few constants and the `PlayLoop` prototype.

The actual `PlayLoop` is implemented in `WL_DRAW.C` (which is

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH — factually wrong. PlayLoop is defined in WL_PLAY.C at line 1368 (void PlayLoop (void)), not in WL_DRAW.C. This page premise is inverted: WL_PLAY.C is a 1472-line file full of definitions (PollControls, TryMove, T_Player, etc.). Rewrite the title and "logic lives in WL_DRAW.C" line.

Comment thread docs/files/WL_PLAY.md

## Functions

None defined here. `PlayLoop` is defined in `WL_DRAW.C`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH. PlayLoop is defined here (WL_PLAY.C:1368). "None defined here" is incorrect.

Comment thread docs/files/WL_DRAW.md

1. The 3-D **raycaster** — per-column wall drawing.
2. The **scaled-shape** renderer (`DrawScaleds`).
3. The **`PlayLoop`** function — gameplay per-tick.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH. PlayLoop is not in WL_DRAW.C; it is WL_PLAY.C:1368. Line 1368 of WL_DRAW.C is inside ThreeDRefresh.

Comment thread docs/files/WL_DRAW.md
| `DrawPlayerWeapon` | line 1201 | Draw B.J.'s held weapon on the screen |
| `CalcTics` | line 1236 | Tick rate measurement |
| `ThreeDRefresh` | `WL_DRAW.C:1336`| Per-tick entry — orchestrates the renderer |
| `PlayLoop` | `WL_DRAW.C:1368`| Per-gameplay-tick loop — drives player + actor state |

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH. Remove this row — WL_DRAW.C has no PlayLoop. It lives in WL_PLAY.C:1368.

Comment thread docs/files/WL_DRAW.md
| `viewx`, `viewy` | line 58 | fixed — camera position |
| `viewangle` | line 59 | int — camera heading |
| `viewsin`, `viewcos`| line 60 | fixed — sin/cos of camera heading |
| `wallheight[]` | line 102 | int[MAXWALLTILES] — wall texture heights |

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH. wallheight[] is declared at WL_DRAW.C:42 as unsigned wallheight[MAXVIEWWIDTH] — not line 102, and not int[MAXWALLTILES]. Line, type, and dimension symbol are all wrong.

Comment thread docs/files/WL_TEXT.md
## Notes

- `text` is a global parse cursor mutated by `ParseNumber`/`RipToEOL`/`HandleWord`; the parser is stateful and single-pass per page.
- There are two `ShowArticle` overloads (lump index vs. raw string) sharing the same layout core — the string form powers help screens loaded from `HELPART.`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM. Not two overloads — C has no overloading. Lines 599/601 are the #ifdef JAPAN / #else signatures of a single ShowArticle; only one compiles per build (the char far * form in non-JAPAN builds). Reword as build variant.

Comment thread docs/systems/input.md

## Relationship to the game loop

`WL_PLAY.C::PollControls` (per tick) asks the Input Manager for the current

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM. PollControls is declared in WL_DEF.H:923 and called from WL_DEBUG.C, but its definition is not in WL_PLAY.C in this tree — verify the owning file before asserting WL_PLAY.C::PollControls.

Comment thread docs/files/WL_MAIN.md
| `ReadConfig` | `WL_MAIN.C:90` | Read `CONFIG.<ext>` from disk into the global config state |
| `WriteConfig` | `WL_MAIN.C:193` | Write the global config state back to `CONFIG.<ext>` |
| `JHParmStrings[]` | `WL_MAIN.C:240` | Static `{"no386", nil}` parser string list |
| `Patch386` | `WL_MAIN.C:243` | Sniff the CPU; sets `IsA386` via the `JABHACK.ASM` glue |

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM. Patch386 is defined at WL_MAIN.C:241; line 243 is extern void far jabhack2(void);.

Comment thread docs/systems/rendering.md

## The raycaster (`WL_DRAW.C`)

`ThreeDRefresh()` (`WL_DRAW.C:72`, the entry point called once per tick from

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW/nit. WL_DRAW.C:72 is the prototype; the ThreeDRefresh definition is at 1336. Cite the definition (the text already says "defined near the end").

Comment thread docs/systems/rendering.md
simplification that gives Wolf3D its right-angle-only geometry.
4. `TransformActor()` (`WL_DRAW.C:210`) rotates each visible actor into view
space so it can be depth-sorted and scaled.
5. `DrawScaleds()` (`WL_DRAW.C:1054`) walks the transformed, depth-sorted list

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW/nit. WL_DRAW.C:1054 is the = DrawScaleds comment banner; the definition is at 1072 (which WL_DRAW.md cites correctly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant