Decomp IsEmptyString and four parent-menu accessors

Decompile from asm:

  IsEmptyString              0x0202A66C
  SetParentMenuState7        0x0202AAA8
  CloseParentMenu            0x0202AABC
  IsParentMenuActive         0x0202AB40
  CheckParentMenuField0x1A0  0x0202AB60

The four menu functions all resolve their window through GetWindowContents,
which src/overlay_10_022BCC60.c already declares as returning void *. What it
returns has fields at 0x198, 0x19C and 0x1A0 and no existing type, so it is
introduced as struct unk_0202AAA8, named for the lowest-addressed function that
uses it, with placeholder fields.

The struct and the GetWindowContents prototype live in include/main_0202AAA8.h
and are included by the second source rather than repeated in it. Two copies of
a struct definition in two translation units is the same drift risk as two
prototypes, and nothing in the build would report them disagreeing.

Return widths differ across these and are read off the target. IsEmptyString and
CheckParentMenuField0x1A0 end in and r0, r0, #0xff, so they return bool8;
IsParentMenuActive does not, so it is word-sized despite reading like a
predicate.

IsParentMenuActive also needed its state field bound to a local. Comparing
menu->field_0x19C against two values inline emits two loads; the target loads it
once.

No comments are added to any pmd-sky file.

Authored by Claude (Opus 5) under human direction. Confirmed by a matching
build: build/pmdsky.us/pmdsky.us.nds: OK.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
cecilarmitais
2026-08-16 23:59:35 -07:00
parent 6f907c680c
commit 3fc19ec702
15 changed files with 12558 additions and 12490 deletions

View File

@@ -1,49 +1,6 @@
#pragma once
.public _0209AE34
.public _0209AE44
.public _0209AEE0
.public _0209AEEC
.public _0209AEF4
.public _0209AEFC
.public _0209AF04
.public _0209AF6C
.public _0209AFC4
.public _0209AFDC
.public _0209AFE4
.public _0209AFEC
.public _0209AFF4
.public _0209AFFC
.public _0209B004
.public _0209B00C
.public _0209B014
.public _0209B01C
.public _0209B024
.public _0209B02C
.public _0209B034
.public _0209B03C
.public _0209B044
.public _0209B04C
.public _0209B054
.public _0209B05C
.public _0209B064
.public _0209B06C
.public _0209B074
.public _0209B07C
.public _0209B084
.public _020AFDAC
.public _s32_div_f
.public ADVANCED_MENU_DEFAULT_WINDOW_PARAMS
.public ADVANCED_TEXT_BOX_DEFAULT_WINDOW_PARAMS
.public ALERT_BOX_DEFAULT_WINDOW_PARAMS
.public AnalyzeText
.public AppendStandardStringToMission
.public AREA_NAME_BOX_DEFAULT_WINDOW_PARAMS
.public COLLECTION_MENU_DEFAULT_WINDOW_PARAMS
.public CONTROLS_CHART_DEFAULT_WINDOW_PARAMS
.public DEBUG_MENU_DEFAULT_WINDOW_PARAMS
.public DeleteWindow
.public DIALOGUE_BOX_DEFAULT_WINDOW_PARAMS
.public DrawTextInWindow
.public CreateParentMenuInternal
.public CreateTextBox
.public FileClose
.public FileRom_HandleOpen
.public FileRom_HandleRead
@@ -51,88 +8,13 @@
.public FileRom_InitDataTransfer
.public FileRom_StopDataTransfer
.public FileRom_Veneer_FileInit
.public GetHeldButtons
.public GetPressedButtons
.public GetReleasedStylus
.public GetStringFromFileVeneer
.public GetWindow
.public GetWindowContents
.public GetWindowRectangle
.public InitPortraitParams
.public InitPreprocessorArgs
.public IsTouchScreenNotOff
.public IsValidPortrait
.public KeyWaitInit
.public LoadPortrait
.public MemAlloc
.public MemcpySimple
.public MemFree
.public MemZero
.public MENU_CONTROL_PTR
.public NewWindowScreenCheck
.public NULL_OVERLAY_LOAD_ENTRY
.public OPTIONS_MENU_DEFAULT_WINDOW_PARAMS
.public PARENT_MENU_DEFAULT_WINDOW_PARAMS
.public PlaySeVolumeWrapper
.public PORTRAIT_BOX_DEFAULT_WINDOW_PARAMS
.public PreprocessString
.public PreprocessStringFromId
.public SCROLL_BOX_DEFAULT_WINDOW_PARAMS
.public SIMPLE_MENU_DEFAULT_WINDOW_PARAMS
.public strcpy
.public sub_01FF9128
.public sub_01FF929C
.public sub_020063A0
.public sub_020063F4
.public sub_02006BFC
.public sub_02006C8C
.public sub_02020B60
.public sub_02020BC4
.public sub_02021F44
.public sub_0202202C
.public sub_02025D50
.public sub_02025D90
.public sub_02025E84
.public sub_0202613C
.public sub_0202614C
.public sub_02026174
.public sub_02026184
.public sub_02026194
.public sub_020261A4
.public sub_020261B4
.public sub_020261C4
.public sub_020261D4
.public sub_020261E4
.public sub_020261F4
.public sub_02026204
.public sub_02026358
.public sub_020263C8
.public sub_02026428
.public sub_02026594
.public sub_020265A8
.public UpdateWindow
.public _0209AE34
.public _0209AE44
.public _020AFDAC
.public sub_02026E3C
.public sub_02027040
.public sub_02027A08
.public sub_02027B1C
.public sub_02028080
.public sub_0202810C
.public sub_0202811C
.public sub_0202812C
.public sub_0202830C
.public sub_02028324
.public sub_02028354
.public sub_0202836C
.public sub_02028770
.public sub_020287C4
.public sub_020288DC
.public sub_02028948
.public sub_020289B8
.public sub_02028A08
.public sub_0202A03C
.public sub_0203C984
.public sub_020469BC
.public sub_02048240
.public TEAM_SELECTION_MENU_DEFAULT_WINDOW_PARAMS
.public TEXT_BOX_DEFAULT_WINDOW_PARAMS
.public UnloadOverlay
.public UpdateWindow

