notaz.gp2x.de
/
pcsx_rearmed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #347 from justinweiss/enable-chd-3ds
[pcsx_rearmed.git]
/
libpcsxcore
/
cdriso.c
diff --git
a/libpcsxcore/cdriso.c
b/libpcsxcore/cdriso.c
index
7007f55
..
daed921
100644
(file)
--- a/
libpcsxcore/cdriso.c
+++ b/
libpcsxcore/cdriso.c
@@
-27,7
+27,9
@@
#include <errno.h>
#include <zlib.h>
#include <errno.h>
#include <zlib.h>
+#ifdef HAVE_CHD
#include <chd.h>
#include <chd.h>
+#endif
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
@@
-94,6
+96,7
@@
static struct {
unsigned int sector_in_blk;
} *compr_img;
unsigned int sector_in_blk;
} *compr_img;
+#ifdef HAVE_CHD
static struct {
unsigned char (*buffer)[CD_FRAMESIZE_RAW + SUB_FRAMESIZE];
chd_file* chd;
static struct {
unsigned char (*buffer)[CD_FRAMESIZE_RAW + SUB_FRAMESIZE];
chd_file* chd;
@@
-102,6
+105,7
@@
static struct {
unsigned int current_hunk;
unsigned int sector_in_hunk;
} *chd_img;
unsigned int current_hunk;
unsigned int sector_in_hunk;
} *chd_img;
+#endif
int (*cdimg_read_func)(FILE *f, unsigned int base, void *dest, int sector);
int (*cdimg_read_func)(FILE *f, unsigned int base, void *dest, int sector);
@@
-1039,6
+1043,7
@@
fail_io:
return -1;
}
return -1;
}
+#ifdef HAVE_CHD
static int handlechd(const char *isofile) {
chd_img = calloc(1, sizeof(*chd_img));
if (chd_img == NULL)
static int handlechd(const char *isofile) {
chd_img = calloc(1, sizeof(*chd_img));
if (chd_img == NULL)
@@
-1110,6
+1115,7
@@
fail_io:
}
return -1;
}
}
return -1;
}
+#endif
// this function tries to get the .sub file of the given .img
static int opensubfile(const char *isoname) {
// this function tries to get the .sub file of the given .img
static int opensubfile(const char *isoname) {
@@
-1272,6
+1278,7
@@
finish:
return CD_FRAMESIZE_RAW;
}
return CD_FRAMESIZE_RAW;
}
+#ifdef HAVE_CHD
static int cdread_chd(FILE *f, unsigned int base, void *dest, int sector)
{
int hunk;
static int cdread_chd(FILE *f, unsigned int base, void *dest, int sector)
{
int hunk;
@@
-1295,7
+1302,7
@@
finish:
CD_FRAMESIZE_RAW);
return CD_FRAMESIZE_RAW;
}
CD_FRAMESIZE_RAW);
return CD_FRAMESIZE_RAW;
}
-
+#endif
static int cdread_2048(FILE *f, unsigned int base, void *dest, int sector)
{
int ret;
static int cdread_2048(FILE *f, unsigned int base, void *dest, int sector)
{
int ret;
@@
-1315,9
+1322,11
@@
static unsigned char * CALLBACK ISOgetBuffer_compr(void) {
return compr_img->buff_raw[compr_img->sector_in_blk] + 12;
}
return compr_img->buff_raw[compr_img->sector_in_blk] + 12;
}
+#ifdef HAVE_CHD
static unsigned char * CALLBACK ISOgetBuffer_chd(void) {
return chd_img->buffer[chd_img->sector_in_hunk] + 12;
}
static unsigned char * CALLBACK ISOgetBuffer_chd(void) {
return chd_img->buffer[chd_img->sector_in_hunk] + 12;
}
+#endif
static unsigned char * CALLBACK ISOgetBuffer(void) {
return cdbuffer + 12;
static unsigned char * CALLBACK ISOgetBuffer(void) {
return cdbuffer + 12;
@@
-1340,6
+1349,7
@@
static long CALLBACK ISOopen(void) {
boolean isMode1ISO = FALSE;
char alt_bin_filename[MAXPATHLEN];
const char *bin_filename;
boolean isMode1ISO = FALSE;
char alt_bin_filename[MAXPATHLEN];
const char *bin_filename;
+ char image_str[1024] = {0};
if (cdHandle != NULL) {
return 0; // it's already open
if (cdHandle != NULL) {
return 0; // it's already open
@@
-1352,7
+1362,7
@@
static long CALLBACK ISOopen(void) {
return -1;
}
return -1;
}
-
SysPrintf(_("Loaded CD Image: %s")
, GetIsoFile());
+
sprintf(image_str, "Loaded CD Image: %s"
, GetIsoFile());
cddaBigEndian = FALSE;
subChanMixed = FALSE;
cddaBigEndian = FALSE;
subChanMixed = FALSE;
@@
-1365,38
+1375,40
@@
static long CALLBACK ISOopen(void) {
cdimg_read_func = cdread_normal;
if (parsetoc(GetIsoFile()) == 0) {
cdimg_read_func = cdread_normal;
if (parsetoc(GetIsoFile()) == 0) {
-
SysPrintf(
"[+toc]");
+
strcat(image_str,
"[+toc]");
}
else if (parseccd(GetIsoFile()) == 0) {
}
else if (parseccd(GetIsoFile()) == 0) {
-
SysPrintf(
"[+ccd]");
+
strcat(image_str,
"[+ccd]");
}
else if (parsemds(GetIsoFile()) == 0) {
}
else if (parsemds(GetIsoFile()) == 0) {
-
SysPrintf(
"[+mds]");
+
strcat(image_str,
"[+mds]");
}
else if (parsecue(GetIsoFile()) == 0) {
}
else if (parsecue(GetIsoFile()) == 0) {
-
SysPrintf(
"[+cue]");
+
strcat(image_str,
"[+cue]");
}
if (handlepbp(GetIsoFile()) == 0) {
}
if (handlepbp(GetIsoFile()) == 0) {
-
SysPrintf("[
pbp]");
+
strcat(image_str, "[+
pbp]");
CDR_getBuffer = ISOgetBuffer_compr;
cdimg_read_func = cdread_compressed;
}
else if (handlecbin(GetIsoFile()) == 0) {
CDR_getBuffer = ISOgetBuffer_compr;
cdimg_read_func = cdread_compressed;
}
else if (handlecbin(GetIsoFile()) == 0) {
-
SysPrintf("[
cbin]");
+
strcat(image_str, "[+
cbin]");
CDR_getBuffer = ISOgetBuffer_compr;
cdimg_read_func = cdread_compressed;
}
CDR_getBuffer = ISOgetBuffer_compr;
cdimg_read_func = cdread_compressed;
}
+#ifdef HAVE_CHD
else if (handlechd(GetIsoFile()) == 0) {
else if (handlechd(GetIsoFile()) == 0) {
-
SysPrintf("[
chd]");
+
strcat(image_str, "[+
chd]");
CDR_getBuffer = ISOgetBuffer_chd;
cdimg_read_func = cdread_chd;
}
CDR_getBuffer = ISOgetBuffer_chd;
cdimg_read_func = cdread_chd;
}
+#endif
if (!subChanMixed && opensubfile(GetIsoFile()) == 0) {
if (!subChanMixed && opensubfile(GetIsoFile()) == 0) {
-
SysPrintf(
"[+sub]");
+
strcat(image_str,
"[+sub]");
}
if (opensbifile(GetIsoFile()) == 0) {
}
if (opensbifile(GetIsoFile()) == 0) {
-
SysPrintf(
"[+sbi]");
+
strcat(image_str,
"[+sbi]");
}
fseeko(cdHandle, 0, SEEK_END);
}
fseeko(cdHandle, 0, SEEK_END);
@@
-1434,13
+1446,13
@@
static long CALLBACK ISOopen(void) {
fseek(cdHandle, 0, SEEK_SET);
fread(&modeTest, 4, 1, cdHandle);
if (SWAP32(modeTest) != 0xffffff00) {
fseek(cdHandle, 0, SEEK_SET);
fread(&modeTest, 4, 1, cdHandle);
if (SWAP32(modeTest) != 0xffffff00) {
-
SysPrintf(
"[2048]");
+
strcat(image_str,
"[2048]");
isMode1ISO = TRUE;
}
}
fseek(cdHandle, 0, SEEK_SET);
isMode1ISO = TRUE;
}
}
fseek(cdHandle, 0, SEEK_SET);
- SysPrintf("
.\n"
);
+ SysPrintf("
%s.\n", image_str
);
PrintTracks();
PrintTracks();
@@
-1479,12
+1491,14
@@
static long CALLBACK ISOclose(void) {
compr_img = NULL;
}
compr_img = NULL;
}
+#ifdef HAVE_CHD
if (chd_img != NULL) {
chd_close(chd_img->chd);
free(chd_img->buffer);
free(chd_img);
chd_img = NULL;
}
if (chd_img != NULL) {
chd_close(chd_img->chd);
free(chd_img->buffer);
free(chd_img);
chd_img = NULL;
}
+#endif
for (i = 1; i <= numtracks; i++) {
if (ti[i].handle != NULL) {
for (i = 1; i <= numtracks; i++) {
if (ti[i].handle != NULL) {