mx sram: fix checksum calc; use Common::BigEndianValue for rtc field.
This commit is contained in:
parent
cd29cdb584
commit
2cd96aa5bb
|
@ -127,7 +127,7 @@ CEXIIPL::CEXIIPL()
|
|||
}
|
||||
|
||||
// Clear RTC
|
||||
memset(g_SRAM.rtc, 0, sizeof(g_SRAM.rtc));
|
||||
g_SRAM.rtc = 0;
|
||||
|
||||
// We Overwrite language selection here since it's possible on the GC to change the language as
|
||||
// you please
|
||||
|
@ -250,8 +250,7 @@ void CEXIIPL::SetCS(int cs)
|
|||
|
||||
void CEXIIPL::UpdateRTC()
|
||||
{
|
||||
const u32 rtc = Common::swap32(GetEmulatedTime(GC_EPOCH));
|
||||
std::memcpy(g_SRAM.rtc, &rtc, sizeof(u32));
|
||||
g_SRAM.rtc = GetEmulatedTime(GC_EPOCH);
|
||||
}
|
||||
|
||||
bool CEXIIPL::IsPresent() const
|
||||
|
|
|
@ -78,14 +78,16 @@ void SetCardFlashID(const u8* buffer, u8 card_index)
|
|||
|
||||
void FixSRAMChecksums()
|
||||
{
|
||||
// 16bit big-endian additive checksum
|
||||
u16 checksum = 0;
|
||||
u16 checksum_inv = 0;
|
||||
for (auto p = reinterpret_cast<u16*>(&g_SRAM.settings.rtc_bias);
|
||||
p != reinterpret_cast<u16*>(&g_SRAM.settings_ex); p++)
|
||||
{
|
||||
checksum += *p;
|
||||
checksum_inv += ~*p;
|
||||
u16 value = Common::FromBigEndian(*p);
|
||||
checksum += value;
|
||||
checksum_inv += ~value;
|
||||
}
|
||||
g_SRAM.settings.checksum = Common::swap16(checksum);
|
||||
g_SRAM.settings.checksum_inv = Common::swap16(checksum_inv);
|
||||
g_SRAM.settings.checksum = checksum;
|
||||
g_SRAM.settings.checksum_inv = checksum_inv;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ distribution.
|
|||
|
||||
#include <array>
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Swap.h"
|
||||
|
||||
using CardFlashId = std::array<u8, 12>;
|
||||
|
||||
|
@ -79,8 +80,8 @@ struct SramFlags
|
|||
struct SramSettings
|
||||
{
|
||||
// checksum covers [rtc_bias, flags]
|
||||
u16 checksum;
|
||||
u16 checksum_inv;
|
||||
Common::BigEndianValue<u16> checksum;
|
||||
Common::BigEndianValue<u16> checksum_inv;
|
||||
|
||||
// Unknown attributes
|
||||
u32 ead0;
|
||||
|
@ -119,7 +120,7 @@ union Sram
|
|||
u8 raw[0x44];
|
||||
struct
|
||||
{
|
||||
u8 rtc[4];
|
||||
Common::BigEndianValue<u32> rtc;
|
||||
SramSettings settings;
|
||||
SramSettingsEx settings_ex;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue