| 179 | } |
| 180 | |
| 181 | static s32 ISOgetTOC(void* toc) |
| 182 | { |
| 183 | u8 type = ISOgetDiskType(); |
| 184 | u8* tocBuff = (u8*)toc; |
| 185 | |
| 186 | //CDVD_LOG("CDVDgetTOC\n"); |
| 187 | |
| 188 | if (type == CDVD_TYPE_DVDV || type == CDVD_TYPE_PS2DVD) |
| 189 | { |
| 190 | // get dvd structure format |
| 191 | // scsi command 0x43 |
| 192 | memset(tocBuff, 0, 2048); |
| 193 | |
| 194 | FindLayer1Start(); |
| 195 | |
| 196 | if (layer1start < 0) |
| 197 | { |
| 198 | // Single Layer - Values are fixed. |
| 199 | tocBuff[0] = 0x04; |
| 200 | tocBuff[1] = 0x02; |
| 201 | tocBuff[2] = 0xF2; |
| 202 | tocBuff[3] = 0x00; |
| 203 | tocBuff[4] = 0x86; |
| 204 | tocBuff[5] = 0x72; |
| 205 | |
| 206 | // These values are fixed on all discs, except position 14 which is the OTP/PTP flags which are 0 in single layer. |
| 207 | tocBuff[12] = 0x01; |
| 208 | tocBuff[13] = 0x02; |
| 209 | tocBuff[14] = 0x01; |
| 210 | tocBuff[15] = 0x00; |
| 211 | |
| 212 | // Values are fixed. |
| 213 | tocBuff[16] = 0x00; |
| 214 | tocBuff[17] = 0x03; |
| 215 | tocBuff[18] = 0x00; |
| 216 | tocBuff[19] = 0x00; |
| 217 | |
| 218 | cdvdTD trackInfo; |
| 219 | // Get the max LSN for the track |
| 220 | if (ISOgetTD(0, &trackInfo) == -1) |
| 221 | trackInfo.lsn = 0; |
| 222 | |
| 223 | // Max LSN in the TOC is calculated as the blocks + 0x30000, then - 1. |
| 224 | // same as layer 1 start. |
| 225 | const s32 maxlsn = trackInfo.lsn + (0x30000 - 1); |
| 226 | tocBuff[20] = maxlsn >> 24; |
| 227 | tocBuff[21] = (maxlsn >> 16) & 0xff; |
| 228 | tocBuff[22] = (maxlsn >> 8) & 0xff; |
| 229 | tocBuff[23] = (maxlsn >> 0) & 0xff; |
| 230 | return 0; |
| 231 | } |
| 232 | else |
| 233 | { |
| 234 | // Dual sided - Values are fixed. |
| 235 | tocBuff[0] = 0x24; |
| 236 | tocBuff[1] = 0x02; |
| 237 | tocBuff[2] = 0xF2; |
| 238 | tocBuff[3] = 0x00; |
nothing calls this directly
no test coverage detected