| 1021 | extern void encode_l2 (uae_u8 *p, int address); |
| 1022 | |
| 1023 | static int command_rawread (int unitnum, uae_u8 *data, int sector, int size, int sectorsize, uae_u32 extra) |
| 1024 | { |
| 1025 | int ret = 0; |
| 1026 | struct cdunit *cdu = unitisopen (unitnum); |
| 1027 | if (!cdu) |
| 1028 | return 0; |
| 1029 | int asector = sector; |
| 1030 | struct cdtoc *t = findtoc (cdu, §or, true); |
| 1031 | int ssize; |
| 1032 | |
| 1033 | if (!t) |
| 1034 | goto end; |
| 1035 | |
| 1036 | ssize = t->size + t->skipsize; |
| 1037 | cdda_stop (cdu); |
| 1038 | if (sectorsize > 0) { |
| 1039 | if ((sectorsize == 2352 || sectorsize == 2368 || sectorsize == 2448) && t->size == 2336) { |
| 1040 | // 2336 -> 2352 |
| 1041 | while (size-- > 0) { |
| 1042 | int address = asector + 150; |
| 1043 | if (isaudiotrack(&cdu->di.toc, sector)) { |
| 1044 | do_read(cdu, t, data, sector, 0, t->size, true); |
| 1045 | } else { |
| 1046 | data[0] = 0x00; |
| 1047 | memset(data + 1, 0xff, 11); |
| 1048 | data[12] = tobcd((uae_u8)(address / (60 * 75))); |
| 1049 | data[13] = tobcd((uae_u8)((address / 75) % 60)); |
| 1050 | data[14] = tobcd((uae_u8)(address % 75)); |
| 1051 | data[15] = 2; /* MODE2 */ |
| 1052 | do_read(cdu, t, data + 16, sector, 0, t->size, false); |
| 1053 | } |
| 1054 | sector++; |
| 1055 | asector++; |
| 1056 | data += sectorsize; |
| 1057 | ret += sectorsize; |
| 1058 | if (sectorsize == 2448) { |
| 1059 | // all subs |
| 1060 | getsub_deinterleaved(data - SUB_CHANNEL_SIZE, cdu, t, sector); |
| 1061 | } else if (sectorsize == 2368) { |
| 1062 | // sub q only |
| 1063 | uae_u8 subs[SUB_CHANNEL_SIZE]; |
| 1064 | getsub_deinterleaved(subs, cdu, t, sector); |
| 1065 | memcpy(data - SUBQ_SIZE, subs + SUBQ_SIZE, SUBQ_SIZE); |
| 1066 | } |
| 1067 | } |
| 1068 | } else if (sectorsize == 2340 && t->size == 2336) { |
| 1069 | // 2336 -> 2340 |
| 1070 | while (size-- > 0) { |
| 1071 | int address = asector + 150; |
| 1072 | data[0] = tobcd((uae_u8)(address / (60 * 75))); |
| 1073 | data[1] = tobcd((uae_u8)((address / 75) % 60)); |
| 1074 | data[2] = tobcd((uae_u8)(address % 75)); |
| 1075 | data[3] = 2; /* MODE2 */ |
| 1076 | do_read(cdu, t, data + 4, sector, 0, t->size, false); |
| 1077 | sector++; |
| 1078 | asector++; |
| 1079 | data += sectorsize; |
| 1080 | ret += sectorsize; |
nothing calls this directly
no test coverage detected