summaryrefslogtreecommitdiffstats
path: root/src/core/Game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/Game.cpp')
-rw-r--r--src/core/Game.cpp203
1 files changed, 193 insertions, 10 deletions
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 33afc956..82e6992d 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -43,6 +43,7 @@
#include "Lights.h"
#include "MBlur.h"
#include "Messages.h"
+#include "MemoryCard.h"
#include "Pad.h"
#include "Particle.h"
#include "ParticleObject.h"
@@ -85,8 +86,7 @@
#include "ZoneCull.h"
#include "Zones.h"
#include "debugmenu.h"
-
-
+#include "frontendoption.h"
eLevelName CGame::currLevel;
bool CGame::bDemoMode = true;
@@ -103,6 +103,43 @@ bool CGame::japaneseGame = false;
int gameTxdSlot;
+
+bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
+void DoRWStuffEndOfFrame(void);
+void MessageScreen(char *msg)
+{
+ //TODO: stretch_screen
+
+ CRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ CRGBA color(255, 255, 255, 255);
+
+ DoRWStuffStartOfFrame(50, 50, 50, 0, 0, 0, 255);
+
+ CSprite2d::InitPerFrame();
+ CFont::InitPerFrame();
+ DefinedState();
+
+ CSprite2d *splash = LoadSplash(NULL);
+ splash->Draw(rect, color, color, color, color);
+ splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_SCALE_X(620.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192));
+
+ CFont::SetFontStyle(FONT_BANK);
+ CFont::SetBackgroundOff();
+ CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f
+ CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f));
+ CFont::SetCentreOn();
+ CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f
+ CFont::SetJustifyOff();
+ CFont::SetColor(CRGBA(255, 255, 255, 255));
+ CFont::SetDropColor(CRGBA(32, 32, 32, 255));
+ CFont::SetDropShadowPosition(3);
+ CFont::SetPropOn();
+ CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(130.0f), TheText.Get(msg));
+ CFont::DrawFonts();
+
+ DoRWStuffEndOfFrame();
+}
+
bool
CGame::InitialiseOnceBeforeRW(void)
{
@@ -112,6 +149,15 @@ CGame::InitialiseOnceBeforeRW(void)
return true;
}
+#ifndef LIBRW
+#ifdef PS2_MATFX
+void ReplaceMatFxCallback();
+#endif // PS2_MATFX
+#ifdef PS2_ALPHA_TEST
+void ReplaceAtomicPipeCallback();
+#endif // PS2_ALPHA_TEST
+#endif // !LIBRW
+
bool
CGame::InitialiseRenderWare(void)
{
@@ -162,7 +208,14 @@ CGame::InitialiseRenderWare(void)
#else
rw::MatFX::modulateEnvMap = false;
#endif
-#endif
+#else
+#ifdef PS2_MATFX
+ ReplaceMatFxCallback();
+#endif // PS2_MATFX
+#ifdef PS2_ALPHA_TEST
+ ReplaceAtomicPipeCallback();
+#endif // PS2_ALPHA_TEST
+#endif // LIBRW
CFont::Initialise();
CHud::Initialise();
@@ -234,6 +287,9 @@ bool CGame::InitialiseOnceAfterRW(void)
DMAudio.SetMusicFadeVol(127);
CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile);
+#ifdef CUSTOM_FRONTEND_OPTIONS
+ CustomFrontendOptionsPopulate();
+#endif
return true;
}
@@ -272,6 +328,9 @@ bool CGame::Initialise(const char* datFile)
CWeather::Init();
CCullZones::Init();
CCollision::Init();
+#ifdef PS2_MENU
+ TheText.Load();
+#endif
CTheZones::Init();
CUserDisplay::Init();
CMessages::Init();
@@ -280,6 +339,11 @@ bool CGame::Initialise(const char* datFile)
CRestart::Initialise();
CWorld::Initialise();
CParticle::Initialise();
+#ifdef PS2
+ gStartX = -180.0f;
+ gStartY = 180.0f;
+ gStartZ = 14.0f;
+#endif
CAnimManager::Initialise();
CCutsceneMgr::Initialise();
CCarCtrl::Init();
@@ -309,9 +373,9 @@ bool CGame::Initialise(const char* datFile)
CStreaming::Init();
CStreaming::LoadInitialVehicles();
CStreaming::LoadInitialPeds();
- CStreaming::RequestBigBuildings(LEVEL_NONE);
+ CStreaming::RequestBigBuildings(LEVEL_GENERIC);
CStreaming::LoadAllRequestedModels(false);
- printf("Streaming uses %dK of its memory", CStreaming::ms_memoryUsed / 1024);
+ printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
CAnimManager::LoadAnimFiles();
CPed::Initialise();
@@ -363,10 +427,16 @@ bool CGame::Initialise(const char* datFile)
CCredits::Init();
CRecordDataForChase::Init();
CReplay::Init();
- LoadingScreen("Loading the Game", "Start script", nil);
+#ifdef PS2_MENU
+ if ( !TheMemoryCard.m_bWantToLoad )
+ {
+#endif
CTheScripts::StartTestScript();
CTheScripts::Process();
TheCamera.Process();
+#ifdef PS2_MENU
+ }
+#endif
LoadingScreen("Loading the Game", "Load scene", nil);
CModelInfo::RemoveColModelsFromOtherLevels(currLevel);
CCollision::ms_collisionInMemory = currLevel;
@@ -431,8 +501,15 @@ bool CGame::ShutDown(void)
void CGame::ReInitGameObjectVariables(void)
{
CGameLogic::InitAtStartOfGame();
- TheCamera.CCamera::Init();
+#ifdef PS2_MENU
+ if ( !TheMemoryCard.m_bWantToLoad )
+ {
+#endif
+ TheCamera.Init();
TheCamera.SetRwCamera(Scene.camera);
+#ifdef PS2_MENU
+ }
+#endif
CDebug::DebugInitTextBuffer();
CWeather::Init();
CUserDisplay::Init();
@@ -441,11 +518,16 @@ void CGame::ReInitGameObjectVariables(void)
CWorld::bDoingCarCollisions = false;
CHud::ReInitialise();
CRadar::Initialise();
+#ifdef PS2
+ gStartX = -180.0f;
+ gStartY = 180.0f;
+ gStartZ = 14.0f;
+#endif
CCarCtrl::ReInit();
CTimeCycle::Initialise();
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
- CStreaming::RequestBigBuildings(LEVEL_NONE);
+ CStreaming::RequestBigBuildings(LEVEL_GENERIC);
CStreaming::LoadAllRequestedModels(false);
CPed::Initialise();
CEventList::Initialise();
@@ -456,6 +538,10 @@ void CGame::ReInitGameObjectVariables(void)
CWorld::Players[i].Clear();
CWorld::PlayerInFocus = 0;
+#ifdef PS2
+ CWeaponEffects::Init();
+ CSkidmarks::Init();
+#endif
CAntennas::Init();
CGlass::Init();
gPhoneInfo.Initialise();
@@ -471,12 +557,20 @@ void CGame::ReInitGameObjectVariables(void)
CPickups::Init();
CPacManPickups::Init();
CGarages::Init();
+#ifdef PS2
+ CClouds::Init();
+ CRemote::Init();
+#endif
CSpecialFX::Init();
CWaterCannons::Init();
CParticle::ReloadConfig();
CCullZones::ResolveVisibilities();
+#ifdef PS2_MENU
+ if ( !TheMemoryCard.m_bWantToLoad )
+#else
if ( !FrontEndMenuManager.m_bWantToLoad )
+#endif
{
CCranes::InitCranes();
CTheScripts::StartTestScript();
@@ -533,8 +627,10 @@ void CGame::ShutDownForRestart(void)
CRadar::RemoveRadarSections();
FrontEndMenuManager.UnloadTextures();
CParticleObject::RemoveAllParticleObjects();
+#ifndef PS2
CPedType::Shutdown();
CSpecialFX::Shutdown();
+#endif
TidyUpMemory(true, false);
}
@@ -545,19 +641,102 @@ void CGame::InitialiseWhenRestarting(void)
CTimer::Initialise();
CSprite2d::SetRecipNearClip();
+
+#ifdef PS2_MENU
+ if ( TheMemoryCard.b_FoundRecentSavedGameWantToLoad == true || TheMemoryCard.m_bWantToLoad == false )
+ {
+ if ( TheMemoryCard.m_bWantToLoad == true )
+ MessageScreen("MCLOAD"); // Loading Data. Please do not remove the Memory Card (PS2) in MEMORY CARD slot 1, reset or switch off the console.
+ else
+ MessageScreen("RESTART"); // Starting new game
+ }
+#endif
+#ifdef PS2_MENU
+ TheMemoryCard.b_FoundRecentSavedGameWantToLoad = false;
+#else
b_FoundRecentSavedGameWantToLoad = false;
+#endif
TheCamera.Init();
+#ifdef PS2_MENU
+ if ( TheMemoryCard.m_bWantToLoad == true )
+ {
+ TheMemoryCard.RestoreForStartLoad();
+ CStreaming::LoadScene(TheCamera.GetPosition());
+ }
+#else
if ( FrontEndMenuManager.m_bWantToLoad == true )
{
RestoreForStartLoad();
CStreaming::LoadScene(TheCamera.GetPosition());
}
+#endif
ReInitGameObjectVariables();
+#ifdef PS2_MENU
+ if ( TheMemoryCard.m_bWantToLoad == true )
+ {
+ if ( TheMemoryCard.LoadSavedGame() == CMemoryCard::RES_SUCCESS )
+ {
+ for ( int32 i = 0; i < 35; i++ )
+ {
+ MessageScreen("FESZ_LS"); // Load Successful.
+ }
+
+ DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds());
+ CTrain::InitTrains();
+ CPlane::InitPlanes();
+ }
+ else
+ {
+ for ( int32 i = 0; i < 50; i++ )
+ {
+ DoRWStuffStartOfFrame(50, 50, 50, 0, 0, 0, 255);
+
+ CSprite2d::InitPerFrame();
+ CFont::InitPerFrame();
+ DefinedState();
+
+ CSprite2d *splash = LoadSplash(NULL);
+ splash->Draw(rect, color, color, color, color);
+ splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_SCALE_X(620.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192));
+
+ //CFont::SetFontStyle(?);
+ CFont::SetBackgroundOff();
+ CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f
+ CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f));
+ CFont::SetCentreOn();
+ CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f
+ CFont::SetJustifyOff();
+ CFont::SetColor(CRGBA(255, 255, 255, 255));
+ CFont::SetBackGroundOnlyTextOff();
+ CFont::SetDropColor(CRGBA(32, 32, 32, 255));
+ CFont::SetDropShadowPosition(3);
+ CFont::SetPropOn();
+ CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(130.0f), TheText.Get("MC_LDFL")); // Load Failed!
+ CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(170.0f), TheText.Get("FES_NOC")); // No Memory Card (PS2) in MEMORY CARD slot 1.
+ CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(240.0f), TheText.Get("MC_NWRE")); // Now Restarting Game.
+ CFont::DrawFonts();
+
+ DoRWStuffEndOfFrame();
+ }
+
+ ShutDownForRestart();
+ CTimer::Stop();
+ CTimer::Initialise();
+ TheMemoryCard.m_bWantToLoad = false;
+ ReInitGameObjectVariables();
+ currLevel = LEVEL_INDUSTRIAL;
+ CCollision::SortOutCollisionAfterLoad();
+
+ FrontEndMenuManager.SetSoundLevelsForMusicMenu();
+ FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame();
+ }
+ }
+#else
if ( FrontEndMenuManager.m_bWantToLoad == true )
{
if ( GenericLoad() == true )
@@ -583,6 +762,7 @@ void CGame::InitialiseWhenRestarting(void)
CCollision::SortOutCollisionAfterLoad();
}
}
+#endif
CTimer::Update();
@@ -596,8 +776,8 @@ void CGame::Process(void)
ProcessTidyUpMemory();
#endif
TheCamera.SetMotionBlurAlpha(0);
- if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL)
- TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE);
+ if (TheCamera.m_BlurType == MOTION_BLUR_NONE || TheCamera.m_BlurType == MOTION_BLUR_SNIPER || TheCamera.m_BlurType == MOTION_BLUR_LIGHT_SCENE)
+ TheCamera.SetMotionBlur(0, 0, 0, 0, MOTION_BLUR_NONE);
#ifdef DEBUGMENU
DebugMenuProcess();
#endif
@@ -666,6 +846,9 @@ void CGame::Process(void)
CCarCtrl::RemoveDistantCars();
}
}
+#ifdef PS2
+ CMemCheck::DoTest();
+#endif
}
void CGame::DrasticTidyUpMemory(bool)