From 97691461ca43fce9e0b376957434d3869fc1fd0e Mon Sep 17 00:00:00 2001 From: "sl1nk3.s" Date: Mon, 8 Jun 2009 02:25:21 +0000 Subject: [PATCH] Fix savestate name for wad games, crashfix for some wad files without MakerID (thanks lpfaint99), fix for US games using SJIS string (Megaman 9 is one of them) can't do the same for PAL games as it would break special chars = we do need an unicode build git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3368 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/CoreParameter.cpp | 29 ++++++++++++--------- Source/Core/DiscIO/Src/VolumeCreator.cpp | 8 +++--- Source/Core/DiscIO/Src/VolumeWad.cpp | 14 +++++----- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 17 ++++++------ Source/Core/DolphinWX/Src/ISOProperties.cpp | 5 ++-- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index b29cf15630..cfb7484780 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -145,23 +145,28 @@ bool SCoreStartupParameter::AutoSetup(EBootBios _BootBios) } else if (DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid()) { - const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename); - u64 TitleID = ContentLoader.GetTitleID(); - char* pTitleID = (char*)&TitleID; + const DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(m_strFilename.c_str()); + const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename); + u64 TitleID = ContentLoader.GetTitleID(); + char* pTitleID = (char*)&TitleID; - // NTSC or PAL - if ((pTitleID[0] == 'E') || (pTitleID[0] == 'J')) - { - bNTSC = true; - } - else - { - bNTSC = false; - } + // NTSC or PAL + if (pTitleID[0] == 'E' || pTitleID[0] == 'J') + { + bNTSC = true; + } + else + { + bNTSC = false; + } bWii = true; Region = EUR_DIR; m_BootType = BOOT_WII_NAND; + + m_strName = pVolume->GetName(); + m_strUniqueID = pVolume->GetUniqueID(); + delete pVolume; } else { diff --git a/Source/Core/DiscIO/Src/VolumeCreator.cpp b/Source/Core/DiscIO/Src/VolumeCreator.cpp index 76ad2aa0a4..eb335043bd 100644 --- a/Source/Core/DiscIO/Src/VolumeCreator.cpp +++ b/Source/Core/DiscIO/Src/VolumeCreator.cpp @@ -133,8 +133,7 @@ bool IsVolumeWadFile(const IVolume *_rVolume) u32 MagicWord = 0; _rVolume->Read(0x02, 4, (u8*)&MagicWord); - return (Common::swap32(MagicWord) == 0x00204973); - // That would be 0x00206962 for boot2 wads + return (Common::swap32(MagicWord) == 0x00204973 || Common::swap32(MagicWord) == 0x00206962); } IVolume* CreateVolumeFromCryptedWiiImage(IBlobReader& _rReader, u32 _PartitionGroup, u32 _VolumeType, u32 _VolumeNum, bool Korean) @@ -227,9 +226,8 @@ EDiscType GetDiscType(IBlobReader& _rReader) { u32 MagicWord = Reader.Read32(0x02); - // That would be 0x206962 for boot2 wads - // Should we add them too ? - if (MagicWord == 0x00204973) + // 0x206962 for boot2 wads + if (MagicWord == 0x00204973 || MagicWord == 0x00206962) return(DISC_TYPE_WAD); } diff --git a/Source/Core/DiscIO/Src/VolumeWad.cpp b/Source/Core/DiscIO/Src/VolumeWad.cpp index 6085aba42d..abc833f2ad 100644 --- a/Source/Core/DiscIO/Src/VolumeWad.cpp +++ b/Source/Core/DiscIO/Src/VolumeWad.cpp @@ -104,7 +104,6 @@ IVolume::ECountry CVolumeWAD::GetCountry() const break; // SDK default: - // PanicAlert("Unknown Country Code!"); country = COUNTRY_UNKNOWN; break; } @@ -132,9 +131,10 @@ std::string CVolumeWAD::GetMakerID() const { u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size) + ALIGN_40(tick_size); - char temp[3]; - if (!Read(0x198 + Offset, 2, (u8*)temp)) - return "0"; + char temp[3] = {1}; + // Some weird channels use 0x0000 in place of the MakerID, so we need a check there + if (!Read(0x198 + Offset, 2, (u8*)temp) || temp[0] == 0 || temp[1] == 0) + return "00"; temp[2] = 0; @@ -153,16 +153,14 @@ bool CVolumeWAD::GetTitleID(u8* _pBuffer) const std::string CVolumeWAD::GetName() const { - if (m_pReader == NULL) - return "Unknown"; - u32 footer_size; + if (!Read(0x1C, 4, (u8*)&footer_size)) return "Unknown"; // Offset to the english title char temp[85]; - if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp)) + if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp) || footer_size < 0xF1) return "Unknown"; char out_temp[43]; diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 439188237c..7af080e2f8 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -302,22 +302,23 @@ void CGameListCtrl::InsertItemInReportView(long _Index) //wxCSConv convTo(wxFontMapper::GetEncodingName(wxFONTENCODING_DEFAULT)); //SetItem(_Index, COLUMN_TITLE, wxString(wxString(rISOFile.GetName()).wc_str(convFrom) , convTo), -1); //SetItem(_Index, COLUMN_NOTES, wxString(wxString(rISOFile.GetDescription()).wc_str(convFrom) , convTo), -1); + + m_gameList.append(std::string(name.mb_str()) + " (J)\n"); if (CopySJISToString(name, rISOFile.GetName(0).c_str())) SetItem(_Index, COLUMN_TITLE, name, -1); if (CopySJISToString(description, rISOFile.GetDescription(0).c_str())) SetItem(_Index, COLUMN_NOTES, description, -1); - - // NetPLay string - m_gameList.append(std::string(name.mb_str()) + " (J)\n"); - break; case DiscIO::IVolume::COUNTRY_USA: - m_gameList.append(std::string(wxString::From8BitData(rISOFile.GetName(0).c_str()).mb_str()) + " (U)\n"); - SetItem(_Index, COLUMN_TITLE, wxString::From8BitData(rISOFile.GetName(0).c_str()), -1); - SetItem(_Index, COLUMN_NOTES, wxString::From8BitData(rISOFile.GetDescription(0).c_str()), -1); + m_gameList.append(std::string(name.mb_str()) + " (U)\n"); + if (CopySJISToString(name, rISOFile.GetName(0).c_str())) + SetItem(_Index, COLUMN_TITLE, name, -1); + if (CopySJISToString(description, rISOFile.GetDescription(0).c_str())) + SetItem(_Index, COLUMN_NOTES, description, -1); break; default: - m_gameList.append(std::string(wxString::From8BitData(rISOFile.GetName((int)SConfig::GetInstance().m_InterfaceLanguage).c_str()).mb_str()) + " (E)\n"); + m_gameList.append(std::string( + wxString::From8BitData(rISOFile.GetName((int)SConfig::GetInstance().m_InterfaceLanguage).c_str()).mb_str()) + " (E)\n"); SetItem(_Index, COLUMN_TITLE, wxString::From8BitData(rISOFile.GetName((int)SConfig::GetInstance().m_InterfaceLanguage).c_str()), -1); SetItem(_Index, COLUMN_NOTES, diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index c231975031..d53354bec9 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -1039,9 +1039,8 @@ bool CISOProperties::CopySJISToString( wxString& _rDestination, const char* _src } } #else - // not implement other than windows - //_rDestination = _src; - //returnCode = true; + _rDestination = wxString(wxString(_src,wxConvLibc),wxConvUTF8); + returnCode = true; #endif return returnCode; }