various input class implementations

This commit is contained in:
Jack Andersen 2015-08-27 14:11:31 -10:00
parent 3616f14f94
commit ce42cdd3be
39 changed files with 836 additions and 226 deletions

View File

@ -8,4 +8,5 @@ add_library(DNACommon
STRG.hpp STRG.cpp
TXTR.hpp TXTR.cpp
ANCS.hpp
ANIM.hpp ANIM.cpp)
ANIM.hpp ANIM.cpp
Tweaks/ITweakPlayerControl.hpp)

View File

@ -1,13 +1,13 @@
#ifndef _DNACOMMON_GX_HPP_
#define _DNACOMMON_GX_HPP_
#include <Athena/DNA.hpp>
#include "DNACommon.hpp"
namespace GX
{
/* RGBA8 structure (GXColor) */
struct Color : Athena::io::DNA<Athena::BigEndian>
struct Color : Retro::BigDNA
{
Value<atUint8> r;
Value<atUint8> g;
@ -30,7 +30,8 @@ enum AttrType
INDEX16
};
enum TevColorArg {
enum TevColorArg
{
CC_CPREV = 0, /*!< Use the color value from previous TEV stage */
CC_APREV = 1, /*!< Use the alpha value from previous TEV stage */
CC_C0 = 2, /*!< Use the color value from the color/output register 0 */
@ -49,7 +50,8 @@ enum TevColorArg {
CC_ZERO = 15 /*!< Use to pass zero value */
};
enum TevAlphaArg {
enum TevAlphaArg
{
CA_APREV = 0, /*!< Use the alpha value from previous TEV stage */
CA_A0 = 1, /*!< Use the alpha value from the color/output register 0 */
CA_A1 = 2, /*!< Use the alpha value from the color/output register 1 */
@ -132,7 +134,8 @@ enum TevKAlphaSel
TEV_KASEL_K3_A = 0x1F
};
enum TevOp {
enum TevOp
{
TEV_ADD = 0,
TEV_SUB = 1,
TEV_COMP_R8_GT = 8,
@ -147,20 +150,23 @@ enum TevOp {
TEV_COMP_A8_EQ = TEV_COMP_RGB8_EQ // for alpha channel
};
enum TevBias {
enum TevBias
{
TB_ZERO = 0,
TB_ADDHALF = 1,
TB_SUBHALF = 2,
};
enum TevScale {
enum TevScale
{
CS_SCALE_1 = 0,
CS_SCALE_2 = 1,
CS_SCALE_4 = 2,
CS_DIVIDE_2 = 3
};
enum TevRegID {
enum TevRegID
{
TEVPREV = 0,
TEVREG0 = 1,
TEVREG1 = 2,

View File

@ -0,0 +1,16 @@
#ifndef __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__
#define __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__
#include "../DNACommon.hpp"
namespace Retro
{
struct ITweakPlayerControl : BigYAML
{
virtual atUint32 GetMapping(atUint32) const=0;
};
}
#endif // __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__

View File

@ -1,4 +1,3 @@
add_subdirectory(Tweaks)
make_dnalist(liblist
PAK
MLVL
@ -10,7 +9,8 @@ make_dnalist(liblist
MAPA
CMDLMaterials
MREA
Tweaks/CTweakParticle)
Tweaks/CTweakParticle
Tweaks/CTweakPlayerControl)
add_library(DNAMP1
DNAMP1.hpp DNAMP1.cpp
${liblist}

View File

@ -0,0 +1,22 @@
#ifndef _DNAMP1_CTWEAKPLAYERCONTROL_HPP_
#define _DNAMP1_CTWEAKPLAYERCONTROL_HPP_
#include "../../DNACommon/Tweaks/ITweakPlayerControl.hpp"
namespace Retro
{
namespace DNAMP1
{
struct CTweakPlayerControl : ITweakPlayerControl
{
DECL_YAML
Vector<atUint32, DNA_COUNT(65)> m_mappings;
atUint32 GetMapping(atUint32 command) const {return m_mappings[command];}
CTweakPlayerControl(Athena::io::IStreamReader& reader) {this->read(reader);}
};
}
}
#endif // _DNAMP1_CTWEAKPLAYERCONTROL_HPP_

View File

@ -38,7 +38,7 @@ CGameAllocator::SGameMemInfo* CGameAllocator::GetMemInfoFromBlockPtr(void* ptr)
return reinterpret_cast<SGameMemInfo*>(reinterpret_cast<u8*>(ptr) - 32);
}
bool CGameAllocator::Initialize(COsContext&)
bool CGameAllocator::Initialize()
{
}
void CGameAllocator::Shutdown()

View File

@ -31,7 +31,7 @@ public:
u32 GetLargestFreeChunk() const;
SGameMemInfo* GetMemInfoFromBlockPtr(void* ptr);
bool Initialize(COsContext&);
bool Initialize();
void Shutdown();
void* Alloc(size_t, EHint, EScope, EType, const CCallStack&);
void Free(void*);

View File

@ -8,10 +8,10 @@ namespace Retro
enum EClientFlowStates
{
ClientStateUnspecified = -1,
ClientStateFrontEnd = 7,
ClientStateGameLoad = 13,
ClientStateMoviePlay = 14
ClientFlowUnspecified = -1,
ClientFlowFrontEnd = 7,
ClientFlowGameLoad = 13,
ClientFlowMoviePlay = 14
};
class CMainFlowBase : public CIOWin

View File

@ -16,7 +16,6 @@ else()
endif()
add_library(RuntimeCommon
COsContext.hpp COsContextBoo.cpp
CMemory.hpp CMemory.cpp
CMemoryCardSys.hpp
IAllocator.hpp IAllocator.cpp

View File

@ -12,9 +12,9 @@ static CGameAllocator g_gameAllocator;
static IAllocator* g_memoryAllocator = &g_gameAllocator;
static bool g_memoryAllocatorReady = false;
void CMemory::Startup(COsContext& cos)
void CMemory::Startup()
{
g_memoryAllocatorReady = g_memoryAllocator->Initialize(cos);
g_memoryAllocatorReady = g_memoryAllocator->Initialize();
}
void CMemory::Shutdown()
@ -23,12 +23,12 @@ void CMemory::Shutdown()
g_memoryAllocatorReady = false;
}
void CMemory::SetAllocator(COsContext& cos, IAllocator& alloc)
void CMemory::SetAllocator(IAllocator& alloc)
{
if (&alloc != g_memoryAllocator)
{
g_memoryAllocator = &alloc;
g_memoryAllocator->Initialize(cos);
g_memoryAllocator->Initialize();
}
}
@ -56,10 +56,10 @@ void* CMemory::Alloc(size_t sz, IAllocator::EHint hint, IAllocator::EScope scope
return newPtr;
}
CMemorySys::CMemorySys(COsContext& cos, IAllocator& alloc)
CMemorySys::CMemorySys(IAllocator& alloc)
{
CMemory::Startup(cos);
CMemory::SetAllocator(cos, alloc);
CMemory::Startup();
CMemory::SetAllocator(alloc);
}
CMemorySys::~CMemorySys()

View File

@ -10,9 +10,9 @@ class COsContext;
class CMemory
{
public:
static void Startup(COsContext&);
static void Startup();
static void Shutdown();
static void SetAllocator(COsContext&, IAllocator&);
static void SetAllocator(IAllocator&);
static void OffsetFakeStatics(int);
static void SetOutOfMemoryCallback(const IAllocator::TOutOfMemoryCallback, void*);
static void Free(void*);
@ -22,7 +22,7 @@ public:
class CMemorySys
{
public:
CMemorySys(COsContext&, IAllocator&);
CMemorySys(IAllocator&);
~CMemorySys();
static IAllocator& GetGameAllocator();
};

View File

@ -1,16 +0,0 @@
#ifndef __RETRO_COSCONTEXT_HPP__
#define __RETRO_COSCONTEXT_HPP__
namespace Retro
{
class COsContext
{
public:
COsContext();
int OpenWindow(const char* name, int x, int y, int w, int h);
};
}
#endif // __RETRO_COSCONTEXT_HPP__

View File

@ -1,16 +0,0 @@
#include "COsContext.hpp"
#include <boo/boo.hpp>
namespace Retro
{
COsContext::COsContext()
{
}
int COsContext::OpenWindow(const char* name, int x, int y, int w, int h)
{
return 0;
}
}

View File

@ -37,12 +37,12 @@ private:
public:
CPakFile(const std::string& filename, bool flag) : CDvdFile(filename.c_str()) {}
const std::vector<u32>& GetDepList() const {return x5c_depList;}
u32 GetResIdByName(const char* name) const
const SObjectTag* GetResIdByName(const char* name) const
{
for (const std::pair<std::string, SObjectTag>& p : x4c_nameList)
if (!CStringExtras::CompareCaseInsensitive(p.first.c_str(), name))
return p.second.id;
return 0;
return &p.second;
return nullptr;
}
const SResInfo* GetResInfoForLoad(u32 id) {}
const SResInfo* GetResInfo(u32 id) const {}

View File

@ -30,7 +30,7 @@ public:
void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**);
void CancelBuild(const SObjectTag&);
bool CanBuild(const SObjectTag& tag) {return x4_loader.ResourceExists(tag);}
u32 GetResourceIdByName(const char* name) const {return x4_loader.GetResourceIdByName(name);}
const SObjectTag* GetResourceIdByName(const char* name) const {return x4_loader.GetResourceIdByName(name);}
std::vector<std::pair<std::string, SObjectTag>> GetResourceIdToNameList() const
{

View File

@ -138,15 +138,15 @@ FourCC CResLoader::GetResourceTypeById(u32 id)
return false;
}
u32 CResLoader::GetResourceIdByName(const char* name) const
const SObjectTag* CResLoader::GetResourceIdByName(const char* name) const
{
for (const std::unique_ptr<CPakFile>& file : x1c_pakLoadedList)
{
u32 id = file->GetResIdByName(name);
const SObjectTag* id = file->GetResIdByName(name);
if (id)
return id;
}
return 0;
return nullptr;
}
bool CResLoader::AreAllPaksLoaded() const

View File

@ -34,7 +34,7 @@ public:
u32 ResourceSize(const SObjectTag& tag);
bool ResourceExists(const SObjectTag& tag);
FourCC GetResourceTypeById(u32 id);
u32 GetResourceIdByName(const char* name) const;
const SObjectTag* GetResourceIdByName(const char* name) const;
bool AreAllPaksLoaded() const;
void AsyncIdlePakLoading();
bool FindResource(u32 id);

View File

@ -12,7 +12,7 @@ public:
void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**) {}
void CancelBuild(const SObjectTag&) {}
bool CanBuild(const SObjectTag&) {}
u32 GetResourceIdByName(const char*) const {}
const SObjectTag* GetResourceIdByName(const char*) const {}
};
}

View File

@ -13,6 +13,8 @@ extern class CGameState* g_GameState;
extern class CInGameTweakManagerBase* g_TweakManager;
extern class CBooRenderer* g_Renderer;
extern class ITweakPlayerControl* g_tweakPlayerControl;
}
#endif // __RETRO_GAMEGLOBALOBJECTS_HPP__

View File

@ -4,14 +4,13 @@
namespace Retro
{
class IObjectStore;
class COsContext;
class CMemorySys;
class CResFactory;
class CBooRenderer
{
public:
CBooRenderer(IObjectStore&, COsContext&, CMemorySys&, CResFactory&)
CBooRenderer(IObjectStore&, CMemorySys&, CResFactory&)
{
}
};

View File

@ -59,7 +59,7 @@ public:
typedef bool(*TOutOfMemoryCallback)(void*, u32);
typedef bool(*TAllocationVisitCallback)(const SAllocInfo&, void*);
virtual bool Initialize(COsContext&)=0;
virtual bool Initialize()=0;
virtual void Shutdown()=0;
virtual void* Alloc(size_t, EHint, EScope, EType, const CCallStack&)=0;
virtual void Free(void*)=0;

View File

@ -17,7 +17,7 @@ public:
virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**)=0;
virtual void CancelBuild(const SObjectTag&)=0;
virtual bool CanBuild(const SObjectTag&)=0;
virtual u32 GetResourceIdByName(const char*) const=0;
virtual const SObjectTag* GetResourceIdByName(const char*) const=0;
};
}

View File

@ -0,0 +1,15 @@
#ifndef __RETRO_CDOLPHINCONTROLLER_HPP__
#define __RETRO_CDOLPHINCONTROLLER_HPP__
#include "IController.hpp"
namespace Retro
{
class CDolphinController : public IController
{
};
}
#endif // __RETRO_CDOLPHINCONTROLLER_HPP__

View File

@ -0,0 +1,8 @@
#include "CFinalInput.hpp"
namespace Retro
{
}

View File

@ -1,11 +1,121 @@
#ifndef __RETRO_CFINALINPUT_HPP__
#define __RETRO_CFINALINPUT_HPP__
#include "../RetroTypes.hpp"
namespace Retro
{
class CFinalInput
{
float x0_dt;
u32 x4_controllerIdx;
float x8_anaLeftX;
float xc_anaLeftY;
float x10_anaRightX;
float x14_anaRightY;
float x18_anaLeftTrigger;
float x1c_anaRightTrigger;
bool x20_enableAnaLeftXP;
bool x21_enableAnaLeftYP;
bool x22_enableAnaRightXP;
bool x23_enableAnaRightYP;
float x24_anaLeftTriggerP;
float x28_anaRightTriggerP;
bool x2c_b24_A:1;
bool x2c_b25_B:1;
bool x2c_b26_X:1;
bool x2c_b27_Y:1;
bool x2c_b28_Z:1;
bool x2c_b29_L:1;
bool x2c_b30_R:1;
bool x2c_b31_DPUp:1;
bool x2d_b24_DPRight:1;
bool x2d_b25_DPDown:1;
bool x2d_b26_DPLeft:1;
bool x2d_b27_Start:1;
bool x2d_b28_PA:1;
bool x2d_b29_PB:1;
bool x2d_b30_PX:1;
bool x2d_b31_PY:1;
bool x2e_b24_PZ:1;
bool x2e_b25_PL:1;
bool x2e_b26_PR:1;
bool x2e_b27_PDPUp:1;
bool x2e_b28_PDPRight:1;
bool x2e_b29_PDPDown:1;
bool x2e_b30_PDPLeft:1;
bool x2e_b31_PStart:1;
public:
bool PStart() const {return x2e_b31_PStart;}
bool PR() const {return x2e_b26_PR;}
bool PL() const {return x2e_b25_PL;}
bool PZ() const {return x2e_b24_PZ;}
bool PY() const {return x2d_b31_PY;}
bool PX() const {return x2d_b30_PX;}
bool PB() const {return x2d_b29_PB;}
bool PA() const {return x2d_b28_PA;}
bool PDPRight() const {return x2e_b28_PDPRight;}
bool PDPLeft() const {return x2e_b30_PDPLeft;}
bool PDPDown() const {return x2e_b29_PDPDown;}
bool PDPUp() const {return x2e_b27_PDPUp;}
bool PRTrigger() const {return x28_anaRightTriggerP > 0.050000001;}
bool PLTrigger() const {return x24_anaLeftTriggerP > 0.050000001;}
bool PRARight() const {return x22_enableAnaRightXP && x10_anaRightX > 0.69999999;}
bool PRALeft() const {return x22_enableAnaRightXP && x10_anaRightX < -0.69999999;}
bool PRADown() const {return x23_enableAnaRightYP && x14_anaRightY < -0.69999999;}
bool PRAUp() const {return x23_enableAnaRightYP && x14_anaRightY > 0.69999999;}
bool PLARight() const {return x20_enableAnaLeftXP && x8_anaLeftX > 0.69999999;}
bool PLALeft() const {return x20_enableAnaLeftXP && x8_anaLeftX < -0.69999999;}
bool PLADown() const {return x21_enableAnaLeftYP && xc_anaLeftY < -0.69999999;}
bool PLAUp() const {return x21_enableAnaLeftYP && xc_anaLeftY > 0.69999999;}
bool DStart() const {return x2d_b27_Start;}
bool DR() const {return x2c_b30_R;}
bool DL() const {return x2c_b29_L;}
bool DZ() const {return x2c_b28_Z;}
bool DY() const {return x2c_b27_Y;}
bool DX() const {return x2c_b26_X;}
bool DB() const {return x2c_b25_B;}
bool DA() const {return x2c_b24_A;}
bool DDPRight() const {return x2d_b24_DPRight;}
bool DDPLeft() const {return x2d_b26_DPLeft;}
bool DDPDown() const {return x2d_b25_DPDown;}
bool DDPUp() const {return x2c_b31_DPUp;}
bool DRTrigger() const {return x1c_anaRightTrigger > 050000001;}
bool DLTrigger() const {return x18_anaLeftTrigger > 050000001;}
bool DRARight() const {return x10_anaRightX > 0.69999999;}
bool DRALeft() const {return x10_anaRightX < -0.69999999;}
bool DRADown() const {return x14_anaRightY < -0.69999999;}
bool DRAUp() const {return x14_anaRightY > 0.69999999;}
bool DLARight() const {return x8_anaLeftX > 0.69999999;}
bool DLALeft() const {return x8_anaLeftX < -0.69999999;}
bool DLADown() const {return xc_anaLeftY < -0.69999999;}
bool DLAUp() const {return xc_anaLeftY > 0.69999999;}
float AStart() const {return x2d_b27_Start ? 1.0 : 0.0;}
float AR() const {return x2c_b30_R ? 1.0 : 0.0;}
float AL() const {return x2c_b29_L ? 1.0 : 0.0;}
float AZ() const {return x2c_b28_Z ? 1.0 : 0.0;}
float AY() const {return x2c_b27_Y ? 1.0 : 0.0;}
float AX() const {return x2c_b26_X ? 1.0 : 0.0;}
float AB() const {return x2c_b25_B ? 1.0 : 0.0;}
float AA() const {return x2c_b24_A ? 1.0 : 0.0;}
float ADPRight() const {return x2d_b24_DPRight ? 1.0 : 0.0;}
float ADPLeft() const {return x2d_b26_DPLeft ? 1.0 : 0.0;}
float ADPDown() const {return x2d_b25_DPDown ? 1.0 : 0.0;}
float ADPUp() const {return x2c_b31_DPUp ? 1.0 : 0.0;}
float ARTrigger() const {return x1c_anaRightTrigger;}
float ALTrigger() const {return x18_anaLeftTrigger;}
float ARARight() const {return x10_anaRightX > 0.0 ? x10_anaRightX : 0.0;}
float ARALeft() const {return x10_anaRightX < 0.0 ? -x10_anaRightX : 0.0;}
float ARADown() const {return x14_anaRightY < 0.0 ? -x14_anaRightY : 0.0;}
float ARAUp() const {return x14_anaRightY > 0.0 ? x14_anaRightY : 0.0;}
float ALARight() const {return x8_anaLeftX > 0.0 ? x8_anaLeftX : 0.0;}
float ALALeft() const {return x8_anaLeftX < 0.0 ? -x8_anaLeftX : 0.0;}
float ALADown() const {return xc_anaLeftY < 0.0 ? -xc_anaLeftY : 0.0;}
float ALAUp() const {return xc_anaLeftY > 0.0 ? xc_anaLeftY : 0.0;}
};
}

View File

@ -0,0 +1,8 @@
#include "CInputGenerator.hpp"
namespace Retro
{
}

View File

@ -1,11 +1,115 @@
#ifndef __RETRO_CINPUTGENERATOR_HPP__
#define __RETRO_CINPUTGENERATOR_HPP__
#include <boo/boo.hpp>
namespace Retro
{
class CInputGenerator
{
struct WindowCallback : boo::IWindowCallback
{
void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
{
fprintf(stderr, "Mouse Down %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]);
}
void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
{
fprintf(stderr, "Mouse Up %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]);
}
void mouseMove(const SWindowCoord& coord)
{
//fprintf(stderr, "Mouse Move (%f,%f)\n", coord.norm[0], coord.norm[1]);
}
void scroll(const SWindowCoord& coord, const SScrollDelta& scroll)
{
fprintf(stderr, "Mouse Scroll (%f,%f) (%f,%f)\n", coord.norm[0], coord.norm[1], scroll.delta[0], scroll.delta[1]);
}
void touchDown(const STouchCoord& coord, uintptr_t tid)
{
//fprintf(stderr, "Touch Down %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]);
}
void touchUp(const STouchCoord& coord, uintptr_t tid)
{
//fprintf(stderr, "Touch Up %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]);
}
void touchMove(const STouchCoord& coord, uintptr_t tid)
{
//fprintf(stderr, "Touch Move %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]);
}
void charKeyDown(unsigned long charCode, EModifierKey mods, bool isRepeat)
{
}
void charKeyUp(unsigned long charCode, EModifierKey mods)
{
}
void specialKeyDown(ESpecialKey key, EModifierKey mods, bool isRepeat)
{
}
void specialKeyUp(ESpecialKey key, EModifierKey mods)
{
}
void modKeyDown(EModifierKey mod, bool isRepeat)
{
}
void modKeyUp(EModifierKey mod)
{
}
} m_windowCb;
struct DolphinSmashAdapterCallback : boo::IDolphinSmashAdapterCallback
{
void controllerConnected(unsigned idx, boo::EDolphinControllerType)
{
printf("CONTROLLER %u CONNECTED\n", idx);
}
void controllerDisconnected(unsigned idx, boo::EDolphinControllerType)
{
printf("CONTROLLER %u DISCONNECTED\n", idx);
}
void controllerUpdate(unsigned idx, boo::EDolphinControllerType,
const boo::DolphinControllerState& state)
{
printf("CONTROLLER %u UPDATE %d %d\n", idx, state.m_leftStick[0], state.m_leftStick[1]);
}
};
class ApplicationDeviceFinder : public boo::DeviceFinder
{
std::unique_ptr<boo::DolphinSmashAdapter> smashAdapter = NULL;
DolphinSmashAdapterCallback m_cb;
public:
ApplicationDeviceFinder()
: boo::DeviceFinder({typeid(boo::DolphinSmashAdapter)})
{}
void deviceConnected(boo::DeviceToken& tok)
{
if (!smashAdapter)
{
smashAdapter.reset(dynamic_cast<boo::DolphinSmashAdapter*>(tok.openAndGetDevice()));
smashAdapter->setCallback(&m_cb);
smashAdapter->startRumble(0);
}
}
void deviceDisconnected(boo::DeviceToken&, boo::DeviceBase* device)
{
if (smashAdapter.get() == device)
smashAdapter.reset(nullptr);
}
};
};
}

View File

@ -0,0 +1,15 @@
#ifndef __RETRO_CKEYBOARDCONTROLLER_HPP__
#define __RETRO_CKEYBOARDCONTROLLER_HPP__
#include "IController.hpp"
namespace Retro
{
class CKeyboardController : public IController
{
};
}
#endif // __RETRO_CKEYBOARDCONTROLLER_HPP__

View File

@ -1,3 +1,8 @@
add_library(RuntimeCommonInput
IController.hpp
CDolphinController.hpp
CKeyboardController.hpp
CMouseController.hpp
ControlMapper.hpp ControlMapper.cpp
CInputGenerator.hpp CInputGenerator.cpp
CFinalInput.hpp CFinalInput.cpp)

View File

@ -0,0 +1,15 @@
#ifndef __RETRO_CMOUSECONTROLLER_HPP__
#define __RETRO_CMOUSECONTROLLER_HPP__
#include "IController.hpp"
namespace Retro
{
class CMouseController : public IController
{
};
}
#endif // __RETRO_CMOUSECONTROLLER_HPP__

View File

@ -0,0 +1,256 @@
#include "../RetroTypes.hpp"
#include "ControlMapper.hpp"
#include "CFinalInput.hpp"
#include "DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp"
#include "../GameGlobalObjects.hpp"
namespace Retro
{
static const char* skCommandDescs[] =
{
"Forward",
"Backward",
"Turn Left",
"Turn Right",
"Strafe Left",
"Strafe Right",
"Look Left",
"Look Right",
"Look Up",
"Look Down",
"Jump/Boost",
"Fire/Bomb",
"Missile/PowerBomb",
"Morph",
"Aim Up",
"Aim Down",
"Cycle Beam Up",
"Cycle Beam Down",
"Cycle Item",
"Power Beam",
"Ice Beam",
"Wave Beam",
"Plasma Beam",
"Toggle Holster",
"Orbit Close",
"Orbit Far",
"Orbit Object",
"Orbit Select",
"Orbit Confirm",
"Orbit Left",
"Orbit Right",
"Orbit Up",
"Orbit Down",
"Look Hold1",
"Look Hold2",
"Look Zoom In",
"Look Zoom Out",
"Aim Hold",
"Map Circle Up",
"Map Circle Down",
"Map Circle Left",
"Map Circle Right",
"Map Move Forward",
"Map Move Back",
"Map Move Left",
"Map Move Right",
"Map Zoom In",
"Map Zoom Out",
"SpiderBall",
"Chase Camera",
"XRay Visor",
"Thermo Visor",
"Enviro Visor",
"No Visor",
"Visor Menu",
"Visor Up",
"Visor Down",
"Use Shield",
"Scan Item",
"UNKNOWN"
};
static const char* skFunctionDescs[] =
{
"None",
"Left Stick Up",
"Left Stick Down",
"Left Stick Left",
"Left Stick Right",
"Right Stick Up",
"Right Stick Down",
"Right Stick Left",
"Right Stick Right",
"Left Trigger",
"Right Trigger",
"D-Pad Up ",
"D-Pad Down ",
"D-Pad Left ",
"D-Pad Right",
"A Button",
"B Button",
"X Button",
"Y Button",
"Z Button",
"Left Trigger Press",
"Right Trigger Press",
"Start"
};
typedef bool (CFinalInput::*BoolReturnFn)() const;
typedef float (CFinalInput::*FloatReturnFn)() const;
static BoolReturnFn skPressFuncs[] =
{
nullptr,
&CFinalInput::PLAUp,
&CFinalInput::PLADown,
&CFinalInput::PLALeft,
&CFinalInput::PLARight,
&CFinalInput::PRAUp,
&CFinalInput::PRADown,
&CFinalInput::PRALeft,
&CFinalInput::PRARight,
&CFinalInput::PLTrigger,
&CFinalInput::PRTrigger,
&CFinalInput::PDPUp,
&CFinalInput::PDPDown,
&CFinalInput::PDPLeft,
&CFinalInput::PDPRight,
&CFinalInput::PA,
&CFinalInput::PB,
&CFinalInput::PX,
&CFinalInput::PY,
&CFinalInput::PZ,
&CFinalInput::PL,
&CFinalInput::PR,
&CFinalInput::PStart,
nullptr
};
static BoolReturnFn skDigitalFuncs[] =
{
nullptr,
&CFinalInput::DLAUp,
&CFinalInput::DLADown,
&CFinalInput::DLALeft,
&CFinalInput::DLARight,
&CFinalInput::DRAUp,
&CFinalInput::DRADown,
&CFinalInput::DRALeft,
&CFinalInput::DRARight,
&CFinalInput::DLTrigger,
&CFinalInput::DRTrigger,
&CFinalInput::DDPUp,
&CFinalInput::DDPDown,
&CFinalInput::DDPLeft,
&CFinalInput::DDPRight,
&CFinalInput::DA,
&CFinalInput::DB,
&CFinalInput::DX,
&CFinalInput::DY,
&CFinalInput::DZ,
&CFinalInput::DL,
&CFinalInput::DR,
&CFinalInput::DStart,
nullptr
};
static FloatReturnFn skAnalogFuncs[] =
{
nullptr,
&CFinalInput::ALAUp,
&CFinalInput::ALADown,
&CFinalInput::ALALeft,
&CFinalInput::ALARight,
&CFinalInput::ARAUp,
&CFinalInput::ARADown,
&CFinalInput::ARALeft,
&CFinalInput::ARARight,
&CFinalInput::ALTrigger,
&CFinalInput::ARTrigger,
&CFinalInput::ADPUp,
&CFinalInput::ADPDown,
&CFinalInput::ADPLeft,
&CFinalInput::ADPRight,
&CFinalInput::AA,
&CFinalInput::AB,
&CFinalInput::AX,
&CFinalInput::AY,
&CFinalInput::AZ,
&CFinalInput::AL,
&CFinalInput::AR,
&CFinalInput::AStart,
nullptr
};
#define kCommandFilterCount 65
static bool skCommandFilterFlag[kCommandFilterCount];
void ControlMapper::SetCommandFiltered(ECommands cmd, bool filtered)
{
skCommandFilterFlag[cmd] = filtered;
}
void ControlMapper::ResetCommandFilters()
{
for (int i=0 ; i<kCommandFilterCount ; ++i)
skCommandFilterFlag[i] = true;
}
bool ControlMapper::GetPressInput(ECommands cmd, const CFinalInput& input)
{
if (!skCommandFilterFlag[cmd])
return false;
EFunctionList func = EFunctionList(g_tweakPlayerControl->GetMapping(cmd));
if (func > FuncMAX)
return false;
BoolReturnFn fn = skPressFuncs[func];
if (!fn)
return false;
return (input.*fn)();
}
bool ControlMapper::GetDigitalInput(ECommands cmd, const CFinalInput& input)
{
if (!skCommandFilterFlag[cmd])
return false;
EFunctionList func = EFunctionList(g_tweakPlayerControl->GetMapping(cmd));
if (func > FuncMAX)
return false;
BoolReturnFn fn = skDigitalFuncs[func];
if (!fn)
return false;
return (input.*fn)();
}
float ControlMapper::GetAnalogInput(ECommands cmd, const CFinalInput& input)
{
if (!skCommandFilterFlag[cmd])
return 0.0;
EFunctionList func = EFunctionList(g_tweakPlayerControl->GetMapping(cmd));
if (func > FuncMAX)
return 0.0;
FloatReturnFn fn = skAnalogFuncs[func];
if (!fn)
return 0.0;
return (input.*fn)();
}
const char* ControlMapper::GetDescriptionForCommand(ECommands cmd)
{
if (cmd > CmdMAX)
return nullptr;
return skCommandDescs[cmd];
}
const char* ControlMapper::GetDescriptionForFunction(EFunctionList func)
{
if (func > FuncMAX)
return nullptr;
return skFunctionDescs[func];
}
}

View File

@ -0,0 +1,115 @@
#ifndef __RETRO_CCONTROLMAPPER_HPP__
#define __RETRO_CCONTROLMAPPER_HPP__
namespace Retro
{
class CFinalInput;
class ControlMapper
{
public:
enum ECommands
{
CmdForward,
CmdBackward,
CmdTurnLeft,
CmdTurnRight,
CmdStrafeLeft,
CmdStrafeRight,
CmdLookLeft,
CmdLookRight,
CmdLookUp,
CmdLookDown,
CmdJumpOrBoost,
CmdFireOrBomb,
CmdMissileOrPowerBomb,
CmdMorph,
CmdAimUp,
CmdAimDown,
CmdCycleBeamUp,
CmdCycleBeamDown,
CmdCycleItem,
CmdPowerBeam,
CmdIceBeam,
CmdWaveBeam,
CmdPlasmaBeam,
CmdToggleHolster,
CmdOrbitClose,
CmdOrbitFar,
CmdOrbitObject,
CmdOrbitSelect,
CmdOrbitConfirm,
CmdOrbitLeft,
CmdOrbitRight,
CmdOrbitUp,
CmdOrbitDown,
CmdLookHold1,
CmdLookHold2,
CmdLookZoomIn,
CmdLookZoomOut,
CmdAimHold,
CmdMapCircleUp,
CmdMapCircleDown,
CmdMapCircleLeft,
CmdMapCircleRight,
CmdMapMoveForward,
CmdMapMoveBack,
CmdMapMoveLeft,
CmdMapMoveRight,
CmdMapZoomIn,
CmdMapZoomOut,
CmdChaseCamera,
CmdXrayVisor,
CmdThermoVisor,
CmdInviroVisor,
CmdNoVisor,
CmdVisorMenu,
CmdVisorUp,
CmdVisorDown,
CmdUseSheild,
CmdScanItem,
CmdUNKNOWN,
CmdNone,
CmdMAX
};
enum EFunctionList
{
FuncNone,
FuncLeftStickUp,
FuncLeftStickDown,
FuncLeftStickLeft,
FuncLeftStickRight,
FuncRightStickUp,
FuncRightStickDown,
FuncRightStickLeft,
FuncRightStickRight,
FuncLeftTrigger,
FuncRightTrigger,
FuncDPadUp,
FuncDPadDown,
FuncDPadLeft,
FuncDPadRight,
FuncAButton,
FuncBButton,
FuncXButton,
FuncYButton,
FuncZButton,
FuncLeftTriggerPress,
FuncRightTriggerPress,
FuncStart,
FuncMAX // default case
};
static void SetCommandFiltered(ECommands cmd, bool filtered);
static void ResetCommandFilters();
static bool GetPressInput(ECommands cmd, const CFinalInput& input);
static bool GetDigitalInput(ECommands cmd, const CFinalInput& input);
static float GetAnalogInput(ECommands cmd, const CFinalInput& input);
static const char* GetDescriptionForCommand(ECommands cmd);
static const char* GetDescriptionForFunction(EFunctionList func);
};
}
#endif // __RETRO_CCONTROLMAPPER_HPP__

View File

@ -0,0 +1,27 @@
#ifndef __RETRO_ICONTROLLER_HPP__
#define __RETRO_ICONTROLLER_HPP__
namespace Retro
{
class IController
{
public:
class CControllerAxis
{
};
class CControllerButton
{
};
class IControllerGamepadData
{
};
void Poll();
u32 GetDeviceCount();
};
}
#endif // __RETRO_ICONTROLLER_HPP__

View File

@ -1,7 +1,7 @@
#ifndef __RETRO_CMAIN_HPP__
#define __RETRO_CMAIN_HPP__
#include "COsContext.hpp"
#include <boo/boo.hpp>
#include "CMemory.hpp"
#include "CTweaks.hpp"
#include "CPlayMovie.hpp"
@ -21,12 +21,35 @@ enum EGameplayResult
GameplayResultPlaying
};
class CMain : public COsContext
{
class CMain : public boo::IApplicationCallback
{
boo::IWindow* mainWindow = NULL;
#if 0
ApplicationDeviceFinder devFinder;
WindowCallback windowCallback;
void appLaunched(boo::IApplication* app)
{
mainWindow = app->newWindow("YAY!");
mainWindow->setCallback(&windowCallback);
mainWindow->showWindow();
devFinder.startScanning();
}
void appQuitting(boo::IApplication*)
{}
void appFilesOpen(boo::IApplication*, const std::vector<std::string>& paths)
{
fprintf(stderr, "OPENING: ");
for (const std::string& path : paths)
fprintf(stderr, "%s ", path.c_str());
fprintf(stderr, "\n");
}
#endif
CMemorySys x6c_memSys;
CTweaks x70_tweaks;
EGameplayResult xe4_gameplayResult;
bool xe8_finished = false;
public:
CMain();
void RegisterResourceTweaks();

View File

@ -16,15 +16,15 @@ void CMainFlow::AdvanceGameState(CArchitectureQueue& queue)
{
switch (x14_gameState)
{
case ClientStateFrontEnd:
SetGameState(ClientStateGameLoad, queue);
case ClientFlowFrontEnd:
CMainFlow::SetGameState(ClientFlowGameLoad, queue);
break;
case ClientStateUnspecified:
case ClientStateGameLoad:
SetGameState(ClientStateMoviePlay, queue);
case ClientFlowUnspecified:
case ClientFlowGameLoad:
CMainFlow::SetGameState(ClientFlowMoviePlay, queue);
break;
case ClientStateMoviePlay:
SetGameState(ClientStateFrontEnd, queue);
case ClientFlowMoviePlay:
CMainFlow::SetGameState(ClientFlowFrontEnd, queue);
break;
}
}
@ -33,7 +33,7 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
{
switch (state)
{
case ClientStateFrontEnd:
case ClientFlowFrontEnd:
{
if (g_main->GetGameplayResult() == GameplayResultNone)
{
@ -48,12 +48,12 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
queue.Push(std::move(MakeMsg::CreateCreateIOWin(TargetIOWinManager, 12, 11, new CFrontEndUI(queue))));
break;
}
case ClientStateGameLoad:
case ClientFlowGameLoad:
{
queue.Push(std::move(MakeMsg::CreateCreateIOWin(TargetIOWinManager, 10, 1000, new CMFGameLoader())));
break;
}
case ClientStateMoviePlay:
case ClientFlowMoviePlay:
{
switch (g_main->GetGameplayResult())
{

View File

@ -1,12 +1,36 @@
#include <LogVisor/LogVisor.hpp>
#include "CTweaks.hpp"
#include "CResFactory.hpp"
#include "CResLoader.hpp"
#include "GameGlobalObjects.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayerControl.hpp"
namespace Retro
{
ITweakPlayerControl* g_tweakPlayerControl = nullptr;
namespace MP1
{
LogVisor::LogModule Log("MP1::CTweaks");
static const SObjectTag& IDFromFactory(CResFactory& factory, const char* name)
{
const SObjectTag* tag = factory.GetResourceIdByName(name);
if (!tag)
Log.report(LogVisor::FatalError, "Tweak Asset not found when loading... '%s'", name);
return *tag;
}
void CTweaks::RegisterTweaks()
{
CResFactory& factory = *g_ResFactory;
CResLoader& loader = factory.GetLoader();
std::unique_ptr<CInputStream> strm;
strm.reset(loader.LoadNewResourceSync(IDFromFactory(factory, "PlayerControls"), nullptr));
TOneStatic<DNAMP1::CTweakPlayerControl> playerControl(*strm);
g_tweakPlayerControl = playerControl.GetAllocSpace();
}
void CTweaks::RegisterResourceTweaks()

View File

@ -57,10 +57,10 @@ class CGameGlobalObjects
{
}
static CBooRenderer*
AllocateRenderer(IObjectStore& store, COsContext& osctx,
AllocateRenderer(IObjectStore& store,
CMemorySys& memSys, CResFactory& resFactory)
{
g_Renderer = new CBooRenderer(store, osctx, memSys, resFactory);
g_Renderer = new CBooRenderer(store, memSys, resFactory);
return g_Renderer;
}
@ -77,11 +77,11 @@ public:
g_TweakManager = &m_tweakManager;
}
void PostInitialize(COsContext& osctx, CMemorySys& memSys)
void PostInitialize(CMemorySys& memSys)
{
AddPaksAndFactories();
LoadStringTable();
m_renderer.reset(AllocateRenderer(m_simplePool, osctx, memSys, m_resFactory));
m_renderer.reset(AllocateRenderer(m_simplePool, memSys, m_resFactory));
}
};
@ -97,7 +97,7 @@ class CGameArchitectureSupport
CConsoleOutputWindow m_consoleWindow;
CAudioStateWin m_audioStateWin;
public:
CGameArchitectureSupport(COsContext& osctx)
CGameArchitectureSupport()
: m_audioSys(0,0,0,0,0)
{
}
@ -109,9 +109,8 @@ public:
};
CMain::CMain()
: x6c_memSys(*this, CMemorySys::GetGameAllocator())
: x6c_memSys(CMemorySys::GetGameAllocator())
{
OpenWindow("", 0, 0, 640, 480);
g_main = this;
xe4_gameplayResult = GameplayResultPlaying;
}
@ -140,12 +139,12 @@ int CMain::RsMain(int argc, const char* argv[])
{
TOneStatic<CGameGlobalObjects> globalObjs;
InitializeSubsystems();
globalObjs->PostInitialize(*this, x6c_memSys);
globalObjs->PostInitialize(x6c_memSys);
x70_tweaks.RegisterTweaks();
AddWorldPaks();
g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs();
TOneStatic<CGameArchitectureSupport> archSupport(*this);
TOneStatic<CGameArchitectureSupport> archSupport;
while (!xe8_finished)
{
xe8_finished = archSupport->Update();
@ -156,138 +155,11 @@ int CMain::RsMain(int argc, const char* argv[])
}
}
struct WindowCallback : boo::IWindowCallback
{
void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
{
fprintf(stderr, "Mouse Down %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]);
}
void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
{
fprintf(stderr, "Mouse Up %d (%f,%f)\n", button, coord.norm[0], coord.norm[1]);
}
void mouseMove(const SWindowCoord& coord)
{
//fprintf(stderr, "Mouse Move (%f,%f)\n", coord.norm[0], coord.norm[1]);
}
void scroll(const SWindowCoord& coord, const SScrollDelta& scroll)
{
fprintf(stderr, "Mouse Scroll (%f,%f) (%f,%f)\n", coord.norm[0], coord.norm[1], scroll.delta[0], scroll.delta[1]);
}
void touchDown(const STouchCoord& coord, uintptr_t tid)
{
//fprintf(stderr, "Touch Down %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]);
}
void touchUp(const STouchCoord& coord, uintptr_t tid)
{
//fprintf(stderr, "Touch Up %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]);
}
void touchMove(const STouchCoord& coord, uintptr_t tid)
{
//fprintf(stderr, "Touch Move %16lX (%f,%f)\n", tid, coord.coord[0], coord.coord[1]);
}
void charKeyDown(unsigned long charCode, EModifierKey mods, bool isRepeat)
{
}
void charKeyUp(unsigned long charCode, EModifierKey mods)
{
}
void specialKeyDown(ESpecialKey key, EModifierKey mods, bool isRepeat)
{
}
void specialKeyUp(ESpecialKey key, EModifierKey mods)
{
}
void modKeyDown(EModifierKey mod, bool isRepeat)
{
}
void modKeyUp(EModifierKey mod)
{
}
};
struct DolphinSmashAdapterCallback : boo::IDolphinSmashAdapterCallback
{
void controllerConnected(unsigned idx, boo::EDolphinControllerType)
{
printf("CONTROLLER %u CONNECTED\n", idx);
}
void controllerDisconnected(unsigned idx, boo::EDolphinControllerType)
{
printf("CONTROLLER %u DISCONNECTED\n", idx);
}
void controllerUpdate(unsigned idx, boo::EDolphinControllerType,
const boo::DolphinControllerState& state)
{
printf("CONTROLLER %u UPDATE %d %d\n", idx, state.m_leftStick[0], state.m_leftStick[1]);
}
};
class ApplicationDeviceFinder : public boo::DeviceFinder
{
std::unique_ptr<boo::DolphinSmashAdapter> smashAdapter = NULL;
DolphinSmashAdapterCallback m_cb;
public:
ApplicationDeviceFinder()
: boo::DeviceFinder({typeid(boo::DolphinSmashAdapter)})
{}
void deviceConnected(boo::DeviceToken& tok)
{
if (!smashAdapter)
{
smashAdapter.reset(dynamic_cast<boo::DolphinSmashAdapter*>(tok.openAndGetDevice()));
smashAdapter->setCallback(&m_cb);
smashAdapter->startRumble(0);
}
}
void deviceDisconnected(boo::DeviceToken&, boo::DeviceBase* device)
{
if (smashAdapter.get() == device)
smashAdapter.reset(nullptr);
}
};
struct ApplicationCallback : boo::IApplicationCallback
{
boo::IWindow* mainWindow = NULL;
ApplicationDeviceFinder devFinder;
WindowCallback windowCallback;
void appLaunched(boo::IApplication* app)
{
mainWindow = app->newWindow("YAY!");
mainWindow->setCallback(&windowCallback);
mainWindow->showWindow();
devFinder.startScanning();
}
void appQuitting(boo::IApplication*)
{
delete mainWindow;
}
void appFilesOpen(boo::IApplication*, const std::vector<std::string>& paths)
{
fprintf(stderr, "OPENING: ");
for (const std::string& path : paths)
fprintf(stderr, "%s ", path.c_str());
fprintf(stderr, "\n");
}
};
int main(int argc, const char* argv[])
{
Retro::TOneStatic<ApplicationCallback> appCB;
std::unique_ptr<boo::IApplication> app =
boo::ApplicationBootstrap(boo::IApplication::PLAT_AUTO, *appCB,
"mp1", "MP1", argc, argv);
Retro::TOneStatic<Retro::MP1::CMain> main;
std::unique_ptr<boo::IApplication> app =
boo::ApplicationBootstrap(boo::IApplication::PLAT_AUTO, *main,
"mp1", "MP1", argc, argv);
return main->RsMain(argc, argv);
}

2
libBoo

@ -1 +1 @@
Subproject commit d69e76d911198e060b825000cc4e8ce9273df537
Subproject commit 12e5948d3178df7f689d9676e103760dbb89d07d