Decomp five leftover single-function asm files

Seventh cleanup sweep. Five asm files and their includes removed:

  asm/overlay_29_0232E400.s   DoMoveWakeUpSlap
  asm/main_0204317C.s         FreeUnkStorageStruct0x18c0
  asm/main_02009DCC.s         sub_02009DCC
  asm/main_020018A4.s         sub_020018A4
  asm/main_0200C4CC.s         sub_0200C4CC

All five merged into an adjacent source rather than splitting one, so the sweep
removes five files and adds none.

DoMoveWakeUpSlap doubles the damage multiplier when the target is in any of the
three sleep-class states, then ends the status. EndSleepClassStatus takes five
arguments here, not four: the target loads r2=0, r3=1 and pushes a third flag on
the stack.

sub_020018A4 rounds a 64-bit value up to the next multiple of 0x100 and returns
the high 56 bits. The `and r2, r1, #0` that opens it is the high half of a 64-bit
`x & 0xFF`, not a separate test.

sub_02009DCC clears one bit of a 5-bit mask per non-zero entry in five byte
arrays at stride 5, then merges it into DISPCNT for the requested engine. The
zero-engine arm has to come first in the source or the wrong arm is predicated.

sub_0200C4CC copies 232 bytes out of _02094C18, whose size is fixed by the gap to
_02094D00.

Field types forced by the access widths in main_02042AF8.h: struct unk_02043148's
field_0x0 becomes s32 and field_0x7D5 splits into two s8s plus padding; struct
unk_020AFEE0's field_0xC becomes s32, which was the last differing row in
FreeUnkStorageStruct0x18c0.

struct unk_02094C18 is new. Its member is u32[0x3A] rather than u8[0xE8] because
the copy's alignment, and so its instruction shape, comes from the member type.

Authored by Claude (Opus 5) under human direction. All five verified at score 0.
Confirmed by a matching build: build/pmdsky.us/pmdsky.us.nds: OK. None carries a
region conditional, so US alone is sufficient.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
cecilarmitais
2026-08-19 20:30:00 -07:00
parent 658a92a802
commit 4d2a484c28
22 changed files with 139 additions and 216 deletions

View File

@@ -1,2 +0,0 @@
#pragma once

View File

@@ -1,6 +0,0 @@
#pragma once
.public _022A37AC
.public _022A37AD
.public _022A37AE
.public _022A37AF
.public _022A37B0

View File

@@ -1,2 +0,0 @@
#pragma once
.public _02094C18

View File

@@ -1,8 +0,0 @@
#pragma once
.public CloseCollectionMenu
.public CloseTextBox
.public MemFree
.public UNK_STORAGE_STRUCT_0X14
.public sub_020442CC
.public sub_02044474
.public sub_020445C8

View File

@@ -1,3 +0,0 @@
#pragma once
.public DealDamage
.public EndSleepClassStatus

View File

@@ -1,20 +0,0 @@
.include "asm/macros.inc"
.include "main_020018A4.inc"
.text
arm_func_start sub_020018A4
sub_020018A4: ; 0x020018A4
and r2, r1, #0
and r3, r0, #0xff
cmp r2, #0
cmpeq r3, #0
mov r2, #0
beq _020018C4
adds r0, r0, #0x100
adc r1, r1, r2
_020018C4:
mov r0, r0, lsr #8
orr r0, r0, r1, lsl #24
bx lr
arm_func_end sub_020018A4

View File

@@ -1,50 +0,0 @@
.include "asm/macros.inc"
.include "main_02009DCC.inc"
.text
arm_func_start sub_02009DCC
sub_02009DCC: ; 0x02009DCC
ldr r1, _02009E58 ; =_022A37AC
add r3, r0, r0, lsl #2
ldrb r2, [r1, r3]
mov r1, #0x1f
cmp r2, #0
ldr r2, _02009E5C ; =_022A37AD
bicne r1, r1, #1
ldrb r2, [r2, r3]
cmp r2, #0
ldr r2, _02009E60 ; =_022A37AE
bicne r1, r1, #2
ldrb r2, [r2, r3]
cmp r2, #0
ldr r2, _02009E64 ; =_022A37AF
bicne r1, r1, #4
ldrb r2, [r2, r3]
cmp r2, #0
ldr r2, _02009E68 ; =_022A37B0
bicne r1, r1, #8
ldrb r2, [r2, r3]
cmp r2, #0
bicne r1, r1, #0x10
cmp r0, #0
ldrne r2, _02009E6C ; =0x04001000
ldrne r0, [r2]
bicne r0, r0, #0x1f00
orrne r0, r0, r1, lsl #8
strne r0, [r2]
bxne lr
mov r2, #0x4000000
ldr r0, [r2]
bic r0, r0, #0x1f00
orr r0, r0, r1, lsl #8
str r0, [r2]
bx lr
.align 2, 0
_02009E58: .word _022A37AC
_02009E5C: .word _022A37AD
_02009E60: .word _022A37AE
_02009E64: .word _022A37AF
_02009E68: .word _022A37B0
_02009E6C: .word 0x04001000
arm_func_end sub_02009DCC

