Merge pull request #50 from lioncash/jbus

General: Amend relevant code to compile with jbus changes
This commit is contained in:
Phillip Stephens 2019-09-03 23:12:06 -07:00 committed by GitHub
commit a1819ca079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 29 deletions

View File

@ -1,8 +1,12 @@
#include "CGBASupport.hpp" #include "CGBASupport.hpp"
#include "CDvdRequest.hpp"
#include <cstring>
#include "CBasics.hpp" #include "CBasics.hpp"
#include "jbus/Listener.hpp" #include "CDvdRequest.hpp"
#include "jbus/Endpoint.hpp"
#include <jbus/Endpoint.hpp>
#include <jbus/Listener.hpp>
namespace urde::MP1 { namespace urde::MP1 {
@ -65,19 +69,27 @@ bool CGBASupport::PollResponse() {
if (status != (jbus::GBA_JSTAT_PSF1 | jbus::GBA_JSTAT_SEND)) if (status != (jbus::GBA_JSTAT_PSF1 | jbus::GBA_JSTAT_SEND))
return false; return false;
u8 bytes[4]; jbus::ReadWriteBuffer bytes;
if (g_JbusEndpoint->GBARead(bytes, &status) == jbus::GBA_NOT_READY) if (g_JbusEndpoint->GBARead(bytes, &status) == jbus::GBA_NOT_READY) {
return false;
if (reinterpret_cast<u32&>(bytes) != SBIG('AMTE'))
return false; return false;
}
if (g_JbusEndpoint->GBAGetStatus(&status) == jbus::GBA_NOT_READY) u32 bytesU32;
return false; std::memcpy(&bytesU32, bytes.data(), sizeof(bytes));
if (status != jbus::GBA_JSTAT_PSF1) if (bytesU32 != SBIG('AMTE')) {
return false; return false;
}
if (g_JbusEndpoint->GBAWrite((unsigned char*)"AMTE", &status) == jbus::GBA_NOT_READY) if (g_JbusEndpoint->GBAGetStatus(&status) == jbus::GBA_NOT_READY) {
return false; return false;
}
if (status != jbus::GBA_JSTAT_PSF1) {
return false;
}
if (g_JbusEndpoint->GBAWrite({'A', 'M', 'T', 'E'}, &status) == jbus::GBA_NOT_READY) {
return false;
}
if (g_JbusEndpoint->GBAGetStatus(&status) == jbus::GBA_NOT_READY) if (g_JbusEndpoint->GBAGetStatus(&status) == jbus::GBA_NOT_READY)
return false; return false;
@ -103,11 +115,13 @@ bool CGBASupport::PollResponse() {
break; break;
} }
if (g_JbusEndpoint->GBARead(bytes, &status) != jbus::GBA_READY) if (g_JbusEndpoint->GBARead(bytes, &status) != jbus::GBA_READY) {
return false; return false;
}
if (bytes[3] != CalculateFusionJBusChecksum(bytes, 3)) if (bytes[3] != CalculateFusionJBusChecksum(bytes.data(), 3)) {
return false; return false;
}
x44_fusionLinked = (bytes[2] & 0x2) == 0; x44_fusionLinked = (bytes[2] & 0x2) == 0;
if (x44_fusionLinked && (bytes[2] & 0x1) != 0) if (x44_fusionLinked && (bytes[2] & 0x1) != 0)

View File

@ -1,11 +1,12 @@
#include <cstdio> #include <cstdio>
#include "GCNTypes.hpp" #include <cstring>
#include <memory> #include <memory>
#include <thread>
#include <queue>
#include <optional> #include <optional>
#include "jbus/Endpoint.hpp"
#include "jbus/Listener.hpp" #include "GCNTypes.hpp"
#include <jbus/Endpoint.hpp>
#include <jbus/Listener.hpp>
#undef min #undef min
#undef max #undef max
@ -97,24 +98,34 @@ bool CGBASupport::PollResponse() {
if (status != (jbus::GBA_JSTAT_PSF1 | jbus::GBA_JSTAT_SEND)) if (status != (jbus::GBA_JSTAT_PSF1 | jbus::GBA_JSTAT_SEND))
return false; return false;
u8 bytes[4]; jbus::ReadWriteBuffer bytes;
if (m_endpoint->GBARead(bytes, &status) == jbus::GBA_NOT_READY) if (m_endpoint->GBARead(bytes, &status) == jbus::GBA_NOT_READY) {
return false;
if (reinterpret_cast<u32&>(bytes) != SBIG('AMTE'))
return false; return false;
}
if (m_endpoint->GBAGetStatus(&status) == jbus::GBA_NOT_READY) u32 bytesU32;
return false; std::memcpy(&bytesU32, bytes.data(), sizeof(bytes));
if (status != jbus::GBA_JSTAT_PSF1) if (bytesU32 != SBIG('AMTE')) {
return false; return false;
}
if (m_endpoint->GBAWrite((unsigned char*)"AMTE", &status) == jbus::GBA_NOT_READY) if (m_endpoint->GBAGetStatus(&status) == jbus::GBA_NOT_READY) {
return false; return false;
}
if (status != jbus::GBA_JSTAT_PSF1) {
return false;
}
if (m_endpoint->GBAGetStatus(&status) == jbus::GBA_NOT_READY) if (m_endpoint->GBAWrite({'A', 'M', 'T', 'E'}, &status) == jbus::GBA_NOT_READY) {
return false; return false;
if ((status & jbus::GBA_JSTAT_FLAGS_MASK) != jbus::GBA_JSTAT_FLAGS_MASK) }
if (m_endpoint->GBAGetStatus(&status) == jbus::GBA_NOT_READY) {
return false; return false;
}
if ((status & jbus::GBA_JSTAT_FLAGS_MASK) != jbus::GBA_JSTAT_FLAGS_MASK) {
return false;
}
u64 profStart = jbus::GetGCTicks(); u64 profStart = jbus::GetGCTicks();
const u64 timeToSpin = jbus::GetGCTicksPerSec() / 8000; const u64 timeToSpin = jbus::GetGCTicksPerSec() / 8000;
@ -138,7 +149,7 @@ bool CGBASupport::PollResponse() {
if (m_endpoint->GBARead(bytes, &status) != jbus::GBA_READY) if (m_endpoint->GBARead(bytes, &status) != jbus::GBA_READY)
return false; return false;
if (bytes[3] != CalculateFusionJBusChecksum(bytes, 3)) if (bytes[3] != CalculateFusionJBusChecksum(bytes.data(), 3))
return false; return false;
x44_fusionLinked = (bytes[2] & 0x2) == 0; x44_fusionLinked = (bytes[2] & 0x2) == 0;