Skip to content

Commit

Permalink
Not all CD image formats worked in relative path mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioni committed Oct 11, 2019
1 parent ec70215 commit 988a524
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
5 changes: 2 additions & 3 deletions blkdev.cpp
Expand Up @@ -2216,10 +2216,10 @@ int blkdev_is_audio_command(uae_u8 cmd)
case 0x03:
case 0x12:
case 0x15:
case 0x25:
case 0x35:
case 0x1a:
case 0x1e:
case 0x25:
case 0x35:
case 0x55:
case 0x5a:
return 0;
Expand All @@ -2229,7 +2229,6 @@ int blkdev_is_audio_command(uae_u8 cmd)
return -1;
}


int blkdev_execute_audio_command(int unitnum, uae_u8 *cdb, int cdblen, uae_u8 *inbuf, int inlen, uae_u8 *sense, int *senselen)
{
int len = inlen;
Expand Down
45 changes: 29 additions & 16 deletions blkdev_cdimage.cpp
Expand Up @@ -1299,14 +1299,17 @@ typedef struct {

#pragma pack()

static int parsemds (struct cdunit *cdu, struct zfile *zmds, const TCHAR *img)
static int parsemds (struct cdunit *cdu, struct zfile *zmds, const TCHAR *img, const TCHAR *curdir, const TCHAR *occurdir)
{
MDS_Header *head;
struct cdtoc *t;
uae_u8 *mds = NULL;
uae_u64 size;
MDS_SessionBlock *sb;

if (curdir)
my_setcurrentdir(occurdir, NULL);

write_log (_T("MDS TOC: '%s'\n"), img);
size = zfile_size (zmds);
mds = xmalloc (uae_u8, size);
Expand Down Expand Up @@ -1391,8 +1394,11 @@ static int parsemds (struct cdunit *cdu, struct zfile *zmds, const TCHAR *img)
}

#ifdef WITH_CHD
static int parsechd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
static int parsechd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img, const TCHAR *curdir, const TCHAR *ocurdir)
{
if (curdir)
my_setcurrentdir(ocurdir, NULL);

chd_error err;
struct cdrom_file *cdf;
struct zfile *f = zfile_dup (zcue);
Expand Down Expand Up @@ -1479,7 +1485,7 @@ static int parsechd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
}
#endif

static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img, const TCHAR *curdir, const TCHAR *ocurdir)
{
int mode;
int num, tracknum, trackmode;
Expand Down Expand Up @@ -1508,6 +1514,9 @@ static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
if (zsub)
write_log (_T("CCD: '%s' detected\n"), fname);

if (curdir)
my_setcurrentdir(ocurdir, NULL);

num = -1;
mode = -1;
for (;;) {
Expand Down Expand Up @@ -1610,7 +1619,7 @@ static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
return cdu->tracks;
}

static int parsecue (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
static int parsecue (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img, const TCHAR *curdir, const TCHAR *ocurdir)
{
int tracknum, pregap, postgap, lastpregap, lastpostgap;
int newfile, secoffset;
Expand Down Expand Up @@ -1875,7 +1884,7 @@ static int parsecue (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
return cdu->tracks;
}

static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img)
static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img, const TCHAR *curdir, const TCHAR *ocurdir)
{
uae_s64 size;
uae_s64 offset;
Expand All @@ -1885,6 +1894,9 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img)
uae_u32 lastlba = 0;
bool gotsession = false;

if (curdir)
my_setcurrentdir(ocurdir, NULL);

size = zfile_size(znrg);
zfile_fseek(znrg, size - 12, SEEK_SET);
zfile_fread(buf, 12, 1, znrg);
Expand Down Expand Up @@ -2063,33 +2075,34 @@ static int parse_image (struct cdunit *cdu, const TCHAR *img)
if (ext) {
TCHAR curdir[MAX_DPATH];
TCHAR oldcurdir[MAX_DPATH], *p;
TCHAR *pcurdir = NULL;

ext++;
oldcurdir[0] = 0;
_tcscpy (curdir, img);
p = curdir + _tcslen (curdir);
_tcscpy(curdir, img);
p = curdir + _tcslen(curdir);
while (p > curdir) {
if (*p == '/' || *p == '\\')
break;
p--;
}
*p = 0;
if (p > curdir)
my_setcurrentdir (curdir, oldcurdir);
if (p > curdir) {
pcurdir = curdir;
my_setcurrentdir(pcurdir, oldcurdir);
}

if (!_tcsicmp(ext, _T("cue"))) {
parsecue(cdu, zcue, img);
parsecue(cdu, zcue, img, pcurdir, oldcurdir);
} else if (!_tcsicmp(ext, _T("ccd"))) {
parseccd(cdu, zcue, img);
parseccd(cdu, zcue, img, pcurdir, oldcurdir);
} else if (!_tcsicmp(ext, _T("mds"))) {
parsemds(cdu, zcue, img);
parsemds(cdu, zcue, img, pcurdir, oldcurdir);
} else if (!_tcsicmp(ext, _T("nrg"))) {
parsenrg(cdu, zcue, img);
parsenrg(cdu, zcue, img, pcurdir, oldcurdir);
#ifdef WITH_CHD
} else if (!_tcsicmp(ext, _T("chd"))) {
if (oldcurdir[0])
my_setcurrentdir (oldcurdir, NULL);
parsechd (cdu, zcue, img);
parsechd (cdu, zcue, img, pcurdir, oldcurdir);
#endif
}

Expand Down

0 comments on commit 988a524

Please sign in to comment.