View File

@@ -1,22 +0,0 @@
.include "asm/macros.inc"
.include "main_0200C4CC.inc"
.text
arm_func_start sub_0200C4CC
sub_0200C4CC: ; 0x0200C4CC
stmdb sp!, {r4, lr}
ldr lr, _0200C4F8 ; =_02094C18
mov r4, r0
mov ip, #0xe
_0200C4DC:
ldmia lr!, {r0, r1, r2, r3}
stmia r4!, {r0, r1, r2, r3}
subs ip, ip, #1
bne _0200C4DC
ldmia lr, {r0, r1}
stmia r4, {r0, r1}
ldmia sp!, {r4, pc}
.align 2, 0
_0200C4F8: .word _02094C18
arm_func_end sub_0200C4CC

View File

@@ -1,50 +0,0 @@
.include "asm/macros.inc"
.include "main_0204317C.inc"
.text
arm_func_start FreeUnkStorageStruct0x18c0
FreeUnkStorageStruct0x18c0: ; 0x0204317C
stmdb sp!, {r3, lr}
ldr r0, _02043214 ; =UNK_STORAGE_STRUCT_0X14
ldr r0, [r0, #4]
cmp r0, #0
ldmeqia sp!, {r3, pc}
bl sub_02044474
bl sub_020442CC
bl sub_020445C8
ldr r0, _02043214 ; =UNK_STORAGE_STRUCT_0X14
ldr r1, [r0, #4]
ldr r0, [r1]
cmp r0, #6
bne _020431BC
add r0, r1, #0x700
ldrsb r0, [r0, #0xd5]
bl CloseTextBox
_020431BC:
ldr r0, _02043214 ; =UNK_STORAGE_STRUCT_0X14
mvn r1, #1
ldr r0, [r0, #4]
add r0, r0, #0x700
ldrsb r0, [r0, #0xd6]
cmp r0, r1
beq _020431DC
bl CloseTextBox
_020431DC:
ldr r1, _02043214 ; =UNK_STORAGE_STRUCT_0X14
ldr r0, [r1, #4]
ldr r2, [r0]
add r0, r0, #0x700
str r2, [r1, #0xc]
ldrsb r0, [r0, #0xd4]
bl CloseCollectionMenu
ldr r0, _02043214 ; =UNK_STORAGE_STRUCT_0X14
ldr r0, [r0, #4]
bl MemFree
ldr r0, _02043214 ; =UNK_STORAGE_STRUCT_0X14
mov r1, #0
str r1, [r0, #4]
ldmia sp!, {r3, pc}
.align 2, 0
_02043214: .word UNK_STORAGE_STRUCT_0X14
arm_func_end FreeUnkStorageStruct0x18c0

View File

@@ -1,45 +0,0 @@
.include "asm/macros.inc"
.include "overlay_29_0232E400.inc"
.text
arm_func_start DoMoveWakeUpSlap
DoMoveWakeUpSlap: ; 0x0232E400
stmdb sp!, {r3, r4, r5, r6, lr}
sub sp, sp, #4
mov r5, r1
ldr ip, [r5, #0xb4]
mov r6, r0
ldrb ip, [ip, #0xbd]
cmp ip, #1
cmpne ip, #3
cmpne ip, #5
str r3, [sp]
bne _0232E468
mov r0, r6
mov r1, r5
mov r3, #0x200
bl DealDamage
cmp r0, #0
movne r4, #1
moveq r4, #0
mov r2, #0
mov r0, r6
mov r1, r5
mov r3, #1
str r2, [sp]
and r4, r4, #0xff
bl EndSleepClassStatus
b _0232E480
_0232E468:
mov r3, #0x100
bl DealDamage
cmp r0, #0
movne r0, #1
moveq r0, #0
and r4, r0, #0xff
_0232E480:
mov r0, r4
add sp, sp, #4
ldmia sp!, {r3, r4, r5, r6, pc}
arm_func_end DoMoveWakeUpSlap

View File

@@ -1,8 +1,14 @@
#ifndef PMDSKY_DIRECTORY_FILE_H
#define PMDSKY_DIRECTORY_FILE_H
#include "util.h"
#include <file.h>
struct unk_02094C18 {
u32 field_0x0[0x3A];
};
struct directory_entry {
u32 offset; // The offset of the file relative to the start of the Pack file
u32 length; // The size of the file
@@ -38,5 +44,6 @@ u32 DirectoryFile_GetDirectoryFileSize(struct directory* pack_file, u32 file_ind
// file_index: file index
// return: number of read bytes (identical to the length of the pack from the Table of Content)
u32 DirectoryFile_LoadDirectoryFile(struct directory *pack_file, void *output_buffer,u32 file_index);
void sub_0200C4CC(struct unk_02094C18* dst);
#endif //PMDSKY_DIRECTORY_FILE_H

View File

@@ -1,6 +1,9 @@
#ifndef PMDSKY_MAIN_02001894_H
#define PMDSKY_MAIN_02001894_H
#include "util.h"
s32 RoundUpDiv256(s32 x);
u32 sub_020018A4(u64 x);
#endif //PMDSKY_MAIN_02001894_H

View File

@@ -1,6 +1,8 @@
#ifndef PMDSKY_MAIN_02009D48_H
#define PMDSKY_MAIN_02009D48_H
#include "util.h"
typedef struct
{
s32 val;
@@ -8,5 +10,6 @@ typedef struct
} unkStruct_02009D48;
void sub_02009D48(s32 arg0);
void sub_02009DCC(s32 engine);
#endif //PMDSKY_MAIN_02009D48_H

View File

@@ -9,10 +9,12 @@ struct unk_020AFED4 {
};
struct unk_02043148 {
u8 field_0x0[4];
s32 field_0x0;
s16 field_0x4[1000];
s8 field_0x7D4;
u8 field_0x7D5[0x13B];
s8 field_0x7D5;
s8 field_0x7D6;
u8 field_0x7D7[0x139];
s16 field_0x910;
u8 field_0x912[0xFAA];
u32 field_0x18BC;
@@ -23,7 +25,7 @@ struct unk_020AFEE0 {
u16 field_0x2;
struct unk_02043148 *field_0x4;
u8 *field_0x8;
u8 field_0xC[4];
s32 field_0xC;
u32 field_0x10;
};

View File

@@ -6,5 +6,6 @@
void sub_02043148(s32 index);
s32 sub_0204316C(s32 a);
void FreeUnkStorageStruct0x18c0(void);
#endif

View File

@@ -1,10 +1,13 @@
#ifndef PMDSKY_OVERLAY_29_0232E3D0_H
#define PMDSKY_OVERLAY_29_0232E3D0_H
#include "util.h"
#include "dungeon_mode.h"
#include "item.h"
#include "move.h"
bool8 DoMoveMiracleEye(struct entity* attacker, struct entity* defender, struct move* move, enum item_id item_id);
bool8 DoMoveWakeUpSlap(struct entity* attacker, struct entity* defender, struct move* move, enum item_id item_id);
#endif

View File

@@ -15,7 +15,6 @@ Static main
Object src/main_02001188.o
Object asm/main_0200119C.o
Object src/main_02001894.o
Object asm/main_020018A4.o
Object src/main_020018D0.o
Object src/main_02001A54.o
Object asm/main_02001B0C.o
@@ -46,7 +45,6 @@ Static main
Object src/main_0200961C.o
Object asm/main_02009648.o
Object src/main_02009D48.o
Object asm/main_02009DCC.o
Object src/main_02009F9C.o
Object asm/main_0200A124.o
Object src/main_0200B330.o
@@ -58,7 +56,6 @@ Static main
Object src/debug.o
Object src/directory_file_mngr.o
Object src/directory_file.o
Object asm/main_0200C4CC.o
Object src/main_0200C4FC.o
Object asm/main_0200C5B4.o
Object src/item_util.o
@@ -209,7 +206,6 @@ Static main
Object src/main_02042B84.o
Object asm/main_02042BE0.o
Object src/main_02043148.o
Object asm/main_0204317C.o
Object src/main_02043218.o
Object asm/main_020432B4.o
Object src/main_02043380.o
@@ -1159,7 +1155,6 @@ Overlay OVY_29
Object src/overlay_29_0232E250.o
Object asm/overlay_29_0232E2B8.o
Object src/overlay_29_0232E3D0.o
Object asm/overlay_29_0232E400.o
Object src/overlay_29_0232E48C.o
Object asm/overlay_29_0232E4A0.o
Object src/overlay_29_0232E734.o

View File

@@ -1,5 +1,7 @@
#include "directory_file.h"
extern const struct unk_02094C18 _02094C18;
#include "file_rom.h"
#include "debug.h"
@@ -37,3 +39,8 @@ u32 DirectoryFile_LoadDirectoryFile(struct directory *pack_file,void *output_buf
FileRom_StopDataTransfer();
return toc_entry->length;
}
void sub_0200C4CC(struct unk_02094C18* dst)
{
*dst = _02094C18;
}

View File

@@ -5,3 +5,12 @@ s32 RoundUpDiv256(s32 x) {
if (x & 0xFF) x += 0x100;
return x >> 8;
}
u32 sub_020018A4(u64 x)
{
if ((x & 0xFF) != 0) {
x += 0x100;
}
return x >> 8;
}

View File

@@ -1,5 +1,15 @@
#include "main_02009D48.h"
extern u8 _022A37AC[];
extern u8 _022A37AD[];
extern u8 _022A37AE[];
extern u8 _022A37AF[];
extern u8 _022A37B0[];
void sub_02009C54(s32);
void sub_02009C38(s32);
void sub_02009C70(s32);
@@ -28,3 +38,35 @@ void sub_02009D48(s32 arg0)
sub_020095E4(_022A37D4[arg0].val);
sub_02009600(_022A37D8[arg0].val);
}
void sub_02009DCC(s32 engine)
{
s32 idx = engine * 5;
u32 mask = 0x1F;
if (_022A37AC[idx] != 0) {
mask &= ~1;
}
if (_022A37AD[idx] != 0) {
mask &= ~2;
}
if (_022A37AE[idx] != 0) {
mask &= ~4;
}
if (_022A37AF[idx] != 0) {
mask &= ~8;
}
if (_022A37B0[idx] != 0) {
mask &= ~0x10;
}
if (engine == 0) {
*(vu32 *) 0x04000000 = (*(vu32 *) 0x04000000 & ~0x1F00) | (mask << 8);
} else {
*(vu32 *) 0x04001000 = (*(vu32 *) 0x04001000 & ~0x1F00) | (mask << 8);
}
}

View File

@@ -1,4 +1,16 @@
#include "main_02043148.h"
extern void sub_02044474(void);
extern void sub_020442CC(void);
extern void sub_020445C8(void);
extern void CloseTextBox(s32 id);
extern void CloseCollectionMenu(s32 id);
extern void MemFree(void *ptr);
#include "main_02042AF8.h"
void sub_02043148(s32 index)
@@ -11,3 +23,30 @@ s32 sub_0204316C(s32 a)
{
return a != 0 ? 5 : 7;
}
void FreeUnkStorageStruct0x18c0(void)
{
struct unk_02043148 *s = UNK_STORAGE_STRUCT_0X14.field_0x4;
if (s == NULL) {
return;
}
sub_02044474();
sub_020442CC();
sub_020445C8();
s = UNK_STORAGE_STRUCT_0X14.field_0x4;
if (s->field_0x0 == 6) {
CloseTextBox(s->field_0x7D5);
}
if (UNK_STORAGE_STRUCT_0X14.field_0x4->field_0x7D6 != -2) {
CloseTextBox(UNK_STORAGE_STRUCT_0X14.field_0x4->field_0x7D6);
}
UNK_STORAGE_STRUCT_0X14.field_0xC = UNK_STORAGE_STRUCT_0X14.field_0x4->field_0x0;
CloseCollectionMenu(UNK_STORAGE_STRUCT_0X14.field_0x4->field_0x7D4);
MemFree(UNK_STORAGE_STRUCT_0X14.field_0x4);
UNK_STORAGE_STRUCT_0X14.field_0x4 = NULL;
}

View File

@@ -1,4 +1,9 @@
#include "overlay_29_0232E3D0.h"
#include "dungeon_util_static.h"
extern s32 DealDamage(struct entity *attacker, struct entity *defender, struct move *move, s32 damageMultiplier, enum item_id item_id);
extern void EndSleepClassStatus(struct entity *user, struct entity *target, bool8 a, bool8 b, bool8 c);
extern void TryInflictMiracleEyeStatus(struct entity *user, struct entity *target, s32 a);
@@ -11,3 +16,18 @@ bool8 DoMoveMiracleEye(struct entity* attacker, struct entity* defender, struct
return TRUE;
}
bool8 DoMoveWakeUpSlap(struct entity* attacker, struct entity* defender, struct move* move, enum item_id item_id)
{
bool8 result;
enum status_sleep_id sleep = GetEntInfo(defender)->sleep_class_status.sleep;
if (sleep == STATUS_SLEEP || sleep == STATUS_NIGHTMARE || sleep == STATUS_NAPPING) {
result = DealDamage(attacker, defender, move, 0x200, item_id) != 0;
EndSleepClassStatus(attacker, defender, FALSE, TRUE, FALSE);
} else {
result = DealDamage(attacker, defender, move, 0x100, item_id) != 0;
}
return result;
}