Skip to content

Match cmMenuFixedController::init and update - #127

Open
vagnertxr wants to merge 1 commit into
doldecomp:mainfrom
vagnertxr:cm/menu-fixed-controller
Open

Match cmMenuFixedController::init and update#127
vagnertxr wants to merge 1 commit into
doldecomp:mainfrom
vagnertxr:cm/menu-fixed-controller

Conversation

@vagnertxr

Copy link
Copy Markdown

Completes and links sora/cm/cm_controller_menu_fixed.cpp.

Depends on Sammi-Husky/BrawlHeaders#66init only matches with gfCamera::TransformFlag's bitfields declared over u16, so that the flag accesses are halfword-wide. This PR does not bump the submodule; it needs that one merged first.

init was at 23%. Three things were wrong:

  • unkFA.m_flag2 is actually m_rotate; the target ORs 0x40, not 0x04.
  • The camera has to be held in a local. Indexing m_cameraManager->m_cameras[0] per statement reloads the manager every time.
  • m_rot is written through an 8-byte temporary, not a Vec3f. A Vec3f temporary forces a 32-byte frame in every position it can occupy, while the target's frame is 16.

The flag writes are split deliberately: setting m_flag7 through the mask keeps the original read live, so the following two writes chain off it. With all three written through the mask, mwcc folds (flags|0x82)|0x40 into flags|0xC2 and hoists it above the first store.

update was never written. It is storeDefault() behind the unk8 guard, then init(), then m_transformFlag and the call. Caching m_cameraManager in a local is what keeps the manager in one register across the inlined bodies.

fn_800A69AC is renamed to its mangled name, which follows from the existing virtual void update(float) declaration.

Verified: ninja reports 127 files OK.

Completes and links sora/cm/cm_controller_menu_fixed.cpp.

init was at 23%. Three things were wrong:

- unkFA.m_flag2 is actually m_rotate; the target ORs 0x40, not 0x04.
- The camera has to be held in a local. Indexing m_cameraManager->m_cameras[0]
  per statement reloads the manager every time.
- m_rot is written through an 8-byte temporary, not a Vec3f. A Vec3f
  temporary forces a 32-byte frame in every position it can occupy, while
  the target's frame is 16.

The flag writes are split deliberately: setting m_flag7 through the mask
keeps the original read live, so the following two writes chain off it. With
all three written through the mask, mwcc folds (flags|0x82)|0x40 into
flags|0xC2 and hoists it above the first store.

update was never written. It is storeDefault() behind the unk8 guard, then
init(), then m_transformFlag and the call. Caching m_cameraManager in a local
is what keeps the manager in one register across the inlined bodies.

fn_800A69AC is renamed to its mangled name, which follows from the existing
virtual void update(float) declaration.

Requires Sammi-Husky/BrawlHeaders#66: init only matches with
gfCamera::TransformFlag's bitfields declared over u16, so that the flag
accesses are halfword-wide.

Verified: `ninja` reports 127 files OK.

Co-Authored-By: Claude Opus 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.

1 participant