sub_809CBBC sub_809CC90

This commit is contained in:
DizzyEggg
2025-05-08 17:22:41 +02:00
parent d3ecfe3b79
commit 57f3422495
2 changed files with 78 additions and 147 deletions

View File

@@ -5,150 +5,6 @@
.text
thumb_func_start sub_809CBBC
sub_809CBBC:
push {r4-r7,lr}
sub sp, 0x54
adds r4, r0, 0
adds r6, r1, 0
adds r5, r2, 0
adds r7, r3, 0
ldrb r1, [r4]
cmp r1, 0x69
bne _0809CC20
ldr r1, _0809CC0C
movs r0, 0x2
ldrsh r2, [r4, r0]
ldr r0, _0809CC10
ldr r0, [r0]
movs r3, 0xD2
lsls r3, 4
adds r0, r3
ldr r3, [r0]
mov r0, sp
bl sprintfStatic
ldr r0, _0809CC14
ldr r0, [r0]
movs r1, 0x98
lsls r1, 2
adds r2, r0, r1
movs r3, 0x2
ldrsh r1, [r4, r3]
ldr r0, [r2]
adds r1, r0, r1
ldr r0, _0809CC18
cmp r1, r0
ble _0809CC1C
cmp r6, 0
beq _0809CC4E
movs r1, 0x1
negs r1, r1
movs r0, 0
adds r2, r6, 0
b _0809CC4A
.align 2, 0
_0809CC0C: .4byte gUnknown_81163E4
_0809CC10: .4byte gItemParametersData
_0809CC14: .4byte gTeamInventoryRef
_0809CC18: .4byte 0x0001869f
_0809CC1C:
str r1, [r2]
b _0809CC5E
_0809CC20:
ldrb r0, [r4, 0x2]
lsls r1, 16
lsls r0, 8
orrs r0, r1
str r0, [sp, 0x50]
add r4, sp, 0x50
mov r0, sp
adds r1, r4, 0
movs r2, 0
bl sub_8090E14
bl GetNumberOfFilledInventorySlots
cmp r0, 0x13
ble _0809CC52
cmp r5, 0
beq _0809CC4E
movs r1, 0x1
negs r1, r1
movs r0, 0
adds r2, r5, 0
_0809CC4A:
bl ScriptPrintText
_0809CC4E:
movs r0, 0
b _0809CC82
_0809CC52:
ldrb r0, [r4, 0x2]
movs r1, 0
bl sub_809124C
bl FillInventoryGaps
_0809CC5E:
cmp r7, 0
beq _0809CC80
ldr r0, _0809CC8C
mov r1, sp
bl strcpy
movs r1, 0x1
negs r1, r1
movs r0, 0
adds r2, r7, 0
bl ScriptPrintText
movs r1, 0x80
lsls r1, 1
movs r0, 0xCB
bl xxx_call_play_fanfare_se
_0809CC80:
movs r0, 0x1
_0809CC82:
add sp, 0x54
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0809CC8C: .4byte gFormatBuffer_Items
thumb_func_end sub_809CBBC
thumb_func_start sub_809CC90
sub_809CC90:
push {lr}
lsls r0, 2
ldr r1, _0809CCBC
adds r1, r0, r1
ldrb r0, [r1]
cmp r0, 0x69
bne _0809CCC8
ldr r0, _0809CCC0
ldr r0, [r0]
movs r2, 0x98
lsls r2, 2
adds r0, r2
movs r2, 0x2
ldrsh r1, [r1, r2]
ldr r0, [r0]
adds r0, r1
ldr r1, _0809CCC4
cmp r0, r1
ble _0809CCD4
movs r0, 0x2
b _0809CCD6
.align 2, 0
_0809CCBC: .4byte gUnknown_81163BC
_0809CCC0: .4byte gTeamInventoryRef
_0809CCC4: .4byte 0x0001869f
_0809CCC8:
bl GetNumberOfFilledInventorySlots
cmp r0, 0x13
ble _0809CCD4
movs r0, 0x2
b _0809CCD6
_0809CCD4:
movs r0, 0x1
_0809CCD6:
pop {r1}
bx r1
thumb_func_end sub_809CC90
thumb_func_start sub_809CCDC
sub_809CCDC:

View File

@@ -5,6 +5,9 @@
#include "event_flag.h"
#include "ground_main.h"
#include "code_80A26CC.h"
#include "code_800D090.h"
#include "code_80118A4.h"
#include "string_format.h"
struct unkStruct_3001B68
{
@@ -413,21 +416,93 @@ void sub_809CB50(void)
gUnknown_20399E0->unk8 = 0;
}
void sub_809CB74(void) {
void sub_809CB74(void)
{
MemoryFree(gUnknown_20399E0);
gUnknown_20399E0 = NULL;
}
void sub_809CB8C(void) {
void sub_809CB8C(void)
{
ClearScriptVarArray(NULL, STATION_ITEM_TEMP);
ClearScriptVarArray(NULL, DELIVER_ITEM_TEMP);
}
bool8 HasItemInInventory(u8 item)
{
if(FindItemInInventory(item) >= 0)
if (FindItemInInventory(item) >= 0)
return TRUE;
else
return FALSE;
}
extern bool8 ScriptPrintText(s32 a0, s32 a1_, const char *text);
extern bool8 sub_809124C(u8 id, u8 param_3);
extern const u8 gUnknown_81163E4[];
struct ItemWithQuantity
{
u8 id;
s16 quantity;
};
bool8 sub_809CBBC(const struct ItemWithQuantity *itemToAdd, u8 *maxMoneyStr, u8 *noItemSpaceStr, u8 *itemGivenStr)
{
char buffer[80];
if (itemToAdd->id == ITEM_POKE) {
int newMoneyAmount;
sprintfStatic(buffer,gUnknown_81163E4,itemToAdd->quantity,gItemParametersData[ITEM_POKE].name);
newMoneyAmount = gTeamInventoryRef->teamMoney + itemToAdd->quantity;
if (newMoneyAmount > MAX_TEAM_MONEY) {
if (maxMoneyStr != 0) {
ScriptPrintText(0, -1, maxMoneyStr);
}
return FALSE;
}
gTeamInventoryRef->teamMoney = newMoneyAmount;
}
else {
Item item = {0};
item.quantity = itemToAdd->quantity;
item.id = itemToAdd->id;
sub_8090E14(buffer,&item,0);
if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE) {
if (noItemSpaceStr != 0) {
ScriptPrintText(0, -1, noItemSpaceStr);
}
return FALSE;
}
sub_809124C(item.id,0);
FillInventoryGaps();
}
if (itemGivenStr != 0) {
strcpy(gFormatBuffer_Items[0], buffer);
ScriptPrintText(0, -1, itemGivenStr);
xxx_call_play_fanfare_se(0xcb,0x100);
}
return TRUE;
}
extern const struct ItemWithQuantity gUnknown_81163BC[];
s32 sub_809CC90(s32 r0)
{
const struct ItemWithQuantity *item = &gUnknown_81163BC[r0];
if (item->id == ITEM_POKE) {
if (gTeamInventoryRef->teamMoney + item->quantity > MAX_TEAM_MONEY)
return 2;
}
else {
if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE)
return 2;
}
return 1;
}