port Inv_InsertItem

This commit is contained in:
Marcin Kurczewski 2024-09-05 17:31:23 +02:00
parent 5f3b877114
commit e658ccd8c6
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
7 changed files with 52 additions and 16 deletions

View File

@ -69,10 +69,10 @@
</g>
<g transform="translate(0 116)">
<text x="0" y="7.50">Tomb2.exe progress according to the physical function order:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">60.26% (734)</tspan> · <tspan class="known">37.27% (454)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">60.34% (735)</tspan> · <tspan class="known">37.19% (453)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="450.16" height="6" x="0" y="0" class="decompiled"/>
<rect width="278.44" height="6" x="450.16" y="0" class="known"/>
<rect width="450.78" height="6" x="0" y="0" class="decompiled"/>
<rect width="277.83" height="6" x="450.78" y="0" class="known"/>
<rect width="18.40" height="6" x="728.60" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -416,7 +416,7 @@
<rect width="12" height="12" x="555" y="90" class="known"><title>void __cdecl RingNotActive(INVENTORY_ITEM *inv_item);</title></rect>
<rect width="12" height="12" x="570" y="90" class="known"><title>void __cdecl RingActive(void);</title></rect>
<rect width="12" height="12" x="585" y="90" class="decompiled"><title>int32_t __cdecl Inv_AddItem(GAME_OBJECT_ID object_num);</title></rect>
<rect width="12" height="12" x="600" y="90" class="known"><title>void __cdecl Inv_InsertItem(INVENTORY_ITEM *inv_item);</title></rect>
<rect width="12" height="12" x="600" y="90" class="decompiled"><title>void __cdecl Inv_InsertItem(INVENTORY_ITEM *inv_item);</title></rect>
<rect width="12" height="12" x="615" y="90" class="known"><title>int32_t __cdecl Inv_RequestItem(GAME_OBJECT_ID object_num);</title></rect>
<rect width="12" height="12" x="630" y="90" class="known"><title>void __cdecl Inv_RemoveAllItems(void);</title></rect>
<rect width="12" height="12" x="645" y="90" class="known"><title>int32_t __cdecl Inv_RemoveItem(GAME_OBJECT_ID object_num);</title></rect>
@ -1298,10 +1298,10 @@
</g>
<g transform="translate(0 546)">
<text x="0" y="7.50">Tomb2.exe progress according to the function sizes:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">64.16%</tspan> · <tspan class="known">35.51%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">64.25%</tspan> · <tspan class="known">35.43%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="479.27" height="6" x="0" y="0" class="decompiled"/>
<rect width="265.29" height="6" x="479.27" y="0" class="known"/>
<rect width="479.92" height="6" x="0" y="0" class="decompiled"/>
<rect width="264.64" height="6" x="479.92" y="0" class="known"/>
<rect width="2.44" height="6" x="744.56" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -1620,7 +1620,7 @@
<rect width="13.19" height="12.58" x="546.69" y="92.72" class="decompiled"><title>int32_t __cdecl Lara_TestSlide(ITEM_INFO *item, COLL_INFO *coll);</title></rect>
<rect width="13.03" height="12.58" x="562.89" y="92.72" class="known"><title>void __cdecl DrawSphereOfDoom(ITEM_INFO *item);</title></rect>
<rect width="12.93" height="12.58" x="578.92" y="92.72" class="decompiled"><title>void __cdecl Output_InsertLine_Sorted(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t z, uint8_t color_idx);</title></rect>
<rect width="12.82" height="12.58" x="594.84" y="92.72" class="known"><title>void __cdecl Inv_InsertItem(INVENTORY_ITEM *inv_item);</title></rect>
<rect width="12.82" height="12.58" x="594.84" y="92.72" class="decompiled"><title>void __cdecl Inv_InsertItem(INVENTORY_ITEM *inv_item);</title></rect>
<rect width="12.77" height="12.58" x="610.66" y="92.72" class="known"><title>void __cdecl SphereOfDoomCollision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12.77" height="12.58" x="626.43" y="92.72" class="known"><title>int32_t __cdecl Collide_TestCollision(ITEM_INFO *item, const ITEM_INFO *lara_item);</title></rect>
<rect width="12.77" height="12.58" x="642.20" y="92.72" class="decompiled"><title>void __cdecl HWR_InitState(void);</title></rect>

Before

Width:  |  Height:  |  Size: 364 KiB

After

Width:  |  Height:  |  Size: 364 KiB

View File