View File

@@ -0,0 +1,18 @@
#pragma once
.public CalcMenuHeightDiv8__02031AA4
.public GetWindow
.public GetWindowContents
.public GetWindowRectangle
.public InitWindowInput
.public IsEmptyString
.public MemAlloc
.public MemFree
.public NewWindowScreenCheck
.public PARENT_MENU_DEFAULT_WINDOW_PARAMS
.public UpdateParentMenu
.public UpdateWindow
.public strcpy
.public sub_020265A8
.public sub_020287C4
.public sub_02031A5C
.public sub_02032984

View File

@@ -0,0 +1,3 @@
#pragma once
.public GetWindowContents
.public sub_0202830C

View File

@@ -0,0 +1,127 @@
#pragma once
.public ADVANCED_MENU_DEFAULT_WINDOW_PARAMS
.public ADVANCED_TEXT_BOX_DEFAULT_WINDOW_PARAMS
.public ALERT_BOX_DEFAULT_WINDOW_PARAMS
.public AREA_NAME_BOX_DEFAULT_WINDOW_PARAMS
.public AnalyzeText
.public AppendStandardStringToMission
.public COLLECTION_MENU_DEFAULT_WINDOW_PARAMS
.public CONTROLS_CHART_DEFAULT_WINDOW_PARAMS
.public DEBUG_MENU_DEFAULT_WINDOW_PARAMS
.public DIALOGUE_BOX_DEFAULT_WINDOW_PARAMS
.public DeleteWindow
.public DrawTextInWindow
.public GetHeldButtons
.public GetPressedButtons
.public GetReleasedStylus
.public GetStringFromFileVeneer
.public GetWindow
.public GetWindowContents
.public GetWindowRectangle
.public InitPortraitParams
.public InitPreprocessorArgs
.public IsEmptyString
.public IsTouchScreenNotOff
.public IsValidPortrait
.public KeyWaitInit
.public LoadPortrait
.public MENU_CONTROL_PTR
.public MemAlloc
.public MemFree
.public MemZero
.public MemcpySimple
.public NULL_OVERLAY_LOAD_ENTRY
.public NewWindowScreenCheck
.public OPTIONS_MENU_DEFAULT_WINDOW_PARAMS
.public PORTRAIT_BOX_DEFAULT_WINDOW_PARAMS
.public PlaySeVolumeWrapper
.public PreprocessString
.public PreprocessStringFromId
.public SCROLL_BOX_DEFAULT_WINDOW_PARAMS
.public SIMPLE_MENU_DEFAULT_WINDOW_PARAMS
.public TEAM_SELECTION_MENU_DEFAULT_WINDOW_PARAMS
.public TEXT_BOX_DEFAULT_WINDOW_PARAMS
.public UnloadOverlay
.public UpdateWindow
.public _0209AEE0
.public _0209AEEC
.public _0209AEF4
.public _0209AEFC
.public _0209AF04
.public _0209AF6C
.public _0209AFC4
.public _0209AFDC
.public _0209AFE4
.public _0209AFEC
.public _0209AFF4
.public _0209AFFC
.public _0209B004
.public _0209B00C
.public _0209B014
.public _0209B01C
.public _0209B024
.public _0209B02C
.public _0209B034
.public _0209B03C
.public _0209B044
.public _0209B04C
.public _0209B054
.public _0209B05C
.public _0209B064
.public _0209B06C
.public _0209B074
.public _0209B07C
.public _0209B084
.public _s32_div_f
.public strcpy
.public sub_01FF9128
.public sub_01FF929C
.public sub_020063A0
.public sub_020063F4
.public sub_02006BFC
.public sub_02006C8C
.public sub_02020B60
.public sub_02020BC4
.public sub_02021F44
.public sub_0202202C
.public sub_02025D50
.public sub_02025D90
.public sub_02025E84
.public sub_0202613C
.public sub_0202614C
.public sub_02026174
.public sub_02026184
.public sub_02026194
.public sub_020261A4
.public sub_020261B4
.public sub_020261C4
.public sub_020261D4
.public sub_020261E4
.public sub_020261F4
.public sub_02026204
.public sub_02026358
.public sub_020263C8
.public sub_02026428
.public sub_02026594
.public sub_020265A8
.public sub_02026E3C
.public sub_02027040
.public sub_02027B1C
.public sub_02028080
.public sub_0202810C
.public sub_0202811C
.public sub_0202812C
.public sub_0202830C
.public sub_02028324
.public sub_02028354
.public sub_0202836C
.public sub_02028770
.public sub_020287C4
.public sub_020288DC
.public sub_02028948
.public sub_020289B8
.public sub_02028A08
.public sub_0202A03C
.public sub_0203C984
.public sub_020469BC
.public sub_02048240

