mirror of
https://github.com/libretro/RetroArch
synced 2025-02-22 03:40:43 +00:00
cdrom: add function for reading via LBA numbers
This commit is contained in:
parent
788b6cd39c
commit
38d49136ce
@ -1058,6 +1058,59 @@ int cdrom_read(libretro_vfs_implementation_file *stream, unsigned char min, unsi
|
||||
|
||||
rv = cdrom_send_command(stream, DIRECTION_IN, s, len, cdb, sizeof(cdb), skip);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("read msf status code %d\n", rv);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (rv)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cdrom_read_lba(libretro_vfs_implementation_file *stream, unsigned lba, void *s, size_t len, size_t skip)
|
||||
{
|
||||
/* MMC Command: READ CD */
|
||||
unsigned char cdb[] = {0xBE, 0, 0, 0, 0, 0, 0, 0, 0, 0xF8, 0, 0};
|
||||
unsigned lba_orig = lba;
|
||||
int rv;
|
||||
|
||||
lba = swap_if_big32(lba);
|
||||
|
||||
cdb[2] = (lba >> 24) & 0xFF;
|
||||
cdb[3] = (lba >> 16) & 0xFF;
|
||||
cdb[4] = (lba >> 8) & 0xFF;
|
||||
cdb[5] = (lba >> 0) & 0xFF;
|
||||
|
||||
if (len + skip <= 2352)
|
||||
{
|
||||
cdb[8] = 1;
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("single-frame read: from %d count %d skip %" PRId64 "\n", lba_orig, 1, skip);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned frames = lba_orig + ceil((len + skip) / 2352.0);
|
||||
unsigned lba_count = frames - lba_orig;
|
||||
|
||||
lba_count = swap_if_big32(lba_count);
|
||||
|
||||
cdb[6] = (lba_count >> 16) & 0xFF;
|
||||
cdb[7] = (lba_count >> 8) & 0xFF;
|
||||
cdb[8] = (lba_count >> 0) & 0xFF;
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("multi-frame read: from %d to %d len %d skip %" PRId64 "\n", lba_orig, frames, frames - lba_orig, skip);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
rv = cdrom_send_command(stream, DIRECTION_IN, s, len, cdb, sizeof(cdb), skip);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("read status code %d\n", rv);
|
||||
fflush(stdout);
|
||||
|
@ -79,6 +79,8 @@ int cdrom_get_inquiry(const libretro_vfs_implementation_file *stream, char *mode
|
||||
|
||||
int cdrom_read(libretro_vfs_implementation_file *stream, unsigned char min, unsigned char sec, unsigned char frame, void *s, size_t len, size_t skip);
|
||||
|
||||
int cdrom_read_lba(libretro_vfs_implementation_file *stream, unsigned lba, void *s, size_t len, size_t skip);
|
||||
|
||||
int cdrom_set_read_speed(libretro_vfs_implementation_file *stream, unsigned speed);
|
||||
|
||||
int cdrom_stop(const libretro_vfs_implementation_file *stream);
|
||||
|
@ -372,6 +372,7 @@ int64_t retro_vfs_file_read_cdrom(libretro_vfs_implementation_file *stream,
|
||||
#endif
|
||||
|
||||
rv = cdrom_read(stream, min, sec, frame, s, (size_t)len, skip);
|
||||
/*rv = cdrom_read_lba(stream, stream->cdrom.cur_lba, s, (size_t)len, skip);*/
|
||||
|
||||
if (rv)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user