Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Nikolay Korolev 2020-12-02 02:18:38 +03:00
commit c0ca3c7a3e
23 changed files with 723 additions and 81 deletions

Binary file not shown.

View File

@ -82,3 +82,14 @@ CAnimBlendHierarchy::RemoveUncompressedData(void)
#endif #endif
compressed = 1; compressed = 1;
} }
#ifdef USE_CUSTOM_ALLOCATOR
void
CAnimBlendHierarchy::MoveMemory(bool onlyone)
{
int i;
for(i = 0; i < numSequences; i++)
if(sequences[i].MoveMemory() && onlyone)
return;
}
#endif

View File

@ -2,6 +2,10 @@
#include "templates.h" #include "templates.h"
#ifdef MoveMemory
#undef MoveMemory // windows shit
#endif
class CAnimBlendSequence; class CAnimBlendSequence;
// A collection of sequences // A collection of sequences
@ -23,6 +27,7 @@ public:
void RemoveAnimSequences(void); void RemoveAnimSequences(void);
void Uncompress(void); void Uncompress(void);
void RemoveUncompressedData(void); void RemoveUncompressedData(void);
void MoveMemory(bool onlyone = false);
}; };
VALIDATE_SIZE(CAnimBlendHierarchy, 0x28); VALIDATE_SIZE(CAnimBlendHierarchy, 0x28);

View File

@ -176,3 +176,24 @@ CAnimBlendSequence::RemoveUncompressedData(void)
keyFrames = nil; keyFrames = nil;
} }
#ifdef USE_CUSTOM_ALLOCATOR
bool
CAnimBlendSequence::MoveMemory(void)
{
if(keyFrames){
void *newaddr = gMainHeap.MoveMemory(keyFrames);
if(newaddr != keyFrames){
keyFrames = newaddr;
return true;
}
}else if(keyFramesCompressed){
void *newaddr = gMainHeap.MoveMemory(keyFramesCompressed);
if(newaddr != keyFramesCompressed){
keyFramesCompressed = newaddr;
return true;
}
}
return false;
}
#endif

View File

@ -2,6 +2,10 @@
#include "Quaternion.h" #include "Quaternion.h"
#ifdef MoveMemory
#undef MoveMemory // windows shit
#endif
// TODO: put them somewhere else? // TODO: put them somewhere else?
struct KeyFrame { struct KeyFrame {
CQuaternion rotation; CQuaternion rotation;
@ -53,6 +57,7 @@ public:
void Uncompress(void); void Uncompress(void);
void CompressKeyframes(void); void CompressKeyframes(void);
void RemoveUncompressedData(void); void RemoveUncompressedData(void);
bool MoveMemory(void);
#ifdef PED_SKIN #ifdef PED_SKIN
void SetBoneTag(int tag) { boneTag = tag; } void SetBoneTag(int tag) { boneTag = tag; }

View File

@ -353,11 +353,11 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
m_pObject->GetMatrix().UpdateRW(); m_pObject->GetMatrix().UpdateRW();
m_pObject->UpdateRwFrame(); m_pObject->UpdateRwFrame();
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, 0) && waterLevel >= m_pObject->GetPosition().z) if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false) && waterLevel >= m_pObject->GetPosition().z)
m_eType = PICKUP_FLOATINGPACKAGE_FLOATING; m_eType = PICKUP_FLOATINGPACKAGE_FLOATING;
break; break;
case PICKUP_FLOATINGPACKAGE_FLOATING: case PICKUP_FLOATINGPACKAGE_FLOATING:
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, 0)) if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false))
m_pObject->GetMatrix().GetPosition().z = waterLevel; m_pObject->GetMatrix().GetPosition().z = waterLevel;
m_pObject->GetMatrix().UpdateRW(); m_pObject->GetMatrix().UpdateRW();

View File

@ -1,5 +1,5 @@
#include "common.h" #include "common.h"
#ifdef GTA_REPLAY
#include "AnimBlendAssociation.h" #include "AnimBlendAssociation.h"
#include "Boat.h" #include "Boat.h"
#include "SpecialFX.h" #include "SpecialFX.h"
@ -1585,3 +1585,4 @@ void CReplay::Display()
if (Mode == MODE_PLAYBACK) if (Mode == MODE_PLAYBACK)
CFont::PrintString(SCREEN_SCALE_X(63.5f), SCREEN_SCALE_Y(30.0f), TheText.Get("REPLAY")); CFont::PrintString(SCREEN_SCALE_X(63.5f), SCREEN_SCALE_Y(30.0f), TheText.Get("REPLAY"));
} }
#endif

View File

