Merge pull request #2557 from AdmiralCurtiss/gc-sram-checksum

GameCube SRAM: Recalculate checksums after setting language.
This commit is contained in:
Ryan Houdek 2015-06-07 23:24:06 -04:00
commit 9969273994
3 changed files with 30 additions and 1 deletions

View File

@ -116,6 +116,7 @@ CEXIIPL::CEXIIPL() :
// We Overwrite language selection here since it's possible on the GC to change the language as you please
g_SRAM.lang = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
FixSRAMChecksums();
WriteProtectMemory(m_pIPL, ROM_SIZE);
m_uAddress = 0;

View File

@ -89,3 +89,16 @@ void SetCardFlashID(u8* buffer, u8 card_index)
g_SRAM.flashID_chksum[card_index] = csum^0xFF;
}
void FixSRAMChecksums()
{
u16 checksum = 0;
u16 checksum_inv = 0;
for (int i = 0x0C; i < 0x14; i += 2)
{
int value = (g_SRAM.p_SRAM[i] << 8) + g_SRAM.p_SRAM[i+1];
checksum += value;
checksum_inv += value ^ 0xFFFF;
}
g_SRAM.checksum = Common::swap16(checksum);
g_SRAM.checksum_inv = Common::swap16(checksum_inv);
}

View File

@ -38,6 +38,20 @@ distribution.
#include "Common/CommonTypes.h"
#pragma pack(push,1)
union SRAMFlags
{
u8 Hex;
struct
{
u8 : 2;
u8 sound : 1; // Audio settings; 0 = Mono, 1 = Stereo
u8 initialized : 1; // if 0, displays prompt to set language on boot and asks user to set options and time/date
u8 : 2;
u8 boot_menu : 1; // if 1, skips logo animation and boots into the system menu regardless of if there is a disc inserted
u8 progressive : 1; // if 1, automatically displays Progressive Scan prompt in games that support it
};
};
union SRAM
{
u8 p_SRAM[64];
@ -51,7 +65,7 @@ union SRAM
s8 display_offsetH; // Pixel offset for the VI
u8 ntd; // Unknown attribute
u8 lang; // Language of system
u8 flags; // Device and operations flag
SRAMFlags flags; // Device and operations flag
// Stored configuration value from the extended SRAM area
u8 flash_id[2][12]; // flash_id[2][12] 96bit memorycard unlock flash ID
@ -66,6 +80,7 @@ union SRAM
#pragma pack(pop)
void InitSRAM();
void SetCardFlashID(u8* buffer, u8 card_index);
void FixSRAMChecksums();
extern SRAM sram_dump;
extern SRAM g_SRAM;