Additional runtime stubs

This commit is contained in:
Jack Andersen 2015-08-17 10:33:58 -10:00
parent 387332ed70
commit 281b908574
22 changed files with 134 additions and 31 deletions

0
Runtime/CAi.cpp Normal file
View File

4
Runtime/CAi.hpp Normal file
View File

@ -0,0 +1,4 @@
#ifndef __RETRO_CAI_HPP__
#define __RETRO_CAI_HPP__
#endif // __RETRO_CAI_HPP__

View File

View File

@ -0,0 +1,4 @@
#ifndef __RETRO_CASSETFACTORY_HPP__
#define __RETRO_CASSETFACTORY_HPP__
#endif // __RETRO_CASSETFACTORY_HPP__

View File

@ -4,25 +4,13 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "RetroTemplates.hpp"
#include <Athena/IStreamReader.hpp> #include <Athena/IStreamReader.hpp>
#include <Athena/IStreamWriter.hpp> #include <Athena/IStreamWriter.hpp>
using CInputStream = Athena::io::IStreamReader; using CInputStream = Athena::io::IStreamReader;
using COutputStream = Athena::io::IStreamWriter; using COutputStream = Athena::io::IStreamWriter;
template<class T>
class TOneStatic
{
static T m_allocspace;
static uint32_t m_refCount;
public:
static T* GetAllocSpace() {return &m_allocspace;}
static uint32_t& ReferenceCount() {return m_refCount;}
void* operator new(size_t) {++ReferenceCount(); return GetAllocSpace();}
void operator delete(void*) {--ReferenceCount();}
};
template<class T> T TOneStatic<T>::m_allocspace;
template<class T> uint32_t TOneStatic<T>::m_refCount;
class CBasics class CBasics
{ {
public: public:

0
Runtime/CGameOptions.cpp Normal file
View File

8
Runtime/CGameOptions.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef __RETRO_CGAMEOPTIONS_HPP__
#define __RETRO_CGAMEOPTIONS_HPP__
class CGameOptions
{
};
#endif // __RETRO_CGAMEOPTIONS_HPP__

View File

@ -1,8 +1,19 @@
#ifndef __RETRO_CGAMESTATE_HPP__ #ifndef __RETRO_CGAMESTATE_HPP__
#define __RETRO_CGAMESTATE_HPP__ #define __RETRO_CGAMESTATE_HPP__
#include <memory>
#include "CPlayerState.hpp"
#include "CGameOptions.hpp"
class CGameState class CGameState
{ {
std::unique_ptr<CPlayerState> m_playerState;
CGameOptions m_gameOpts;
public:
CGameState()
{
m_playerState.reset(new CPlayerState);
}
}; };
#endif // __RETRO_CGAMESTATE_HPP__ #endif // __RETRO_CGAMESTATE_HPP__

View File

@ -5,7 +5,7 @@ add_subdirectory(GuiSys)
add_subdirectory(Script) add_subdirectory(Script)
add_executable(RuntimeCheck add_executable(RuntimeCheck
main.hpp main.cpp main.cpp
COsContext.hpp COsContextBoo.cpp COsContext.hpp COsContextBoo.cpp
CMemory.hpp CMemory.cpp CMemory.hpp CMemory.cpp
CMemoryCardSys.hpp CMemoryCardSysPC.cpp CMemoryCardSys.hpp CMemoryCardSysPC.cpp
@ -20,4 +20,12 @@ add_executable(RuntimeCheck
CMapWorldInfo.hpp CMapWorldInfo.cpp CMapWorldInfo.hpp CMapWorldInfo.cpp
CPlayerState.hpp CPlayerState.cpp CPlayerState.hpp CPlayerState.cpp
CWorldTransManager.hpp CWorldTransManager.cpp CWorldTransManager.hpp CWorldTransManager.cpp
CRandom16.hpp CRandom16.cpp) CRandom16.hpp CRandom16.cpp
CResFactory.hpp CResFactory.cpp
CSimplePool.hpp CSimplePool.cpp
CAssetFactory.hpp CAssetFactory.cpp
CAi.hpp CAi.cpp
CGameOptions.hpp CGameOptions.cpp
CStaticInterference.hpp CStaticInterference.cpp
RetroTemplates.hpp
GCNTypes.hpp)

View File

@ -36,5 +36,5 @@ CMemorySys::~CMemorySys()
CMemory::Shutdown(); CMemory::Shutdown();
} }
IAllocator* CMemorySys::GetGameAllocator() {return &GAME_ALLOCATOR;} IAllocator& CMemorySys::GetGameAllocator() {return GAME_ALLOCATOR;}

View File

@ -17,7 +17,7 @@ class CMemorySys
public: public:
CMemorySys(COsContext&, IAllocator&); CMemorySys(COsContext&, IAllocator&);
~CMemorySys(); ~CMemorySys();
static IAllocator* GetGameAllocator(); static IAllocator& GetGameAllocator();
}; };
#endif // __RETRO_CMEMORY_HPP__ #endif // __RETRO_CMEMORY_HPP__

View File

