mirror of
https://github.com/pret/pmd-sky.git
synced 2026-10-02 07:08:09 -05:00
Decomp GetAppointedLeaderMemberIdx and sub_02056914
Decompile the last two accessors of this cluster from asm/main_02055894.s. Both resolve the appointed leader through the roster region of team_member_table: they read the active team from active_team, index the three number_active_team_members fields by it, and use that value to index active_roster_member_idxs. GetAppointedLeaderMemberIdx returns the resulting member index, or -1 when the first read is -1. sub_02056914 is its pointer counterpart, returning &members[index] or NULL when either read is -1 -- the same index/pointer pairing as GetHeroMemberIdx and GetHero. Each sits in the middle of asm/main_02055894.s and is not adjacent to the other, so each extraction splits the file: the trailing functions move verbatim into asm/main_020568DC.s and asm/main_02056960.s, the affected .inc files are regenerated, and main.lsf gains the four objects. GetAppointedLeaderMemberIdx returns u32, consistent with the other MemberIdx functions in this cluster. Its prototype and sub_02056914's move out of main_02064FFC.h, where they were declared while their callers were decompiled, into the new headers; main_02064FFC.h now includes those. sub_02065050 and sub_0206549C call them and were rebuilt to confirm the u32 change leaves both byte-identical. The three number_active_team_members fields are separate scalars in common.h but are indexed here as an array, which is what the asm does; the expression relies on them being contiguous, which the struct layout guarantees. No new names are introduced. struct team_member_table, struct ground_monster, their fields and TEAM_MEMBER_TABLE_PTR all already exist in the tree, and both function labels were already present. 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>
This commit is contained in:
@@ -1,77 +1,22 @@
|
||||
#pragma once
|
||||
.public AddMoneyCarried
|
||||
.public AddSimpleObjToOam
|
||||
.public CleanStickyItemsInBag
|
||||
.public CopyAndInterleaveWrapper
|
||||
.public CopyTacticString
|
||||
.public Debug_Print0
|
||||
.public DirectoryFileMngr_OpenDirectoryFile
|
||||
.public EnableAllLearnableIqSkills
|
||||
.public FillPaletteInitInfo
|
||||
.public GetBaseDefensiveStat
|
||||
.public GetBaseFormCastformCherrimDeoxys
|
||||
.public GetBaseHp
|
||||
.public GetBaseOffensiveStat
|
||||
.public GetBodySize
|
||||
.public GetGameMode
|
||||
.public GetHeroMemberIdx
|
||||
.public GetItemAtIdx
|
||||
.public GetItemMoveId16
|
||||
.public GetMainCharacter1MemberIdx
|
||||
.public GetMainCharacter2MemberIdx
|
||||
.public GetMainCharacter3MemberIdx
|
||||
.public GetMaxMembersAllowed
|
||||
.public GetMaxPp
|
||||
.public GetMoneyQuantity
|
||||
.public GetNameRaw
|
||||
.public GetPartnerMemberIdx
|
||||
.public GetShadowSize
|
||||
.public GetTeamMember
|
||||
.public GroundToDungeonMoveset
|
||||
.public HandleSir0Translation
|
||||
.public IsLevelResetDungeon
|
||||
.public IsMainCharacter
|
||||
.public IsSkyExclusiveDungeon
|
||||
.public IsValidTeamMember
|
||||
.public ItemZInit
|
||||
.public LoadObjPalette
|
||||
.public OBJ_GRAPHICS_CONTROLS_PTR
|
||||
.public RecolorNameString
|
||||
.public RecolorTeamMemberNameString
|
||||
.public RemoveHolderForItemInBag
|
||||
.public RemovePokeItemsInBag
|
||||
.public SetHolderForItemInBag
|
||||
.public SetPokemonJoined
|
||||
.public ShuffleHiddenPower
|
||||
.public StrcmpMonsterName
|
||||
.public StrncpyName
|
||||
.public StrncpySimple
|
||||
.public StrncpySimpleNoPadSafe
|
||||
.public TEAM_MEMBER_TABLE_PTR
|
||||
.public UnloadFile
|
||||
.public _020A3350
|
||||
.public _020A336C
|
||||
.public _020A3398
|
||||
.public _020A33B8
|
||||
.public _020A33D4
|
||||
.public _020A340C
|
||||
.public _020A343C
|
||||
.public _020A344C
|
||||
.public _020A3450
|
||||
.public _020A3468
|
||||
.public _020AFC28
|
||||
.public _022B5788
|
||||
.public _022B578C
|
||||
.public sub_0200FA0C
|
||||
.public sub_0204E584
|
||||
.public sub_02052CF4
|
||||
.public sub_02052E2C
|
||||
.public sub_020530D4
|
||||
.public sub_02053174
|
||||
.public sub_0205349C
|
||||
.public sub_020534BC
|
||||
.public sub_02053D1C
|
||||
.public sub_02053F10
|
||||
.public sub_02055410
|
||||
.public sub_02055474
|
||||
.public sub_020554D8
|
||||
|
||||
2
asm/include/main_020568DC.inc
Normal file
2
asm/include/main_020568DC.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
.public TEAM_MEMBER_TABLE_PTR
|
||||
80
asm/include/main_02056960.inc
Normal file
80
asm/include/main_02056960.inc
Normal file
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
.public AddMoneyCarried
|
||||
.public AddSimpleObjToOam
|
||||
.public CheckTeamMemberIdx
|
||||
.public CleanStickyItemsInBag
|
||||
.public CopyAndInterleaveWrapper
|
||||
.public CopyTacticString
|
||||
.public Debug_Print0
|
||||
.public DirectoryFileMngr_OpenDirectoryFile
|
||||
.public FillPaletteInitInfo
|
||||
.public GetActiveTeamMember
|
||||
.public GetAppointedLeaderMemberIdx
|
||||
.public GetBaseFormCastformCherrimDeoxys
|
||||
.public GetBodySize
|
||||
.public GetGameMode
|
||||
.public GetHeroMemberIdx
|
||||
.public GetItemAtIdx
|
||||
.public GetItemMoveId16
|
||||
.public GetMainCharacter1MemberIdx
|
||||
.public GetMainCharacter2MemberIdx
|
||||
.public GetMainCharacter3MemberIdx
|
||||
.public GetMaxMembersAllowed
|
||||
.public GetMaxPp
|
||||
.public GetMoneyQuantity
|
||||
.public GetPartnerMemberIdx
|
||||
.public GetShadowSize
|
||||
.public GetTeamMember
|
||||
.public GroundToDungeonMoveset
|
||||
.public HandleSir0Translation
|
||||
.public IsLevelResetDungeon
|
||||
.public IsMainCharacter
|
||||
.public IsMonsterIdInNormalRange
|
||||
.public IsSkyExclusiveDungeon
|
||||
.public IsValidTeamMember
|
||||
.public ItemZInit
|
||||
.public LoadObjPalette
|
||||
.public OBJ_GRAPHICS_CONTROLS_PTR
|
||||
.public RecolorNameString
|
||||
.public RecolorTeamMemberNameString
|
||||
.public RemoveHolderForItemInBag
|
||||
.public RemovePokeItemsInBag
|
||||
.public SetHolderForItemInBag
|
||||
.public ShuffleHiddenPower
|
||||
.public StrncpySimpleNoPadSafe
|
||||
.public TEAM_MEMBER_TABLE_PTR
|
||||
.public TryAddMonsterToActiveTeam
|
||||
.public UnloadFile
|
||||
.public _020A336C
|
||||
.public _020A3398
|
||||
.public _020A33B8
|
||||
.public _020A33D4
|
||||
.public _020A340C
|
||||
.public _020A343C
|
||||
.public _020A344C
|
||||
.public _020A3450
|
||||
.public _020A3468
|
||||
.public _020AFC28
|
||||
.public _022B578C
|
||||
.public sub_0200FA0C
|
||||
.public sub_0204E584
|
||||
.public sub_02052E2C
|
||||
.public sub_020530D4
|
||||
.public sub_02053174
|
||||
.public sub_0205349C
|
||||
.public sub_020534BC
|
||||
.public sub_02053D1C
|
||||
.public sub_02055410
|
||||
.public sub_02055474
|
||||
.public sub_020554D8
|
||||
.public sub_020559D8
|
||||
.public sub_02056228
|
||||
.public sub_02056318
|
||||
.public sub_02056410
|
||||
.public sub_02056460
|
||||
.public sub_020564B0
|
||||
.public sub_02056504
|
||||
.public sub_02056554
|
||||
.public sub_020565F4
|
||||
.public sub_020566C4
|
||||
.public sub_020568DC
|
||||
2723
asm/main_02055894.s
2723
asm/main_02055894.s
File diff suppressed because it is too large
Load Diff
23
asm/main_020568DC.s
Normal file
23
asm/main_020568DC.s
Normal file
@@ -0,0 +1,23 @@
|
||||
.include "asm/macros.inc"
|
||||
.include "main_020568DC.inc"
|
||||
|
||||
.text
|
||||
|
||||
arm_func_start sub_020568DC
|
||||
sub_020568DC: ; 0x020568DC
|
||||
ldr r1, _02056910 ; =TEAM_MEMBER_TABLE_PTR
|
||||
mvn r3, #0
|
||||
ldr r2, [r1]
|
||||
add r1, r2, r0, lsl #1
|
||||
add r1, r1, #0x9800
|
||||
ldrsh r1, [r1, #0x50]
|
||||
cmp r1, r3
|
||||
addne r0, r2, r0, lsl #3
|
||||
addne r0, r0, r1, lsl #1
|
||||
addne r0, r0, #0x9800
|
||||
ldrnesh r3, [r0, #0x56]
|
||||
mov r0, r3
|
||||
bx lr
|
||||
.align 2, 0
|
||||
_02056910: .word TEAM_MEMBER_TABLE_PTR
|
||||
arm_func_end sub_020568DC
|
||||
2665
asm/main_02056960.s
Normal file
2665
asm/main_02056960.s
Normal file
File diff suppressed because it is too large
Load Diff
6
include/main_020568A4.h
Normal file
6
include/main_020568A4.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef PMDSKY_MAIN_020568A4_H
|
||||
#define PMDSKY_MAIN_020568A4_H
|
||||
|
||||
u32 GetAppointedLeaderMemberIdx(void);
|
||||
|
||||
#endif
|
||||
8
include/main_02056914.h
Normal file
8
include/main_02056914.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef PMDSKY_MAIN_02056914_H
|
||||
#define PMDSKY_MAIN_02056914_H
|
||||
|
||||
struct ground_monster;
|
||||
|
||||
struct ground_monster* sub_02056914(void);
|
||||
|
||||
#endif
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "common.h"
|
||||
#include "main_02055770.h"
|
||||
#include "main_0205567C.h"
|
||||
#include "main_020568A4.h"
|
||||
#include "main_02056914.h"
|
||||
|
||||
struct unk_02064F94 {
|
||||
u8 field_0x0[8];
|
||||
@@ -31,7 +33,6 @@ extern struct team_member_table *TEAM_MEMBER_TABLE_PTR;
|
||||
|
||||
void sub_0201E380(u8* a, u32* b, s16 c, s16 d);
|
||||
|
||||
int GetAppointedLeaderMemberIdx(void);
|
||||
int OverlayIsLoaded(s32 overlay_id);
|
||||
int ov11_022E96E4(void);
|
||||
int GetUnitNpcIds(void* buf);
|
||||
@@ -39,7 +40,6 @@ int GetAdventureNpcIds(void* buf);
|
||||
int sub_02055410(int a);
|
||||
int sub_02055474(int a);
|
||||
int sub_020554D8(int a);
|
||||
struct ground_monster* sub_02056914(void);
|
||||
|
||||
void sub_02064F94(struct unk_02064F94* a, u32* data, int count);
|
||||
void sub_02064FE4(struct unk_02064F94* a, struct unk_02064FE4* b);
|
||||
|
||||
4
main.lsf
4
main.lsf
@@ -155,6 +155,10 @@ Static main
|
||||
Object src/main_0205567C.o
|
||||
Object src/main_02055770.o
|
||||
Object asm/main_02055894.o
|
||||
Object src/main_020568A4.o
|
||||
Object asm/main_020568DC.o
|
||||
Object src/main_02056914.o
|
||||
Object asm/main_02056960.o
|
||||
Object src/main_02058C3C.o
|
||||
Object asm/main_02058C4C.o
|
||||
Object src/main_02058CD8.o
|
||||
|
||||
14
src/main_020568A4.c
Normal file
14
src/main_020568A4.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "main_020568A4.h"
|
||||
#include "common.h"
|
||||
|
||||
extern struct team_member_table *TEAM_MEMBER_TABLE_PTR;
|
||||
|
||||
u32 GetAppointedLeaderMemberIdx(void)
|
||||
{
|
||||
struct team_member_table *t = TEAM_MEMBER_TABLE_PTR;
|
||||
s16 count = (&t->number_active_team_members_main)[t->active_team];
|
||||
if (count == -1) {
|
||||
return -1;
|
||||
}
|
||||
return t->active_roster_member_idxs[count];
|
||||
}
|
||||
15
src/main_02056914.c
Normal file
15
src/main_02056914.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "main_02056914.h"
|
||||
#include "common.h"
|
||||
|
||||
extern struct team_member_table *TEAM_MEMBER_TABLE_PTR;
|
||||
|
||||
struct ground_monster* sub_02056914(void)
|
||||
{
|
||||
struct team_member_table *t = TEAM_MEMBER_TABLE_PTR;
|
||||
s16 count = (&t->number_active_team_members_main)[t->active_team];
|
||||
s16 idx;
|
||||
if (count == -1 || (idx = t->active_roster_member_idxs[count]) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
return &t->members[idx];
|
||||
}
|
||||
Reference in New Issue
Block a user