Skip to content

Conversation

@itsgrimetime
Copy link
Contributor

@itsgrimetime itsgrimetime commented Dec 30, 2025

Summary

Split from #2024 - focused PR for Icicle Mountain stage matches.

Methods

I spent a few hours in the dolphin debugger setting different breakpoints and tracing some of the contents in memory, mostly trying to figure out exactly how grIceMt_GroundVars.xF8[5] is used/what it is. I'm still not 100% sure (should become clearer with more matches in this file & a bit more debugging) but it seems to be related to keeping track of the set of platforms or breakable ice blocks that can spawn within a "row" of icicle mountain.

I've got some more matches queued up for this but wanted to keep this one from getting too big. There's a lot of goofy-feeling casts still I'd like to work out, but I've cleaned up all the pointer arithmetic in the original draft, and think I've landed on the right structs.

I also am a bit skeptical that there'd be two of these "GroundVars" structs - followup PR will focus on validating that and will probably come with a bit more certainty around naming/usage.

Match Icicle Mountain stage functions:
- grIceMt_801F85C4 (100%) - Stage update calling animation/state functions
- grIceMt_801F87FC (94.8%) - Loop over 5 GObj pointers calling grMaterial_801C8CDC

Note: grIceMt_801F87FC uses raw pointer math for array access at offset 0xF8.
This could be improved with proper struct field definitions if the array
purpose is understood.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@decomp-dev
Copy link

decomp-dev bot commented Dec 30, 2025

Report for GALE01 (ae5ac00 - 3eec275)

📈 Matched code: 47.86% (+0.01%, +216 bytes)

✅ 2 new matches
Unit Item Bytes Before After
main/melee/gr/gricemt fn_801F75EC +1 99.75% 100.00%
main/melee/gr/gricemt grIceMt_801FA728 +1 99.96% 100.00%
📈 13 improvements in unmatched functions
Unit Item Bytes Before After
main/melee/gr/gricemt grIceMt_801F686C +1587 18.26% 94.98%
main/melee/gr/gricemt grIceMt_801F8CDC +377 0.00% 99.45%
main/melee/gr/gricemt grIceMt_801F785C +200 26.34% 99.78%
main/melee/gr/gricemt grIceMt_801F87FC +83 0.00% 99.67%
main/melee/gr/gricemt grIceMt_801F75FC +68 76.66% 99.90%
main/melee/gr/gricemt grIceMt_801F85C4 +67 0.00% 99.12%
main/melee/gr/gricemt fn_801F91A8 +47 10.59% 80.00%
main/melee/gr/gricemt grIceMt_801F796C +43 33.31% 55.44%
main/melee/gr/gricemt grIceMt_801F98A8 +19 78.00% 91.08%
main/melee/gr/gricemt .sdata2 +11 7.14% 21.05%
main/melee/gr/gricemt .sdata +5 65.96% 74.47%
main/melee/gr/gricemt grIceMt_801F7728 0 68.36% 68.39%
main/melee/gr/gricemt grIceMt_801FA6D8 0 84.55% 84.60%

itsgrimetime and others added 3 commits December 29, 2025 19:16
Replace raw pointer math `(u8*)gp + 0xF8 + i * 4` with proper struct
field access `gp->gv.icemt.xF4[i + 1]`.

Also document the xF4 field's mixed-type usage:
- xF4[0] stores IceMountainParams*
- xF4[1-5] store HSD_GObj* for material updates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace raw pointer math `(u8*)gp + 0xF8 + i * 4` with proper struct
field access `gp->gv.icemt.xF4[i + 1]`.

Document xF4 field's mixed-type usage:
- xF4[0] stores IceMountainParams*
- xF4[1-5] store Item_GObj* for grMaterial cleanup

Add @todo for future renaming once row 5's purpose is understood.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This flag was inadvertently included in the grIceMt commit. The upstream
melee repo doesn't want this change - the --valid-syntax flag should only
be used in the local decomp.me instance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
itsgrimetime added a commit to itsgrimetime/melee that referenced this pull request Jan 2, 2026
- Add padding fields xE8 and xEC to grIceMt_GroundVars to fix struct offset
- Use proper struct access gp->gv.icemt.xF4[] instead of pointer arithmetic
- grIceMt_801F85C4: 99.1% (register allocation diff only)
- grIceMt_801F87FC: 99.7% (uses inline assignment for better codegen)