@ -1,8 +1,20 @@
#ifndef __RETRO_CPLAYERSTATE_HPP__ #ifndef __RETRO_CPLAYERSTATE_HPP__
#define __RETRO_CPLAYERSTATE_HPP__ #define __RETRO_CPLAYERSTATE_HPP__
class CPlayerState #include "RetroTemplates.hpp"
#include "CStaticInterference.hpp"
class CPlayerState : TOneStatic<CPlayerState>
{ {
CStaticInterference m_staticIntf;
class CPowerUp
{
int m_a;
int m_b;
public:
CPowerUp(int a, int b) : m_a(a), m_b(b) {}
};
CPowerUp m_powerups[29];
}; };
#endif // __RETRO_CPLAYERSTATE_HPP__ #endif // __RETRO_CPLAYERSTATE_HPP__

0
Runtime/CResFactory.cpp Normal file
View File

8
Runtime/CResFactory.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef __RETRO_CRESFACTORY_HPP__
#define __RETRO_CRESFACTORY_HPP__
class CResFactory
{
};
#endif // __RETRO_CRESFACTORY_HPP__

0
Runtime/CSimplePool.cpp Normal file
View File

8
Runtime/CSimplePool.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef __RETRO_CSIMPLEPOOL_HPP__
#define __RETRO_CSIMPLEPOOL_HPP__
class CSimplePool
{
};
#endif // __RETRO_CSIMPLEPOOL_HPP__

View File

View File

@ -0,0 +1,8 @@
#ifndef __RETRO_CSTATICINTERFERENCE_HPP__
#define __RETRO_CSTATICINTERFERENCE_HPP__
class CStaticInterference
{
};
#endif // __RETRO_CSTATICINTERFERENCE_HPP__

15
Runtime/GCNTypes.hpp Normal file
View File

@ -0,0 +1,15 @@
#ifndef __RETRO_GCTYPES_HPP__
#define __RETRO_GCTYPES_HPP__
#include <stdint.h>
using s8 = int8_t;
using u8 = uint8_t;
using s16 = int16_t;
using u16 = uint16_t;
using s32 = int32_t;
using u32 = uint32_t;
using s64 = int64_t;
using u64 = uint64_t;
#endif // __RETRO_GCTYPES_HPP__

View File

@ -0,0 +1,23 @@
#ifndef __RETRO_TEMPLATES_HPP__
#define __RETRO_TEMPLATES_HPP__
#include "GCNTypes.hpp"
/**
* @brief Inheritable singleton static-allocator
*/
template<class T>
class TOneStatic
{
static T m_allocspace;
static uint32_t m_refCount;
public:
static T* GetAllocSpace() {return &m_allocspace;}
static u32& ReferenceCount() {return m_refCount;}
void* operator new(size_t) {++ReferenceCount(); return GetAllocSpace();}
void operator delete(void*) {--ReferenceCount();}
};
template<class T> T TOneStatic<T>::m_allocspace;
template<class T> u32 TOneStatic<T>::m_refCount;
#endif // __RETRO_TEMPLATES_HPP__

View File

@ -2,21 +2,30 @@
#include "COsContext.hpp" #include "COsContext.hpp"
#include "CBasics.hpp" #include "CBasics.hpp"
#include "CTweaks.hpp" #include "CTweaks.hpp"
#include "CMemory.hpp"
#include "CMemoryCardSys.hpp" #include "CMemoryCardSys.hpp"
#include "CResFactory.hpp"
#include "CSimplePool.hpp"
class CGameGlobalObjects : public TOneStatic<CGameGlobalObjects> class CGameGlobalObjects : public TOneStatic<CGameGlobalObjects>
{ {
CMemoryCardSys m_memoryCardSys; CMemoryCardSys m_memoryCardSys;
CResFactory m_resFactory;
CSimplePool m_simplePool;
public: public:
void PostInitialize(COsContext& osctx, CMemorySys& memSys)
{
}
}; };
class CMain : public COsContext class CMain : public COsContext
{ {
std::unique_ptr<CGameGlobalObjects> m_gameGlobalObjects; CMemorySys m_memSys;
CTweaks m_tweaks; CTweaks m_tweaks;
bool m_run = true;
public: public:
CMain() CMain()
: m_memSys(*this, CMemorySys::GetGameAllocator())
{ {
OpenWindow("", 0, 0, 640, 480); OpenWindow("", 0, 0, 640, 480);
} }
@ -25,7 +34,13 @@ public:
} }
int RsMain(int argc, const char* argv[]) int RsMain(int argc, const char* argv[])
{ {
m_gameGlobalObjects.reset(new CGameGlobalObjects); CGameGlobalObjects* globalObjs = new CGameGlobalObjects;
InitializeSubsystems();
globalObjs->PostInitialize(*this, m_memSys);
while (m_run)
{
}
return 0; return 0;
} }
}; };

View File

@ -1,9 +0,0 @@
#ifndef __RETRO_CMAIN_HPP__
#define __RETRO_CMAIN_HPP__
#include "COsContext.hpp"
#include "CTweaks.hpp"
#endif // __RETRO_CMAIN_HPP__