]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Make CHD support optional (WITH_CHD), also remove static for a couple
authorFrode Solheim <frode@fs-uae.net>
Wed, 29 Jan 2014 23:32:45 +0000 (00:32 +0100)
committerFrode Solheim <frode@fs-uae.net>
Wed, 29 Jan 2014 23:35:12 +0000 (00:35 +0100)
of functions which are used elsewhere in FS-UAE.

blkdev_cdimage.cpp
hardfile.cpp
od-win32/sysconfig.h

index a4400b2f4feb542643e305a497ac7c45f1c547b7..84e0edf39f490fe44acad4924dd0fcbe748a7a07 100644 (file)
 #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
 
@@ -66,7 +68,9 @@ struct cdtoc
        audenc enctype;
        int writeoffset;
        int subcode;
+#ifdef WITH_CHD
        const cdrom_track_info *chdtrack;
+#endif
 };
 
 struct cdunit {
@@ -92,8 +96,10 @@ 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];
@@ -140,7 +146,9 @@ static struct cdtoc *findtoc (struct cdunit *cdu, int *sectorp)
 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);
@@ -236,7 +244,7 @@ static uae_u8 *flac_get_data (struct cdtoc *t)
        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;
@@ -249,7 +257,7 @@ static void sub_to_interleaved (const uae_u8 *s, uae_u8 *d)
                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;
@@ -269,10 +277,12 @@ static int getsub_deinterleaved (uae_u8 *dst, struct cdunit *cdu, struct cdtoc *
        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;
@@ -396,7 +406,6 @@ static void *cdda_play_func (void *v)
 {
        int cdda_pos;
        int num_sectors = CDDA_BUFFERS;
-       int quit = 0;
        int bufnum;
        int bufon[2];
        int oldplay;
@@ -538,6 +547,7 @@ static void *cdda_play_func (void *v)
                                        }
                                        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;
@@ -545,6 +555,7 @@ static void *cdda_play_func (void *v)
                                                                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;
@@ -1174,6 +1185,7 @@ end:
        return cdu->tracks;
 }
 
+#ifdef WITH_CHD
 static int parsechd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
 {
        chd_error err;
@@ -1260,7 +1272,7 @@ static int parsechd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
        }
        return cdu->tracks;
 }
-
+#endif
 
 static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
 {
@@ -1695,8 +1707,10 @@ static int parse_image (struct cdunit *cdu, 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);
@@ -1827,11 +1841,13 @@ static void unload_image (struct cdunit *cdu)
                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;
index ce60ce2ab87d71a4e105bf100ef4844314d0a636..903f5f957184fe0bf948ec03afa79a8b03b9c08f 100644 (file)
@@ -7,8 +7,6 @@
 *           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
@@ -465,7 +463,7 @@ int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
        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, '.');
@@ -537,7 +535,7 @@ int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
                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);
@@ -557,11 +555,13 @@ void hdf_close (struct hardfiledata *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;
@@ -866,12 +866,15 @@ static int hdf_read2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, in
                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);
 }
 
@@ -881,8 +884,10 @@ static int hdf_write2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, i
                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);
 }
index 72f1fbbdd6843667894866e692b3988d1fb12e9d..7a01da22343504995de57bd405be336aaab3d63b 100644 (file)
@@ -75,6 +75,7 @@
 #define SANA2 /* SANA2 network driver */
 #define AMAX /* A-Max ROM adapater emulation */
 #define RETROPLATFORM /* Cloanto RetroPlayer support */
+#define WITH_CHD
 #define WITH_LUA /* lua scripting */
 
 #else