Skip to content

docs: Comprehensive documentation — Fighter, SysDolphin Engine & Items (~19,000 lines) - #3591

Closed
beammeupscottyyy wants to merge 69 commits into
doldecomp:masterfrom
beammeupscottyyy:master
Closed

beammeupscottyyy wants to merge 69 commits into
doldecomp:masterfrom
beammeupscottyyy:master

Conversation

@beammeupscottyyy

Copy link
Copy Markdown
Contributor

Pull Request: Comprehensive Documentation — Fighter, Engine & Items

Summary

This PR adds ~19,000 lines of Doxygen documentation, inline comments, and local variable renames across 281 files in three major subsystems of the Melee decompilation. Zero functional code changes — all struct layouts, function signatures, control flow, global symbols, and macros are preserved exactly as-is.

The goal is to make the decompiled source immediately readable and useful for modders, researchers, and contributors by explaining what the code does in gameplay terms rather than just what the assembly does.


Changes by Module

1. Fighter System (src/melee/ft/) — 74 files, +7,394 / −2,177

Core Engine Files (23 .c / 3 .h files)

Every core source file in the Fighter module has been annotated with:

  • Doxygen function headers (@brief, @param, @return, @details) explaining gameplay mechanics
  • Local variable renames (e.g. sp48 → spark_pos, bool1 → damaged_bool, arg3 → ref_gobj)
  • Inline comments documenting Smash-specific constants and formulas

Key files documented:

  • fighter.c — The heart of the engine: Fighter_ChangeMotionState (action state machine), 15 priority-ordered procHitlag/procAnim/procInput/procUpdate/procMap frame callbacks, hitlag SDI, L-cancel detection (7f window), hitstun formula (KB × 0.4), crouch cancel (0.67× multiplier)
  • ftaction.c — Subaction bytecode interpreter and state transition logic
  • ftcommon.c — Ground acceleration, aerial drift, gravity, fastfall, grab mechanics
  • ftcoll.c — Hitbox/hurtbox capsule collision detection
  • ftcmdscript.c — CPU command script interpreter and input VM
  • ftdynamics.c — Secondary bone physics (cape, hair cloth simulation)
  • ftcliffcommon.c — Ledge grab mechanics (regrab cooldown, snap positions, getup options)
  • ftcamera.c, ftparts.c, ftcolanim.c, ftdata.c, ftlib.c, ftanim.c, and 10 more

Core Headers (3 files)

  • forward.h — FighterKind enum with English character names, FtMoveId with fighting game terminology (jab, f-tilt, up-smash, nair, etc.), MotionFlags bitmask documentation
  • types.h — Full Fighter struct (every field annotated), ftCommonData (PlCo.dat globals), ftCo_DatAttrs (per-character attributes: walk speed, dash speed, gravity, weight, jump height)
  • fighter.h — API declarations, Fighter_804D651C metal modifiers, Fighter_804D6520 bunny hood modifiers, Fighter_804D6524 mushroom scale modifiers

Character-Specific @todo Resolutions (6 files)

Resolved upstream @todo Proper state name tags by reverse-engineering motion state variables:

  • Samus (ftSamus/types.h): unk2 → speciallw, unk5 → specialhi (Screw Attack, Bomb, Charge Shot)
  • Donkey Kong (ftDonkey/types.h): unk5 → cargo_turn, unk7 → cargo_jump, unk8 → cargo_wait
  • Bowser (ftKoopa/types.h): unk1 → specials_cmd_grab (Koopa Klaw)
  • Pikachu (ftPikachu/types.h): unk2 → specialn, unk3 → specials (Thunder Jolt, Skull Bash)
  • Ness (ftNess/ftness.h): Fixed Doxygen formatting tags

Stale @todo Removals (2 files)

  • ftCo_AppealS.h — Removed @todo enum params (already resolved)

2. SysDolphin Engine (src/sysdolphin/baselib/) — 57 files, +7,807 / −2,263

Complete Doxygen annotation of HAL Laboratory's SysDolphin rendering engine:

