summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2018-09-30 20:34:22 -0700
committerShawn Hoffman <godisgovernment@gmail.com>2018-10-01 00:00:20 -0700
commit2a0f022da3cd288dec45e01750f9ba54ea9a7879 (patch)
tree42615957f3393fc2ad245a4b7deef9c8e5d2e0ae /Source/Core
parentd300f3bbbc4ea47b5e074efe2a5348ac5c0b2987 (diff)
mx sram: replace union-with-byte-array with operator[] to make gcc happy.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp4
-rw-r--r--Source/Core/Core/HW/Sram.cpp23
-rw-r--r--Source/Core/Core/HW/Sram.h18
-rw-r--r--Source/Core/Core/NetPlayServer.cpp2
4 files changed, 28 insertions, 19 deletions
diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp
index b30bf5b569..6839ec92ef 100644
--- a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp
+++ b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp
@@ -341,9 +341,9 @@ void CEXIIPL::TransferByte(u8& data)
{
u32 dev_addr = DEV_ADDR_CURSOR(SRAM);
if (m_command.is_write())
- g_SRAM.raw[dev_addr] = data;
+ g_SRAM[dev_addr] = data;
else
- data = g_SRAM.raw[dev_addr];
+ data = g_SRAM[dev_addr];
}
else if (IN_RANGE(UART))
{
diff --git a/Source/Core/Core/HW/Sram.cpp b/Source/Core/Core/HW/Sram.cpp
index cafc5e2f5c..51ce971230 100644
--- a/Source/Core/Core/HW/Sram.cpp
+++ b/Source/Core/Core/HW/Sram.cpp
@@ -10,13 +10,22 @@
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
-// english
-const Sram sram_dump = {{0, 0, 0, 0, 0x00, 0x2C, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C,
- 0x44, 0x4F, 0x4C, 0x50, 0x48, 0x49, 0x4E, 0x53, 0x4C, 0x4F, 0x54, 0x41,
- 0x44, 0x4F, 0x4C, 0x50, 0x48, 0x49, 0x4E, 0x53, 0x4C, 0x4F, 0x54, 0x42,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x6E, 0x6D, 0x00, 0x00, 0x00, 0x00}};
+// English
+// This is just a template. Most/all fields are updated with sane(r) values at runtime.
+const Sram sram_dump = {Common::BigEndianValue<u32>{0},
+ {Common::BigEndianValue<u16>{0x2c}, Common::BigEndianValue<u16>{0xffd0}, 0,
+ 0, 0, 0, 0, 0, 0x20 | SramFlags::kOobeDone | SramFlags::kStereo},
+ {{
+ {'D', 'O', 'L', 'P', 'H', 'I', 'N', 'S', 'L', 'O', 'T', 'A'},
+ {'D', 'O', 'L', 'P', 'H', 'I', 'N', 'S', 'L', 'O', 'T', 'B'},
+ },
+ 0,
+ {},
+ 0,
+ 0,
+ {0x6E, 0x6D},
+ 0,
+ {}}};
#if 0
// german
diff --git a/Source/Core/Core/HW/Sram.h b/Source/Core/Core/HW/Sram.h
index ae2b156b4c..624ee86bf5 100644
--- a/Source/Core/Core/HW/Sram.h
+++ b/Source/Core/Core/HW/Sram.h
@@ -114,17 +114,17 @@ struct SramSettingsEx
u8 field_3e[2];
};
-union Sram
+struct Sram
{
- // TODO determine real full sram size for gc/wii
- u8 raw[0x44];
- struct
- {
- Common::BigEndianValue<u32> rtc;
- SramSettings settings;
- SramSettingsEx settings_ex;
- };
+ Common::BigEndianValue<u32> rtc;
+ SramSettings settings;
+ SramSettingsEx settings_ex;
+ // Allow access to this entire structure as a raw blob
+ // Typical union-with-byte-array method can't be used here on GCC
+ u8& operator[](size_t offset) { return reinterpret_cast<u8*>(&rtc)[offset]; }
};
+// TODO determine real full sram size for gc/wii
+static_assert(sizeof(Sram) == 0x44);
#pragma pack(pop)
diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp
index 56be7a7c97..8c5fa6eb3d 100644
--- a/Source/Core/Core/NetPlayServer.cpp
+++ b/Source/Core/Core/NetPlayServer.cpp
@@ -353,7 +353,7 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket)
spac << static_cast<MessageId>(NP_MSG_SYNC_GC_SRAM);
for (size_t i = 0; i < sizeof(g_SRAM) - offsetof(Sram, settings); ++i)
{
- spac << g_SRAM.raw[offsetof(Sram, settings) + i];
+ spac << g_SRAM[offsetof(Sram, settings) + i];
}
Send(player.socket, spac);