(Patch by KrossX): Fixed multitap (e.g. Timesplitters), New: support raw PSX memcards (mcd/mcr), Fixed issues with pad 2 (e.g. issue 1326).

- Also, I slightly modified the default column widths at the memory card config panel.
- Tip: If the column widths are resized, the new widths will get saved after clicking OK/Apply, but NOT if clicking Cancel or closing the window with [X]. 

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5622 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
avihal@gmail.com 2013-04-27 16:24:02 +00:00
parent c5ffa6ae92
commit 6bfcf433db
7 changed files with 57 additions and 9 deletions

View File

@ -1058,6 +1058,14 @@ typedef struct _PS2E_ComponentAPI_Mcd
//
void (PS2E_CALLBACK* McdGetSizeInfo)( PS2E_THISPTR thisptr, uint port, uint slot, PS2E_McdSizeInfo* outways );
// McdIsPSX
// Checks if the memorycard is a PSX one from the Mcd provider.
//
// Returns:
// False: PS2, True: PSX
//
bool (PS2E_CALLBACK* McdIsPSX)( PS2E_THISPTR thisptr, uint port, uint slot );
// McdRead
// Requests that a block of data be loaded from the memorycard into the specified dest
// buffer (which is allocated by the caller). Bytes read should match the requested

View File