File Component Key Mechanics Documented
jobj.c/h Joint Object Skeletal bone hierarchy, transform matrix computation, billboarding, 2-bone analytical IK solver (Law of Cosines), envelope skinning
cobj.c/h Camera Object GX projection/modelview matrices, perspective params, fog, viewport scissor
dobj.c/h Display Object Renderable mesh nodes, material blend mode classification (opaque/XLU/alpha-test)
mobj.c/h Material Object Texture/color setup, TEV stage configuration, toon shading
pobj.c/h Polygon Object Vertex geometry, rigid/envelope/shape-anim skinning, GX display lists
tobj.c/h Texture Object Multi-texturing, wrap/filter modes, texcoord generation, TEV blending
aobj.c/h Animation Object Keyframe interpolation (constant/linear/hermite), playback rate, looping
fobj.c/h Frame Object Variable-length bitstream decoding, fixed-point quantization, cubic Hermite spline evaluation
lobj.c/h Light Object Point/directional/spot/ambient lights, GX hardware light configuration
robj.c/h Constraint Object IK effectors, angular limits, position targets
gobj.c/h Game Object Universal entity base class, priority-ordered process callbacks
gobjproc.c/h GObj Process 2D scheduling grid (s_link × p_link), frame cycle parity, group pause masks
gobjgxlink.c/h GObj GX Link Render queue sorting, multi-pass pipeline (opaque → XLU → shadow)
gobjplink.c/h GObj Priority Priority-linked entity lists, insertion strategies
displayfunc.c/h Display Dispatch Scene graph traversal, Z-list merge sort for translucent objects, billboard matrix computation
controller.c/h Controller GameCube pad polling, deadzone clamping, analog-to-digital macro conversion
archive.c/h DAT Archive In-place pointer relocation, public symbol lookup, external reference patching
class.c/h Class System C-based OOP with single inheritance, VMTs, RTTI (instanceof), bucketed piece allocator
axdriver.c/h Audio Driver DSP voice allocation, streaming, pitch/volume control
texp.c/h TEV Expression Texture expression tree compiler for GX TEV stages
bytecode.c/h Bytecode VM Stack-based interpreter with 60+ opcodes (arithmetic, trig, PRNG, conditionals)
objalloc.c/h Memory Pools Fixed-size block allocator with free-list recycling
shadow.c/h Shadow System Circular floor shadow projection beneath entities
video.c/h Video System GX framebuffer (EFB/XFB), V-sync retrace, display resolution
random.c/h PRNG Linear Congruential Generator (multiplier: 214013, increment: 2531011)

3. Items System (src/melee/it/) — 20 files, +3,244 / −1,290

File Component Key Mechanics Documented
types.h Item Struct All fields of the 4,044-byte Item struct: velocity pipeline, ECB collision, 4 hitbox capsules, 2 hurtbox capsules, state machine, timers, ammo, owner/victim tracking, script VM state
item.c/h Core Lifecycle Item initialization, state transitions, memory allocation, physics pipeline
itcoll.c/h Entity Collision Item-vs-item clanking, hitbox-vs-hurtbox, knockback formula (0.01 × bks × ...), elemental hit effects, damage staling
itgroundcoll.c/h Map Collision ECB math, ground/wall/ceiling detection, bounce dampening thresholds
ithitbox.c/h Hitboxes Offensive hitbox generation, position tracking, damage scaling
itspawn.c/h Spawning Weighted random item selection (bisection search), container drop tables, Master Ball restrictions
itdraw.c/h Rendering JObj tree dispatch, camera shake offsets for held items, debug hitbox visualization
itmaplib.c/h ECB Queries Item-to-map collision interface, edge/ledge detection, slope terrain
itmaterial.c/h Material FX Starman flashing, metal state, TEV color register allocation
itzako.c/h Wireframes Fighting Wireframe knockback, camera offsets, rare item drops

Stale @todo Removal

  • itlinkarrow.c — Removed @todo replace with enum names (already used It_Kind_Link_Arrow etc.)

4. Progress Tracker


What This Does NOT Change

Important

  • Zero changes to function signatures, struct layouts, or memory offsets
  • Zero changes to control flow, conditional logic, or arithmetic
  • Zero changes to global variables, macros, or #include directives
  • Zero changes to .rodata string literals (preserves HSD_ASSERT stringification)
  • All changes are comments-only and local variable renames (stack variables with no ABI impact)

This PR is safe to merge without any risk of breaking matching.


Motivation

The Melee decompilation is an incredible technical achievement, but the raw decompiled output is dense and difficult to navigate for newcomers. This PR bridges the gap between "what the assembly does" and "what happens in the game" by:

  1. Explaining Smash mechanics — Hitstun formulas, L-cancel windows, SDI displacement, crouch cancel multipliers, ledge regrab cooldowns
  2. Naming the unnamed — Converting unk5, sp48, var_r31 into meaningful identifiers like cargo_jump, spark_pos, curr_jobj
  3. Documenting the engine — HAL's SysDolphin is a full 3D engine with its own OOP system, scene graph, animation pipeline, and GPU abstraction — now all documented
  4. Resolving upstream TODOs — Addressed @todo Proper state name tags for Samus, DK, Bowser, and Pikachu by reverse-engineering their motion state variables

