| 1099 | } |
| 1100 | |
| 1101 | int cdvdReadSector() |
| 1102 | { |
| 1103 | s32 bcr; |
| 1104 | |
| 1105 | CDVD_LOG("SECTOR %d (BCR %x;%x)", cdvd.CurrentSector, HW_DMA3_BCR_H16, HW_DMA3_BCR_L16); |
| 1106 | |
| 1107 | bcr = (HW_DMA3_BCR_H16 * HW_DMA3_BCR_L16) * 4; |
| 1108 | if (bcr < cdvd.BlockSize || !(HW_DMA3_CHCR & 0x01000000)) |
| 1109 | { |
| 1110 | CDVD_LOG("READBLOCK: bcr < cdvd.BlockSize; %x < %x", bcr, cdvd.BlockSize); |
| 1111 | if (HW_DMA3_CHCR & 0x01000000) |
| 1112 | { |
| 1113 | HW_DMA3_CHCR &= ~0x01000000; |
| 1114 | psxDmaInterrupt(3); |
| 1115 | } |
| 1116 | return -1; |
| 1117 | } |
| 1118 | |
| 1119 | //if( (HW_DMA3_CHCR & 0x01000000) == 0 ) { |
| 1120 | // // DMA3 problem? |
| 1121 | // Console.Warning( "CDVD READ - DMA3 transfer off (try again)\n" ); |
| 1122 | //} |
| 1123 | |
| 1124 | // DMAs use physical addresses (air) |
| 1125 | u8* mdest = iopPhysMem(HW_DMA3_MADR); |
| 1126 | |
| 1127 | // if raw dvd sector 'fill in the blanks' |
| 1128 | if (cdvd.BlockSize == 2064) |
| 1129 | { |
| 1130 | // get info on dvd type and layer1 start |
| 1131 | u32 layer1Start; |
| 1132 | s32 dualType; |
| 1133 | s32 layerNum; |
| 1134 | u32 lsn = cdvd.CurrentSector; |
| 1135 | |
| 1136 | cdvdReadDvdDualInfo(&dualType, &layer1Start); |
| 1137 | |
| 1138 | if ((dualType == 1) && (lsn >= layer1Start)) |
| 1139 | { |
| 1140 | // dual layer ptp disc |
| 1141 | layerNum = 1; |
| 1142 | lsn = lsn - layer1Start + 0x30000; |
| 1143 | } |
| 1144 | else if ((dualType == 2) && (lsn >= layer1Start)) |
| 1145 | { |
| 1146 | // dual layer otp disc |
| 1147 | layerNum = 1; |
| 1148 | lsn = ~(layer1Start + 0x30000 - 1); |
| 1149 | } |
| 1150 | else |
| 1151 | { |
| 1152 | // Assuming the other dualType is 0, |
| 1153 | // single layer disc, or on first layer of dual layer disc. |
| 1154 | layerNum = 0; |
| 1155 | lsn += 0x30000; |
| 1156 | } |
| 1157 | |
| 1158 | mdest[0] = 0x20 | layerNum; |
no test coverage detected