summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2015-09-12 02:15:59 -0400
committerRyan Houdek <Sonicadvance1@gmail.com>2015-09-12 02:15:59 -0400
commit2e6db7dc278c2ba1d95d58c7e7fc490e5c68e14b (patch)
treeea2aa2df6da90bc6c23d7a018c802d22eb9a641f /Source/Core
parent17ff069d4a1fe7e6b1e6091ded8d10c2e4c79945 (diff)
parentec3d55b093866e86b83ea8639a59d672df465a9d (diff)
Merge pull request #2991 from lioncash/pcast
EXI_DeviceIPL: Get rid of a pointer cast
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/EXI_DeviceIPL.cpp33
-rw-r--r--Source/Core/Core/HW/EXI_DeviceIPL.h2
2 files changed, 21 insertions, 14 deletions
diff --git a/Source/Core/Core/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI_DeviceIPL.cpp
index 246903eae9..36962bd826 100644
--- a/Source/Core/Core/HW/EXI_DeviceIPL.cpp
+++ b/Source/Core/Core/HW/EXI_DeviceIPL.cpp
@@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include <cstring>
+
#include "Common/ChunkFile.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
@@ -170,6 +172,21 @@ void CEXIIPL::SetCS(int _iCS)
}
}
+void CEXIIPL::UpdateRTC()
+{
+ // Seconds between 1.1.2000 and 4.1.2008 16:00:38
+ static constexpr u32 WII_BIAS = 0x0F1114A6;
+
+ u32 rtc;
+
+ if (SConfig::GetInstance().bWii)
+ rtc = Common::swap32(GetGCTime() - WII_BIAS);
+ else
+ rtc = Common::swap32(GetGCTime());
+
+ std::memcpy(m_RTC, &rtc, sizeof(u32));
+}
+
bool CEXIIPL::IsPresent() const
{
return true;
@@ -177,9 +194,6 @@ bool CEXIIPL::IsPresent() const
void CEXIIPL::TransferByte(u8& _uByte)
{
- // Seconds between 1.1.2000 and 4.1.2008 16:00:38
- const u32 cWiiBias = 0x0F1114A6;
-
// The first 4 bytes must be the address
// If we haven't read it, do it now
if (m_uPosition <= 3)
@@ -192,17 +206,8 @@ void CEXIIPL::TransferByte(u8& _uByte)
// Check if the command is complete
if (m_uPosition == 3)
{
- // Get the time ...
- u32 &rtc = *((u32 *)&m_RTC);
- if (SConfig::GetInstance().bWii)
- {
- // Subtract Wii bias
- rtc = Common::swap32(CEXIIPL::GetGCTime() - cWiiBias);
- }
- else
- {
- rtc = Common::swap32(CEXIIPL::GetGCTime());
- }
+ // Get the time...
+ UpdateRTC();
// Log the command
std::string device_name;
diff --git a/Source/Core/Core/HW/EXI_DeviceIPL.h b/Source/Core/Core/HW/EXI_DeviceIPL.h
index 25bb53c9b9..40af936de2 100644
--- a/Source/Core/Core/HW/EXI_DeviceIPL.h
+++ b/Source/Core/Core/HW/EXI_DeviceIPL.h
@@ -64,6 +64,8 @@ private:
std::string m_buffer;
bool m_FontsLoaded;
+ void UpdateRTC();
+
void TransferByte(u8& _uByte) override;
bool IsWriteCommand() const { return !!(m_uAddress & (1 << 31)); }
u32 CommandRegion() const { return (m_uAddress & ~(1 << 31)) >> 8; }