port Inv_InsertItem

This commit is contained in:
rr- 2021-03-01 23:24:56 +01:00
parent 1b65fdcb4c
commit dc4abcd9ee
4 changed files with 58 additions and 10 deletions

View file

@ -295,7 +295,7 @@
<rect width="12.00" height="12.00" x="588.00" y="87.00" fill="forestgreen"/> <rect width="12.00" height="12.00" x="588.00" y="87.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="602.00" y="87.00" fill="forestgreen"/> <rect width="12.00" height="12.00" x="602.00" y="87.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="616.00" y="87.00" fill="forestgreen"/> <rect width="12.00" height="12.00" x="616.00" y="87.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="630.00" y="87.00" fill="lightpink"/> <rect width="12.00" height="12.00" x="630.00" y="87.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="644.00" y="87.00" fill="lightpink"/> <rect width="12.00" height="12.00" x="644.00" y="87.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="658.00" y="87.00" fill="lightpink"/> <rect width="12.00" height="12.00" x="658.00" y="87.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="672.00" y="87.00" fill="lightpink"/> <rect width="12.00" height="12.00" x="672.00" y="87.00" fill="lightpink"/>
@ -983,7 +983,7 @@
<rect width="12.47" height="13.61" x="497.39" y="385.50" fill="forestgreen"/> <rect width="12.47" height="13.61" x="497.39" y="385.50" fill="forestgreen"/>
<rect width="12.47" height="13.56" x="497.39" y="401.11" fill="forestgreen"/> <rect width="12.47" height="13.56" x="497.39" y="401.11" fill="forestgreen"/>
<rect width="12.47" height="13.46" x="497.39" y="416.67" fill="lightpink"/> <rect width="12.47" height="13.46" x="497.39" y="416.67" fill="lightpink"/>
<rect width="12.47" height="13.35" x="497.39" y="432.13" fill="lightpink"/> <rect width="12.47" height="13.35" x="497.39" y="432.13" fill="forestgreen"/>
<rect width="12.47" height="13.35" x="497.39" y="447.48" fill="lightpink"/> <rect width="12.47" height="13.35" x="497.39" y="447.48" fill="lightpink"/>
<rect width="12.47" height="13.30" x="497.39" y="462.84" fill="lightpink"/> <rect width="12.47" height="13.30" x="497.39" y="462.84" fill="lightpink"/>
<rect width="12.47" height="13.09" x="497.39" y="478.14" fill="forestgreen"/> <rect width="12.47" height="13.09" x="497.39" y="478.14" fill="forestgreen"/>
@ -1463,10 +1463,10 @@
<rect width="-0.06" height="-0.07" x="694.51" y="536.07" fill="mistyrose"/> <rect width="-0.06" height="-0.07" x="694.51" y="536.07" fill="mistyrose"/>
<rect width="-0.45" height="-0.55" x="696.45" y="536.07" fill="mistyrose"/> <rect width="-0.45" height="-0.55" x="696.45" y="536.07" fill="mistyrose"/>
<rect width="-0.45" height="-1.52" x="696.45" y="537.52" fill="lightpink"/> <rect width="-0.45" height="-1.52" x="696.45" y="537.52" fill="lightpink"/>
<rect width="12.00" height="12.00" x="0.00" y="564.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="570.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (count): 42.68%</text> <rect width="12.00" height="12.00" x="0.00" y="564.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="570.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (count): 42.82%</text>
<rect width="12.00" height="12.00" x="0.00" y="582.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="588.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (bytesize): 42.98%</text> <rect width="12.00" height="12.00" x="0.00" y="582.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="588.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (bytesize): 43.10%</text>
<rect width="12.00" height="12.00" x="0.00" y="600.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="606.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (count): 43.23%</text> <rect width="12.00" height="12.00" x="0.00" y="600.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="606.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (count): 43.09%</text>
<rect width="12.00" height="12.00" x="0.00" y="618.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="624.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (bytesize): 41.19%</text> <rect width="12.00" height="12.00" x="0.00" y="618.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="624.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (bytesize): 41.07%</text>
<rect width="12.00" height="12.00" x="0.00" y="636.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="642.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (count): 14.09%</text> <rect width="12.00" height="12.00" x="0.00" y="636.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="642.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (count): 14.09%</text>
<rect width="12.00" height="12.00" x="0.00" y="654.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="660.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (bytesize): 15.83%</text> <rect width="12.00" height="12.00" x="0.00" y="654.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="660.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (bytesize): 15.83%</text>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Before After
Before After

View file

@ -409,7 +409,7 @@ RingIsNotOpen 0x00420150 0x00000076 +
RingNotActive 0x004201D0 0x0000069E + RingNotActive 0x004201D0 0x0000069E +
RingActive 0x00420980 0x00000039 + RingActive 0x00420980 0x00000039 +
Inv_AddItem 0x004209C0 0x00000620 + Inv_AddItem 0x004209C0 0x00000620 +
Inv_InsertItem 0x004210D0 0x00000129 * Inv_InsertItem 0x004210D0 0x00000129 +
Inv_RequestItem 0x00421200 0x00000077 * Inv_RequestItem 0x00421200 0x00000077 *
Inv_RemoveAllItems 0x00421280 0x0000001E * Inv_RemoveAllItems 0x00421280 0x0000001E *
Inv_RemoveItem 0x004212A0 0x00000110 * Inv_RemoveItem 0x004212A0 0x00000110 *

