aboutsummaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authortwinaphex2013-03-18 01:16:31 +0100
committertwinaphex2013-03-18 01:16:31 +0100
commit22dade5ca95efa7fb3530023dbab77f8516bfed7 (patch)
tree40a660c1e7a806abe03b2c9f2e6389073894877b /libpcsxcore
parent24f4865eff11beb6348d9e0e310d593477359afe (diff)
parent101e053c72e9299bfbd1cbf6a8de9ba6cff11e4c (diff)
downloadpcsx_rearmed-22dade5ca95efa7fb3530023dbab77f8516bfed7.tar.gz
pcsx_rearmed-22dade5ca95efa7fb3530023dbab77f8516bfed7.tar.bz2
pcsx_rearmed-22dade5ca95efa7fb3530023dbab77f8516bfed7.zip
Merge git://github.com/notaz/pcsx_rearmed
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/cdriso.c9
-rw-r--r--libpcsxcore/cdrom.c57
-rw-r--r--libpcsxcore/cdrom.h5
-rw-r--r--libpcsxcore/new_dynarec/new_dynarec.c16
-rw-r--r--libpcsxcore/new_dynarec/pcsxmem.c6
-rw-r--r--libpcsxcore/psxbios.c3
-rw-r--r--libpcsxcore/psxmem.c30
7 files changed, 83 insertions, 43 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index 21203da..dde21bc 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -1316,8 +1316,12 @@ static long CALLBACK ISOclose(void) {
}
}
numtracks = 0;
+ ti[1].type = 0;
UnloadSBI();
+ memset(cdbuffer, 0, sizeof(cdbuffer));
+ CDR_getBuffer = ISOgetBuffer;
+
return 0;
}
@@ -1400,6 +1404,7 @@ static void DecodeRawSubData(void) {
// uses bcd format
static long CALLBACK ISOreadTrack(unsigned char *time) {
int sector = MSF2SECT(btoi(time[0]), btoi(time[1]), btoi(time[2]));
+ long ret;
if (cdHandle == NULL) {
return -1;
@@ -1414,7 +1419,9 @@ static long CALLBACK ISOreadTrack(unsigned char *time) {
}
}
- cdimg_read_func(cdHandle, 0, cdbuffer, sector);
+ ret = cdimg_read_func(cdHandle, 0, cdbuffer, sector);
+ if (ret < 0)
+ return -1;
if (subHandle != NULL) {
fseek(subHandle, sector * SUB_FRAMESIZE, SEEK_SET);
diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c
index 966bb70..38fecf7 100644
--- a/libpcsxcore/cdrom.c
+++ b/libpcsxcore/cdrom.c
@@ -205,7 +205,7 @@ static void sec2msf(unsigned int s, u8 *msf) {
cdr.Reading = 0; \
psxRegs.interrupt &= ~(1 << PSXINT_CDREAD); \
} \
- cdr.StatP &= ~STATUS_READ;\
+ cdr.StatP &= ~(STATUS_READ|STATUS_SEEK);\
}
#define StopCdda() { \
@@ -492,7 +492,10 @@ void cdrPlayInterrupt()
setIrq();
}
- memcpy(cdr.SetSectorPlay, cdr.SetSector, 4);
+ if (cdr.SetlocPending) {
+ memcpy(cdr.SetSectorPlay, cdr.SetSector, 4);
+ cdr.SetlocPending = 0;
+ }
Find_CurTrack(cdr.SetSectorPlay);
ReadTrack(cdr.SetSectorPlay);
cdr.TrackChanged = FALSE;
@@ -574,13 +577,17 @@ void cdrInterrupt() {
case CdlSetloc:
break;
+ do_CdlPlay:
case CdlPlay:
StopCdda();
if (cdr.Seeked == SEEK_PENDING) {
// XXX: wrong, should seek instead..
- memcpy( cdr.SetSectorPlay, cdr.SetSector, 4 );
cdr.Seeked = SEEK_DONE;
}
+ if (cdr.SetlocPending) {
+ memcpy(cdr.SetSectorPlay, cdr.SetSector, 4);
+ cdr.SetlocPending = 0;
+ }
// BIOS CD Player
// - Pause player, hit Track 01/02/../xx (Setloc issued!!)
@@ -900,13 +907,22 @@ void cdrInterrupt() {
case CdlReadN:
case CdlReadS:
+ if (cdr.SetlocPending) {
+ memcpy(cdr.SetSectorPlay, cdr.SetSector, 4);
+ cdr.SetlocPending = 0;
+ }
+ Find_CurTrack(cdr.SetSectorPlay);
+
+ if ((cdr.Mode & MODE_CDDA) && cdr.CurTrack > 1)
+ // Read* acts as play for cdda tracks in cdda mode
+ goto do_CdlPlay;
+
cdr.Reading = 1;
cdr.FirstSector = 1;
// Fighting Force 2 - update subq time immediately
// - fixes new game
- Find_CurTrack(cdr.SetSector);
- ReadTrack(cdr.SetSector);
+ ReadTrack(cdr.SetSectorPlay);
// Crusaders of Might and Magic - update getlocl now
@@ -1057,7 +1073,7 @@ void cdrReadInterrupt() {
cdr.Result[0] = cdr.StatP;
cdr.Seeked = SEEK_DONE;
- ReadTrack(cdr.SetSector);
+ ReadTrack(cdr.SetSectorPlay);
buf = CDR_getBuffer();
if (buf == NULL)
@@ -1098,13 +1114,13 @@ void cdrReadInterrupt() {
}
}
- cdr.SetSector[2]++;
- if (cdr.SetSector[2] == 75) {
- cdr.SetSector[2] = 0;
- cdr.SetSector[1]++;
- if (cdr.SetSector[1] == 60) {
- cdr.SetSector[1] = 0;
- cdr.SetSector[0]++;
+ cdr.SetSectorPlay[2]++;
+ if (cdr.SetSectorPlay[2] == 75) {
+ cdr.SetSectorPlay[2] = 0;
+ cdr.SetSectorPlay[1]++;
+ if (cdr.SetSectorPlay[1] == 60) {
+ cdr.SetSectorPlay[1] = 0;
+ cdr.SetSectorPlay[0]++;
}
}
@@ -1124,7 +1140,7 @@ void cdrReadInterrupt() {
}
// update for CdlGetlocP
- ReadTrack(cdr.SetSector);
+ ReadTrack(cdr.SetSectorPlay);
}
/*
@@ -1218,18 +1234,14 @@ void cdrWrite1(unsigned char rt) {
for (i = 0; i < 3; i++)
set_loc[i] = btoi(cdr.Param[i]);
- // FIXME: clean up this SetSector/SetSectorPlay mess,
- // there should be single var tracking current sector pos
- if (cdr.Play)
- i = msf2sec(cdr.SetSectorPlay);
- else
- i = msf2sec(cdr.SetSector);
+ i = msf2sec(cdr.SetSectorPlay);
i = abs(i - msf2sec(set_loc));
if (i > 16)
cdr.Seeked = SEEK_PENDING;
memcpy(cdr.SetSector, set_loc, 3);
cdr.SetSector[3] = 0;
+ cdr.SetlocPending = 1;
break;
case CdlReadN:
@@ -1467,7 +1479,7 @@ int cdrFreeze(void *f, int Mode) {
if (Mode == 0 && !Config.Cdda)
CDR_stop();
- cdr.freeze_ver = 0x63647201;
+ cdr.freeze_ver = 0x63647202;
gzfreeze(&cdr, sizeof(cdr));
if (Mode == 1) {
@@ -1488,6 +1500,9 @@ int cdrFreeze(void *f, int Mode) {
ReadTrack(tmpp);
if (cdr.Play) {
+ if (cdr.freeze_ver < 0x63647202)
+ memcpy(cdr.SetSectorPlay, cdr.SetSector, 3);
+
Find_CurTrack(cdr.SetSectorPlay);
if (!Config.Cdda)
CDR_play(cdr.SetSectorPlay);
diff --git a/libpcsxcore/cdrom.h b/libpcsxcore/cdrom.h
index 5d7c358..543c619 100644
--- a/libpcsxcore/cdrom.h
+++ b/libpcsxcore/cdrom.h
@@ -73,13 +73,14 @@ typedef struct {
unsigned char ResultReady;
unsigned char Cmd;
unsigned char Readed;
+ unsigned char SetlocPending;
u32 Reading;
unsigned char ResultTN[6];
unsigned char ResultTD[4];
- unsigned char SetSector[4];
- unsigned char SetSectorEnd[4];
unsigned char SetSectorPlay[4];
+ unsigned char SetSectorEnd[4];
+ unsigned char SetSector[4];
unsigned char Track;
boolean Play, Muted;
int CurTrack;
diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c
index bab5ec8..21c9669 100644
--- a/libpcsxcore/new_dynarec/new_dynarec.c
+++ b/libpcsxcore/new_dynarec/new_dynarec.c
@@ -279,6 +279,8 @@ int tracedebug=0;
//#define DEBUG_CYCLE_COUNT 1
+#define NO_CYCLE_PENALTY_THR 12
+
int cycle_multiplier; // 100 for 1.0
static int CLOCK_ADJUST(int x)
@@ -4981,6 +4983,7 @@ void do_cc(int i,signed char i_regmap[],int *adj,int addr,int taken,int invert)
int count;
int jaddr;
int idle=0;
+ int t=0;
if(itype[i]==RJUMP)
{
*adj=0;
@@ -4988,7 +4991,7 @@ void do_cc(int i,signed char i_regmap[],int *adj,int addr,int taken,int invert)
//if(ba[i]>=start && ba[i]<(start+slen*4))
if(internal_branch(branch_regs[i].is32,ba[i]))
{
- int t=(ba[i]-start)>>2;
+ t=(ba[i]-start)>>2;
if(is_ds[t]) *adj=-1; // Branch into delay slot adds an extra cycle
else *adj=ccadj[t];
}
@@ -5007,7 +5010,14 @@ void do_cc(int i,signed char i_regmap[],int *adj,int addr,int taken,int invert)
emit_jmp(0);
}
else if(*adj==0||invert) {
- emit_addimm_and_set_flags(CLOCK_ADJUST(count+2),HOST_CCREG);
+ int cycles=CLOCK_ADJUST(count+2);
+ // faster loop HACK
+ if (t&&*adj) {
+ int rel=t-i;
+ if(-NO_CYCLE_PENALTY_THR<rel&&rel<0)
+ cycles=CLOCK_ADJUST(*adj)+count+2-*adj;
+ }
+ emit_addimm_and_set_flags(cycles,HOST_CCREG);
jaddr=(int)out;
emit_jns(0);
}
@@ -9853,7 +9863,7 @@ int new_recompile_block(int addr)
// GTE runs in parallel until accessed, divide by 2 for a rough guess
cc+=gte_cycletab[source[i]&0x3f]/2;
}
- else if(/*itype[i]==LOAD||*/itype[i]==STORE||itype[i]==C1LS) // load causes weird timing issues
+ else if(/*itype[i]==LOAD||itype[i]==STORE||*/itype[i]==C1LS) // load,store causes weird timing issues
{
cc+=2; // 2 cycle penalty (after CLOCK_DIVIDER)
}
diff --git a/libpcsxcore/new_dynarec/pcsxmem.c b/libpcsxcore/new_dynarec/pcsxmem.c
index a42852a..3d14904 100644
--- a/libpcsxcore/new_dynarec/pcsxmem.c
+++ b/libpcsxcore/new_dynarec/pcsxmem.c
@@ -338,11 +338,17 @@ void new_dyna_pcsx_mem_init(void)
// scratchpad
map_l1_mem(mem_readtab, 0, 0x1f800000, 0x1000, psxH);
+ map_l1_mem(mem_readtab, 0, 0x9f800000, 0x1000, psxH);
map_l1_mem(mem_writetab, 0, 0x1f800000, 0x1000, psxH);
+ map_l1_mem(mem_writetab, 0, 0x9f800000, 0x1000, psxH);
// I/O
map_item(&mem_readtab[0x1f801000 >> 12], mem_iortab, 1);
+ map_item(&mem_readtab[0x9f801000 >> 12], mem_iortab, 1);
+ map_item(&mem_readtab[0xbf801000 >> 12], mem_iortab, 1);
map_item(&mem_writetab[0x1f801000 >> 12], mem_iowtab, 1);
+ map_item(&mem_writetab[0x9f801000 >> 12], mem_iowtab, 1);
+ map_item(&mem_writetab[0xbf801000 >> 12], mem_iowtab, 1);
// L2
// unmapped tables
diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c
index b3435ad..12c17ef 100644
--- a/libpcsxcore/psxbios.c
+++ b/libpcsxcore/psxbios.c
@@ -1837,7 +1837,8 @@ int nfile;
if ((*ptr & 0xF0) != 0x50) continue; \
ptr+= 0xa; \
if (pfile[0] == 0) { \
- strcpy(dir->name, ptr); \
+ strncpy(dir->name, ptr, sizeof(dir->name)); \
+ dir->name[sizeof(dir->name) - 1] = '\0'; \
} else for (i=0; i<20; i++) { \
if (pfile[i] == ptr[i]) { \
dir->name[i] = ptr[i]; \
diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c
index 9e44267..f12a981 100644
--- a/libpcsxcore/psxmem.c
+++ b/libpcsxcore/psxmem.c
@@ -198,7 +198,7 @@ void psxMemReset() {
void psxMemShutdown() {
psxUnmap(psxM, 0x00210000, MAP_TAG_RAM);
- psxUnmap(psxH, 0x1f800000, MAP_TAG_OTHER);
+ psxUnmap(psxH, 0x10000, MAP_TAG_OTHER);
psxUnmap(psxR, 0x80000, MAP_TAG_OTHER);
free(psxMemRLUT);
@@ -212,8 +212,8 @@ u8 psxMemRead8(u32 mem) {
u32 t;
t = mem >> 16;
- if (t == 0x1f80) {
- if (mem < 0x1f801000)
+ if (t == 0x1f80 || t == 0x9f80 || t == 0xbf80) {
+ if ((mem & 0xffff) < 0x400)
return psxHu8(mem);
else
return psxHwRead8(mem);
@@ -237,8 +237,8 @@ u16 psxMemRead16(u32 mem) {
u32 t;
t = mem >> 16;
- if (t == 0x1f80) {
- if (mem < 0x1f801000)
+ if (t == 0x1f80 || t == 0x9f80 || t == 0xbf80) {
+ if ((mem & 0xffff) < 0x400)
return psxHu16(mem);
else
return psxHwRead16(mem);
@@ -262,8 +262,8 @@ u32 psxMemRead32(u32 mem) {
u32 t;
t = mem >> 16;
- if (t == 0x1f80) {
- if (mem < 0x1f801000)
+ if (t == 0x1f80 || t == 0x9f80 || t == 0xbf80) {
+ if ((mem & 0xffff) < 0x400)
return psxHu32(mem);
else
return psxHwRead32(mem);
@@ -287,8 +287,8 @@ void psxMemWrite8(u32 mem, u8 value) {
u32 t;
t = mem >> 16;
- if (t == 0x1f80) {
- if (mem < 0x1f801000)
+ if (t == 0x1f80 || t == 0x9f80 || t == 0xbf80) {
+ if ((mem & 0xffff) < 0x400)
psxHu8(mem) = value;
else
psxHwWrite8(mem, value);
@@ -314,8 +314,8 @@ void psxMemWrite16(u32 mem, u16 value) {
u32 t;
t = mem >> 16;
- if (t == 0x1f80) {
- if (mem < 0x1f801000)
+ if (t == 0x1f80 || t == 0x9f80 || t == 0xbf80) {
+ if ((mem & 0xffff) < 0x400)
psxHu16ref(mem) = SWAPu16(value);
else
psxHwWrite16(mem, value);
@@ -342,8 +342,8 @@ void psxMemWrite32(u32 mem, u32 value) {
// if ((mem&0x1fffff) == 0x71E18 || value == 0x48088800) SysPrintf("t2fix!!\n");
t = mem >> 16;
- if (t == 0x1f80) {
- if (mem < 0x1f801000)
+ if (t == 0x1f80 || t == 0x9f80 || t == 0xbf80) {
+ if ((mem & 0xffff) < 0x400)
psxHu32ref(mem) = SWAPu32(value);
else
psxHwWrite32(mem, value);
@@ -400,8 +400,8 @@ void *psxMemPointer(u32 mem) {
u32 t;
t = mem >> 16;
- if (t == 0x1f80) {
- if (mem < 0x1f801000)
+ if (t == 0x1f80 || t == 0x9f80 || t == 0xbf80) {
+ if ((mem & 0xffff) < 0x400)
return (void *)&psxH[mem];
else
return NULL;