@ -3214,7 +3214,7 @@ typedef enum {
0x00423E40 0x0369 -R void __cdecl RingNotActive(INVENTORY_ITEM *inv_item);
0x004242B0 0x0032 -R void __cdecl RingActive(void);
0x004242F0 0x06BE + int32_t __cdecl Inv_AddItem(GAME_OBJECT_ID object_num);
0x00424B00 0x0129 - void __cdecl Inv_InsertItem(INVENTORY_ITEM *inv_item);
0x00424B00 0x0129 + void __cdecl Inv_InsertItem(INVENTORY_ITEM *inv_item);
0x00424C30 0x0077 - int32_t __cdecl Inv_RequestItem(GAME_OBJECT_ID object_num);
0x00424CB0 0x001B - void __cdecl Inv_RemoveAllItems(void);
0x00424CD0 0x0110 - int32_t __cdecl Inv_RemoveItem(GAME_OBJECT_ID object_num);
@ -4664,8 +4664,8 @@ typedef enum {
0x00521BE0 - uint32_t g_SaveGameReqFlags2[24]; // MAX_REQUESTER_ITEMS
0x004D9EC8 - int32_t g_SaveCounter;
0x00466B80 - int16_t g_SavedLevels[24]; // MAX_LEVELS
0x004654E8 - int16_t g_InvMainQtys[];
0x00465578 - int16_t g_InvKeysQtys[];
0x004654E8 - int16_t g_Inv_MainQtys[];
0x00465578 - int16_t g_Inv_KeysQtys[];
0x0046773C - int32_t g_DetailLevel;
0x0051A250 - int32_t g_LayoutPage;
0x0051A24C + int32_t g_KeySelector;

View File

@ -5,6 +5,41 @@
#include "global/funcs.h"
#include "global/vars.h"
void __cdecl Inv_InsertItem(INVENTORY_ITEM *const inv_item)
{
int32_t n;
if (inv_item->inv_pos < 100) {
for (n = 0; n < g_Inv_MainObjectsCount; n++) {
if (g_Inv_MainList[n]->inv_pos > inv_item->inv_pos) {
break;
}
}
for (int32_t i = g_Inv_MainObjectsCount; i > n - 1; i--) {
g_Inv_MainList[i + 1] = g_Inv_MainList[i];
g_Inv_MainQtys[i + 1] = g_Inv_MainQtys[i];
}
g_Inv_MainList[n] = inv_item;
g_Inv_MainQtys[n] = 1;
g_Inv_MainObjectsCount++;
} else {
for (n = 0; n < g_Inv_KeyObjectsCount; n++) {
if (g_Inv_KeysList[n]->inv_pos > inv_item->inv_pos) {
break;
}
}
for (int i = g_Inv_KeyObjectsCount; i > n - 1; i--) {
g_Inv_KeysList[i + 1] = g_Inv_KeysList[i];
g_Inv_KeysQtys[i + 1] = g_Inv_KeysQtys[i];
}
g_Inv_KeysList[n] = inv_item;
g_Inv_KeysQtys[n] = 1;
g_Inv_KeyObjectsCount++;
}
}
int32_t __cdecl Inv_AddItem(const GAME_OBJECT_ID object_id)
{
const GAME_OBJECT_ID inv_object_id = Inv_GetItemOption(object_id);
@ -16,7 +51,7 @@ int32_t __cdecl Inv_AddItem(const GAME_OBJECT_ID object_id)
const INVENTORY_ITEM *const inv_item = g_Inv_MainList[i];
if (inv_item->obj_num == inv_object_id) {
const int32_t qty = object_id == O_FLARES_ITEM ? FLARE_AMMO_QTY : 1;
g_InvMainQtys[i] += qty;
g_Inv_MainQtys[i] += qty;
return true;
}
}
@ -24,7 +59,7 @@ int32_t __cdecl Inv_AddItem(const GAME_OBJECT_ID object_id)
for (int32_t i = 0; i < g_Inv_KeyObjectsCount; i++) {
const INVENTORY_ITEM *const inv_item = g_Inv_KeysList[i];
if (inv_item->obj_num == inv_object_id) {
g_InvKeysQtys[i]++;
g_Inv_KeysQtys[i]++;
return true;
}
}

View File

@ -2,5 +2,6 @@
#include "global/types.h"
void __cdecl Inv_InsertItem(INVENTORY_ITEM *inv_item);
int32_t __cdecl Inv_AddItem(GAME_OBJECT_ID object_id);
void Inv_AddItemNTimes(GAME_OBJECT_ID object_num, int32_t qty);

View File

@ -100,7 +100,6 @@
#define RingIsNotOpen ((void __cdecl (*)(RING_INFO *ring))0x00423DB0)
#define RingNotActive ((void __cdecl (*)(INVENTORY_ITEM *inv_item))0x00423E40)
#define RingActive ((void __cdecl (*)(void))0x004242B0)
#define Inv_InsertItem ((void __cdecl (*)(INVENTORY_ITEM *inv_item))0x00424B00)
#define Inv_RequestItem ((int32_t __cdecl (*)(GAME_OBJECT_ID object_num))0x00424C30)
#define Inv_RemoveAllItems ((void __cdecl (*)(void))0x00424CB0)
#define Inv_RemoveItem ((int32_t __cdecl (*)(GAME_OBJECT_ID object_num))0x00424CD0)

View File

@ -62,9 +62,9 @@
#define g_Inv_Item_Controls (*(INVENTORY_ITEM*)0x00465440)
#define g_Inv_Item_Photo (*(INVENTORY_ITEM*)0x00465490)
#define g_Inv_MainObjectsCount (*(int16_t*)0x004654E0) // = 8
#define g_InvMainQtys (*(int16_t(*)[])0x004654E8)
#define g_Inv_MainQtys (*(int16_t(*)[])0x004654E8)
#define g_Inv_MainList (*(INVENTORY_ITEM *(*)[])0x00465518)
#define g_InvKeysQtys (*(int16_t(*)[])0x00465578)
#define g_Inv_KeysQtys (*(int16_t(*)[])0x00465578)
#define g_Inv_KeysList (*(INVENTORY_ITEM *(*)[])0x004655A8)
#define g_GymInvOpenEnabled (*(BOOL*)0x00465618) // = TRUE
#define g_LoadGameRequester (*(REQUEST_INFO*)0x00465620)

View File

@ -622,6 +622,7 @@ static void Inject_Inventory(const bool enable)
INJECT(enable, 0x00423500, Inv_AnimateInventoryItem);
INJECT(enable, 0x00423590, Inv_DrawInventoryItem);
INJECT(enable, 0x004242F0, Inv_AddItem);
INJECT(enable, 0x00424B00, Inv_InsertItem);
INJECT(enable, 0x00424DE0, Inv_GetItemOption);
INJECT(enable, 0x00425000, Inv_Ring_Init);
INJECT(enable, 0x00425110, Inv_Ring_GetView);