notaz.gp2x.de
/
pcsx_rearmed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #186 from fr500/patch-3
[pcsx_rearmed.git]
/
libpcsxcore
/
sio.c
diff --git
a/libpcsxcore/sio.c
b/libpcsxcore/sio.c
index
8a30797
..
d251fa7
100644
(file)
--- a/
libpcsxcore/sio.c
+++ b/
libpcsxcore/sio.c
@@
-48,7
+48,8
@@
// *** FOR WORKS ON PADS AND MEMORY CARDS *****
static unsigned char buf[256];
// *** FOR WORKS ON PADS AND MEMORY CARDS *****
static unsigned char buf[256];
-unsigned char cardh[4] = { 0x00, 0x00, 0x5a, 0x5d };
+static unsigned char cardh1[4] = { 0xff, 0x08, 0x5a, 0x5d };
+static unsigned char cardh2[4] = { 0xff, 0x08, 0x5a, 0x5d };
// Transfer Ready and the Buffer is Empty
// static unsigned short StatReg = 0x002b;
// Transfer Ready and the Buffer is Empty
// static unsigned short StatReg = 0x002b;
@@
-64,6
+65,7
@@
static unsigned char adrH, adrL;
static unsigned int padst;
char Mcd1Data[MCD_SIZE], Mcd2Data[MCD_SIZE];
static unsigned int padst;
char Mcd1Data[MCD_SIZE], Mcd2Data[MCD_SIZE];
+char McdDisable[2];
#define SIO_INT(eCycle) { \
if (!Config.Sio) { \
#define SIO_INT(eCycle) { \
if (!Config.Sio) { \
@@
-115,6
+117,20
@@
void sioWrite8(unsigned char value) {
break;
}
}
break;
}
}
+ // NegCon - Wipeout 3
+ if( buf[parp] == 0x23 ) {
+ switch (value) {
+ // enter config mode
+ case 0x43:
+ buf[1] = 0x79;
+ break;
+
+ // get status
+ case 0x45:
+ buf[1] = 0xf3;
+ break;
+ }
+ }
}
else padst = 0;
return;
}
else padst = 0;
return;
@@
-204,6
+220,14
@@
void sioWrite8(unsigned char value) {
return;
case 5:
parp++;
return;
case 5:
parp++;
+ if ((rdwr == 1 && parp == 132) ||
+ (rdwr == 2 && parp == 129)) {
+ // clear "new card" flags
+ if (CtrlReg & 0x2000)
+ cardh2[1] &= ~8;
+ else
+ cardh1[1] &= ~8;
+ }
if (rdwr == 2) {
if (parp < 128) buf[parp + 1] = value;
}
if (rdwr == 2) {
if (parp < 128) buf[parp + 1] = value;
}
@@
-258,14
+282,32
@@
void sioWrite8(unsigned char value) {
SIO_INT(SIO_CYCLES);
return;
case 0x81: // start memcard
SIO_INT(SIO_CYCLES);
return;
case 0x81: // start memcard
+ if (CtrlReg & 0x2000)
+ {
+ if (McdDisable[1])
+ goto no_device;
+ memcpy(buf, cardh2, 4);
+ }
+ else
+ {
+ if (McdDisable[0])
+ goto no_device;
+ memcpy(buf, cardh1, 4);
+ }
StatReg |= RX_RDY;
StatReg |= RX_RDY;
- memcpy(buf, cardh, 4);
parp = 0;
bufcount = 3;
mcdst = 1;
rdwr = 0;
SIO_INT(SIO_CYCLES);
return;
parp = 0;
bufcount = 3;
mcdst = 1;
rdwr = 0;
SIO_INT(SIO_CYCLES);
return;
+ default:
+ no_device:
+ StatReg |= RX_RDY;
+ buf[0] = 0xff;
+ parp = 0;
+ bufcount = 0;
+ return;
}
}
}
}
@@
-279,7
+321,7
@@
void sioWriteMode16(unsigned short value) {
void sioWriteCtrl16(unsigned short value) {
CtrlReg = value & ~RESET_ERR;
if (value & RESET_ERR) StatReg &= ~IRQ;
void sioWriteCtrl16(unsigned short value) {
CtrlReg = value & ~RESET_ERR;
if (value & RESET_ERR) StatReg &= ~IRQ;
- if ((CtrlReg & SIO_RESET) ||
(!CtrlReg
)) {
+ if ((CtrlReg & SIO_RESET) ||
!(CtrlReg & DTR
)) {
padst = 0; mcdst = 0; parp = 0;
StatReg = TX_RDY | TX_EMPTY;
psxRegs.interrupt &= ~(1 << PSXINT_SIO);
padst = 0; mcdst = 0; parp = 0;
StatReg = TX_RDY | TX_EMPTY;
psxRegs.interrupt &= ~(1 << PSXINT_SIO);
@@
-358,21
+400,36
@@
void sioInterrupt() {
PAD_LOG("Sio Interrupt (CP0.Status = %x)\n", psxRegs.CP0.n.Status);
#endif
// SysPrintf("Sio Interrupt\n");
PAD_LOG("Sio Interrupt (CP0.Status = %x)\n", psxRegs.CP0.n.Status);
#endif
// SysPrintf("Sio Interrupt\n");
- StatReg |= IRQ;
- psxHu32ref(0x1070) |= SWAPu32(0x80);
+ if (!(StatReg & IRQ)) {
+ StatReg |= IRQ;
+ psxHu32ref(0x1070) |= SWAPu32(0x80);
+ }
}
void LoadMcd(int mcd, char *str) {
FILE *f;
char *data = NULL;
}
void LoadMcd(int mcd, char *str) {
FILE *f;
char *data = NULL;
- if (mcd
== 1) data = Mcd1Data;
-
if (mcd == 2) data = Mcd2Data
;
+ if (mcd
!= 1 && mcd != 2)
+
return
;
- if (*str == 0) {
- sprintf(str, "memcards/card%d.mcd", mcd);
- SysPrintf(_("No memory card value was specified - creating a default card %s\n"), str);
+ if (mcd == 1) {
+ data = Mcd1Data;
+ cardh1[1] |= 8; // mark as new
+ }
+ if (mcd == 2) {
+ data = Mcd2Data;
+ cardh2[1] |= 8;
+ }
+
+ McdDisable[mcd - 1] = 0;
+ if (str == NULL || strcmp(str, "none") == 0) {
+ McdDisable[mcd - 1] = 1;
+ return;
}
}
+ if (*str == 0)
+ return;
+
f = fopen(str, "rb");
if (f == NULL) {
SysPrintf(_("The memory card %s doesn't exist - creating it\n"), str);
f = fopen(str, "rb");
if (f == NULL) {
SysPrintf(_("The memory card %s doesn't exist - creating it\n"), str);
@@
-415,6
+472,9
@@
void LoadMcds(char *mcd1, char *mcd2) {
void SaveMcd(char *mcd, char *data, uint32_t adr, int size) {
FILE *f;
void SaveMcd(char *mcd, char *data, uint32_t adr, int size) {
FILE *f;
+ if (mcd == NULL || *mcd == 0 || strcmp(mcd, "none") == 0)
+ return;
+
f = fopen(mcd, "r+b");
if (f != NULL) {
struct stat buf;
f = fopen(mcd, "r+b");
if (f != NULL) {
struct stat buf;
@@
-673,13
+733,19
@@
void ConvertMcd(char *mcd, char *data) {
}
void GetMcdBlockInfo(int mcd, int block, McdBlock *Info) {
}
void GetMcdBlockInfo(int mcd, int block, McdBlock *Info) {
-
unsigned
char *data = NULL, *ptr, *str, *sstr;
+ char *data = NULL, *ptr, *str, *sstr;
unsigned short clut[16];
unsigned short c;
int i, x;
memset(Info, 0, sizeof(McdBlock));
unsigned short clut[16];
unsigned short c;
int i, x;
memset(Info, 0, sizeof(McdBlock));
+ if (mcd != 1 && mcd != 2)
+ return;
+
+ if (McdDisable[mcd - 1])
+ return;
+
if (mcd == 1) data = Mcd1Data;
if (mcd == 2) data = Mcd2Data;
if (mcd == 1) data = Mcd1Data;
if (mcd == 2) data = Mcd2Data;
@@
-760,7
+826,7
@@
void GetMcdBlockInfo(int mcd, int block, McdBlock *Info) {
strncpy(Info->Name, ptr, 16);
}
strncpy(Info->Name, ptr, 16);
}
-int sioFreeze(
gzFile
f, int Mode) {
+int sioFreeze(
void *
f, int Mode) {
gzfreeze(buf, sizeof(buf));
gzfreeze(&StatReg, sizeof(StatReg));
gzfreeze(&ModeReg, sizeof(ModeReg));
gzfreeze(buf, sizeof(buf));
gzfreeze(&StatReg, sizeof(StatReg));
gzfreeze(&ModeReg, sizeof(ModeReg));