Skip to content

Commit 0e06974

Browse files
committed
Update
1 parent a205a1b commit 0e06974

7 files changed

Lines changed: 53 additions & 9 deletions

File tree

formats/libchdr/libchdr_chd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,8 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des
16821682
bytes = read_compressed(chd, blockoffs, blocklen);
16831683
if (bytes == NULL)
16841684
return CHDERR_READ_ERROR;
1685+
if (!chd->codecintf[rawmap[0]])
1686+
return CHDERR_UNSUPPORTED_FORMAT;
16851687
switch (chd->codecintf[rawmap[0]]->compression)
16861688
{
16871689
case CHD_CODEC_CD_LZMA:

include/formats/cdfs.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,31 @@ RETRO_BEGIN_DECLS
3131
* of a CD (following the ISO-9660 directory structure definition)
3232
*/
3333

34+
typedef struct cdfs_track_t
35+
{
36+
intfstream_t* stream;
37+
unsigned int stream_sector_size;
38+
unsigned int stream_sector_header_size;
39+
unsigned int pregap_sectors;
40+
} cdfs_track_t;
41+
3442
typedef struct cdfs_file_t
3543
{
3644
int first_sector;
3745
int current_sector;
3846
unsigned int current_sector_offset;
3947
int sector_buffer_valid;
40-
unsigned int stream_sector_size;
41-
unsigned int stream_sector_header_size;
4248
unsigned int size;
4349
unsigned int pos;
44-
intfstream_t* stream;
4550
uint8_t sector_buffer[2048];
51+
struct cdfs_track_t* track;
4652
} cdfs_file_t;
4753

4854
/* opens the specified file within the CD or virtual CD.
4955
* if path is NULL, will open the raw CD (useful for reading CD without having to worry about sector sizes,
5056
* headers, or checksum data)
5157
*/
52-
int cdfs_open_file(cdfs_file_t* file, intfstream_t* stream, const char* path);
58+
int cdfs_open_file(cdfs_file_t* file, cdfs_track_t* stream, const char* path);
5359

5460
void cdfs_close_file(cdfs_file_t* file);
5561

@@ -61,6 +67,8 @@ int64_t cdfs_tell(cdfs_file_t* file);
6167

6268
int64_t cdfs_seek(cdfs_file_t* file, int64_t offset, int whence);
6369

70+
void cdfs_seek_sector(cdfs_file_t* file, unsigned int sector);
71+
6472
/* opens the specified track in a CD or virtual CD file - the resulting stream should be passed to
6573
* cdfs_open_file to get access to a file within the CD.
6674
*
@@ -75,11 +83,11 @@ int64_t cdfs_seek(cdfs_file_t* file, int64_t offset, int whence);
7583
* MODE1/2048 - untested
7684
* MODE2/2336 - untested
7785
*/
78-
intfstream_t* cdfs_open_track(const char* path, unsigned int track_index);
86+
cdfs_track_t* cdfs_open_track(const char* path, unsigned int track_index);
7987

8088
/* opens the first data track in a CD or virtual CD file. see cdfs_open_track for supported file formats
8189
*/
82-
intfstream_t* cdfs_open_data_track(const char* path);
90+
cdfs_track_t* cdfs_open_data_track(const char* path);
8391

8492
/* opens a raw track file for a CD or virtual CD.
8593
*
@@ -89,7 +97,10 @@ intfstream_t* cdfs_open_data_track(const char* path);
8997
* bin - path will point to the bin file
9098
* iso - path will point to the iso file
9199
*/
92-
intfstream_t* cdfs_open_raw_track(const char* path);
100+
cdfs_track_t* cdfs_open_raw_track(const char* path);
101+
102+
/* closes the CD or virtual CD track and frees the associated memory */
103+
void cdfs_close_track(cdfs_track_t* track);
93104

94105
RETRO_END_DECLS
95106

include/libretro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@ struct retro_core_option_display
25242524
/* Maximum number of values permitted for a core option
25252525
* NOTE: This may be increased on a core-by-core basis
25262526
* if required (doing so has no effect on the frontend) */
2527-
#define RETRO_NUM_CORE_OPTION_VALUES_MAX 192
2527+
#define RETRO_NUM_CORE_OPTION_VALUES_MAX 128
25282528

25292529
struct retro_core_option_value
25302530
{

include/streams/chd_stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ int64_t chdstream_seek(chdstream_t *stream, int64_t offset, int whence);
5757

5858
ssize_t chdstream_get_size(chdstream_t *stream);
5959

60+
uint32_t chdstream_get_pregap(chdstream_t* stream);
61+
6062
RETRO_END_DECLS
6163

6264
#endif

include/streams/interface_stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ int64_t intfstream_get_size(intfstream_internal_t *intf);
9696

9797
int intfstream_flush(intfstream_internal_t *intf);
9898

99+
uint32_t intfstream_get_chd_pregap(intfstream_internal_t *intf);
100+
99101
intfstream_t* intfstream_open_file(const char *path,
100102
unsigned mode, unsigned hints);
101103

streams/chd_stream.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,5 +426,22 @@ int64_t chdstream_seek(chdstream_t *stream, int64_t offset, int whence)
426426

427427
ssize_t chdstream_get_size(chdstream_t *stream)
428428
{
429-
return stream->track_end;
429+
return stream->track_end;
430+
}
431+
432+
uint32_t chdstream_get_pregap(chdstream_t *stream)
433+
{
434+
metadata_t meta;
435+
uint32_t frame_offset = 0;
436+
uint32_t i;
437+
438+
for (i = 0; chdstream_get_meta(stream->chd, i, &meta); ++i)
439+
{
440+
if (stream->track_frame == frame_offset)
441+
return meta.pregap;
442+
443+
frame_offset += meta.frames + meta.extra;
444+
}
445+
446+
return 0;
430447
}

streams/interface_stream.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,16 @@ void intfstream_putc(intfstream_internal_t *intf, int c)
421421
}
422422
}
423423

424+
uint32_t intfstream_get_chd_pregap(intfstream_internal_t *intf)
425+
{
426+
#ifdef HAVE_CHD
427+
if (intf->type == INTFSTREAM_CHD)
428+
return chdstream_get_pregap(intf->chd.fp);
429+
#endif
430+
431+
return 0;
432+
}
433+
424434
intfstream_t* intfstream_open_file(const char *path,
425435
unsigned mode, unsigned hints)
426436
{

0 commit comments

Comments
 (0)