SilentPatch/SilentPatch/TheFLAUtils.h

78 lines
1.5 KiB
C
Raw Normal View History

2017-06-19 23:00:02 +05:00
#pragma once
#include <cstdint>
class FLAUtils
{
public:
class int8
2017-06-19 23:00:02 +05:00
{
2017-09-09 23:46:10 +05:00
public:
inline int32_t Get() const
{
return GetExtendedID8Func( &value );
}
private:
int8() = delete;
int8& operator =( const int8& ) = delete;
uint8_t value;
};
class int16
{
2017-09-09 23:46:10 +05:00
public:
inline int32_t Get() const
{
return GetExtendedID16Func( &value );
}
private:
int16() = delete;
int16& operator =( const int16& ) = delete;
uint16_t value;
};
2018-04-25 02:39:44 +05:00
using CdStreamWakeFunc = void(*)( struct CdStream* );
2017-09-26 21:03:13 +05:00
2018-04-25 02:39:44 +05:00
static void Init( const class ModuleList& moduleList );
static bool UsesEnhancedIMGs();
2017-06-19 23:00:02 +05:00
2017-09-26 21:03:13 +05:00
static void SetCdStreamWakeFunction( CdStreamWakeFunc func )
{
if ( SetCdStreamWakeFunc != nullptr )
{
SetCdStreamWakeFunc( func );
}
}
static bool CdStreamRaceConditionAware()
{
return SetCdStreamWakeFunc != nullptr;
}
2017-06-19 23:00:02 +05:00
private:
static constexpr int32_t MAX_UINT8_ID = 0xFF;
static constexpr int32_t MAX_UINT16_ID = 0xFFFD;
2017-09-09 23:46:10 +05:00
static int32_t GetExtendedID8_Stock(const uint8_t* ptr)
{
2017-09-09 23:46:10 +05:00
const uint8_t uID = *ptr;
return uID != MAX_UINT8_ID ? uID : -1;
}
2017-06-19 23:00:02 +05:00
2017-09-09 23:46:10 +05:00
static int32_t GetExtendedID16_Stock(const uint16_t* ptr)
2017-06-20 23:35:35 +05:00
{
2017-09-09 23:46:10 +05:00
const uint16_t uID = *ptr;
return uID <= MAX_UINT16_ID ? uID : *reinterpret_cast<const int16_t*>(ptr);
2017-06-20 23:35:35 +05:00
}
2017-09-09 23:46:10 +05:00
static int32_t (*GetExtendedID8Func)(const uint8_t* ptr);
static int32_t (*GetExtendedID16Func)(const uint16_t* ptr);
2017-09-26 21:03:13 +05:00
static void (*SetCdStreamWakeFunc)(CdStreamWakeFunc func);
2017-09-09 23:46:10 +05:00
static_assert( sizeof(int8) == sizeof(uint8_t) );
static_assert( sizeof(int16) == sizeof(uint16_t) );
2017-06-19 23:00:02 +05:00
};