trunk/src/mess/drivers/ng_aes.c
| r19354 | r19355 | |
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | |
| 1036 | |
| 1037 | /* |
| 1038 | * CD-ROM / DMA control |
| 1039 | * |
| 1040 | * DMA |
| 1041 | |
| 1042 | FF0061 Write 0x40 means start DMA transfer |
| 1043 | FF0064 Source address (in copy mode), Target address (in filll mode) |
| 1044 | FF0068 Target address (in copy mode) |
| 1045 | FF006C Fill word |
| 1046 | FF0070 Words count |
| 1047 | FF007E \ |
| 1048 | ...... | DMA programming words? NeoGeoCD uses Sanyo Puppet LC8359 chip to |
| 1049 | FF008E / interface with CD, and do DMA transfers |
| 1050 | |
| 1051 | Memory access control |
| 1052 | |
| 1053 | FF011C DIP SWITCH (Region code) |
| 1054 | FF0105 Area Selector (5 = FIX, 0 = SPR, 4 = Z80, 1 = PCM) |
| 1055 | FF01A1 Sprite bank selector |
| 1056 | FF01A3 PCM bank selector |
| 1057 | FF0120 Prepare sprite area for transfer |
| 1058 | FF0122 Prepare PCM area for transfer |
| 1059 | FF0126 Prepare Z80 area for transfer |
| 1060 | FF0128 Prepare Fix area for transfer |
| 1061 | FF0140 Terminate work on Spr Area (Sprites must be decoded here) |
| 1062 | FF0142 Terminate work on Pcm Area |
| 1063 | FF0146 Terminate work on Z80 Area (Z80 needs to be reset) |
| 1064 | FF0148 Terminate work on Fix Area |
| 1065 | |
| 1066 | CD-ROM: |
| 1067 | 0xff0102 == 0xF0 start cd transfer |
| 1068 | int m=bcd(fast_r8(0x10f6c8)); |
| 1069 | int s=bcd(fast_r8(0x10f6c9)); |
| 1070 | int f=bcd(fast_r8(0x10f6ca)); |
| 1071 | int seccount=fast_r16(0x10f688); |
| 1072 | |
| 1073 | inisec=((m*60)+s)*75+f; |
| 1074 | inisec-=150; |
| 1075 | dstaddr=0x111204; // this must come from somewhere |
| 1076 | |
| 1077 | the value @ 0x10f688 is decremented each time a sector is read until it's 0. |
| 1078 | |
| 1079 | * |
| 1080 | */ |
| 1081 | |
| 1082 | |
| 1036 | 1083 | void ng_aes_state::NeoCDDoDMA() |
| 1037 | 1084 | { |
| 1038 | 1085 | |
trunk/src/mame/machine/megacdcd.c
| r19354 | r19355 | |
| 25 | 25 | NeoCDCommsWordCount = 0; |
| 26 | 26 | NeoCDAssyStatus = 0; |
| 27 | 27 | SCD_CURLBA = 0; |
| 28 | | for (int i=0;i<2352;i++) |
| 29 | | NeoCDSectorData[i] = 0; |
| 28 | |
| 30 | 29 | bNeoCDLoadSector = false; |
| 31 | 30 | CDC_REG0 = 0; |
| 32 | 31 | nNeoCDIRQVectorAck = 0; |
| r19354 | r19355 | |
| 1010 | 1009 | NeoCDIRQUpdate(0); |
| 1011 | 1010 | |
| 1012 | 1011 | if (nff0002 & 0x0500) { |
| 1013 | | Read_LBA_To_Buffer_NeoCD(); |
| 1012 | Read_LBA_To_Buffer(machine()); |
| 1014 | 1013 | } |
| 1015 | 1014 | } |
| 1016 | 1015 | } |
| r19354 | r19355 | |
| 1040 | 1039 | |
| 1041 | 1040 | |
| 1042 | 1041 | |
| 1043 | | INT32 lc89510_temp_device::CDEmuLoadSector(INT32 LBA, char* pBuffer) |
| 1044 | | { |
| 1045 | | // printf("CDEmuLoadSector %d\n", LBA); |
| 1046 | | //LBA += 150; |
| 1047 | 1042 | |
| 1048 | | cdrom_read_data(segacd.cd, LBA, pBuffer, CD_TRACK_MODE1); |
| 1049 | 1043 | |
| 1050 | | return LBA+1;// - 150; |
| 1051 | | } |
| 1052 | 1044 | |
| 1053 | | |
| 1054 | | |
| 1055 | | |
| 1056 | | |
| 1057 | 1045 | void lc89510_temp_device::NeoCDCommsReset() |
| 1058 | 1046 | { |
| 1059 | 1047 | bNeoCDCommsSend = false; |
| r19354 | r19355 | |
| 1066 | 1054 | |
| 1067 | 1055 | NeoCDAssyStatus = 9; |
| 1068 | 1056 | |
| 1069 | | memset(NeoCDSectorData, 0, sizeof(NeoCDSectorData)); |
| 1070 | | |
| 1071 | 1057 | bNeoCDLoadSector = false; |
| 1072 | 1058 | |
| 1073 | 1059 | nff0016 = 0; |
| r19354 | r19355 | |
| 1193 | 1179 | //bprintf(PRINT_ERROR, _T(" LC8951 DOUTEN status invalid\n")); |
| 1194 | 1180 | return NULL; |
| 1195 | 1181 | } |
| 1196 | | if (((LC8951RegistersW[REG_W_DACH] << 8) | LC8951RegistersW[REG_W_DACL]) + (NeoCDDMACount << 1) > 2352) { |
| 1182 | if (((LC8951RegistersW[REG_W_DACH] << 8) | LC8951RegistersW[REG_W_DACL]) + (NeoCDDMACount << 1) > LC89510_EXTERNAL_BUFFER_SIZE) { |
| 1197 | 1183 | //bprintf(PRINT_ERROR, _T(" DMA transfer exceeds current sector in LC8951 external buffer\n")); |
| 1184 | |
| 1198 | 1185 | return NULL; |
| 1199 | 1186 | } |
| 1200 | 1187 | |
| 1201 | | return NeoCDSectorData + ((LC8951RegistersW[REG_W_DACH] << 8) | LC8951RegistersW[REG_W_DACL]); |
| 1188 | char* addr = (char*)CDC_BUFFER + ((LC8951RegistersW[REG_W_DACH] << 8) | LC8951RegistersW[REG_W_DACL]); |
| 1189 | return addr; |
| 1202 | 1190 | } |
| 1203 | 1191 | |
| 1204 | 1192 | void lc89510_temp_device::LC8915EndTransfer() |
| r19354 | r19355 | |
| 1236 | 1224 | |
| 1237 | 1225 | |
| 1238 | 1226 | |
| 1239 | | /* |
| 1240 | | * CD-ROM / DMA control |
| 1241 | | * |
| 1242 | | * DMA |
| 1243 | 1227 | |
| 1244 | | FF0061 Write 0x40 means start DMA transfer |
| 1245 | | FF0064 Source address (in copy mode), Target address (in filll mode) |
| 1246 | | FF0068 Target address (in copy mode) |
| 1247 | | FF006C Fill word |
| 1248 | | FF0070 Words count |
| 1249 | | FF007E \ |
| 1250 | | ...... | DMA programming words? NeoGeoCD uses Sanyo Puppet LC8359 chip to |
| 1251 | | FF008E / interface with CD, and do DMA transfers |
| 1252 | | |
| 1253 | | Memory access control |
| 1254 | | |
| 1255 | | FF011C DIP SWITCH (Region code) |
| 1256 | | FF0105 Area Selector (5 = FIX, 0 = SPR, 4 = Z80, 1 = PCM) |
| 1257 | | FF01A1 Sprite bank selector |
| 1258 | | FF01A3 PCM bank selector |
| 1259 | | FF0120 Prepare sprite area for transfer |
| 1260 | | FF0122 Prepare PCM area for transfer |
| 1261 | | FF0126 Prepare Z80 area for transfer |
| 1262 | | FF0128 Prepare Fix area for transfer |
| 1263 | | FF0140 Terminate work on Spr Area (Sprites must be decoded here) |
| 1264 | | FF0142 Terminate work on Pcm Area |
| 1265 | | FF0146 Terminate work on Z80 Area (Z80 needs to be reset) |
| 1266 | | FF0148 Terminate work on Fix Area |
| 1267 | | |
| 1268 | | CD-ROM: |
| 1269 | | 0xff0102 == 0xF0 start cd transfer |
| 1270 | | int m=bcd(fast_r8(0x10f6c8)); |
| 1271 | | int s=bcd(fast_r8(0x10f6c9)); |
| 1272 | | int f=bcd(fast_r8(0x10f6ca)); |
| 1273 | | int seccount=fast_r16(0x10f688); |
| 1274 | | |
| 1275 | | inisec=((m*60)+s)*75+f; |
| 1276 | | inisec-=150; |
| 1277 | | dstaddr=0x111204; // this must come from somewhere |
| 1278 | | |
| 1279 | | the value @ 0x10f688 is decremented each time a sector is read until it's 0. |
| 1280 | | |
| 1281 | | * |
| 1282 | | */ |
| 1283 | | |
| 1284 | | void lc89510_temp_device::Read_LBA_To_Buffer_NeoCD() |
| 1285 | | { |
| 1286 | | if ((nff0002 & 0x0500)) { |
| 1287 | | if (NeoCDAssyStatus == 1 && bNeoCDLoadSector) { |
| 1288 | | |
| 1289 | | // if (LC8951RegistersW[REG_W_CTRL0] & 0x80) { |
| 1290 | | SCD_CURLBA++; |
| 1291 | | SCD_CURLBA = CDEmuLoadSector(SCD_CURLBA, NeoCDSectorData + 4) -1; |
| 1292 | | // } |
| 1293 | | |
| 1294 | | if (LC8951RegistersW[REG_W_CTRL0] & 0x80) { |
| 1295 | | LC8951UpdateHeader(); |
| 1296 | | |
| 1297 | | LC8951RegistersR[REG_R_STAT0] = 0x80; // STAT0 |
| 1298 | | LC8951RegistersR[REG_R_STAT1] = 0; // STAT1 |
| 1299 | | LC8951RegistersR[REG_R_STAT2] = 0x10; // STAT2 |
| 1300 | | LC8951RegistersR[REG_R_STAT3] = 0; // STAT3 |
| 1301 | | |
| 1302 | | // bprintf(PRINT_IMPORTANT, _T(" Sector %08i (%02i:%02i:%02i) read\n"), SCD_CURLBA, NeoCDSectorMin, NeoCDSectorSec, NeoCDSectorFrm); |
| 1303 | | |
| 1304 | | // CDZ protection hack? (error correction on the CDC should correct this?) |
| 1305 | | #if 1 |
| 1306 | | if (NeoCDSectorData[4 + 64] == 'g' && !strncmp(NeoCDSectorData + 4, "Copyright by SNK", 16)) { |
| 1307 | | // printf(PRINT_ERROR, _T(" simulated CDZ protection error\n")); |
| 1308 | | // bprintf(PRINT_ERROR, _T(" %.70hs\n"), NeoCDSectorData + 4); |
| 1309 | | |
| 1310 | | NeoCDSectorData[4 + 64] = 'f'; |
| 1311 | | |
| 1312 | | // LC8951RegistersR[REG_R_STATB0] = 0x00; // STAT0 |
| 1313 | | } |
| 1314 | | #endif |
| 1315 | | |
| 1316 | | nIRQAcknowledge &= ~0x20; |
| 1317 | | NeoCDIRQUpdate(0); |
| 1318 | | |
| 1319 | | LC8951RegistersR[REG_R_IFSTAT] &= ~0x20; |
| 1320 | | |
| 1321 | | // bprintf(PRINT_IMPORTANT, _T(" DECI interrupt triggered\n")); |
| 1322 | | } |
| 1323 | | } |
| 1324 | | |
| 1325 | | bNeoCDLoadSector = true; |
| 1326 | | // bNeoCDLoadSector = false; |
| 1327 | | } |
| 1328 | | } |
| 1329 | | |
| 1330 | | |
| 1331 | | |
| 1332 | 1228 | void lc89510_temp_device::scd_ctrl_checks(running_machine& machine) |
| 1333 | 1229 | { |
| 1334 | 1230 | LC8951RegistersR[REG_R_STAT0] = 0x80; |
| r19354 | r19355 | |
| 1338 | 1234 | |
| 1339 | 1235 | if (LC8951RegistersW[REG_W_IFCTRL] & 0x20) |
| 1340 | 1236 | { |
| 1341 | | CHECK_SCD_LV5_INTERRUPT |
| 1237 | |
| 1238 | // todo: handle as interrupt callback |
| 1239 | if (is_neoCD) |
| 1240 | { |
| 1241 | nIRQAcknowledge &= ~0x20; |
| 1242 | NeoCDIRQUpdate(0); |
| 1243 | } |
| 1244 | else |
| 1245 | { |
| 1246 | CHECK_SCD_LV5_INTERRUPT |
| 1247 | } |
| 1248 | |
| 1249 | |
| 1250 | |
| 1342 | 1251 | LC8951RegistersR[REG_R_IFSTAT] &= ~0x20; |
| 1343 | 1252 | CDC_DECODE = 0; |
| 1344 | 1253 | } |
| r19354 | r19355 | |
| 1392 | 1301 | CDC_BUFFER[pt+1] = LC8951RegistersR[REG_R_HEAD1]; |
| 1393 | 1302 | CDC_BUFFER[pt+2] = LC8951RegistersR[REG_R_HEAD2]; |
| 1394 | 1303 | CDC_BUFFER[pt+3] = LC8951RegistersR[REG_R_HEAD3]; |
| 1304 | |
| 1305 | |
| 1306 | if (is_neoCD) |
| 1307 | { |
| 1308 | // This simulates the protection used by the NeoCDZ, a number of games (samsrpg for example) |
| 1309 | // will not be recognized unless this happens. Is this part of the CDC error correction |
| 1310 | // mechanism? |
| 1311 | char *buffer_hack = (char*)&CDC_BUFFER[pt]; |
| 1312 | if (buffer_hack[4 + 64] == 'g' && !strncmp(buffer_hack + 4, "Copyright by SNK", 16)) |
| 1313 | { |
| 1314 | buffer_hack[4 + 64] = 'f'; |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1395 | 1318 | } |
| 1396 | 1319 | else |
| 1397 | 1320 | { |
| r19354 | r19355 | |
| 1402 | 1325 | } |
| 1403 | 1326 | |
| 1404 | 1327 | scd_ctrl_checks(machine); |
| 1328 | |
| 1329 | |
| 1405 | 1330 | } |
| 1406 | 1331 | |
| 1407 | 1332 | |