unify bag item struct and use proper header

This commit is contained in:
Seth Barberee 2026-01-19 10:38:22 -08:00
parent f4f4e9754e
commit 74f0a49c5a
6 changed files with 31 additions and 52 deletions

View File

@ -1,41 +0,0 @@
.include "asm/macros.inc"
.include "main_0200ED1C.inc"
.text
arm_func_start SetMoneyCarried
SetMoneyCarried: ; 0x0200ED1C
ldr r1, _0200ED50 ; =0x0001869F
cmp r0, r1
movgt r0, r1
bgt _0200ED34
cmp r0, #0
movlt r0, #0
_0200ED34:
ldr r1, _0200ED54 ; =BAG_ITEMS_PTR_MIRROR
ldr r2, [r1]
ldrb r1, [r2, #0x388]
add r1, r2, r1, lsl #2
add r1, r1, #0x1000
str r0, [r1, #0x394]
bx lr
.align 2, 0
_0200ED50: .word 0x0001869F
_0200ED54: .word BAG_ITEMS_PTR_MIRROR
arm_func_end SetMoneyCarried
arm_func_start AddMoneyCarried
AddMoneyCarried: ; 0x0200ED58
ldr r1, _0200ED7C ; =BAG_ITEMS_PTR_MIRROR
ldr ip, _0200ED80 ; =SetMoneyCarried
ldr r2, [r1]
ldrb r1, [r2, #0x388]
add r1, r2, r1, lsl #2
add r1, r1, #0x1000
ldr r1, [r1, #0x394]
add r0, r0, r1
bx ip
.align 2, 0
_0200ED7C: .word BAG_ITEMS_PTR_MIRROR
_0200ED80: .word SetMoneyCarried
arm_func_end AddMoneyCarried

View File

@ -1640,6 +1640,9 @@ struct bag_items_inner {
struct bag_items {
u8 fill0[0x384];
/* 0x384 */ struct bag_items_inner *bag_items;
u8 unk388;
u8 fill2[0x1009];
u32 maybeMoney[]; // Unknown size, but indexed with an u8
};
struct bulk_item

View File

@ -1,15 +1,14 @@
#ifndef PMDSKY_MAIN_0200ECFC_H
#define PMDSKY_MAIN_0200ECFC_H
typedef struct {
u8 fill1[0x388];
u8 unk388;
u8 fill2[0x1009];
u32 maybeMoney[]; // Unknown size, but indexed with an u8
} bag_items;
// Gets the amount of money the player is carrying.
// return: value
u32 GetMoneyCarried(void);
// Sets the amount of money the player is carrying.
void SetMoneyCarried(s32 amount);
// Adds the amount of to the money the player is carrying.
void AddMoneyCarried(s32 amount);
#endif //PMDSKY_MAIN_0200ECFC_H

View File

@ -42,7 +42,6 @@ Static main
Object src/item_util_1.o
Object asm/main_0200EB30.o
Object src/main_0200ECFC.o
Object asm/main_0200ED1C.o
Object src/main_0200EDC0.o
Object asm/main_0200EDFC.o
Object src/exclusive_item.o

View File

@ -1,9 +1,30 @@
#include "main_0200ECFC.h"
#include "item.h"
extern bag_items* BAG_ITEMS_PTR_MIRROR;
extern struct bag_items* BAG_ITEMS_PTR_MIRROR;
u32 GetMoneyCarried(void)
{
int tmp = BAG_ITEMS_PTR_MIRROR->unk388;
return BAG_ITEMS_PTR_MIRROR->maybeMoney[tmp];
}
void SetMoneyCarried(s32 amount)
{
s32 var_r0;
var_r0 = amount;
if (var_r0 > 99999) {
var_r0 = 99999;
} else if (var_r0 < 0) {
var_r0 = 0;
}
BAG_ITEMS_PTR_MIRROR->maybeMoney[BAG_ITEMS_PTR_MIRROR->unk388] = var_r0;
}
void AddMoneyCarried(s32 amount)
{
SetMoneyCarried(amount + BAG_ITEMS_PTR_MIRROR->maybeMoney[BAG_ITEMS_PTR_MIRROR->unk388]);
}

View File

@ -37,8 +37,6 @@ extern s32 GetMoneyStored();
extern s32 GetLanguageType();
extern enum game_mode GetGameMode();
extern s32 GetNotifyNote();
extern s32 AddMoneyCarried(s32 arg0);
extern s32 SetMoneyCarried(s32 arg0);
extern s32 SetMoneyStored(s32 arg0);
extern s32 SetNotifyNote(s32 arg0);
extern void InitDungeonListScriptVars();