mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
cdrom: add atip check function, show relative and absolute MSF for read command
This commit is contained in:
parent
c4d443b5c5
commit
2ef16de941
@ -936,12 +936,15 @@ int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, si
|
||||
unsigned char control = buf[4 + (i * 11) + 1] & 0xF;
|
||||
unsigned char tno = buf[4 + (i * 11) + 2];
|
||||
unsigned char point = buf[4 + (i * 11) + 3];
|
||||
/*unsigned char amin = buf[4 + (i * 11) + 4];
|
||||
unsigned char asec = buf[4 + (i * 11) + 5];
|
||||
unsigned char aframe = buf[4 + (i * 11) + 6];*/
|
||||
unsigned char pmin = buf[4 + (i * 11) + 8];
|
||||
unsigned char psec = buf[4 + (i * 11) + 9];
|
||||
unsigned char pframe = buf[4 + (i * 11) + 10];
|
||||
unsigned lba = cdrom_msf_to_lba(pmin, psec, pframe);
|
||||
|
||||
/*printf("i %d control %d adr %d tno %d point %d: ", i, control, adr, tno, point);*/
|
||||
/*printf("i %d control %d adr %d tno %d point %d: amin %d asec %d aframe %d pmin %d psec %d pframe %d\n", i, control, adr, tno, point, amin, asec, aframe, pmin, psec, pframe);*/
|
||||
/* why is control always 0? */
|
||||
|
||||
if (/*(control == 4 || control == 6) && */adr == 1 && tno == 0 && point >= 1 && point <= 99)
|
||||
@ -1266,6 +1269,7 @@ struct string_list* cdrom_get_available_drives(void)
|
||||
|
||||
sscanf(dir_list->elems[i].data + strlen("/dev/sg"), "%d", &dev_index);
|
||||
|
||||
dev_index = '0' + dev_index;
|
||||
attr.i = dev_index;
|
||||
|
||||
snprintf(drive_string, sizeof(drive_string), "Drive %d: ", drive_index + 1);
|
||||
@ -1480,3 +1484,26 @@ bool cdrom_get_timeouts(libretro_vfs_implementation_file *stream, cdrom_group_ti
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cdrom_has_atip(const libretro_vfs_implementation_file *stream)
|
||||
{
|
||||
/* MMC Command: READ TOC/PMA/ATIP */
|
||||
unsigned char cdb[] = {0x43, 0x2, 0x4, 0, 0, 0, 0, 0x9, 0x30, 0};
|
||||
unsigned char buf[32] = {0};
|
||||
unsigned short atip_len = 0;
|
||||
int rv = cdrom_send_command(stream, DIRECTION_IN, buf, sizeof(buf), cdb, sizeof(cdb), 0);
|
||||
|
||||
if (rv)
|
||||
return false;
|
||||
|
||||
atip_len = buf[0] << 8 | buf[1];
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("ATIP Length %d, Disc Type %d, Disc Sub-Type %d\n", atip_len, (buf[6] >> 6) & 0x1, ((buf[6] >> 5) & 0x1) << 2 | ((buf[6] >> 4) & 0x1) << 1 | ((buf[6] >> 3) & 0x1) << 0);
|
||||
#endif
|
||||
|
||||
if (atip_len < 5)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -115,6 +115,8 @@ bool cdrom_set_read_cache(const libretro_vfs_implementation_file *stream, bool e
|
||||
|
||||
bool cdrom_get_timeouts(libretro_vfs_implementation_file *stream, cdrom_group_timeouts_t *timeouts);
|
||||
|
||||
bool cdrom_has_atip(const libretro_vfs_implementation_file *stream);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -365,11 +365,15 @@ int64_t retro_vfs_file_read_cdrom(libretro_vfs_implementation_file *stream,
|
||||
unsigned char min = 0;
|
||||
unsigned char sec = 0;
|
||||
unsigned char frame = 0;
|
||||
unsigned char rmin = 0;
|
||||
unsigned char rsec = 0;
|
||||
unsigned char rframe = 0;
|
||||
|
||||
cdrom_lba_to_msf(stream->cdrom.cur_lba, &min, &sec, &frame);
|
||||
cdrom_lba_to_msf(stream->cdrom.cur_lba - vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].lba, &rmin, &rsec, &rframe);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("CDROM Read: Reading %" PRIu64 " bytes from %s starting at byte offset %" PRIu64 " (MSF %02u:%02u:%02u) (LBA %u) skip %" PRIu64 "...\n", len, stream->orig_path, stream->cdrom.byte_pos, (unsigned)min, (unsigned)sec, (unsigned)frame, stream->cdrom.cur_lba, skip);
|
||||
printf("CDROM Read: Reading %" PRIu64 " bytes from %s starting at byte offset %" PRIu64 " (rMSF %02u:%02u:%02u aMSF %02u:%02u:%02u) (LBA %u) skip %" PRIu64 "...\n", len, stream->orig_path, stream->cdrom.byte_pos, (unsigned)rmin, (unsigned)rsec, (unsigned)rframe, (unsigned)min, (unsigned)sec, (unsigned)frame, stream->cdrom.cur_lba, skip);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
@ -387,6 +391,7 @@ int64_t retro_vfs_file_read_cdrom(libretro_vfs_implementation_file *stream,
|
||||
|
||||
stream->cdrom.byte_pos += len;
|
||||
stream->cdrom.cur_lba = vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].lba + (stream->cdrom.byte_pos / 2352);
|
||||
|
||||
cdrom_lba_to_msf(stream->cdrom.cur_lba, &stream->cdrom.cur_min, &stream->cdrom.cur_sec, &stream->cdrom.cur_frame);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
|
Loading…
x
Reference in New Issue
Block a user