Tweaks to Elfheader & cdvdReadKey. For the moment, lets not read or write Dev9 memory locations in the null plugin...

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2436 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-01-16 12:29:24 +00:00
parent 1aa3f77dad
commit 37611e4eb0
6 changed files with 66 additions and 57 deletions

View File

@ -305,15 +305,30 @@ s32 cdvdWriteConfig(const u8* config)
static MutexLockRecursive Mutex_NewDiskCB;
// Sets ElfCRC to the CRC of the game bound to the CDVD plugin.
static __forceinline ElfObject *loadElfCRC( const wxString filename )
{
// Note: calling loadElfFile here causes bad things to happen.
IsoFSCDVD isofs;
IsoFile file(isofs, filename);
ElfObject *elfptr;
elfptr = new ElfObject(filename, file);
elfptr->getCRC();
Console.WriteLn(wxsFormat(L"loadElfCRC(" + filename + L") = %8.8X", ElfCRC));
return elfptr;
}
static __forceinline void _reloadElfInfo(wxString str)
{
ElfObject *elfptr;
// Now's a good time to reload the ELF info...
ScopedLock locker( Mutex_NewDiskCB );
ElfCRC = loadElfCRC(str);
ElfApplyPatches();
GetMTGS().SendGameCRC(ElfCRC);
elfptr = loadElfCRC(str);
elfptr->applyPatches();
}
static __forceinline void reloadElfInfo(u32 discType, wxString str)
@ -334,31 +349,30 @@ static __forceinline void reloadElfInfo(u32 discType, wxString str)
}
}
static __forceinline s32 StrToS32(const wxString& str, int base = 10)
{
long l;
str.ToLong(&l, base);
return l;
}
void cdvdReadKey(u8 arg0, u16 arg1, u32 arg2, u8* key)
{
s32 numbers, letters;
u32 key_0_3;
u8 key_4, key_14;
wxString fname;
char exeName[12];
wxString fname, exeName;
// Get the main elf name.
u32 discType = GetPS2ElfName(fname);
const wxCharBuffer crap( fname.To8BitData() );
const char* str = crap.data();
exeName = fname(8, 11);
DevCon.Warning(L"exeName = " + exeName);
// convert the number characters to a real 32 bit number
numbers = StrToS32(exeName(5,3) + exeName(9,2));
sprintf(exeName, "%c%c%c%c%c%c%c%c%c%c%c",str[8],str[9],str[10],str[11],str[12],str[13],str[14],str[15],str[16],str[17],str[18]);
DevCon.Warning("exeName = %s", &str[8]);
// convert the number characters to a real 32bit number
numbers = ((((exeName[5] - '0'))*10000) +
(((exeName[ 6] - '0'))*1000) +
(((exeName[ 7] - '0'))*100) +
(((exeName[ 9] - '0'))*10) +
(((exeName[10] - '0'))*1) );
// combine the lower 7 bits of each char
// to make the 4 letters fit into a single u32
letters = (s32)((exeName[3]&0x7F)<< 0) |

View File

@ -169,7 +169,7 @@ ElfObject::ElfObject( const wxString& srcfile, uint hdrsize )
void ElfObject::initElfHeaders()
{
Console.WriteLn( L"Initializing Elf: %d bytes", data.GetSizeInBytes());
if ( header.e_phnum > 0 )
proghead = (ELF_PHR*)&data[header.e_phoff];
@ -181,7 +181,9 @@ void ElfObject::initElfHeaders()
if ( ( header.e_phnum > 0 ) && ( header.e_phentsize != sizeof(ELF_PHR) ) )
Console.Error( "(ELF) Size of program headers is not standard" );
//getCRC();
const char* elftype = NULL;
switch( header.e_type )
{
@ -228,6 +230,8 @@ void ElfObject::initElfHeaders()
ELF_LOG("sh strndx: %08x",header.e_shstrndx);
ELF_LOG("\n");
//applyPatches();
}
bool ElfObject::hasProgramHeaders() { return (proghead != NULL); }
@ -267,7 +271,7 @@ void ElfObject::checkElfSize(s64 elfsize)
throw Exception::BadStream( filename, wxLt("Unexpected end of ELF file: ") );
}
u32 ElfObject::getCRC() const
void ElfObject::getCRC()
{
u32 CRC = 0;
@ -275,7 +279,7 @@ u32 ElfObject::getCRC() const
for(u32 i=data.GetSizeInBytes()/4; i; --i, ++srcdata)
CRC ^= *srcdata;
return CRC;
ElfCRC = CRC;
}
void ElfObject::loadProgramHeaders()
@ -411,7 +415,7 @@ void ElfObject::loadHeaders()
loadSectionHeaders();
}
void ElfApplyPatches()
void ElfObject::applyPatches()
{
wxString filename( wxsFormat( L"%8.8x", ElfCRC ) );
@ -419,21 +423,7 @@ void ElfApplyPatches()
Console.SetTitle(L"Game running [CRC=" + filename +L"]");
if (EmuConfig.EnablePatches) InitPatch(filename);
}
// Fetches the CRC of the game bound to the CDVD plugin.
u32 loadElfCRC( const wxString filename )
{
// Note: calling loadElfFile here causes bad things to happen.
u32 crcval = 0;
IsoFSCDVD isofs;
IsoFile file(isofs, filename);
crcval = ElfObject(filename, file).getCRC();
Console.WriteLn(wxsFormat(L"loadElfCRC(" + filename + L") = %8.8X", crcval));
return crcval;
GetMTGS().SendGameCRC(ElfCRC);
}
// Loads the elf binary data from the specified file into PS2 memory, and injects the ELF's
@ -504,10 +494,9 @@ void loadElfFile(const wxString& filename)
DevCon.WriteLn( wxsFormat(L"loadElfFile: addr %x \"rom0:OSDSYS\" -> \"" + filename + L"\"", i));
}
}
ElfCRC = elfptr->getCRC();
elfptr->getCRC();
Console.WriteLn( L"loadElfFile: %s; CRC = %8.8X", filename.c_str(), ElfCRC );
ElfApplyPatches();
GetMTGS().SendGameCRC( ElfCRC );
elfptr->applyPatches();
return;
}

