port GetNearByRooms and GetNewRoom

This commit is contained in:
rr- 2021-02-24 18:11:51 +01:00
parent da2f05d3e8
commit 18a3322f97
6 changed files with 50 additions and 9 deletions

View file

@ -137,7 +137,7 @@
<rect width="12.00" height="12.00" x="476.00" y="45.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="490.00" y="45.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="504.00" y="45.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="518.00" y="45.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="518.00" y="45.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="532.00" y="45.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="546.00" y="45.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="560.00" y="45.00" fill="lightpink"/>
@ -821,7 +821,7 @@
<rect width="21.98" height="21.21" x="338.61" y="315.95" fill="lightpink"/>
<rect width="21.98" height="21.12" x="338.61" y="339.16" fill="forestgreen"/>
<rect width="21.98" height="20.46" x="338.61" y="362.27" fill="mistyrose"/>
<rect width="21.98" height="20.34" x="338.61" y="384.74" fill="lightpink"/>
<rect width="21.98" height="20.34" x="338.61" y="384.74" fill="forestgreen"/>
<rect width="21.98" height="20.15" x="338.61" y="407.07" fill="lightpink"/>
<rect width="21.98" height="20.09" x="338.61" y="429.22" fill="mistyrose"/>
<rect width="21.98" height="19.87" x="338.61" y="451.31" fill="lightpink"/>
@ -1459,10 +1459,10 @@
<rect width="-0.46" height="0.42" x="695.22" y="535.58" fill="mistyrose"/>
<rect width="-0.76" height="-0.18" x="696.76" y="535.58" fill="mistyrose"/>
<rect width="-0.76" height="-1.39" x="696.76" y="537.39" 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): 29.63%</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): 29.17%</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): 56.38%</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): 54.86%</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): 29.77%</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): 29.46%</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): 56.24%</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): 54.57%</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): 13.99%</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.97%</text>
</svg>

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Before After
Before After

View file

@ -172,8 +172,8 @@ InGameCinematicCamera 0x004115F0 0x00000190 *
GetCollisionInfo 0x00411780 0x000007DD +
FindGridShift ---------- ---------- +
CollideStaticObjects 0x00411FA0 0x000003D6 *
GetNearByRooms 0x00412390 0x000002CC -
GetNewRoom ---------- ---------- -
GetNearByRooms 0x00412390 0x000002CC +
GetNewRoom ---------- ---------- +
ShiftItem 0x00412660 0x00000037 *
UpdateLaraRoom 0x004126A0 0x0000005F *
GetTiltType ---------- ---------- +

View file

@ -283,6 +283,42 @@ int32_t FindGridShift(int32_t src, int32_t dst)
}
}
void GetNearByRooms(
int32_t x, int32_t y, int32_t z, int32_t r, int32_t h, int16_t room_num)
{
RoomsToDraw[0] = room_num;
RoomsToDrawNum = 1;
GetNewRoom(x + r, y, z + r, room_num);
GetNewRoom(x - r, y, z + r, room_num);
GetNewRoom(x + r, y, z - r, room_num);
GetNewRoom(x - r, y, z - r, room_num);
GetNewRoom(x + r, y - h, z + r, room_num);
GetNewRoom(x - r, y - h, z + r, room_num);
GetNewRoom(x + r, y - h, z - r, room_num);
GetNewRoom(x - r, y - h, z - r, room_num);
}
void GetNewRoom(int32_t x, int32_t y, int32_t z, int16_t room_num)
{
GetFloor(x, y, z, &room_num);
int i;
for (i = 0; i < RoomsToDrawNum; i++) {
if (RoomsToDraw[i] == room_num) {
break;
}
}
// NOTE: this access violation check was not present in the original code
if (i >= MAX_ROOMS_TO_DRAW) {
return;
}
if (i == RoomsToDrawNum) {
RoomsToDraw[RoomsToDrawNum++] = room_num;
}
}
int16_t GetTiltType(FLOOR_INFO* floor, int32_t x, int32_t y, int32_t z)
{
ROOM_INFO* r;
@ -311,4 +347,5 @@ int16_t GetTiltType(FLOOR_INFO* floor, int32_t x, int32_t y, int32_t z)
void T1MInjectGameCollide()
{
INJECT(0x00411780, GetCollisionInfo);
INJECT(0x00412390, GetNearByRooms);
}

View file

@ -17,6 +17,9 @@ void GetCollisionInfo(
COLL_INFO* coll, int32_t xpos, int32_t ypos, int32_t zpos, int16_t room_num,
int32_t objheight);
int32_t FindGridShift(int32_t src, int32_t dst);
void GetNearByRooms(
int32_t x, int32_t y, int32_t z, int32_t r, int32_t h, int16_t room_num);
void GetNewRoom(int32_t x, int32_t y, int32_t z, int16_t room_num);
int16_t GetTiltType(FLOOR_INFO* floor, int32_t x, int32_t y, int32_t z);
void T1MInjectGameCollide();

View file

@ -6,6 +6,7 @@
#define NUM_PU 3
#define NUM_SLOTS 8
#define MAX_ROOMS 1024
#define MAX_ROOMS_TO_DRAW 100
#define MAX_FRAMES 10
#define MAX_TEXTURES 2048
#define NUMBER_ITEMS 256

View file

@ -138,7 +138,7 @@ extern char TextStrings[MAX_TEXT_STRINGS][MAX_STRING_SIZE];
#define InterpolatedBounds ARRAY_(0x00462BF0, int16_t, [6])
#define W2VMatrix VAR_U_(0x006CADA0, PHD_MATRIX)
#define DoorVBuf ARRAY_(0x00462540, DOOR_VBUF, [4])
#define RoomsToDraw ARRAY_(0x00462580, int16_t, [100])
#define RoomsToDraw ARRAY_(0x00462580, int16_t, [MAX_ROOMS_TO_DRAW])
#define RoomsToDrawNum VAR_U_(0x00461F38, int32_t)
#define Weapons ARRAY_(0x004563A8, WEAPON_INFO, [NUM_WEAPONS])
#define DemoLevels ARRAY_(0x00453538, int8_t, [])