Prettified the checksum fix. Moved it to its own button. The rest of the manager is now unaltered.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@677 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
b39f0240cb
commit
7d7b1b57ed
|
@ -75,6 +75,7 @@ BEGIN_EVENT_TABLE(CMemcardManager, wxDialog)
|
||||||
EVT_CLOSE(CMemcardManager::OnClose)
|
EVT_CLOSE(CMemcardManager::OnClose)
|
||||||
EVT_BUTTON(ID_COPYRIGHT,CMemcardManager::CopyDeleteClick)
|
EVT_BUTTON(ID_COPYRIGHT,CMemcardManager::CopyDeleteClick)
|
||||||
EVT_BUTTON(ID_COPYLEFT,CMemcardManager::CopyDeleteClick)
|
EVT_BUTTON(ID_COPYLEFT,CMemcardManager::CopyDeleteClick)
|
||||||
|
EVT_BUTTON(ID_FIXCHECKSUM,CMemcardManager::CopyDeleteClick)
|
||||||
EVT_BUTTON(ID_DELETERIGHT,CMemcardManager::CopyDeleteClick)
|
EVT_BUTTON(ID_DELETERIGHT,CMemcardManager::CopyDeleteClick)
|
||||||
EVT_BUTTON(ID_DELETELEFT,CMemcardManager::CopyDeleteClick)
|
EVT_BUTTON(ID_DELETELEFT,CMemcardManager::CopyDeleteClick)
|
||||||
EVT_FILEPICKER_CHANGED(ID_MEMCARD1PATH,CMemcardManager::OnPathChange)
|
EVT_FILEPICKER_CHANGED(ID_MEMCARD1PATH,CMemcardManager::OnPathChange)
|
||||||
|
@ -107,6 +108,8 @@ void CMemcardManager::CreateGUIControls()
|
||||||
m_CopyRight = new wxButton(this, ID_COPYRIGHT, wxT("->Copy->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
m_CopyRight = new wxButton(this, ID_COPYRIGHT, wxT("->Copy->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||||
m_CopyLeft = new wxButton(this, ID_COPYLEFT, wxT("<-Copy<-"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
m_CopyLeft = new wxButton(this, ID_COPYLEFT, wxT("<-Copy<-"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||||
|
|
||||||
|
m_FixChecksum = new wxButton(this, ID_FIXCHECKSUM, wxT("Fix\nchecksum"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||||
|
|
||||||
m_DeleteRight = new wxButton(this, ID_DELETERIGHT, wxT("Delete->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
m_DeleteRight = new wxButton(this, ID_DELETERIGHT, wxT("Delete->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||||
m_DeleteLeft = new wxButton(this, ID_DELETELEFT, wxT("<-Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
m_DeleteLeft = new wxButton(this, ID_DELETELEFT, wxT("<-Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||||
|
|
||||||
|
@ -136,6 +139,8 @@ void CMemcardManager::CreateGUIControls()
|
||||||
sButtons->Add(m_CopyRight, 0, 0, 5);
|
sButtons->Add(m_CopyRight, 0, 0, 5);
|
||||||
sButtons->Add(m_CopyLeft, 0, 0, 5);
|
sButtons->Add(m_CopyLeft, 0, 0, 5);
|
||||||
sButtons->AddStretchSpacer(2);
|
sButtons->AddStretchSpacer(2);
|
||||||
|
sButtons->Add(m_FixChecksum, 0, 0, 5);
|
||||||
|
sButtons->AddStretchSpacer(2);
|
||||||
sButtons->Add(m_DeleteRight, 0, 0, 5);
|
sButtons->Add(m_DeleteRight, 0, 0, 5);
|
||||||
sButtons->Add(m_DeleteLeft, 0, 0, 5);
|
sButtons->Add(m_DeleteLeft, 0, 0, 5);
|
||||||
sButtons->AddStretchSpacer(1);
|
sButtons->AddStretchSpacer(1);
|
||||||
|
@ -195,6 +200,17 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
|
||||||
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
|
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ID_FIXCHECKSUM:
|
||||||
|
if(m_MemcardList[0]->GetItemCount() > 0)
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------------------
|
||||||
|
// Fix checksums and save the changes
|
||||||
|
memoryCard[0]->FixChecksums();
|
||||||
|
memoryCard[0]->Save();
|
||||||
|
MessageBox(0, "The checksum was successfully fixed", "Message", 0);
|
||||||
|
// ---------------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ID_DELETERIGHT:
|
case ID_DELETERIGHT:
|
||||||
if(index1 != -1)
|
if(index1 != -1)
|
||||||
{
|
{
|
||||||
|
@ -221,8 +237,6 @@ void CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
||||||
// TODO: add error checking and animate icons
|
// TODO: add error checking and animate icons
|
||||||
memoryCard[card] = new GCMemcard(fileName);
|
memoryCard[card] = new GCMemcard(fileName);
|
||||||
|
|
||||||
memoryCard[0]->Save(); // save the changes we made in TestChecksums
|
|
||||||
|
|
||||||
m_MemcardList[card]->Hide();
|
m_MemcardList[card]->Hide();
|
||||||
m_MemcardList[card]->ClearAll();
|
m_MemcardList[card]->ClearAll();
|
||||||
m_MemcardList[card]->InsertColumn(COLUMN_BANNER, _T("Banner"));
|
m_MemcardList[card]->InsertColumn(COLUMN_BANNER, _T("Banner"));
|
||||||
|
|
|
@ -45,6 +45,7 @@ class CMemcardManager
|
||||||
wxBoxSizer* sMain;
|
wxBoxSizer* sMain;
|
||||||
wxButton* m_CopyRight;
|
wxButton* m_CopyRight;
|
||||||
wxButton* m_CopyLeft;
|
wxButton* m_CopyLeft;
|
||||||
|
wxButton* m_FixChecksum;
|
||||||
wxButton* m_DeleteRight;
|
wxButton* m_DeleteRight;
|
||||||
wxButton* m_DeleteLeft;
|
wxButton* m_DeleteLeft;
|
||||||
wxStaticBoxSizer* sMemcard1;
|
wxStaticBoxSizer* sMemcard1;
|
||||||
|
@ -60,6 +61,7 @@ class CMemcardManager
|
||||||
{
|
{
|
||||||
ID_COPYRIGHT = 1000,
|
ID_COPYRIGHT = 1000,
|
||||||
ID_COPYLEFT,
|
ID_COPYLEFT,
|
||||||
|
ID_FIXCHECKSUM,
|
||||||
ID_DELETERIGHT,
|
ID_DELETERIGHT,
|
||||||
ID_DELETELEFT,
|
ID_DELETELEFT,
|
||||||
ID_MEMCARD1PATH,
|
ID_MEMCARD1PATH,
|
||||||
|
|
|
@ -525,26 +525,10 @@ u32 GCMemcard::TestChecksums()
|
||||||
if(BE16(dir.CheckSum1)!=csum1) results |= 2;
|
if(BE16(dir.CheckSum1)!=csum1) results |= 2;
|
||||||
if(BE16(dir.CheckSum2)!=csum2) results |= 2;
|
if(BE16(dir.CheckSum2)!=csum2) results |= 2;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------
|
|
||||||
// Save the checksums we just calculated
|
|
||||||
dir.CheckSum1[0]=u8(csum1>>8);
|
|
||||||
dir.CheckSum1[1]=u8(csum1);
|
|
||||||
dir.CheckSum2[0]=u8(csum2>>8);
|
|
||||||
dir.CheckSum2[1]=u8(csum2);
|
|
||||||
// ------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
calc_checksumsBE((u16*)&dir_backup,0xFFE,&csum1,&csum2);
|
calc_checksumsBE((u16*)&dir_backup,0xFFE,&csum1,&csum2);
|
||||||
if(BE16(dir_backup.CheckSum1)!=csum1) results |= 4;
|
if(BE16(dir_backup.CheckSum1)!=csum1) results |= 4;
|
||||||
if(BE16(dir_backup.CheckSum2)!=csum2) results |= 4;
|
if(BE16(dir_backup.CheckSum2)!=csum2) results |= 4;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------
|
|
||||||
// Save the checksums we just calculated
|
|
||||||
dir_backup.CheckSum1[0]=u8(csum1>>8);
|
|
||||||
dir_backup.CheckSum1[1]=u8(csum1);
|
|
||||||
dir_backup.CheckSum2[0]=u8(csum2>>8);
|
|
||||||
dir_backup.CheckSum2[1]=u8(csum2);
|
|
||||||
// ------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
calc_checksumsBE((u16*)(((u8*)&bat)+4),0xFFE,&csum1,&csum2);
|
calc_checksumsBE((u16*)(((u8*)&bat)+4),0xFFE,&csum1,&csum2);
|
||||||
if(BE16(bat.CheckSum1)!=csum1) results |= 8;
|
if(BE16(bat.CheckSum1)!=csum1) results |= 8;
|
||||||
if(BE16(bat.CheckSum2)!=csum2) results |= 8;
|
if(BE16(bat.CheckSum2)!=csum2) results |= 8;
|
||||||
|
@ -556,6 +540,47 @@ u32 GCMemcard::TestChecksums()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ==========================================================================================
|
||||||
|
// Fix checksums - I'll begin with fixing Directory and Directory backup. Feel free to add the
|
||||||
|
// other blocks.
|
||||||
|
// ------------------------------------------------------------------------------------------
|
||||||
|
u32 GCMemcard::FixChecksums()
|
||||||
|
{
|
||||||
|
if(!mcdFile) return 0xFFFFFFFF;
|
||||||
|
|
||||||
|
u16 csum1=0,csum2=0;
|
||||||
|
|
||||||
|
u32 results = 0;
|
||||||
|
|
||||||
|
calc_checksumsBE((u16*)&dir,0xFFE,&csum1,&csum2);
|
||||||
|
if(BE16(dir.CheckSum1) != csum1) results |= 2;
|
||||||
|
if(BE16(dir.CheckSum2) != csum2) results |= 2;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------
|
||||||
|
// Save the values we just read
|
||||||
|
dir.CheckSum1[0]=u8(csum1>>8);
|
||||||
|
dir.CheckSum1[1]=u8(csum1);
|
||||||
|
dir.CheckSum2[0]=u8(csum2>>8);
|
||||||
|
dir.CheckSum2[1]=u8(csum2);
|
||||||
|
// ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
calc_checksumsBE((u16*)&dir_backup,0xFFE,&csum1,&csum2);
|
||||||
|
if(BE16(dir_backup.CheckSum1) != csum1) results |= 4;
|
||||||
|
if(BE16(dir_backup.CheckSum2) != csum2) results |= 4;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------
|
||||||
|
// Save the values we just read
|
||||||
|
dir_backup.CheckSum1[0]=u8(csum1>>8);
|
||||||
|
dir_backup.CheckSum1[1]=u8(csum1);
|
||||||
|
dir_backup.CheckSum2[0]=u8(csum2>>8);
|
||||||
|
dir_backup.CheckSum2[1]=u8(csum2);
|
||||||
|
// ------------------------------------------------------------------------------------------
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// ==========================================================================================
|
||||||
|
|
||||||
|
|
||||||
u32 GCMemcard::CopyFrom(GCMemcard& source, u32 index)
|
u32 GCMemcard::CopyFrom(GCMemcard& source, u32 index)
|
||||||
{
|
{
|
||||||
if(!mcdFile) return 0;
|
if(!mcdFile) return 0;
|
||||||
|
|
|
@ -128,6 +128,7 @@ public:
|
||||||
bool IsOpen();
|
bool IsOpen();
|
||||||
|
|
||||||
u32 TestChecksums();
|
u32 TestChecksums();
|
||||||
|
u32 FixChecksums();
|
||||||
|
|
||||||
// get number of file entries in the directory
|
// get number of file entries in the directory
|
||||||
u32 GetNumFiles();
|
u32 GetNumFiles();
|
||||||
|
|
Loading…
Reference in New Issue