metaforce/Runtime/MP1/main.cpp

224 lines
5.5 KiB
C++
Raw Normal View History

2015-08-31 03:44:42 +00:00
#if _WIN32
2015-10-12 04:41:28 +00:00
#ifndef NOMINMAX
#define NOMINMAX
#endif
2015-08-31 03:44:42 +00:00
#include <objbase.h>
#endif
#include <clocale>
2015-08-17 05:26:58 +00:00
#include <memory>
2015-08-18 22:51:54 +00:00
#include <boo/boo.hpp>
#include <boo/graphicsdev/GL.hpp>
2015-08-17 05:26:58 +00:00
#include "CBasics.hpp"
#include "CMemoryCardSys.hpp"
2015-08-17 20:33:58 +00:00
#include "CResFactory.hpp"
#include "CSimplePool.hpp"
2015-08-17 23:46:41 +00:00
#include "Character/CAssetFactory.hpp"
#include "CAi.hpp"
#include "CGameState.hpp"
#include "CInGameTweakManager.hpp"
2015-08-18 05:54:43 +00:00
#include "Particle/CElementGen.hpp"
#include "Character/CAnimData.hpp"
#include "Particle/CDecalManager.hpp"
#include "Graphics/CBooRenderer.hpp"
#include "Audio/CAudioSys.hpp"
#include "Input/CInputGenerator.hpp"
#include "GuiSys/CGuiSys.hpp"
#include "CIOWinManager.hpp"
#include "GuiSys/CSplashScreen.hpp"
#include "CMainFlow.hpp"
#include "GuiSys/CConsoleOutputWindow.hpp"
#include "Audio/CAudioStateWin.hpp"
#include "GameGlobalObjects.hpp"
2015-08-22 01:58:41 +00:00
#include "CArchitectureQueue.hpp"
2015-08-27 00:23:46 +00:00
#include "CMain.hpp"
#include "CTimeProvider.hpp"
2015-08-17 05:26:58 +00:00
2015-08-29 01:30:47 +00:00
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp"
2015-08-29 01:30:47 +00:00
2016-02-13 09:02:47 +00:00
namespace pshag
2015-08-17 05:26:58 +00:00
{
2015-08-18 05:54:43 +00:00
CMemoryCardSys* g_MemoryCardSys = nullptr;
CResFactory* g_ResFactory = nullptr;
2015-08-18 05:54:43 +00:00
CSimplePool* g_SimplePool = nullptr;
CCharacterFactoryBuilder* g_CharFactoryBuilder = nullptr;
CAiFuncMap* g_AiFuncMap = nullptr;
CGameState* g_GameState = nullptr;
2015-08-27 00:23:46 +00:00
CInGameTweakManagerBase* g_TweakManager = nullptr;
2015-08-18 05:54:43 +00:00
CBooRenderer* g_Renderer = nullptr;
namespace MP1
{
2015-08-27 00:23:46 +00:00
class CMain* g_main = nullptr;
2015-08-18 05:54:43 +00:00
class CGameGlobalObjects
{
2016-02-16 05:50:41 +00:00
CMemoryCardSys x0_memoryCardSys;
CResFactory x20_resFactory;
CSimplePool x114_simplePool;
CCharacterFactoryBuilder x14c_charFactoryBuilder;
CAiFuncMap x188_aiFuncMap;
CGameState x1a8_gameState;
CInGameTweakManager x1c0_tweakManager;
2015-08-18 22:51:54 +00:00
std::unique_ptr<CBooRenderer> m_renderer;
2015-08-18 05:54:43 +00:00
void AddPaksAndFactories()
{
}
void LoadStringTable()
{
}
2015-08-18 22:51:54 +00:00
static CBooRenderer*
2015-08-28 00:11:31 +00:00
AllocateRenderer(IObjectStore& store,
2015-08-18 22:51:54 +00:00
CMemorySys& memSys, CResFactory& resFactory)
2015-08-18 05:54:43 +00:00
{
2015-08-28 00:11:31 +00:00
g_Renderer = new CBooRenderer(store, memSys, resFactory);
2015-08-18 22:51:54 +00:00
return g_Renderer;
2015-08-18 05:54:43 +00:00
}
2015-08-17 23:46:41 +00:00
2015-08-17 05:26:58 +00:00
public:
2015-08-18 05:54:43 +00:00
CGameGlobalObjects()
2016-02-16 05:50:41 +00:00
: x114_simplePool(x20_resFactory)
2015-08-18 05:54:43 +00:00
{
2016-02-16 05:50:41 +00:00
g_MemoryCardSys = &x0_memoryCardSys;
g_ResFactory = &x20_resFactory;
g_SimplePool = &x114_simplePool;
g_CharFactoryBuilder = &x14c_charFactoryBuilder;
g_AiFuncMap = &x188_aiFuncMap;
g_GameState = &x1a8_gameState;
g_TweakManager = &x1c0_tweakManager;
2015-08-18 05:54:43 +00:00
}
2015-08-28 00:11:31 +00:00
void PostInitialize(CMemorySys& memSys)
2015-08-18 05:54:43 +00:00
{
AddPaksAndFactories();
LoadStringTable();
2016-02-16 05:50:41 +00:00
m_renderer.reset(AllocateRenderer(x114_simplePool, memSys, x20_resFactory));
2015-08-18 05:54:43 +00:00
}
};
class CGameArchitectureSupport
{
2015-08-20 02:52:07 +00:00
CArchitectureQueue m_archQueue;
2015-08-18 22:51:54 +00:00
CAudioSys m_audioSys;
CInputGenerator m_inputGenerator;
CGuiSys m_guiSys;
CIOWinManager m_ioWinManager;
CSplashScreen m_splashScreen;
CMainFlow m_mainFlow;
CConsoleOutputWindow m_consoleWindow;
CAudioStateWin m_audioStateWin;
2015-08-18 05:54:43 +00:00
public:
2015-08-28 00:11:31 +00:00
CGameArchitectureSupport()
2015-08-29 01:30:47 +00:00
: m_audioSys(0,0,0,0,0),
m_inputGenerator(0.0f /*g_tweakPlayer->GetLeftLogicalThreshold()*/,
0.0f /*g_tweakPlayer->GetRightLogicalThreshold()*/)
2015-08-17 20:33:58 +00:00
{
m_inputGenerator.startScanning();
2015-08-17 20:33:58 +00:00
}
2015-08-20 02:52:07 +00:00
bool Update()
{
bool finished = false;
return finished;
}
2015-08-17 05:26:58 +00:00
};
2015-08-27 00:23:46 +00:00
CMain::CMain()
2015-08-28 00:11:31 +00:00
: x6c_memSys(CMemorySys::GetGameAllocator())
2015-08-17 05:26:58 +00:00
{
2015-08-27 00:23:46 +00:00
g_main = this;
2015-11-21 01:16:07 +00:00
xe4_gameplayResult = EGameplayResult::Playing;
2015-08-27 00:23:46 +00:00
}
void CMain::RegisterResourceTweaks()
{
}
void CMain::ResetGameState()
{
}
2015-08-27 00:23:46 +00:00
void CMain::InitializeSubsystems()
{
CElementGen::Initialize();
CAnimData::InitializeCache();
CDecalManager::Initialize();
}
void CMain::AddWorldPaks()
{
#if 0
u32 i = 0;
while (i <= 255)
{
std::string pakName = CBasics::Stringize("%s%i.pak", g_tweakGame->GetWorldPrefix().c_str(), i);
if (CDvdFile::FileExists(pakName.c_str()))
g_ResFactory->GetLoader().AddPakFile(pakName, false);
i++;
}
#endif
2015-08-27 00:23:46 +00:00
}
2015-08-27 00:23:46 +00:00
void CMain::FillInAssetIDs()
{
}
void CMain::LoadAudio()
{
}
int CMain::appMain(boo::IApplication* app)
2015-08-27 00:23:46 +00:00
{
Zeus::detectCPU();
2015-11-10 20:12:43 +00:00
mainWindow = app->newWindow(_S("Metroid Prime 1 Reimplementation vZygote"));
mainWindow->showWindow();
2015-08-27 00:23:46 +00:00
TOneStatic<CGameGlobalObjects> globalObjs;
InitializeSubsystems();
2015-08-28 00:11:31 +00:00
globalObjs->PostInitialize(x6c_memSys);
2015-08-27 00:23:46 +00:00
x70_tweaks.RegisterTweaks();
AddWorldPaks();
g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs();
2015-08-28 00:11:31 +00:00
TOneStatic<CGameArchitectureSupport> archSupport;
boo::IGraphicsCommandQueue* gfxQ = mainWindow->getCommandQueue();
float rgba[4] = { 0.5f, 0.5f, 0.5f, 1.0f};
gfxQ->setClearColor(rgba);
float time = 0.0f;
int frame = 0;
CTimeProvider test(time);
2015-09-17 19:50:43 +00:00
while (!xe8_b24_finished)
2015-08-17 05:26:58 +00:00
{
mainWindow->waitForRetrace();
2015-09-17 19:50:43 +00:00
xe8_b24_finished = archSupport->Update();
gfxQ->clearTarget();
gfxQ->execute();
time = (frame++) / 60.f;
//fprintf(stderr, "%f\n", test.x0_currentTime);
2015-08-17 05:26:58 +00:00
}
2015-08-27 00:23:46 +00:00
return 0;
}
2015-08-17 05:26:58 +00:00
}
}
2015-08-31 03:44:42 +00:00
#ifdef _WIN32
int wmain(int argc, const wchar_t* argv[])
#else
2015-08-17 05:26:58 +00:00
int main(int argc, const char* argv[])
2015-08-31 03:44:42 +00:00
#endif
2015-08-17 05:26:58 +00:00
{
2015-08-31 03:44:42 +00:00
#if _WIN32
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
#else
std::setlocale(LC_ALL, "en-US.UTF-8");
#endif
LogVisor::RegisterConsoleLogger();
2016-02-13 09:02:47 +00:00
pshag::TOneStatic<pshag::MP1::CMain> main;
2015-11-21 01:16:07 +00:00
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, *main,
2015-08-31 03:44:42 +00:00
_S("mp1"), _S("MP1"), argc, argv);
return ret;
2015-08-17 05:26:58 +00:00
}