Decompiled math functions 4; Code cleaning; Decompiled many functions;

This commit is contained in:
MontyTRC89 2020-04-15 18:30:34 +02:00
parent d0a18e4979
commit cc4691dd8b
31 changed files with 357 additions and 1218 deletions

View file

@ -3,7 +3,6 @@
#include "..\Global\global.h"
#include "pickup.h"
#include "spotcam.h"
#include "Camera.h"
#include "Lara.h"
#include "hair.h"
@ -65,6 +64,7 @@ short NextFxFree;
short NextItemActive;
short NextItemFree;
short* TriggerIndex;
int DisableLaraControl = 0;
extern GameFlow* g_GameFlow;
extern GameScript* g_GameScript;
@ -3263,6 +3263,74 @@ void InterpolateAngle(short angle, short* rotation, short* outAngle, int shift)
*rotation += deltaAngle >> shift;
}
#define OutsideRoomTable VAR_U_(0x00EEF4AC, unsigned char*)
#define OutsideRoomOffsets ARRAY_(0x00EEF040, short, [27 * 27])
int IsRoomOutside(int x, int y, int z)
{
short offset = OutsideRoomOffsets[((x >> 12) * 27) + (z >> 12)];
if (offset == -1)
return -2;
if (offset < 0)
{
ROOM_INFO* r = &Rooms[(offset & 0x7FFF)];
if ((y > r->maxceiling) && (y < r->minfloor)
&& ((z > (r->z + 1024)) && (z < (r->z + ((r->xSize - 1) * 1024))))
&& ((x > (r->x + 1024)) && (x < (r->x + ((r->ySize - 1) * 1024)))))
{
short roomNumber = offset & 0x7fff;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
int height = GetFloorHeight(floor, x, y, z);
if (height == NO_HEIGHT || y > height)
return -2;
height = GetCeiling(floor, x, y, z);
if (y < height)
return -2;
if (!(r->flags & (ENV_FLAG_WIND | ENV_FLAG_WATER)))
return -3;
IsRoomOutsideNo = offset & 0x7FFF;
return 1;
}
else
return -2;
}
else
{
unsigned char* s = &OutsideRoomTable[offset];
while (*s != 0xFF)
{
ROOM_INFO* r = &Rooms[*s];
if ((y > r->maxceiling && y < r->minfloor)
&& ((z > (r->z + 1024)) && (z < (r->z + ((r->xSize - 1) * 1024))))
&& ((x > (r->x + 1024)) && (x < (r->x + ((r->ySize - 1) * 1024)))))
{
short roomNumber = *s;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
int height = GetFloorHeight(floor, x, y, z);
if (height == NO_HEIGHT || y > height)
return -2;
height = GetCeiling(floor, x, y, z);
if (y < height)
return -2;
if (!(r->flags & (ENV_FLAG_WIND | ENV_FLAG_WATER)))
return -3;
IsRoomOutsideNo = *s;
return 1;
}
s++;
}
return -2;
}
}
void Inject_Control()
{
INJECT(0x00416760, TestTriggers);

View file

@ -19,6 +19,7 @@ extern short NextFxFree;
extern short NextItemActive;
extern short NextItemFree;
extern short* TriggerIndex;
extern int DisableLaraControl;
GAME_STATUS DoTitle(int index);
GAME_STATUS DoLevel(int index, int ambient, bool loadFromSavegame);
@ -63,6 +64,7 @@ int TriggerActive(ITEM_INFO* item);
int GetWaterHeight(int x, int y, int z, short roomNumber);
int is_object_in_room(short roomNumber, short objectNumber);
void InterpolateAngle(short angle, short* rotation, short* outAngle, int shift);
int IsRoomOutside(int x, int y, int z);
unsigned __stdcall GameMain(void*);
void Inject_Control();

View file

@ -569,44 +569,62 @@ void phd_RotYXZpack(int rots)
}
}
void _gar_RotYXZsuperpack(short** pproc, int skip)
void gar_RotYXZsuperpack(short** pprot, int skip)
{
unsigned short* prot;
int packed;
while (skip)
{
prot = reinterpret_cast<unsigned short*>(*pprot);
if (*prot & (3 << 14))
(*pprot) += 1;
else
(*pprot) += 2;
skip--;
}
prot = reinterpret_cast<unsigned short*>(*pprot);
switch (*prot >> 14)
{
case 0:
packed = (*prot << 16) + *(prot + 1);
phd_RotYXZpack(packed);
(*pprot) += 2;
return;
case 1:
phd_RotX((short)((*prot & 1023) << 4));
break;
case 2:
phd_RotY((short)((*prot & 1023) << 4));
break;
default:
phd_RotZ((short)((*prot & 1023) << 4));
break;
}
(*pprot) += 1;
}
void _gar_RotYXZsuperpack_I(short** pproc1, short** pproc2, int skip)
void gar_RotYXZsuperpack_I(short** framePtr1, short** framePtr2, int skip)
{
gar_RotYXZsuperpack(framePtr1, skip);
int* mptr = MatrixPtr;
int* dxptr = DxMatrixPtr;
MatrixPtr = IMptr;
DxMatrixPtr = DxIMptr;
gar_RotYXZsuperpack(framePtr2, skip);
MatrixPtr = mptr;
DxMatrixPtr = dxptr;
}
void _phd_ClipBoundingBox(short* frames)
{
}
void _phd_DxTranslateRel(int x, int y, int z)
{
}
void _phd_DxTranslateAbs(int x, int y, int z)
{
}
void _phd_DxRotY(short ry)
{
}
void _phd_DxRotX(short rx)
{
}
void _phd_DxRotZ(short rz)
{
}
void _phd_DxRotYXZ(short ry, short rx, short rz)
{
}
void _phd_DxRotYXZpack(int rangle)
{
}
void Inject_Draw()
@ -633,4 +651,6 @@ void Inject_Draw()
INJECT(0x0048FA90, phd_PushUnitMatrix);
INJECT(0x004904B0, phd_GetVectorAngles);
INJECT(0x0048FEB0, phd_RotYXZpack);
/*INJECT(0x0042C310, gar_RotYXZsuperpack);
INJECT(0x0042C290, gar_RotYXZsuperpack_I);*/
}

