Decomp 8 functions, emptying seven asm files

Confirmed by a matching build: build/pmdsky.us/pmdsky.us.nds: OK.
This commit is contained in:
darkruss48
2026-09-10 21:10:23 +00:00
parent 02e838c934
commit 2c2c5c2a04
27 changed files with 130 additions and 202 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,3 +0,0 @@
#pragma once
.public _022A88F0
.public _022A88FC

View File

@@ -1,4 +0,0 @@
#pragma once
.public _020A2D09
.public _s32_div_f
.public MONSTER_SPRITE_DATA

View File

@@ -1,3 +0,0 @@
#pragma once
.public ov29_023531BC
.public SubstitutePlaceholderItemTags

View File

@@ -1,17 +0,0 @@
.include "asm/macros.inc"
.include "main_02001CB0.inc"
.text
arm_func_start FixedPoint64ToInt
FixedPoint64ToInt: ; 0x02001CB0
ldmia r0, {r1, r2}
mov r0, #0x10000
rsb r0, r0, #0
mov r1, r1, lsl #0x10
and r0, r2, r0
orr r0, r1, r0, lsr #16
tst r2, #0x8000
addne r0, r0, #1
bx lr
arm_func_end FixedPoint64ToInt

View File

@@ -1,9 +0,0 @@
.include "asm/macros.inc"
.include "main_02008240.inc"
.text
arm_func_start sub_02008240
sub_02008240: ; 0x02008240
ldmia sp!, {r4, r5, r6, pc}
arm_func_end sub_02008240

View File

