#define FLAC__NO_DLL
#include "FLAC/stream_decoder.h"
+#ifdef WITH_CHD
#include "archivers/chd/chdtypes.h"
#include "archivers/chd/chd.h"
#include "archivers/chd/chdcd.h"
+#endif
#define scsi_log write_log
audenc enctype;
int writeoffset;
int subcode;
+#ifdef WITH_CHD
const cdrom_track_info *chdtrack;
+#endif
};
struct cdunit {
TCHAR imgname[MAX_DPATH];
uae_sem_t sub_sem;
struct device_info di;
+#ifdef WITH_CHD
chd_file *chd_f;
cdrom_file *chd_cdf;
+#endif
};
static struct cdunit cdunits[MAX_TOTAL_SCSI_DEVICES];
static int do_read (struct cdunit *cdu, struct cdtoc *t, uae_u8 *data, int sector, int offset, int size)
{
if (t->enctype == ENC_CHD) {
+#ifdef WITH_CHD
return read_partial_sector(cdu->chd_cdf, data, sector + t->offset, 0, offset, size) == CHDERR_NONE;
+#endif
} else if (t->handle) {
int ssize = t->size + t->skipsize;
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + offset, SEEK_SET);
return t->data;
}
-static void sub_to_interleaved (const uae_u8 *s, uae_u8 *d)
+void sub_to_interleaved (const uae_u8 *s, uae_u8 *d)
{
for (int i = 0; i < 8 * 12; i ++) {
int dmask = 0x80;
d++;
}
}
-static void sub_to_deinterleaved (const uae_u8 *s, uae_u8 *d)
+void sub_to_deinterleaved (const uae_u8 *s, uae_u8 *d)
{
for (int i = 0; i < 8 * 12; i ++) {
int dmask = 0x80;
uae_sem_wait (&cdu->sub_sem);
if (t->subcode) {
if (t->enctype == ENC_CHD) {
+#ifdef WITH_CHD
const cdrom_track_info *cti = t->chdtrack;
ret = do_read (cdu, t, dst, sector, cti->datasize, cti->subsize);
if (ret)
ret = t->subcode;
+#endif
} else if (t->subhandle) {
int offset = 0;
int totalsize = SUB_CHANNEL_SIZE;
{
int cdda_pos;
int num_sectors = CDDA_BUFFERS;
- int quit = 0;
int bufnum;
int bufon[2];
int oldplay;
}
if (!(t->ctrl & 4)) {
if (t->enctype == ENC_CHD) {
+#ifdef WITH_CHD
do_read (cdu, t, dst, sector, 0, t->size);
for (int i = 0; i < 2352; i+=2) {
uae_u8 p;
dst[i + 0] = dst[i + 1];
dst[i +1] = p;
}
+#endif
} else if (t->handle) {
int totalsize = t->size + t->skipsize;
int offset = t->offset;
return cdu->tracks;
}
+#ifdef WITH_CHD
static int parsechd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
{
chd_error err;
}
return cdu->tracks;
}
-
+#endif
static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
{
parseccd (cdu, zcue, img);
else if (!_tcsicmp (ext, _T("mds")))
parsemds (cdu, zcue, img);
+#ifdef WITH_CHD
else if (!_tcsicmp (ext, _T("chd")))
parsechd (cdu, zcue, img);
+#endif
if (oldcurdir[0])
my_setcurrentdir (oldcurdir, NULL);
xfree (t->subdata);
xfree (t->extrainfo);
}
+#ifdef WITH_CHD
cdrom_close (cdu->chd_cdf);
cdu->chd_cdf = NULL;
if (cdu->chd_f)
cdu->chd_f->close();
cdu->chd_f = NULL;
+#endif
memset (cdu->toc, 0, sizeof cdu->toc);
cdu->tracks = 0;
cdu->cdsize = 0;
* 2002 Toni Wilen (scsi emulation, 64-bit support)
*/
-#define USE_CHD 1
-
#include "sysconfig.h"
#include "sysdeps.h"
#include "execio.h"
#include "zfile.h"
-#if USE_CHD
+#ifdef WITH_CHD
#include "archivers/chd/chdtypes.h"
#include "archivers/chd/chd.h"
#endif
//#undef DEBUGME
-#define hf_log
-#define hf_log2
-#define scsi_log
-#define hf_log3
+#define hf_log(fmt, ...)
+#define hf_log2(fmt, ...)
+#define scsi_log(fmt, ...)
+#define hf_log3(fmt, ...)
//#define DEBUGME
#ifdef DEBUGME
hfd->hfd_type = 0;
if (!pname)
pname = hfd->ci.rootdir;
-#if USE_CHD
+#ifdef WITH_CHD
TCHAR nametmp[MAX_DPATH];
_tcscpy (nametmp, pname);
TCHAR *ext = _tcsrchr (nametmp, '.');
hfd->vhd_sectormapblock = -1;
hfd->vhd_bitmapsize = ((hfd->vhd_blocksize / (8 * 512)) + 511) & ~511;
}
- write_log (_T("HDF is VHD %s image, virtual size=%dK\n"),
+ write_log (_T("HDF is VHD %s image, virtual size=%lldK\n"),
hfd->hfd_type == HFD_VHD_FIXED ? _T("fixed") : _T("dynamic"),
hfd->virtsize / 1024);
hdf_init_cache (hfd);
{
hdf_flush_cache (hfd);
hdf_close_target (hfd);
+#ifdef WITH_CHD
if (hfd->chd_handle) {
chd_file *cf = (chd_file*)hfd->chd_handle;
cf->close();
hfd->chd_handle = NULL;
}
+#endif
hfd->hfd_type = 0;
xfree (hfd->vhd_header);
hfd->vhd_header = NULL;
return vhd_read (hfd, buffer, offset, len);
else if (hfd->hfd_type == HFD_VHD_FIXED)
return hdf_read_target (hfd, buffer, offset + 512, len);
+#ifdef WITH_CHD
else if (hfd->hfd_type == HFD_CHD) {
chd_file *cf = (chd_file*)hfd->chd_handle;
if (cf->read_bytes(offset, buffer, len) == CHDERR_NONE)
return len;
return 0;
- } else
+ }
+#endif
+ else
return hdf_read_target (hfd, buffer, offset, len);
}
return vhd_write (hfd, buffer, offset, len);
else if (hfd->hfd_type == HFD_VHD_FIXED)
return hdf_write_target (hfd, buffer, offset + 512, len);
+#ifdef WITH_CHD
else if (hfd->hfd_type == HFD_CHD)
return 0;
+#endif
else
return hdf_write_target (hfd, buffer, offset, len);
}