View file

@ -3,39 +3,14 @@
#include "..\Global\global.h"
#define CalcLaraMatrices ((void (__cdecl*)(int)) 0x0041E120)
#define IsRoomOutside ((int (__cdecl*)(int, int, int)) 0x00418E90)
//#define IsRoomOutside ((int (__cdecl*)(int, int, int)) 0x00418E90)
#define sub_42B4C0 ((void (__cdecl*)(ITEM_INFO*,short*)) 0x0042B4C0)
#define gar_RotYXZsuperpack ((void(__cdecl*)(short**,int)) 0x0042C310)
#define gar_RotYXZsuperpack_I ((void(__cdecl*)(short**,short**,int)) 0x0042C290)
#define phd_RotBoundingBoxNoPersp ((void (__cdecl*)(short*, short*)) 0x0042E240)
//#define InitInterpolate ((void(__cdecl*)(int,int)) 0x0042BE90)
//#define Sync ((int (__cdecl*)()) 0x004D1A40)
//#define GetBoundsAccurate ((short* (__cdecl*)(ITEM_INFO*)) 0x0042CF80)
//#define GetBestFrame ((short* (__cdecl*)(ITEM_INFO*)) 0x0042D020)
//#define phd_PushMatrix ((void(__cdecl*)(void)) 0x0048F9C0)
//#define phd_RotYXZ ((void(__cdecl*)(short, short, short)) 0x00490150)
//#define phd_TranslateRel ((void(__cdecl*)(int, int, int)) 0x0048FB20)
//#define phd_TranslateRel_I ((void(__cdecl*)(int, int, int)) 0x0042C110)
//#define phd_TranslateRel_ID ((void(__cdecl*)(int,int,int,int,int,int)) 0x0042C190)
//#define phd_TranslateAbs ((void(__cdecl*)(int, int, int)) 0x004903F0)
//#define phd_PopMatrix_I ((void(__cdecl*)(void)) 0x0042BF00)
//#define phd_RotY ((void(__cdecl*)(short)) 0x0048FCD0)
//#define phd_RotX ((void(__cdecl*)(short)) 0x0048FBE0)
//#define phd_RotZ ((void(__cdecl*)(short)) 0x0048FDC0)
//#define phd_RotY_I ((void(__cdecl*)(short)) 0x0042BFC0)
//#define phd_RotX_I ((void(__cdecl*)(short)) 0x0042C030)
//#define phd_RotZ_I ((void(__cdecl*)(short)) 0x0042C0A0)
//#define phd_SetTrans ((void (__cdecl*)(int, int, int)) 0x0048FA40)
//#define phd_PushMatrix_I ((void(__cdecl*)(void)) 0x0042BF50)
//#define phd_PushUnitMatrix ((void (__cdecl*)()) 0x0048FA90)
//#define phd_GetVectorAngles ((void(__cdecl*)(int, int, int, short*)) 0x004904B0)
//#define phd_RotYXZpack ((void(__cdecl*)(int)) 0x0048FEB0)
#define mGetAngle ((int(__cdecl*)(int, int, int, int)) 0x0048F290)
#define phd_GenerateW2V ((void(__cdecl*)(PHD_3DPOS*)) 0x0048F330)
extern Renderer11* g_Renderer;
extern BITE_INFO EnemyBites[9];
extern int LightningCount;
extern int LightningRand;
extern int StormTimer;
@ -52,7 +27,6 @@ int Sync();
bool TIME_Init();
bool TIME_Reset();
void DrawAnimatingItem(ITEM_INFO* item);
void phd_PushMatrix();
void InitInterpolate(int frac, int rate);
void phd_PopMatrix();
@ -73,14 +47,7 @@ void phd_PushMatrix_I();
void phd_PushUnitMatrix();
void phd_GetVectorAngles(int x, int y, int z, short* angles);
void phd_RotYXZpack(int rots);
/* phd function (DX11 version) */
// TODO: phd_XX function after this lign is used with DX11 one, when it's finished, delete the #define one and delete this sign: "_" at the beginning of the new function. (delete the unused if needed)
void _gar_RotYXZsuperpack(short** pproc, int skip);
void _gar_RotYXZsuperpack_I(short** pproc1, short** pproc2, int skip);
extern Renderer11* g_Renderer;
extern BITE_INFO EnemyBites[9];
void gar_RotYXZsuperpack(short** framePtr, int skip);
void gar_RotYXZsuperpack_I(short** framePtr1, short** framePtr2, int skip);
void Inject_Draw();