@ -63,6 +63,12 @@ struct CStoredDetailedAnimationState
void PlayReplayFromHD(void); void PlayReplayFromHD(void);
#ifdef GTA_REPLAY
#define REPLAY_STUB
#else
#define REPLAY_STUB {}
#endif
class CReplay class CReplay
{ {
enum { enum {
@ -273,20 +279,24 @@ private:
#endif #endif
public: public:
static void Init(void); static void Init(void) REPLAY_STUB;
static void DisableReplays(void); static void DisableReplays(void) REPLAY_STUB;
static void EnableReplays(void); static void EnableReplays(void) REPLAY_STUB;
static void Update(void); static void Update(void) REPLAY_STUB;
static void FinishPlayback(void); static void FinishPlayback(void) REPLAY_STUB;
static void EmptyReplayBuffer(void); static void EmptyReplayBuffer(void) REPLAY_STUB;
static void Display(void); static void Display(void) REPLAY_STUB;
static void TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene); static void TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene) REPLAY_STUB;
static void StreamAllNecessaryCarsAndPeds(void); static void StreamAllNecessaryCarsAndPeds(void) REPLAY_STUB;
static bool ShouldStandardCameraBeProcessed(void);
#ifndef GTA_REPLAY
static bool ShouldStandardCameraBeProcessed(void) { return true; }
static bool IsPlayingBack() { return false; }
static bool IsPlayingBackFromFile() { return false; }
#else
static bool ShouldStandardCameraBeProcessed(void);
static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; } static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; }
static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; } static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; }
private: private:
static void RecordThisFrame(void); static void RecordThisFrame(void);
static void StorePedUpdate(CPed *ped, int id); static void StorePedUpdate(CPed *ped, int id);
@ -314,4 +324,5 @@ private:
/* Absolute nonsense, but how could this function end up being outside of class? */ /* Absolute nonsense, but how could this function end up being outside of class? */
friend void PlayReplayFromHD(void); friend void PlayReplayFromHD(void);
#endif
}; };

View File

