PSX: match user_io buffer size to chd hunk size
This commit is contained in:
@@ -467,6 +467,15 @@ void psx_fill_blanksave(uint8_t *buffer, uint32_t lba, int cnt)
|
||||
static toc_t toc = {};
|
||||
#define CD_SECTOR_LEN 2352
|
||||
|
||||
int psx_chd_hunksize()
|
||||
{
|
||||
if (toc.chd_f)
|
||||
return toc.chd_hunksize;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void psx_read_cd(uint8_t *buffer, int lba, int cnt)
|
||||
{
|
||||
//printf("req lba=%d, cnt=%d\n", lba, cnt);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
void psx_mount_cd(int f_index, int s_index, const char *filename);
|
||||
void psx_fill_blanksave(uint8_t *buffer, uint32_t lba, int cnt);
|
||||
void psx_read_cd(uint8_t *buffer, int lba, int cnt);
|
||||
int psx_chd_hunksize();
|
||||
const char* psx_get_game_id();
|
||||
void psx_poll();
|
||||
|
||||
|
||||
@@ -3118,6 +3118,13 @@ void user_io_poll()
|
||||
else if (op & 1)
|
||||
{
|
||||
uint32_t buf_n = sizeof(buffer[0]) / blksz;
|
||||
int psx_blksz = 0;
|
||||
if (is_psx() && blksz == 2352)
|
||||
{
|
||||
//returns 0 if the mounted disk is not a chd, otherwise returns the chd hunksize in bytes
|
||||
psx_blksz = psx_chd_hunksize();
|
||||
if (psx_blksz && psx_blksz <= sizeof(buffer[0])) buf_n = psx_blksz / blksz;
|
||||
}
|
||||
//printf("SD RD (%llu,%d) on %d, WIDE=%d\n", lba, blksz, disk, fio_size);
|
||||
|
||||
int done = 0;
|
||||
|
||||
Reference in New Issue
Block a user