mirror of https://github.com/PCSX2/pcsx2.git
wxgui:
* Removed some erroneous language error messages during first-time startup on non-english systems. * Cleaned up BIOS code a bit and moved all the scatterings from Memory.cpp, Misc.cpp, etc. into a single BiosTools.cpp file. * Implemented BIOS selector in the config dialog. git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxgui@1634 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
3457347716
commit
49144a5331
|
@ -26,6 +26,7 @@
|
|||
#include "CDVD_internal.h"
|
||||
#include "CDVDisoReader.h"
|
||||
#include "gs.h" // for gsRegionMode
|
||||
#include "ps2/BiosTools.h"
|
||||
#include "AppConfig.h"
|
||||
|
||||
static cdvdStruct cdvd;
|
||||
|
|
|
@ -46,6 +46,7 @@ BIOS
|
|||
|
||||
#include "IopCommon.h"
|
||||
#include "iR5900.h"
|
||||
#include "ps2/BiosTools.h"
|
||||
|
||||
#include "VUmicro.h"
|
||||
#include "GS.h"
|
||||
|
@ -85,40 +86,6 @@ u16 ba0R16(u32 mem)
|
|||
}
|
||||
|
||||
|
||||
// Attempts to load a BIOS rom file, by trying multiple combinations of base filename
|
||||
// and extension. The bios specified in Config.Bios is used as the base.
|
||||
void loadBiosRom( const wxChar *ext, u8 *dest, long maxSize )
|
||||
{
|
||||
wxString Bios1;
|
||||
long filesize;
|
||||
|
||||
// Try first a basic extension concatenation (normally results in something like name.bin.rom1)
|
||||
const wxString Bios( g_Conf->FullpathToBios() );
|
||||
Bios1.Printf( L"%s.%s", Bios.c_str(), ext);
|
||||
|
||||
if( (filesize=Path::GetFileSize( Bios1 ) ) <= 0 )
|
||||
{
|
||||
// Try the name properly extensioned next (name.rom1)
|
||||
Bios1 = Path::ReplaceExtension( Bios, ext );
|
||||
if( (filesize=Path::GetFileSize( Bios1 ) ) <= 0 )
|
||||
{
|
||||
// Try for the old-style method (rom1.bin)
|
||||
Bios1 = Path::Combine( g_Conf->Folders.Bios, (wxString)ext ) + L".bin";
|
||||
if( (filesize=Path::GetFileSize( Bios1 ) ) <= 0 )
|
||||
{
|
||||
Console::Notice( "Load Bios Warning: %s not found (this is not an error!)", params wxString(ext).ToAscii().data() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we made it this far, we have a successful file found:
|
||||
|
||||
wxFile fp( Bios1 );
|
||||
fp.Read( dest, min( maxSize, filesize ) );
|
||||
}
|
||||
|
||||
|
||||
u8 *psM = NULL; //32mb Main Ram
|
||||
u8 *psR = NULL; //4mb rom area
|
||||
u8 *psR1 = NULL; //256kb rom1 area (actually 196kb, but can't mask this)
|
||||
|
@ -802,35 +769,7 @@ void memReset()
|
|||
vtlb_VMap(0x00000000,0x00000000,0x20000000);
|
||||
vtlb_VMapUnmap(0x20000000,0x60000000);
|
||||
|
||||
wxString Bios( g_Conf->FullpathToBios() );
|
||||
|
||||
long filesize = Path::GetFileSize( Bios );
|
||||
if( filesize > 0 )
|
||||
{
|
||||
wxFile fp( Bios.c_str() );
|
||||
fp.Read( PS2MEM_ROM, min( (long)Ps2MemSize::Rom, filesize ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Translated: Bios file not found or not specified ... A bios is required for Pcsx2 to run!
|
||||
throw Exception::FileNotFound( Bios,
|
||||
L"Configured Bios file does not exist",
|
||||
pxE( ".Error:BiosNotFound",
|
||||
L"The configured BIOS file does not exist, or no BIOS has been configured.\n\n"
|
||||
L"PCSX2 requires a PS2 BIOS to run; and the BIOS *must* be obtained from an actual PS2 unit\n"
|
||||
L"that you own (borrowing doesn't count). Please consult the FAQs and Guides for further instructions."
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
BiosVersion = GetBiosVersion();
|
||||
Console::Status("Bios Version %d.%d", params BiosVersion >> 8, BiosVersion & 0xff);
|
||||
|
||||
//injectIRX("host.irx"); //not fully tested; still buggy
|
||||
|
||||
loadBiosRom( L"rom1", PS2MEM_ROM1, Ps2MemSize::Rom1 );
|
||||
loadBiosRom( L"rom2", PS2MEM_ROM2, Ps2MemSize::Rom2 );
|
||||
loadBiosRom( L"erom", PS2MEM_EROM, Ps2MemSize::ERom );
|
||||
LoadBIOS();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -158,5 +158,4 @@ extern void mmap_ClearCpuBlock( uint offset );
|
|||
#define memWrite64 vtlb_memWrite64
|
||||
#define memWrite128 vtlb_memWrite128
|
||||
|
||||
extern void loadBiosRom( const char *ext, u8 *dest, long maxSize );
|
||||
extern u16 ba0R16(u32 mem);
|
||||
|
|
147
pcsx2/Misc.cpp
147
pcsx2/Misc.cpp
|
@ -47,7 +47,6 @@
|
|||
using namespace std;
|
||||
using namespace R5900;
|
||||
|
||||
u32 BiosVersion;
|
||||
static int g_Pcsx2Recording = 0; // true 1 if recording video and sound
|
||||
bool renderswitch = 0;
|
||||
|
||||
|
@ -58,30 +57,13 @@ int StatesC = 0;
|
|||
extern wxString strgametitle;
|
||||
|
||||
|
||||
#define DIRENTRY_SIZE 16
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
struct romdir
|
||||
{
|
||||
char fileName[10];
|
||||
u16 extInfoSize;
|
||||
u32 fileSize;
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#pragma pack() //+22
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Force DevAssert to *not* inline for devel/debug builds (allows using breakpoints to trap
|
||||
// assertions), and force it to inline for release builds (optimizes it out completely since
|
||||
// IsDevBuild is false). Since Devel builds typically aren't enabled with Global Optimization/
|
||||
// LTCG, this currently isn't even necessary. But might as well, in case we decide at a later
|
||||
// date to re-enable LTCG for devel.
|
||||
//
|
||||
#ifdef PCSX2_DEVBUILD
|
||||
# define DEVASSERT_INLINE __noinline
|
||||
#else
|
||||
|
@ -110,133 +92,6 @@ DEVASSERT_INLINE void DevAssert( bool condition, const char* msg )
|
|||
}
|
||||
}
|
||||
|
||||
u32 GetBiosVersion() {
|
||||
unsigned int fileOffset=0;
|
||||
s8 *ROMVER;
|
||||
char vermaj[8];
|
||||
char vermin[8];
|
||||
struct romdir *rd;
|
||||
u32 version;
|
||||
int i;
|
||||
|
||||
for (i=0; i<512*1024; i++) {
|
||||
rd = (struct romdir*)&psRu8(i);
|
||||
if (strncmp(rd->fileName, "RESET", 5) == 0)
|
||||
break; /* found romdir */
|
||||
}
|
||||
if (i == 512*1024) return -1;
|
||||
|
||||
while(strlen(rd->fileName) > 0){
|
||||
if (strcmp(rd->fileName, "ROMVER") == 0){ // found romver
|
||||
ROMVER = &psRs8(fileOffset);
|
||||
|
||||
strncpy(vermaj, (char *)(ROMVER+ 0), 2); vermaj[2] = 0;
|
||||
strncpy(vermin, (char *)(ROMVER+ 2), 2); vermin[2] = 0;
|
||||
version = strtol(vermaj, (char**)NULL, 0) << 8;
|
||||
version|= strtol(vermin, (char**)NULL, 0);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
if ((rd->fileSize % 0x10)==0)
|
||||
fileOffset += rd->fileSize;
|
||||
else
|
||||
fileOffset += (rd->fileSize + 0x10) & 0xfffffff0;
|
||||
|
||||
rd++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//2002-09-22 (Florin)
|
||||
bool IsBIOS(const wxString& filename, wxString& description)
|
||||
{
|
||||
uint fileOffset=0;
|
||||
romdir rd;
|
||||
|
||||
wxFileName Bios( g_Conf->Folders.Bios + filename );
|
||||
wxFile fp( Bios.GetFullPath().c_str() );
|
||||
|
||||
if( !fp.IsOpened() ) return FALSE;
|
||||
|
||||
int biosFileSize = fp.Length();
|
||||
if( biosFileSize <= 0) return FALSE;
|
||||
|
||||
while( (fp.Tell() < 512*1024) && (fp.Read( &rd, DIRENTRY_SIZE ) == DIRENTRY_SIZE) )
|
||||
{
|
||||
if (strcmp(rd.fileName, "RESET") == 0)
|
||||
break; // found romdir
|
||||
}
|
||||
|
||||
if ((strcmp(rd.fileName, "RESET") != 0) || (rd.fileSize == 0)) {
|
||||
return FALSE; //Unable to locate ROMDIR structure in file or a ioprpXXX.img
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
|
||||
while(strlen(rd.fileName) > 0)
|
||||
{
|
||||
if (strcmp(rd.fileName, "ROMVER") == 0) // found romver
|
||||
{
|
||||
char aROMVER[14+1]; // ascii version loaded from disk.
|
||||
|
||||
uint filepos = fp.Tell();
|
||||
fp.Seek( fileOffset );
|
||||
if( fp.Read( &aROMVER, 14 ) == 0 ) break;
|
||||
fp.Seek( filepos ); //go back
|
||||
|
||||
const char zonefail[2] = { aROMVER[4], '\0' }; // the default "zone" (unknown code)
|
||||
const char* zone = zonefail;
|
||||
|
||||
switch(aROMVER[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;
|
||||
}
|
||||
|
||||
const wxString romver( wxString::FromAscii(aROMVER) );
|
||||
|
||||
description.Printf( L"%s v%c%c.%c%c(%c%c/%c%c/%c%c%c%c) %s", wxString::FromAscii(zone).ToAscii().data(),
|
||||
romver[0], romver[1], // ver major
|
||||
romver[2], romver[3], // ver minor
|
||||
romver[12], romver[13], // day
|
||||
romver[10], romver[11], // month
|
||||
romver[6], romver[7], romver[8], romver[9], // year!
|
||||
(aROMVER[5]=='C') ? L"Console" : (aROMVER[5]=='D') ? L"Devel" : L""
|
||||
);
|
||||
found = true;
|
||||
}
|
||||
|
||||
if ((rd.fileSize % 0x10)==0)
|
||||
fileOffset += rd.fileSize;
|
||||
else
|
||||
fileOffset += (rd.fileSize + 0x10) & 0xfffffff0;
|
||||
|
||||
if (fp.Read( &rd, DIRENTRY_SIZE ) != DIRENTRY_SIZE) break;
|
||||
}
|
||||
fileOffset-=((rd.fileSize + 0x10) & 0xfffffff0) - rd.fileSize;
|
||||
|
||||
if (found)
|
||||
{
|
||||
if ( biosFileSize < (int)fileOffset)
|
||||
{
|
||||
description << ((biosFileSize*100)/(int)fileOffset) << L"%";
|
||||
// we force users to have correct bioses,
|
||||
// not that lame scph10000 of 513KB ;-)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; //fail quietly
|
||||
}
|
||||
|
||||
// return value:
|
||||
// 0 - Invalid or unknown disc.
|
||||
// 1 - PS1 CD
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __MISC_H__
|
||||
#define __MISC_H__
|
||||
#pragma once
|
||||
|
||||
struct KeyModifiers
|
||||
{
|
||||
|
@ -32,8 +31,6 @@ extern struct KeyModifiers keymodifiers;
|
|||
// So a rename to pDisplay is in the works, but it will not, in fact, be removed.
|
||||
extern uptr pDsp; //Used in GS, MTGS, Plugins, Misc
|
||||
|
||||
u32 GetBiosVersion(); // Used in Misc, Memory
|
||||
extern u32 BiosVersion; // Used in Memory, Misc, CDVD
|
||||
int GetPS2ElfName( wxString& dest ); // Used in Misc, System, Linux, CDVD
|
||||
|
||||
// Not sure what header these should go in. Probably not this one.
|
||||
|
@ -42,10 +39,7 @@ extern u32 g_sseVUMXCSR, g_sseMXCSR;
|
|||
|
||||
// Used in Misc,and Windows/Linux files.
|
||||
extern void ProcessFKeys(int fkey, struct KeyModifiers *keymod); // processes fkey related commands value 1-12
|
||||
extern bool IsBIOS(const wxString& filename, wxString& description);
|
||||
|
||||
void SaveGSState(const wxString& file);
|
||||
void LoadGSState(const wxString& file);
|
||||
|
||||
#endif /* __MISC_H__ */
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "SaveState.h"
|
||||
|
||||
#include "CDVD/IsoFSdrv.h"
|
||||
#include "ps2/BiosTools.h"
|
||||
|
||||
#include "VUmicro.h"
|
||||
#include "VU.h"
|
||||
#include "iCore.h"
|
||||
|
|
|
@ -400,6 +400,7 @@ void AppConfig::Apply()
|
|||
|
||||
NTFS_CompressFile( g_Conf->Folders.MemoryCards.ToString(), g_Conf->McdEnableNTFS );
|
||||
|
||||
bool prev = wxLog::EnableLogging( false ); // wx generates verbose errors if languages don't exist, so disable them here.
|
||||
if( !i18n_SetLanguage( LanguageId ) )
|
||||
{
|
||||
if( !i18n_SetLanguage( wxLANGUAGE_DEFAULT ) )
|
||||
|
@ -407,6 +408,7 @@ void AppConfig::Apply()
|
|||
i18n_SetLanguage( wxLANGUAGE_ENGLISH );
|
||||
}
|
||||
}
|
||||
wxLog::EnableLogging( prev );
|
||||
|
||||
// Always perform delete and reload of the Recent Iso List. This handles cases where
|
||||
// the recent file count has been changed, and it's a helluva lot easier than trying
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <wx/docview.h>
|
||||
|
||||
#include "App.h"
|
||||
#include "PS2/CoreEmuThread.h"
|
||||
#include "ps2/CoreEmuThread.h"
|
||||
|
||||
extern CoreEmuThread* g_EmuThread;
|
||||
|
||||
|
|
|
@ -356,6 +356,7 @@ namespace Panels
|
|||
public:
|
||||
ComboBoxPanel( PluginSelectorPanel* parent );
|
||||
wxComboBox& Get( int i ) { return *m_combobox[i]; }
|
||||
wxComboBox& GetBios() { return m_BiosBox; }
|
||||
void Reset();
|
||||
};
|
||||
|
||||
|
@ -367,7 +368,7 @@ namespace Panels
|
|||
int m_progress;
|
||||
|
||||
public:
|
||||
StatusPanel( wxWindow* parent, int pluginCount );
|
||||
StatusPanel( wxWindow* parent, int pluginCount, int biosCount );
|
||||
void AdvanceProgress( const wxString& msg );
|
||||
void Reset();
|
||||
};
|
||||
|
@ -378,6 +379,7 @@ namespace Panels
|
|||
|
||||
protected:
|
||||
wxArrayString m_FileList; // list of potential plugin files
|
||||
wxArrayString m_BiosList;
|
||||
StatusPanel& m_StatusPanel;
|
||||
ComboBoxPanel& m_ComponentBoxes;
|
||||
bool m_Uninitialized;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "Plugins.h"
|
||||
#include "ConfigurationPanels.h"
|
||||
#include "ps2/BiosTools.h"
|
||||
|
||||
#include <wx/dynlib.h>
|
||||
#include <wx/dir.h>
|
||||
|
@ -116,7 +117,7 @@ public:
|
|||
static const wxString failed_separator( L"-------- Unsupported Plugins --------" );
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
Panels::PluginSelectorPanel::StatusPanel::StatusPanel( wxWindow* parent, int pluginCount ) :
|
||||
Panels::PluginSelectorPanel::StatusPanel::StatusPanel( wxWindow* parent, int pluginCount, __unused int biosCount ) :
|
||||
wxPanelWithHelpers( parent )
|
||||
, m_gauge( *new wxGauge( this, wxID_ANY, pluginCount ) )
|
||||
, m_label( *new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE | wxST_NO_AUTORESIZE ) )
|
||||
|
@ -146,8 +147,10 @@ void Panels::PluginSelectorPanel::StatusPanel::Reset()
|
|||
// ------------------------------------------------------------------------
|
||||
Panels::PluginSelectorPanel::ComboBoxPanel::ComboBoxPanel( PluginSelectorPanel* parent ) :
|
||||
wxPanelWithHelpers( parent )
|
||||
, m_BiosBox( *new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ) )
|
||||
, m_BiosBox( *new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY | wxCB_SORT ) )
|
||||
{
|
||||
m_BiosBox.SetFont( wxFont( m_BiosBox.GetFont().GetPointSize()+1, wxFONTFAMILY_MODERN, wxNORMAL, wxNORMAL, false, L"Lucida Console" ) );
|
||||
|
||||
wxFlexGridSizer& s_plugin = *new wxFlexGridSizer( NumPluginTypes, 3, 16, 10 );
|
||||
s_plugin.SetFlexibleDirection( wxHORIZONTAL );
|
||||
s_plugin.AddGrowableCol( 1 ); // expands combo boxes to full width.
|
||||
|
@ -182,7 +185,8 @@ Panels::PluginSelectorPanel::PluginSelectorPanel( wxWindow& parent, int idealWid
|
|||
BaseApplicableConfigPanel( &parent, idealWidth )
|
||||
, m_FileList()
|
||||
, m_StatusPanel( *new StatusPanel( this,
|
||||
wxDir::GetAllFiles( g_Conf->Folders.Plugins.ToString(), &m_FileList, wxsFormat( L"*%s", wxDynamicLibrary::GetDllExt()), wxDIR_FILES )
|
||||
wxDir::GetAllFiles( g_Conf->Folders.Plugins.ToString(), &m_FileList, wxsFormat( L"*%s", wxDynamicLibrary::GetDllExt()), wxDIR_FILES ),
|
||||
wxDir::GetAllFiles( g_Conf->Folders.Bios.ToString(), &m_BiosList, L"*.bin", wxDIR_FILES )
|
||||
) )
|
||||
, m_ComponentBoxes( *new ComboBoxPanel( this ) )
|
||||
, m_Uninitialized( true )
|
||||
|
@ -195,7 +199,6 @@ Panels::PluginSelectorPanel::PluginSelectorPanel( wxWindow& parent, int idealWid
|
|||
//s_main.AddSpacer( 4 );
|
||||
//AddStaticText( s_main, _("Tip: Installed plugins that are not compatible with your hardware or operating system will be listed below a separator.") );
|
||||
s_main.AddSpacer( 4 );
|
||||
|
||||
s_main.Add( &m_StatusPanel, SizerFlags::StdExpand().ReserveSpaceEvenIfHidden() );
|
||||
|
||||
// refresh button used for diagnostics... (don't think there's a point to having one otherwise) --air
|
||||
|
@ -226,12 +229,46 @@ void Panels::PluginSelectorPanel::Apply( AppConfig& conf )
|
|||
for( int i=0; i<NumPluginTypes; ++i )
|
||||
{
|
||||
int sel = m_ComponentBoxes.Get(i).GetSelection();
|
||||
if( sel == wxNOT_FOUND ) continue;
|
||||
if( sel == wxNOT_FOUND )
|
||||
{
|
||||
wxString plugname( wxString::FromAscii( tbl_PluginInfo[i].shortname ) );
|
||||
|
||||
throw Exception::CannotApplySettings( this,
|
||||
// English Log
|
||||
wxsFormat( L"User did not specify a valid selection for the %s plugin.", plugname.c_str() ),
|
||||
|
||||
// Translated
|
||||
wxsFormat( L"Please select a valid plugin for the %s.", plugname.c_str() ) + L"\n\n" +
|
||||
pxE( ".Popup Error:Invalid Plugin Selection",
|
||||
L"All plugins must have valid selections for PCSX2 to run. If you are unable to make\n"
|
||||
L"a valid selection due to missing plugins or an incomplete install of PCSX2, then\n"
|
||||
L"press cancel to close the Configuration panel."
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
wxFileName relative( m_FileList[(int)m_ComponentBoxes.Get(i).GetClientData(sel)] );
|
||||
relative.MakeRelativeTo( g_Conf->Folders.Plugins.ToString() );
|
||||
conf.BaseFilenames.Plugins[tbl_PluginInfo[i].id] = relative.GetFullPath();
|
||||
}
|
||||
|
||||
int sel = m_ComponentBoxes.GetBios().GetSelection();
|
||||
if( sel == wxNOT_FOUND )
|
||||
{
|
||||
throw Exception::CannotApplySettings( this,
|
||||
// English Log
|
||||
L"User did not specify a valid BIOS selection.",
|
||||
|
||||
// Translated
|
||||
pxE( ".Popup Error:Invalid BIOS Selection",
|
||||
L"Please select a valid BIOS before applying new settings. If you are unable to make\n"
|
||||
L"a valid selection then press cancel to close the Configuration panel."
|
||||
)
|
||||
);
|
||||
}
|
||||
wxFileName relative( m_BiosList[(int)m_ComponentBoxes.GetBios().GetClientData(sel)] );
|
||||
relative.MakeRelativeTo( g_Conf->Folders.Bios.ToString() );
|
||||
conf.BaseFilenames.Bios = relative.GetFullPath();
|
||||
}
|
||||
|
||||
void Panels::PluginSelectorPanel::DoRefresh()
|
||||
|
@ -270,6 +307,26 @@ void Panels::PluginSelectorPanel::OnEnumComplete( wxCommandEvent& evt )
|
|||
{
|
||||
safe_delete( m_EnumeratorThread );
|
||||
|
||||
// -----------------
|
||||
// Enumerate BIOS
|
||||
// -----------------
|
||||
|
||||
wxFileName right( g_Conf->FullpathToBios() );
|
||||
right.MakeRelativeTo( g_Conf->Folders.Plugins.ToString() );
|
||||
|
||||
for( size_t i=0; i<m_BiosList.GetCount(); ++i )
|
||||
{
|
||||
wxString description;
|
||||
if( !IsBIOS(m_BiosList[i], description) ) continue;
|
||||
int sel = m_ComponentBoxes.GetBios().Append( description, (void*)i );
|
||||
|
||||
wxFileName left( m_BiosList[i] );
|
||||
left.MakeRelativeTo( g_Conf->Folders.Plugins.ToString() );
|
||||
|
||||
if( left == right )
|
||||
m_ComponentBoxes.GetBios().SetSelection( sel );
|
||||
}
|
||||
|
||||
// fixme: Default plugins should be picked based on the timestamp of the DLL or something?
|
||||
// (for now we just force it to selection zero if nothing's selected)
|
||||
|
||||
|
@ -394,7 +451,7 @@ sptr Panels::PluginSelectorPanel::EnumThread::ExecuteTask()
|
|||
yay.SetExtraLong( curidx );
|
||||
m_master.GetEventHandler()->AddPendingEvent( yay );
|
||||
}
|
||||
|
||||
|
||||
wxCommandEvent done( wxEVT_EnumerationFinished );
|
||||
m_master.GetEventHandler()->AddPendingEvent( done );
|
||||
|
||||
|
|
|
@ -86,12 +86,14 @@ static void i18n_DoPackageCheck( wxLanguage wxLangId, LangPackList& langs )
|
|||
//
|
||||
void i18n_EnumeratePackages( LangPackList& langs )
|
||||
{
|
||||
bool prev = wxLog::EnableLogging( false ); // wx generates verbose errors if languages don't exist, so disable them here.
|
||||
langs.push_back( LangPackEnumeration() );
|
||||
|
||||
for( int li=wxLANGUAGE_UNKNOWN+1; li<wxLANGUAGE_USER_DEFINED; ++li )
|
||||
{
|
||||
i18n_DoPackageCheck( (wxLanguage)li, langs );
|
||||
}
|
||||
wxLog::EnableLogging( prev );
|
||||
|
||||
// Brilliant. Because someone in the wx world didn't think to move wxLANGUAGE_USER_DEFINED
|
||||
// to a place where it wasn't butt right up against the main languages (like, say, start user
|
||||
|
|
|
@ -0,0 +1,259 @@
|
|||
/* Pcsx2 - Pc Ps2 Emulator
|
||||
* Copyright (C) 2002-2009 Pcsx2 Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "AppConfig.h"
|
||||
#include "Common.h"
|
||||
#include "BiosTools.h"
|
||||
|
||||
#include "wx/file.h"
|
||||
|
||||
#define DIRENTRY_SIZE 16
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// romdir structure (packing required!)
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
struct romdir
|
||||
{
|
||||
char fileName[10];
|
||||
u16 extInfoSize;
|
||||
u32 fileSize;
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#pragma pack() //+22
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
u32 BiosVersion; // Used in Memory, Misc, CDVD
|
||||
|
||||
// Returns the version information of the bios currently loaded into memory.
|
||||
static u32 GetBiosVersion()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<512*1024; i++)
|
||||
{
|
||||
if( strncmp( (char*)&psRu8(i), "RESET", 5 ) == 0 )
|
||||
break; /* found romdir */
|
||||
}
|
||||
if (i == 512*1024) return -1;
|
||||
|
||||
const romdir* rd = (romdir*)&psRu8(i);
|
||||
uint fileOffset = 0;
|
||||
|
||||
while(strlen(rd->fileName) > 0)
|
||||
{
|
||||
if (strcmp(rd->fileName, "ROMVER") == 0)
|
||||
{
|
||||
char vermaj[8];
|
||||
char vermin[8];
|
||||
u32 version;
|
||||
|
||||
const s8 *ROMVER = &psRs8(fileOffset);
|
||||
|
||||
strncpy(vermaj, (char *)(ROMVER+ 0), 2); vermaj[2] = 0;
|
||||
strncpy(vermin, (char *)(ROMVER+ 2), 2); vermin[2] = 0;
|
||||
version = strtol(vermaj, (char**)NULL, 0) << 8;
|
||||
version|= strtol(vermin, (char**)NULL, 0);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
if ((rd->fileSize % 0x10)==0)
|
||||
fileOffset += rd->fileSize;
|
||||
else
|
||||
fileOffset += (rd->fileSize + 0x10) & 0xfffffff0;
|
||||
|
||||
rd++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Attempts to load a BIOS rom sub-component, by trying multiple combinations of base
|
||||
// filename and extension. The bios specified in the user's configuration is used as
|
||||
// the base.
|
||||
//
|
||||
// Parameters:
|
||||
// ext - extension of the sub-component to load. Valid options are rom1, rom2, AND erom.
|
||||
//
|
||||
static void loadBiosRom( const wxChar *ext, u8 *dest, long maxSize )
|
||||
{
|
||||
wxString Bios1;
|
||||
long filesize;
|
||||
|
||||
// Try first a basic extension concatenation (normally results in something like name.bin.rom1)
|
||||
const wxString Bios( g_Conf->FullpathToBios() );
|
||||
Bios1.Printf( L"%s.%s", Bios.c_str(), ext);
|
||||
|
||||
if( (filesize=Path::GetFileSize( Bios1 ) ) <= 0 )
|
||||
{
|
||||
// Try the name properly extensioned next (name.rom1)
|
||||
Bios1 = Path::ReplaceExtension( Bios, ext );
|
||||
if( (filesize=Path::GetFileSize( Bios1 ) ) <= 0 )
|
||||
{
|
||||
Console::Notice( "Load Bios Warning: %s not found (this is not an error!)", params wxString(ext).ToAscii().data() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if we made it this far, we have a successful file found:
|
||||
|
||||
wxFile fp( Bios1 );
|
||||
fp.Read( dest, min( maxSize, filesize ) );
|
||||
}
|
||||
|
||||
// Loads the configured bios rom file into PS2 memory. PS2 memory must be allocated prior to
|
||||
// this method being called.
|
||||
//
|
||||
// Remarks:
|
||||
// This function does not fail if rom1, rom2, or erom files are missing, since none are
|
||||
// explicitly required for most emulation tasks.
|
||||
//
|
||||
// Exceptions:
|
||||
// FileNotFound - Thrown if the primary bios file (usually .bin) is not found.
|
||||
//
|
||||
void LoadBIOS()
|
||||
{
|
||||
DevAssert( PS2MEM_ROM != NULL, "PS2 system memory has not been initialized yet." );
|
||||
|
||||
wxString Bios( g_Conf->FullpathToBios() );
|
||||
|
||||
long filesize = Path::GetFileSize( Bios );
|
||||
if( filesize > 0 )
|
||||
{
|
||||
wxFile fp( Bios.c_str() );
|
||||
fp.Read( PS2MEM_ROM, min( (long)Ps2MemSize::Rom, filesize ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Translated: Bios file not found or not specified ... A bios is required for Pcsx2 to run!
|
||||
throw Exception::FileNotFound( Bios,
|
||||
L"Configured Bios file does not exist",
|
||||
|
||||
pxE( ".Error:BiosNotFound",
|
||||
L"The configured BIOS file does not exist, or no BIOS has been configured.\n\n"
|
||||
L"PCSX2 requires a PS2 BIOS to run; and the BIOS *must* be obtained from an actual PS2 unit\n"
|
||||
L"that you own (borrowing doesn't count). Please consult the FAQs and Guides for further instructions."
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
BiosVersion = GetBiosVersion();
|
||||
Console::Status("Bios Version %d.%d", params BiosVersion >> 8, BiosVersion & 0xff);
|
||||
|
||||
//injectIRX("host.irx"); //not fully tested; still buggy
|
||||
|
||||
loadBiosRom( L"rom1", PS2MEM_ROM1, Ps2MemSize::Rom1 );
|
||||
loadBiosRom( L"rom2", PS2MEM_ROM2, Ps2MemSize::Rom2 );
|
||||
loadBiosRom( L"erom", PS2MEM_EROM, Ps2MemSize::ERom );
|
||||
}
|
||||
|
||||
bool IsBIOS(const wxString& filename, wxString& description)
|
||||
{
|
||||
uint fileOffset=0;
|
||||
romdir rd;
|
||||
|
||||
wxFileName Bios( g_Conf->Folders.Bios + filename );
|
||||
wxFile fp( Bios.GetFullPath().c_str() );
|
||||
|
||||
if( !fp.IsOpened() ) return FALSE;
|
||||
|
||||
int biosFileSize = fp.Length();
|
||||
if( biosFileSize < 1024*4096) return FALSE; // valid bios must be at least 4mb.
|
||||
|
||||
while( (fp.Tell() < 512*1024) && (fp.Read( &rd, DIRENTRY_SIZE ) == DIRENTRY_SIZE) )
|
||||
{
|
||||
if (strcmp(rd.fileName, "RESET") == 0)
|
||||
break; // found romdir
|
||||
}
|
||||
|
||||
if ((strcmp(rd.fileName, "RESET") != 0) || (rd.fileSize == 0)) {
|
||||
return FALSE; //Unable to locate ROMDIR structure in file or a ioprpXXX.img
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
|
||||
while(strlen(rd.fileName) > 0)
|
||||
{
|
||||
if (strcmp(rd.fileName, "ROMVER") == 0) // found romver
|
||||
{
|
||||
char aROMVER[14+1]; // ascii version loaded from disk.
|
||||
|
||||
uint filepos = fp.Tell();
|
||||
fp.Seek( fileOffset );
|
||||
if( fp.Read( &aROMVER, 14 ) == 0 ) break;
|
||||
fp.Seek( filepos ); //go back
|
||||
|
||||
const char zonefail[2] = { aROMVER[4], '\0' }; // the default "zone" (unknown code)
|
||||
const char* zone = zonefail;
|
||||
|
||||
switch(aROMVER[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;
|
||||
}
|
||||
|
||||
const wxString romver( wxString::FromAscii(aROMVER) );
|
||||
|
||||
description.Printf( L"%-7s v%c%c.%c%c(%c%c/%c%c/%c%c%c%c) %s",
|
||||
wxString::FromAscii(zone).c_str(),
|
||||
romver[0], romver[1], // ver major
|
||||
romver[2], romver[3], // ver minor
|
||||
romver[12], romver[13], // day
|
||||
romver[10], romver[11], // month
|
||||
romver[6], romver[7], romver[8], romver[9], // year!
|
||||
(aROMVER[5]=='C') ? L"Console" : (aROMVER[5]=='D') ? L"Devel" : L""
|
||||
);
|
||||
found = true;
|
||||
}
|
||||
|
||||
if ((rd.fileSize % 0x10)==0)
|
||||
fileOffset += rd.fileSize;
|
||||
else
|
||||
fileOffset += (rd.fileSize + 0x10) & 0xfffffff0;
|
||||
|
||||
if (fp.Read( &rd, DIRENTRY_SIZE ) != DIRENTRY_SIZE) break;
|
||||
}
|
||||
fileOffset-=((rd.fileSize + 0x10) & 0xfffffff0) - rd.fileSize;
|
||||
|
||||
if (found)
|
||||
{
|
||||
if ( biosFileSize < (int)fileOffset)
|
||||
{
|
||||
description << ((biosFileSize*100)/(int)fileOffset) << L"%";
|
||||
// we force users to have correct bioses,
|
||||
// not that lame scph10000 of 513KB ;-)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; //fail quietly
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/* Pcsx2 - Pc Ps2 Emulator
|
||||
* Copyright (C) 2002-2009 Pcsx2 Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
extern u32 BiosVersion; // Used by CDVD
|
||||
|
||||
extern void LoadBIOS();
|
||||
extern bool IsBIOS(const wxString& filename, wxString& description);
|
|
@ -1042,6 +1042,14 @@
|
|||
RelativePath="..\..\x86\BaseblockEx.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\ps2\BiosTools.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\ps2\BiosTools.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\ps2\CoreEmuThread.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue