From cb14a17ff56d715f31caafc2d359026bb4b03c7c Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sat, 18 Oct 2008 05:19:44 +0000 Subject: [PATCH] updated GCMemcard to fix the header's checksum. sidenote: replace the first 0x13bytes of your raw memcard dumps with 0x0750B25EC2A150A9E2047343000000000B1B595C to use them in dolphin. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@908 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Core/DolphinWX/Src/FilesystemViewer.cpp | 4 +- Source/Core/DolphinWX/Src/MemcardManager.cpp | 42 ++++++++++--------- .../DolphinWX/Src/MemoryCards/GCMemcard.cpp | 20 ++++++--- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/Source/Core/DolphinWX/Src/FilesystemViewer.cpp b/Source/Core/DolphinWX/Src/FilesystemViewer.cpp index 987b0a61cb..e273145fed 100644 --- a/Source/Core/DolphinWX/Src/FilesystemViewer.cpp +++ b/Source/Core/DolphinWX/Src/FilesystemViewer.cpp @@ -220,7 +220,7 @@ void CFilesystemViewer::CreateGUIControls() // Filesystem tree sbTreectrl = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Filesytem:")); - m_Treectrl = new wxTreeCtrl(this, ID_TREECTRL, wxDefaultPosition, wxSize(350, 450)/*wxDefaultSize*/, wxTR_DEFAULT_STYLE, wxDefaultValidator); + m_Treectrl = new wxTreeCtrl(this, ID_TREECTRL, wxDefaultPosition, wxSize(350, -1), wxTR_DEFAULT_STYLE, wxDefaultValidator); sbTreectrl->Add(m_Treectrl, 1, wxEXPAND); RootId = m_Treectrl->AddRoot(wxT("Root"), -1, -1, 0); @@ -229,7 +229,7 @@ void CFilesystemViewer::CreateGUIControls() sMain = new wxGridBagSizer(0, 0); sMain->Add(sbISODetails, wxGBPosition(0, 0), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); sMain->Add(sbBannerDetails, wxGBPosition(1, 0), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); - sMain->Add(sbTreectrl, wxGBPosition(0, 1), wxGBSpan(2, 1), wxALL, 5); + sMain->Add(sbTreectrl, wxGBPosition(0, 1), wxGBSpan(2, 1), wxEXPAND|wxALL, 5); sMain->Add(m_Close, wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT, 5); this->SetSizer(sMain); diff --git a/Source/Core/DolphinWX/Src/MemcardManager.cpp b/Source/Core/DolphinWX/Src/MemcardManager.cpp index db57e75ad9..e528a9459a 100644 --- a/Source/Core/DolphinWX/Src/MemcardManager.cpp +++ b/Source/Core/DolphinWX/Src/MemcardManager.cpp @@ -132,11 +132,11 @@ void CMemcardManager::CreateGUIControls() sMemcard2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Memory Card 2")); // Create the controls for both memcards - // Will change Mem*.raw to *.raw, when loading invalid .raw files doesn't crash the app :/ + // Loading invalid .raw files still crash the app, but eh, needed this for testing m_Memcard1Path = new wxFilePickerCtrl(this, ID_MEMCARD1PATH, wxEmptyString, wxT("Choose a memory card:"), - wxT("Dolphin memcards (Mem*.raw)|Mem*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN); + wxT("Raw memcards (*.raw)|*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN); m_Memcard2Path = new wxFilePickerCtrl(this, ID_MEMCARD2PATH, wxEmptyString, wxT("Choose a memory card:"), - wxT("Dolphin memcards (Mem*.raw)|Mem*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN); + wxT("Raw memcards (*.raw)|*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN); m_MemcardList[0] = new wxListCtrl(this, ID_MEMCARD1LIST, wxDefaultPosition, wxSize(350,400), wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL); @@ -225,7 +225,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) } break; case ID_FIXCHECKSUM: - if (m_MemcardList[0]->GetItemCount() > 0) + if (memoryCard[0] != NULL) { // Fix checksums and save the changes memoryCard[0]->FixChecksums() ? wxMessageBox(wxT("The checksum was successfully fixed"), wxT("Success"), wxOK) @@ -234,7 +234,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) } break; case ID_CONVERTTOGCI: - { // Wont compile without brackets?? VC++ Express + { // Wont compile without brackets?? wxString temp = wxFileSelector(_T("Select the save file to convert"), wxEmptyString, wxEmptyString, wxEmptyString,wxString::Format ( @@ -245,20 +245,24 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) wxFileSelectorDefaultWildcardStr ), wxFD_OPEN | wxFD_FILE_MUST_EXIST); - const char * fileName = temp.ToAscii(); - wxString temp2 = wxFileSelector(_T("Save GCI as.."), - wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format - ( - _T("GCI File(*.gci)|*.gci"), - wxFileSelectorDefaultWildcardStr, - wxFileSelectorDefaultWildcardStr - ), - wxFD_OVERWRITE_PROMPT|wxFD_SAVE); - const char * fileName2 = temp2.ToAscii(); - if (temp.length() > 0) - { - memoryCard[0]->ImportGci(fileName, fileName2); - } + + if (!temp.empty()) + { + const char * fileName = temp.ToAscii(); + wxString temp2 = wxFileSelector(_T("Save GCI as.."), + wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format + ( + _T("GCI File(*.gci)|*.gci"), + wxFileSelectorDefaultWildcardStr, + wxFileSelectorDefaultWildcardStr + ), + wxFD_OVERWRITE_PROMPT|wxFD_SAVE); + const char * fileName2 = temp2.ToAscii(); + if (temp.length() > 0) + { + memoryCard[0]->ImportGci(fileName, fileName2); + } + } } break; case ID_GCIOPENLEFT: diff --git a/Source/Core/DolphinWX/Src/MemoryCards/GCMemcard.cpp b/Source/Core/DolphinWX/Src/MemoryCards/GCMemcard.cpp index 7e88805507..acefa1c98a 100644 --- a/Source/Core/DolphinWX/Src/MemoryCards/GCMemcard.cpp +++ b/Source/Core/DolphinWX/Src/MemoryCards/GCMemcard.cpp @@ -591,6 +591,12 @@ bool GCMemcard::FixChecksums() u16 csum1=0,csum2=0; + calc_checksumsBE((u16*)&hdr,0xFE,&csum1,&csum2); + hdr.CheckSum1[0]=u8(csum1>>8); + hdr.CheckSum1[1]=u8(csum1); + hdr.CheckSum2[0]=u8(csum2>>8); + hdr.CheckSum2[1]=u8(csum2); + calc_checksumsBE((u16*)&dir,0xFFE,&csum1,&csum2); dir.CheckSum1[0]=u8(csum1>>8); dir.CheckSum1[1]=u8(csum1); @@ -852,12 +858,14 @@ GCMemcard::GCMemcard(const char *filename) // update checksums csums = TestChecksums(); } - } - - if(BE16(dir_backup.UpdateCounter) > BE16(dir.UpdateCounter)) //check if the backup is newer - { - dir = dir_backup; - bat = bat_backup; // needed? +// It seems that the backup having a larger counter doesn't necessarily mean +// the backup should be copied? +// } +// +// if(BE16(dir_backup.UpdateCounter) > BE16(dir.UpdateCounter)) //check if the backup is newer +// { +// dir = dir_backup; +// bat = bat_backup; // needed? } fseek(mcd,0xa000,SEEK_SET);