View file

@ -503,6 +503,17 @@ void Richochet(PHD_3DPOS* pos)
SoundEffect(SFX_LARA_RICOCHET, pos, 0);
}
void DoLotsOfBlood(int x, int y, int z, int speed, short direction, short roomNumber, int count)
{
for (int i = 0; i < count; i++)
{
DoBloodSplat(x + 256 - (GetRandomControl() * 512 / 0x8000),
y + 256 - (GetRandomControl() * 512 / 0x8000),
z + 256 - (GetRandomControl() * 512 / 0x8000),
speed, direction, roomNumber);
}
}
void Inject_Effects()
{
INJECT(0x00432580, ItemNearLara);

View file

@ -3,7 +3,7 @@
#include "..\Global\global.h"
#include "control.h"
#define DoLotsOfBlood ((void (__cdecl*)(int, int, int, short, short, short, int)) 0x00432800)
//#define DoLotsOfBlood ((void (__cdecl*)(int, int, int, short, short, short, int)) 0x00432800)
#define SoundEffects ((void (__cdecl*)()) 0x00432640)
int ItemNearLara(PHD_3DPOS* pos, int radius);
@ -47,6 +47,7 @@ void TL_10(ITEM_INFO* item);
void TL_11(ITEM_INFO* item);
void TL_12(ITEM_INFO* item);
void Richochet(PHD_3DPOS* pos);
void DoLotsOfBlood(int x, int y, int z, int speed, short direction, short roomNumber, int count);
void Inject_Effects();

View file

@ -105,7 +105,7 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
int* bone = Bones + object->boneIndex;
phd_TranslateRel((int) * (frame + 6), (int) * (frame + 7), (int) * (frame + 8));
gar_RotYXZsuperpack(&rotation, 0);
Legacy_gar_RotYXZsuperpack(&rotation, 0);
// Hips
phd_PushMatrix();
@ -119,7 +119,7 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
phd_TranslateRel(*(bone + 1 + 24), *(bone + 2 + 24), *(bone + 3 + 24));
gar_RotYXZsuperpack(&rotation, 6);
Legacy_gar_RotYXZsuperpack(&rotation, 6);
phd_RotYXZ(Lara.torsoYrot, Lara.torsoXrot, Lara.torsoZrot);
// Torso
@ -136,7 +136,7 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
phd_PushMatrix();
phd_TranslateRel(*(bone + 1 + 28), *(bone + 2 + 28), *(bone + 3 + 28));
gar_RotYXZsuperpack(&rotation, 0);
Legacy_gar_RotYXZsuperpack(&rotation, 0);
// Right arm
objptr = Lara.meshPtrs[LM_RINARM];
@ -149,7 +149,7 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
phd_PushMatrix();
phd_TranslateRel(*(bone + 1 + 40), *(bone + 2 + 40), *(bone + 3 + 40));
gar_RotYXZsuperpack(&rotation, 2);
Legacy_gar_RotYXZsuperpack(&rotation, 2);
// Left arm
objptr = Lara.meshPtrs[LM_LINARM];
@ -161,7 +161,7 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
phd_PopMatrix();
phd_TranslateRel(*(bone + 1 + 52), *(bone + 2 + 52), *(bone + 3 + 52));
gar_RotYXZsuperpack(&rotation, 2);
Legacy_gar_RotYXZsuperpack(&rotation, 2);
phd_RotYXZ(Lara.headYrot, Lara.headXrot, Lara.headZrot);
// Head

View file

@ -8,6 +8,7 @@
#include "savegame.h"
#include "Lara.h"
#include "camera.h"
#include "spotcam.h"
#include "..\Global\global.h"
#include "..\Specific\input.h"
#include "..\Specific\configuration.h"

View file

@ -645,6 +645,94 @@ void InitialiseTightRope(short itemNumber)
}
}
void InitialiseAnimating(short itemNumber)
{
ITEM_INFO* item = &Items[itemNumber];
item->currentAnimState = 0;
item->animNumber = Objects[item->objectNumber].animIndex;
item->frameNumber = Anims[item->animNumber].frameBase;
}
void AnimatingControl(short itemNumber)
{
ITEM_INFO* item = &Items[itemNumber];
if (!TriggerActive(item))
return;
item->status = ITEM_ACTIVE;
AnimateItem(item);
if (item->frameNumber >= Anims[item->animNumber].frameEnd)
{
item->frameNumber = Anims[item->animNumber].frameBase;
RemoveActiveItem(itemNumber);
item->aiBits = 0;
item->status = ITEM_INACTIVE;
}
}
void HighObject2Control(short itemNumber)
{
ITEM_INFO* item = &Items[itemNumber];
if (!TriggerActive(item))
return;
if (!item->itemFlags[2])
{
int div = item->triggerFlags % 10 << 10;
int mod = item->triggerFlags / 10 << 10;
item->itemFlags[0] = GetRandomControl() % div;
item->itemFlags[1] = GetRandomControl() % mod;
item->itemFlags[2] = (GetRandomControl() & 0xF) + 15;
}
if (--item->itemFlags[2] < 15)
{
SPARKS* spark = &Sparks[GetFreeSpark()];
spark->on = 1;
spark->sR = -1;
spark->sB = 16;
spark->sG = (GetRandomControl() & 0x1F) + 48;
spark->dR = (GetRandomControl() & 0x3F) - 64;
spark->dB = 0;
spark->dG = (GetRandomControl() & 0x3F) + -128;
spark->fadeToBlack = 4;
spark->colFadeSpeed = (GetRandomControl() & 3) + 4;
spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 24;
spark->x = item->itemFlags[1] + (GetRandomControl() & 0x3F) + item->pos.xPos - 544;
spark->y = item->pos.yPos;
spark->z = item->itemFlags[0] + (GetRandomControl() & 0x3F) + item->pos.zPos - 544;
spark->xVel = (GetRandomControl() & 0x1FF) - 256;
spark->friction = 6;
spark->zVel = (GetRandomControl() & 0x1FF) - 256;
spark->rotAng = GetRandomControl() & 0xFFF;
spark->rotAdd = (GetRandomControl() & 0x3F) - 32;
spark->maxYvel = 0;
spark->yVel = -512 - (GetRandomControl() & 0x3FF);
spark->sSize = spark->size = (GetRandomControl() & 0xF) + 32;
spark->dSize = spark->size >> 2;
if (GetRandomControl() & 3)
{
spark->flags = SP_ROTATE | SP_DEF | SP_SCALE | SP_EXPDEF;
spark->scalar = 3;
spark->gravity = (GetRandomControl() & 0x3F) + 32;
}
else
{
spark->flags = SP_ROTATE | SP_DEF | SP_SCALE;
spark->def = Objects[ID_DEFAULT_SPRITES].meshIndex + SPR_UNDERWATERDUST;
spark->scalar = 1;
spark->gravity = (GetRandomControl() & 0xF) + 64;
}
}
}
void Inject_Objects()
{
INJECT(0x00465FE0, TightRopeCollision);

View file

@ -1,10 +1,6 @@
#pragma once
#include "..\Global\global.h"
#define InitialiseAnimating ((void (__cdecl*)(short)) 0x00440100)
#define AnimatingControl ((void (__cdecl*)(short)) 0x00465590)
//#define InitialiseSmashObject ((void (__cdecl*)(short)) 0x0043D7F0)
void SmashObject(short itemNumber);
void SmashObjectControl(short itemNumber);
void BridgeFlatFloor(ITEM_INFO* item, int x, int y, int z, int* height);
@ -19,19 +15,15 @@ void PoleCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
void ControlTriggerTriggerer(short itemNumber);
void AnimateWaterfalls();
void ControlWaterfall(short itemNumber);
//#define InitialiseTightRope ((void (__cdecl*)(short)) 0x0043ED30)
void TightRopeCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
void ParallelBarsCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
#define InitialiseXRayMachine ((void (__cdecl*)(short)) 0x0043FA20)
void ControlXRayMachine(short itemNumber);
void CutsceneRopeControl(short itemNumber);
void HybridCollision(short itemNum, ITEM_INFO* laraitem, COLL_INFO* coll);
//#define InitialiseRaisingBlock ((void (__cdecl*)(short)) 0x0043D730)
//#define RaisingBlockControl ((void (__cdecl*)(short)) 0x0048C3D0)
//#define InitialiseRaisingCog ((void (__cdecl*)(short)) 0x00440320)
//#define RaisingCogControl ((void (__cdecl*)(short)) 0x00406040)
#define HighObject2Control ((void (__cdecl*)(short)) 0x004070D0)
void InitialiseSmashObject(short itemNumber);
void InitialiseTightRope(short itemNumber);
void InitialiseAnimating(short itemNumber);
void AnimatingControl(short itemNumber);
void HighObject2Control(short itemNumber);
void Inject_Objects();

View file

@ -2,10 +2,6 @@
#include "..\Global\global.h"
//#define PickupCollision ((void (__cdecl*)(short, ITEM_INFO*, COLL_INFO*)) 0x00467C00)
//#define InitialisePickup ((void (__cdecl*)(short)) 0x0043E260)
//#define PickupControl ((void (__cdecl*)(short)) 0x004679D0)
void InitialisePickup(short itemNumber);
void PickedUpObject(short objectNumber);
void RemoveObjectFromInventory(short objectNumber, int count);

View file

@ -1 +0,0 @@
#include "rat.h"

View file

@ -1,6 +0,0 @@
#pragma once
#include "..\Global\global.h"
//#define InitialiseLittleRats ((void (__cdecl*)(short)) 0x0046B220)
//#define ControlLittleRats ((void (__cdecl*)(short)) 0x0046AB30)

View file

@ -25,8 +25,6 @@ struct PENDULUM
extern PENDULUM CurrentPendulum;
#define CalculateRopePoints ((void (__cdecl*)(ROPE_STRUCT*)) 0x0046EC70)
void InitialiseRope(short itemNumber);
void PrepareRope(ROPE_STRUCT* rope, PHD_VECTOR* pos1, PHD_VECTOR* pos2, int length, ITEM_INFO* item);
PHD_VECTOR* NormaliseRopeVector(PHD_VECTOR* vec);

View file

@ -9,11 +9,6 @@
#include "..\Scripting\GameFlowScript.h"
#include "..\Scripting\GameLogicScript.h"
#define RestoreGame ((int (__cdecl*)()) 0x00472060)
#define ReadSavegame ((int (__cdecl*)(int)) 0x004A8E10)
#define CreateSavegame ((void (__cdecl*)()) 0x00470FA0)
#define WriteSavegame ((int (__cdecl*)(int)) 0x004A8BC0)
#define SAVEGAME_BUFFER_SIZE 1048576
extern GameFlow* g_GameFlow;

View file

@ -42,7 +42,7 @@ int GetSpheres(ITEM_INFO* item, SPHERE* ptr, char worldSpace)
short* frame = GetBestFrame(item);
phd_TranslateRel(frame[6], frame[7], frame[8]);
short* rotation = frame + 9;
gar_RotYXZsuperpack(&rotation, 0);
Legacy_gar_RotYXZsuperpack(&rotation, 0);
OBJECT_INFO* obj = &Objects[item->objectNumber];
short** meshPtr = &Meshes[obj->meshIndex];
@ -74,7 +74,7 @@ int GetSpheres(ITEM_INFO* item, SPHERE* ptr, char worldSpace)
phd_PushMatrix();
phd_TranslateRel(*(bone), *(bone + 1), *(bone + 2));
gar_RotYXZsuperpack(&rotation, 0);
Legacy_gar_RotYXZsuperpack(&rotation, 0);
if ((poppush & (ROT_X | ROT_Y | ROT_Z)) && extraRotation)
{
@ -216,7 +216,7 @@ void GetJointAbsPosition(ITEM_INFO* item, PHD_VECTOR* vec, int joint)
{
phd_TranslateRel((int) * (frmptr[0] + 6), (int) * (frmptr[0] + 7), (int) * (frmptr[0] + 8));
short* rotation1 = frmptr[0] + 9;
gar_RotYXZsuperpack(&rotation1, 0);
Legacy_gar_RotYXZsuperpack(&rotation1, 0);
for (int i = 0; i < joint; i++, bone += 4)
{
@ -229,7 +229,7 @@ void GetJointAbsPosition(ITEM_INFO* item, PHD_VECTOR* vec, int joint)
phd_PushMatrix();
phd_TranslateRel(bone[1], bone[2], bone[3]);
gar_RotYXZsuperpack(&rotation1, 0);
Legacy_gar_RotYXZsuperpack(&rotation1, 0);
if (poppush & (ROT_X | ROT_Y | ROT_Z))
{
@ -257,7 +257,7 @@ void GetJointAbsPosition(ITEM_INFO* item, PHD_VECTOR* vec, int joint)
short* rotation2 = frmptr[1] + 9;
phd_TranslateRel_ID((int) * (frmptr[0] + 6), (int) * (frmptr[0] + 7), (int) * (frmptr[0] + 8),
(int) * (frmptr[1] + 6), (int) * (frmptr[1] + 7), (int) * (frmptr[1] + 8));
gar_RotYXZsuperpack_I(&rotation1, &rotation2, 0);
Legacy_gar_RotYXZsuperpack_I(&rotation1, &rotation2, 0);
for (int i = 0; i < joint; i++, bone += 4)
{
@ -269,7 +269,7 @@ void GetJointAbsPosition(ITEM_INFO* item, PHD_VECTOR* vec, int joint)
phd_PushMatrix_I();
phd_TranslateRel_I(bone[1], bone[2], bone[3]);
gar_RotYXZsuperpack_I(&rotation1, &rotation2, 0);
Legacy_gar_RotYXZsuperpack_I(&rotation1, &rotation2, 0);
if (poppush & (ROT_X | ROT_Y | ROT_Z))
{

View file

@ -2,10 +2,6 @@
#include "..\Global\global.h"
//#define TestCollision ((int (__cdecl*)(ITEM_INFO*, ITEM_INFO*)) 0x00479170)
//#define GetJointAbsPosition ((int (__cdecl*)(ITEM_INFO*, PHD_VECTOR*, int)) 0x00479780)
//#define GetSpheres ((int (__cdecl*)(ITEM_INFO*, SPHERE*, int)) 0x00479380)
#define InterpolateMatrix ((int (__cdecl*)()) 0x0042C8F0)
#define InitInterpolate2 ((int (__cdecl*)(int, int)) 0x00479BB0)

View file

@ -1,4 +0,0 @@
#pragma once
#include "..\Global\global.h"

View file

@ -42,6 +42,8 @@ int LaraAir;
int CurrentSpotcamSequence;
SPOTCAM SpotCam[64];
int NumberSpotcams;
int CheckTrigger = 0;
int UseSpotCam = 0;
extern Renderer11* g_Renderer;
@ -899,6 +901,36 @@ void CalculateSpotCameras()
}
}
// It just works (tm)!
int Spline(int x, int* knots, int nk)
{
int64_t v3 = x * (int64_t)(nk - 3) << 16 >> 16;
int32_t v4 = (int32_t)v3 >> 16;
if ((int32_t)v3 >> 16 >= nk - 3)
v4 = nk - 4;
int32_t v5 = knots[v4];
int32_t v6 = knots[v4 + 2];
int32_t nka = knots[v4 + 3] >> 1;
int32_t v7 = knots[v4 + 1];
return (int32_t)(v7
+ (int64_t)(uint64_t)((int32_t)((~v5 >> 1)
+ (v6 >> 1)
+ (int64_t)(uint64_t)((int32_t)(v5
+ (int64_t)(uint64_t)(((~v5 >> 1)
+ nka
+ v7
+ (v7 >> 1)
- (v6 >> 1)
- v6)
* (int64_t)((int32_t)v3 - (v4 << 16)) >> 16)
- 2 * v7
+ 2 * v6
- (v7 >> 1)
- nka)
* (int64_t)((int32_t)v3 - (v4 << 16)) >> 16))
* (int64_t)((int32_t)v3 - (v4 << 16)) >> 16));
}
void Inject_Spotcam()
{
INJECT(0x0047A800, InitSpotCamSequences);

View file

@ -22,20 +22,16 @@ enum spotcam_flags
SCF_CAMERA_ONE_SHOT = (1 << 15), // 0x8000
};
//#define InitSpotCamSequences ((void (__cdecl*)()) 0x0047A800)
//#define CalculateSpotCameras ((void (__cdecl*)()) 0x0047B280)
//#define InitialiseSpotCam ((void (__cdecl*)(short)) 0x0047A9D0)
#define TriggerTitleSpotcam ((void (__cdecl*)(int)) 0x004284A0)
#define Spline ((int (__cdecl*)(int, int*, int)) 0x0047A890)
extern byte SpotCamRemap[16];
extern byte CameraCnt[16];
extern int LastSpotCam;
extern SPOTCAM SpotCam[64];
extern int NumberSpotcams;
extern int UseSpotCam;
void InitSpotCamSequences();
void InitialiseSpotCam(short sequence);
void CalculateSpotCameras();
int Spline(int x, int* knots, int nk);
void Inject_Spotcam();

File diff suppressed because it is too large Load diff

View file

View file

@ -1,12 +1,6 @@
#pragma once
#include "..\Global\global.h"
//#define InitialiseSwitch ((void (__cdecl*)(short)) 0x00440070)
//#define SequenceControl ((void (__cdecl*)(short)) 0x0047F520)
//#define SequenceCollision ((void (__cdecl*)(short,ITEM_INFO*,COLL_INFO*)) 0x0047F610)
//#define LeverSwitchCollision ((void (__cdecl*)(short,ITEM_INFO*,COLL_INFO*)) 0x0047EE00)
//#define InitialisePulleySwitch ((void (__cdecl*)(short)) 0x0043E1F0)
//#define InitialiseCrowDoveSwitch ((void (__cdecl*)(short)) 0x0043ECF0)
void CrowDoveSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
void CrowDoveSwitchControl(short itemNumber);
void CogSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);

View file

@ -1 +0,0 @@
#include "twogun.h"

View file

@ -1 +0,0 @@
#pragma once

View file

@ -99,6 +99,30 @@
// DRAW.CPP
#define Legacy_UpdateStorm ((void (__cdecl*)()) 0x0042A310)
#define Legacy_InitInterpolate ((void(__cdecl*)(int,int)) 0x0042BE90)
#define Legacy_Sync ((int (__cdecl*)()) 0x004D1A40)
#define Legacy_GetBoundsAccurate ((short* (__cdecl*)(ITEM_INFO*)) 0x0042CF80)
#define Legacy_GetBestFrame ((short* (__cdecl*)(ITEM_INFO*)) 0x0042D020)
#define Legacy_phd_PushMatrix ((void(__cdecl*)(void)) 0x0048F9C0)
#define Legacy_phd_RotYXZ ((void(__cdecl*)(short, short, short)) 0x00490150)
#define Legacy_phd_TranslateRel ((void(__cdecl*)(int, int, int)) 0x0048FB20)
#define Legacy_phd_TranslateRel_I ((void(__cdecl*)(int, int, int)) 0x0042C110)
#define Legacy_phd_TranslateRel_ID ((void(__cdecl*)(int,int,int,int,int,int)) 0x0042C190)
#define Legacy_phd_TranslateAbs ((void(__cdecl*)(int, int, int)) 0x004903F0)
#define Legacy_phd_PopMatrix_I ((void(__cdecl*)(void)) 0x0042BF00)
#define Legacy_phd_RotY ((void(__cdecl*)(short)) 0x0048FCD0)
#define Legacy_phd_RotX ((void(__cdecl*)(short)) 0x0048FBE0)
#define Legacy_phd_RotZ ((void(__cdecl*)(short)) 0x0048FDC0)
#define Legacy_phd_RotY_I ((void(__cdecl*)(short)) 0x0042BFC0)
#define Legacy_phd_RotX_I ((void(__cdecl*)(short)) 0x0042C030)
#define Legacy_phd_RotZ_I ((void(__cdecl*)(short)) 0x0042C0A0)
#define Legacy_phd_SetTrans ((void (__cdecl*)(int, int, int)) 0x0048FA40)
#define Legacy_phd_PushMatrix_I ((void(__cdecl*)(void)) 0x0042BF50)
#define Legacy_phd_PushUnitMatrix ((void (__cdecl*)()) 0x0048FA90)
#define Legacy_phd_GetVectorAngles ((void(__cdecl*)(int, int, int, short*)) 0x004904B0)
#define Legacy_phd_RotYXZpack ((void(__cdecl*)(int)) 0x0048FEB0)
#define Legacy_gar_RotYXZsuperpack ((void(__cdecl*)(short**,int)) 0x0042C310)
#define Legacy_gar_RotYXZsuperpack_I ((void(__cdecl*)(short**,short**,int)) 0x0042C290)
// EFFECT2.CPP
#define Legacy_DetatchSpark ((SPARKS* (__cdecl*)(int, int)) 0x0042E6A0)
@ -149,3 +173,53 @@
// LARA.CPP
#define Legacy_AnimateLara ((int (__cdecl*)(ITEM_INFO*)) 0x004563F0)
// OBJECTS.CPP
#define Legacy_InitialiseTightRope ((void (__cdecl*)(short)) 0x0043ED30)
#define Legacy_InitialiseRaisingBlock ((void (__cdecl*)(short)) 0x0043D730)
#define Legacy_RaisingBlockControl ((void (__cdecl*)(short)) 0x0048C3D0)
#define Legacy_InitialiseRaisingCog ((void (__cdecl*)(short)) 0x00440320)
#define Legacy_RaisingCogControl ((void (__cdecl*)(short)) 0x00406040)
#define Legacy_InitialiseSmashObject ((void (__cdecl*)(short)) 0x0043D7F0)
#define Legacy_InitialiseAnimating ((void (__cdecl*)(short)) 0x00440100)
#define Legacy_AnimatingControl ((void (__cdecl*)(short)) 0x00465590)
#define Legacy_InitialiseXRayMachine ((void (__cdecl*)(short)) 0x0043FA20)
#define Legacy_HighObject2Control ((void (__cdecl*)(short)) 0x004070D0)
// PICKUP.CPP
#define Legacy_PickupCollision ((void (__cdecl*)(short, ITEM_INFO*, COLL_INFO*)) 0x00467C00)
#define Legacy_InitialisePickup ((void (__cdecl*)(short)) 0x0043E260)
#define Legacy_PickupControl ((void (__cdecl*)(short)) 0x004679D0)
// ROPE.CPP
#define Legacy_CalculateRopePoints ((void (__cdecl*)(ROPE_STRUCT*)) 0x0046EC70)
// SAVEGAME.CPP
#define Legacy_RestoreGame ((int (__cdecl*)()) 0x00472060)
#define Legacy_ReadSavegame ((int (__cdecl*)(int)) 0x004A8E10)
#define Legacy_CreateSavegame ((void (__cdecl*)()) 0x00470FA0)
#define Legacy_WriteSavegame ((int (__cdecl*)(int)) 0x004A8BC0)
// SPHERE.CPP
#define Legacy_TestCollision ((int (__cdecl*)(ITEM_INFO*, ITEM_INFO*)) 0x00479170)
#define Legacy_GetJointAbsPosition ((int (__cdecl*)(ITEM_INFO*, PHD_VECTOR*, int)) 0x00479780)
#define Legacy_GetSpheres ((int (__cdecl*)(ITEM_INFO*, SPHERE*, int)) 0x00479380)
// SPOTCAM.CPP
#define Legacy_InitSpotCamSequences ((void (__cdecl*)()) 0x0047A800)
#define Legacy_CalculateSpotCameras ((void (__cdecl*)()) 0x0047B280)
#define Legacy_InitialiseSpotCam ((void (__cdecl*)(short)) 0x0047A9D0)
#define Legacy_TriggerTitleSpotcam ((void (__cdecl*)(int)) 0x004284A0)
#define Legacy_Spline ((int (__cdecl*)(int, int*, int)) 0x0047A890)
// SWITCH.CPP
#define Legacy_InitialiseSwitch ((void (__cdecl*)(short)) 0x00440070)
#define Legacy_SequenceControl ((void (__cdecl*)(short)) 0x0047F520)
#define Legacy_SequenceCollision ((void (__cdecl*)(short,ITEM_INFO*,COLL_INFO*)) 0x0047F610)
#define Legacy_LeverSwitchCollision ((void (__cdecl*)(short,ITEM_INFO*,COLL_INFO*)) 0x0047EE00)
#define Legacy_InitialisePulleySwitch ((void (__cdecl*)(short)) 0x0043E1F0)
#define Legacy_InitialiseCrowDoveSwitch ((void (__cdecl*)(short)) 0x0043ECF0)
// MISC
#define Legacy_SQRT_ASM ((int(__cdecl*)(int)) 0x0048F980)

View file

@ -18,7 +18,7 @@
#define TR_ANGLE_TO_DEGREES(x) ((x) / 65536.0f * 360.0f)
#define TR_ANGLE_TO_RAD(x) ((x) / 65536.0f * 360.0f * RADIAN)
#define SQRT_ASM ((int(__cdecl*)(int)) 0x0048F980)
#define SQRT_ASM(x) (int)sqrt(x)
#define ATAN ((int(__cdecl*)(int, int)) 0x0048F8A0)
#define SIN(x) (4 * rcossin_tbl[(int(x) >> 3) & 8190])
#define COS(x) (4 * rcossin_tbl[((int(x) >> 3) & 8190) + 1])

View file

@ -73,9 +73,9 @@
#define DelCutSeqPlayer VAR_U_(0x0051CE2C, short)
#define TitleControlsLockedOut VAR_U_(0x00E5C2A8, byte)
#define TrackCameraInit VAR_U_(0x0051D010, int)
#define CheckTrigger VAR_U_(0x0051D014, int)
#define UseSpotCam VAR_U_(0x0051D018, int)
#define DisableLaraControl VAR_U_(0x0051D01C, byte)
//#define CheckTrigger VAR_U_(0x0051D014, int)
//#define UseSpotCam VAR_U_(0x0051D018, int)
//#define DisableLaraControl VAR_U_(0x0051D01C, byte)
#define FramesCount VAR_U_(0x0051CA78, int)
#define GlobalCounter VAR_U_(0x0051CA58, short)
#define LevelComplete VAR_U_(0x00E5C2F0, byte)

View file

@ -22,8 +22,6 @@
#include "..\Objects\oldobjects.h"
#include "..\Objects\newobjects.h"
#include "..\Game\rat.h"
#include "roomload.h"
#include <stdlib.h>
@ -2571,14 +2569,14 @@ void ObjectObjects()
obj->savePosition = true;
}
obj = &Objects[ID_XRAY_CONTROLLER];
/*obj = &Objects[ID_XRAY_CONTROLLER];
if (obj->loaded)
{
obj->initialise = InitialiseXRayMachine;
obj->control = ControlXRayMachine;
obj->drawRoutine = NULL;
obj->saveFlags = true;
}
}*/
// by default loaded, explosion time :D
obj = &Objects[ID_BODY_PART];

View file

@ -120,7 +120,6 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<ClInclude Include="Game\bubble.h" />
<ClInclude Include="Game\footprint.h" />
<ClInclude Include="Game\groundfx.h" />
<ClInclude Include="Game\swat.h" />
<ClInclude Include="Global\legacyfunctions.h" />
<ClInclude Include="Libs\fixedpoint\fixed_point.hpp" />
<ClInclude Include="Objects\oldobjects.h" />
@ -187,19 +186,16 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<ClInclude Include="Game\objlight.h" />
<ClInclude Include="Game\people.h" />
<ClInclude Include="Game\pickup.h" />
<ClInclude Include="Game\rat.h" />
<ClInclude Include="Game\rope.h" />
<ClInclude Include="Game\savegame.h" />
<ClInclude Include="Game\sound.h" />
<ClInclude Include="Game\sphere.h" />
<ClInclude Include="Game\spikewall.h" />
<ClInclude Include="Game\spotcam.h" />
<ClInclude Include="Game\switch.h" />
<ClInclude Include="Game\text.h" />
<ClInclude Include="CustomObjects\tiger.h" />
<ClInclude Include="Game\tomb4fx.h" />
<ClInclude Include="Game\traps.h" />
<ClInclude Include="Game\twogun.h" />
<ClInclude Include="Global\constants.h" />
<ClInclude Include="Global\enums.h" />
<ClInclude Include="Global\global.h" />
@ -226,7 +222,6 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<ClCompile Include="Game\bubble.cpp" />
<ClCompile Include="Game\footprint.cpp" />
<ClCompile Include="Game\misc.cpp" />
<ClCompile Include="Game\swat.cpp" />
<ClCompile Include="Global\math.cpp" />
<ClCompile Include="Objects\TR1\tr1_lara_evil.cpp" />
<ClCompile Include="Objects\TR1\tr1_larson.cpp" />
@ -365,7 +360,6 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<ClCompile Include="Game\objlight.cpp" />
<ClCompile Include="Game\people.cpp" />
<ClCompile Include="Game\pickup.cpp" />
<ClCompile Include="Game\rat.cpp" />
<ClCompile Include="Game\rope.cpp" />
<ClCompile Include="Game\savegame.cpp" />
<ClCompile Include="Game\sound.cpp" />
@ -375,7 +369,6 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<ClCompile Include="Game\text.cpp" />
<ClCompile Include="Game\tomb4fx.cpp" />
<ClCompile Include="Game\traps.cpp" />
<ClCompile Include="Game\twogun.cpp" />
<ClCompile Include="Global\malloc.cpp" />
<ClCompile Include="Objects\TR4\tr4_baddy.cpp" />
<ClCompile Include="Objects\Vehicles\motorbike.cpp" />

View file

@ -114,9 +114,6 @@
<ClInclude Include="Game\pickup.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Game\rat.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Game\rope.h">
<Filter>File di intestazione</Filter>
</ClInclude>
@ -144,9 +141,6 @@
<ClInclude Include="Game\traps.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Game\twogun.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Global\malloc.h">
<Filter>File di intestazione</Filter>
</ClInclude>
@ -180,9 +174,6 @@
<ClInclude Include="Specific\setup.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Game\spikewall.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="CustomObjects\cobra.h">
<Filter>File di intestazione</Filter>
</ClInclude>
@ -270,9 +261,6 @@
<ClInclude Include="Specific\configuration.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Game\swat.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Objects\oldobjects.h">
<Filter>File di intestazione</Filter>
</ClInclude>
@ -425,9 +413,6 @@
<ClCompile Include="Game\pickup.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Game\rat.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Game\rope.cpp">
<Filter>File di origine</Filter>
</ClCompile>
@ -455,9 +440,6 @@
<ClCompile Include="Game\traps.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Game\twogun.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Global\malloc.cpp">
<Filter>File di origine</Filter>
</ClCompile>
@ -506,9 +488,6 @@
<ClCompile Include="Specific\configuration.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Game\swat.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Game\misc.cpp">
<Filter>File di origine</Filter>
</ClCompile>