@ -94,9 +94,9 @@ CCamera::Init(void)
#endif #endif
#ifdef PS2_MENU #ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad && !FrontEndMenuManager.m_bWantToRestart ) { if ( !TheMemoryCard.m_bWantToLoad && !FrontEndMenuManager.m_bWantToRestart )
#endif #endif
{
#ifdef FIX_BUGS #ifdef FIX_BUGS
static const CCamera DummyCamera = CCamera(0.f); static const CCamera DummyCamera = CCamera(0.f);
*this = DummyCamera; *this = DummyCamera;
@ -110,9 +110,7 @@ CCamera::Init(void)
#endif #endif
m_pRwCamera = nil; m_pRwCamera = nil;
#ifdef PS2_MENU
} }
#endif
m_1rstPersonRunCloseToAWall = false; m_1rstPersonRunCloseToAWall = false;
m_fPositionAlongSpline = 0.0f; m_fPositionAlongSpline = 0.0f;
@ -719,10 +717,14 @@ CCamera::Process(void)
LODDistMultiplier = 70.0f/CDraw::GetFOV() * CDraw::GetAspectRatio()/(4.0f/3.0f); LODDistMultiplier = 70.0f/CDraw::GetFOV() * CDraw::GetAspectRatio()/(4.0f/3.0f);
else else
LODDistMultiplier = 1.0f; LODDistMultiplier = 1.0f;
// missing on PS2 #ifdef FIX_BUGS
// from VC. to high values bug out spawns
LODDistMultiplier = Min(LODDistMultiplier, 2.2f);
#endif
#if GTA_VERSION > GTA3_PS2_160
GenerationDistMultiplier = LODDistMultiplier; GenerationDistMultiplier = LODDistMultiplier;
LODDistMultiplier *= CRenderer::ms_lodDistScale; LODDistMultiplier *= CRenderer::ms_lodDistScale;
// #endif
// Keep track of speed // Keep track of speed
if(m_bJustInitalised || m_bJust_Switched){ if(m_bJustInitalised || m_bJust_Switched){

View File

@ -59,7 +59,13 @@ CFileLoader::LoadLevel(const char *filename)
savedTxd = RwTexDictionaryCreate(); savedTxd = RwTexDictionaryCreate();
RwTexDictionarySetCurrent(savedTxd); RwTexDictionarySetCurrent(savedTxd);
} }
#if GTA_VERSION <= GTA3_PS2_160
CFileMgr::ChangeDir("\\DATA\\");
fd = CFileMgr::OpenFile(filename, "r"); fd = CFileMgr::OpenFile(filename, "r");
CFileMgr::ChangeDir("\\");
#else
fd = CFileMgr::OpenFile(filename, "r");
#endif
assert(fd > 0); assert(fd > 0);
for(line = LoadLine(fd); line; line = LoadLine(fd)){ for(line = LoadLine(fd); line; line = LoadLine(fd)){

View File

@ -91,6 +91,9 @@
#include "screendroplets.h" #include "screendroplets.h"
#include "crossplatform.h" #include "crossplatform.h"
#include "MemoryHeap.h" #include "MemoryHeap.h"
#ifdef USE_TEXTURE_POOL
#include "TexturePools.h"
#endif
eLevelName CGame::currLevel; eLevelName CGame::currLevel;
bool CGame::bDemoMode = true; bool CGame::bDemoMode = true;
@ -167,6 +170,7 @@ void ReplaceAtomicPipeCallback();
#endif // PS2_ALPHA_TEST #endif // PS2_ALPHA_TEST
#endif // !LIBRW #endif // !LIBRW
// missing altogether on PS2, mostly done in GameInit there it seems
bool bool
CGame::InitialiseRenderWare(void) CGame::InitialiseRenderWare(void)
{ {
@ -233,6 +237,7 @@ CGame::InitialiseRenderWare(void)
return (true); return (true);
} }
// missing altogether on PS2
void CGame::ShutdownRenderWare(void) void CGame::ShutdownRenderWare(void)
{ {
CMBlur::MotionBlurClose(); CMBlur::MotionBlurClose();
@ -265,16 +270,19 @@ void CGame::ShutdownRenderWare(void)
#endif #endif
} }
// missing altogether on PS2
bool CGame::InitialiseOnceAfterRW(void) bool CGame::InitialiseOnceAfterRW(void)
{ {
#if GTA_VERSION > GTA3_PS2_160
TheText.Load(); TheText.Load();
DMAudio.Initialise(); DMAudio.Initialise(); // before TheGame() on PS2
CTimer::Initialise(); CTimer::Initialise();
CTempColModels::Initialise(); CTempColModels::Initialise();
mod_HandlingManager.Initialise(); mod_HandlingManager.Initialise();
CSurfaceTable::Initialise("DATA\\SURFACE.DAT"); CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
CPedStats::Initialise(); CPedStats::Initialise();
CTimeCycle::Initialise(); CTimeCycle::Initialise();
#endif
if ( DMAudio.GetNum3DProvidersAvailable() == 0 ) if ( DMAudio.GetNum3DProvidersAvailable() == 0 )
FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1; FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1;
@ -318,6 +326,7 @@ bool CGame::InitialiseOnceAfterRW(void)
return true; return true;
} }
// missing altogether on PS2
void void
CGame::FinalShutdown(void) CGame::FinalShutdown(void)
{ {
@ -330,10 +339,15 @@ bool CGame::Initialise(const char* datFile)
{ {
#ifdef GTA_PS2 #ifdef GTA_PS2
// TODO: upload VU0 collision code here // TODO: upload VU0 collision code here
#else #endif
#if GTA_VERSION > GTA3_PS2_160
ResetLoadingScreenBar(); ResetLoadingScreenBar();
strcpy(aDatFile, datFile); strcpy(aDatFile, datFile);
CPools::Initialise(); // done in CWorld on PS2 CPools::Initialise(); // done in CWorld on PS2
#endif
#ifndef GTA_PS2
CIniFile::LoadIniFile(); CIniFile::LoadIniFile();
#endif #endif
@ -367,13 +381,15 @@ bool CGame::Initialise(const char* datFile)
CWeather::Init(); CWeather::Init();
CCullZones::Init(); CCullZones::Init();
CCollision::Init(); CCollision::Init();
#ifdef PS2_MENU #ifdef PS2_MENU // TODO: is this the right define?
TheText.Load(); TheText.Load();
#endif #endif
CTheZones::Init(); CTheZones::Init();
CUserDisplay::Init(); CUserDisplay::Init();
CMessages::Init(); CMessages::Init();
#if GTA_VERSION > GTA3_PS2_160
CMessages::ClearAllMessagesDisplayedByGame(); CMessages::ClearAllMessagesDisplayedByGame();
#endif
CRecordDataForGame::Init(); CRecordDataForGame::Init();
CRestart::Initialise(); CRestart::Initialise();
@ -381,11 +397,17 @@ bool CGame::Initialise(const char* datFile)
CWorld::Initialise(); CWorld::Initialise();
POP_MEMID(); POP_MEMID();
#if GTA_VERSION <= GTA3_PS2_160
mod_HandlingManager.Initialise();
CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
CTempColModels::Initialise();
#endif
PUSH_MEMID(MEMID_TEXTURES); PUSH_MEMID(MEMID_TEXTURES);
CParticle::Initialise(); CParticle::Initialise();
POP_MEMID(); POP_MEMID();
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
gStartX = -180.0f; gStartX = -180.0f;
gStartY = 180.0f; gStartY = 180.0f;
gStartZ = 14.0f; gStartZ = 14.0f;
@ -400,20 +422,31 @@ bool CGame::Initialise(const char* datFile)
CCarCtrl::Init(); CCarCtrl::Init();
POP_MEMID(); POP_MEMID();
#ifndef GTA_PS2 #if GTA_VERSION > GTA3_PS2_160
InitModelIndices(); InitModelIndices();
#endif #endif
PUSH_MEMID(MEMID_DEF_MODELS); PUSH_MEMID(MEMID_DEF_MODELS);
CModelInfo::Initialise(); CModelInfo::Initialise();
#ifndef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
CPedStats::Initialise(); // InitialiseOnceAfterRW
#else
// probably moved before LoadLevel for multiplayer maps? // probably moved before LoadLevel for multiplayer maps?
CPickups::Init(); CPickups::Init();
CTheCarGenerators::Init(); CTheCarGenerators::Init();
#endif #endif
#ifndef GTA_PS2 // or GTA_VERSION?
CdStreamAddImage("MODELS\\GTA3.IMG"); CdStreamAddImage("MODELS\\GTA3.IMG");
#endif
#if GTA_VERSION > GTA3_PS2_160
CFileLoader::LoadLevel("DATA\\DEFAULT.DAT"); CFileLoader::LoadLevel("DATA\\DEFAULT.DAT");
CFileLoader::LoadLevel(datFile); CFileLoader::LoadLevel(datFile);
#else
CFileLoader::LoadLevel("GTA3.DAT");
#endif
#ifdef EXTENDED_PIPELINES #ifdef EXTENDED_PIPELINES
// for generic fallback // for generic fallback
CustomPipes::SetTxdFindCallback(); CustomPipes::SetTxdFindCallback();
@ -424,18 +457,25 @@ bool CGame::Initialise(const char* datFile)
CTheZones::PostZoneCreation(); CTheZones::PostZoneCreation();
POP_MEMID(); POP_MEMID();
#if GTA_VERSION <= GTA3_PS2_160
TestModelIndices();
#endif
LoadingScreen("Loading the Game", "Setup paths", GetRandomSplashScreen()); LoadingScreen("Loading the Game", "Setup paths", GetRandomSplashScreen());
ThePaths.PreparePathData(); ThePaths.PreparePathData();
// done elsewhere on PS2 #if GTA_VERSION > GTA3_PS2_160
for (int i = 0; i < NUMPLAYERS; i++) for (int i = 0; i < NUMPLAYERS; i++)
CWorld::Players[i].Clear(); CWorld::Players[i].Clear();
CWorld::Players[0].LoadPlayerSkin(); CWorld::Players[0].LoadPlayerSkin();
TestModelIndices(); TestModelIndices();
// #endif
LoadingScreen("Loading the Game", "Setup water", nil); LoadingScreen("Loading the Game", "Setup water", nil);
CWaterLevel::Initialise("DATA\\WATER.DAT"); CWaterLevel::Initialise("DATA\\WATER.DAT");
#if GTA_VERSION <= GTA3_PS2_160
CTimeCycle::Initialise(); // InitialiseOnceAfterRW
#else
TheConsole.Init(); TheConsole.Init();
#endif
CDraw::SetFOV(120.0f); CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f; CDraw::ms_fLODDistance = 500.0f;
@ -472,6 +512,11 @@ bool CGame::Initialise(const char* datFile)
LoadingScreen("Loading the Game", "Setup game variables", nil); LoadingScreen("Loading the Game", "Setup game variables", nil);
CPopulation::Initialise(); CPopulation::Initialise();
#if GTA_VERSION <= GTA3_PS2_160
for (int i = 0; i < NUMPLAYERS; i++)
CWorld::Players[i].Clear();
// CWorld::Players[0].LoadPlayerSkin(); // TODO: use a define for this
#endif
CWorld::PlayerInFocus = 0; CWorld::PlayerInFocus = 0;
CCoronas::Init(); CCoronas::Init();
CShadows::Init(); CShadows::Init();
@ -480,7 +525,7 @@ bool CGame::Initialise(const char* datFile)
CAntennas::Init(); CAntennas::Init();
CGlass::Init(); CGlass::Init();
gPhoneInfo.Initialise(); gPhoneInfo.Initialise();
#ifndef GTA_PS2 #ifndef GTA_PS2 // TODO: define for this
CSceneEdit::Initialise(); CSceneEdit::Initialise();
#endif #endif
@ -491,11 +536,11 @@ bool CGame::Initialise(const char* datFile)
POP_MEMID(); POP_MEMID();
LoadingScreen("Loading the Game", "Setup game variables", nil); LoadingScreen("Loading the Game", "Setup game variables", nil);
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
CTimer::Initialise(); CTimer::Initialise();
#endif #endif
CClock::Initialise(1000); CClock::Initialise(1000);
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
CTheCarGenerators::Init(); CTheCarGenerators::Init();
#endif #endif
CHeli::InitHelis(); CHeli::InitHelis();
@ -503,27 +548,35 @@ bool CGame::Initialise(const char* datFile)
CMovingThings::Init(); CMovingThings::Init();
CDarkel::Init(); CDarkel::Init();
CStats::Init(); CStats::Init();
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
CPickups::Init(); CPickups::Init();
#endif #endif
CPacManPickups::Init(); CPacManPickups::Init();
// CGarages::Init(); here on PS2 instead #if GTA_VERSION <= GTA3_PS2_160
CGarages::Init();
#endif
CRubbish::Init(); CRubbish::Init();
CClouds::Init(); CClouds::Init();
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
CRemote::Init(); CRemote::Init();
#endif #endif
CSpecialFX::Init(); CSpecialFX::Init();
CWaterCannons::Init(); CWaterCannons::Init();
CBridge::Init(); CBridge::Init();
#if GTA_VERSION > GTA3_PS2_160
CGarages::Init(); CGarages::Init();
#endif
LoadingScreen("Loading the Game", "Position dynamic objects", nil); LoadingScreen("Loading the Game", "Position dynamic objects", nil);
CWorld::RepositionCertainDynamicObjects(); CWorld::RepositionCertainDynamicObjects();
// CCullZones::ResolveVisibilities(); on PS2 here instead #if GTA_VERSION <= GTA3_PS2_160
CCullZones::ResolveVisibilities();
#endif
LoadingScreen("Loading the Game", "Initialise vehicle paths", nil); LoadingScreen("Loading the Game", "Initialise vehicle paths", nil);
#if GTA_VERSION > GTA3_PS2_160
CCullZones::ResolveVisibilities(); CCullZones::ResolveVisibilities();
#endif
CTrain::InitTrains(); CTrain::InitTrains();
CPlane::InitPlanes(); CPlane::InitPlanes();
CCredits::Init(); CCredits::Init();
@ -532,15 +585,13 @@ bool CGame::Initialise(const char* datFile)
#ifdef PS2_MENU #ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad ) if ( !TheMemoryCard.m_bWantToLoad )
{
#endif #endif
{
LoadingScreen("Loading the Game", "Start script", nil); LoadingScreen("Loading the Game", "Start script", nil);
CTheScripts::StartTestScript(); CTheScripts::StartTestScript();
CTheScripts::Process(); CTheScripts::Process();
TheCamera.Process(); TheCamera.Process();
#ifdef PS2_MENU
} }
#endif
LoadingScreen("Loading the Game", "Load scene", nil); LoadingScreen("Loading the Game", "Load scene", nil);
CModelInfo::RemoveColModelsFromOtherLevels(currLevel); CModelInfo::RemoveColModelsFromOtherLevels(currLevel);
@ -556,7 +607,7 @@ bool CGame::ShutDown(void)
CPlane::Shutdown(); CPlane::Shutdown();
CTrain::Shutdown(); CTrain::Shutdown();
CSpecialFX::Shutdown(); CSpecialFX::Shutdown();
#ifndef PS2 #if GTA_VERSION > GTA3_PS2_160
CGarages::Shutdown(); CGarages::Shutdown();
#endif #endif
CMovingThings::Shutdown(); CMovingThings::Shutdown();
@ -597,7 +648,9 @@ bool CGame::ShutDown(void)
CSkidmarks::Shutdown(); CSkidmarks::Shutdown();
CWeaponEffects::Shutdown(); CWeaponEffects::Shutdown();
CParticle::Shutdown(); CParticle::Shutdown();
#if GTA_VERSION > GTA3_PS2_160
CPools::ShutDown(); CPools::ShutDown();
#endif
CTxdStore::RemoveTxdSlot(gameTxdSlot); CTxdStore::RemoveTxdSlot(gameTxdSlot);
CdStreamRemoveImages(); CdStreamRemoveImages();
return true; return true;
@ -608,13 +661,11 @@ void CGame::ReInitGameObjectVariables(void)
CGameLogic::InitAtStartOfGame(); CGameLogic::InitAtStartOfGame();
#ifdef PS2_MENU #ifdef PS2_MENU
if ( !TheMemoryCard.m_bWantToLoad ) if ( !TheMemoryCard.m_bWantToLoad )
{
#endif #endif
{
TheCamera.Init(); TheCamera.Init();
TheCamera.SetRwCamera(Scene.camera); TheCamera.SetRwCamera(Scene.camera);
#ifdef PS2_MENU
} }
#endif
CDebug::DebugInitTextBuffer(); CDebug::DebugInitTextBuffer();
CWeather::Init(); CWeather::Init();
CUserDisplay::Init(); CUserDisplay::Init();
@ -623,7 +674,7 @@ void CGame::ReInitGameObjectVariables(void)
CWorld::bDoingCarCollisions = false; CWorld::bDoingCarCollisions = false;
CHud::ReInitialise(); CHud::ReInitialise();
CRadar::Initialise(); CRadar::Initialise();
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
gStartX = -180.0f; gStartX = -180.0f;
gStartY = 180.0f; gStartY = 180.0f;
gStartZ = 14.0f; gStartZ = 14.0f;
@ -646,7 +697,7 @@ void CGame::ReInitGameObjectVariables(void)
CWorld::Players[i].Clear(); CWorld::Players[i].Clear();
CWorld::PlayerInFocus = 0; CWorld::PlayerInFocus = 0;
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
CWeaponEffects::Init(); CWeaponEffects::Init();
CSkidmarks::Init(); CSkidmarks::Init();
#endif #endif
@ -669,7 +720,7 @@ void CGame::ReInitGameObjectVariables(void)
CPickups::Init(); CPickups::Init();
CPacManPickups::Init(); CPacManPickups::Init();
CGarages::Init(); CGarages::Init();
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
CClouds::Init(); CClouds::Init();
CRemote::Init(); CRemote::Init();
#endif #endif
@ -739,7 +790,7 @@ void CGame::ShutDownForRestart(void)
CRadar::RemoveRadarSections(); CRadar::RemoveRadarSections();
FrontEndMenuManager.UnloadTextures(); FrontEndMenuManager.UnloadTextures();
CParticleObject::RemoveAllParticleObjects(); CParticleObject::RemoveAllParticleObjects();
#ifndef PS2 #if GTA_VERSION >= GTA3_PS2_160
CPedType::Shutdown(); CPedType::Shutdown();
CSpecialFX::Shutdown(); CSpecialFX::Shutdown();
#endif #endif
@ -925,7 +976,9 @@ void CGame::Process(void)
CSkidmarks::Update(); CSkidmarks::Update();
CAntennas::Update(); CAntennas::Update();
CGlass::Update(); CGlass::Update();
#ifndef GTA_PS2 // TODO: define
CSceneEdit::Update(); CSceneEdit::Update();
#endif
CEventList::Update(); CEventList::Update();
CParticle::Update(); CParticle::Update();
gFireManager.Update(); gFireManager.Update();
@ -977,23 +1030,163 @@ void CGame::Process(void)
#endif #endif
} }
void CGame::DrasticTidyUpMemory(bool) int32 gNumMemMoved;
RwTexture *
MoveTextureMemoryCB(RwTexture *texture, void *pData)
{
// TODO
return texture;
}
bool
TidyUpModelInfo(CBaseModelInfo *,bool)
{
// TODO
return false;
}
void CGame::DrasticTidyUpMemory(bool flushDraw)
{ {
#ifdef USE_CUSTOM_ALLOCATOR #ifdef USE_CUSTOM_ALLOCATOR
// meow bool removedCol = false;
TidyUpMemory(true, flushDraw);
if(gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro){
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
TidyUpMemory(true, flushDraw);
}
if(gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro){
CModelInfo::RemoveColModelsFromOtherLevels(LEVEL_GENERIC);
TidyUpMemory(true, flushDraw);
removedCol = true;
}
if(gMainHeap.GetLargestFreeBlock() < 200000 && !playingIntro){
CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL);
CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL);
CStreaming::RemoveBigBuildings(LEVEL_SUBURBAN);
TidyUpMemory(true, flushDraw);
}
if(removedCol){
// different on PS2
CFileLoader::LoadCollisionFromDatFile(CCollision::ms_collisionInMemory);
}
if(!playingIntro)
CStreaming::RequestBigBuildings(currLevel);
CStreaming::LoadAllRequestedModels(true);
#endif #endif
} }
void CGame::TidyUpMemory(bool, bool) void CGame::TidyUpMemory(bool moveTextures, bool flushDraw)
{ {
#ifdef USE_CUSTOM_ALLOCATOR #ifdef USE_CUSTOM_ALLOCATOR
// meow printf("Largest free block before tidy %d\n", gMainHeap.GetLargestFreeBlock());
if(moveTextures){
if(flushDraw){
#ifdef GTA_PS2
for(int i = 0; i < sweMaxFlips+1; i++){
#else
for(int i = 0; i < 5; i++){ // probably more than needed
#endif
RwCameraBeginUpdate(Scene.camera);
RwCameraEndUpdate(Scene.camera);
RwCameraShowRaster(Scene.camera, nil, 0);
}
}
int fontSlot = CTxdStore::FindTxdSlot("fonts");
for(int i = 0; i < TXDSTORESIZE; i++){
if(i == fontSlot ||
CTxdStore::GetSlot(i) == nil)
continue;
RwTexDictionary *txd = CTxdStore::GetSlot(i)->texDict;
if(txd)
RwTexDictionaryForAllTextures(txd, MoveTextureMemoryCB, nil);
}
}
// animations
for(int i = 0; i < NUMANIMATIONS; i++){
CAnimBlendHierarchy *anim = CAnimManager::GetAnimation(i);
if(anim == nil)
continue; // cannot happen
anim->MoveMemory();
}
// model info
for(int i = 0; i < MODELINFOSIZE; i++){
CBaseModelInfo *mi = CModelInfo::GetModelInfo(i);
if(mi == nil)
continue;
TidyUpModelInfo(mi, false);
}
printf("Largest free block after tidy %d\n", gMainHeap.GetLargestFreeBlock());
#endif #endif
} }
void CGame::ProcessTidyUpMemory(void) void CGame::ProcessTidyUpMemory(void)
{ {
#ifdef USE_CUSTOM_ALLOCATOR #ifdef USE_CUSTOM_ALLOCATOR
// meow static int32 modelIndex = 0;
static int32 animIndex = 0;
static int32 txdIndex = 0;
bool txdReturn = false;
RwTexDictionary *txd = nil;
gNumMemMoved = 0;
// model infos
for(int numCleanedUp = 0; numCleanedUp < 10; numCleanedUp++){
CBaseModelInfo *mi;
do{
mi = CModelInfo::GetModelInfo(modelIndex);
modelIndex++;
if(modelIndex >= MODELINFOSIZE)
modelIndex = 0;
}while(mi == nil);
if(TidyUpModelInfo(mi, true))
return;
}
// tex dicts
for(int numCleanedUp = 0; numCleanedUp < 3; numCleanedUp++){
if(gNumMemMoved > 80)
break;
do{
#ifdef FIX_BUGS
txd = nil;
#endif
if(CTxdStore::GetSlot(txdIndex))
txd = CTxdStore::GetSlot(txdIndex)->texDict;
txdIndex++;
if(txdIndex >= TXDSTORESIZE)
txdIndex = 0;
}while(txd == nil);
RwTexDictionaryForAllTextures(txd, MoveTextureMemoryCB, &txdReturn);
if(txdReturn)
return;
}
// animations
CAnimBlendHierarchy *anim;
do{
anim = CAnimManager::GetAnimation(animIndex);
animIndex++;
if(animIndex >= NUMANIMATIONS)
animIndex = 0;
}while(anim == nil); // always != nil
anim->MoveMemory(true);
#endif #endif
} }

View File

@ -53,7 +53,7 @@ bool CWorld::bIncludeCarTyres;
void void
CWorld::Initialise() CWorld::Initialise()
{ {
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
CPools::Initialise(); CPools::Initialise();
#endif #endif
pIgnoreEntity = nil; pIgnoreEntity = nil;
@ -1791,6 +1791,9 @@ CWorld::ShutDown(void)
} }
} }
ms_listMovingEntityPtrs.Flush(); ms_listMovingEntityPtrs.Flush();
#if GTA_VERSION <= GTA3_PS2_160
CPools::Shutdown();
#endif
} }
void void

