port LOT_CreateZone

This commit is contained in:
Marcin Kurczewski 2024-08-05 19:51:39 +02:00
parent 6afd573c93
commit e8bd6bcc04
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
6 changed files with 47 additions and 13 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">50.82% (619)</tspan> · <tspan class="known">46.72% (569)</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">50.90% (620)</tspan> · <tspan class="known">46.63% (568)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="379.63" height="6" x="0" y="0" class="decompiled"/>
<rect width="348.97" height="6" x="379.63" y="0" class="known"/>
<rect width="380.25" height="6" x="0" y="0" class="decompiled"/>
<rect width="348.35" height="6" x="380.25" y="0" class="known"/>
<rect width="18.40" height="6" x="728.60" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -676,7 +676,7 @@
<rect width="12" height="12" x="705" y="165" class="decompiled"><title>void __cdecl LOT_DisableBaddieAI(int16_t item_num);</title></rect>
<rect width="12" height="12" x="720" y="165" class="decompiled"><title>bool __cdecl LOT_EnableBaddieAI(int16_t item_num, bool always);</title></rect>
<rect width="12" height="12" x="735" y="165" class="decompiled"><title>void __cdecl LOT_InitialiseSlot(int16_t item_num, int32_t slot);</title></rect>
<rect width="12" height="12" x="0" y="180" class="known"><title>void __cdecl CreateZone(ITEM_INFO *item);</title></rect>
<rect width="12" height="12" x="0" y="180" class="decompiled"><title>void __cdecl LOT_CreateZone(ITEM_INFO *item);</title></rect>
<rect width="12" height="12" x="15" y="180" class="known"><title>void __cdecl ClearLOT(LOT_INFO *LOT);</title></rect>
<rect width="12" height="12" x="30" y="180" class="known"><title>void __cdecl ControlMissile(int16_t fx_num);</title></rect>
<rect width="12" height="12" x="45" y="180" class="known"><title>void __cdecl ShootAtLara(FX_INFO *fx);</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">51.25%</tspan> · <tspan class="known">48.42%</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">51.31%</tspan> · <tspan class="known">48.37%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="382.85" height="6" x="0" y="0" class="decompiled"/>
<rect width="361.71" height="6" x="382.85" y="0" class="known"/>
<rect width="383.26" height="6" x="0" y="0" class="decompiled"/>
<rect width="361.30" height="6" x="383.26" y="0" class="known"/>
<rect width="2.44" height="6" x="744.56" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -1785,7 +1785,7 @@
<rect width="9.74" height="9.05" x="637.30" y="149.67" class="decompiled"><title>int32_t __cdecl BGND_AddTexture(int32_t tile_idx, BYTE *bitmap, int32_t pal_index, RGB_888 *bmp_pal);</title></rect>
<rect width="9.74" height="9.05" x="650.04" y="149.67" class="decompiled"><title>bool __cdecl D3DSetViewport(void);</title></rect>
<rect width="9.68" height="9.05" x="662.79" y="149.67" class="decompiled"><title>void __cdecl Creature_Die(int16_t item_num, int32_t explode);</title></rect>
<rect width="9.68" height="9.05" x="675.46" y="149.67" class="known"><title>void __cdecl CreateZone(ITEM_INFO *item);</title></rect>
<rect width="9.68" height="9.05" x="675.46" y="149.67" class="decompiled"><title>void __cdecl LOT_CreateZone(ITEM_INFO *item);</title></rect>
<rect width="9.47" height="9.05" x="688.14" y="149.67" class="decompiled"><title>void __cdecl Output_InsertLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t z, uint8_t color_idx);</title></rect>
<rect width="9.40" height="9.05" x="700.61" y="149.67" class="decompiled"><title>void __cdecl Room_DrawSingleRoomGeometry(int16_t room_num);</title></rect>
<rect width="9.33" height="9.05" x="713.01" y="149.67" class="decompiled"><title>void __cdecl Gondola_Control(int16_t item_num);</title></rect>

