Assorted CD-ROM fixes (now cue sheets starting at a non-zero sector work correctly) and increased the maximum number of CD-ROM drives to 8.

This commit is contained in:
OBattler
2023-10-04 02:49:22 +02:00
parent 7fed7c1510
commit 209c8fbbda
4 changed files with 15 additions and 9 deletions

View File

@@ -73,7 +73,7 @@ bin_read(void *priv, uint8_t *buffer, uint64_t seek, size_t count)
track_file_t *tf = (track_file_t *) priv;
cdrom_image_backend_log("CDROM: binary_read(%08lx, pos=%" PRIu64 " count=%lu\n",
tf->file, seek, count);
tf->fp, seek, count);
if (tf->fp == NULL)
return 0;
@@ -101,14 +101,14 @@ bin_get_length(void *priv)
off64_t len;
track_file_t *tf = (track_file_t *) priv;
cdrom_image_backend_log("CDROM: binary_length(%08lx)\n", tf->file);
cdrom_image_backend_log("CDROM: binary_length(%08lx)\n", tf->fp);
if (tf->fp == NULL)
return 0;
fseeko64(tf->fp, 0, SEEK_END);
len = ftello64(tf->fp);
cdrom_image_backend_log("CDROM: binary_length(%08lx) = %" PRIu64 "\n", tf->file, len);
cdrom_image_backend_log("CDROM: binary_length(%08lx) = %" PRIu64 "\n", tf->fp, len);
return len;
}
@@ -145,7 +145,7 @@ bin_init(const char *filename, int *error)
memset(tf->fn, 0x00, sizeof(tf->fn));
strncpy(tf->fn, filename, sizeof(tf->fn) - 1);
tf->fp = plat_fopen64(tf->fn, "rb");
cdrom_image_backend_log("CDROM: binary_open(%s) = %08lx\n", tf->fn, tf->file);
cdrom_image_backend_log("CDROM: binary_open(%s) = %08lx\n", tf->fn, tf->fp);
if (stat(tf->fn, &stats) != 0) {
/* Use a blank structure if stat failed. */
@@ -332,6 +332,11 @@ cdi_get_track(cd_img_t *cdi, uint32_t sector)
for (int i = 0; i < (cdi->tracks_num - 1); i++) {
cur = &cdi->tracks[i];
next = &cdi->tracks[i + 1];
/* Take into account cue sheets that do not start on sector 0. */
if ((i == 0) && (sector < cur->start))
return cur->number;
if ((cur->start <= sector) && (sector < next->start))
return cur->number;
}
@@ -425,8 +430,9 @@ cdi_read_sector(cd_img_t *cdi, uint8_t *buffer, int raw, uint32_t sector)
return 1;
} else if (!raw && track_is_raw)
return trk->file->read(trk->file, buffer, seek + offset, length);
else
else {
return trk->file->read(trk->file, buffer, seek, length);
}
}
int

View File

@@ -15,7 +15,7 @@
#ifndef EMU_CDROM_H
#define EMU_CDROM_H
#define CDROM_NUM 4
#define CDROM_NUM 8
#define CD_STATUS_EMPTY 0
#define CD_STATUS_DATA_ONLY 1

View File

@@ -224,12 +224,12 @@
#define RW_DELAY (TIMER_USEC * 500)
/* Some generally useful CD-ROM information */
#define CD_MINS 75 /* max. minutes per CD */
#define CD_MINS 90 /* max. minutes per CD */
#define CD_SECS 60 /* seconds per minute */
#define CD_FRAMES 75 /* frames per second */
#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */
#define CD_MAX_BYTES (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE)
#define CD_MAX_SECTORS (CD_MAX_BYTES / 512)
#define CD_MAX_SECTORS (CD_MAX_BYTES / 2048)
/* Event notification classes for GET EVENT STATUS NOTIFICATION */
#define GESN_NO_EVENTS 0

View File

@@ -2256,7 +2256,7 @@ begin:
another variable. */
if (dev->drv->cd_status == CD_STATUS_EMPTY)
max_len = 70; /* No media inserted. */
else if (dev->drv->cdrom_capacity > 405000)
else if (dev->drv->cdrom_capacity > CD_MAX_SECTORS)
max_len = 65; /* DVD. */
else if (dev->drv->cd_status == CD_STATUS_DATA_ONLY)
max_len = 1; /* Data CD. */