port Boat_TestWaterHeight

This commit is contained in:
Marcin Kurczewski 2024-07-16 10:11:01 +02:00
parent c7f8bc98ce
commit 92aed53c64
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
6 changed files with 41 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">44.25% (539)</tspan> · <tspan class="known">53.28% (649)</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">44.33% (540)</tspan> · <tspan class="known">53.20% (648)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="330.57" height="6" x="0" y="0" class="decompiled"/>
<rect width="398.03" height="6" x="330.57" y="0" class="known"/>
<rect width="331.18" height="6" x="0" y="0" class="decompiled"/>
<rect width="397.42" height="6" x="331.18" y="0" class="known"/>
<rect width="18.40" height="6" x="728.60" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -165,7 +165,7 @@
<rect width="12" height="12" x="540" y="15" class="decompiled"><title>void __cdecl Boat_Initialise(int16_t item_num);</title></rect>
<rect width="12" height="12" x="555" y="15" class="decompiled"><title>int32_t __cdecl Boat_CheckGeton(int16_t item_num, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="570" y="15" class="decompiled"><title>void __cdecl Boat_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="585" y="15" class="known"><title>int32_t __cdecl Boat_TestWaterHeight(ITEM_INFO *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);</title></rect>
<rect width="12" height="12" x="585" y="15" class="decompiled"><title>int32_t __cdecl Boat_TestWaterHeight(ITEM_INFO *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);</title></rect>
<rect width="12" height="12" x="600" y="15" class="known"><title>void __cdecl Boat_DoShift(int32_t boat_num);</title></rect>
<rect width="12" height="12" x="615" y="15" class="known"><title>void __cdecl Boat_DoWakeEffect(ITEM_INFO *boat);</title></rect>
<rect width="12" height="12" x="630" y="15" class="known"><title>int32_t __cdecl Boat_DoDynamics(int32_t height, int32_t fall_speed, int32_t *y);</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">40.23%</tspan> · <tspan class="known">59.44%</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">40.30%</tspan> · <tspan class="known">59.37%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="300.53" height="6" x="0" y="0" class="decompiled"/>
<rect width="444.03" height="6" x="300.53" y="0" class="known"/>
<rect width="301.08" height="6" x="0" y="0" class="decompiled"/>
<rect width="443.48" height="6" x="301.08" y="0" class="known"/>
<rect width="2.44" height="6" x="744.56" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -1671,7 +1671,7 @@
<rect width="11.45" height="11.42" x="480.35" y="151.76" class="decompiled"><title>void __cdecl Lara_Col_Back(ITEM_INFO *item, COLL_INFO *coll);</title></rect>
<rect width="11.45" height="11.36" x="480.35" y="166.18" class="known"><title>void __cdecl Lara_InitialiseMeshes(int32_t level_num);</title></rect>
<rect width="11.45" height="11.36" x="480.35" y="180.54" class="known"><title>BOOL __cdecl DecompPCX(const uint8_t *pcx, size_t pcx_size, LPBYTE pic, RGB_888 *pal);</title></rect>
<rect width="11.45" height="11.24" x="480.35" y="194.89" class="known"><title>int32_t __cdecl Boat_TestWaterHeight(ITEM_INFO *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);</title></rect>
<rect width="11.45" height="11.24" x="480.35" y="194.89" class="decompiled"><title>int32_t __cdecl Boat_TestWaterHeight(ITEM_INFO *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);</title></rect>
<rect width="11.45" height="11.24" x="480.35" y="209.14" class="decompiled"><title>int32_t __cdecl Creature_CheckBaddieOverlap(int16_t item_num);</title></rect>
<rect width="11.45" height="11.24" x="480.35" y="223.38" class="known"><title>void __cdecl DrawFlareInAir(ITEM_INFO *item);</title></rect>
<rect width="11.45" height="11.24" x="480.35" y="237.63" class="known"><title>void __cdecl SkidooCollision(int16_t item_num, ITEM_INFO *litem, COLL_INFO *coll);</title></rect>

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

View File

@ -2194,7 +2194,7 @@ typedef struct {
0x0040CB30 0x003C + void __cdecl Boat_Initialise(int16_t item_num);
0x0040CB70 0x0170 + int32_t __cdecl Boat_CheckGeton(int16_t item_num, COLL_INFO *coll);
0x0040CCE0 0x015E + void __cdecl Boat_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
0x0040CE40 0x00F8 - int32_t __cdecl Boat_TestWaterHeight(ITEM_INFO *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);
0x0040CE40 0x00F8 + int32_t __cdecl Boat_TestWaterHeight(ITEM_INFO *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);
0x0040CF40 0x01C1 - void __cdecl Boat_DoShift(int32_t boat_num);
0x0040D110 0x0174 - void __cdecl Boat_DoWakeEffect(ITEM_INFO *boat);
0x0040D290 0x004B - int32_t __cdecl Boat_DoDynamics(int32_t height, int32_t fall_speed, int32_t *y);

View File

@ -145,3 +145,32 @@ void __cdecl Boat_Collision(
boat->status = IS_ACTIVE;
}
}
int32_t __cdecl Boat_TestWaterHeight(
const ITEM_INFO *const item, const int32_t z_off, const int32_t x_off,
XYZ_32 *const pos)
{
// clang-format off
pos->y = item->pos.y
+ ((x_off * Math_Sin(item->rot.z)) >> W2V_SHIFT)
- ((z_off * Math_Sin(item->rot.x)) >> W2V_SHIFT);
// clang-format on
const int32_t c = Math_Cos(item->rot.y);
const int32_t s = Math_Sin(item->rot.y);
pos->x = item->pos.x + ((x_off * c + z_off * s) >> W2V_SHIFT);
pos->z = item->pos.z + ((z_off * c - x_off * s) >> W2V_SHIFT);
int16_t room_num = item->room_num;
Room_GetFloor(pos->x, pos->y, pos->z, &room_num);
int32_t height = Room_GetWaterHeight(pos->x, pos->y, pos->z, room_num);
if (height == NO_HEIGHT) {
FLOOR_INFO *floor = Room_GetFloor(pos->x, pos->y, pos->z, &room_num);
height = Room_GetHeight(floor, pos->x, pos->y, pos->z);
if (height != NO_HEIGHT) {
return height;
}
}
return height - 5;
}

View File

@ -7,3 +7,5 @@
void __cdecl Boat_Initialise(int16_t item_num);
int32_t __cdecl Boat_CheckGeton(int16_t item_num, const COLL_INFO *coll);
void __cdecl Boat_Collision(int16_t item_num, ITEM_INFO *lara, COLL_INFO *coll);
int32_t __cdecl Boat_TestWaterHeight(
const ITEM_INFO *item, int32_t z_off, int32_t x_off, XYZ_32 *pos);

View File

@ -6,7 +6,6 @@
// clang-format off
#define Output_InsertInventoryBackground ((void __cdecl (*)(const int16_t *obj_ptr))0x00401D50)
#define Boat_TestWaterHeight ((int32_t __cdecl (*)(ITEM_INFO *item, int32_t z_off, int32_t x_off, XYZ_32 *pos))0x0040CE40)
#define Boat_DoShift ((void __cdecl (*)(int32_t boat_num))0x0040CF40)
#define Boat_DoWakeEffect ((void __cdecl (*)(ITEM_INFO *boat))0x0040D110)
#define Boat_DoDynamics ((int32_t __cdecl (*)(int32_t height, int32_t fall_speed, int32_t *y))0x0040D290)

View File

@ -664,6 +664,7 @@ static void Inject_Objects(const bool enable)
INJECT(enable, 0x0040CB30, Boat_Initialise);
INJECT(enable, 0x0040CB70, Boat_CheckGeton);
INJECT(enable, 0x0040CCE0, Boat_Collision);
INJECT(enable, 0x0040CE40, Boat_TestWaterHeight);
}
static void Inject_S_Audio_Sample(const bool enable)