Before

Width:  |  Height:  |  Size: 362 KiB

After

Width:  |  Height:  |  Size: 362 KiB

View File

@ -3336,7 +3336,7 @@ typedef enum {
0x00432AC0 0x004F + void __cdecl LOT_DisableBaddieAI(int16_t item_num);
0x00432B10 0x01B0 + bool __cdecl LOT_EnableBaddieAI(int16_t item_num, bool always);
0x00432CC0 0x0106 + void __cdecl LOT_InitialiseSlot(int16_t item_num, int32_t slot);
0x00432ED0 0x00B8 -R void __cdecl CreateZone(ITEM_INFO *item);
0x00432ED0 0x00B8 + void __cdecl LOT_CreateZone(ITEM_INFO *item);
0x00432F90 0x0049 -R void __cdecl ClearLOT(LOT_INFO *LOT);
# game/missile.c

View File

@ -165,8 +165,42 @@ void __cdecl LOT_InitialiseSlot(const int16_t item_num, const int32_t slot)
ClearLOT(&creature->lot);
if (item_num != g_Lara.item_num) {
CreateZone(item);
LOT_CreateZone(item);
}
g_SlotsUsed++;
}
void __cdecl LOT_CreateZone(ITEM_INFO *const item)
{
CREATURE_INFO *const creature = item->data;
int16_t *zone;
int16_t *flip;
if (creature->lot.fly) {
zone = g_FlyZone[0];
flip = g_FlyZone[1];
} else {
const int32_t layer = creature->lot.step >> 8;
zone = g_GroundZone[layer][0];
flip = g_GroundZone[layer][1];
}
const ROOM_INFO *const r = &g_Rooms[item->room_num];
const int32_t x_floor = (item->pos.z - r->pos.z) >> WALL_SHIFT;
const int32_t y_floor = (item->pos.x - r->pos.x) >> WALL_SHIFT;
item->box_num = r->floor[x_floor + y_floor * r->x_size].box;
int16_t zone_num = zone[item->box_num];
int16_t flip_num = flip[item->box_num];
creature->lot.zone_count = 0;
BOX_NODE *node = creature->lot.node;
for (int32_t i = 0; i < g_BoxCount; i++) {
if (zone[i] == zone_num || flip[i] == flip_num) {
node->box_num = i;
node++;
creature->lot.zone_count++;
}
}
}

View File

@ -1,9 +1,9 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include "global/types.h"
void __cdecl LOT_InitialiseArray(void);
void __cdecl LOT_DisableBaddieAI(int16_t item_num);
bool __cdecl LOT_EnableBaddieAI(int16_t item_num, bool always);
void __cdecl LOT_InitialiseSlot(int16_t item_num, int32_t slot);
void __cdecl LOT_CreateZone(ITEM_INFO *item);

View File

@ -194,7 +194,6 @@
#define undraw_flare_meshes ((void __cdecl (*)(void))0x00430010)
#define ready_flare ((void __cdecl (*)(void))0x00430030)
#define FlareControl ((void __cdecl (*)(int16_t item_num))0x00430070)
#define CreateZone ((void __cdecl (*)(ITEM_INFO *item))0x00432ED0)
#define ClearLOT ((void __cdecl (*)(LOT_INFO *LOT))0x00432F90)
#define ControlMissile ((void __cdecl (*)(int16_t fx_num))0x00432FE0)
#define ShootAtLara ((void __cdecl (*)(FX_INFO *fx))0x004332B0)

View File

@ -755,6 +755,7 @@ static void Inject_Lot(const bool enable)
INJECT(enable, 0x00432AC0, LOT_DisableBaddieAI);
INJECT(enable, 0x00432B10, LOT_EnableBaddieAI);
INJECT(enable, 0x00432CC0, LOT_InitialiseSlot);
INJECT(enable, 0x00432ED0, LOT_CreateZone);
}
static void Inject_Objects(const bool enable)