mirror of
https://github.com/pret/pmd-sky.git
synced 2026-09-30 14:18:10 -05:00
Decompile GetHeroMemberIdx, GetPartnerMemberIdx, GetMainCharacter1MemberIdx, GetMainCharacter2MemberIdx and GetMainCharacter3MemberIdx from asm/main_02054E4C.s. Each returns the index of a TEAM_MEMBER_TABLE_PTR->members entry when that entry's is_valid bit is set, or -1 otherwise: hero is index 0, partner index 1, and the GetMainCharacter functions choose the index by game mode -- 2/3/4 during a special episode, 0/1/none otherwise. They are the index returning counterparts of the pointer accessors in the previous commit and merge into a new src/main_0205567C.c. The return type is u32. This matters: with a signed int return, the compiler recognises `valid ? 0 : -1` as the idiom -(!valid) and emits an arithmetic negate, but the target uses a conditional-move select. Under u32, -1 is 0xFFFFFFFF, the negate idiom no longer applies, and the compiler emits the select the target has. The distinction is only observable for hero, whose index is the constant 0; for the others the index is non-zero or runtime, so both signednesses produce the select. The whole family is typed u32 for consistency, and sub_02065050, which calls two of these, was rebuilt to confirm the type change leaves it byte-identical. No new names are introduced. struct team_member_table, struct ground_monster and TEAM_MEMBER_TABLE_PTR already exist in the tree, and the five function names were already labelled; this commit only fills in bodies. No comments are added to any pmd-sky file. Authored by Claude (Opus 4.8) under human direction. Confirmed by a matching build: build/pmdsky.us/pmdsky.us.nds: OK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
11 lines
244 B
C
11 lines
244 B
C
#ifndef PMDSKY_MAIN_0205567C_H
|
|
#define PMDSKY_MAIN_0205567C_H
|
|
|
|
u32 GetHeroMemberIdx(void);
|
|
u32 GetPartnerMemberIdx(void);
|
|
u32 GetMainCharacter1MemberIdx(void);
|
|
u32 GetMainCharacter2MemberIdx(void);
|
|
u32 GetMainCharacter3MemberIdx(void);
|
|
|
|
#endif
|