View File

@ -196,6 +196,7 @@ enum Config {
# define RANDOMSPLASH // use random splash as on PS2 # define RANDOMSPLASH // use random splash as on PS2
# define PS2_MATFX # define PS2_MATFX
# endif # endif
# define GTA_REPLAY
#elif defined GTA_XBOX #elif defined GTA_XBOX
#endif #endif

View File

@ -415,6 +415,7 @@ PluginAttach(void)
return TRUE; return TRUE;
} }
// rather different on PS2
static RwBool static RwBool
Initialise3D(void *param) Initialise3D(void *param)
{ {

View File

@ -187,7 +187,7 @@ CMemoryHeap::Malloc(uint32 size)
void *mem = Malloc(size); void *mem = Malloc(size);
if (removeCollision) { if (removeCollision) {
CTimer::Stop(); CTimer::Stop();
// different on PS2 // TODO: different on PS2
CFileLoader::LoadCollisionFromDatFile(CCollision::ms_collisionInMemory); CFileLoader::LoadCollisionFromDatFile(CCollision::ms_collisionInMemory);
removeCollision = false; removeCollision = false;
CTimer::Update(); CTimer::Update();

View File

@ -198,6 +198,7 @@ public:
void TidyHeap(void); void TidyHeap(void);
uint32 GetMemoryUsed(int32 id); uint32 GetMemoryUsed(int32 id);
uint32 GetBlocksUsed(int32 id); uint32 GetBlocksUsed(int32 id);
int32 GetLargestFreeBlock(void) { return m_freeList.m_last.m_prev->m_size; }
void ParseHeap(void); void ParseHeap(void);

View File

@ -605,11 +605,6 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer)
return (nil); return (nil);
} }
#ifdef USE_TEXTURE_POOL
WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); }
WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); }
#endif
#ifdef LIBRW #ifdef LIBRW
#include <rpmatfx.h> #include <rpmatfx.h>
#include "VehicleModelInfo.h" #include "VehicleModelInfo.h"

