aboutsummaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/cdrom.c55
-rw-r--r--libpcsxcore/cdrom.h5
2 files changed, 38 insertions, 22 deletions
diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c
index 966bb70..7b5cdf2 100644
--- a/libpcsxcore/cdrom.c
+++ b/libpcsxcore/cdrom.c
@@ -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;