| Previous | 15994 Revisions | Next |
| r6141 Tuesday 20th October, 2009 at 03:31:51 UTC by Harmony |
|---|
| [CDI] Improved Sound Map support: [Harmony] - Enabled sound effects by default - Known issue(s): - Sometimes game logic will flip out and attempt to DMA from a nonexistent RAM address, causing a crash - see Whack-A-Bubble in-game and Hotel Mario upon completing a level. - Fixed issue(s): - Zelda's voice no longer cuts out during the Wand of Gamelon tutorial |
| [src/mess/drivers] | cdi.c |
| r6140 | r6141 | |
|---|---|---|
| 45 | 45 | |
| 46 | 46 | #define ENABLE_UART_PRINTING (0) |
| 47 | 47 | |
| 48 | #define VERBOSE_LEVEL ( | |
| 48 | #define VERBOSE_LEVEL (5) | |
| 49 | 49 | |
| 50 | 50 | #define ENABLE_VERBOSE_LOG (0) |
| 51 | 51 | |
| r6140 | r6141 | |
| 966 | 966 | |
| 967 | 967 | static int cdic_xa_last[4] = { 0, 0, 0, 0 }; |
| 968 | 968 | |
| 969 | INLINE int CDIC_IS_VALID_SAMPLE_BUF(UINT16 addr) | |
| 970 | { | |
| 971 | UINT8 *cdram8 = ((UINT8*)cdram) + addr + 8; | |
| 972 | if(cdram8[2] != 0xff) | |
| 973 | { | |
| 974 | return 1; | |
| 975 | } | |
| 976 | return 0; | |
| 977 | } | |
| 978 | ||
| 979 | INLINE double CDIC_SAMPLE_BUF_FREQ(UINT16 addr) | |
| 980 | { | |
| 981 | UINT8 *cdram8 = ((UINT8*)cdram) + addr + 8; | |
| 982 | switch(cdram8[2] & 0x3f) | |
| 983 | { | |
| 984 | case 0: | |
| 985 | case 1: | |
| 986 | case 16: | |
| 987 | case 17: | |
| 988 | return 37800.0f; | |
| 989 | ||
| 990 | case 4: | |
| 991 | case 5: | |
| 992 | return 18900.0f; | |
| 993 | ||
| 994 | default: | |
| 995 | return 18900.0f; | |
| 996 | } | |
| 997 | } | |
| 998 | ||
| 999 | INLINE int CDIC_SAMPLE_BUF_SIZE(UINT16 addr) | |
| 1000 | { | |
| 1001 | UINT8 *cdram8 = ((UINT8*)cdram) + addr + 8; | |
| 1002 | switch(cdram8[2] & 0x3f) | |
| 1003 | { | |
| 1004 | case 0: | |
| 1005 | case 4: | |
| 1006 | return 4; | |
| 1007 | ||
| 1008 | case 1: | |
| 1009 | case 5: | |
| 1010 | case 16: | |
| 1011 | return 2; | |
| 1012 | ||
| 1013 | case 17: | |
| 1014 | return 1; | |
| 1015 | ||
| 1016 | default: | |
| 1017 | return 2; | |
| 1018 | } | |
| 1019 | } | |
| 1020 | ||
| 969 | 1021 | INLINE INT16 clamp(INT16 in) |
| 970 | 1022 | { |
| 971 | 1023 | return in; |
| r6140 | r6141 | |
| 1064 | 1116 | l3=cdic_xa_last[3]; |
| 1065 | 1117 | int b=0; |
| 1066 | 1118 | int s=0; |
| 1119 | int decoded = 0; | |
| 1067 | 1120 | |
| 1068 | 1121 | for (b=0; b<18; b++) |
| 1069 | 1122 | { |
| r6140 | r6141 | |
| 1096 | 1149 | *dp++=d1; |
| 1097 | 1150 | l3=l2; |
| 1098 | 1151 | l2=d1; |
| 1152 | decoded += 2; | |
| 1099 | 1153 | } |
| 1100 | 1154 | } |
| 1101 | 1155 | |
| r6140 | r6141 | |
| 1106 | 1160 | cdic_xa_last[1]=l1; |
| 1107 | 1161 | cdic_xa_last[2]=l2; |
| 1108 | 1162 | cdic_xa_last[3]=l3; |
| 1163 | ||
| 1164 | //printf( "Decoded %d samples\n", decoded ); | |
| 1109 | 1165 | } |
| 1110 | 1166 | |
| 1111 | 1167 | static void cdic_decode_xa_stereo8(const unsigned char *xa, signed short *dp) |
| r6140 | r6141 | |
| 1172 | 1228 | INT16 samples[18*28*16+16]; |
| 1173 | 1229 | //FILE* temp_adpcm = fopen("temp_adpcm.bin","ab"); |
| 1174 | 1230 | |
| 1231 | //printf( "%02x\n", hdr[2] & 0x3f ); | |
| 1232 | ||
| 1175 | 1233 | if(hdr[2] == 0xff && triggered == 1) |
| 1176 | 1234 | { |
| 1177 | // Stop playing | |
| 1178 | timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_never, 0); | |
| 1235 | // Don't play | |
| 1236 | //timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_never, 0); | |
| 1237 | //fclose(temp_adpcm); | |
| 1179 | 1238 | return; |
| 1180 | 1239 | } |
| 1181 | 1240 | |
| 1241 | verboselog(machine, 0, "cdic_decode_audio_sector, got header type %02x\n", hdr[2] ); | |
| 1242 | ||
| 1182 | 1243 | //fseek(temp_adpcm, 0, SEEK_END); |
| 1183 | //printf( "%02x\n", hdr[2] & 0x3f ); | |
| 1184 | 1244 | switch(hdr[2] & 0x3f) // ignore emphasis and reserved bits |
| 1185 | 1245 | { |
| 1186 | 1246 | case 0: |
| r6140 | r6141 | |
| 1250 | 1310 | break; |
| 1251 | 1311 | case 8: |
| 1252 | 1312 | cdic_decode_xa_mono8(hdr + 4, samples); |
| 1253 | //fwrite(samples, 1, 18*28*4, temp_adpcm); | |
| 1254 | 1313 | for(index = 18*28*8 - 1; index >= 0; index--) |
| 1255 | 1314 | { |
| 1256 | 1315 | samples[index*2 + 1] = samples[index]; |
| r6140 | r6141 | |
| 1268 | 1327 | cdic_decode_xa_stereo(hdr + 4, samples); |
| 1269 | 1328 | samples[18*28*8 + 0] = samples[18*28*8 + 2] = samples[18*28*8 + 4] = samples[18*28*8 + 6] = samples[18*28*8 + 8] = samples[18*28*8 + 10] = samples[18*28*8 + 12] = samples[18*28*8 + 14] = samples[18*28*8 - 2]; |
| 1270 | 1329 | samples[18*28*8 + 1] = samples[18*28*8 + 3] = samples[18*28*8 + 5] = samples[18*28*8 + 7] = samples[18*28*8 + 9] = samples[18*28*8 + 11] = samples[18*28*8 + 13] = samples[18*28*8 + 15] = samples[18*28*8 - 1]; |
| 1330 | //fwrite(samples, 1, 18*28*4*cdic_regs.audio_sample_size, temp_adpcm); | |
| 1271 | 1331 | break; |
| 1272 | 1332 | case 8: |
| 1273 | 1333 | cdic_decode_xa_stereo8(hdr + 4, samples); |
| r6140 | r6141 | |
| 1286 | 1346 | // After an appropriate delay for decoding to take place... |
| 1287 | 1347 | static TIMER_CALLBACK( audio_sample_trigger ) |
| 1288 | 1348 | { |
| 1289 | attotime period; | |
| 1349 | if(cdic_regs.z_buffer & 0x2000) | |
| 1350 | { | |
| 1351 | // Indicate that data has been decoded | |
| 1352 | verboselog(machine, 0, "Flagging that audio data has been decoded\n" ); | |
| 1353 | cdic_regs.audio_buffer |= 0x8000; | |
| 1354 | } | |
| 1290 | 1355 | |
| 1291 | // Decode the data at Z+4, the same offset as a normal CD sector. | |
| 1292 | cdic_decode_audio_sector(machine, ((UINT8*)cdram) + cdic_regs.z_buffer + 4, 1); | |
| 1356 | // Set the CDIC interrupt line | |
| 1357 | verboselog(machine, 0, "Setting CDIC interrupt line for soundmap decode\n" ); | |
| 1358 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); | |
| 1359 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); | |
| 1293 | 1360 | |
| 1294 | // Swap buffer positions to indicate our new buffer position at the next read | |
| 1295 | cdic_regs.z_buffer = (cdic_regs.z_buffer == 0x2800) ? 0x3200 : 0x2800; | |
| 1361 | if(CDIC_IS_VALID_SAMPLE_BUF(cdic_regs.z_buffer & 0x3ffe)) | |
| 1362 | { | |
| 1363 | attotime period; | |
| 1296 | 1364 | |
| 1297 | //// Delay for Frequency * (18*28*2*size in bytes) | |
| 1298 | period = attotime_mul(ATTOTIME_IN_HZ(cdic_regs.audio_sample_freq), 18*28*2*cdic_regs.audio_sample_size); | |
| 1365 | verboselog(machine, 0, "Hit audio_sample_trigger, with cdic_regs.z_buffer == %04x, calling cdic_decode_audio_sector\n", cdic_regs.z_buffer ); | |
| 1299 | 1366 | |
| 1300 | // Indicate that data has been decoded | |
| 1301 | cdic_regs.audio_buffer |= 0x8000; | |
| 1367 | // Decode the data at Z+4, the same offset as a normal CD sector. | |
| 1368 | cdic_decode_audio_sector(machine, ((UINT8*)cdram) + (cdic_regs.z_buffer & 0x3ffe) + 4, 1); | |
| 1302 | 1369 | |
| 1303 | // Set the CDIC interrupt line | |
| 1304 | //printf( "Setting CDIC interrupt line\n" ); | |
| 1305 | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); | |
| 1306 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); | |
| 1307 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); | |
| 1370 | // Swap buffer positions to indicate our new buffer position at the next read | |
| 1371 | cdic_regs.z_buffer &= 0xfffe; | |
| 1372 | cdic_regs.z_buffer += 0xa00; | |
| 1373 | if(cdic_regs.z_buffer == 0x3c00) | |
| 1374 | { | |
| 1375 | cdic_regs.z_buffer = 0x2800; | |
| 1376 | } | |
| 1308 | 1377 | |
| 1309 | // Request more data as necessary | |
| 1310 | timer_adjust_oneshot(cdic_regs.audio_sample_timer, period, 0); | |
| 1311 | //dmadac_enable(&dmadac[0], 2, 0); | |
| 1378 | verboselog(machine, 0, "Updated cdic_regs.z_buffer, new value is %04x\n", cdic_regs.z_buffer ); | |
| 1379 | ||
| 1380 | //// Delay for Frequency * (18*28*2*size in bytes) before requesting more data | |
| 1381 | verboselog(machine, 0, "Data is valid, setting up a new callback\n" ); | |
| 1382 | period = attotime_mul(ATTOTIME_IN_HZ(CDIC_SAMPLE_BUF_FREQ(cdic_regs.z_buffer & 0x3ffe)), 18*28*2*CDIC_SAMPLE_BUF_SIZE(cdic_regs.z_buffer & 0x3ffe)); | |
| 1383 | timer_adjust_oneshot(cdic_regs.audio_sample_timer, period, 0); | |
| 1384 | //dmadac_enable(&dmadac[0], 2, 0); | |
| 1385 | } | |
| 1386 | else | |
| 1387 | { | |
| 1388 | cdic_regs.z_buffer &= 0xfffe; | |
| 1389 | verboselog(machine, 0, "Data is not valid, stopping playback\n" ); | |
| 1390 | timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_never, 0); | |
| 1391 | } | |
| 1312 | 1392 | } |
| 1313 | 1393 | |
| 1314 | 1394 | static TIMER_CALLBACK( cdic_trigger_readback_int ) |
| r6140 | r6141 | |
| 1392 | 1472 | } |
| 1393 | 1473 | |
| 1394 | 1474 | //printf( "%02x\n", buffer[CDIC_SECTOR_SUBMODE2] ); |
| 1395 | if(((buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_FORM | CDIC_SUBMODE_DATA | CDIC_SUBMODE_AUDIO | CDIC_SUBMODE_VIDEO)) == (CDIC_SUBMODE_FORM | CDIC_SUBMODE_AUDIO)) && | |
| 1396 | (cdic_regs.channel & cdic_regs.audio_channel & (1 << buffer[CDIC_SECTOR_CHAN2]))) | |
| 1475 | if(((buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_FORM | CDIC_SUBMODE_DATA | CDIC_SUBMODE_AUDIO | CDIC_SUBMODE_VIDEO)) == (CDIC_SUBMODE_FORM | CDIC_SUBMODE_AUDIO))) | |
| 1397 | 1476 | { |
| 1477 | cdic_regs.data_buffer &= 0x7fff; | |
| 1478 | if(cdic_regs.channel & (1 << buffer[CDIC_SECTOR_CHAN2])) | |
| 1479 | { | |
| 1398 | 1480 | //if(!(buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_TRIG)) |
| 1399 | 1481 | //{ |
| 1400 | 1482 | verboselog(machine, 0, "Audio sector\n" ); |
| 1401 | 1483 | //} |
| 1402 | 1484 | //else |
| 1403 | 1485 | //{ |
| 1404 | cdic_regs.data_buffer |= 0x0004; | |
| 1486 | //cdic_regs.data_buffer |= 0x0004; | |
| 1405 | 1487 | cdic_regs.data_buffer ^= 0x0001; |
| 1406 | 1488 | for(index = 6; index < 2352/2; index++) |
| 1407 | 1489 | { |
| 1408 | 1490 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1]; |
| 1409 | 1491 | } |
| 1410 | 1492 | |
| 1411 | cdic_decode_audio_sector(machine, ((UINT8*)cdram) + ((cdic_regs.data_buffer & 5) * 0xa00 + 4), 0); | |
| 1412 | // Ignore the audio sector for now. | |
| 1493 | if(cdic_regs.audio_channel & (1 << buffer[CDIC_SECTOR_CHAN2])) | |
| 1494 | { | |
| 1495 | cdic_decode_audio_sector(machine, ((UINT8*)cdram) + ((cdic_regs.data_buffer & 5) * 0xa00 + 4), 0); | |
| 1496 | } | |
| 1497 | //else | |
| 1498 | { | |
| 1499 | //cdic_regs.data_buffer &= ~0x0004; | |
| 1500 | } | |
| 1501 | ||
| 1502 | //cdic_regs.audio_buffer |= 0x8000; | |
| 1503 | ||
| 1413 | 1504 | cdic_regs.x_buffer |= 0x8000; |
| 1414 | 1505 | |
| 1415 | 1506 | cdic_regs.data_buffer |= 0x4000; |
| 1416 | cdic_regs.data_buffer &= 0x7fff; | |
| 1417 | 1507 | |
| 1418 | 1508 | //printf( "Setting CDIC interrupt line\n" ); |
| 1419 | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); | |
| 1509 | verboselog(machine, 0, "Setting CDIC interrupt line for audio sector\n" ); | |
| 1420 | 1510 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| 1421 | 1511 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 1422 | 1512 | //} |
| 1513 | } | |
| 1423 | 1514 | } |
| 1424 | 1515 | else if((buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_DATA | CDIC_SUBMODE_AUDIO | CDIC_SUBMODE_VIDEO)) == 0x00) |
| 1425 | 1516 | { |
| 1517 | cdic_regs.data_buffer &= 0x7fff; | |
| 1426 | 1518 | cdic_regs.data_buffer &= ~0x0004; |
| 1427 | 1519 | cdic_regs.data_buffer ^= 0x0001; |
| 1428 | 1520 | for(index = 6; index < 2352/2; index++) |
| r6140 | r6141 | |
| 1430 | 1522 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1]; |
| 1431 | 1523 | } |
| 1432 | 1524 | |
| 1433 | if((buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_TRIG) == CDIC_SUBMODE_TRIG || (buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_EOR | CDIC_SUBMODE_FORM)) == (CDIC_SUBMODE_EOR | CDIC_SUBMODE_FORM)) | |
| 1434 | { | |
| 1435 | cdic_regs.x_buffer |= 0x8000; | |
| 1525 | cdic_regs.x_buffer |= 0x8000; | |
| 1436 | 1526 | |
| 1437 | cdic_regs.data_buffer |= 0x4000; | |
| 1438 | cdic_regs.data_buffer &= 0x7fff; | |
| 1527 | cdic_regs.data_buffer |= 0x4000; | |
| 1439 | 1528 | |
| 1529 | if((buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_TRIG) == CDIC_SUBMODE_TRIG || | |
| 1530 | (buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_EOR) == CDIC_SUBMODE_EOR || | |
| 1531 | (buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_EOF) == CDIC_SUBMODE_EOF) | |
| 1532 | { | |
| 1440 | 1533 | //printf( "Setting CDIC interrupt line\n" ); |
| 1441 | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); | |
| 1534 | verboselog(machine, 0, "Setting CDIC interrupt line for message sector\n" ); | |
| 1442 | 1535 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| 1443 | 1536 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 1444 | 1537 | } |
| r6140 | r6141 | |
| 1447 | 1540 | verboselog(machine, 0, "Message sector, ignored\n" ); |
| 1448 | 1541 | } |
| 1449 | 1542 | } |
| 1450 | else /*if(buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_DATA | CDIC_SUBMODE_VIDEO))*/ | |
| 1543 | else if((buffer[CDIC_SECTOR_FILE2] << 8) == cdic_regs.file) /*if(buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_DATA | CDIC_SUBMODE_VIDEO))*/ | |
| 1451 | 1544 | { |
| 1545 | cdic_regs.data_buffer &= 0x7fff; | |
| 1546 | ||
| 1452 | 1547 | cdic_regs.x_buffer |= 0x8000; |
| 1453 | 1548 | |
| 1454 | 1549 | cdic_regs.data_buffer |= 0x4000; |
| 1455 | cdic_regs.data_buffer &= 0x7fff; | |
| 1456 | 1550 | |
| 1457 | 1551 | cdic_regs.data_buffer &= ~0x0004; |
| 1458 | 1552 | cdic_regs.data_buffer ^= 0x0001; |
| r6140 | r6141 | |
| 1462 | 1556 | } |
| 1463 | 1557 | |
| 1464 | 1558 | //printf( "Setting CDIC interrupt line\n" ); |
| 1465 | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); | |
| 1559 | verboselog(machine, 0, "Setting CDIC interrupt line for data sector\n" ); | |
| 1466 | 1560 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| 1467 | 1561 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 1468 | 1562 | } |
| r6140 | r6141 | |
| 1473 | 1567 | } |
| 1474 | 1568 | else |
| 1475 | 1569 | { |
| 1476 | cdic_regs.command = 0; | |
| 1570 | //cdic_regs.command = 0; | |
| 1477 | 1571 | } |
| 1478 | 1572 | |
| 1479 | 1573 | break; |
| r6140 | r6141 | |
| 1487 | 1581 | } |
| 1488 | 1582 | } |
| 1489 | 1583 | |
| 1490 | INLINE int CDIC_IS_VALID_SAMPLE_BUF(UINT16 addr) | |
| 1491 | { | |
| 1492 | UINT8 *cdram8 = ((UINT8*)cdram) + addr + 4; | |
| 1493 | if(cdram8[2] != 0xff) | |
| 1494 | { | |
| 1495 | return 1; | |
| 1496 | } | |
| 1497 | return 0; | |
| 1498 | } | |
| 1499 | ||
| 1500 | INLINE double CDIC_SAMPLE_BUF_FREQ(UINT16 addr) | |
| 1501 | { | |
| 1502 | UINT8 *cdram8 = ((UINT8*)cdram) + addr + 4; | |
| 1503 | switch(cdram8[2] & 0x3f) | |
| 1504 | { | |
| 1505 | case 0: | |
| 1506 | case 1: | |
| 1507 | case 16: | |
| 1508 | case 17: | |
| 1509 | return 37800.0f; | |
| 1510 | ||
| 1511 | case 4: | |
| 1512 | case 5: | |
| 1513 | return 18900.0f; | |
| 1514 | ||
| 1515 | default: | |
| 1516 | return 18900.0f; | |
| 1517 | } | |
| 1518 | } | |
| 1519 | ||
| 1520 | INLINE int CDIC_SAMPLE_BUF_SIZE(UINT16 addr) | |
| 1521 | { | |
| 1522 | UINT8 *cdram8 = ((UINT8*)cdram) + addr + 4; | |
| 1523 | switch(cdram8[2] & 0x3f) | |
| 1524 | { | |
| 1525 | case 0: | |
| 1526 | case 4: | |
| 1527 | return 4; | |
| 1528 | ||
| 1529 | case 1: | |
| 1530 | case 5: | |
| 1531 | case 16: | |
| 1532 | return 2; | |
| 1533 | ||
| 1534 | case 17: | |
| 1535 | return 1; | |
| 1536 | ||
| 1537 | default: | |
| 1538 | return 2; | |
| 1539 | } | |
| 1540 | } | |
| 1541 | ||
| 1542 | 1584 | static READ16_HANDLER( cdic_r ) |
| 1543 | 1585 | { |
| 1544 | 1586 | offset += 0x3c00/2; |
| r6140 | r6141 | |
| 1547 | 1589 | case 0x3c00/2: // Command register |
| 1548 | 1590 | verboselog(space->machine, 0, "cdic_r: Command Register = %04x & %04x\n", cdic_regs.command, mem_mask); |
| 1549 | 1591 | return cdic_regs.command; |
| 1592 | case 0x3c02/2: // Time register (MSW) | |
| 1593 | verboselog(space->machine, 0, "cdic_r: Time Register (MSW) = %04x & %04x\n", cdic_regs.time >> 16, mem_mask); | |
| 1594 | return cdic_regs.time >> 16; | |
| 1595 | case 0x3c04/2: // Time register (LSW) | |
| 1596 | verboselog(space->machine, 0, "cdic_r: Time Register (LSW) = %04x & %04x\n", (UINT16)(cdic_regs.time & 0x0000ffff), mem_mask); | |
| 1597 | return cdic_regs.time & 0x0000ffff; | |
| 1598 | case 0x3c06/2: // File register | |
| 1599 | verboselog(space->machine, 0, "cdic_r: File Register = %04x & %04x\n", cdic_regs.file, mem_mask); | |
| 1600 | return cdic_regs.file; | |
| 1550 | 1601 | case 0x3c08/2: // Channel register (MSW) |
| 1551 | 1602 | verboselog(space->machine, 0, "cdic_r: Channel Register (MSW) = %04x & %04x\n", cdic_regs.channel >> 16, mem_mask); |
| 1552 | 1603 | return cdic_regs.channel >> 16; |
| r6140 | r6141 | |
| 1565 | 1616 | verboselog(space->machine, 0, "Clearing CDIC interrupt line\n" ); |
| 1566 | 1617 | //printf("Clearing CDIC interrupt line\n" ); |
| 1567 | 1618 | } |
| 1619 | verboselog(space->machine, 0, "cdic_r: Audio Buffer Register = %04x & %04x\n", temp, mem_mask); | |
| 1568 | 1620 | cdic_regs.audio_buffer &= 0x7fff; |
| 1569 | verboselog(space->machine, 0, "cdic_r: Audio Buffer Register = %04x & %04x\n", temp, mem_mask); | |
| 1570 | 1621 | return temp; |
| 1571 | 1622 | } |
| 1572 | 1623 | case 0x3ff6/2: |
| r6140 | r6141 | |
| 1577 | 1628 | return temp; |
| 1578 | 1629 | } |
| 1579 | 1630 | case 0x3ffa/2: |
| 1631 | { | |
| 1632 | if(!(cdic_regs.z_buffer & 0x2000)) | |
| 1633 | { | |
| 1634 | cdic_regs.z_buffer ^= 0x0001; | |
| 1635 | } | |
| 1580 | 1636 | verboselog(space->machine, 0, "cdic_r: Z-Buffer Register = %04x & %04x\n", cdic_regs.z_buffer, mem_mask); |
| 1581 | 1637 | return cdic_regs.z_buffer; |
| 1638 | } | |
| 1582 | 1639 | case 0x3ffe/2: |
| 1583 | 1640 | { |
| 1584 | 1641 | UINT16 temp = cdic_regs.data_buffer; |
| r6140 | r6141 | |
| 1667 | 1724 | break; |
| 1668 | 1725 | } |
| 1669 | 1726 | case 0x3ffa/2: |
| 1727 | { | |
| 1670 | 1728 | verboselog(space->machine, 0, "cdic_w: Z-Buffer Register = %04x & %04x\n", data, mem_mask); |
| 1671 | 1729 | COMBINE_DATA(&cdic_regs.z_buffer); |
| 1672 | /* | |
| 1673 | 1730 | if(cdic_regs.z_buffer & 0x2000) |
| 1674 | 1731 | { |
| 1675 | if(CDIC_IS_VALID_SAMPLE_BUF(cdic_regs.z_buffer)) | |
| 1732 | if(CDIC_IS_VALID_SAMPLE_BUF(cdic_regs.z_buffer & 0x3ffe)) | |
| 1676 | 1733 | { |
| 1677 | attotime period = attotime_mul(ATTOTIME_IN_HZ(CDIC_SAMPLE_BUF_FREQ(cdic_regs.z_buffer)), 18*28* | |
| 1734 | attotime period = attotime_mul(ATTOTIME_IN_HZ(CDIC_SAMPLE_BUF_FREQ(cdic_regs.z_buffer & 0x3ffe)), 18*28*2 | |
| 1678 | 1735 | timer_adjust_oneshot(cdic_regs.audio_sample_timer, period, 0); |
| 1736 | //timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_zero, 0); | |
| 1679 | 1737 | } |
| 1680 | 1738 | } |
| 1681 | 1739 | else |
| 1682 | 1740 | { |
| 1683 | 1741 | timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_never, 0); |
| 1742 | //if((cdic_regs.z_buffer & 0x3ffe) == 0x800) | |
| 1743 | //{ | |
| 1744 | // cdic_regs.z_buffer |= 0x0001; | |
| 1745 | //} | |
| 1684 | 1746 | } |
| 1685 | */ | |
| 1686 | 1747 | break; |
| 1748 | } | |
| 1687 | 1749 | case 0x3ffc/2: |
| 1688 | 1750 | verboselog(space->machine, 0, "cdic_w: Interrupt Vector Register = %04x & %04x\n", data, mem_mask); |
| 1689 | 1751 | COMBINE_DATA(&cdic_regs.interrupt_vector); |
| r6140 | r6141 | |
| 1702 | 1764 | case 0x2e: // Abort |
| 1703 | 1765 | //timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed |
| 1704 | 1766 | timer_adjust_oneshot(cdic_regs.interrupt_timer, attotime_never, 0); |
| 1767 | //timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_never, 0); | |
| 1705 | 1768 | cdic_regs.data_buffer &= 0x3fff; |
| 1706 | 1769 | dmadac_enable(&dmadac[0], 2, 0); |
| 1707 | 1770 | break; |
| r6140 | r6141 | |
| 1709 | 1772 | case 0x2a: // Read Mode 2 |
| 1710 | 1773 | timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed |
| 1711 | 1774 | cdic_regs.data_buffer &= 0xfffe; |
| 1775 | cdic_regs.z_buffer &= 0xfffe; | |
| 1712 | 1776 | break; |
| 1777 | case 0x2c: // Seek | |
| 1778 | cdic_regs.data_buffer &= 0x7fff; | |
| 1779 | //cdic_regs.x_buffer |= 0x8000; | |
| 1780 | break; | |
| 1713 | 1781 | default: |
| 1714 | 1782 | verboselog(space->machine, 0, "Unknown CDIC command: %02x\n", cdic_regs.command ); |
| 1715 | 1783 | break; |
| r6140 | r6141 | |
| 1997 | 2065 | dmadac_enable(&dmadac[0], 2, 0); |
| 1998 | 2066 | slave_regs.in_index = 0; |
| 1999 | 2067 | slave_regs.in_count = 0; |
| 2000 | timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_never, 0); | |
| 2068 | //timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_never, 0); | |
| 2001 | 2069 | break; |
| 2002 | 2070 | case 0x83: // Unmute audio |
| 2003 | 2071 | verboselog(space->machine, 0, "slave_w: Channel %d: Unmute Audio (0x83)\n", offset ); |
| r6140 | r6141 | |
| 2886 | 2954 | { |
| 2887 | 2955 | int x = 0; |
| 2888 | 2956 | |
| 2889 | static int latched_rf0 = 0; | |
| 2890 | static int latched_rf1 = 0; | |
| 2957 | static int latched_rf0 = 1; | |
| 2958 | static int latched_rf1 = 1; | |
| 2891 | 2959 | static int latched_wfa = 0; |
| 2892 | 2960 | static int latched_wfb = 0; |
| 2893 | 2961 | latched_wfa = mcd212.channel[0].weight_factor_a[0]; |
| r6140 | r6141 | |
| 3446 | 3514 | plane_enable_a = mcd212.region_flag_1[x]; |
| 3447 | 3515 | break; |
| 3448 | 3516 | case 5: |
| 3449 | plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b || mcd212.region_flag_0[x] == | |
| 3517 | plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b || mcd212.region_flag_0[x] == 0); | |
| 3450 | 3518 | break; |
| 3451 | 3519 | case 6: |
| 3452 | 3520 | plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b || mcd212.region_flag_1[x] == 1); |
| r6140 | r6141 | |
| 3684 | 3752 | * Memory maps * |
| 3685 | 3753 | *************************/ |
| 3686 | 3754 | |
| 3687 | /* | |
| 3688 | 3755 | static WRITE16_HANDLER(cdic_ram_w) |
| 3689 | 3756 | { |
| 3690 | 3757 | verboselog(space->machine, 0, "cdic_ram_w: %08x = %04x & %04x\n", 0x00300000 + offset*2, data, mem_mask); |
| r6140 | r6141 | |
| 3696 | 3763 | verboselog(space->machine, 0, "cdic_ram_r: %08x = %04x & %04x\n", 0x00300000 + offset*2, cdram[offset], mem_mask); |
| 3697 | 3764 | return cdram[offset]; |
| 3698 | 3765 | } |
| 3699 | */ | |
| 3700 | 3766 | |
| 3701 | 3767 | static ADDRESS_MAP_START( cdimono1_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 3702 | 3768 | AM_RANGE(0x00000000, 0x0007ffff) AM_RAM AM_BASE(&planea) |
| r6140 | r6141 | |
| 3704 | 3770 | #if ENABLE_UART_PRINTING |
| 3705 | 3771 | AM_RANGE(0x00301400, 0x00301403) AM_READ(uart_loopback_enable) |
| 3706 | 3772 | #endif |
| 3707 | //AM_RANGE(0x00300000, 0x00303bff) AM_READWRITE(cdic_ram_r, cdic_ram_w) AM_BASE(&cdram) | |
| 3708 | AM_RANGE(0x00300000, 0x00303bff) AM_RAM AM_BASE(&cdram) | |
| 3773 | AM_RANGE(0x00300000, 0x00303bff) AM_READWRITE(cdic_ram_r, cdic_ram_w) AM_BASE(&cdram) | |
| 3774 | //AM_RANGE(0x00300000, 0x00303bff) AM_RAM AM_BASE(&cdram) | |
| 3709 | 3775 | AM_RANGE(0x00303c00, 0x00303fff) AM_READWRITE(cdic_r, cdic_w) |
| 3710 | 3776 | AM_RANGE(0x00310000, 0x00317fff) AM_READWRITE(slave_r, slave_w) |
| 3711 | 3777 | //AM_RANGE(0x00318000, 0x0031ffff) AM_NOP |
| r6140 | r6141 | |
| 3773 | 3839 | |
| 3774 | 3840 | cdic_regs.z_buffer = 0; |
| 3775 | 3841 | cdic_regs.channel = 0xffffffff; |
| 3842 | cdic_regs.audio_channel = 0xffff; | |
| 3776 | 3843 | |
| 3777 | 3844 | dmadac[0] = devtag_get_device(machine, "dac1"); |
| 3778 | 3845 | dmadac[1] = devtag_get_device(machine, "dac2"); |
| Previous | 15994 Revisions | Next |