File diff suppressed because it is too large Load Diff

309
asm/main_0202A690.s Normal file
View File

@@ -0,0 +1,309 @@
.include "asm/macros.inc"
.include "main_0202A690.inc"
.text
arm_func_start CreateParentMenu
CreateParentMenu: ; 0x0202A690
stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, lr}
mov r6, r3
mov r8, r1
mov r7, r2
mov sb, r0
mov r1, r6
mov r2, #0
b _0202A6B8
_0202A6B0:
add r1, r1, #8
add r2, r2, #1
_0202A6B8:
ldr r0, [r1]
cmp r0, #0
bne _0202A6B0
add r0, r2, #1
add r0, r0, r0, lsl #6
mov r0, r0, lsl #2
mov r1, #8
bl MemAlloc
mov r4, r0
mov r5, r4
b _0202A6FC
_0202A6E4:
mov r0, r5
bl strcpy
ldr r0, [r6, #4]
add r6, r6, #8
str r0, [r5, #0x100]
add r5, r5, #0x104
_0202A6FC:
ldr r1, [r6]
cmp r1, #0
bne _0202A6E4
mov r0, #0
strb r0, [r5]
ldr r6, [r6, #4]
mov r0, sb
mov r1, r8
mov r2, r7
mov r3, r4
str r6, [r5, #0x100]
bl CreateParentMenuInternal
ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, pc}
arm_func_end CreateParentMenu
arm_func_start CreateParentMenuWrapper
CreateParentMenuWrapper: ; 0x0202A730
stmdb sp!, {r4, lr}
bl CreateParentMenu
mov r4, r0
mvn r1, #1
cmp r4, r1
beq _0202A754
bl GetWindowContents
mov r1, #1
strb r1, [r0, #0x1b0]
_0202A754:
mov r0, r4
ldmia sp!, {r4, pc}
arm_func_end CreateParentMenuWrapper
arm_func_start CreateParentMenuInternal
CreateParentMenuInternal: ; 0x0202A75C
stmdb sp!, {r4, r5, r6, r7, r8, sb, sl, fp, lr}
sub sp, sp, #0x2c
mov r6, r0
mov sl, r1
mov r0, #0x1b4
mov r1, #8
mov sb, r2
mov r8, r3
bl MemAlloc
tst sl, #0x20
ldrne r7, [sb]
mov fp, #0
moveq r7, #0
cmp r6, #0
str fp, [sp, #8]
mov r4, r0
addne ip, sp, #0x1c
ldmneia r6, {r0, r1, r2, r3}
stmneia ip, {r0, r1, r2, r3}
ldrne r0, _0202A94C ; =UpdateParentMenu
mov r5, r8
strne r0, [sp, #0x1c]
bne _0202A7CC
ldr r0, _0202A950 ; =PARENT_MENU_DEFAULT_WINDOW_PARAMS
add r6, sp, #0x1c
ldmia r0, {r0, r1, r2, r3}
stmia r6, {r0, r1, r2, r3}
orr sl, sl, #0x300000
_0202A7CC:
ldrb r0, [sp, #0x22]
str r4, [sp, #0x28]
cmp r0, #0
bne _0202A81C
mov r6, #0
b _0202A7F8
_0202A7E4:
mov r0, r5
bl sub_020265A8
cmp r0, r6
movgt r6, r0
add r5, r5, #0x104
_0202A7F8:
mov r0, r5
bl IsEmptyString
cmp r0, #0
beq _0202A7E4
mov r0, sl
mov r1, sb
add r2, r6, #0x10
bl sub_02031A5C
strb r0, [sp, #0x22]
_0202A81C:
mov r5, r8
and r6, sl, #0x20
b _0202A84C
_0202A828:
cmp r6, #0
beq _0202A83C
ldr r0, [r5, #0x100]
cmp r0, r7
ldreq fp, [sp, #8]
_0202A83C:
ldr r0, [sp, #8]
add r5, r5, #0x104
add r0, r0, #1
str r0, [sp, #8]
_0202A84C:
mov r0, r5
bl IsEmptyString
cmp r0, #0
beq _0202A828
ldrb r0, [sp, #0x23]
cmp r0, #0
bne _0202A880
add r2, sp, #8
mov r0, sl
mov r1, sb
mov r3, r2
bl CalcMenuHeightDiv8__02031AA4
strb r0, [sp, #0x23]
_0202A880:
tst sl, #0x200000
ldrneb r1, [sp, #0x20]
ldrneb r0, [sp, #0x22]
subne r0, r1, r0
strneb r0, [sp, #0x20]
tst sl, #0x100000
ldrneb r1, [sp, #0x21]
ldrneb r0, [sp, #0x23]
subne r0, r1, r0
strneb r0, [sp, #0x21]
ldr r0, _0202A94C ; =UpdateParentMenu
cmp sb, #0
str r0, [r4]
str sl, [r4, #0xfc]
beq _0202A8DC
add r6, r4, #0x100
mov r5, #9
_0202A8C4:
ldmia sb!, {r0, r1, r2, r3}
stmia r6!, {r0, r1, r2, r3}
subs r5, r5, #1
bne _0202A8C4
ldmia sb, {r0, r1}
stmia r6, {r0, r1}
_0202A8DC:
str fp, [r4, #0x100]
str r8, [r4, #0x198]
mov r2, #0
str r2, [r4, #0x19c]
strb r2, [r4, #0x1a0]
strb r2, [r4, #0x1a1]
str r2, [r4, #0x1a4]
str r2, [r4, #0x1a8]
str r2, [r4, #0x1ac]
strb r2, [r4, #0x1b0]
add r0, sp, #0x1c
mov r1, #3
strb r2, [sp, #0x24]
bl NewWindowScreenCheck
add r1, sp, #0xc
mov r6, r0
bl GetWindowRectangle
ldr r5, [sp, #8]
add r3, sp, #0xc
str r5, [sp]
mov r1, sl
add r0, r4, #4
add r2, r4, #0x100
str r5, [sp, #4]
bl InitWindowInput
mov r0, r6
add sp, sp, #0x2c
ldmia sp!, {r4, r5, r6, r7, r8, sb, sl, fp, pc}
.align 2, 0
_0202A94C: .word UpdateParentMenu
_0202A950: .word PARENT_MENU_DEFAULT_WINDOW_PARAMS
arm_func_end CreateParentMenuInternal
arm_func_start ResumeParentMenu
ResumeParentMenu: ; 0x0202A954
stmdb sp!, {r3, lr}
bl GetWindowContents
mov r1, #1
str r1, [r0, #0x19c]
mov r1, #0
strb r1, [r0, #0x1a0]
strb r1, [r0, #0x1a1]
str r1, [r0, #0x1a4]
ldr r1, [r0, #0xfc]
bic r1, r1, #0x800000
str r1, [r0, #0xfc]
add r0, r0, #4
bl sub_02032984
ldmia sp!, {r3, pc}
arm_func_end ResumeParentMenu
arm_func_start sub_0202A98C
sub_0202A98C: ; 0x0202A98C
stmdb sp!, {r4, r5, r6, r7, r8, sb, sl, lr}
sub sp, sp, #0x18
mov r4, r0
mov sb, r1
mov r5, #0
bl GetWindow
mov r7, r0
mov r1, sb
ldr r8, [r7, #0xc]
b _0202A9BC
_0202A9B4:
add r1, r1, #8
add r5, r5, #1
_0202A9BC:
ldr r0, [r1]
cmp r0, #0
bne _0202A9B4
ldr r0, [r8, #0x198]
cmp r0, #0
beq _0202A9D8
bl MemFree
_0202A9D8:
add r0, r5, #1
add r0, r0, r0, lsl #6
mov r0, r0, lsl #2
mov r1, #8
bl MemAlloc
mov r5, r0
mov r6, r5
b _0202AA10
_0202A9F8:
mov r0, r6
bl strcpy
ldr r0, [sb, #4]
add sb, sb, #8
str r0, [r6, #0x100]
add r6, r6, #0x104
_0202AA10:
ldr r1, [sb]
cmp r1, #0
bne _0202A9F8
mov sl, #0
strb sl, [r6]
ldr r0, [sb, #4]
mov sb, r5
str r0, [r6, #0x100]
b _0202AA3C
_0202AA34:
add sb, sb, #0x104
add sl, sl, #1
_0202AA3C:
mov r0, sb
bl IsEmptyString
cmp r0, #0
beq _0202AA34
str r5, [r8, #0x198]
ldrb r0, [r7, #8]
bl sub_020287C4
mov r0, r4
bl UpdateWindow
mov r0, #3
str r0, [r8, #0x19c]
mov r2, #0
strb r2, [r8, #0x1a0]
strb r2, [r8, #0x1a1]
add r1, sp, #8
mov r0, r4
str r2, [r8, #0x1a4]
bl GetWindowRectangle
str sl, [sp]
str sl, [sp, #4]
ldr r1, [r8, #0xfc]
add r0, r8, #4
add r2, r8, #0x100
add r3, sp, #8
bl InitWindowInput
add sp, sp, #0x18
ldmia sp!, {r4, r5, r6, r7, r8, sb, sl, pc}
arm_func_end sub_0202A98C

30
asm/main_0202AAE8.s Normal file
View File

@@ -0,0 +1,30 @@
.include "asm/macros.inc"
.include "main_0202AAE8.inc"
.text
arm_func_start sub_0202AAE8
sub_0202AAE8: ; 0x0202AAE8
stmdb sp!, {r3, r4, r5, lr}
mov r5, r0
bl GetWindowContents
mov r4, r0
ldr r0, [r4, #0x19c]
cmp r0, #4
cmpne r0, #5
cmpne r0, #9
movne r0, #0
ldmneia sp!, {r3, r4, r5, pc}
mov r0, #1
strb r0, [r4, #0x1a0]
mov r2, #0
strb r0, [r4, #0x1a1]
mov r0, r5
sub r1, r2, #5
str r2, [r4, #0x1a4]
bl sub_0202830C
mov r0, #7
str r0, [r4, #0x19c]
mov r0, #1
ldmia sp!, {r3, r4, r5, pc}
arm_func_end sub_0202AAE8

11978
asm/main_0202AB80.s Normal file

File diff suppressed because it is too large Load Diff

8
include/main_0202A66C.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef PMDSKY_MAIN_0202A66C_H
#define PMDSKY_MAIN_0202A66C_H
#include "util.h"
bool8 IsEmptyString(u8* str);
#endif

18
include/main_0202AAA8.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef PMDSKY_MAIN_0202AAA8_H
#define PMDSKY_MAIN_0202AAA8_H
#include "util.h"
struct unk_0202AAA8 {
u8 field_0x0[0x198];
void *field_0x198;
s32 field_0x19C;
u8 field_0x1A0;
};
void *GetWindowContents(s32 window_id);
void SetParentMenuState7(s32 window_id);
void CloseParentMenu(s32 window_id);
#endif

9
include/main_0202AB40.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef PMDSKY_MAIN_0202AB40_H
#define PMDSKY_MAIN_0202AB40_H
#include "util.h"
u32 IsParentMenuActive(s32 window_id);
bool8 CheckParentMenuField0x1A0(s32 window_id);
#endif

View File

@@ -146,6 +146,12 @@ Static main
Object asm/main_02029EE8.o
Object src/main_0202A388.o
Object asm/main_0202A3E4.o
Object src/main_0202A66C.o
Object asm/main_0202A690.o
Object src/main_0202AAA8.o
Object asm/main_0202AAE8.o
Object src/main_0202AB40.o
Object asm/main_0202AB80.o
Object src/main_020348E4.o
Object asm/main_02034974.o
Object src/main_0203C760.o

9
src/main_0202A66C.c Normal file
View File

@@ -0,0 +1,9 @@
#include "main_0202A66C.h"
bool8 IsEmptyString(u8* str)
{
if (str == 0) {
return TRUE;
}
return *str == 0;
}

20
src/main_0202AAA8.c Normal file
View File

@@ -0,0 +1,20 @@
#include "main_0202AAA8.h"
void MemFree(void *ptr);
void DeleteWindow(s32 window_id);
void SetParentMenuState7(s32 window_id)
{
struct unk_0202AAA8 *menu = GetWindowContents(window_id);
menu->field_0x19C = 7;
}
void CloseParentMenu(s32 window_id)
{
struct unk_0202AAA8 *menu = GetWindowContents(window_id);
MemFree(menu->field_0x198);
MemFree(menu);
DeleteWindow(window_id);
}

17
src/main_0202AB40.c Normal file
View File

@@ -0,0 +1,17 @@
#include "main_0202AB40.h"
#include "main_0202AAA8.h"
u32 IsParentMenuActive(s32 window_id)
{
struct unk_0202AAA8 *menu = GetWindowContents(window_id);
s32 state = menu->field_0x19C;
return state != 8 && state != 9;
}
bool8 CheckParentMenuField0x1A0(s32 window_id)
{
struct unk_0202AAA8 *menu = GetWindowContents(window_id);
return menu->field_0x1A0 == 0;
}