DRA AddToInventory (#978)

It took me over a year to understand this one.
This commit is contained in:
Luciano Ciccariello 2024-01-14 17:52:36 +00:00 committed by GitHub
parent 930fcf4a81
commit c539d3be9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 63 deletions

View File

@ -168,8 +168,6 @@ func_800FB23C = 0x800FB394;
MenuHandle = 0x800FBD84;
TimeAttackController = 0x800FD474;
func_800FD6C4 = 0x800FD678;
GetEquipOrder = 0x800FD6F8;
GetEquipCount = 0x800FD714;
CheckEquipmentItemCount = 0x800FD774;
AddToInventory = 0x800FD828;
GetStatusAilmentTimer = 0x800FDACC;

View File

@ -57,8 +57,6 @@ MenuDraw = 0x800F8F28;
MenuHandleCursorInput = 0x800FA034;
MenuHandle = 0x800FBC24;
TimeAttackController = 0x800FD4C0;
GetEquipOrder = 0x800FD744;
GetEquipCount = 0x800FD760;
CheckEquipmentItemCount = 0x800FD7C0;
AddToInventory = 0x800FD874;
GetStatusAilmentTimer = 0x800FDB18;

View File

@ -1126,6 +1126,5 @@ _snd_seq_t_max = 0x800987A4;
_svm_vab_count = 0x8009880C;
g_DebugPlayer = 0x80098850;
g_MainGame = 0x800A0000;
D_800A7734 = 0x800A7734;
D_8017A000 = 0x8017A000;
D_8017D000 = 0x8017D000;

View File

@ -1225,7 +1225,7 @@ typedef struct {
TimeAttackEvents eventId, TimeAttackActions action);
/* 8003C844 */ void* (*func_8010E0A8)(void);
/* 8003C848 */ void (*func_800FE044)(s32, s32);
/* 8003C84C */ void (*AddToInventory)(u16 itemId, s32 itemCategory);
/* 8003C84C */ void (*AddToInventory)(u16 id, ItemTypes kind);
/* 8003C850 */ RelicOrb* relicDefs;
/* 8003C854 */ void (*InitStatsAndGear)(bool debugMode);
/* 8003C858 */ s32 (*func_80134714)(s32 arg0, s32 arg1, s32 arg2);
@ -1290,7 +1290,7 @@ extern s32 (*g_api_TimeAttackController)(
TimeAttackEvents eventId, TimeAttackActions action);
extern void* (*g_api_func_8010E0A8)(void);
extern void (*g_api_func_800FE044)(s32, s32);
extern void (*g_api_AddToInventory)(u16 itemId, s32 itemCategory);
extern void (*g_api_AddToInventory)(u16 id, ItemTypes kind);
extern RelicOrb* g_api_relicDefs;
extern s32 (*g_api_func_80134714)(s32 arg0, s32 arg1, s32 arg2);
extern s32 (*g_api_func_80134678)(s16 arg0, u16 arg1);

View File

@ -109,22 +109,22 @@ s32 func_800FD6C4(s32 equipTypeFilter) {
return itemCount;
}
u8* GetEquipOrder(s32 equipTypeFilter) {
if (equipTypeFilter == 0) {
u8* GetEquipOrder(ItemTypes kind) {
if (kind == HAND_TYPE) {
return g_Status.equipHandOrder;
}
return g_Status.equipBodyOrder;
}
u8* GetEquipCount(s32 equipTypeFilter) {
if (equipTypeFilter == 0) {
u8* GetEquipCount(ItemTypes kind) {
if (kind == HAND_TYPE) {
return g_Status.equipHandCount;
}
return g_Status.equipBodyCount;
}
const char* GetEquipmentName(s32 equipTypeFilter, s32 equipId) {
if (!equipTypeFilter) {
const char* GetEquipmentName(ItemTypes kind, s32 equipId) {
if (kind == HAND_TYPE) {
return g_EquipDefs[equipId].name;
} else {
return g_AccessoryDefs[equipId].name;
@ -151,55 +151,58 @@ u32 CheckEquipmentItemCount(u32 itemId, u32 equipType) {
// seems to require missing return
}
#ifndef NON_EQUIVALENT
INCLUDE_ASM("dra/nonmatchings/5D5BC", AddToInventory);
#else
void AddToInventory(u16 itemId, s32 itemCategory) {
u8 temp_a1;
s32 new_var2;
u8* phi_a0;
u8* phi_a0_2;
long i;
s32 phi_a1;
s32 phi_a1_2;
u8* cursorY = GetEquipOrder(itemCategory);
u8* itemArray = GetEquipCount(itemCategory);
if (itemArray[itemId] < 99) {
temp_a1 = itemArray[itemId];
itemArray[itemId]++;
if (itemArray[itemId] == 1) {
itemArray[itemId] = temp_a1;
phi_a1_2 = itemCategory;
if (phi_a1_2 != 0) {
i = g_AccessoryDefs[itemId].equipType;
}
phi_a0 = cursorY;
for (phi_a1_2 = 0; true; phi_a1_2++) {
if (phi_a0[phi_a1_2] == itemId) {
break;
}
}
void AddToInventory(u16 id, ItemTypes kind) {
s32 i;
ItemTypes found;
u8 prevAmount;
u8* order;
u8* count;
u8* pOrder;
s32 existingItemSlot;
s32 emptySlot;
phi_a0_2++;
phi_a0_2 = cursorY;
for (phi_a1 = 0; true; phi_a1++) {
if (((!itemArray[*phi_a0_2]) && phi_a1_2) &&
(i == g_AccessoryDefs[*phi_a0_2].equipType)) {
new_var2 = phi_a1;
cursorY[new_var2] = itemId;
break;
}
}
order = GetEquipOrder(kind);
count = GetEquipCount(kind);
if (count[id] >= 99) {
return;
}
itemArray[itemId]++;
if (new_var2 < phi_a1_2) {
cursorY[phi_a1_2] = cursorY[new_var2];
cursorY[new_var2] = itemId;
}
prevAmount = count[id];
count[id] = prevAmount + 1;
if (count[id] != 1) {
return;
}
count[id] = prevAmount;
if (kind != HAND_TYPE) {
found = g_AccessoryDefs[id].equipType;
}
pOrder = order;
for (i = 0; true; i++) {
if (*pOrder++ == id) {
existingItemSlot = i;
break;
}
}
pOrder = order;
for (i = 0; true; i++, pOrder++) {
if (count[*pOrder] > 0) {
continue;
}
if (kind == HAND_TYPE || found == g_AccessoryDefs[*pOrder].equipType) {
emptySlot = i;
break;
}
}
count[id]++;
if (emptySlot < existingItemSlot) {
order[existingItemSlot] = order[emptySlot];
order[emptySlot] = id;
}
}
#endif
void func_800FD9D4(SpellDef* spell, s32 id) {
*spell = g_SpellDefs[id];

View File

@ -877,11 +877,10 @@ void InitStatsAndGear(bool isDeathTakingItems);
s32 TimeAttackController(TimeAttackEvents eventId, TimeAttackActions action);
s32 func_800FD664(s32 arg0);
s32 func_800FD6C4(s32 equipTypeFilter);
u8* GetEquipOrder(s32 equipTypeFilter);
u8* GetEquipCount(s32 equipTypeFilter);
const char* GetEquipmentName(s32 equipTypeFilter, s32 equipId);
u8* GetEquipOrder(ItemTypes kind);
u8* GetEquipCount(ItemTypes kind);
const char* GetEquipmentName(ItemTypes kind, s32 equipId);
u32 CheckEquipmentItemCount(u32 itemId, u32 equipType);
void AddToInventory(u16 itemId, s32 itemCategory);
void func_800FD9D4(SpellDef* spell, s32 id);
s16 GetStatusAilmentTimer(StatusAilments statusAilment, s16 timer);
void LearnSpell(s32 spellId);

View File

@ -617,8 +617,6 @@ s32 func_800FB23C(MenuNavigation* nav, u8* order, u8* count, u32* selected) {
return 0;
}
void AddToInventory(u16 itemId, s32 itemCategory) { NOT_IMPLEMENTED; }
Entity* GetFreeEntity(s16 start, s16 end);
Entity* CreateEntFactoryFromEntity(
Entity* source, u32 factoryParams, s32 arg2_raw) {