Lookit what goodies came in the mail today:


There is a reason why I'm showing you
Lady Phantom - this is one of the somewhat problematic CD-ROMs for PCE. First, the TOC:
-> Track 01 (Audio, 00:47:65, LBA: 0 / 00:02:00)
-> Track 02 (Mode 1, LBA: 3590 / 00:49:65)
-> Track 03 (Audio, 02:34:63, LBA: 5157 / 01:10:57)
-> Track 04 (Audio, 02:23:59, LBA: 16770 / 03:45:45)
-> Track 05 (Audio, 02:48:09, LBA: 27554 / 06:09:29)
-> Track 06 (Audio, 02:30:08, LBA: 40163 / 08:57:38)
-> Track 07 (Audio, 02:48:02, LBA: 51421 / 11:27:46)
-> Track 08 (Audio, 02:27:37, LBA: 64023 / 14:15:48)
-> Track 09 (Audio, 00:33:26, LBA: 75085 / 16:43:10)
-> Track 10 (Audio, 00:09:50, LBA: 77586 / 17:16:36)
-> Track 11 (Audio, 00:33:54, LBA: 78311 / 17:26:11)
-> Track 12 (Audio, 02:13:59, LBA: 80840 / 17:59:65)
-> Track 13 (Mode 1, LBA: 90874 / 20:13:49)
-> Track 14 (Audio, 02:14:25, LBA: 91550 / 20:22:50)
-> Track 15 (Mode 1, LBA: 101625 / 22:37:00)
-> Track 16 (Audio, 02:55:64, LBA: 102325 / 22:46:25)
-> Track 17 (Mode 1, LBA: 115514 / 25:42:14)
-> Track 18 (Audio, 02:05:73, LBA: 116214 / 25:51:39)
-> Track 19 (Mode 1, LBA: 125662 / 27:57:37)
-> Track 20 (Audio, 01:54:28, LBA: 126384 / 28:07:09)
-> Track 21 (Mode 1, LBA: 134962 / 30:01:37)
-> Track 22 (Audio, 01:43:38, LBA: 135678 / 30:11:03)
-> Track 23 (Mode 1, LBA: 143441 / 31:54:41)
-> Track 24 (Audio, 02:30:03, LBA: 144149 / 32:03:74)
-> Track 25 (Mode 1, LBA: 155402 / 34:34:02)
-> Track 26 (Audio, 01:52:62, LBA: 156088 / 34:43:13)
-> Track 27 (Mode 1, LBA: 164550 / 36:36:00)
-> Track 28 (Audio, 02:09:10, LBA: 165266 / 36:45:41)
-> Track 29 (Mode 1, LBA: 174951 / 38:54:51)
-> Track 30 (Audio, 00:37:56, LBA: 175575 / 39:03:00)
-> Track 31 (Mode 1, LBA: 178406 / 39:40:56)
-> Track 32 (Audio, 01:21:72, LBA: 179070 / 39:49:45)
-> Track 33 (Mode 1, LBA: 185217 / 41:11:42)
-> Track 34 (Audio, 01:43:24, LBA: 185889 / 41:20:39)
-> Track 35 (Mode 1, LBA: 193638 / 43:03:63)
-> Track 36 (Audio, 01:11:69, LBA: 194338 / 43:13:13)
-> Track 37 (Mode 1, LBA: 199732 / 44:25:07)
-> Track 38 (Audio, 01:31:39, LBA: 200368 / 44:33:43)
-> Track 39 (Mode 1, LBA: 207232 / 46:05:07)
-> Track 40 (Audio, 03:42:69, LBA: 208632 / 46:23:57)
-> Track 41 (Audio, 01:01:60, LBA: 225351 / 50:06:51)
-> Track 42 (Mode 1, LBA: 229986 / 51:08:36)
-> Track 43 (Audio, 04:11:57, LBA: 230654 / 51:17:29)
-> Track 44 (Mode 1, LBA: 249536 / 55:29:11)
-> LeadOut (LBA: 250814 / 55:46:14)
It's very rare for any disc to have so many data and audio tracks mixed together. PCE doesn't use ISO9660 so the devs just split the game data as they saw fit.
If this was a well-mastered Yellow Book compliant CD-ROM then we'd just rip the tracks, ignore pre/postgaps and it'd be a complete, working dump. It's not so easy in this case. Let's analyze the transition from track 14 to track 15.
-> Track 14 (Audio, 02:14:25, LBA: 91550 / 20:22:50)
-> Track 15 (Mode 1, LBA: 101625 / 22:37:00)
The last sections of track 14 are silent, this is normal except for cases where you don't want gaps in audio. Since the next track is data it's a good idea to do this properly. Except, you know, the
very last sectors are filled with junk here :)
LBA : 101472
0000 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ <- silence
SUBC : 01 14 01 02 12 22 00 22 34 72 00 00 00 00 00 00 ....."."4r......
LBA : 101473
0000 : 6A 82 AF 21 BC 18 71 CA A4 57 3B 7E 93 60 6D E8 j..!..q..W;~.`m. <- junk
SUBC : 01 14 01 02 12 23 00 22 34 73 00 00 00 00 00 00 .....#."4s......
LBA : 101474
0000 : 6A 82 AF 21 BC 18 71 CA A4 57 3B 7E 93 60 6D E8 j..!..q..W;~.`m. <- more junk
SUBC : 01 14 01 02 12 24 00 22 34 74 00 00 00 00 00 00 .....$."4t......
Notice how Q sub properly identifies this as audio track 14, index 1, time 22:34:74 - which is (22*60 + 34)*75 + 74 = 101624. With the usual TOC offset of 150 we get LBA 101474. Figures.
Also, TOC says track 14 should be 2:14:25 long and sure enough this is the last audio section, 2:12:24, according to Q (these counters start at zero).
Now, since there should be a 2-second long pregap for a data track that follows an audio track, and the data track starts at LBA 101625, so that means the first Mode 1 sector should be at LBA 101625 - 2*75 = 101475:
LBA : 101475
0000 : 00 FF FF FF FF FF FF FF FF FF FF 00 22 35 00 01 ............"5.. <- Mode 1 header, first sector of a pregap
SUBC : 01 14 01 02 12 23 00 22 34 73 00 00 00 00 00 00 .....#."4s...... <- Q address goes back!
And we have a Mode 1 header! Except Q sub still says it's audio track #14-1 :) Also, data header address is 22:35:00 and Q has 22:34:73.
It doesn't take a genius to notice that 22:34:73 was also the first audio sector with "junk" instead of proper silence. Gee, I wonder what would happen if we extracted that junk and run it through descrambler. Yup. It is, in fact, the same sector we are looking at now and the header is 00 FF FF FF FF FF FF FF FF FF FF 00 22 35 00 01.
So... two last sections of track 14 and two first sectors of track 15 are overlapping. Depending which track you're reading, the drive will return either raw bytes for audio or descrambled sectors for data. In fact, it's even worse:
0000 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0010 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0020 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
...
0440 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0450 : 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF ................
0460 : FF FF FF FF FF FF FF 00 23 B5 00 61 00 28 00 1E ........#..a.(..
0470 : 80 08 60 06 A8 02 FE 81 80 60 60 28 28 1E 9E 88 ..`......``((...
0480 : 68 66 AE AA FC 7F 01 E0 00 48 00 36 80 16 E0 0E hf.......H.6....
0490 : C8 04 56 83 7E E1 E0 48 48 36 B6 96 F6 EE C6 CC ..V.~..HH6......
The data sector 22:35:00 starts in the middle of audio section 22:34:72. Which is perfectly OK. Except it cannot be properly ripped when the drive already cooks the raw data into sectors - since you can sync data to headers but there is no way to sync the audio.
And this is why I said it's not always possible to rip a CD-ROM track by track, even using subcodes as a reference. It only works for discs where audio sections match data sectors perfectly and even then it's down to drive logic to figure out how to join subchannel data with post-CIRC stream. So, claiming that any dump is a perfect copy of the master image is just... silly.
Let's see what happens next with our dump:
LBA : 101476
0000 : 00 FF FF FF FF FF FF FF FF FF FF 00 22 35 01 01 ............"5..
SUBC : 01 14 01 02 12 24 00 22 34 74 00 00 00 00 00 00 .....$."4t...... <- note that Q still says track type is audio
LBA : 101477
0000 : 00 FF FF FF FF FF FF FF FF FF FF 00 22 35 02 01 ............"5.. <- M1 address: 22:35:02
SUBC : 41 15 00 00 01 74 00 22 35 00 00 00 00 00 00 00 A....t."5....... <- Q address: 22:35:00 (index 0, so a pregap)
LBA : 101478
0000 : 00 FF FF FF FF FF FF FF FF FF FF 00 22 35 03 01 ............"5..
0920 : 00 00 00 00 00 00 00 00 00 00 AD 90 29 C9 83 16 ............)...
SUBC : 41 15 00 00 01 73 00 22 35 01 00 00 00 00 00 00 A....s."5.......
LBA : 101625
0000 : 00 FF FF FF FF FF FF FF FF FF FF 00 22 37 00 01 ............"7.. <- First sector with actual data
SUBC : 41 15 00 00 00 01 00 22 36 73 00 00 00 00 00 00 A......"6s...... <- Q still says pregap
LBA : 101626
0000 : 00 FF FF FF FF FF FF FF FF FF FF 00 22 37 01 01 ............"7..
SUBC : 41 15 00 00 00 00 00 22 36 74 00 00 00 00 00 00 A......"6t......
LBA : 101627
0000 : 00 FF FF FF FF FF FF FF FF FF FF 00 22 37 02 01 ............"7..
SUBC : 41 15 01 00 00 00 00 22 37 00 00 00 00 00 00 00 A......"7....... <- Q finally switches to index 1
Q never matches the header address and in fact even the track type is wrong for some sectors. But don't assume that this 2-section offset is constant for all the audio/data tracks on the disc. While it could be the case, it's not guaranteed. The spec allows up to +/- 1 second offset so the difference could be anywhere from zero to 150 and, depending on what the drive logic thinks is the start of audio data, the header position might end up in different part of the audio section. In fact it's allowed for the header to start well inside a frame, as long as it's on 4-byte boundary.
So... all these frames, sections, offsets, sectors, tracks and gaps start to confuse you? Well, keep in mind the CD, while digital in nature, was meant to carry audio. Data sectors were added later and kinda slapped onto existing audio layer. This let the manufacturers reuse their designs by just adding header detection and descrambling hardware (along with some RAM for data buffering). But thanks to that we have this mess on our hands now :)