@ -43,6 +43,11 @@ void SysPluginBindings::McdGetSizeInfo( uint port, uint slot, PS2E_McdSizeInfo&
Mcd->McdGetSizeInfo( (PS2E_THISPTR) Mcd, port, slot, &outways );
}
bool SysPluginBindings::McdIsPSX( uint port, uint slot )
{
return Mcd->McdIsPSX( (PS2E_THISPTR) Mcd, port, slot );
}
void SysPluginBindings::McdRead( uint port, uint slot, u8 *dest, u32 adr, int size )
{
Mcd->McdRead( (PS2E_THISPTR) Mcd, port, slot, dest, adr, size );

View File

@ -236,6 +236,7 @@ public:
bool McdIsPresent( uint port, uint slot );
void McdGetSizeInfo( uint port, uint slot, PS2E_McdSizeInfo& outways );
bool McdIsPSX( uint port, uint slot );
void McdRead( uint port, uint slot, u8 *dest, u32 adr, int size );
void McdSave( uint port, uint slot, const u8 *src, u32 adr, int size );
void McdEraseBlock( uint port, uint slot, u32 adr );

View File

@ -64,6 +64,7 @@ public:
s32 IsPresent ( uint slot );
void GetSizeInfo( uint slot, PS2E_McdSizeInfo& outways );
bool IsPSX ( uint slot );
s32 Read ( uint slot, u8 *dest, u32 adr, int size );
s32 Save ( uint slot, const u8 *src, u32 adr, int size );
s32 EraseBlock ( uint slot, u32 adr );
@ -266,6 +267,11 @@ void FileMemoryCard::GetSizeInfo( uint slot, PS2E_McdSizeInfo& outways )
outways.McdSizeInSectors = 0x4000;
}
bool FileMemoryCard::IsPSX( uint slot )
{
return m_file[slot].Length() == 0x20000;
}
s32 FileMemoryCard::Read( uint slot, u8 *dest, u32 adr, int size )
{
wxFFile& mcfp( m_file[slot] );
@ -379,6 +385,11 @@ static void PS2E_CALLBACK FileMcd_GetSizeInfo( PS2E_THISPTR thisptr, uint port,
thisptr->impl.GetSizeInfo( FileMcd_ConvertToSlot( port, slot ), *outways );
}
static bool PS2E_CALLBACK FileMcd_IsPSX( PS2E_THISPTR thisptr, uint port, uint slot )
{
return thisptr->impl.IsPSX( FileMcd_ConvertToSlot( port, slot ) );
}
static s32 PS2E_CALLBACK FileMcd_Read( PS2E_THISPTR thisptr, uint port, uint slot, u8 *dest, u32 adr, int size )
{
return thisptr->impl.Read( FileMcd_ConvertToSlot( port, slot ), dest, adr, size );
@ -408,6 +419,7 @@ Component_FileMcd::Component_FileMcd()
api.McdIsPresent = FileMcd_IsPresent;
api.McdGetSizeInfo = FileMcd_GetSizeInfo;
api.McdIsPSX = FileMcd_IsPSX;
api.McdRead = FileMcd_Read;
api.McdSave = FileMcd_Save;
api.McdEraseBlock = FileMcd_EraseBlock;

View File

@ -35,13 +35,18 @@ using namespace Panels;
static bool IsMcdFormatted( wxFFile& fhand )
{
static const char formatted_psx[] = "MC";
static const char formatted_string[] = "Sony PS2 Memory Card Format";
static const int fmtstrlen = sizeof( formatted_string )-1;
char dest[fmtstrlen];
fhand.Read( dest, fmtstrlen );
return memcmp( formatted_string, dest, fmtstrlen ) == 0;
bool formatted = memcmp( formatted_string, dest, fmtstrlen ) == 0;
if(!formatted) formatted = memcmp( formatted_psx, dest, 2 ) == 0;
return formatted;
}
//sets IsPresent if the file is valid, and derived properties (filename, formatted, size, etc)
@ -56,7 +61,10 @@ bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const w
//DevCon.WriteLn( fullpath );
wxFFile mcdFile( fullpath );
if( !mcdFile.IsOpened() ) return false; // wx should log the error for us.
if( mcdFile.Length() < (1024*528) )
wxFileOffset length = mcdFile.Length();
if( length < (1024*528) && length != 0x20000 )
{
Console.Warning( "... MemoryCard appears to be truncated. Ignoring." );
return false;
@ -67,7 +75,14 @@ bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const w
if( filename.GetFullPath() == (basePath+filename.GetFullName()).GetFullPath() )
dest.Filename = filename.GetFullName();
dest.SizeInMB = (uint)(mcdFile.Length() / (1024 * 528 * 2));
dest.SizeInMB = (uint)(length / (1024 * 528 * 2));
if(length == 0x20000)
{
dest.IsPSX = true; // PSX memcard;
dest.SizeInMB = 1; // MegaBIT
}
dest.IsFormatted = IsMcdFormatted( mcdFile );
filename.GetTimes( NULL, &dest.DateModified, &dest.DateCreated );
@ -1082,6 +1097,8 @@ void Panels::MemoryCardListPanel_Simple::ReadFilesAtMcdFolder(){
wxArrayString memcardList;
wxDir::GetAllFiles(m_FolderPicker->GetPath().ToString(), &memcardList, L"*.ps2", wxDIR_FILES);
wxDir::GetAllFiles(m_FolderPicker->GetPath().ToString(), &memcardList, L"*.mcd", wxDIR_FILES);
wxDir::GetAllFiles(m_FolderPicker->GetPath().ToString(), &memcardList, L"*.mcr", wxDIR_FILES);
for(uint i = 0; i < memcardList.size(); i++) {
McdSlotItem currentCardFile;

View File

@ -76,6 +76,7 @@ enum McdColumnType_Simple
McdColS_Filename,
McdColS_Size,
McdColS_Formatted,
McdColS_Type,
McdColS_DateModified,
McdColS_DateCreated,
McdColS_Count
@ -102,13 +103,14 @@ const ListViewColumnInfo& MemoryCardListView_Simple::GetDefaultColumnInfo( uint
{
static const ListViewColumnInfo columns[] =
{
{ _("PS2 Port") , 154 , wxLIST_FORMAT_LEFT },
{ _("PS2 Port") , 170 , wxLIST_FORMAT_LEFT },
//{ _("Port status") , 80 , wxLIST_FORMAT_LEFT },
{ _("Card (file) name") , 126 , wxLIST_FORMAT_LEFT },
{ _("Card size") , 60 , wxLIST_FORMAT_LEFT },
{ _("Card (file) name") , 145 , wxLIST_FORMAT_LEFT },
{ _("Card size") , 65 , wxLIST_FORMAT_LEFT },
{ _("Formatted") , 80 , wxLIST_FORMAT_LEFT },
{ _("Last Modified"), 85 , wxLIST_FORMAT_LEFT },
{ _("Created on") , 85 , wxLIST_FORMAT_LEFT },
{ _("Type") , 60 , wxLIST_FORMAT_LEFT },
{ _("Last Modified"), 90 , wxLIST_FORMAT_LEFT },
{ _("Created on") , 90 , wxLIST_FORMAT_LEFT },
};
pxAssertDev( idx < ArraySize(columns), "ListView column index is out of bounds." );
@ -152,8 +154,9 @@ wxString MemoryCardListView_Simple::OnGetItemText(long item, long column) const
return prefix + res;
}
*/
case McdColS_Size: return prefix + ( !it.IsPresent ? L"" : pxsFmt( L"%u MB", it.SizeInMB ) );
case McdColS_Size: return prefix + ( !it.IsPresent ? L"" : (it.IsPSX? pxsFmt( L"%u MBit", it.SizeInMB ) : pxsFmt( L"%u MiB", it.SizeInMB )) );
case McdColS_Formatted: return prefix + ( !it.IsPresent ? L"" : ( it.IsFormatted ? _("Yes") : _("No")) );
case McdColS_Type: return prefix + ( !it.IsPresent ? L"" : ( it.IsPSX? _("PSX") : _("PS2")) );
case McdColS_DateModified: return prefix + ( !it.IsPresent ? L"" : it.DateModified.FormatDate() );
case McdColS_DateCreated: return prefix + ( !it.IsPresent ? L"" : it.DateCreated.FormatDate() );

View File

@ -44,6 +44,7 @@ struct McdSlotItem
//Only meaningful when IsPresent==true (a file exists for this item):
wxFileName Filename; // full pathname
bool IsFormatted;
bool IsPSX; // False: PS2 memory card, True: PSX memory card
uint SizeInMB; // size, in megabytes!
wxDateTime DateCreated;
wxDateTime DateModified;
@ -62,6 +63,7 @@ struct McdSlotItem
{
Slot = -1;
IsPSX = false;
IsPresent = false;
IsEnabled = false;
}