mirror of
https://github.com/libretro/libretro-common.git
synced 2025-04-02 10:31:51 -04:00
Update
This commit is contained in:
parent
c853996ab3
commit
daa1294a07
8 changed files with 286 additions and 102 deletions
182
cdrom/cdrom.c
182
cdrom/cdrom.c
|
@ -63,7 +63,7 @@ typedef enum
|
|||
DIRECTION_OUT
|
||||
} CDROM_CMD_Direction;
|
||||
|
||||
void lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned char *frame)
|
||||
void cdrom_lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned char *frame)
|
||||
{
|
||||
if (!min || !sec || !frame)
|
||||
return;
|
||||
|
@ -75,7 +75,7 @@ void lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned c
|
|||
*min = lba;
|
||||
}
|
||||
|
||||
unsigned msf_to_lba(unsigned char min, unsigned char sec, unsigned char frame)
|
||||
unsigned cdrom_msf_to_lba(unsigned char min, unsigned char sec, unsigned char frame)
|
||||
{
|
||||
return (min * 60 + sec) * 75 + frame;
|
||||
}
|
||||
|
@ -218,6 +218,22 @@ static void cdrom_print_sense_data(const unsigned char *sense, size_t len)
|
|||
break;
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
if (asc == 0x11 && ascq == 0x5)
|
||||
printf("Description: L-EC UNCORRECTABLE ERROR\n");
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
if (asc == 0x20 && ascq == 0)
|
||||
printf("Description: INVALID COMMAND OPERATION CODE\n");
|
||||
else if (asc == 0x24 && ascq == 0)
|
||||
printf("Description: INVALID FIELD IN CDB\n");
|
||||
else if (asc == 0x26 && ascq == 0)
|
||||
printf("Description: INVALID FIELD IN PARAMETER LIST\n");
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
if (asc == 0x28 && ascq == 0)
|
||||
|
@ -261,7 +277,7 @@ static int cdrom_send_command_win32(HANDLE fh, CDROM_CMD_Direction dir, void *bu
|
|||
break;
|
||||
}
|
||||
|
||||
sptd.s.TimeOutValue = 30;
|
||||
sptd.s.TimeOutValue = 5;
|
||||
sptd.s.DataBuffer = buf;
|
||||
sptd.s.DataTransferLength = len;
|
||||
sptd.s.SenseInfoLength = sizeof(sptd.sense);
|
||||
|
@ -306,7 +322,7 @@ static int cdrom_send_command_linux(int fd, CDROM_CMD_Direction dir, void *buf,
|
|||
sgio.dxfer_len = len;
|
||||
sgio.sbp = sense;
|
||||
sgio.mx_sb_len = sense_len;
|
||||
sgio.timeout = 30000;
|
||||
sgio.timeout = 5000;
|
||||
|
||||
rv = ioctl(fd, SG_IO, &sgio);
|
||||
|
||||
|
@ -323,11 +339,17 @@ static int cdrom_send_command(const libretro_vfs_implementation_file *stream, CD
|
|||
unsigned char sense[CDROM_MAX_SENSE_BYTES] = {0};
|
||||
unsigned char retries_left = CDROM_MAX_RETRIES;
|
||||
int rv = 0;
|
||||
size_t padded_req_bytes;
|
||||
|
||||
if (!cmd || cmd_len == 0)
|
||||
return 1;
|
||||
|
||||
xfer_buf = (unsigned char*)calloc(1, len + skip);
|
||||
if (cmd[0] == 0xBE || cmd[0] == 0xB9)
|
||||
padded_req_bytes = 2352 * ceil((len + skip) / 2352.0);
|
||||
else
|
||||
padded_req_bytes = len + skip;
|
||||
|
||||
xfer_buf = (unsigned char*)calloc(1, padded_req_bytes);
|
||||
|
||||
if (!xfer_buf)
|
||||
return 1;
|
||||
|
@ -343,6 +365,9 @@ static int cdrom_send_command(const libretro_vfs_implementation_file *stream, CD
|
|||
printf("%02X ", cmd[i]);
|
||||
}
|
||||
|
||||
if (len)
|
||||
printf("(buffer of size %" PRId64 " with skip bytes %" PRId64 " padded to %" PRId64 ")\n", len, skip, padded_req_bytes);
|
||||
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
@ -350,10 +375,10 @@ static int cdrom_send_command(const libretro_vfs_implementation_file *stream, CD
|
|||
|
||||
retry:
|
||||
#if defined(__linux__) && !defined(ANDROID)
|
||||
if (!cdrom_send_command_linux(fileno(stream->fp), dir, xfer_buf, len + skip, cmd, cmd_len, sense, sizeof(sense)))
|
||||
if (!cdrom_send_command_linux(fileno(stream->fp), dir, xfer_buf, padded_req_bytes, cmd, cmd_len, sense, sizeof(sense)))
|
||||
#else
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
if (!cdrom_send_command_win32(stream->fh, dir, xfer_buf, len + skip, cmd, cmd_len, sense, sizeof(sense)))
|
||||
if (!cdrom_send_command_win32(stream->fh, dir, xfer_buf, padded_req_bytes, cmd, cmd_len, sense, sizeof(sense)))
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
|
@ -364,6 +389,8 @@ retry:
|
|||
}
|
||||
else
|
||||
{
|
||||
cdrom_print_sense_data(sense, sizeof(sense));
|
||||
|
||||
/* INQUIRY/TEST should never fail, don't retry */
|
||||
if (cmd[0] != 0x0 && cmd[0] != 0x12)
|
||||
{
|
||||
|
@ -400,11 +427,7 @@ retry:
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("CHECK CONDITION\n");
|
||||
|
||||
cdrom_print_sense_data(sense, sizeof(sense));
|
||||
#endif
|
||||
rv = 1;
|
||||
}
|
||||
|
||||
|
@ -832,7 +855,7 @@ static int cdrom_read_track_info(libretro_vfs_implementation_file *stream, unsig
|
|||
printf("Track %d Info: ", track);
|
||||
printf("Copy: %d ", (buf[5] & 0x10) > 0);
|
||||
printf("Data Mode: %d ", buf[6] & 0xF);
|
||||
printf("LBA Start: %d ", lba);
|
||||
printf("LBA Start: %d (%d) ", lba, toc->track[track - 1].lba);
|
||||
printf("Track Size: %d\n", track_size);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
@ -918,7 +941,7 @@ int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, si
|
|||
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 = msf_to_lba(pmin, psec, pframe);
|
||||
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);*/
|
||||
/* why is control always 0? */
|
||||
|
@ -970,7 +993,7 @@ int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, si
|
|||
unsigned char sec = 0;
|
||||
unsigned char frame = 0;
|
||||
|
||||
lba_to_msf(pregap_lba_len, &min, &sec, &frame);
|
||||
cdrom_lba_to_msf(pregap_lba_len, &min, &sec, &frame);
|
||||
|
||||
pos += snprintf(*out_buf + pos, len - pos, " INDEX 00 00:00:00\n");
|
||||
pos += snprintf(*out_buf + pos, len - pos, " INDEX 01 %02u:%02u:%02u\n", (unsigned)min, (unsigned)sec, (unsigned)frame);
|
||||
|
@ -1048,9 +1071,9 @@ int cdrom_read(libretro_vfs_implementation_file *stream, unsigned char min, unsi
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned frames = msf_to_lba(min, sec, frame) + ceil((len + skip) / 2352.0);
|
||||
unsigned frames = cdrom_msf_to_lba(min, sec, frame) + ceil((len + skip) / 2352.0);
|
||||
|
||||
lba_to_msf(frames, &cdb[6], &cdb[7], &cdb[8]);
|
||||
cdrom_lba_to_msf(frames, &cdb[6], &cdb[7], &cdb[8]);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("multi-frame read: from %d %d %d to %d %d %d skip %" PRId64 "\n", cdb[3], cdb[4], cdb[5], cdb[6], cdb[7], cdb[8], skip);
|
||||
|
@ -1060,6 +1083,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);
|
||||
|
@ -1281,3 +1357,77 @@ bool cdrom_is_media_inserted(const libretro_vfs_implementation_file *stream)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool cdrom_set_read_cache(const libretro_vfs_implementation_file *stream, bool enabled)
|
||||
{
|
||||
/* MMC Command: MODE SENSE (10) and MODE SELECT (10) */
|
||||
unsigned char cdb_sense_changeable[] = {0x5A, 0, 0x48, 0, 0, 0, 0, 0, 0x14, 0};
|
||||
unsigned char cdb_sense[] = {0x5A, 0, 0x8, 0, 0, 0, 0, 0, 0x14, 0};
|
||||
unsigned char cdb_select[] = {0x55, 0x10, 0, 0, 0, 0, 0, 0, 0x14, 0};
|
||||
unsigned char buf[20] = {0};
|
||||
int rv, i;
|
||||
|
||||
rv = cdrom_send_command(stream, DIRECTION_IN, buf, sizeof(buf), cdb_sense_changeable, sizeof(cdb_sense_changeable), 0);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("mode sense changeable status code %d\n", rv);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (rv)
|
||||
return false;
|
||||
|
||||
if (!(buf[10] & 0x1))
|
||||
{
|
||||
/* RCD (read cache disable) bit is not changeable */
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("RCD (read cache disable) bit is not changeable.\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
rv = cdrom_send_command(stream, DIRECTION_IN, buf, sizeof(buf), cdb_sense, sizeof(cdb_sense), 0);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("mode sense status code %d\n", rv);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (rv)
|
||||
return false;
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("Mode sense data for caching mode page: ");
|
||||
|
||||
for (i = 0; i < sizeof(buf); i++)
|
||||
{
|
||||
printf("%02X ", buf[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
/* "When transferred during execution of the MODE SELECT (10) command, Mode Data Length is reserved." */
|
||||
for (i = 0; i < 8; i++)
|
||||
buf[i] = 0;
|
||||
|
||||
if (enabled)
|
||||
buf[10] &= ~1;
|
||||
else
|
||||
buf[10] |= 1;
|
||||
|
||||
rv = cdrom_send_command(stream, DIRECTION_OUT, buf, sizeof(buf), cdb_select, sizeof(cdb_select), 0);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("mode select status code %d\n", rv);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (rv)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -28,18 +28,13 @@
|
|||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <vfs/vfs.h>
|
||||
#include <libretro.h>
|
||||
#include <retro_common_api.h>
|
||||
#include <retro_inline.h>
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
#ifdef VFS_FRONTEND
|
||||
typedef struct retro_vfs_file_handle libretro_vfs_implementation_file;
|
||||
#else
|
||||
typedef struct libretro_vfs_implementation_file libretro_vfs_implementation_file;
|
||||
#endif
|
||||
|
||||
struct string_list;
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
@ -64,9 +59,9 @@ typedef struct
|
|||
cdrom_track_t track[99];
|
||||
} cdrom_toc_t;
|
||||
|
||||
void lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned char *frame);
|
||||
void cdrom_lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned char *frame);
|
||||
|
||||
unsigned msf_to_lba(unsigned char min, unsigned char sec, unsigned char frame);
|
||||
unsigned cdrom_msf_to_lba(unsigned char min, unsigned char sec, unsigned char frame);
|
||||
|
||||
void increment_msf(unsigned char *min, unsigned char *sec, unsigned char *frame);
|
||||
|
||||
|
@ -79,6 +74,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);
|
||||
|
@ -106,6 +103,8 @@ void cdrom_get_current_config_random_readable(const libretro_vfs_implementation_
|
|||
|
||||
int cdrom_get_sense(const libretro_vfs_implementation_file *stream, unsigned char *sense, size_t len);
|
||||
|
||||
bool cdrom_set_read_cache(const libretro_vfs_implementation_file *stream, bool enabled);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
97
include/vfs/vfs.h
Normal file
97
include/vfs/vfs.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* Copyright (C) 2010-2019 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (vfs_implementation.h).
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*
|
||||
* Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __LIBRETRO_SDK_VFS_H
|
||||
#define __LIBRETRO_SDK_VFS_H
|
||||
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
#ifdef HAVE_CDROM
|
||||
typedef struct
|
||||
{
|
||||
char *cue_buf;
|
||||
size_t cue_len;
|
||||
int64_t byte_pos;
|
||||
char drive;
|
||||
unsigned char cur_min;
|
||||
unsigned char cur_sec;
|
||||
unsigned char cur_frame;
|
||||
unsigned char cur_track;
|
||||
unsigned cur_lba;
|
||||
} vfs_cdrom_t;
|
||||
#endif
|
||||
|
||||
enum vfs_scheme
|
||||
{
|
||||
VFS_SCHEME_NONE = 0,
|
||||
VFS_SCHEME_CDROM
|
||||
};
|
||||
|
||||
#ifndef __WINRT__
|
||||
#ifdef VFS_FRONTEND
|
||||
struct retro_vfs_file_handle
|
||||
#else
|
||||
struct libretro_vfs_implementation_file
|
||||
#endif
|
||||
{
|
||||
int fd;
|
||||
unsigned hints;
|
||||
int64_t size;
|
||||
char *buf;
|
||||
FILE *fp;
|
||||
#ifdef _WIN32
|
||||
HANDLE fh;
|
||||
#endif
|
||||
char* orig_path;
|
||||
uint64_t mappos;
|
||||
uint64_t mapsize;
|
||||
uint8_t *mapped;
|
||||
enum vfs_scheme scheme;
|
||||
#ifdef HAVE_CDROM
|
||||
vfs_cdrom_t cdrom;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Replace the following symbol with something appropriate
|
||||
* to signify the file is being compiled for a front end instead of a core.
|
||||
* This allows the same code to act as reference implementation
|
||||
* for VFS and as fallbacks for when the front end does not provide VFS functionality.
|
||||
*/
|
||||
|
||||
#ifdef VFS_FRONTEND
|
||||
typedef struct retro_vfs_file_handle libretro_vfs_implementation_file;
|
||||
#else
|
||||
typedef struct libretro_vfs_implementation_file libretro_vfs_implementation_file;
|
||||
#endif
|
||||
|
||||
#ifdef VFS_FRONTEND
|
||||
typedef struct retro_vfs_dir_handle libretro_vfs_implementation_dir;
|
||||
#else
|
||||
typedef struct libretro_vfs_implementation_dir libretro_vfs_implementation_dir;
|
||||
#endif
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
|
@ -27,6 +27,7 @@
|
|||
#include <stdint.h>
|
||||
#include <libretro.h>
|
||||
#include <retro_environment.h>
|
||||
#include <vfs/vfs.h>
|
||||
|
||||
#ifdef HAVE_CDROM
|
||||
#include <vfs/vfs_implementation_cdrom.h>
|
||||
|
@ -36,56 +37,6 @@
|
|||
typedef void* HANDLE;
|
||||
#endif
|
||||
|
||||
enum vfs_scheme
|
||||
{
|
||||
VFS_SCHEME_NONE = 0,
|
||||
VFS_SCHEME_CDROM
|
||||
};
|
||||
|
||||
#ifndef __WINRT__
|
||||
#ifdef VFS_FRONTEND
|
||||
struct retro_vfs_file_handle
|
||||
#else
|
||||
struct libretro_vfs_implementation_file
|
||||
#endif
|
||||
{
|
||||
int fd;
|
||||
unsigned hints;
|
||||
int64_t size;
|
||||
char *buf;
|
||||
FILE *fp;
|
||||
#ifdef _WIN32
|
||||
HANDLE fh;
|
||||
#endif
|
||||
char* orig_path;
|
||||
uint64_t mappos;
|
||||
uint64_t mapsize;
|
||||
uint8_t *mapped;
|
||||
enum vfs_scheme scheme;
|
||||
#ifdef HAVE_CDROM
|
||||
vfs_cdrom_t cdrom;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Replace the following symbol with something appropriate
|
||||
* to signify the file is being compiled for a front end instead of a core.
|
||||
* This allows the same code to act as reference implementation
|
||||
* for VFS and as fallbacks for when the front end does not provide VFS functionality.
|
||||
*/
|
||||
|
||||
#ifdef VFS_FRONTEND
|
||||
typedef struct retro_vfs_file_handle libretro_vfs_implementation_file;
|
||||
#else
|
||||
typedef struct libretro_vfs_implementation_file libretro_vfs_implementation_file;
|
||||
#endif
|
||||
|
||||
#ifdef VFS_FRONTEND
|
||||
typedef struct retro_vfs_dir_handle libretro_vfs_implementation_dir;
|
||||
#else
|
||||
typedef struct libretro_vfs_implementation_dir libretro_vfs_implementation_dir;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -23,31 +23,13 @@
|
|||
#ifndef __LIBRETRO_SDK_VFS_IMPLEMENTATION_CDROM_H
|
||||
#define __LIBRETRO_SDK_VFS_IMPLEMENTATION_CDROM_H
|
||||
|
||||
#include <vfs/vfs.h>
|
||||
#include <cdrom/cdrom.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
typedef struct RFILE RFILE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *cue_buf;
|
||||
size_t cue_len;
|
||||
int64_t byte_pos;
|
||||
char drive;
|
||||
unsigned char cur_min;
|
||||
unsigned char cur_sec;
|
||||
unsigned char cur_frame;
|
||||
unsigned char cur_track;
|
||||
unsigned cur_lba;
|
||||
} vfs_cdrom_t;
|
||||
|
||||
#ifdef VFS_FRONTEND
|
||||
struct retro_vfs_file_handle;
|
||||
#else
|
||||
struct libretro_vfs_implementation_file;
|
||||
#endif
|
||||
|
||||
int64_t retro_vfs_file_seek_cdrom(libretro_vfs_implementation_file *stream, int64_t offset, int whence);
|
||||
|
||||
void retro_vfs_file_open_cdrom(
|
||||
|
|
|
@ -221,6 +221,9 @@ int filestream_scanf(RFILE *stream, const char* format, ...)
|
|||
int ret = 0;
|
||||
int64_t maxlen = filestream_read(stream, buf, sizeof(buf)-1);
|
||||
|
||||
if (maxlen <= 0)
|
||||
return EOF;
|
||||
|
||||
buf[maxlen] = '\0';
|
||||
|
||||
va_start(args, format);
|
||||
|
|
|
@ -81,7 +81,7 @@ int64_t retro_vfs_file_seek_cdrom(libretro_vfs_implementation_file *stream, int6
|
|||
new_lba = vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].lba + (stream->cdrom.byte_pos / 2352);
|
||||
seek_type = "SEEK_CUR";
|
||||
|
||||
lba_to_msf(new_lba, &min, &sec, &frame);
|
||||
cdrom_lba_to_msf(new_lba, &min, &sec, &frame);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ int64_t retro_vfs_file_seek_cdrom(libretro_vfs_implementation_file *stream, int6
|
|||
ssize_t pregap_lba_len = (vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].audio ? 0 : (vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].lba - vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].lba_start));
|
||||
ssize_t lba_len = vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].track_size - pregap_lba_len;
|
||||
|
||||
lba_to_msf(lba_len + lba, &min, &sec, &frame);
|
||||
cdrom_lba_to_msf(lba_len + lba, &min, &sec, &frame);
|
||||
|
||||
stream->cdrom.byte_pos = lba_len * 2352;
|
||||
seek_type = "SEEK_END";
|
||||
|
@ -102,7 +102,7 @@ int64_t retro_vfs_file_seek_cdrom(libretro_vfs_implementation_file *stream, int6
|
|||
{
|
||||
seek_type = "SEEK_SET";
|
||||
stream->cdrom.byte_pos = offset;
|
||||
lba_to_msf(vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].lba + (stream->cdrom.byte_pos / 2352), &min, &sec, &frame);
|
||||
cdrom_lba_to_msf(vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].lba + (stream->cdrom.byte_pos / 2352), &min, &sec, &frame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ int64_t retro_vfs_file_seek_cdrom(libretro_vfs_implementation_file *stream, int6
|
|||
stream->cdrom.cur_min = min;
|
||||
stream->cdrom.cur_sec = sec;
|
||||
stream->cdrom.cur_frame = frame;
|
||||
stream->cdrom.cur_lba = msf_to_lba(min, sec, frame);
|
||||
stream->cdrom.cur_lba = cdrom_msf_to_lba(min, sec, frame);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("CDROM Seek %s: Path %s Offset %" PRIu64 " is now at %" PRIu64 " (MSF %02u:%02u:%02u) (LBA %u)...\n", seek_type, stream->orig_path, offset, stream->cdrom.byte_pos, (unsigned)stream->cdrom.cur_min, (unsigned)stream->cdrom.cur_sec, (unsigned)stream->cdrom.cur_frame, stream->cdrom.cur_lba);
|
||||
|
@ -273,14 +273,14 @@ void retro_vfs_file_open_cdrom(
|
|||
stream->cdrom.cur_min = vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].min;
|
||||
stream->cdrom.cur_sec = vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].sec;
|
||||
stream->cdrom.cur_frame = vfs_cdrom_toc.track[stream->cdrom.cur_track - 1].frame;
|
||||
stream->cdrom.cur_lba = msf_to_lba(stream->cdrom.cur_min, stream->cdrom.cur_sec, stream->cdrom.cur_frame);
|
||||
stream->cdrom.cur_lba = cdrom_msf_to_lba(stream->cdrom.cur_min, stream->cdrom.cur_sec, stream->cdrom.cur_frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
stream->cdrom.cur_min = vfs_cdrom_toc.track[0].min;
|
||||
stream->cdrom.cur_sec = vfs_cdrom_toc.track[0].sec;
|
||||
stream->cdrom.cur_frame = vfs_cdrom_toc.track[0].frame;
|
||||
stream->cdrom.cur_lba = msf_to_lba(stream->cdrom.cur_min, stream->cdrom.cur_sec, stream->cdrom.cur_frame);
|
||||
stream->cdrom.cur_lba = cdrom_msf_to_lba(stream->cdrom.cur_min, stream->cdrom.cur_sec, stream->cdrom.cur_frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ int64_t retro_vfs_file_read_cdrom(libretro_vfs_implementation_file *stream,
|
|||
unsigned char sec = 0;
|
||||
unsigned char frame = 0;
|
||||
|
||||
lba_to_msf(stream->cdrom.cur_lba, &min, &sec, &frame);
|
||||
cdrom_lba_to_msf(stream->cdrom.cur_lba, &min, &sec, &frame);
|
||||
|
||||
#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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -384,10 +385,10 @@ 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);
|
||||
lba_to_msf(stream->cdrom.cur_lba, &stream->cdrom.cur_min, &stream->cdrom.cur_sec, &stream->cdrom.cur_frame);
|
||||
cdrom_lba_to_msf(stream->cdrom.cur_lba, &stream->cdrom.cur_min, &stream->cdrom.cur_sec, &stream->cdrom.cur_frame);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
printf("CDROM read %" PRIu64 " bytes, position is now: %" PRIu64 " (MSF %02u:%02u:%02u) (LBA %u)\n", len, stream->cdrom.byte_pos, (unsigned)stream->cdrom.cur_min, (unsigned)stream->cdrom.cur_sec, (unsigned)stream->cdrom.cur_frame, msf_to_lba(stream->cdrom.cur_min, stream->cdrom.cur_sec, stream->cdrom.cur_frame));
|
||||
printf("CDROM read %" PRIu64 " bytes, position is now: %" PRIu64 " (MSF %02u:%02u:%02u) (LBA %u)\n", len, stream->cdrom.byte_pos, (unsigned)stream->cdrom.cur_min, (unsigned)stream->cdrom.cur_sec, (unsigned)stream->cdrom.cur_frame, cdrom_msf_to_lba(stream->cdrom.cur_min, stream->cdrom.cur_sec, stream->cdrom.cur_frame));
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ using namespace Windows::Storage::FileProperties;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include <vfs/vfs.h>
|
||||
#include <vfs/vfs_implementation.h>
|
||||
#include <libretro.h>
|
||||
#include <encodings/utf.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue