mirror of
https://github.com/libretro/beetle-pce-fast-libretro.git
synced 2025-02-17 05:38:28 +00:00
Update CDROM code
This commit is contained in:
parent
59bbdb1352
commit
c7a9524746
@ -19,6 +19,9 @@
|
||||
#include "CDAccess.h"
|
||||
#include "CDAccess_Image.h"
|
||||
#include "CDAccess_CCD.h"
|
||||
#ifdef HAVE_PBP
|
||||
#include "CDAccess_PBP.h"
|
||||
#endif
|
||||
|
||||
CDAccess::CDAccess()
|
||||
{
|
||||
@ -32,13 +35,17 @@ CDAccess::~CDAccess()
|
||||
|
||||
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"))
|
||||
ret = new CDAccess_CCD(path, image_memcache);
|
||||
else
|
||||
ret = new CDAccess_Image(path, image_memcache);
|
||||
if(path.size() >= 4 && !strcasecmp(path.c_str() + path.size() - 4, ".ccd"))
|
||||
ret = new CDAccess_CCD(path, image_memcache);
|
||||
#ifdef HAVE_PBP
|
||||
else if(path.size() >= 4 && !strcasecmp(path.c_str() + path.size() - 4, ".pbp"))
|
||||
ret = new CDAccess_PBP(path, image_memcache);
|
||||
#endif
|
||||
else
|
||||
ret = new CDAccess_Image(path, image_memcache);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ class CDAccess
|
||||
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),
|
||||
// or if the read can't be done in a thread-safe re-entrant manner.
|
||||
@ -20,7 +20,7 @@ class CDAccess
|
||||
// Writes 96 bytes into pwbuf, and returns 'true' otherwise.
|
||||
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:
|
||||
CDAccess(const CDAccess&); // No copy constructor.
|
||||
|
@ -400,24 +400,26 @@ CDAccess_CCD::~CDAccess_CCD()
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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->read(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)
|
||||
@ -439,8 +441,9 @@ bool CDAccess_CCD::Fast_Read_Raw_PW_TSRE(uint8_t* pwbuf, int32_t lba)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDAccess_CCD::Read_TOC(TOC *toc)
|
||||
bool CDAccess_CCD::Read_TOC(TOC *toc)
|
||||
{
|
||||
*toc = tocd;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,11 @@ class CDAccess_CCD : public CDAccess
|
||||
CDAccess_CCD(const std::string& path, bool image_memcache);
|
||||
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 void Read_TOC(TOC *toc);
|
||||
virtual bool Read_TOC(TOC *toc);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -30,13 +30,15 @@
|
||||
|
||||
#include "../mednafen.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <memory>
|
||||
|
||||
#include <retro_stat.h>
|
||||
|
||||
#include "../general.h"
|
||||
#include "../mednafen-endian.h"
|
||||
#include "../FileStream.h"
|
||||
@ -384,7 +386,7 @@ bool CDAccess_Image::ImageOpen(const std::string& path, bool image_memcache)
|
||||
static const unsigned max_args = 4;
|
||||
std::string linebuf;
|
||||
std::string cmdbuf, args[max_args];
|
||||
bool IsTOC = FALSE;
|
||||
bool IsTOC = false;
|
||||
int32_t active_track = -1;
|
||||
int32_t AutoTrackInc = 1; // For TOC
|
||||
CDRFILE_TRACK_INFO TmpTrack;
|
||||
@ -410,7 +412,7 @@ bool CDAccess_Image::ImageOpen(const std::string& path, bool image_memcache)
|
||||
if(fp.read(bom_tmp, 3, false) == 3 && bom_tmp[0] == 0xEF && bom_tmp[1] == 0xBB && bom_tmp[2] == 0xBF)
|
||||
{
|
||||
// Print an annoying error message, but don't actually error out.
|
||||
MDFN_PrintError(_("UTF-8 BOM detected at start of CUE sheet."));
|
||||
log_cb(RETRO_LOG_WARN, "UTF-8 BOM detected at start of CUE sheet.\n");
|
||||
}
|
||||
else
|
||||
fp.seek(0, SEEK_SET);
|
||||
@ -502,7 +504,7 @@ bool CDAccess_Image::ImageOpen(const std::string& path, bool image_memcache)
|
||||
}
|
||||
|
||||
if(TmpTrack.DIFormat == DI_FORMAT_AUDIO)
|
||||
TmpTrack.RawAudioMSBFirst = TRUE; // Silly cdrdao...
|
||||
TmpTrack.RawAudioMSBFirst = true; /* Silly cdrdao... */
|
||||
|
||||
if(!strcasecmp(args[1].c_str(), "RW"))
|
||||
{
|
||||
@ -1020,7 +1022,7 @@ CDAccess_Image::~CDAccess_Image()
|
||||
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];
|
||||
int32_t track;
|
||||
@ -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);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
//
|
||||
//
|
||||
@ -1180,6 +1182,8 @@ void CDAccess_Image::Read_Raw_Sector(uint8_t *buf, int32_t lba)
|
||||
ct->fp->read(buf + 2352, 96);
|
||||
}
|
||||
} // end if audible part of audio track read.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
||||
return track;
|
||||
}
|
||||
|
||||
void CDAccess_Image::Read_TOC(TOC *rtoc)
|
||||
bool CDAccess_Image::Read_TOC(TOC *rtoc)
|
||||
{
|
||||
*rtoc = toc;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDAccess_Image::GenerateTOC(void)
|
||||
|
@ -58,11 +58,11 @@ class CDAccess_Image : public CDAccess
|
||||
CDAccess_Image(const std::string& path, bool image_memcache);
|
||||
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 void Read_TOC(TOC *toc);
|
||||
virtual bool Read_TOC(TOC *toc);
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user