Addresses r-burns feedback on PR doldecomp#2027.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
itsgrimetime and others added 9 commits January 1, 2026 18:50
Addresses r-burns feedback on PR doldecomp#2027:
- Add padding fields xE8 and xEC to grIceMt_GroundVars for correct offset
- Use gp->gv.icemt.xF4[] struct access instead of pointer arithmetic
- grIceMt_801F85C4: 99.1% (register allocation diff only)
- grIceMt_801F87FC: 99.7% (uses inline assignment for better codegen)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Address review feedback: Split void* xF4[6] into IceMountainParams* xF4
and HSD_GObj* xF8[5] for clearer type semantics. Update accessor code
in grIceMt_801F85C4, grIceMt_801F87FC, and grIceMt_801F75FC accordingly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix xC4/xC6 types from HSD_GObj* to s16 (assembly shows sth/lha)
- Add xF0 padding field to align xF4 to correct offset
- Define IceMtRowData struct for grIm_803E4068 (12-byte elements)
- Improve grIceMt_801F75FC match using s16 pointer arithmetic (75.6%)

The xF4 memory area is interpreted as s16 indices during initialization
but later treated as pointers by other functions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add proper bitfield check at start of function - checks and clears
bit 6 of icemt2.xC4 (interpreted as byte flags) before doing cleanup.
Uses pointer array for sequential HSD_JObj access.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes typedef-redefinition error by moving the forward declaration
to gr/forward.h where other forward declarations live, avoiding
conflict with the full definition in gricemt.h.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The typedef is already in forward.h, so we only need the struct
definition here. Having both causes a "typedef redefinition" error
in C90/C99 mode.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Match grIceMt_801F8CDC to 93.4% (material item creation for Ice Mountain)
- Fix header signature mismatches for void-returning functions
- Define const floats locally instead of extern declarations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add padding fields xE8 and xEC to grIceMt_GroundVars to fix struct offset
- Use proper struct access gp->gv.icemt.xF4[] instead of pointer arithmetic
- grIceMt_801F85C4: 99.1% (register allocation diff only)
- grIceMt_801F87FC: 99.7% (uses inline assignment for better codegen)

Addresses r-burns feedback on PR doldecomp#2027.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@itsgrimetime itsgrimetime changed the title gr: Match grIceMt_801F85C4 and grIceMt_801F87FC gr: some Icicle Mountain functions Jan 2, 2026
The cherry-pick of 401daef57 inadvertently reverted the struct changes
from 4e1ab96. Restore the correct layout:
- Add u32 xF0 padding field
- Split void* xF4[6] into IceMountainParams* xF4 + HSD_GObj* xF8[5]

Update function code to use xF8[i] instead of xF4[i+1].

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
itsgrimetime and others added 9 commits January 2, 2026 11:10
… calls

- Implement grIceMt_801F785C using struct access where possible
- Use M2C_FIELD macro for xAC offset access
- Fix grIceMt_801FA0BC calls to pass address instead of value
- Both grIceMt_801F75FC and grIceMt_801F785C now use (int)&gp->gv.icemt.xC4

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Based on assembly analysis:
- Change IceMountainParams.xAC from HSD_GObj* to s16* (array of row indices)
- Change IceMtRowData.gobj to IceMtRowData.id (s32 identifier)
- Update grIceMt_801F785C to use xAC[0]/xAC[1] array access
- Fix fn_801F91A8 to properly read xAC[gp->xE0] (80% match, was 10.6%)
- Remove M2C_FIELD usage now that types are correct

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add missing 4th call to grIceMt_801F993C using field28
- Fix y_pos accumulation pattern to match target
- Update grIceMt_801F993C signature from UNK_PARAMS to (s32, s32) -> f32
- Remove volatile/void workaround for field28 since it's now used
- Move grIm_804DB570 extern to header

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…Vars

The xF4 field was incorrectly typed as IceMountainParams* but is never
dereferenced as a pointer. Analysis shows it's used as an s16 array
for slot initialization, with indices 0-5 overflowing into adjacent xF8.

Changes:
- types.h: IceMountainParams* xF4 -> s16 xF4[2]
- gricemt.c: Replace pointer arithmetic with clean array access

grIceMt_801F75FC now matches at 99.9% (was 89.2% with pointer arithmetic).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The function returns -1 as a sentinel pointer value. Cast through s32
(same size as pointer) to avoid -Wint-to-pointer-cast warning while
preserving the correct return value.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace M2C_FIELD offset access with proper struct array indexing:
- archive->unk4->unk8[7].unk0 instead of M2C_FIELD(..., 0x16C)
- Use string literals for __assert instead of char pointer math

Match improved from 93.08% to 99.45%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants