port Lara_IsNearItem

This commit is contained in:
Marcin Kurczewski 2024-07-27 13:57:02 +02:00
parent 7cb3bcb424
commit 97a2024cc2
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
8 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">48.69% (593)</tspan> · <tspan class="known">48.85% (595)</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">48.77% (594)</tspan> · <tspan class="known">48.77% (594)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="363.69" height="6" x="0" y="0" class="decompiled"/>
<rect width="364.91" height="6" x="363.69" y="0" class="known"/>
<rect width="364.30" height="6" x="0" y="0" class="decompiled"/>
<rect width="364.30" height="6" x="364.30" y="0" class="known"/>
<rect width="18.40" height="6" x="728.60" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -317,7 +317,7 @@
<rect width="12" height="12" x="570" y="60" class="known"><title>void __cdecl AddDynamicLight(int32_t x, int32_t y, int32_t z, int32_t intensity, int32_t falloff);</title></rect>
<rect width="12" height="12" x="585" y="60" class="known"><title>void __cdecl BigEelControl(int16_t item_num);</title></rect>
<rect width="12" height="12" x="600" y="60" class="known"><title>void __cdecl EelControl(int16_t item_num);</title></rect>
<rect width="12" height="12" x="615" y="60" class="known"><title>int32_t __cdecl ItemNearLara(PHD_3DPOS *pos, int32_t distance);</title></rect>
<rect width="12" height="12" x="615" y="60" class="decompiled"><title>int32_t __cdecl Lara_IsNearItem(PHD_3DPOS *pos, int32_t distance);</title></rect>
<rect width="12" height="12" x="630" y="60" class="decompiled"><title>void __cdecl Sound_UpdateEffects(void);</title></rect>
<rect width="12" height="12" x="645" y="60" class="known"><title>int16_t __cdecl DoBloodSplat(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE direction, int16_t room_num);</title></rect>
<rect width="12" height="12" x="660" y="60" class="known"><title>void __cdecl DoLotsOfBlood(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE direction, int16_t room_num, int32_t 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">46.66%</tspan> · <tspan class="known">53.02%</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">46.70%</tspan> · <tspan class="known">52.98%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="348.52" height="6" x="0" y="0" class="decompiled"/>
<rect width="396.04" height="6" x="348.52" y="0" class="known"/>
<rect width="348.83" height="6" x="0" y="0" class="decompiled"/>
<rect width="395.73" height="6" x="348.83" y="0" class="known"/>
<rect width="2.44" height="6" x="744.56" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -1890,7 +1890,7 @@
<rect width="7.69" height="8.03" x="665.49" y="185.54" class="decompiled"><title>void __cdecl HWR_LoadTexturePages(int32_t pages_count, void *pages_buf, RGB_888 *palette);</title></rect>
<rect width="7.61" height="8.03" x="676.18" y="185.54" class="known"><title>void __cdecl DetonatorControl(int16_t item_num);</title></rect>
<rect width="7.54" height="8.03" x="686.79" y="185.54" class="decompiled"><title>const int16_t *__cdecl Output_InsertObjectGT4_Sorted(const int16_t *obj_ptr, int32_t num, SORT_TYPE sort_type);</title></rect>
<rect width="7.54" height="8.03" x="697.32" y="185.54" class="known"><title>int32_t __cdecl ItemNearLara(PHD_3DPOS *pos, int32_t distance);</title></rect>
<rect width="7.54" height="8.03" x="697.32" y="185.54" class="decompiled"><title>int32_t __cdecl Lara_IsNearItem(PHD_3DPOS *pos, int32_t distance);</title></rect>
<rect width="7.54" height="8.03" x="707.86" y="185.54" class="known"><title>void __cdecl ControlSnowSprite(int16_t fx_num);</title></rect>
<rect width="7.54" height="8.03" x="718.39" y="185.54" class="decompiled"><title>void __cdecl Text_AddBackground(TEXTSTRING *string, int16_t x_size, int16_t y_size, int16_t x_off, int16_t y_off, int16_t z_off, int16_t colour, uint16_t *gour_ptr, uint16_t flags);</title></rect>
<rect width="7.54" height="8.03" x="728.93" y="185.54" class="unused"><title>sub_444B20</title></rect>

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

View File

@ -2941,7 +2941,7 @@ typedef enum {
0x0041C2E0 0x01E1 -R void __cdecl EelControl(int16_t item_num);
# game/effects.c
0x0041C4D0 0x008C -R int32_t __cdecl ItemNearLara(PHD_3DPOS *pos, int32_t distance);
0x0041C4D0 0x008C + int32_t __cdecl Lara_IsNearItem(PHD_3DPOS *pos, int32_t distance);
0x0041C560 0x0068 + void __cdecl Sound_UpdateEffects(void);
0x0041C5D0 0x0059 -R int16_t __cdecl DoBloodSplat(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE direction, int16_t room_num);
0x0041C630 0x00A4 -R void __cdecl DoLotsOfBlood(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE direction, int16_t room_num, int32_t num);

View File

@ -722,3 +722,26 @@ int16_t *__cdecl Item_GetBestFrame(const ITEM_INFO *const item)
const int32_t frac = Item_GetFrames(item, (int16_t **)frmptr, &rate);
return (int16_t *)frmptr[frac > rate / 2 ? 1 : 0];
}
bool __cdecl Item_IsNearItem(
const ITEM_INFO *const item, const XYZ_32 *const pos,
const int32_t distance)
{
const XYZ_32 d = {
.x = item->pos.x - pos->x,
.y = item->pos.y - pos->y,
.z = item->pos.z - pos->z,
};
if (ABS(d.x) > distance || ABS(d.z) > distance || ABS(d.y) > WALL_L * 3) {
return false;
}
if (SQUARE(d.x) + SQUARE(d.z) > SQUARE(distance)) {
return false;
}
const BOUNDS_16 *const bounds =
(const BOUNDS_16 *)Item_GetBoundsAccurate(item);
return d.y >= bounds->min_y && d.y <= bounds->max_y + 100;
}

View File

@ -31,5 +31,7 @@ int32_t __cdecl Item_GetFrames(
const ITEM_INFO *item, int16_t *frmptr[], int32_t *rate);
int16_t *__cdecl Item_GetBoundsAccurate(const ITEM_INFO *item);
int16_t *__cdecl Item_GetBestFrame(const ITEM_INFO *item);
bool __cdecl Item_IsNearItem(
const ITEM_INFO *item, const XYZ_32 *pos, int32_t distance);
bool Item_IsSmashable(const ITEM_INFO *item);

View File

@ -1206,3 +1206,8 @@ int32_t __cdecl Lara_MovePosition(
return Misc_Move3DPosTo3DPos(
&lara_item->pos_full, &new_pos_full, MOVE_SPEED, MOVE_ANGLE);
}
int32_t __cdecl Lara_IsNearItem(const XYZ_32 *const pos, const int32_t distance)
{
return Item_IsNearItem(g_LaraItem, pos, distance);
}

View File

@ -55,3 +55,4 @@ void __cdecl Lara_Push(
bool big_push);
int32_t __cdecl Lara_MovePosition(
XYZ_32 *vec, ITEM_INFO *item, ITEM_INFO *lara_item);
int32_t __cdecl Lara_IsNearItem(const XYZ_32 *pos, int32_t distance);

View File

@ -38,7 +38,6 @@
#define AddDynamicLight ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int32_t intensity, int32_t falloff))0x0041C0F0)
#define BigEelControl ((void __cdecl (*)(int16_t item_num))0x0041C140)
#define EelControl ((void __cdecl (*)(int16_t item_num))0x0041C2E0)
#define ItemNearLara ((int32_t __cdecl (*)(PHD_3DPOS *pos, int32_t distance))0x0041C4D0)
#define DoBloodSplat ((int16_t __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE direction, int16_t room_num))0x0041C5D0)
#define DoLotsOfBlood ((void __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE direction, int16_t room_num, int32_t num))0x0041C630)
#define ControlBlood1 ((void __cdecl (*)(int16_t fx_num))0x0041C6E0)

View File

@ -556,6 +556,7 @@ static void Inject_Lara_Misc(const bool enable)
INJECT(enable, 0x004137E0, Lara_TakeHit);
INJECT(enable, 0x00413A30, Lara_Push);
INJECT(enable, 0x00414090, Lara_MovePosition);
INJECT(enable, 0x0041C4D0, Lara_IsNearItem);
}
static void Inject_Lara_State(const bool enable)