port Room_FindGridShift

This commit is contained in:
Marcin Kurczewski 2024-07-17 17:39:16 +02:00
parent dca77bf8c5
commit 54f8fc4c9f
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
6 changed files with 34 additions and 10 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">45.07% (549)</tspan> · <tspan class="known">52.46% (639)</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">45.16% (550)</tspan> · <tspan class="known">52.38% (638)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="336.70" height="6" x="0" y="0" class="decompiled"/>
<rect width="391.90" height="6" x="336.70" y="0" class="known"/>
<rect width="337.32" height="6" x="0" y="0" class="decompiled"/>
<rect width="391.29" height="6" x="337.32" y="0" class="known"/>
<rect width="18.40" height="6" x="728.60" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -223,7 +223,7 @@
<rect width="12" height="12" x="660" y="30" class="decompiled"><title>void __cdecl CutscenePlayerGen_Initialise(int16_t item_num);</title></rect>
<rect width="12" height="12" x="675" y="30" class="decompiled"><title>void __cdecl Camera_LoadCutsceneFrame(void);</title></rect>
<rect width="12" height="12" x="690" y="30" class="decompiled"><title>void __cdecl Collide_GetCollisionInfo(COLL_INFO *coll, int32_t xpos, int32_t ypos, int32_t zpos, int16_t room_num, int32_t obj_height);</title></rect>
<rect width="12" height="12" x="705" y="30" class="known"><title>int32_t __cdecl Room_FindGridShift(int32_t src, int32_t dst);</title></rect>
<rect width="12" height="12" x="705" y="30" class="decompiled"><title>int32_t __cdecl Room_FindGridShift(int32_t src, int32_t dst);</title></rect>
<rect width="12" height="12" x="720" y="30" class="known"><title>int32_t __cdecl Collide_CollideStaticObjects(COLL_INFO *coll, int32_t x, int32_t y, int32_t z, int16_t room_num, int32_t height);</title></rect>
<rect width="12" height="12" x="735" y="30" class="known"><title>void __cdecl Room_GetNearbyRooms(int32_t x, int32_t y, int32_t z, int32_t r, int32_t h, int16_t room_num);</title></rect>
<rect width="12" height="12" x="0" y="45" class="known"><title>void __cdecl Room_GetNewRoom(int32_t x, int32_t y, int32_t z, int16_t room_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">42.15%</tspan> · <tspan class="known">57.52%</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">42.17%</tspan> · <tspan class="known">57.51%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="314.88" height="6" x="0" y="0" class="decompiled"/>
<rect width="429.68" height="6" x="314.88" y="0" class="known"/>
<rect width="314.98" height="6" x="0" y="0" class="decompiled"/>
<rect width="429.58" height="6" x="314.98" y="0" class="known"/>
<rect width="2.44" height="6" x="744.56" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -2292,7 +2292,7 @@
<rect width="3.18" height="3.45" x="737.65" y="303.07" class="known"><title>void __cdecl CleanupTextures(void);</title></rect>
<rect width="3.18" height="3.45" x="743.82" y="303.07" class="known"><title>BOOL __cdecl OpenRegistryKey(LPCTSTR lpSubKey);</title></rect>
<rect width="3.24" height="3.25" x="675.50" y="309.52" class="decompiled"><title>void __cdecl Creature_Initialise(int16_t item_num);</title></rect>
<rect width="3.24" height="3.25" x="675.50" y="315.77" class="known"><title>int32_t __cdecl Room_FindGridShift(int32_t src, int32_t dst);</title></rect>
<rect width="3.24" height="3.25" x="675.50" y="315.77" class="decompiled"><title>int32_t __cdecl Room_FindGridShift(int32_t src, int32_t dst);</title></rect>
<rect width="3.24" height="3.25" x="675.50" y="322.02" class="known"><title>void __cdecl Inv_Ring_RotateLeft(RING_INFO *ring);</title></rect>
<rect width="3.24" height="3.25" x="675.50" y="328.27" class="known"><title>void __cdecl Inv_Ring_RotateRight(RING_INFO *ring);</title></rect>
<rect width="3.24" height="3.25" x="675.50" y="334.52" class="decompiled"><title>void __cdecl Lara_State_SwanDive(ITEM_INFO *item, COLL_INFO *coll);</title></rect>

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

View File

@ -2738,7 +2738,7 @@ typedef struct {
# game/collide.c
0x004128F0 0x067C + void __cdecl Collide_GetCollisionInfo(COLL_INFO *coll, int32_t xpos, int32_t ypos, int32_t zpos, int16_t room_num, int32_t obj_height);
0x00412FB0 0x002F - int32_t __cdecl Room_FindGridShift(int32_t src, int32_t dst);
0x00412FB0 0x002F + int32_t __cdecl Room_FindGridShift(int32_t src, int32_t dst);
0x00412FE0 0x03D2 - int32_t __cdecl Collide_CollideStaticObjects(COLL_INFO *coll, int32_t x, int32_t y, int32_t z, int16_t room_num, int32_t height);
0x004133D0 0x00C8 - void __cdecl Room_GetNearbyRooms(int32_t x, int32_t y, int32_t z, int32_t r, int32_t h, int16_t room_num);
0x004134A0 0x0055 - void __cdecl Room_GetNewRoom(int32_t x, int32_t y, int32_t z, int16_t room_num);

View File

@ -19,3 +19,19 @@ int16_t Room_GetIndexFromPos(const int32_t x, const int32_t y, const int32_t z)
}
return NO_ROOM;
}
int32_t __cdecl Room_FindGridShift(int32_t src, const int32_t dst)
{
const int32_t src_w = src >> WALL_SHIFT;
const int32_t dst_w = dst >> WALL_SHIFT;
if (src_w == dst_w) {
return 0;
}
src &= WALL_L - 1;
if (dst_w > src_w) {
return WALL_L - (src - 1);
} else {
return -(src + 1);
}
}

