summaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-05-10 07:11:29 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-05-10 07:11:29 +0000
commit78470f808411136437789aee0d33fbe0c892daea (patch)
tree881982366f2b13fd535ac0160d505764bc0e19ba /libpcsxcore
parent92679bf72724dc122da6c69c20d9f785a230af4b (diff)
downloadpcsxr-78470f808411136437789aee0d33fbe0c892daea.tar.gz
got rid of cdrfilename & cdOpenCase, windows broken for now
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@47753 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/cdriso.c16
-rw-r--r--libpcsxcore/plugins.c30
-rw-r--r--libpcsxcore/plugins.h5
-rw-r--r--libpcsxcore/psxcommon.c1
-rw-r--r--libpcsxcore/psxcommon.h4
-rw-r--r--libpcsxcore/psxhw.c8
-rw-r--r--libpcsxcore/sio.c105
7 files changed, 90 insertions, 79 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index 856cee9a..b86447a9 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -240,7 +240,7 @@ static void startCDDA(unsigned int offset) {
stopCDDA();
}
- cddaHandle = fopen(cdrfilename, "rb");
+ cddaHandle = fopen(GetIsoFile(), "rb");
if (cddaHandle == NULL) {
return;
}
@@ -629,31 +629,31 @@ static long CALLBACK ISOopen(void) {
return 0; // it's already open
}
- cdHandle = fopen(cdrfilename, "rb");
+ cdHandle = fopen(GetIsoFile(), "rb");
if (cdHandle == NULL) {
return -1;
}
- SysPrintf(_("Loaded CD Image: %s"), cdrfilename);
+ SysPrintf(_("Loaded CD Image: %s"), GetIsoFile());
cddaBigEndian = 0;
subChanInterleaved = 0;
- if (parsetoc(cdrfilename) == 0) {
+ if (parsetoc(GetIsoFile()) == 0) {
cddaBigEndian = 1; // cdrdao uses big-endian for CD Audio
SysPrintf("[+toc]");
}
- else if (parsecue(cdrfilename) == 0) {
+ else if (parsecue(GetIsoFile()) == 0) {
SysPrintf("[+cue]");
}
- else if (parseccd(cdrfilename) == 0) {
+ else if (parseccd(GetIsoFile()) == 0) {
SysPrintf("[+ccd]");
}
- else if (parsemds(cdrfilename) == 0) {
+ else if (parsemds(GetIsoFile()) == 0) {
SysPrintf("[+mds]");
}
- if (!subChanInterleaved && opensubfile(cdrfilename) == 0) {
+ if (!subChanInterleaved && opensubfile(GetIsoFile()) == 0) {
SysPrintf("[+sub]");
}
diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c
index cd8fc8cc..59d14bb6 100644
--- a/libpcsxcore/plugins.c
+++ b/libpcsxcore/plugins.c
@@ -24,8 +24,8 @@
#include "plugins.h"
#include "cdriso.h"
-char cdrfilename[MAXPATHLEN] = ""; // FIXME: cleanup
-int cdOpenCase = 0; // FIXME: cleanup
+static char IsoFile[MAXPATHLEN] = "";
+static s64 cdOpenCaseTime = 0;
GPUupdateLace GPU_updateLace;
GPUinit GPU_init;
@@ -213,7 +213,7 @@ long CALLBACK CDR__play(unsigned char *sector) { return 0; }
long CALLBACK CDR__stop(void) { return 0; }
long CALLBACK CDR__getStatus(struct CdrStat *stat) {
- if (cdOpenCase < 0 || cdOpenCase > time(NULL))
+ if (cdOpenCaseTime < 0 || cdOpenCaseTime > (s64)time(NULL))
stat->Status = 0x10;
else
stat->Status = 0;
@@ -460,7 +460,7 @@ int LoadPlugins() {
ReleasePlugins();
- if (cdrfilename[0] != '\0') {
+ if (UsingIso()) {
LoadCDRplugin(NULL);
} else {
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);
@@ -511,7 +511,7 @@ void ReleasePlugins() {
if (Config.UseNet) {
int ret = NET_close();
if (ret < 0) Config.UseNet = 0;
- NetOpened = 0;
+ NetOpened = FALSE;
}
if (hCDRDriver != NULL || cdrIsoActive()) CDR_shutdown();
@@ -532,3 +532,23 @@ void ReleasePlugins() {
SysCloseLibrary(hNETDriver); hNETDriver = NULL;
}
}
+
+void SetIsoFile(const char *filename) {
+ if (filename == NULL) {
+ IsoFile[0] = '\0';
+ return;
+ }
+ strncpy(IsoFile, filename, MAXPATHLEN);
+}
+
+const char *GetIsoFile(void) {
+ return IsoFile;
+}
+
+boolean UsingIso(void) {
+ return (IsoFile[0] != '\0');
+}
+
+void SetCdOpenCaseTime(s64 time) {
+ cdOpenCaseTime = time;
+}
diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h
index 82c76f75..6cb358c0 100644
--- a/libpcsxcore/plugins.h
+++ b/libpcsxcore/plugins.h
@@ -312,7 +312,10 @@ extern NETkeypressed NET_keypressed;
void CALLBACK clearDynarec(void);
-extern char cdrfilename[MAXPATHLEN]; // FIXME: cleanup
+void SetIsoFile(const char *filename);
+const char *GetIsoFile(void);
+boolean UsingIso(void);
+void SetCdOpenCaseTime(s64 time);
#ifdef __cplusplus
}
diff --git a/libpcsxcore/psxcommon.c b/libpcsxcore/psxcommon.c
index ea12db86..a47be96a 100644
--- a/libpcsxcore/psxcommon.c
+++ b/libpcsxcore/psxcommon.c
@@ -23,6 +23,7 @@
#include "cheat.h"
PcsxConfig Config;
+boolean NetOpened = FALSE;
int Log = 0;
FILE *emuLog = NULL;
diff --git a/libpcsxcore/psxcommon.h b/libpcsxcore/psxcommon.h
index 059800ef..f37a2520 100644
--- a/libpcsxcore/psxcommon.h
+++ b/libpcsxcore/psxcommon.h
@@ -134,9 +134,7 @@ typedef struct {
} PcsxConfig;
extern PcsxConfig Config;
-
-extern int cdOpenCase; // FIXME: cleanup
-extern int NetOpened;
+extern boolean NetOpened;
#define gzfreeze(ptr, size) \
if (Mode == 1) gzwrite(f, ptr, size); \
diff --git a/libpcsxcore/psxhw.c b/libpcsxcore/psxhw.c
index 15395a40..16a749ff 100644
--- a/libpcsxcore/psxhw.c
+++ b/libpcsxcore/psxhw.c
@@ -26,12 +26,12 @@
#include "cdrom.h"
void psxHwReset() {
- if (Config.Sio) psxHu32ref(0x1070) |= SWAP32(0x80);
- if (Config.SpuIrq) psxHu32ref(0x1070) |= SWAP32(0x200);
+ if (Config.Sio) psxHu32ref(0x1070) |= SWAP32(0x80);
+ if (Config.SpuIrq) psxHu32ref(0x1070) |= SWAP32(0x200);
memset(psxH, 0, 0x10000);
- mdecInit(); //intialize mdec decoder
+ mdecInit(); // initialize mdec decoder
cdrReset();
psxRcntInit();
}
@@ -366,7 +366,7 @@ void psxHwWrite16(u32 add, u16 value) {
#endif
return;
case 0x1f801044:
- sioWriteStat16(value);
+ sioWriteStat16(value);
#ifdef PAD_LOG
PAD_LOG ("sio write16 %lx, %x\n", add&0xf, value);
#endif
diff --git a/libpcsxcore/sio.c b/libpcsxcore/sio.c
index 2243243d..6d61b002 100644
--- a/libpcsxcore/sio.c
+++ b/libpcsxcore/sio.c
@@ -1,20 +1,20 @@
/***************************************************************************
- * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
+ * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
/*
@@ -50,8 +50,8 @@
static unsigned char buf[256];
unsigned char cardh[4] = { 0x00, 0x00, 0x5a, 0x5d };
-//static unsigned short StatReg = 0x002b;
// Transfer Ready and the Buffer is Empty
+// static unsigned short StatReg = 0x002b;
static unsigned short StatReg = TX_RDY | TX_EMPTY;
static unsigned short ModeReg;
static unsigned short CtrlReg;
@@ -70,7 +70,7 @@ char Mcd1Data[MCD_SIZE], Mcd2Data[MCD_SIZE];
#define SIO_INT() { \
if (!Config.Sio) { \
psxRegs.interrupt |= 0x80; \
- psxRegs.intCycle[7 + 1] = 200; /*270;*/ \
+ psxRegs.intCycle[7 + 1] = 200; /*271;*/ \
psxRegs.intCycle[7] = psxRegs.cycle; \
} \
}
@@ -81,10 +81,10 @@ void sioWrite8(unsigned char value) {
#endif
switch (padst) {
case 1: SIO_INT();
- if ((value&0x40) == 0x40) {
+ if ((value & 0x40) == 0x40) {
padst = 2; parp = 1;
if (!Config.UseNet) {
- switch (CtrlReg&0x2002) {
+ switch (CtrlReg & 0x2002) {
case 0x0002:
buf[parp] = PAD1_poll(value);
break;
@@ -122,7 +122,7 @@ void sioWrite8(unsigned char value) {
return;
}*/
if (!Config.UseNet) {
- switch (CtrlReg&0x2002) {
+ switch (CtrlReg & 0x2002) {
case 0x0002: buf[parp] = PAD1_poll(value); break;
case 0x2002: buf[parp] = PAD2_poll(value); break;
}
@@ -169,7 +169,7 @@ void sioWrite8(unsigned char value) {
buf[1] = 0x5d;
buf[2] = adrH;
buf[3] = adrL;
- switch (CtrlReg&0x2002) {
+ switch (CtrlReg & 0x2002) {
case 0x0002:
memcpy(&buf[4], Mcd1Data + (adrL | (adrH << 8)) * 128, 128);
break;
@@ -201,7 +201,7 @@ void sioWrite8(unsigned char value) {
case 5:
parp++;
if (rdwr == 2) {
- if (parp < 128) buf[parp+1] = value;
+ if (parp < 128) buf[parp + 1] = value;
}
SIO_INT();
return;
@@ -212,7 +212,7 @@ void sioWrite8(unsigned char value) {
StatReg |= RX_RDY; // Transfer is Ready
if (!Config.UseNet) {
- switch (CtrlReg&0x2002) {
+ switch (CtrlReg & 0x2002) {
case 0x0002: buf[0] = PAD1_startPoll(1); break;
case 0x2002: buf[0] = PAD2_startPoll(2); break;
}
@@ -241,10 +241,10 @@ void sioWrite8(unsigned char value) {
if (NET_recvPadData(buf, 1) == -1)
netError();
- if (NET_recvPadData(buf+128, 2) == -1)
+ if (NET_recvPadData(buf + 128, 2) == -1)
netError();
} else {
- memcpy(buf, buf+128, 32);
+ memcpy(buf, buf + 128, 32);
}
}
@@ -265,28 +265,24 @@ void sioWrite8(unsigned char value) {
}
}
-void sioWriteStat16(unsigned short value)
-{
+void sioWriteStat16(unsigned short value) {
}
-void sioWriteMode16(unsigned short value)
-{
+void sioWriteMode16(unsigned short value) {
ModeReg = value;
}
-void sioWriteCtrl16(unsigned short value)
-{
+void sioWriteCtrl16(unsigned short value) {
CtrlReg = value & ~RESET_ERR;
if (value & RESET_ERR) StatReg &= ~IRQ;
if ((CtrlReg & SIO_RESET) || (!CtrlReg)) {
padst = 0; mcdst = 0; parp = 0;
StatReg = TX_RDY | TX_EMPTY;
- psxRegs.interrupt&=~0x80;
+ psxRegs.interrupt &= ~0x80;
}
}
-void sioWriteBaud16(unsigned short value)
-{
+void sioWriteBaud16(unsigned short value) {
BaudReg = value;
}
@@ -301,7 +297,7 @@ unsigned char sioRead8() {
if (mcdst == 5) {
mcdst = 0;
if (rdwr == 2) {
- switch (CtrlReg&0x2002) {
+ switch (CtrlReg & 0x2002) {
case 0x0002:
memcpy(Mcd1Data + (adrL | (adrH << 8)) * 128, &buf[1], 128);
SaveMcd(Config.Mcd1, Mcd1Data, (adrL | (adrH << 8)) * 128, 128);
@@ -327,23 +323,19 @@ unsigned char sioRead8() {
return ret;
}
-unsigned short sioReadStat16()
-{
+unsigned short sioReadStat16() {
return StatReg;
}
-unsigned short sioReadMode16()
-{
+unsigned short sioReadMode16() {
return ModeReg;
}
-unsigned short sioReadCtrl16()
-{
+unsigned short sioReadCtrl16() {
return CtrlReg;
}
-unsigned short sioReadBaud16()
-{
+unsigned short sioReadBaud16() {
return BaudReg;
}
@@ -353,13 +345,12 @@ void netError() {
SysRunGui();
}
-
void sioInterrupt() {
#ifdef PAD_LOG
PAD_LOG("Sio Interrupt (CP0.Status = %x)\n", psxRegs.CP0.n.Status);
#endif
// SysPrintf("Sio Interrupt\n");
- StatReg|= IRQ;
+ StatReg |= IRQ;
psxHu32ref(0x1070) |= SWAPu32(0x80);
}
@@ -457,7 +448,7 @@ void CreateMcd(char *mcd) {
if (f == NULL)
return;
- if (stat(mcd, &buf)!=-1) {
+ if (stat(mcd, &buf) != -1) {
if ((buf.st_size == MCD_SIZE + 3904) || strstr(mcd, ".gme")) {
s = s + 3904;
fputc('1', f);
@@ -611,7 +602,7 @@ void ConvertMcd(char *mcd, char *data) {
if (strstr(mcd, ".gme")) {
f = fopen(mcd, "wb");
if (f != NULL) {
- fwrite(data-3904, 1, MCD_SIZE+3904, f);
+ fwrite(data - 3904, 1, MCD_SIZE + 3904, f);
fclose(f);
}
f = fopen(mcd, "r+");
@@ -627,7 +618,7 @@ void ConvertMcd(char *mcd, char *data) {
fputc('S', f); s--;
fputc('T', f); s--;
fputc('D', f); s--;
- for(i=0;i<7;i++) {
+ for (i = 0; i < 7; i++) {
fputc(0, f); s--;
}
fputc(1, f); s--;
@@ -690,14 +681,14 @@ void GetMcdBlockInfo(int mcd, int block, McdBlock *Info) {
Info->IconCount = *ptr & 0x3;
- ptr+= 2;
+ ptr += 2;
- i=0;
+ i = 0;
memcpy(Info->sTitle, ptr, 48*2);
- for (i=0; i < 48; i++) {
+ for (i = 0; i < 48; i++) {
c = *(ptr) << 8;
- c|= *(ptr+1);
+ c|= *(ptr + 1);
if (!c) break;
if (c >= 0x8281 && c <= 0x8298)
@@ -712,19 +703,17 @@ void GetMcdBlockInfo(int mcd, int block, McdBlock *Info) {
else if (c == 0x816D) c = '[';
else if (c == 0x816E) c = ']';
else if (c == 0x817C) c = '-';
- else {
- c = ' ';
- }
+ else c = ' ';
str[i] = c;
- ptr+=2;
+ ptr += 2;
}
str[i] = 0;
ptr = data + block * 8192 + 0x60; // icon palete data
for (i = 0; i < 16; i++) {
- clut[i] = *((unsigned short*)ptr);
+ clut[i] = *((unsigned short *)ptr);
ptr += 2;
}