[Core/CD] fixed cooked Mode-1 (ISO) sectors access in CHD files

This commit is contained in:
EkeEke 2017-09-23 00:14:43 +02:00
parent 5d13ccbe3f
commit 00a79db64e
4 changed files with 14 additions and 4 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

After

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 3.4 MiB

View File

@ -449,8 +449,8 @@ int cdd_load(char *filename, char *header)
cdd.chd.hunknum = cdd.toc.tracks[0].offset / cdd.chd.hunkbytes; cdd.chd.hunknum = cdd.toc.tracks[0].offset / cdd.chd.hunkbytes;
chd_read(cdd.chd.file, cdd.chd.hunknum, cdd.chd.hunk); chd_read(cdd.chd.file, cdd.chd.hunknum, cdd.chd.hunk);
/* copy CD image header + security code */ /* copy CD image header + security code (skip RAW sector 16-byte header) */
memcpy(header, cdd.chd.hunk + (cdd.toc.tracks[0].offset % cdd.chd.hunkbytes) + 0x10, 0x210); memcpy(header, cdd.chd.hunk + (cdd.toc.tracks[0].offset % cdd.chd.hunkbytes) + ((cdd.sectorSize == 2048) ? 0 : 16), 0x210);
/* there is a valid DATA track */ /* there is a valid DATA track */
cdd.toc.tracks[0].type = TYPE_CDROM; cdd.toc.tracks[0].type = TYPE_CDROM;
@ -1235,8 +1235,18 @@ void cdd_read_data(uint8 *dst)
cdd.chd.hunknum = hunknum; cdd.chd.hunknum = hunknum;
} }
/* copy Mode 1 sector data (2048 bytes only, skipping 16-byte header) */ /* copy Mode 1 sector data (2048 bytes only) */
memcpy(dst, cdd.chd.hunk + (offset % cdd.chd.hunkbytes) + 16, 2048); if (cdd.sectorSize == 2048)
{
/* Mode 1 COOKED data (ISO) */
memcpy(dst, cdd.chd.hunk + (offset % cdd.chd.hunkbytes), 2048);
}
else
{
/* Mode 1 RAW data (skip 16-byte header) */
memcpy(dst, cdd.chd.hunk + (offset % cdd.chd.hunkbytes) + 16, 2048);
}
return; return;
} }
#endif #endif