Testing

  • clang -fsyntax-only passes on all modified files (0 errors)
  • git diff --check confirms no whitespace issues
  • No compilation testing was performed (requires original GameCube ISO for byte-matching verification)

… move IDs

- Added file header with ft module description
- Documented all 34 FighterKind values with English character names
- Documented all 32 MotionFlags with gameplay effects during state transitions
- Documented all 54 Fighter_Part skeleton bone names
- Documented all 93 FtMoveId attack IDs in fighting game terminology
- Added Kirby copy ability mappings for all 26 characters
- Explained SmashState charging (60-frame window, 1.367x max damage)
- Documented FIGHTERVARS_SIZE, ledge catch directions, GroundOrAir enum
…structs

- Added file header with fighter module overview
- Documented 40 core functions with Doxygen comments
- Documented all 15 GObj process callback priorities (hitlag→camera→player)
- Explained Fighter_ChangeMotionState — the central state machine function
- Documented modifier structs: Metal Box, Bunny Hood, Mushroom Scale effects
- Documented CPU decision tables, stale move queue, item swing speed tables
- Explained hitstun formula (knockback * 0.4 frames)
- Added CLEANUP_PROGRESS.md tracker
…ter attrs

- Documented ftCommonData: deadzones, shield mechanics, SDI, crouch cancel
- Documented ftCo_DatAttrs: walk/dash/run speeds, gravity, weight, jump physics
- Documented Fighter struct: velocity vectors, animation state, damage tracking
- Documented dmg substruct: hit percent, knockback angle, incoming damage
- Documented shield properties, reflectors, grab pointers
- Documented all bitfield flags: IASA, fast fall, SDI, metal, invisibility
- Documented callbacks: physics, collision, damage, input polling
…te machine

- Documented 58 functions: opcode handlers, interpreter loops, state callbacks
- Explained MotionState table lookup (common vs character-specific states)
- Documented all 5 MotionState callbacks: anim_cb, input_cb, phys_cb, coll_cb, cam_cb
- Documented bytecode opcodes 0-58: control flow, hitboxes, IASA, throws, SFX
- Explained hitbox creation params: damage, BKB, KGB, Sakurai angle 361
- Documented IASA/FAF (opcode 23), jab window (29), rapid jab (30)
- Documented smash charge (opcode 56): 60-frame window, 1.367x max scaling
- Explained mid-animation entry and Ft_MF_UpdateCmd fast-forward
- Renamed decompiler variables to meaningful names in SFX handlers
…, grab

- Documented ground acceleration/deceleration formulas
- Documented dash/run physics with taper gain
- Documented fall physics: gravity, terminal velocity, fast fall
- Documented grab initiation and grab mash escape mechanics
- Explained self-movement from grounded velocity transfer
…ume system

- Documented 18 functions for character archive loading pipeline
- Explained PlXx.dat/PlXxNn.dat/PlXxAJ.dat file hierarchy
- Documented ARAM vs Main RAM memory management for animations
- Documented Popo/Nana animation sharing and fallback system
- Documented fighter reference counting and slot allocation (6 slots)
- Documented costume list parsing and texture/material swap system
- Renamed 12 decompiler variables to meaningful names
- Documented CostumeListsForeachCharacter and gFtDataList dispatch arrays
…essors

- Documented fighter count, nearest opponent search, percent get/set
- Documented motion ID accessors and dead state checks
- Documented smash charge detection utilities
- Added file headers explaining ftlib's role as the fighter API layer
- Documented ftdynamics: secondary bone dynamics (hair, capes)
- Documented ftcmdscript: CPU Command Script Virtual Machine (bytecode ISA, opcodes)
- Documented ftcoll: knockback formula, clanking, phantom hits, shield pushing, simultaneous hits
- Updated CLEANUP_PROGRESS.md
@ribbanya ribbanya added naming documentation ai-assisted Utilizes a LLM to do the heavy lifting labels Sep 30, 2026
@ribbanya

Copy link
Copy Markdown
Collaborator

I'm sorry, but this is impossible to review. You should review precedent for AI naming passes (#2778 for example) and then split this into much smaller chunks with granular reasoning. We do not leverage AI to handle reviews for naming or documentation, so the bottleneck is maintainer availability.

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

Labels

ai-assisted Utilizes a LLM to do the heavy lifting documentation naming

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants