(Patch by KrossX) - Fix memory card issues from r5703 (should fix Persona 3/4, possibly MGS3, possibly others).

Please report here if there are still games which suffer from memory card issues. Thanks to KrossX for the quick fix.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5706 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
avihal@gmail.com 2013-07-27 23:11:31 +00:00
parent 1c9146b07e
commit baffb9c8d9
2 changed files with 20 additions and 89 deletions

View File

@ -19,12 +19,6 @@
#include "Sio.h"
#include "sio_internal.h"
#ifdef _KELOGS
KELOGS kelogs[4096];
u32 kelogs_count = 0;
bool doKelogs = false;
#endif
_sio sio;
_mcd mcds[2][4];
_mcd *mcd;
@ -128,8 +122,20 @@ void SIO_FORCEINLINE sioInterrupt()
SIO_WRITE sioWriteStart(u8 data)
{
//sio2.packet.recvVal1 = 0x01100; // Pad is present
//sio2.packet.recvVal1 = 0x1D100; // Pad not present
u32 sioreg = sio2.packet.sendArray3[sio2.cmdport ? (sio2.cmdport - 1) : 0];
//u16 size1 = (sioreg >> 8) & 0x1FF;
u16 size2 = (sioreg >> 18) & 0x1FF;
//if(size1 != size2)
// DevCon.Warning("SIO: Bad command length [%02X] (%02X|%02X)", data, size1, size2);
// On mismatch, sio2.cmdlength (size1) is smaller than what it should (Persona 3)
// while size2 is the proper length. -KrossX
sio.bufSize = size2; //max(size1, size2);
if(sio.bufSize)
sio.bufSize--;
switch(data)
{
@ -150,8 +156,6 @@ SIO_WRITE sioWriteStart(u8 data)
SIO_WRITE sioWriteController(u8 data)
{
//sio.packetsize++;
switch(sio.bufCount)
{
case 0:
@ -258,8 +262,11 @@ SIO_WRITE sioWriteMultitap(u8 data)
SIO_WRITE MemcardResponse()
{
sio.buf[sio.bufSize - 1] = 0x2B;
sio.buf[sio.bufSize - 0] = mcd->term;
if(sio.bufSize > 1)
{
sio.buf[sio.bufSize - 1] = 0x2B;
sio.buf[sio.bufSize - 0] = mcd->term;
}
}
SIO_WRITE memcardAuth(u8 data)
@ -504,8 +511,7 @@ SIO_WRITE sioWriteMemcard(u8 data)
break;
case 1:
//printf("Memcard cmd: %02X\n", data);
siocmd = data;
siocmd = data;
switch(data)
{
case 0x21: // SET_SECTOR_ERASE
@ -744,8 +750,6 @@ void sioWriteCtrl16(u16 value)
tcount[0] = 0;
tcount[1] = 0;
KELOGS_PRINT();
sio.StatReg = TX_RDY | TX_EMPTY;
psxRegs.interrupt &= ~(1<<IopEvt_SIO);
}
@ -768,19 +772,16 @@ u8 sioRead8()
ret = sio.ret;
}
KELOGS_READ(ret);
return ret;
}
void sioWrite8(u8 value)
{
KELOGS_WRITE(value);
sioWrite8inl(value);
}
void SIODMAWrite(u8 value)
{
KELOGS_WRITE(value);
sioWrite8inl(value);
}

View File

@ -41,74 +41,6 @@ static const int
RTS = 0x0020,
SIO_RESET = 0x0040;
//#define _KELOGS // Krossx's Enhanced LOGS, it has nothing to do with Kellogg's
#ifdef _KELOGS
struct KELOGS
{
u8 number;
u8 write;
u8 read;
};
extern KELOGS kelogs[];
extern u32 kelogs_count;
extern bool doKelogs;
void inline KelogsPrint()
{
if(doKelogs)
{
printf(" [##|");
for(u32 i = 0; i < kelogs_count; i++)
printf("%02X|", kelogs[i].number);
printf("\nSIO [W8|");
for(u32 i = 0; i < kelogs_count; i++)
printf("%02X|", kelogs[i].write);
printf("\n [R8|");
for(u32 i = 0; i < kelogs_count; i++)
printf("%02X|", kelogs[i].read);
printf("\n\n");
doKelogs = false;
}
kelogs_count = 0;
}
void inline KelogsWrite(u8 value)
{
kelogs[kelogs_count].number = sio.bufCount;
kelogs[kelogs_count].write = value;
}
void inline KelogsRead(u8 value)
{
kelogs[kelogs_count++].read = value;
}
void inline KelogsEnable()
{
doKelogs = true;
}
#define KELOGS_PRINT() KelogsPrint()
#define KELOGS_WRITE(x) KelogsWrite(x)
#define KELOGS_READ(x) KelogsRead(x)
#define KELOGS_ENABLE() KelogsEnable()
#else
#define KELOGS_PRINT()
#define KELOGS_WRITE(x)
#define KELOGS_READ(x)
#define KELOGS_ENABLE()
#endif
void inline SIO_STAT_READY()
{
sio.StatReg &= ~TX_EMPTY; // Now the Buffer is not empty
@ -125,7 +57,6 @@ void inline DEVICE_PLUGGED()
{
sio.ret = 0xFF;
sio2.packet.recvVal1 = 0x01100;
sio.bufSize = sio2.cmdlength;
memset8<0xFF>(sio.buf);
}
@ -133,7 +64,6 @@ void inline DEVICE_UNPLUGGED()
{
sio.ret = 0x00;
sio2.packet.recvVal1 = 0x1D100;
sio.bufSize = sio2.cmdlength;
memset8<0x00>(sio.buf);
}