View File

@ -155,13 +155,12 @@ class ElfObject
bool hasSectionHeaders();
bool hasHeaders();
u32 getCRC() const;
void getCRC();
void applyPatches();
};
//-------------------
extern void loadElfFile(const wxString& filename);
extern u32 loadElfCRC(const wxString filename);
extern void ElfApplyPatches();
extern int GetPS2ElfName( wxString& dest );

View File

@ -200,10 +200,12 @@ Panels::LogOptionsPanel::LogOptionsPanel(wxWindow* parent )
m_SIF = new pxCheckBox( this, L"SIF (EE<->IOP)" );
m_VIFunpack = new pxCheckBox( this, L"VIFunpack" );
m_GIFtag = new pxCheckBox( this, L"GIFtag" );
m_Elf = new pxCheckBox( this, L"Elves" );
m_SIF ->SetToolTip(_("Enables logging of both SIF DMAs and SIF Register activity.") );
m_VIFunpack ->SetToolTip(_("Special detailed logs of VIF packed data handling (does not include VIF control, status, or hwRegs)"));
m_GIFtag ->SetToolTip(_("(not implemented yet)"));
m_Elf ->SetToolTip(_("Logging of Elf headers."));
wxBoxSizer& topSizer = *new wxBoxSizer( wxHORIZONTAL );
@ -215,6 +217,7 @@ Panels::LogOptionsPanel::LogOptionsPanel(wxWindow* parent )
s_misc += m_SIF;
s_misc += m_VIFunpack;
s_misc += m_GIFtag;
s_misc += m_Elf;
*this += m_masterEnabler | StdSpace();
*this += new wxStaticLine( this, wxID_ANY ) | StdExpand().Border(wxLEFT | wxRIGHT, 20);
@ -233,6 +236,7 @@ void Panels::LogOptionsPanel::OnSettingsChanged()
m_masterEnabler->SetValue( conf.Enabled );
m_SIF->SetValue( conf.SIF );
m_Elf->SetValue( g_Conf->EmuOptions.Log.ELF );
SetCheckValue( EE, VIFunpack );
SetCheckValue( EE, GIFtag );
@ -248,6 +252,7 @@ void Panels::LogOptionsPanel::OnUpdateEnableAll()
bool enabled( m_masterEnabler->GetValue() );
m_SIF->Enable( enabled );
m_Elf->Enable( enabled );
m_VIFunpack->Enable( enabled );
m_GIFtag->Enable( enabled );
@ -265,9 +270,10 @@ void Panels::LogOptionsPanel::OnCheckBoxClicked(wxCommandEvent &evt)
void Panels::LogOptionsPanel::Apply()
{
if( !m_IsDirty ) return;
g_Conf->EmuOptions.Trace.Enabled = m_masterEnabler->GetValue();
g_Conf->EmuOptions.Trace.SIF = m_SIF->GetValue();
g_Conf->EmuOptions.Log.ELF = m_Elf->GetValue();
g_Conf->EmuOptions.Trace.EE.m_VIFunpack = m_VIFunpack->GetValue();
g_Conf->EmuOptions.Trace.EE.m_GIFtag = m_GIFtag->GetValue();

View File

@ -103,6 +103,7 @@ namespace Panels
pxCheckBox* m_masterEnabler;
pxCheckBox* m_SIF;
pxCheckBox* m_Elf;
pxCheckBox* m_VIFunpack;
pxCheckBox* m_GIFtag;

View File

@ -102,9 +102,9 @@ EXPORT_C_(u8) DEV9read8(u32 addr)
switch(addr)
{
// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay)
case 0x10000038: value = dev9Ru8(addr); break; // We need to have at least one case to avoid warnings.
case 0x10000038: /*value = dev9Ru8(addr);*/ break; // We need to have at least one case to avoid warnings.
default:
value = dev9Ru8(addr);
//value = dev9Ru8(addr);
Dev9Log.WriteLn("*Unknown 8 bit read at address %lx", addr);
break;
}
@ -134,9 +134,9 @@ EXPORT_C_(u16) DEV9read16(u32 addr)
// case 0x1000004E: // status
// case 0x1000005C: // status
// case 0x10000064: // if_ctrl
case 0x10000038: value = dev9Ru16(addr); break;
case 0x10000038: /*value = dev9Ru16(addr);*/ break;
default:
value = dev9Ru16(addr);
//value = dev9Ru16(addr);
Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr);
break;
}
@ -150,9 +150,9 @@ EXPORT_C_(u32 ) DEV9read32(u32 addr)
switch(addr)
{
case 0x10000038: value = dev9Ru32(addr); break;
case 0x10000038: /*value = dev9Ru32(addr);*/ break;
default:
value = dev9Ru32(addr);
//value = dev9Ru32(addr);
Dev9Log.WriteLn("*Unknown 32 bit read at address %lx", addr);
break;
}
@ -164,10 +164,10 @@ EXPORT_C_(void) DEV9write8(u32 addr, u8 value)
{
switch(addr)
{
case 0x10000038: dev9Ru8(addr) = value; break;
case 0x10000038: /*dev9Ru8(addr) = value;*/ break;
default:
Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value);
dev9Ru8(addr) = value;
//dev9Ru8(addr) = value;
break;
}
}
@ -178,10 +178,10 @@ EXPORT_C_(void) DEV9write16(u32 addr, u16 value)
{
// Remember that list on DEV9read16? You'll want to write to a
// lot of them, too.
case 0x10000038: dev9Ru16(addr) = value; break;
case 0x10000038: /*dev9Ru16(addr) = value;*/ break;
default:
Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value);
dev9Ru16(addr) = value;
//dev9Ru16(addr) = value;
break;
}
}
@ -190,10 +190,10 @@ EXPORT_C_(void) DEV9write32(u32 addr, u32 value)
{
switch(addr)
{
case 0x10000038: dev9Ru32(addr) = value; break;
case 0x10000038: /*dev9Ru32(addr) = value;*/ break;
default:
Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value);
dev9Ru32(addr) = value;
//dev9Ru32(addr) = value;
break;
}
}