summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2011-01-12 02:51:29 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2011-01-12 02:51:29 +0000
commit27e8b5744ddab50cc9ef50b6ee1f3a94010a8cea (patch)
treec38e3e5475e499b769368cb34129c70f1e2a36f8
parent9bbb363c552598dcec7d17c7e6386a6f405edcab (diff)
downloadpcsxr-27e8b5744ddab50cc9ef50b6ee1f3a94010a8cea.tar.gz
- Added -slowboot parameter.
- Load SBI file from patches/SLUS_xxx.xx.sbi instead. - Inlined the I-cache code for performance improvement. - Fixed endianness issue (not tested). git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@62024 e17a0e51-4ae3-4d35-97c3-1a29b211df97
-rw-r--r--gui/LnxMain.c3
-rw-r--r--libpcsxcore/cdriso.c60
-rw-r--r--libpcsxcore/cdrom.c26
-rw-r--r--libpcsxcore/misc.c1
-rw-r--r--libpcsxcore/ppf.c62
-rw-r--r--libpcsxcore/ppf.h3
-rw-r--r--libpcsxcore/psxinterpreter.c109
-rw-r--r--libpcsxcore/r3000a.c7
-rw-r--r--libpcsxcore/r3000a.h76
-rw-r--r--win32/gui/WndMain.c2
10 files changed, 161 insertions, 188 deletions
diff --git a/gui/LnxMain.c b/gui/LnxMain.c
index 36f15464..247bf105 100644
--- a/gui/LnxMain.c
+++ b/gui/LnxMain.c
@@ -292,7 +292,8 @@ int main(int argc, char *argv[]) {
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-runcd")) runcd = RUN_CD;
else if (!strcmp(argv[i], "-nogui")) UseGui = FALSE;
- else if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
+ else if (!strcmp(argv[i], "-psxout")) Config.PsxOut = TRUE;
+ else if (!strcmp(argv[i], "-slowboot")) Config.SlowBoot = TRUE;
else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
else if (!strcmp(argv[i], "-cfg")) {
if (i+1 >= argc) break;
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index f2746943..5c83990b 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -701,61 +701,6 @@ static int opensubfile(const char *isoname) {
return 0;
}
-// redump.org SBI files
-u8 sbitime[256][3];
-u8 sbicount;
-
-int opensbifile(const char *isoname) {
- FILE *sbihandle;
- char sbiname[MAXPATHLEN];
-
-
- // init
- sbicount = 0;
-
-
- // copy name of the iso and change extension from .img to .sbi
- strncpy(sbiname, isoname, sizeof(sbiname));
- sbiname[MAXPATHLEN - 1] = '\0';
- if (strlen(sbiname) >= 4) {
- strcpy(sbiname + strlen(sbiname) - 4, ".sbi");
- }
- else {
- return -1;
- }
-
- sbihandle = fopen(sbiname, "rb");
- if (sbihandle == NULL) {
- return -1;
- }
-
-
- // 4-byte SBI header
- fread( sbiname, 1, 4, sbihandle );
- while( !feof(sbihandle) ) {
- u8 subq[11];
- fread( sbitime[ sbicount++ ], 1, 3, sbihandle );
- fread( subq, 1, 11, sbihandle );
- }
-
-
- return 0;
-}
-
-int checkSBI(u8 *time) {
- int lcv;
-
- // both BCD format
- for( lcv=0; lcv<sbicount; lcv++ ) {
- if( time[0] == sbitime[lcv][0] &&
- time[1] == sbitime[lcv][1] &&
- time[2] == sbitime[lcv][2] )
- return 1;
- }
-
- return 0;
-}
-
long CALLBACK ISOinit(void) {
assert(cdHandle == NULL);
assert(subHandle == NULL);
@@ -830,14 +775,9 @@ static long CALLBACK ISOopen(void) {
fseek(cdHandle, 0, SEEK_SET);
}
-
if (!subChanMixed && opensubfile(GetIsoFile()) == 0) {
SysPrintf("[+sub]");
}
-
- if (opensbifile(GetIsoFile()) == 0) {
- SysPrintf("[+sbi]");
- }
SysPrintf(".\n");
diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c
index 3759dd65..7c3a1eb1 100644
--- a/libpcsxcore/cdrom.c
+++ b/libpcsxcore/cdrom.c
@@ -480,11 +480,6 @@ static void ReadTrack( u8 *time ) {
}
-extern int opensbifile(const char *isoname);
-extern int cdrIsoActive(void);
-extern int checkSBI(u8 *time);
-
-
void AddIrqQueue(unsigned char irq, unsigned long ecycle) {
cdr.Irq = irq;
cdr.eCycle = ecycle;
@@ -1215,7 +1210,7 @@ void cdrInterrupt() {
}
// redump.org - wipe time
- if( !cdr.Play && checkSBI(cdr.Result+5) ) {
+ if( !cdr.Play && CheckSBI(cdr.Result+5) ) {
memset( cdr.Result+2, 0, 6 );
}
@@ -1351,7 +1346,7 @@ void cdrInterrupt() {
if (CDR_getStatus(&stat) == -1) {
cdr.Result[0] = 0x00; // 0x08 and cdr.Result[1]|0x10 : audio cd, enters cd player
- cdr.Result[1] = 0x00; // 0x80 leads to the menu in the bios, else loads CD
+ cdr.Result[1] = 0x80; // 0x80 leads to the menu in the bios, else loads CD
}
else {
if (stat.Type == 2) {
@@ -1363,12 +1358,17 @@ void cdrInterrupt() {
}
else {
// Data CD
- cdr.Result[0] = 0x08;
- cdr.Result[1] = 0x00;
+ if (CdromId[0] == '\0') {
+ cdr.Result[0] = 0x00;
+ cdr.Result[1] = 0x80;
+ }
+ else {
+ cdr.Result[0] = 0x08;
+ cdr.Result[1] = 0x00;
+ }
}
}
- if (CdromId[0] == '\0') cdr.Result[1] |= 0x80;
cdr.Result[2] = 0x00;
cdr.Result[3] = 0x00;
strncpy((char *)&cdr.Result[4], "PCSX", 4);
@@ -2299,11 +2299,7 @@ void cdrReset() {
memset(&cdr, 0, sizeof(cdr));
cdr.CurTrack = 1;
cdr.File = 1;
- cdr.Channel = 1;
-
- if( !cdrIsoActive() ) {
- opensbifile( "redump.sbi" );
- }
+ cdr.Channel = 1;
}
int cdrFreeze(gzFile f, int Mode) {
diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c
index f3b29816..3f47e083 100644
--- a/libpcsxcore/misc.c
+++ b/libpcsxcore/misc.c
@@ -346,6 +346,7 @@ int CheckCdrom() {
SysPrintf(_("CD-ROM ID: %.9s\n"), CdromId);
BuildPPFCache();
+ LoadSBI();
return 0;
}
diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c
index 45c8733c..d421d09e 100644
--- a/libpcsxcore/ppf.c
+++ b/libpcsxcore/ppf.c
@@ -1,7 +1,8 @@
-/* PPF Patch Support for PCSX-Reloaded
+/* PPF/SBI Support for PCSX-Reloaded
* Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
+ * Copyright (c) 2010, shalma.
*
- * Based on P.E.Op.S CDR Plugin by Pete Bernert.
+ * PPF code based on P.E.Op.S CDR Plugin by Pete Bernert.
* Copyright (c) 2002, Pete Bernert.
*
* This program is free software; you can redistribute it and/or modify
@@ -330,3 +331,60 @@ void BuildPPFCache() {
SysPrintf(_("Loaded PPF %d.0 patch: %s.\n"), method + 1, szPPF);
}
+
+// redump.org SBI files
+static u8 sbitime[256][3], sbicount;
+
+void LoadSBI() {
+ FILE *sbihandle;
+ char buffer[16], sbifile[MAXPATHLEN];
+
+ // Generate filename in the format of SLUS_123.45.sbi
+ buffer[0] = toupper(CdromId[0]);
+ buffer[1] = toupper(CdromId[1]);
+ buffer[2] = toupper(CdromId[2]);
+ buffer[3] = toupper(CdromId[3]);
+ buffer[4] = '_';
+ buffer[5] = CdromId[4];
+ buffer[6] = CdromId[5];
+ buffer[7] = CdromId[6];
+ buffer[8] = '.';
+ buffer[9] = CdromId[7];
+ buffer[10] = CdromId[8];
+ buffer[11] = '.';
+ buffer[12] = 's';
+ buffer[13] = 'b';
+ buffer[14] = 'i';
+ buffer[15] = '\0';
+
+ sprintf(sbifile, "%s%s", Config.PatchesDir, buffer);
+
+ // init
+ sbicount = 0;
+
+ sbihandle = fopen(sbifile, "rb");
+ if (sbihandle == NULL) return;
+
+ // 4-byte SBI header
+ fseek(sbihandle, 4, SEEK_SET);
+ while (!feof(sbihandle)) {
+ fread(sbitime[sbicount++], 1, 3, sbihandle);
+ fseek(sbihandle, 11, SEEK_CUR);
+ }
+
+ SysPrintf(_("Loaded SBI file: %s.\n"), sbifile);
+}
+
+boolean CheckSBI(const u8 *time) {
+ int lcv;
+
+ // both BCD format
+ for (lcv = 0; lcv < sbicount; lcv++) {
+ if (time[0] == sbitime[lcv][0] &&
+ time[1] == sbitime[lcv][1] &&
+ time[2] == sbitime[lcv][2])
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/libpcsxcore/ppf.h b/libpcsxcore/ppf.h
index f578028b..a8adecbb 100644
--- a/libpcsxcore/ppf.h
+++ b/libpcsxcore/ppf.h
@@ -27,6 +27,9 @@ void BuildPPFCache();
void FreePPFCache();
void CheckPPFCache(unsigned char *pB, unsigned char m, unsigned char s, unsigned char f);
+void LoadSBI();
+boolean CheckSBI(const u8 *time);
+
#ifdef __cplusplus
}
#endif
diff --git a/libpcsxcore/psxinterpreter.c b/libpcsxcore/psxinterpreter.c
index 1ddc73cd..77791897 100644
--- a/libpcsxcore/psxinterpreter.c
+++ b/libpcsxcore/psxinterpreter.c
@@ -47,102 +47,6 @@ void (*psxREG[32])();
void (*psxCP0[32])();
void (*psxCP2[64])();
void (*psxCP2BSC[32])();
-
-/*
-Formula One 2001
-- Use old CPU cache code when the RAM location is
- updated with new code (affects in-game racing)
-
-TODO:
-- I-cache / D-cache swapping
-- Isolate D-cache from RAM
-*/
-
-u32 *Read_ICache( u32 pc, u32 isolate )
-{
-#define U32_PTR(x) (SWAP32(* (u32 *)(x)))
-#define U32_PTR_REF(x) (* (u32 *)(x))
-
-
- u32 pc_bank, pc_offset, pc_cache;
- u8 *IAddr, *ICode;
-
- pc_bank = pc >> 24;
- pc_offset = pc & 0xffffff;
- pc_cache = pc & 0xfff;
-
- IAddr = psxRegs.ICache_Addr;
- ICode = psxRegs.ICache_Code;
-
-
- //return PSXM(pc);
-
-
-
- // clear I-cache
- if( psxRegs.ICache_valid == 0 )
- {
- memset( psxRegs.ICache_Addr, 0xff, sizeof(psxRegs.ICache_Addr) );
- memset( psxRegs.ICache_Code, 0xff, sizeof(psxRegs.ICache_Code) );
-
- psxRegs.ICache_valid = 1;
- }
-
-
-
- // uncached
- if( pc_bank >= 0xa0 )
- return PSXM(pc);
-
-
- // cached - RAM
- if( pc_bank == 0x80 || pc_bank == 0x00 )
- {
- if( U32_PTR( IAddr + pc_cache ) == pc_offset )
- {
- // Cache hit - return last opcode used
- return ICode + pc_cache;
- }
- else
- {
- // Cache miss - addresses don't match
- // - default: 0xffffffff (not init)
-
- if( isolate == 0 )
- {
- // cache line is 4 bytes wide
- pc_offset &= ~0xf;
- pc_cache &= ~0xf;
-
- // address line
- U32_PTR_REF( IAddr + pc_cache + 0x0 ) = pc_offset + 0x0;
- U32_PTR_REF( IAddr + pc_cache + 0x4 ) = pc_offset + 0x4;
- U32_PTR_REF( IAddr + pc_cache + 0x8 ) = pc_offset + 0x8;
- U32_PTR_REF( IAddr + pc_cache + 0xc ) = pc_offset + 0xc;
-
- // opcode line
- pc_offset = pc & ~0xf;
- U32_PTR_REF( ICode + pc_cache + 0x0 ) = psxMu32( pc_offset + 0x0 );
- U32_PTR_REF( ICode + pc_cache + 0x4 ) = psxMu32( pc_offset + 0x4 );
- U32_PTR_REF( ICode + pc_cache + 0x8 ) = psxMu32( pc_offset + 0x8 );
- U32_PTR_REF( ICode + pc_cache + 0xc ) = psxMu32( pc_offset + 0xc );
- }
-
- // normal code
- return PSXM(pc);
- }
- }
-
-
- /*
- TODO: Probably should add cached BIOS
- */
-
-
- // default
- return PSXM(pc);
-}
-
static void delayRead(int reg, u32 bpc) {
u32 rold, rnew;
@@ -362,8 +266,7 @@ void psxDelayTest(int reg, u32 bpc) {
u32 tmp;
// Don't execute yet - just peek
- //code = (u32 *)PSXM(bpc);
- code = Read_ICache(bpc,1);
+ code = Read_ICache(bpc, TRUE);
tmp = ((code == NULL) ? 0 : SWAP32(*code));
branch = 1;
@@ -392,8 +295,7 @@ __inline void doBranch(u32 tar) {
branchPC = tar;
// branch delay slot
- //code = (u32 *)PSXM(psxRegs.pc);
- code = Read_ICache( psxRegs.pc, 1 );
+ code = Read_ICache(psxRegs.pc, TRUE);
psxRegs.code = ((code == NULL) ? 0 : SWAP32(*code));
@@ -1039,7 +941,7 @@ static int intInit() {
}
static void intReset() {
- psxRegs.ICache_valid = 0;
+ psxRegs.ICache_valid = FALSE;
}
static void intExecute() {
@@ -1059,9 +961,8 @@ static void intShutdown() {
}
// interpreter execution
-inline void execI() {
- //u32 *code = (u32 *)PSXM(psxRegs.pc);
- u32 *code = Read_ICache( psxRegs.pc,0 );
+inline void execI() {
+ u32 *code = Read_ICache(psxRegs.pc, FALSE);
psxRegs.code = ((code == NULL) ? 0 : SWAP32(*code));
debugI();
diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c
index bcae44ef..1422d52f 100644
--- a/libpcsxcore/r3000a.c
+++ b/libpcsxcore/r3000a.c
@@ -25,10 +25,7 @@
#include "cdrom.h"
#include "mdec.h"
#include "gpu.h"
-#include "gte.h"
-
-extern u32 *Read_ICache( u32 pc, u32 isolate );
-
+#include "gte.h"
R3000Acpu *psxCpu = NULL;
psxRegisters psxRegs;
@@ -116,7 +113,7 @@ void psxBranchTest() {
u32 opcode;
// Crash Bandicoot 2: Don't run exceptions when GTE in pipeline
- opcode = *Read_ICache( psxRegs.pc, 1 );
+ opcode = SWAP32(*Read_ICache(psxRegs.pc, TRUE));
if( ((opcode >> 24) & 0xfe) != 0x4a ) {
#ifdef PSXCPU_LOG
PSXCPU_LOG("Interrupt: %x %x\n", psxHu32(0x1070), psxHu32(0x1074));
diff --git a/libpcsxcore/r3000a.h b/libpcsxcore/r3000a.h
index 8d5fd618..3547069e 100644
--- a/libpcsxcore/r3000a.h
+++ b/libpcsxcore/r3000a.h
@@ -173,11 +173,85 @@ typedef struct {
struct { u32 sCycle, cycle; } intCycle[32];
u8 ICache_Addr[0x1000];
u8 ICache_Code[0x1000];
- u32 ICache_valid;
+ boolean ICache_valid;
} psxRegisters;
extern psxRegisters psxRegs;
+/*
+Formula One 2001
+- Use old CPU cache code when the RAM location is
+ updated with new code (affects in-game racing)
+
+TODO:
+- I-cache / D-cache swapping
+- Isolate D-cache from RAM
+*/
+
+static inline u32 *Read_ICache(u32 pc, boolean isolate) {
+ u32 pc_bank, pc_offset, pc_cache;
+ u8 *IAddr, *ICode;
+
+ pc_bank = pc >> 24;
+ pc_offset = pc & 0xffffff;
+ pc_cache = pc & 0xfff;
+
+ IAddr = psxRegs.ICache_Addr;
+ ICode = psxRegs.ICache_Code;
+
+ // clear I-cache
+ if (!psxRegs.ICache_valid) {
+ memset(psxRegs.ICache_Addr, 0xff, sizeof(psxRegs.ICache_Addr));
+ memset(psxRegs.ICache_Code, 0xff, sizeof(psxRegs.ICache_Code));
+
+ psxRegs.ICache_valid = TRUE;
+ }
+
+ // uncached
+ if (pc_bank >= 0xa0)
+ return PSXM(pc);
+
+ // cached - RAM
+ if (pc_bank == 0x80 || pc_bank == 0x00) {
+ if (SWAP32(*(u32 *)(IAddr + pc_cache)) == pc_offset) {
+ // Cache hit - return last opcode used
+ return ICode + pc_cache;
+ } else {
+ // Cache miss - addresses don't match
+ // - default: 0xffffffff (not init)
+
+ if (!isolate) {
+ // cache line is 4 bytes wide
+ pc_offset &= ~0xf;
+ pc_cache &= ~0xf;
+
+ // address line
+ *(u32 *)(IAddr + pc_cache + 0x0) = SWAP32(pc_offset + 0x0);
+ *(u32 *)(IAddr + pc_cache + 0x4) = SWAP32(pc_offset + 0x4);
+ *(u32 *)(IAddr + pc_cache + 0x8) = SWAP32(pc_offset + 0x8);
+ *(u32 *)(IAddr + pc_cache + 0xc) = SWAP32(pc_offset + 0xc);
+
+ // opcode line
+ pc_offset = pc & ~0xf;
+ *(u32 *)(ICode + pc_cache + 0x0) = psxMu32(pc_offset + 0x0);
+ *(u32 *)(ICode + pc_cache + 0x4) = psxMu32(pc_offset + 0x4);
+ *(u32 *)(ICode + pc_cache + 0x8) = psxMu32(pc_offset + 0x8);
+ *(u32 *)(ICode + pc_cache + 0xc) = psxMu32(pc_offset + 0xc);
+ }
+
+ // normal code
+ return PSXM(pc);
+ }
+ }
+
+ /*
+ TODO: Probably should add cached BIOS
+ */
+
+ // default
+ return PSXM(pc);
+}
+
#if defined(__BIGENDIAN__)
#define _i32(x) *(s32 *)&x
diff --git a/win32/gui/WndMain.c b/win32/gui/WndMain.c
index 90f7fcb4..7d1360e4 100644
--- a/win32/gui/WndMain.c
+++ b/win32/gui/WndMain.c
@@ -208,6 +208,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
}
} else if (strcmp(arg, "-psxout") == 0) {
Config.PsxOut = TRUE;
+ } else if (strcmp(arg, "-slowboot") == 0) {
+ Config.SlowBoot = TRUE;
} else if (strcmp(arg, "-help") == 0) {
MessageBox(gApp.hWnd, _(
"Usage: pcsx [options]\n"