View File

@ -50,8 +50,6 @@ RwCamera *CameraCreate(RwInt32 width,
RwBool zBuffer); RwBool zBuffer);
void _TexturePoolsInitialise();
void _TexturePoolsShutdown();
RpAtomic *ConvertPlatformAtomic(RpAtomic *atomic, void *data); RpAtomic *ConvertPlatformAtomic(RpAtomic *atomic, void *data);

221
src/rw/TexturePools.cpp Normal file
View File

@ -0,0 +1,221 @@
#ifndef LIBRW
#include <d3d8.h>
#define WITHD3D
#include "common.h"
#include "TexturePools.h"
// TODO: this needs to be integrated into RW
extern "C" LPDIRECT3DDEVICE8 _RwD3DDevice;
CTexturePool aTexturePools[12];
CPaletteList PaletteList;
int numTexturePools;
int MaxPaletteIndex;
bool bUsePaletteIndex = true;
void
CTexturePool::Create(D3DFORMAT _Format, int _size, uint32 mipmapLevels, int32 numTextures)
{
Format = _Format;
size = _size;
levels = mipmapLevels;
pTextures = new IDirect3DTexture8 *[numTextures];
texturesMax = numTextures;
texturesNum = 0;
texturesUsed = 0;
}
void
CTexturePool::Release()
{
int i = 0;
while (i < texturesNum) {
pTextures[i]->Release();
i++;
}
delete[] pTextures;
pTextures = nil;
texturesNum = 0;
texturesUsed = 0;
}
IDirect3DTexture8 *
CTexturePool::FindTexture()
{
if (texturesNum == 0)
return nil;
texturesUsed--;
return pTextures[--texturesNum];
}
bool
CTexturePool::AddTexture(IDirect3DTexture8 *texture)
{
++texturesUsed;
if (texturesNum >= texturesMax)
return false;
pTextures[texturesNum] = texture;
++texturesNum;
return true;
}
void
CTexturePool::Resize(int numTextures)
{
if (numTextures == texturesMax)
return;
IDirect3DTexture8 **newTextures = new IDirect3DTexture8 *[numTextures];
for (int i = 0; i < texturesNum && i < numTextures; i++)
newTextures[i] = pTextures[i];
if (numTextures < texturesNum) {
for (int i = numTextures; i < texturesNum; i++)
pTextures[i]->Release();
}
delete[] pTextures;
pTextures = newTextures;
texturesMax = numTextures;
}
void
CPaletteList::Alloc(int max)
{
Data = new int[max];
Max = max;
Num = 0;
}
void
CPaletteList::Free()
{
delete[] Data;
Data = nil;
Num = 0;
}
int
CPaletteList::Find()
{
if (Num == 0)
return -1;
return Data[--Num];
}
void
CPaletteList::Add(int item)
{
if (Num < Max)
Data[Num++] = item;
else {
Resize(2 * Max);
Add(item);
}
}
void
CPaletteList::Resize(int max)
{
if (max == Max)
return;
int *newData = new int[4 * max];
for (int i = 0; i < Num && i < max; i++)
newData[i] = Data[i];
delete[] Data;
Data = newData;
Max = max;
}
HRESULT
CreateTexture(int width, int height, int levels, D3DFORMAT Format, IDirect3DTexture8 **texture)
{
if (width == height) {
for (int i = 0; i < numTexturePools; i++) {
if (width != aTexturePools[i].GetSize() && levels == aTexturePools[i].levels && Format == aTexturePools[i].Format)
*texture = aTexturePools[i].FindTexture();
}
}
if (*texture)
return D3D_OK;
else
return _RwD3DDevice->CreateTexture(width, height, levels, 0, Format, D3DPOOL_MANAGED, texture);
}
void
ReleaseTexture(IDirect3DTexture8 *texture)
{
int levels = 1;
if (texture->GetLevelCount() > 1)
levels = 0;
D3DSURFACE_DESC SURFACE_DESC;
texture->GetLevelDesc(0, &SURFACE_DESC);
if (SURFACE_DESC.Width == SURFACE_DESC.Height) {
for (int i = 0; i < numTexturePools; i++) {
if (SURFACE_DESC.Width == aTexturePools[i].GetSize() && SURFACE_DESC.Format == aTexturePools[i].Format && levels == aTexturePools[i].levels) {
if (!aTexturePools[i].AddTexture(texture)) {
if (aTexturePools[i].texturesUsed > 3 * aTexturePools[i].texturesMax / 2) {
aTexturePools[i].Resize(2 * aTexturePools[i].texturesMax);
aTexturePools[i].texturesUsed--;
aTexturePools[i].AddTexture(texture);
} else {
texture->Release();
}
}
return;
}
}
}
if (numTexturePools < 12 && bUsePaletteIndex && levels != 0 && SURFACE_DESC.Width == SURFACE_DESC.Height &&
(SURFACE_DESC.Width == 64 || SURFACE_DESC.Width == 128 || SURFACE_DESC.Width == 256)) {
aTexturePools[numTexturePools].Create(SURFACE_DESC.Format, SURFACE_DESC.Width, 1, 16);
aTexturePools[numTexturePools].AddTexture(texture);
numTexturePools++;
} else
texture->Release();
}
int
FindAvailablePaletteIndex()
{
int index = PaletteList.Find();
if (index == -1)
index = MaxPaletteIndex++;
return index;
}
void
AddAvailablePaletteIndex(int index)
{
if (bUsePaletteIndex)
PaletteList.Add(index);
}
void
_TexturePoolsInitialise()
{
PaletteList.Alloc(100);
MaxPaletteIndex = 0;
}
void
_TexturePoolsShutdown()
{
for (int i = 0; i < numTexturePools; i++)
aTexturePools[i].Release();
numTexturePools = 0;
bUsePaletteIndex = false;
PaletteList.Free();
}
#endif // !LIBRW

