This commit is contained in:
twinaphex 2019-10-30 13:22:08 +01:00
parent a205a1bf69
commit 0e069748e0
7 changed files with 53 additions and 9 deletions

View File

@ -1682,6 +1682,8 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des
bytes = read_compressed(chd, blockoffs, blocklen);
if (bytes == NULL)
return CHDERR_READ_ERROR;
if (!chd->codecintf[rawmap[0]])
return CHDERR_UNSUPPORTED_FORMAT;
switch (chd->codecintf[rawmap[0]]->compression)
{
case CHD_CODEC_CD_LZMA:

View File

@ -31,25 +31,31 @@ RETRO_BEGIN_DECLS
* of a CD (following the ISO-9660 directory structure definition)
*/
typedef struct cdfs_track_t
{
intfstream_t* stream;
unsigned int stream_sector_size;
unsigned int stream_sector_header_size;
unsigned int pregap_sectors;
} cdfs_track_t;
typedef struct cdfs_file_t
{
int first_sector;
int current_sector;
unsigned int current_sector_offset;
int sector_buffer_valid;
unsigned int stream_sector_size;
unsigned int stream_sector_header_size;
unsigned int size;
unsigned int pos;
intfstream_t* stream;
uint8_t sector_buffer[2048];
struct cdfs_track_t* track;
} cdfs_file_t;
/* opens the specified file within the CD or virtual CD.
* if path is NULL, will open the raw CD (useful for reading CD without having to worry about sector sizes,
* headers, or checksum data)
*/
int cdfs_open_file(cdfs_file_t* file, intfstream_t* stream, const char* path);
int cdfs_open_file(cdfs_file_t* file, cdfs_track_t* stream, const char* path);
void cdfs_close_file(cdfs_file_t* file);
@ -61,6 +67,8 @@ int64_t cdfs_tell(cdfs_file_t* file);
int64_t cdfs_seek(cdfs_file_t* file, int64_t offset, int whence);
void cdfs_seek_sector(cdfs_file_t* file, unsigned int sector);
/* opens the specified track in a CD or virtual CD file - the resulting stream should be passed to
* cdfs_open_file to get access to a file within the CD.
*
@ -75,11 +83,11 @@ int64_t cdfs_seek(cdfs_file_t* file, int64_t offset, int whence);
* MODE1/2048 - untested
* MODE2/2336 - untested
*/
intfstream_t* cdfs_open_track(const char* path, unsigned int track_index);
cdfs_track_t* cdfs_open_track(const char* path, unsigned int track_index);
/* opens the first data track in a CD or virtual CD file. see cdfs_open_track for supported file formats
*/
intfstream_t* cdfs_open_data_track(const char* path);
cdfs_track_t* cdfs_open_data_track(const char* path);
/* opens a raw track file for a CD or virtual CD.
*
@ -89,7 +97,10 @@ intfstream_t* cdfs_open_data_track(const char* path);
* bin - path will point to the bin file
* iso - path will point to the iso file
*/
intfstream_t* cdfs_open_raw_track(const char* path);
cdfs_track_t* cdfs_open_raw_track(const char* path);
/* closes the CD or virtual CD track and frees the associated memory */
void cdfs_close_track(cdfs_track_t* track);
RETRO_END_DECLS

View File

@ -2524,7 +2524,7 @@ struct retro_core_option_display
/* Maximum number of values permitted for a core option
* NOTE: This may be increased on a core-by-core basis
* if required (doing so has no effect on the frontend) */
#define RETRO_NUM_CORE_OPTION_VALUES_MAX 192
#define RETRO_NUM_CORE_OPTION_VALUES_MAX 128
struct retro_core_option_value
{

View File

@ -57,6 +57,8 @@ int64_t chdstream_seek(chdstream_t *stream, int64_t offset, int whence);
ssize_t chdstream_get_size(chdstream_t *stream);
uint32_t chdstream_get_pregap(chdstream_t* stream);
RETRO_END_DECLS
#endif

View File

@ -96,6 +96,8 @@ int64_t intfstream_get_size(intfstream_internal_t *intf);
int intfstream_flush(intfstream_internal_t *intf);
uint32_t intfstream_get_chd_pregap(intfstream_internal_t *intf);
intfstream_t* intfstream_open_file(const char *path,
unsigned mode, unsigned hints);

View File

@ -426,5 +426,22 @@ int64_t chdstream_seek(chdstream_t *stream, int64_t offset, int whence)
ssize_t chdstream_get_size(chdstream_t *stream)
{
return stream->track_end;
return stream->track_end;
}
uint32_t chdstream_get_pregap(chdstream_t *stream)
{
metadata_t meta;
uint32_t frame_offset = 0;
uint32_t i;
for (i = 0; chdstream_get_meta(stream->chd, i, &meta); ++i)
{
if (stream->track_frame == frame_offset)
return meta.pregap;
frame_offset += meta.frames + meta.extra;
}
return 0;
}

View File

@ -421,6 +421,16 @@ void intfstream_putc(intfstream_internal_t *intf, int c)
}
}
uint32_t intfstream_get_chd_pregap(intfstream_internal_t *intf)
{
#ifdef HAVE_CHD
if (intf->type == INTFSTREAM_CHD)
return chdstream_get_pregap(intf->chd.fp);
#endif
return 0;
}
intfstream_t* intfstream_open_file(const char *path,
unsigned mode, unsigned hints)
{