Remove optional.hpp dependency

This commit is contained in:
Jack Andersen 2017-12-06 18:09:57 -10:00
parent b1f9b08d25
commit 34860de248
2 changed files with 12 additions and 8 deletions

View File

@ -3,7 +3,6 @@
#include "Common.hpp"
#include "Socket.hpp"
#include "optional.hpp"
#include <thread>
#include <mutex>
#include <condition_variable>
@ -67,6 +66,7 @@ class Endpoint
s32 x60_gameId;
u32 x64_totalBytes;
bool m_started = true;
bool m_initialized = false;
void _0Reset(ThreadLocalEndpoint& endpoint, EJoyReturn status);
void _1GetStatus(ThreadLocalEndpoint& endpoint, EJoyReturn status);
@ -86,6 +86,7 @@ class Endpoint
}
public:
KawasedoChallenge() = default;
KawasedoChallenge(Endpoint& endpoint, s32 paletteColor, s32 paletteSpeed,
const u8* programp, s32 length, u8* status, FGBACallback&& callback);
bool started() const { return m_started; }
@ -96,6 +97,7 @@ class Endpoint
return x34_bytesSent * 100 / x64_totalBytes;
}
bool isDone() const { return !x14_callback; }
operator bool() const { return m_initialized; }
};
friend class ThreadLocalEndpoint;
@ -117,7 +119,7 @@ class Endpoint
std::mutex m_syncLock;
std::condition_variable m_syncCv;
std::condition_variable m_issueCv;
std::experimental::optional<KawasedoChallenge> m_joyBoot;
KawasedoChallenge m_joyBoot;
FGBACallback m_callback;
u8 m_buffer[5];
u8* m_readDstPtr = nullptr;

View File

@ -5,6 +5,8 @@
namespace jbus
{
#define ROUND_UP_8(val) (((val) + 7) & ~7)
void Endpoint::KawasedoChallenge::DSPSecParms::ProcessGBACrypto()
{
/* Unwrap key from challenge using 'sedo' magic number (to encrypt JoyBoot program) */
@ -389,7 +391,7 @@ void Endpoint::KawasedoChallenge::_8BootDone(ThreadLocalEndpoint& endpoint, EJoy
Endpoint::KawasedoChallenge::KawasedoChallenge(Endpoint& endpoint, s32 paletteColor, s32 paletteSpeed,
const u8* programp, s32 length, u8* status, FGBACallback&& callback)
: x0_pColor(paletteColor), x4_pSpeed(paletteSpeed), x8_progPtr(programp), xc_progLen(length),
x10_statusPtr(status), x14_callback(std::move(callback)), x34_bytesSent(0)
x10_statusPtr(status), x14_callback(std::move(callback)), x34_bytesSent(0), m_initialized(true)
{
if (endpoint.GBAGetStatusAsync(x10_statusPtr,
bindThis(&KawasedoChallenge::_0Reset)) != GBA_READY)
@ -608,8 +610,8 @@ EJoyReturn Endpoint::GBAGetProcessStatus(u8& percentOut)
std::unique_lock<std::mutex> lk(m_syncLock);
if (m_joyBoot)
{
percentOut = m_joyBoot->percentComplete();
if (!m_joyBoot->isDone())
percentOut = m_joyBoot.percentComplete();
if (!m_joyBoot.isDone())
return GBA_BUSY;
}
@ -803,9 +805,9 @@ EJoyReturn Endpoint::GBAJoyBootAsync(s32 paletteColor, s32 paletteSpeed,
if (programp[0xac] * programp[0xac] * programp[0xac] * programp[0xac] == 0)
return GBA_JOYBOOT_ERR_INVALID;
m_joyBoot.emplace(*this, paletteColor, paletteSpeed, programp, length, status,
std::move(callback));
if (!m_joyBoot->started())
m_joyBoot = KawasedoChallenge(*this, paletteColor, paletteSpeed, programp, length, status,
std::move(callback));
if (!m_joyBoot.started())
return GBA_NOT_READY;
return GBA_READY;