CD-ROM: Parity and CRC checking support, System Shock 2 now works with a directly mounted .CUE image as well.
This commit is contained in:
@@ -2237,6 +2237,7 @@ image_read_sector(const void *local, uint8_t *buffer,
|
||||
const uint32_t sector)
|
||||
{
|
||||
const cd_image_t *img = (const cd_image_t *) local;
|
||||
cdrom_t *dev = (cdrom_t *) img->dev;
|
||||
int m = 0;
|
||||
int s = 0;
|
||||
int f = 0;
|
||||
@@ -2245,6 +2246,7 @@ image_read_sector(const void *local, uint8_t *buffer,
|
||||
int track;
|
||||
int index;
|
||||
uint8_t q[16] = { 0x00 };
|
||||
uint8_t *buf = buffer;
|
||||
|
||||
if (sector == 0xffffffff)
|
||||
lba = img->dev->seek_pos;
|
||||
@@ -2304,6 +2306,33 @@ image_read_sector(const void *local, uint8_t *buffer,
|
||||
/* Index is not in the file, no read to fail here. */
|
||||
ret = 1;
|
||||
|
||||
if ((ret > 0) && (trk->attr & 0x04) && ((idx->type < INDEX_NORMAL) || !track_is_raw)) {
|
||||
uint32_t crc;
|
||||
|
||||
if ((trk->mode == 2) && (trk->form == 1))
|
||||
crc = cdrom_crc32(0xffffffff, buf, 2072) ^ 0xffffffff;
|
||||
else
|
||||
crc = cdrom_crc32(0xffffffff, buf, 2064) ^ 0xffffffff;
|
||||
|
||||
memcpy(&(buf[2064]), &crc, 4);
|
||||
|
||||
#if 0
|
||||
/* Compute ECC P code. */
|
||||
cdrom_compute_ecc_block(dev, dev->p_parity, &(buf[12]), 86, 24, 2, 86);
|
||||
memcpy(&(buf[2076]), dev->p_parity, 172);
|
||||
|
||||
/* Compute ECC Q code. */
|
||||
cdrom_compute_ecc_block(dev, dev->q_parity, &(buf[12]), 52, 43, 86, 88);
|
||||
memcpy(&(buf[2248]), dev->q_parity, 104);
|
||||
#else
|
||||
/* Compute ECC P code. */
|
||||
cdrom_compute_ecc_block(dev, &(buf[2076]), &(buf[12]), 86, 24, 2, 86);
|
||||
|
||||
/* Compute ECC Q code. */
|
||||
cdrom_compute_ecc_block(dev, &(buf[2248]), &(buf[12]), 52, 43, 86, 88);
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((ret > 0) && ((idx->type < INDEX_NORMAL) || (trk->subch_type != 0x08))) {
|
||||
buffer -= offset;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user