Commit b65f9995 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent 68a75379
...@@ -33,12 +33,12 @@ class Stream ...@@ -33,12 +33,12 @@ class Stream
virtual uint64_t read(void *data, uint64_t count, bool error_on_eos = true) = 0; virtual uint64_t read(void *data, uint64_t count, bool error_on_eos = true) = 0;
virtual void write(const void *data, uint64_t count) = 0; virtual void write(const void *data, uint64_t count) = 0;
virtual void truncate(uint64_t length) = 0; // Should have ftruncate()-like semantics; but avoid using it to extend files.
virtual void seek(int64_t offset, int whence) = 0; virtual void seek(int64_t offset, int whence) = 0;
virtual uint64_t tell(void) = 0; virtual uint64_t tell(void) = 0;
virtual uint64_t size(void) = 0; virtual void truncate(uint64_t length) = 0; // Should have ftruncate()-like semantics; but avoid using it to extend files.
virtual void flush(void) = 0; virtual void flush(void) = 0;
virtual uint64_t size(void) = 0;
virtual void close(void) = 0; // Flushes(in the case of writeable streams) and closes the stream. virtual void close(void) = 0; // Flushes(in the case of writeable streams) and closes the stream.
// Necessary since this operation can fail(running out of disk space, for instance), // Necessary since this operation can fail(running out of disk space, for instance),
// and throw an exception in the destructor would be a Bad Idea(TM). // and throw an exception in the destructor would be a Bad Idea(TM).
......
...@@ -42,34 +42,12 @@ CDAFReader::~CDAFReader() ...@@ -42,34 +42,12 @@ CDAFReader::~CDAFReader()
} }
enum CDAFReader* CDAFR_Open(Stream* fp)
{ {
AUDIO_VORBIS = 0,
#ifdef HAVE_MPC #ifdef HAVE_MPC
AUDIO_MPC, return CDAFR_MPC_Open(fp);
#else
return CDAFR_Vorbis_Open(fp);
#endif #endif
AUDIO_LAST
};
CDAFReader *CDAFR_Open(Stream *fp)
{
unsigned i;
for (i = 0; i < AUDIO_LAST; i++)
{
switch (i)
{
case AUDIO_VORBIS:
return CDAFR_Vorbis_Open(fp);
#ifdef HAVE_MPC
case AUDIO_MPC:
return CDAFR_MPC_Open(fp);
#endif
default:
break;
}
}
return(NULL);
} }
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#include "CDAccess.h" #include "CDAccess.h"
#include "CDAccess_Image.h" #include "CDAccess_Image.h"
#include "CDAccess_CCD.h" #include "CDAccess_CCD.h"
#ifdef HAVE_PBP
#include "CDAccess_PBP.h"
#endif
CDAccess::CDAccess() CDAccess::CDAccess()
{ {
...@@ -32,13 +35,17 @@ CDAccess::~CDAccess() ...@@ -32,13 +35,17 @@ CDAccess::~CDAccess()
CDAccess* CDAccess_Open(const std::string& path, bool image_memcache) CDAccess* CDAccess_Open(const std::string& path, bool image_memcache)
{ {
CDAccess *ret = NULL; CDAccess *ret = NULL;
if(path.size() >= 4 && !strcasecmp(path.c_str() + path.size() - 4, ".ccd")) if(path.size() >= 4 && !strcasecmp(path.c_str() + path.size() - 4, ".ccd"))
ret = new CDAccess_CCD(path, image_memcache); ret = new CDAccess_CCD(path, image_memcache);
else #ifdef HAVE_PBP
ret = new CDAccess_Image(path, image_memcache); else if(path.size() >= 4 && !strcasecmp(path.c_str() + path.size() - 4, ".pbp"))
ret = new CDAccess_PBP(path, image_memcache);
return ret; #endif
else
ret = new CDAccess_Image(path, image_memcache);
return ret;
} }
...@@ -12,7 +12,7 @@ class CDAccess ...@@ -12,7 +12,7 @@ class CDAccess
CDAccess(); CDAccess();
virtual ~CDAccess(); virtual ~CDAccess();
virtual void Read_Raw_Sector(uint8_t *buf, int32_t lba) = 0; virtual bool Read_Raw_Sector(uint8_t *buf, int32_t lba) = 0;
// Returns false if the read wouldn't be "fast"(i.e. reading from a disk), // Returns false if the read wouldn't be "fast"(i.e. reading from a disk),
// or if the read can't be done in a thread-safe re-entrant manner. // or if the read can't be done in a thread-safe re-entrant manner.
...@@ -20,7 +20,7 @@ class CDAccess ...@@ -20,7 +20,7 @@ class CDAccess
// Writes 96 bytes into pwbuf, and returns 'true' otherwise. // Writes 96 bytes into pwbuf, and returns 'true' otherwise.
virtual bool Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba) = 0; virtual bool Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba) = 0;
virtual void Read_TOC(TOC *toc) = 0; virtual bool Read_TOC(TOC *toc) = 0;
private: private:
CDAccess(const CDAccess&); // No copy constructor. CDAccess(const CDAccess&); // No copy constructor.
......
...@@ -400,24 +400,26 @@ CDAccess_CCD::~CDAccess_CCD() ...@@ -400,24 +400,26 @@ CDAccess_CCD::~CDAccess_CCD()
delete[] sub_data; delete[] sub_data;
} }
void CDAccess_CCD::Read_Raw_Sector(uint8_t *buf, int32_t lba) bool CDAccess_CCD::Read_Raw_Sector(uint8_t *buf, int32_t lba)
{ {
if(lba < 0) if(lba < 0)
{ {
synth_udapp_sector_lba(0xFF, tocd, lba, 0, buf); synth_udapp_sector_lba(0xFF, tocd, lba, 0, buf);
return; return true; /* TODO/FIXME - see if we need to return false here? */
} }
if((size_t)lba >= img_numsectors) if((size_t)lba >= img_numsectors)
{ {
synth_leadout_sector_lba(0xFF, tocd, lba, buf); synth_leadout_sector_lba(0xFF, tocd, lba, buf);
return; return true; /* TODO/FIXME - see if we need to return false here? */
} }
img_stream->seek(lba * 2352, SEEK_SET); img_stream->seek(lba * 2352, SEEK_SET);
img_stream->read(buf, 2352); img_stream->read(buf, 2352);
subpw_interleave(&sub_data[lba * 96], buf + 2352); subpw_interleave(&sub_data[lba * 96], buf + 2352);
return true;
} }
bool CDAccess_CCD::Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba) bool CDAccess_CCD::Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba)
...@@ -439,8 +441,9 @@ bool CDAccess_CCD::Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba) ...@@ -439,8 +441,9 @@ bool CDAccess_CCD::Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba)
return true; return true;
} }
void CDAccess_CCD::Read_TOC(TOC *toc) bool CDAccess_CCD::Read_TOC(TOC *toc)
{ {
*toc = tocd; *toc = tocd;
return true;
} }
...@@ -31,11 +31,11 @@ class CDAccess_CCD : public CDAccess ...@@ -31,11 +31,11 @@ class CDAccess_CCD : public CDAccess
CDAccess_CCD(const std::string& path, bool image_memcache); CDAccess_CCD(const std::string& path, bool image_memcache);
virtual ~CDAccess_CCD(); virtual ~CDAccess_CCD();
virtual void Read_Raw_Sector(uint8 *buf, int32 lba); virtual bool Read_Raw_Sector(uint8 *buf, int32 lba);
virtual bool Fast_Read_Raw_PW_TSRE(uint8* pwbuf, int32 lba); virtual bool Fast_Read_Raw_PW_TSRE(uint8* pwbuf, int32 lba);
virtual void Read_TOC(TOC *toc); virtual bool Read_TOC(TOC *toc);
private: private:
......
...@@ -30,13 +30,15 @@ ...@@ -30,13 +30,15 @@
#include "../mednafen.h" #include "../mednafen.h"
#include <sys/types.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
#include <memory> #include <memory>
#include <retro_stat.h>
#include "../general.h" #include "../general.h"
#include "../mednafen-endian.h" #include "../mednafen-endian.h"
#include "../FileStream.h" #include "../FileStream.h"
...@@ -1020,7 +1022,7 @@ CDAccess_Image::~CDAccess_Image() ...@@ -1020,7 +1022,7 @@ CDAccess_Image::~CDAccess_Image()
Cleanup(); Cleanup();
} }
void CDAccess_Image::Read_Raw_Sector(uint8_t *buf, int32_t lba) bool CDAccess_Image::Read_Raw_Sector(uint8_t *buf, int32_t lba)
{ {
uint8_t SimuQ[0xC]; uint8_t SimuQ[0xC];
int32_t track; int32_t track;
...@@ -1053,7 +1055,7 @@ void CDAccess_Image::Read_Raw_Sector(uint8_t *buf, int32_t lba) ...@@ -1053,7 +1055,7 @@ void CDAccess_Image::Read_Raw_Sector(uint8_t *buf, int32_t lba)
} }
synth_leadout_sector_lba(data_synth_mode, toc, lba, buf); synth_leadout_sector_lba(data_synth_mode, toc, lba, buf);
return; return true;
} }
// //
// //
...@@ -1180,6 +1182,8 @@ void CDAccess_Image::Read_Raw_Sector(uint8_t *buf, int32_t lba) ...@@ -1180,6 +1182,8 @@ void CDAccess_Image::Read_Raw_Sector(uint8_t *buf, int32_t lba)
ct->fp->read(buf + 2352, 96); ct->fp->read(buf + 2352, 96);
} }
} // end if audible part of audio track read. } // end if audible part of audio track read.
return true;
} }
bool CDAccess_Image::Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba) bool CDAccess_Image::Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba)
...@@ -1325,9 +1329,10 @@ int32_t CDAccess_Image::MakeSubPQ(int32_t lba, uint8_t *SubPWBuf) const ...@@ -1325,9 +1329,10 @@ int32_t CDAccess_Image::MakeSubPQ(int32_t lba, uint8_t *SubPWBuf) const
return track; return track;
} }
void CDAccess_Image::Read_TOC(TOC *rtoc) bool CDAccess_Image::Read_TOC(TOC *rtoc)
{ {
*rtoc = toc; *rtoc = toc;
return true;
} }
void CDAccess_Image::GenerateTOC(void) void CDAccess_Image::GenerateTOC(void)
......
...@@ -58,11 +58,11 @@ class CDAccess_Image : public CDAccess ...@@ -58,11 +58,11 @@ class CDAccess_Image : public CDAccess
CDAccess_Image(const std::string& path, bool image_memcache); CDAccess_Image(const std::string& path, bool image_memcache);
virtual ~CDAccess_Image(); virtual ~CDAccess_Image();
virtual void Read_Raw_Sector(uint8_t *buf, int32_t lba); virtual bool Read_Raw_Sector(uint8_t *buf, int32_t lba);
virtual bool Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba); virtual bool Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba);
virtual void Read_TOC(TOC *toc); virtual bool Read_TOC(TOC *toc);
private: private:
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <mednafen/mednafen.h> #include <mednafen/mednafen.h>
#include <math.h> #include <math.h>
#include <algorithm> #include <algorithm>
#include <trio/trio.h>
#include "scsicd.h" #include "scsicd.h"
#include "cdromif.h" #include "cdromif.h"
#include "SimpleFIFO.h" #include "SimpleFIFO.h"
...@@ -28,8 +27,6 @@ ...@@ -28,8 +27,6 @@
#include <emmintrin.h> #include <emmintrin.h>
#endif #endif
using namespace CDUtility;
static uint32_t CD_DATA_TRANSFER_RATE; static uint32_t CD_DATA_TRANSFER_RATE;
static uint32_t System_Clock; static uint32_t System_Clock;
static void (*CDIRQCallback)(int); static void (*CDIRQCallback)(int);
...@@ -173,7 +170,7 @@ static cdda_t cdda; ...@@ -173,7 +170,7 @@ static cdda_t cdda;
static SimpleFIFO<uint8_t> *din = NULL; static SimpleFIFO<uint8_t> *din = NULL;
static CDUtility::TOC toc; static TOC toc;
static uint32_t read_sec_start; static uint32_t read_sec_start;
static uint32_t read_sec; static uint32_t read_sec;
...@@ -2876,11 +2873,11 @@ uint32_t SCSICD_Run(scsicd_timestamp_t system_timestamp) ...@@ -2876,11 +2873,11 @@ uint32_t SCSICD_Run(scsicd_timestamp_t system_timestamp)
log_buffer[0] = 0; log_buffer[0] = 0;
lb_pos = trio_snprintf(log_buffer, 1024, "Command: %02x, %s%s ", cd.command_buffer[0], cmd_info_ptr->pretty_name ? cmd_info_ptr->pretty_name : "!!BAD COMMAND!!", lb_pos = snprintf(log_buffer, 1024, "Command: %02x, %s%s ", cd.command_buffer[0], cmd_info_ptr->pretty_name ? cmd_info_ptr->pretty_name : "!!BAD COMMAND!!",
(cmd_info_ptr->flags & SCF_UNTESTED) ? "(UNTESTED)" : ""); (cmd_info_ptr->flags & SCF_UNTESTED) ? "(UNTESTED)" : "");
for(int i = 0; i < RequiredCDBLen[cd.command_buffer[0] >> 4]; i++) for(int i = 0; i < RequiredCDBLen[cd.command_buffer[0] >> 4]; i++)
lb_pos += trio_snprintf(log_buffer + lb_pos, 1024 - lb_pos, "%02x ", cd.command_buffer[i]); lb_pos += snprintf(log_buffer + lb_pos, 1024 - lb_pos, "%02x ", cd.command_buffer[i]);
SCSILog("SCSI", "%s", log_buffer); SCSILog("SCSI", "%s", log_buffer);
//puts(log_buffer); //puts(log_buffer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment