pcsx2: add --irx option to inject an irx module

Irx module will be loaded at the end of the ROM (limited
at 256KB)

At the execution of the boot the list of module addresses are
hacked to add the new module.

For #1130
This commit is contained in:
Gregory Hainaut 2016-01-22 19:37:22 +01:00
parent 2ff611137e
commit 724542d870
7 changed files with 64 additions and 5 deletions

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include "IopCommon.h"
#include "App.h" // For host irx injection hack
using namespace R3000A;
@ -127,6 +128,14 @@ void psxJALR()
static __fi void execI()
{
// Inject IRX hack
if (psxRegs.pc == 0x1630 && g_Conf->CurrentIRX.Length() > 3) {
if (iopMemRead32(0x20018) == 0x1F) {
// FIXME do I need to increase the module count (0x1F -> 0x20)
iopMemWrite32(0x20094, 0xbffc0000);
}
}
psxRegs.code = iopMemRead32(psxRegs.pc);
PSXCPU_LOG("%s", disR3000AF(psxRegs.code, psxRegs.pc));

View File

@ -298,6 +298,7 @@ public:
// Indicates if PCSX2 should autorun the configured CDVD source and/or ISO file.
bool SysAutoRun;
bool SysAutoRunElf;
bool SysAutoRunIrx;
StartupOptions()
{
@ -306,7 +307,7 @@ public:
PortableMode = false;
NoFastBoot = false;
SysAutoRun = false;
SysAutoRunElf = false;
SysAutoRunIrx = false;
CdvdSource = CDVDsrc_NoDisc;
}
};

View File

@ -659,6 +659,7 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini )
CurrentIso = res.GetFullPath();
IniEntry( CurrentELF );
IniEntry( CurrentIRX );
IniEntry( EnableSpeedHacks );
IniEntry( EnableGameFixes );

View File

@ -315,6 +315,7 @@ public:
wxString CurrentIso;
wxString CurrentELF;
wxString CurrentIRX;
CDVD_SourceType CdvdSource;
// Memorycard options - first 2 are default slots, last 6 are multitap 1 and 2

View File

@ -235,6 +235,7 @@ void Pcsx2App::OnInitCmdLine( wxCmdLineParser& parser )
parser.AddSwitch( wxEmptyString,L"noguiprompt", _("when nogui - prompt before exiting on suspend") );
parser.AddOption( wxEmptyString,L"elf", _("executes an ELF image"), wxCMD_LINE_VAL_STRING );
parser.AddOption( wxEmptyString,L"irx", _("executes an IRX image"), wxCMD_LINE_VAL_STRING );
parser.AddSwitch( wxEmptyString,L"nodisc", _("boots an empty DVD tray; use to enter the PS2 system menu") );
parser.AddSwitch( wxEmptyString,L"usecd", _("boots from the CDVD plugin (overrides IsoFile parameter)") );
@ -352,9 +353,12 @@ bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
if (parser.Found(L"elf", &elf_file) && !elf_file.IsEmpty()) {
Startup.SysAutoRunElf = true;
Startup.ElfFile = elf_file;
} else if (parser.Found(L"irx", &elf_file) && !elf_file.IsEmpty()) {
Startup.SysAutoRunIrx = true;
Startup.ElfFile = elf_file;
}
}
if( parser.Found(L"usecd") )
{
Startup.CdvdSource = CDVDsrc_Plugin;
@ -480,9 +484,12 @@ bool Pcsx2App::OnInit()
AllocateCoreStuffs();
if( m_UseGUI ) OpenMainFrame();
(new GameDatabaseLoaderThread())->Start();
// By default no IRX injection
g_Conf->CurrentIRX = "";
if( Startup.SysAutoRun )
{
// Notes: Saving/remembering the Iso file is probably fine and desired, so using
@ -499,6 +506,15 @@ bool Pcsx2App::OnInit()
sApp.SysExecute( Startup.CdvdSource, Startup.ElfFile );
}
else if (Startup.SysAutoRunIrx )
{
g_Conf->EmuOptions.UseBOOT2Injection = true;
g_Conf->CurrentIRX = Startup.ElfFile;
// FIXME: ElfFile is an irx it will crash
sApp.SysExecute( Startup.CdvdSource, Startup.ElfFile );
}
}
// ----------------------------------------------------------------------------
catch( Exception::StartupAborted& ex ) // user-aborted, no popups needed.

View File

@ -211,7 +211,7 @@ static void LoadExtraRom( const wxChar* ext, u8 (&dest)[_size] )
wxFile fp( Bios1 );
fp.Read( dest, std::min<s64>( _size, filesize ) );
// Checksum for ROM1, ROM2, EROM? Rama says no, Gigaherz says yes. I'm not sure either way. --air
//ChecksumIt( BiosChecksum, dest );
}
@ -227,6 +227,26 @@ static void LoadExtraRom( const wxChar* ext, u8 (&dest)[_size] )
}
}
static void LoadIrx( const wxString& filename, u8* dest )
{
s64 filesize = 0;
try
{
wxFile irx(filename);
if( (filesize=Path::GetFileSize( filename ) ) <= 0 ) {
Console.Warning(L"IRX Warning: %s could not be read", WX_STR(filename));
return;
}
irx.Read( dest, filesize );
}
catch (Exception::BadStream& ex)
{
Console.Warning(L"IRX Warning: %s could not be read", WX_STR(filename));
Console.Indent().WriteLn(L"Details: %s", WX_STR(ex.FormatDiagnosticMessage()));
}
}
// Loads the configured bios rom file into PS2 memory. PS2 memory must be allocated prior to
// this method being called.
//
@ -267,7 +287,7 @@ void LoadBIOS()
pxInputStream memfp( Bios, new wxMemoryInputStream( eeMem->ROM, sizeof(eeMem->ROM) ) );
LoadBiosVersion( memfp, BiosVersion, BiosDescription, biosZone );
Console.SetTitle( pxsFmt( L"Running BIOS (%s v%u.%u)",
WX_STR(biosZone), BiosVersion >> 8, BiosVersion & 0xff
));
@ -278,6 +298,9 @@ void LoadBIOS()
LoadExtraRom( L"rom2", eeMem->ROM2 );
LoadExtraRom( L"erom", eeMem->EROM );
if (g_Conf->CurrentIRX.Length() > 3)
LoadIrx(g_Conf->CurrentIRX, &eeMem->ROM[0x3C0000]);
CurrentBiosInformation = NULL;
for (size_t i = 0; i < sizeof(biosVersions)/sizeof(biosVersions[0]); i++)
{

View File

@ -1065,6 +1065,14 @@ static void __fastcall iopRecRecompile( const u32 startpc )
u32 i;
u32 willbranch3 = 0;
// Inject IRX hack
if (startpc == 0x1630 && g_Conf->CurrentIRX.Length() > 3) {
if (iopMemRead32(0x20018) == 0x1F) {
// FIXME do I need to increase the module count (0x1F -> 0x20)
iopMemWrite32(0x20094, 0xbffc0000);
}
}
if( IsDebugBuild && (psxdump & 4) )
{
extern void iDumpPsxRegisters(u32 startpc, u32 temp);