diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index c389fa8bf5..d1e946f555 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -136,6 +136,34 @@ NVMLayout* getNvmLayout() return nvmLayout; } +static void cdvdCreateNewNVM(const wxString& filename) +{ + wxFFile fp(filename, L"wb"); + if (!fp.IsOpened()) + throw Exception::CannotCreateStream(filename); + + u8 zero[1024] = { 0 }; + fp.Write(zero, sizeof(zero)); + + // Write NVM ILink area with dummy data (Age of Empires 2) + // Also write language data defaulting to English (Guitar Hero 2) + + NVMLayout* nvmLayout = getNvmLayout(); + u8 ILinkID_Data[8] = { 0x00, 0xAC, 0xFF, 0xFF, 0xFF, 0xFF, 0xB9, 0x86 }; + + fp.Seek(*(s32*)(((u8*)nvmLayout) + offsetof(NVMLayout, ilinkId))); + fp.Write(ILinkID_Data, sizeof(ILinkID_Data)); + + u8 biosLanguage[16]; + memcpy(biosLanguage, &biosLangDefaults[BiosRegion][0], 16); + // Config sections first 16 bytes are generally blank expect the last byte which is PS1 mode stuff + // So let's ignore that and just write the PS2 mode stuff + fp.Seek(*(s32*)(((u8*)nvmLayout) + offsetof(NVMLayout, config1)) + 0x10); + fp.Write(biosLanguage, sizeof(biosLanguage)); + + fp.Close(); +} + // Throws Exception::CannotCreateStream if the file cannot be opened for reading, or cannot // be created for some reason. static void cdvdNVM(u8* buffer, int offset, size_t bytes, bool read) @@ -152,23 +180,29 @@ static void cdvdNVM(u8* buffer, int offset, size_t bytes, bool read) { Console.Warning("NVM File Not Found, creating substitute..."); - wxFFile fp(fname, L"wb"); + cdvdCreateNewNVM(fname); + } + else + { + u8 LanguageParams[16]; + u8 zero[16] = { 0 }; + NVMLayout* nvmLayout = getNvmLayout(); + + wxFFile fp(fname, L"r+b"); if (!fp.IsOpened()) throw Exception::CannotCreateStream(fname); - u8 zero[1024] = { 0 }; - fp.Write(zero, sizeof(zero)); + fp.Seek(*(s32*)(((u8*)nvmLayout) + offsetof(NVMLayout, config1)) + 0x10); + fp.Read(LanguageParams, 16); - // Write NVM ILink area with dummy data (Age of Empires 2) - // Also write language data defaulting to English (Guitar Hero 2) + fp.Close(); - NVMLayout* nvmLayout = getNvmLayout(); - u8 ILinkID_Data[8] = { 0x00, 0xAC, 0xFF, 0xFF, 0xFF, 0xFF, 0xB9, 0x86 }; + if (memcmp(LanguageParams, zero, sizeof(LanguageParams)) == 0) + { + Console.Warning("Language Parameters missing, filling in defaults"); - fp.Seek(*(s32*)(((u8*)nvmLayout) + offsetof(NVMLayout, ilinkId))); - fp.Write(ILinkID_Data, sizeof(ILinkID_Data)); - - g_SkipBiosHack = false; + cdvdCreateNewNVM(fname); + } } wxFFile fp(fname, L"r+b"); diff --git a/pcsx2/CDVD/CDVD_internal.h b/pcsx2/CDVD/CDVD_internal.h index a748d2f61d..b70f4836e1 100644 --- a/pcsx2/CDVD/CDVD_internal.h +++ b/pcsx2/CDVD/CDVD_internal.h @@ -238,4 +238,16 @@ static NVMLayout nvmlayouts[NVM_FORMAT_MAX] = {0x146, 0x270, 0x2B0, 0x200, 0x1C8, 0x1E0, 0x1B0, 0x180, 0x198}, // eeproms from bios v1.70 and up }; +static u8 biosLangDefaults[8][16] = +{ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // T10K (Japanese, generally gets overridden) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Test (Japanese, as above) + {0x20, 0x20, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30}, // Japan (Japanese) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // USA (English) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // Europe (English) + {0x30, 0x21, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41}, // HongKong (English) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Free (Japanese, no examples to use) + {0x30, 0x2B, 0x80, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4B}, // China (Simplified Chinese) +}; + #endif diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index afe9db2c11..92f8e23c6e 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -434,18 +434,6 @@ void MainEmuFrame::_DoBootCdvd() } } - if (!g_Conf->EmuOptions.FullBootConfig && g_Conf->EmuOptions.UseBOOT2Injection) - { - g_Conf->EmuOptions.UseBOOT2Injection = false; - g_Conf->EmuOptions.FullBootConfig = true; - - wxString message; - message.Printf(_("For the first run of this version of the emulator, you will be forced to boot to your BIOS. You are required to configure the BIOS language before proceeding. Once this has been done you can Fast Boot normally.")); - Msgbox::Alert(message, _("BIOS Configuration")); - } - else - g_Conf->EmuOptions.FullBootConfig = true; - sApp.SysExecute(g_Conf->CdvdSource); } diff --git a/pcsx2/ps2/BiosTools.cpp b/pcsx2/ps2/BiosTools.cpp index 418db79ae5..fc50d5be42 100644 --- a/pcsx2/ps2/BiosTools.cpp +++ b/pcsx2/ps2/BiosTools.cpp @@ -51,6 +51,7 @@ static_assert( sizeof(romdir) == DIRENTRY_SIZE, "romdir struct not packed to 16 u32 BiosVersion; u32 BiosChecksum; +u32 BiosRegion; bool NoOSD; wxString BiosDescription; const BiosDebugInformation* CurrentBiosInformation; @@ -72,7 +73,7 @@ Exception::BiosLoadFailed::BiosLoadFailed( const wxString& filename ) // This method throws a BadStream exception if the bios information chould not be obtained. // (indicating that the file is invalid, incomplete, corrupted, or plain naughty). -static void LoadBiosVersion( pxInputStream& fp, u32& version, wxString& description, wxString& zoneStr ) +static void LoadBiosVersion( pxInputStream& fp, u32& version, wxString& description, u32& region, wxString& zoneStr ) { uint i; romdir rd; @@ -111,14 +112,14 @@ static void LoadBiosVersion( pxInputStream& fp, u32& version, wxString& descript switch(romver[4]) { - case 'T': zone = "T10K"; break; - case 'X': zone = "Test"; break; - case 'J': zone = "Japan"; break; - case 'A': zone = "USA"; break; - case 'E': zone = "Europe"; break; - case 'H': zone = "HK"; break; - case 'P': zone = "Free"; break; - case 'C': zone = "China"; break; + case 'T': zone = "T10K"; region = 0; break; + case 'X': zone = "Test"; region = 1; break; + case 'J': zone = "Japan"; region = 2; break; + case 'A': zone = "USA"; region = 3; break; + case 'E': zone = "Europe"; region = 4; break; + case 'H': zone = "HK"; region = 5; break; + case 'P': zone = "Free"; region = 6; break; + case 'C': zone = "China"; region = 7; break; } char vermaj[3] = { romver[0], romver[1], 0 }; @@ -167,10 +168,10 @@ static void LoadBiosVersion( pxInputStream& fp, u32& version, wxString& descript } } -static void LoadBiosVersion( pxInputStream& fp, u32& version, wxString& description ) +static void LoadBiosVersion( pxInputStream& fp, u32& version, wxString& description, u32& region ) { wxString zoneStr; - LoadBiosVersion( fp,version, description, zoneStr ); + LoadBiosVersion( fp,version, description, region, zoneStr ); } template< size_t _size > @@ -295,7 +296,7 @@ void LoadBIOS() ChecksumIt( BiosChecksum, eeMem->ROM ); pxInputStream memfp( Bios, new wxMemoryInputStream( eeMem->ROM, sizeof(eeMem->ROM) ) ); - LoadBiosVersion( memfp, BiosVersion, BiosDescription, biosZone ); + LoadBiosVersion( memfp, BiosVersion, BiosDescription, BiosRegion, biosZone ); Console.SetTitle( pxsFmt( L"Running BIOS (%s v%u.%u)", WX_STR(biosZone), BiosVersion >> 8, BiosVersion & 0xff @@ -341,7 +342,8 @@ bool IsBIOS(const wxString& filename, wxString& description) try { u32 version; - LoadBiosVersion( inway, version, description ); + u32 region; + LoadBiosVersion( inway, version, description, region ); return true; } catch( Exception::BadStream& ) { } diff --git a/pcsx2/ps2/BiosTools.h b/pcsx2/ps2/BiosTools.h index 7de07137d6..cac9251a16 100644 --- a/pcsx2/ps2/BiosTools.h +++ b/pcsx2/ps2/BiosTools.h @@ -36,6 +36,7 @@ struct BiosDebugInformation }; extern u32 BiosVersion; // Used by CDVD +extern u32 BiosRegion; // Used by CDVD extern bool NoOSD; // Used for HLE OSD Config Params extern u32 BiosChecksum; extern wxString BiosDescription;