42
src/rw/TexturePools.h Normal file
View File

@ -0,0 +1,42 @@
#pragma once
class CTexturePool
{
public:
D3DFORMAT Format;
int size;
uint32 levels;
int32 texturesMax;
int32 texturesUsed;
int32 texturesNum;
IDirect3DTexture8 **pTextures;
public:
CTexturePool() {}
void Create(D3DFORMAT _Format, int size, uint32 mipmapLevels, int32 numTextures);
void Release();
IDirect3DTexture8 *FindTexture();
bool AddTexture(IDirect3DTexture8 *texture);
void Resize(int numTextures);
#ifdef FIX_BUGS
int GetSize() { return size; }
#else
float GetSize() { return size; }
#endif
};
class CPaletteList
{
int Max;
int Num;
int *Data;
public:
void Alloc(int max);
void Free();
int Find();
void Add(int item);
void Resize(int max);
};
void _TexturePoolsInitialise();
void _TexturePoolsShutdown();

View File

@ -1453,12 +1453,14 @@ WinMain(HINSTANCE instance,
RwChar** argv; RwChar** argv;
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE);
#if 0 #ifndef MASTER
// TODO: make this an option somewhere if (strstr(cmdLine, "-console"))
{
AllocConsole(); AllocConsole();
freopen("CONIN$", "r", stdin); freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr); freopen("CONOUT$", "w", stderr);
}
#endif #endif
#else #else