View File

@ -3,3 +3,4 @@
#include <stdint.h>
int16_t Room_GetIndexFromPos(int32_t x, int32_t y, int32_t z);
int32_t __cdecl Room_FindGridShift(int32_t src, int32_t dst);

View File

@ -6,7 +6,6 @@
// clang-format off
#define Output_InsertInventoryBackground ((void __cdecl (*)(const int16_t *obj_ptr))0x00401D50)
#define Room_FindGridShift ((int32_t __cdecl (*)(int32_t src, int32_t dst))0x00412FB0)
#define Collide_CollideStaticObjects ((int32_t __cdecl (*)(COLL_INFO *coll, int32_t x, int32_t y, int32_t z, int16_t room_num, int32_t height))0x00412FE0)
#define Room_GetNearbyRooms ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int32_t r, int32_t h, int16_t room_num))0x004133D0)
#define Room_GetNewRoom ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t room_num))0x004134A0)

View File

@ -26,6 +26,7 @@
#include "game/output.h"
#include "game/overlay.h"
#include "game/random.h"
#include "game/room.h"
#include "game/shell.h"
#include "game/sound.h"
#include "game/text.h"
@ -39,6 +40,7 @@ static void Inject_HWR(bool enable);
static void Inject_Camera(bool enable);
static void Inject_Collide(bool enable);
static void Inject_Room(bool enable);
static void Inject_Math(bool enable);
static void Inject_Matrix(bool enable);
static void Inject_Shell(bool enable);
@ -228,6 +230,11 @@ static void Inject_Collide(const bool enable)
INJECT(enable, 0x004128F0, Collide_GetCollisionInfo);
}
static void Inject_Room(const bool enable)
{
INJECT(enable, 0x00412FB0, Room_FindGridShift);
}
static void Inject_Matrix(const bool enable)
{
INJECT(enable, 0x00401000, Matrix_GenerateW2V);
@ -732,6 +739,7 @@ void Inject_Exec(void)
Inject_Camera(true);
Inject_Collide(true);
Inject_Room(true);
Inject_Math(true);
Inject_Matrix(true);
Inject_Shell(true);