@@ -1,21 +0,0 @@
.include "asm/macros.inc"
.include "main_0200EB30.inc"
.text
; https://decomp.me/scratch/FPdo0
arm_func_start sub_0200EB64
sub_0200EB64: ; 0x0200EB64
ldr r1, _0200EB88 ; =ITEM_DATA_TABLE_PTRS
mov r2, r0, lsl #0x1f
ldr r1, [r1, #8]
mov r0, r0, asr #1
ldr r3, [r1, r0, lsl #2]
ldr r0, _0200EB8C ; =0x000007FF
mov r1, r2, lsr #0x1b
and r0, r0, r3, asr r1
bx lr
.align 2, 0
_0200EB88: .word ITEM_DATA_TABLE_PTRS
_0200EB8C: .word 0x000007FF
arm_func_end sub_0200EB64

View File

@@ -1,41 +0,0 @@
.include "asm/macros.inc"
.include "main_02010830.inc"
.text
arm_func_start RemoveInvalidKecleonShop1Items
RemoveInvalidKecleonShop1Items: ; 0x02010830
ldr r1, _02010868 ; =BAG_ITEMS_PTR_MIRROR
mov r0, #0
ldr r1, [r1]
mov r2, r0
add r1, r1, #0x1000
ldr r3, [r1, #0x32c]
_02010848:
mov r1, r2, lsl #2
ldrsh r1, [r3, r1]
add r2, r2, #1
cmp r1, #0
addne r0, r0, #1
cmp r2, #8
blt _02010848
bx lr
.align 2, 0
_02010868: .word BAG_ITEMS_PTR_MIRROR
arm_func_end RemoveInvalidKecleonShop1Items
arm_func_start RemoveItemFromKecleonShop1
RemoveItemFromKecleonShop1: ; 0x0201086C
ldr r1, _02010894 ; =BAG_ITEMS_PTR_MIRROR
mov r3, r0, lsl #2
ldr r1, [r1]
mov r2, #0
add r1, r1, #0x1000
ldr r1, [r1, #0x32c]
strh r2, [r1, r3]
add r0, r1, r0, lsl #2
strh r2, [r0, #2]
bx lr
.align 2, 0
_02010894: .word BAG_ITEMS_PTR_MIRROR
arm_func_end RemoveItemFromKecleonShop1

View File

@@ -1,32 +0,0 @@
.include "asm/macros.inc"
.include "main_0202760C.inc"
.text
arm_func_start sub_0202760C
sub_0202760C: ; 0x0202760C
mov r1, #0xe0
mul r1, r0, r1
ldr r0, _02027620 ; =_022A88F0
ldr r0, [r0, r1]
bx lr
.align 2, 0
#ifdef JAPAN
_02027620: .word _022A88FC
#else
_02027620: .word _022A88F0
#endif
arm_func_end sub_0202760C
#ifdef JAPAN
arm_func_start sub_0202796C_JP
sub_0202796C_JP: ; 0x0202796C
mov r1, #0xe0
mul r1, r0, r1
ldr r0, _02027980 ; =_022A88F0
ldr r0, [r0, r1]
bx lr
.align 2, 0
_02027980: .word _022A88F0
arm_func_end sub_0202796C_JP
#endif

View File

@@ -1,37 +0,0 @@
.include "asm/macros.inc"
.include "main_020527E0.inc"
.text
arm_func_start GetSpriteSize
GetSpriteSize: ; 0x020527E0
stmdb sp!, {r3, lr}
mov r1, #0x258
bl _s32_div_f
mov r0, r1, lsl #0x10
ldr r2, _02052818 ; =MONSTER_SPRITE_DATA
mov r0, r0, asr #0x10
ldrb r0, [r2, r0, lsl #1]
cmp r0, #0
moveq r0, #0
ldmeqia sp!, {r3, pc}
cmp r0, #6
movls r0, #6
ldrhib r0, [r2, r1, lsl #1]
ldmia sp!, {r3, pc}
.align 2, 0
_02052818: .word MONSTER_SPRITE_DATA
arm_func_end GetSpriteSize
arm_func_start GetSpriteFileSize
GetSpriteFileSize: ; 0x0205281C
stmdb sp!, {r3, lr}
mov r1, #0x258
bl _s32_div_f
ldr r0, _02052838 ; =_020A2D09
ldrb r0, [r0, r1, lsl #1]
mov r0, r0, lsl #9
ldmia sp!, {r3, pc}
.align 2, 0
_02052838: .word _020A2D09
arm_func_end GetSpriteFileSize

View File

@@ -1,19 +0,0 @@
.include "asm/macros.inc"
.include "overlay_29_02344BA8.inc"
.text
arm_func_start PrepareItemForPrinting2
PrepareItemForPrinting2: ; 0x02344BA8
stmdb sp!, {r3, lr}
add r3, r0, r1, lsl #2
orr ip, r1, #0x40000
mov r0, r1
mov r1, r2
ldr r2, _02344BCC ; =ov29_023531BC
str ip, [r3, #0x10]
bl SubstitutePlaceholderItemTags
ldmia sp!, {r3, pc}
.align 2, 0
_02344BCC: .word ov29_023531BC
arm_func_end PrepareItemForPrinting2

View File

@@ -42,6 +42,6 @@ bool8 TestItemAiFlag(s16 item_id, s32 flag);
bool8 IsItemInTimeDarkness(s16 item_id);
bool8 IsItemValidVeneer(s16 item_id);
s32 sub_0200EB64(s16 idx);
#endif //PMDSKY_ITEM_UTIL_1_H

View File

@@ -5,5 +5,6 @@
u32 sub_02001BB4(s32 x, s32 y);
void IntToFixedPoint64(struct fixed_point_64* out, s32 x);
s32 FixedPoint64ToInt(struct fixed_point_64 *x);
#endif //PMDSKY_MAIN_02001BB4_H

View File

@@ -4,5 +4,7 @@
u16 GetEggHatchTimer(void);
void SetEggHatchTimer(u16 timer);
void DecrementEggHatchTimer(void);
int RemoveInvalidKecleonShop1Items(void);
void RemoveItemFromKecleonShop1(int slot);
#endif

View File

@@ -3,5 +3,9 @@
#include "window.h"
u32 sub_0202760C(s32 idx);
#ifdef JAPAN
u32 sub_0202796C_JP(s32 idx);
#endif
#endif

View File

@@ -1,7 +1,16 @@
#ifndef PMDSKY_MAIN_020527A8_H
#define PMDSKY_MAIN_020527A8_H
struct monster_sprite_data_entry {
u8 sprite_size;
u8 sprite_file_size;
};
extern struct monster_sprite_data_entry MONSTER_SPRITE_DATA[600];
u8 GetMonsterGender(s16 monster_id);
u8 GetBodySize(s16 monster_id);
u8 GetSpriteSize(s16 monster_id);
u32 GetSpriteFileSize(s16 monster_id);
#endif //PMDSKY_MAIN_020527A8_H

View File

@@ -1,6 +1,11 @@
#ifndef PMDSKY_OVERLAY_29_02344B9C_H
#define PMDSKY_OVERLAY_29_02344B9C_H
#include "util.h"
#include "dungeon_mode.h"
#include "main_0200C4FC.h"
void ov29_02344B9C(s32 idx, u32 val);
void PrepareItemForPrinting2(struct preprocessor_args *preprocessor_args, u8 tag_id, struct item *item);
#endif

View File

@@ -19,7 +19,6 @@ Static main
Object src/main_02001A54.o
Object asm/main_02001B0C.o
Object src/main_02001BB4.o
Object asm/main_02001CB0.o
Object src/main_02001CD4.o
Object asm/main_02001D68.o
Object src/main_0200224C.o
@@ -42,7 +41,6 @@ Static main
Object asm/main_02004FF8.o
Object src/main_02008194.o
Object src/main_02008210.o
Object asm/main_02008240.o
Object src/main_02008254.o
Object asm/main_020082C4.o
Object src/main_02008BD4.o
@@ -71,7 +69,6 @@ Static main
Object src/main_0200D81C.o
Object asm/main_0200D8E4.o
Object src/item_util_1.o
Object asm/main_0200EB30.o
Object src/main_0200ECFC.o
Object src/main_0200EDC0.o
Object src/main_0200EEE0.o
@@ -89,7 +86,6 @@ Static main
Object src/main_0201077C.o
Object src/main_020107AC.o
Object src/main_020107DC.o
Object asm/main_02010830.o
Object src/main_02010898.o
Object asm/main_020108B4.o
Object src/main_02010BA4.o
@@ -148,7 +144,6 @@ Static main
Object src/main_020265C4.o
Object asm/main_0202676C.o
Object src/main_020275F8.o
Object asm/main_0202760C.o
Object src/main_02027648.o
Object asm/main_020276C0.o
Object src/main_020278A8.o
@@ -293,7 +288,6 @@ Static main
Object src/main_020526EC.o
Object src/get_category_string.o
Object src/main_020527A8.o
Object asm/main_020527E0.o
Object src/main_0205283C.o
Object asm/main_02052A7C.o
Object src/main_02052B28.o
@@ -1244,7 +1238,6 @@ Overlay OVY_29
Object asm/overlay_29_02344178.o
Object src/overlay_29_02344AF8.o
Object src/overlay_29_02344B9C.o
Object asm/overlay_29_02344BA8.o
Object src/overlay_29_02344BE4.o
Object asm/overlay_29_02344BF8.o
Object src/overlay_29_02345698.o

View File

@@ -230,3 +230,16 @@ bool8 IsItemValidVeneer(s16 item_id)
{
return IsItemValid(item_id);
}
// NOTE: the s32 return (not s16) and the explicit lsl/lsr shifts are
// load-bearing for an exact match: s16 return emits lsl/asr #16, and
// (idx & 1) << 4 does not produce the mov/lsl + mov/lsr pair.
// Semantics unchanged (11-bit field, 0..0x7FF).
s32 sub_0200EB64(s16 idx)
{
u32 shift = (u32)idx << 31;
s32 *table = ITEM_DATA_TABLE_PTRS.langFile.iov_base;
s32 entry_index = idx >> 1;
s32 entry = table[entry_index];
return 0x7FF & (entry >> (shift >> 27));
}

View File

@@ -69,3 +69,23 @@ void IntToFixedPoint64(struct fixed_point_64* out, s32 x)
out->upper = out->upper | ~0xFFFF;
}
}
s32 FixedPoint64ToInt(struct fixed_point_64 *x)
{
u32 lower;
s32 upper;
u32 mask;
s64 shifted;
u32 masked;
s32 result;
mask = ~0xFFFFu;
upper = x->upper;
lower = x->lower;
shifted = upper * 0x10000;
masked = lower & mask;
result = shifted | (masked >> 16);
if (lower & 0x8000u) {
result += 1;
}
return result;
}

View File

@@ -19,3 +19,23 @@ void DecrementEggHatchTimer(void)
BAG_ITEMS_PTR_MIRROR->field_0x13A8--;
}
}
int RemoveInvalidKecleonShop1Items(void)
{
int count = 0;
int i;
struct bulk_item *items = (struct bulk_item *)BAG_ITEMS_PTR_MIRROR->field_0x132C;
for (i = 0; i < 8; i++) {
if (items[i].id != 0)
count++;
}
return count;
}
void RemoveItemFromKecleonShop1(int slot)
{
struct bulk_item *items = (struct bulk_item *)BAG_ITEMS_PTR_MIRROR->field_0x132C;
u16 *item = (u16 *)&items[slot];
item[0] = 0;
item[1] = 0;
}

View File

@@ -1,7 +1,28 @@
#include "main_020275F8.h"
#include "window.h"
extern u8 _022A88F0[];
#ifdef JAPAN
extern u8 _022A88FC[];
#endif
struct Window* GetWindow(s32 window_id)
{
return &WINDOW_LIST[window_id];
}
u32 sub_0202760C(s32 idx)
{
#ifdef JAPAN
return *(u32 *)(_022A88FC + idx * 0xE0);
#else
return *(u32 *)(_022A88F0 + idx * 0xE0);
#endif
}
#ifdef JAPAN
u32 sub_0202796C_JP(s32 idx)
{
return *(u32 *)(_022A88F0 + idx * 0xE0);
}
#endif

View File

@@ -10,3 +10,27 @@ u8 GetBodySize(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].body_size;
}
u8 GetSpriteSize(s16 monster_id)
{
s32 raw = monster_id % 600;
s16 mod = raw;
u8 size = MONSTER_SPRITE_DATA[mod].sprite_size;
if (size == 0) {
return 0;
}
if (size <= 6) {
return 6;
}
// NOTE: reload through raw (not size) is load-bearing for an exact
// match: reusing size lets the compiler fold both loads into one.
return MONSTER_SPRITE_DATA[raw].sprite_size;
}
u32 GetSpriteFileSize(s16 monster_id)
{
s32 raw = monster_id % 600;
// NOTE: u32 return (not u8 as in pmdsky-debug): no truncation is
// emitted and callers accumulate the full value (field << 9).
return MONSTER_SPRITE_DATA[raw].sprite_file_size << 9;
}

View File

@@ -1,8 +1,18 @@
#include "overlay_29_02344B9C.h"
#include "overlay_29_02344AF8.h"
#include "main_02001188.h"
#include "overlay_29_0234B024.h"
extern struct unk_023531A4 ov29_023531BC;
extern void SubstitutePlaceholderItemTags(s32 tag_id, struct item *item, struct unk_023531A4 *param_3);
void ov29_02344B9C(s32 idx, u32 val)
{
SetPreprocessorArgsIdVal(idx, val);
}
void PrepareItemForPrinting2(struct preprocessor_args *preprocessor_args, u8 tag_id, struct item *item)
{
preprocessor_args->id_vals[tag_id] = tag_id | 0x40000;
SubstitutePlaceholderItemTags(tag_id, item, &ov29_023531BC);
}