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>
|
2015-11-02 18:45:39 +00:00
|
|
|
#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"
|
2016-04-03 05:25:34 +00:00
|
|
|
#include "Particle/CGenDescription.hpp"
|
2015-08-18 05:54:43 +00:00
|
|
|
#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"
|
2016-03-21 05:02:56 +00:00
|
|
|
#include "GuiSys/CTextParser.hpp"
|
2015-08-18 05:54:43 +00:00
|
|
|
#include "Audio/CAudioStateWin.hpp"
|
|
|
|
#include "GameGlobalObjects.hpp"
|
2015-08-22 01:58:41 +00:00
|
|
|
#include "CArchitectureQueue.hpp"
|
2016-03-04 05:28:20 +00:00
|
|
|
#include "MP1.hpp"
|
2015-11-09 03:43:11 +00:00
|
|
|
#include "CTimeProvider.hpp"
|
2016-03-21 22:01:19 +00:00
|
|
|
#include "GuiSys/CTextExecuteBuffer.hpp"
|
2015-08-17 05:26:58 +00:00
|
|
|
|
2015-08-29 01:30:47 +00:00
|
|
|
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp"
|
2015-11-02 18:45:39 +00:00
|
|
|
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp"
|
2015-08-29 01:30:47 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-17 05:26:58 +00:00
|
|
|
{
|
2015-08-18 05:54:43 +00:00
|
|
|
CMemoryCardSys* g_MemoryCardSys = nullptr;
|
2015-11-02 18:45:39 +00:00
|
|
|
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;
|
|
|
|
|
2015-08-17 22:05:00 +00:00
|
|
|
namespace MP1
|
|
|
|
{
|
2015-08-27 00:23:46 +00:00
|
|
|
class CMain* g_main = nullptr;
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2015-08-18 05:54:43 +00:00
|
|
|
class CGameGlobalObjects
|
2015-08-17 22:05:00 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-02-20 06:45:36 +00:00
|
|
|
class CGameArchitectureSupport : public boo::IWindowCallback
|
2015-08-18 05:54:43 +00:00
|
|
|
{
|
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;
|
2016-02-20 10:26:43 +00:00
|
|
|
boo::SWindowRect m_windowRect;
|
|
|
|
bool m_rectIsDirty;
|
2016-02-20 06:45:36 +00:00
|
|
|
|
|
|
|
void mouseDown(const boo::SWindowCoord &coord, boo::EMouseButton button, boo::EModifierKey mods)
|
|
|
|
{ m_inputGenerator.mouseDown(coord, button, mods); }
|
|
|
|
void mouseUp(const boo::SWindowCoord &coord, boo::EMouseButton button, boo::EModifierKey mods)
|
|
|
|
{ m_inputGenerator.mouseUp(coord, button, mods); }
|
|
|
|
void mouseMove(const boo::SWindowCoord &coord)
|
|
|
|
{ m_inputGenerator.mouseMove(coord); }
|
|
|
|
void scroll(const boo::SWindowCoord &coord, const boo::SScrollDelta &scroll)
|
|
|
|
{ m_inputGenerator.scroll(coord, scroll); }
|
|
|
|
void charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
|
|
|
|
{ m_inputGenerator.charKeyDown(charCode, mods, isRepeat); }
|
|
|
|
void charKeyUp(unsigned long charCode, boo::EModifierKey mods)
|
|
|
|
{ m_inputGenerator.charKeyUp(charCode, mods); }
|
|
|
|
void specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
|
|
|
|
{ m_inputGenerator.specialKeyDown(key, mods, isRepeat); }
|
|
|
|
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods)
|
|
|
|
{ m_inputGenerator.specialKeyUp(key, mods); }
|
|
|
|
void modKeyDown(boo::EModifierKey mod, bool isRepeat)
|
|
|
|
{ m_inputGenerator.modKeyDown(mod, isRepeat);}
|
|
|
|
void modKeyUp(boo::EModifierKey mod)
|
|
|
|
{ m_inputGenerator.modKeyUp(mod); }
|
|
|
|
|
|
|
|
void destroyed() { m_archQueue.Push(std::move(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport))); }
|
|
|
|
|
2016-02-20 10:26:43 +00:00
|
|
|
void resized(const boo::SWindowRect &rect)
|
|
|
|
{
|
|
|
|
m_windowRect = rect;
|
|
|
|
m_rectIsDirty = true;
|
|
|
|
}
|
|
|
|
|
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),
|
2015-10-28 04:45:02 +00:00
|
|
|
m_inputGenerator(0.0f /*g_tweakPlayer->GetLeftLogicalThreshold()*/,
|
2016-03-11 00:23:16 +00:00
|
|
|
0.0f /*g_tweakPlayer->GetRightLogicalThreshold()*/),
|
|
|
|
m_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero)
|
2015-08-17 20:33:58 +00:00
|
|
|
{
|
2016-03-19 03:58:01 +00:00
|
|
|
g_GuiSys = &m_guiSys;
|
2015-11-09 03:43:11 +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;
|
2016-02-20 06:45:36 +00:00
|
|
|
m_inputGenerator.Update(1.0 / 60.0, m_archQueue);
|
|
|
|
|
|
|
|
while(m_archQueue)
|
|
|
|
{
|
|
|
|
CArchitectureMessage msg = m_archQueue.Pop();
|
|
|
|
if (msg.GetTarget() == EArchMsgTarget::ArchitectureSupport)
|
|
|
|
{
|
|
|
|
if (msg.GetType() == EArchMsgType::ApplicationExit)
|
|
|
|
finished = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg.GetTarget() == EArchMsgTarget::Game && msg.GetType() == EArchMsgType::UserInput)
|
|
|
|
{
|
|
|
|
const CArchMsgParmUserInput* input = msg.GetParm<CArchMsgParmUserInput>();
|
|
|
|
if (input->x4_parm.DStart())
|
|
|
|
m_archQueue.Push(std::move(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport)));
|
|
|
|
}
|
|
|
|
}
|
2015-08-20 02:52:07 +00:00
|
|
|
return finished;
|
|
|
|
}
|
2016-02-20 10:26:43 +00:00
|
|
|
|
|
|
|
bool isRectDirty() { return m_rectIsDirty; }
|
|
|
|
const boo::SWindowRect& getWindowRect()
|
|
|
|
{
|
|
|
|
m_rectIsDirty = false;
|
|
|
|
return m_windowRect;
|
|
|
|
}
|
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-11-02 18:45:39 +00:00
|
|
|
|
2015-08-27 00:23:46 +00:00
|
|
|
void CMain::InitializeSubsystems()
|
|
|
|
{
|
|
|
|
CElementGen::Initialize();
|
|
|
|
CAnimData::InitializeCache();
|
|
|
|
CDecalManager::Initialize();
|
|
|
|
}
|
|
|
|
void CMain::AddWorldPaks()
|
|
|
|
{
|
2015-11-02 18:45:39 +00:00
|
|
|
#if 0
|
|
|
|
u32 i = 0;
|
|
|
|
while (i <= 255)
|
|
|
|
{
|
|
|
|
std::string pakName = CBasics::Stringize("%s%i.pak", g_tweakGame->GetWorldPrefix().c_str(), i);
|
2015-11-09 03:43:11 +00:00
|
|
|
if (CDvdFile::FileExists(pakName.c_str()))
|
|
|
|
g_ResFactory->GetLoader().AddPakFile(pakName, false);
|
2015-11-02 18:45:39 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
#endif
|
2015-08-27 00:23:46 +00:00
|
|
|
}
|
2015-11-02 18:45:39 +00:00
|
|
|
|
2015-08-27 00:23:46 +00:00
|
|
|
void CMain::FillInAssetIDs()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void CMain::LoadAudio()
|
|
|
|
{
|
|
|
|
}
|
2015-11-02 18:45:39 +00:00
|
|
|
|
|
|
|
int CMain::appMain(boo::IApplication* app)
|
2015-08-27 00:23:46 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
zeus::detectCPU();
|
2016-02-24 03:20:07 +00:00
|
|
|
mainWindow = app->newWindow(_S("Metroid Prime 1 Reimplementation vZygote"), 1);
|
2015-11-02 18:45:39 +00:00
|
|
|
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;
|
2016-02-20 06:45:36 +00:00
|
|
|
mainWindow->setCallback(archSupport.GetAllocSpace());
|
2015-11-02 18:45:39 +00:00
|
|
|
|
|
|
|
boo::IGraphicsCommandQueue* gfxQ = mainWindow->getCommandQueue();
|
2016-02-20 10:26:43 +00:00
|
|
|
boo::SWindowRect windowRect = mainWindow->getWindowFrame();
|
2016-03-30 19:16:01 +00:00
|
|
|
boo::ITextureR* renderTex;
|
|
|
|
boo::GraphicsDataToken data = mainWindow->getMainContextDataFactory()->commitTransaction(
|
|
|
|
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
|
|
|
{
|
|
|
|
renderTex = ctx.newRenderTexture(windowRect.size[0], windowRect.size[1], true, true);
|
|
|
|
return true;
|
|
|
|
});
|
2016-02-20 05:49:47 +00:00
|
|
|
float rgba[4] = { 0.2f, 0.2f, 0.2f, 1.0f};
|
2015-11-02 18:45:39 +00:00
|
|
|
gfxQ->setClearColor(rgba);
|
|
|
|
|
2015-09-17 19:50:43 +00:00
|
|
|
while (!xe8_b24_finished)
|
2015-08-17 05:26:58 +00:00
|
|
|
{
|
2015-09-17 19:50:43 +00:00
|
|
|
xe8_b24_finished = archSupport->Update();
|
2015-11-02 18:45:39 +00:00
|
|
|
|
2016-02-20 10:26:43 +00:00
|
|
|
if (archSupport->isRectDirty())
|
|
|
|
{
|
|
|
|
const boo::SWindowRect& windowRect = archSupport->getWindowRect();
|
|
|
|
gfxQ->resizeRenderTexture(renderTex,
|
|
|
|
windowRect.size[0],
|
|
|
|
windowRect.size[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxQ->setRenderTarget(renderTex);
|
|
|
|
gfxQ->clearTarget();
|
|
|
|
gfxQ->resolveDisplay(renderTex);
|
2015-11-02 18:45:39 +00:00
|
|
|
gfxQ->execute();
|
2016-02-20 12:40:58 +00:00
|
|
|
mainWindow->waitForRetrace();
|
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-17 22:05:00 +00:00
|
|
|
}
|
|
|
|
}
|