From 746eb46026bf76608ef0bec30324fd15c9519d1a Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 19 Aug 2015 16:52:07 -1000 Subject: [PATCH] various implementations --- CMakeLists.txt | 4 +- MathLib | 2 +- Runtime/Audio/CAudioStateWin.hpp | 5 + Runtime/Audio/CAudioSys.hpp | 13 ++ Runtime/Audio/CMakeLists.txt | 4 +- .../{CObjectList.cpp => Audio/CSfxHandle.cpp} | 0 Runtime/Audio/CSfxHandle.hpp | 13 ++ Runtime/Audio/CSfxManager.cpp | 0 Runtime/Audio/CSfxManager.hpp | 133 ++++++++++++++++ Runtime/CArchitectureMessage.hpp | 142 ++++++++++++++++++ Runtime/CArchitectureQueue.cpp | 0 Runtime/CArchitectureQueue.hpp | 30 ++++ Runtime/CGameOptions.hpp | 7 + Runtime/CGameState.cpp | 8 + Runtime/CGameState.hpp | 12 +- Runtime/CIOWin.hpp | 12 ++ Runtime/CIOWinManager.cpp | 20 +++ Runtime/CIOWinManager.hpp | 14 ++ Runtime/CMFGame.cpp | 0 Runtime/CMFGame.hpp | 19 +++ Runtime/CMainFlow.cpp | 27 ++++ Runtime/CMainFlow.hpp | 44 +++++- Runtime/CMakeLists.txt | 8 +- Runtime/CPlayerState.cpp | 6 + Runtime/CPlayerState.hpp | 11 +- Runtime/CStaticInterference.cpp | 6 - Runtime/CStaticInterference.hpp | 62 ++++++++ Runtime/CWorldTransManager.cpp | 8 + Runtime/CWorldTransManager.hpp | 11 ++ Runtime/Input/CFinalInput.cpp | 0 Runtime/Input/CFinalInput.hpp | 13 ++ Runtime/Input/CMakeLists.txt | 3 +- Runtime/MP1/main.cpp | 12 +- Runtime/RetroTypes.hpp | 17 ++- 34 files changed, 643 insertions(+), 23 deletions(-) rename Runtime/{CObjectList.cpp => Audio/CSfxHandle.cpp} (100%) create mode 100644 Runtime/Audio/CSfxHandle.hpp create mode 100644 Runtime/Audio/CSfxManager.cpp create mode 100644 Runtime/Audio/CSfxManager.hpp create mode 100644 Runtime/CArchitectureMessage.hpp create mode 100644 Runtime/CArchitectureQueue.cpp create mode 100644 Runtime/CArchitectureQueue.hpp create mode 100644 Runtime/CMFGame.cpp create mode 100644 Runtime/CMFGame.hpp delete mode 100644 Runtime/CStaticInterference.cpp create mode 100644 Runtime/Input/CFinalInput.cpp create mode 100644 Runtime/Input/CFinalInput.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2773aae39..a61f2bcd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,8 +30,10 @@ set(HECL_DATASPEC_PUSHES add_subdirectory(hecl) add_subdirectory(NODLib) set(NODLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/NODLib/include) +add_subdirectory(MathLib) +set(MATHLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/MathLib/include) include_directories(${ATHENA_INCLUDE_DIR} ${LOG_VISOR_INCLUDE_DIR} ${HECL_INCLUDE_DIR} - ${NODLIB_INCLUDE_DIR} + ${NODLIB_INCLUDE_DIR} ${MATHLIB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(DataSpec) add_subdirectory(Runtime) diff --git a/MathLib b/MathLib index 9d657895c..2e3512b80 160000 --- a/MathLib +++ b/MathLib @@ -1 +1 @@ -Subproject commit 9d657895cb143fd37ab66658d2af8b5d3198257d +Subproject commit 2e3512b80098eb0c3facd4fd3ab6433fe424c4f7 diff --git a/Runtime/Audio/CAudioStateWin.hpp b/Runtime/Audio/CAudioStateWin.hpp index 7b3990cf4..c9fb4de7c 100644 --- a/Runtime/Audio/CAudioStateWin.hpp +++ b/Runtime/Audio/CAudioStateWin.hpp @@ -8,6 +8,11 @@ namespace Retro class CAudioStateWin : public CIOWin { +public: + CAudioStateWin() : CIOWin("CAudioStateWin") {} + virtual bool OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) + { + } }; } diff --git a/Runtime/Audio/CAudioSys.hpp b/Runtime/Audio/CAudioSys.hpp index ab677d452..560f7b126 100644 --- a/Runtime/Audio/CAudioSys.hpp +++ b/Runtime/Audio/CAudioSys.hpp @@ -2,6 +2,7 @@ #define __RETRO_CAUDIOSYS_HPP__ #include "../GCNTypes.hpp" +#include "CVector3f.hpp" namespace Retro { @@ -9,6 +10,18 @@ namespace Retro class CAudioSys { public: + struct C3DEmitterParmData + { + CVector3f pos; + CVector3f dir; + float maxDist; + float distComp; + u32 flags; + u16 sfxId; + u8 maxVol; + u8 minVol; + u8 extra[2]; + }; CAudioSys(u8,u8,u8,u8,u32) { } diff --git a/Runtime/Audio/CMakeLists.txt b/Runtime/Audio/CMakeLists.txt index 4574ee960..655a29dd8 100644 --- a/Runtime/Audio/CMakeLists.txt +++ b/Runtime/Audio/CMakeLists.txt @@ -1,3 +1,5 @@ add_library(RuntimeCommonAudio CAudioSys.hpp CAudioSys.cpp - CAudioStateWin.hpp CAudioStateWin.cpp) + CAudioStateWin.hpp CAudioStateWin.cpp + CSfxManager.hpp CSfxManager.cpp + CSfxHandle.hpp CSfxHandle.cpp) diff --git a/Runtime/CObjectList.cpp b/Runtime/Audio/CSfxHandle.cpp similarity index 100% rename from Runtime/CObjectList.cpp rename to Runtime/Audio/CSfxHandle.cpp diff --git a/Runtime/Audio/CSfxHandle.hpp b/Runtime/Audio/CSfxHandle.hpp new file mode 100644 index 000000000..4cc87c1fe --- /dev/null +++ b/Runtime/Audio/CSfxHandle.hpp @@ -0,0 +1,13 @@ +#ifndef __RETRO_CSFXHANDLE_HPP__ +#define __RETRO_CSFXHANDLE_HPP__ + +namespace Retro +{ + +class CSfxHandle +{ +}; + +} + +#endif // __RETRO_CSFXHANDLE_HPP__ diff --git a/Runtime/Audio/CSfxManager.cpp b/Runtime/Audio/CSfxManager.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/Runtime/Audio/CSfxManager.hpp b/Runtime/Audio/CSfxManager.hpp new file mode 100644 index 000000000..17a148c3f --- /dev/null +++ b/Runtime/Audio/CSfxManager.hpp @@ -0,0 +1,133 @@ +#ifndef __RETRO_CSFXMANAGER_HPP__ +#define __RETRO_CSFXMANAGER_HPP__ + +#include +#include "../RetroTypes.hpp" +#include "CSfxHandle.hpp" +#include "CVector3f.hpp" +#include "CAudioSys.hpp" + +namespace Retro +{ + +class CSfxManager +{ + enum ESfxChannels + { + }; + + enum ESfxAudibility + { + Aud0, + Aud1, + Aud2, + Aud3 + }; + + class CSfxChannel + { + }; + + class CBaseSfxWrapper + { + s16 m_rank; + s16 m_prio; + CSfxHandle m_handle; + TAreaId m_area; + bool m_useAcoustics:1; + bool m_available:1; + bool m_inArea:1; + bool m_looped:1; + bool m_playing:1; + bool m_active:1; + public: + virtual ~CBaseSfxWrapper() {} + virtual void SetActive(bool v) {m_active = v;} + virtual void SetPlaying(bool v) {m_playing = v;} + virtual void SetRank(short v) {m_rank = v;} + virtual void SetInArea(bool v) {m_inArea = v;} + virtual bool IsLooped() const {return m_looped;} + virtual bool IsPlaying() const {return m_playing;} + virtual bool IsActive() const {return m_active;} + virtual bool IsInArea() const {return m_inArea;} + virtual bool UseAcoustics() const {return m_useAcoustics;} + virtual s16 GetRank() const {return m_rank;} + virtual s16 GetPriority() const {return m_prio;} + virtual TAreaId GetArea() const {return m_area;} + virtual CSfxHandle GetSfxHandle() const {return m_handle;} + virtual void Play()=0; + virtual void Stop()=0; + virtual bool Ready()=0; + virtual ESfxAudibility GetAudible(const CVector3f&)=0; + virtual u32 GetVoice() const=0; + + void Release() {m_available = true;} + bool Available() const {return m_available;} + + CBaseSfxWrapper(bool looped, s16 prio, const CSfxHandle& handle, bool useAcoustics, TAreaId area) + : m_rank(0), m_prio(prio), m_handle(handle), m_area(area), m_useAcoustics(useAcoustics), + m_inArea(0), m_looped(looped), m_playing(0), m_active(0) {} + }; + + class CSfxEmitterWrapper : public CBaseSfxWrapper + { + CAudioSys::C3DEmitterParmData m_parmData; + u32 m_emitterHandle = -1; + public: + bool IsPlaying() const; + void Play(); + void Stop(); + bool Ready(); + ESfxAudibility GetAudible(const CVector3f&); + u32 GetVoice() const; + + u32 GetHandle() const {return m_emitterHandle;} + + CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data, + const CSfxHandle& handle, bool useAcoustics, TAreaId area) + : CBaseSfxWrapper(looped, prio, handle, useAcoustics, area), m_parmData(data) {} + }; + + class CSfxWrapper : public CBaseSfxWrapper + { + u16 m_sfxId; + u32 m_voiceHandle = -1; + s16 m_vol; + s16 m_pan; + public: + bool IsPlaying() const; + void Play(); + void Stop(); + bool Ready(); + ESfxAudibility GetAudible(const CVector3f&) {return Aud3;} + u32 GetVoice() const {return m_voiceHandle;} + + void SetVolume(s16 vol) {m_vol = vol;} + + CSfxWrapper(bool looped, s16 prio, u16 sfxId, s16 vol, s16 pan, + const CSfxHandle& handle, bool useAcoustics, TAreaId area) + : CBaseSfxWrapper(looped, prio, handle, useAcoustics, area), + m_sfxId(sfxId), m_vol(vol), m_pan(pan) {} + }; + + static CSfxChannel m_channels[4]; + static rstl::reserved_vector m_emitterWrapperPool; + static rstl::reserved_vector m_wrapperPool; + static ESfxChannels m_currentChannel; + static bool m_doUpdate; + static void* m_sfxTranslationTable; + static void* m_usedSounds; + static bool m_muted; + static bool m_auxProcessingEnabled; + + static u16 kMaxPriority; + static u16 kMedPriority; + static u16 kInternalInvalidSfxId; + static u32 kAllAreas; + + static ESfxChannels GetCurrentChannel() {return m_currentChannel;} +}; + +} + +#endif // __RETRO_CSFXMANAGER_HPP__ diff --git a/Runtime/CArchitectureMessage.hpp b/Runtime/CArchitectureMessage.hpp new file mode 100644 index 000000000..5d4ba7e5b --- /dev/null +++ b/Runtime/CArchitectureMessage.hpp @@ -0,0 +1,142 @@ +#ifndef __RETRO_CARCHITECTUREMESSAGE_HPP__ +#define __RETRO_CARCHITECTUREMESSAGE_HPP__ + +#include +#include "GCNTypes.hpp" +#include "Input/CFinalInput.hpp" + +namespace Retro +{ + +class CIOWin; + +enum EArchMsgTarget +{ + TargetMainFlow = 0 +}; + +enum EArchMsgType +{ + MsgDeleteIOWin = 0, + MsgCreateIOWin = 1, + MsgChangeIOWinPriority = 2, + MsgTimerTick = 4, + MsgUserInput = 5, + MsgSetGameState = 6, + MsgControllerStatus = 7, + MsgQuitGameplay = 8, + MsgUpdateBegin = 10, + MsgFrameBegin = 11, +}; + +struct IArchMsgParm +{ + virtual ~IArchMsgParm() {} +}; + +struct CArchMsgParmInt32 : IArchMsgParm +{ + u32 m_parm; + CArchMsgParmInt32(u32 parm) : m_parm(parm) {} +}; + +struct CArchMsgParmInt32Int32VoidPtr : IArchMsgParm +{ + u32 m_parm1; + u32 m_parm2; + const void* m_parm3; + CArchMsgParmInt32Int32VoidPtr(u32 parm1, u32 parm2, const void* parm3) + : m_parm1(parm1), m_parm2(parm2), m_parm3(parm3) {} +}; + +struct CArchMsgParmNull : IArchMsgParm +{ +}; + +struct CArchMsgParmReal32 : IArchMsgParm +{ + float m_parm; + CArchMsgParmReal32(float parm) : m_parm(parm) {} +}; + +struct CArchMsgParmUserInput : IArchMsgParm +{ + CFinalInput m_parm; + CArchMsgParmUserInput(const CFinalInput& parm) : m_parm(parm) {} +}; + +struct CArchMsgParmControllerStatus : IArchMsgParm +{ + u16 m_parm1; + bool m_parm2; + CArchMsgParmControllerStatus(u16 a, bool b) + : m_parm1(a), m_parm2(b) {} +}; + +class CArchitectureMessage +{ + EArchMsgTarget m_target; + EArchMsgType m_type; + std::unique_ptr m_parm; +public: + CArchitectureMessage(EArchMsgTarget target, EArchMsgType type, IArchMsgParm* parm) + : m_target(target), m_type(type), m_parm(parm) {} + + EArchMsgTarget GetTarget() const {return m_target;} + EArchMsgType GetType() const {return m_type;} + template + const T* GetParm() const {return dynamic_cast(m_parm.get());} +}; + +class MakeMsg +{ +public: + static CArchitectureMessage CreateQuitGameplay(EArchMsgTarget target) + { + return CArchitectureMessage(target, MsgQuitGameplay, new CArchMsgParmNull()); + } + static CArchitectureMessage CreateControllerStatus(EArchMsgTarget target, u16 a, bool b) + { + return CArchitectureMessage(target, MsgControllerStatus, new CArchMsgParmControllerStatus(a, b)); + } + static const CArchMsgParmInt32& GetParmNewGameflowState(const CArchitectureMessage& msg) + { + return *msg.GetParm(); + } + static const CArchMsgParmUserInput& GetParmUserInput(const CArchitectureMessage& msg) + { + return *msg.GetParm(); + } + static CArchitectureMessage CreateUserInput(EArchMsgTarget target, const CFinalInput& input) + { + return CArchitectureMessage(target, MsgUserInput, new CArchMsgParmUserInput(input)); + } + static const CArchMsgParmReal32& GetParmTimerTick(const CArchitectureMessage& msg) + { + return *msg.GetParm(); + } + static CArchitectureMessage CreateTimerTick(EArchMsgTarget target, float val) + { + return CArchitectureMessage(target, MsgTimerTick, new CArchMsgParmReal32(val)); + } + static const CArchMsgParmInt32Int32VoidPtr& GetParmChangeIOWinPriority(const CArchitectureMessage& msg) + { + return *msg.GetParm(); + } + static const CArchMsgParmInt32Int32VoidPtr& GetParmCreateIOWin(const CArchitectureMessage& msg) + { + return *msg.GetParm(); + } + static CArchitectureMessage CreateCreateIOWin(EArchMsgTarget target, int pmin, int pmax, const CIOWin* iowin) + { + return CArchitectureMessage(target, MsgCreateIOWin, new CArchMsgParmInt32Int32VoidPtr(pmin, pmax, iowin)); + } + static const CArchMsgParmInt32Int32VoidPtr& GetParmDeleteIOWin(const CArchitectureMessage& msg) + { + return *msg.GetParm(); + } +}; + +} + +#endif // __RETRO_CARCHITECTUREMESSAGE_HPP__ diff --git a/Runtime/CArchitectureQueue.cpp b/Runtime/CArchitectureQueue.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/Runtime/CArchitectureQueue.hpp b/Runtime/CArchitectureQueue.hpp new file mode 100644 index 000000000..cb17e219f --- /dev/null +++ b/Runtime/CArchitectureQueue.hpp @@ -0,0 +1,30 @@ +#ifndef __RETRO_CARCHITECTUREQUEUE_HPP__ +#define __RETRO_CARCHITECTUREQUEUE_HPP__ + +#include +#include "CArchitectureMessage.hpp" + +namespace Retro +{ + +class CArchitectureQueue +{ + std::list m_list; +public: + void PushMessage(CArchitectureMessage&& msg) + { + m_list.push_back(std::move(msg)); + } + const CArchitectureMessage& PeekMessage() const + { + return m_list.front(); + } + void PopMessage() + { + m_list.pop_front(); + } +}; + +} + +#endif // __RETRO_CARCHITECTUREQUEUE_HPP__ diff --git a/Runtime/CGameOptions.hpp b/Runtime/CGameOptions.hpp index 81e0a3a25..e27d929ce 100644 --- a/Runtime/CGameOptions.hpp +++ b/Runtime/CGameOptions.hpp @@ -6,6 +6,13 @@ namespace Retro class CGameOptions { + char a = 0; + char b = 0; + char c = 128; + char d = 128; + char e = 255; + char f = 255; + bool g = true; }; } diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index f3de4f73e..7f4b11d26 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -3,4 +3,12 @@ namespace Retro { +CGameState::CGameState(CInputStream& stream) +: m_stateFlag(stream.readUint32Big()), m_playerState(stream), m_gameTime(stream.readFloatBig()) +{} + +void CGameState::SetCurrentWorldId(unsigned int id, const std::string& name) +{ +} + } diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index c314e3d9e..f1cf71a63 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -2,20 +2,26 @@ #define __RETRO_CGAMESTATE_HPP__ #include +#include "CBasics.hpp" #include "CPlayerState.hpp" #include "CGameOptions.hpp" +#include "CWorldTransManager.hpp" namespace Retro { class CGameState { + int m_stateFlag = -1; TOneStatic m_playerState; + CWorldTransManager m_transManager; + float m_gameTime = 0.0; CGameOptions m_gameOpts; public: - CGameState() - { - } + CGameState() {} + CGameState(CInputStream& stream); + void SetCurrentWorldId(unsigned int id, const std::string& name); + CWorldTransManager& WorldTransitionManager() {return m_transManager;} }; } diff --git a/Runtime/CIOWin.hpp b/Runtime/CIOWin.hpp index 91ccd61c7..2819e57b8 100644 --- a/Runtime/CIOWin.hpp +++ b/Runtime/CIOWin.hpp @@ -1,11 +1,23 @@ #ifndef __RETRO_CIOWIN_HPP__ #define __RETRO_CIOWIN_HPP__ +#include +#include "CArchitectureMessage.hpp" +#include "CArchitectureQueue.hpp" + namespace Retro { class CIOWin { + const char* m_name; +public: + virtual ~CIOWin() {} + CIOWin(const char* name) : m_name(name) {} + virtual bool OnMessage(const CArchitectureMessage&, CArchitectureQueue&)=0; + virtual bool GetIsContinueDraw() const {return true;} + virtual void Draw() const {} + virtual void PreDraw() const {} }; } diff --git a/Runtime/CIOWinManager.cpp b/Runtime/CIOWinManager.cpp index e69de29bb..f7cf976d7 100644 --- a/Runtime/CIOWinManager.cpp +++ b/Runtime/CIOWinManager.cpp @@ -0,0 +1,20 @@ +#include "CIOWinManager.hpp" + +namespace Retro +{ + +bool CIOWinManager::OnIOWinMessage(const CArchitectureMessage& msg) +{ + switch (msg.GetType()) + { + case MsgChangeIOWinPriority: + { + const CArchMsgParmInt32Int32VoidPtr& parm = MakeMsg::GetParmChangeIOWinPriority(msg); + + } + default: break; + } + return false; +} + +} diff --git a/Runtime/CIOWinManager.hpp b/Runtime/CIOWinManager.hpp index e6d8caacd..97f1fd553 100644 --- a/Runtime/CIOWinManager.hpp +++ b/Runtime/CIOWinManager.hpp @@ -1,11 +1,25 @@ #ifndef __RETRO_CIOWINMANAGER_HPP__ #define __RETRO_CIOWINMANAGER_HPP__ +#include +#include "CIOWin.hpp" + namespace Retro { class CIOWinManager { + struct IOWinPQNode + { + std::shared_ptr m_iowin; + int m_prio; + CIOWinManager::IOWinPQNode* m_prev; + IOWinPQNode(std::weak_ptr iowin, int prio, + CIOWinManager::IOWinPQNode* prev) + : m_iowin(iowin), m_prio(prio), m_prev(prev) {} + std::shared_ptr GetIOWin() const {return m_iowin;} + }; + bool OnIOWinMessage(const CArchitectureMessage& msg); }; } diff --git a/Runtime/CMFGame.cpp b/Runtime/CMFGame.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/Runtime/CMFGame.hpp b/Runtime/CMFGame.hpp new file mode 100644 index 000000000..831775937 --- /dev/null +++ b/Runtime/CMFGame.hpp @@ -0,0 +1,19 @@ +#ifndef __RETRO_CMFGAME_HPP__ +#define __RETRO_CMFGAME_HPP__ + +#include "CIOWin.hpp" + +namespace Retro +{ + +class CMFGameLoader : public CIOWin +{ +public: + CMFGameLoader() : CIOWin("CMFGameLoader") {} + bool OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue); + void Draw() const; +}; + +} + +#endif // __RETRO_CMFGAME_HPP__ diff --git a/Runtime/CMainFlow.cpp b/Runtime/CMainFlow.cpp index e69de29bb..4c21994bd 100644 --- a/Runtime/CMainFlow.cpp +++ b/Runtime/CMainFlow.cpp @@ -0,0 +1,27 @@ +#include "CMainFlow.hpp" +#include "GameGlobalObjects.hpp" +#include "CGameState.hpp" + +namespace Retro +{ + +bool CMFGameLoader::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) +{ + switch (msg.GetType()) + { + case MsgTimerTick: + { + const CArchMsgParmReal32& tick = MakeMsg::GetParmTimerTick(msg); + g_GameState->WorldTransitionManager(); + } + default: break; + } + return true; +} + +void CMFGameLoader::Draw() const +{ + g_GameState->WorldTransitionManager().Draw(); +} + +} diff --git a/Runtime/CMainFlow.hpp b/Runtime/CMainFlow.hpp index c7695ab04..4e2276908 100644 --- a/Runtime/CMainFlow.hpp +++ b/Runtime/CMainFlow.hpp @@ -1,11 +1,53 @@ #ifndef __RETRO_CMAINFLOW_HPP__ #define __RETRO_CMAINFLOW_HPP__ +#include "CIOWin.hpp" +#include "CMFGame.hpp" + namespace Retro { -class CMainFlow +enum EClientFlowStates { + StateGameLoad = 13, +}; + +class CMainFlow : public CIOWin +{ +public: + CMainFlow() : CIOWin("CMainFlow") {} + void AdvanceGameState(CArchitectureQueue& queue) + { + } + void SetGameState(EClientFlowStates state, CArchitectureQueue& queue) + { + switch (state) + { + case StateGameLoad: + queue.PushMessage(std::move(MakeMsg::CreateCreateIOWin(TargetMainFlow, 10, 1000, new CMFGameLoader()))); + break; + default: break; + } + } + bool OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) + { + switch (msg.GetType()) + { + case MsgTimerTick: + AdvanceGameState(queue); + break; + case MsgSetGameState: + { + CArchMsgParmInt32 state = MakeMsg::GetParmNewGameflowState(msg); + SetGameState(EClientFlowStates(state.m_parm), queue); + return true; + } + default: break; + } + return false; + } + bool GetIsContinueDraw() const {return false;} + void Draw() const {} }; } diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index 98931fab9..34adb4dca 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -29,12 +29,16 @@ add_library(RuntimeCommon CSimplePool.hpp CSimplePool.cpp CAi.hpp CAi.cpp CGameOptions.hpp CGameOptions.cpp - CStaticInterference.hpp CStaticInterference.cpp + CStaticInterference.hpp CCRC32.hpp CCRC32.cpp CEntity.hpp CEntity.cpp IFactory.hpp ScriptObjectSupport.hpp ScriptObjectSupport.cpp - CObjectList.hpp CObjectList.cpp + CObjectList.hpp + CMFGame.hpp CMFGame.cpp + CMainFlow.hpp CMainFlow.cpp + CArchitectureMessage.hpp + CArchitectureQueue.hpp CArchitectureQueue.cpp GameGlobalObjects.hpp RetroTypes.hpp GCNTypes.hpp) diff --git a/Runtime/CPlayerState.cpp b/Runtime/CPlayerState.cpp index 4bd35255e..74e7afe11 100644 --- a/Runtime/CPlayerState.cpp +++ b/Runtime/CPlayerState.cpp @@ -3,4 +3,10 @@ namespace Retro { +CPlayerState::CPlayerState(CInputStream& stream) +: m_staticIntf(5) +{ + +} + } diff --git a/Runtime/CPlayerState.hpp b/Runtime/CPlayerState.hpp index 2e3c89f33..fd68e184b 100644 --- a/Runtime/CPlayerState.hpp +++ b/Runtime/CPlayerState.hpp @@ -2,6 +2,7 @@ #define __RETRO_CPLAYERSTATE_HPP__ #include "RetroTypes.hpp" +#include "CBasics.hpp" #include "CStaticInterference.hpp" namespace Retro @@ -12,13 +13,17 @@ class CPlayerState CStaticInterference m_staticIntf; class CPowerUp { - int m_a; - int m_b; + int m_a = 0; + int m_b = 0; public: - CPowerUp() : m_a(-1), m_b(-1) {} + CPowerUp() {} CPowerUp(int a, int b) : m_a(a), m_b(b) {} }; CPowerUp m_powerups[29]; + +public: + CPlayerState() : m_staticIntf(5) {} + CPlayerState(CInputStream& stream); }; } diff --git a/Runtime/CStaticInterference.cpp b/Runtime/CStaticInterference.cpp deleted file mode 100644 index 005c064e9..000000000 --- a/Runtime/CStaticInterference.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "CStaticInterference.hpp" - -namespace Retro -{ - -} diff --git a/Runtime/CStaticInterference.hpp b/Runtime/CStaticInterference.hpp index 4fbd1a06b..ff6455a9a 100644 --- a/Runtime/CStaticInterference.hpp +++ b/Runtime/CStaticInterference.hpp @@ -1,11 +1,73 @@ #ifndef __RETRO_CSTATICINTERFERENCE_HPP__ #define __RETRO_CSTATICINTERFERENCE_HPP__ +#include +#include "RetroTypes.hpp" + namespace Retro { +class CStateManager; + +struct CStaticInterferenceSource +{ + TUniqueId id; + float magnitude; + float timeLeft; +}; class CStaticInterference { + std::vector m_sources; +public: + CStaticInterference(int sourceCount) + { + m_sources.reserve(sourceCount); + } + void AddSource(TUniqueId id, float magnitude, float duration) + { + for (CStaticInterferenceSource& src : m_sources) + { + if (src.id == id) + { + src.magnitude = magnitude; + src.timeLeft = duration; + return; + } + } + m_sources.push_back({id, magnitude, duration}); + } + void Update(CStateManager&, float dt) + { + std::vector newSources; + newSources.reserve(m_sources.size()); + for (CStaticInterferenceSource& src : m_sources) + { + if (src.timeLeft >= 0.0) + { + src.timeLeft -= dt; + newSources.push_back(src); + } + } + m_sources = std::move(newSources); + } + float GetTotalInterference() const + { + float validAccum = 0.0; + float invalidAccum = 0.0; + for (const CStaticInterferenceSource& src : m_sources) + { + if (src.id == kInvalidUniqueId) + invalidAccum += src.magnitude; + else + validAccum += src.magnitude; + } + if (validAccum > 0.80000001) + validAccum = 0.80000001; + validAccum += invalidAccum; + if (validAccum > 1.0) + return 1.0; + return validAccum; + } }; } diff --git a/Runtime/CWorldTransManager.cpp b/Runtime/CWorldTransManager.cpp index 39626f248..730a4aa46 100644 --- a/Runtime/CWorldTransManager.cpp +++ b/Runtime/CWorldTransManager.cpp @@ -3,4 +3,12 @@ namespace Retro { +void CWorldTransManager::DrawEnabled() const +{ +} + +void CWorldTransManager::DrawDisabled() const +{ +} + } diff --git a/Runtime/CWorldTransManager.hpp b/Runtime/CWorldTransManager.hpp index 852a1d0dc..1c84b3b86 100644 --- a/Runtime/CWorldTransManager.hpp +++ b/Runtime/CWorldTransManager.hpp @@ -6,6 +6,17 @@ namespace Retro class CWorldTransManager { + bool m_drawEnabled; +public: + void DrawEnabled() const; + void DrawDisabled() const; + void Draw() const + { + if (m_drawEnabled) + DrawEnabled(); + else + DrawDisabled(); + } }; } diff --git a/Runtime/Input/CFinalInput.cpp b/Runtime/Input/CFinalInput.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/Runtime/Input/CFinalInput.hpp b/Runtime/Input/CFinalInput.hpp new file mode 100644 index 000000000..0aa39377a --- /dev/null +++ b/Runtime/Input/CFinalInput.hpp @@ -0,0 +1,13 @@ +#ifndef __RETRO_CFINALINPUT_HPP__ +#define __RETRO_CFINALINPUT_HPP__ + +namespace Retro +{ + +class CFinalInput +{ +}; + +} + +#endif // __RETRO_CFINALINPUT_HPP__ diff --git a/Runtime/Input/CMakeLists.txt b/Runtime/Input/CMakeLists.txt index e5bdf0281..c02ccf972 100644 --- a/Runtime/Input/CMakeLists.txt +++ b/Runtime/Input/CMakeLists.txt @@ -1,2 +1,3 @@ add_library(RuntimeCommonInput - CInputGenerator.hpp CInputGenerator.cpp) + CInputGenerator.hpp CInputGenerator.cpp + CFinalInput.hpp CFinalInput.cpp) diff --git a/Runtime/MP1/main.cpp b/Runtime/MP1/main.cpp index d64a8acbf..c42e70893 100644 --- a/Runtime/MP1/main.cpp +++ b/Runtime/MP1/main.cpp @@ -87,6 +87,7 @@ public: class CGameArchitectureSupport { + CArchitectureQueue m_archQueue; CAudioSys m_audioSys; CInputGenerator m_inputGenerator; CGuiSys m_guiSys; @@ -100,13 +101,18 @@ public: : m_audioSys(0,0,0,0,0) { } + bool Update() + { + bool finished = false; + return finished; + } }; class CMain : public COsContext { CMemorySys m_memSys; CTweaks m_tweaks; - bool m_run = true; + bool m_finished = false; public: CMain() : m_memSys(*this, CMemorySys::GetGameAllocator()) @@ -135,9 +141,9 @@ public: g_TweakManager->ReadFromMemoryCard("AudioTweaks"); FillInAssetIDs(); TOneStatic archSupport(*this); - while (m_run) + while (!m_finished) { - + m_finished = archSupport->Update(); } return 0; } diff --git a/Runtime/RetroTypes.hpp b/Runtime/RetroTypes.hpp index 8be905157..a06c93828 100644 --- a/Runtime/RetroTypes.hpp +++ b/Runtime/RetroTypes.hpp @@ -1,6 +1,7 @@ #ifndef __RETRO_TYPES_HPP__ #define __RETRO_TYPES_HPP__ +#include #include #include "GCNTypes.hpp" @@ -42,10 +43,24 @@ public: template u8 TOneStatic::m_allocspace[sizeof(T)]; template u32 TOneStatic::m_refCount; -using TUniqueId = s16; +using TUniqueId = u16; using TEditorId = u32; using TAreaId = u32; +#define kInvalidEditorId TEditorId(-1) +#define kInvalidUniqueId TUniqueId(-1) +#define kInvalidAreaId TAreaId(-1) + +} + +namespace rstl +{ +template +class reserved_vector : public std::vector +{ +public: + reserved_vector() {this->reserve(N);} +}; } #endif // __RETRO_TYPES_HPP__