View File

@ -2011,16 +2011,18 @@ WinMain(HINSTANCE instance,
RwChar **argv; RwChar **argv;
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE);
#ifdef USE_CUSTOM_ALLOCATOR #ifndef MASTER
InitMemoryMgr(); if (strstr(cmdLine, "-console"))
#endif {
#if 1
// TODO: make this an option somewhere
AllocConsole(); AllocConsole();
freopen("CONIN$", "r", stdin); freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr); freopen("CONOUT$", "w", stderr);
}
#endif
#ifdef USE_CUSTOM_ALLOCATOR
InitMemoryMgr();
#endif #endif
/* /*

View File

@ -8021,11 +8021,132 @@ Error al cargar el juego. El juego se reiniciará.
RESTAURADO AJUSTE ORIGINAL RESTAURADO AJUSTE ORIGINAL
[FET_RSC] [FET_RSC]
HARDAWARE NO DISPONIBLE. RESTAURADO AJUSTE ORIGINAL HARDWARE NOT AVAILABLE - ORIGINAL SETTING RESTORED HARDAWARE NO DISPONIBLE. RESTAURADO AJUSTE ORIGINAL
[CRED270] [CRED270]
MIKE HONG MIKE HONG
{ re3 updates }
{ new languages }
[FEL_JAP]
JAPONÉS
[FEL_POL]
POLACO
[FEL_RUS]
RUSO
{ new display menus }
[FET_GRA]
AJUSTES GRÁFICOS
[FED_MIP]
MIPMAPPING
[FED_AAS]
SUAVIZADO DE BORDES
[FED_FIL]
FILTRO DE TEXTURAS
[FED_BIL]
BILINEAL
[FED_TRL]
TRILINEAL
[FED_WND]
VENTANA
[FED_FLS]
PANTALLA COMPLETA
[FEM_CSB]
BORDES EN CINEMÁTICAS
[FEM_SCF]
FORMATO DE IMAGEN
[FEM_ISL]
USO DE MEMORIA
[FEM_LOW]
BAJO
[FEM_MED]
MEDIO
[FEM_HIG]
ALTO
[FEM_2PR]
ALPHA TEST TIPO PS2
[FEC_FRC]
CÁMARA LIBRE
{ Linux joy detection }
[FEC_JOD]
DETECTAR JOYSTICK
[FEC_JPR]
Pulsa cualquier botón del joystick que quieras usar con el juego para seleccionarlo.
[FEC_JDE]
Joystick detectado
{ mission restart }
[FET_RMS]
REPETIR MISIÓN
[FESZ_RM]
¿REINTENTAR?
[FED_VPL]
FLUJO DE VEHÍCULOS
[FED_PRM]
LUCES EN PEATONES
[FED_RGL]
BRILLO DE CARRETERAS
[FED_CLF]
FILTRO DE COLOR
[FED_WLM]
MAPAS DE LUZ DEL MUNDO
[FED_MBL]
DESENFOQ. MOVIMIENTO
[FEM_SIM]
SIMPLE
[FEM_NRM]
NORMAL
[FEM_MOB]
MÓVIL
[FED_MFX]
MATFX
[FED_NEO]
NEO
[FEM_PS2]
PS2
[FEM_XBX]
XBOX
[FEC_IVP]
INVERTIR VERTICALIDAD MANDO
{ end of file }
[DUMMY] [DUMMY]
THIS LABEL NEEDS TO BE HERE !!! THIS LABEL NEEDS TO BE HERE !!!
AS THE LAST LABEL DOES NOT GET COMPILED AS THE LAST LABEL DOES NOT GET COMPILED