View file

@ -6,7 +6,6 @@
// clang-format off // clang-format off
#define RemoveInventoryText ((void (*)())0x00421550) #define RemoveInventoryText ((void (*)())0x00421550)
#define Inv_InsertItem ((void (*)(INVENTORY_ITEM* inv_item))0x004210D0)
#define Inv_RemoveAllItems ((void (*)())0x00421280) #define Inv_RemoveAllItems ((void (*)())0x00421280)
#define Inv_RemoveItem ((void (*)(int16_t item_num))0x004212A0) #define Inv_RemoveItem ((void (*)(int16_t item_num))0x004212A0)
#define Inv_GetItemOption ((int32_t (*)(int32_t item_num))0x004213B0) #define Inv_GetItemOption ((int32_t (*)(int32_t item_num))0x004213B0)
@ -41,6 +40,7 @@ void RingNotActive(INVENTORY_ITEM* inv_item);
void RingActive(); void RingActive();
int32_t Inv_AddItem(int32_t item_num); int32_t Inv_AddItem(int32_t item_num);
void Inv_InsertItem(INVENTORY_ITEM* inv_item);
void T1MInjectGameInvEntry(); void T1MInjectGameInvEntry();
void T1MInjectGameInvFunc(); void T1MInjectGameInvFunc();

View file

@ -298,7 +298,7 @@ int32_t Inv_AddItem(int32_t item_num)
for (int i = 0; i < InvMainObjects; i++) { for (int i = 0; i < InvMainObjects; i++) {
INVENTORY_ITEM* inv_item = InvMainList[i]; INVENTORY_ITEM* inv_item = InvMainList[i];
if (inv_item->object_number == item_num_option) { if (inv_item->object_number == item_num_option) {
++InvMainQtys[i]; InvMainQtys[i]++;
return 1; return 1;
} }
} }
@ -306,7 +306,7 @@ int32_t Inv_AddItem(int32_t item_num)
for (int i = 0; i < InvKeysObjects; i++) { for (int i = 0; i < InvKeysObjects; i++) {
INVENTORY_ITEM* inv_item = InvKeysList[i]; INVENTORY_ITEM* inv_item = InvKeysList[i];
if (inv_item->object_number == item_num_option) { if (inv_item->object_number == item_num_option) {
++InvKeysQtys[i]; InvKeysQtys[i]++;
return 1; return 1;
} }
} }
@ -452,6 +452,53 @@ int32_t Inv_AddItem(int32_t item_num)
return 0; return 0;
} }
void Inv_InsertItem(INVENTORY_ITEM* inv_item)
{
int n;
if (inv_item->inv_pos < 100) {
for (n = 0; n < InvMainObjects; n++) {
if (InvMainList[n]->inv_pos > inv_item->inv_pos) {
break;
}
}
if (n == InvMainObjects) {
InvMainList[InvMainObjects] = inv_item;
InvMainQtys[InvMainObjects] = 1;
InvMainObjects++;
} else {
for (int i = InvMainObjects; i > n - 1; i--) {
InvMainList[i + 1] = InvMainList[i];
InvMainQtys[i + 1] = InvMainQtys[i];
}
InvMainList[n] = inv_item;
InvMainQtys[n] = 1;
InvMainObjects++;
}
} else {
for (n = 0; n < InvKeysObjects; n++) {
if (InvKeysList[n]->inv_pos > inv_item->inv_pos) {
break;
}
}
if (n == InvKeysObjects) {
InvKeysList[InvKeysObjects] = inv_item;
InvKeysQtys[InvKeysObjects] = 1;
InvKeysObjects++;
} else {
for (int i = InvKeysObjects; i > n - 1; i--) {
InvKeysList[i + 1] = InvKeysList[i];
InvKeysQtys[i + 1] = InvKeysQtys[i];
}
InvKeysList[n] = inv_item;
InvKeysQtys[n] = 1;
InvKeysObjects++;
}
}
}
void T1MInjectGameInvFunc() void T1MInjectGameInvFunc()
{ {
INJECT(0x0041FEF0, InitColours); INJECT(0x0041FEF0, InitColours);
@ -460,4 +507,5 @@ void T1MInjectGameInvFunc()
INJECT(0x004201D0, RingNotActive); INJECT(0x004201D0, RingNotActive);
INJECT(0x00420980, RingActive); INJECT(0x00420980, RingActive);
INJECT(0x004209C0, Inv_AddItem); INJECT(0x004209C0, Inv_AddItem);
INJECT(0x004210D0, Inv_InsertItem);
} }