src/mess/drivers/cdi.c
| r6230 | r6231 | |
| 1464 | 1464 | case 0x23: // Reset Mode 1 |
| 1465 | 1465 | case 0x29: // Read Mode 1 |
| 1466 | 1466 | case 0x2a: // Read Mode 2 |
| 1467 | //case 0x2c: // Seek |
| 1467 | 1468 | { |
| 1468 | 1469 | UINT8 buffer[2560] = { 0 }; |
| 1469 | 1470 | UINT32 msf = cdic_regs.time >> 8; |
| r6230 | r6231 | |
| 1638 | 1639 | |
| 1639 | 1640 | break; |
| 1640 | 1641 | } |
| 1641 | | case 0x2c: // Seek |
| 1642 | | timer_adjust_oneshot(cdic_regs.interrupt_timer, attotime_never, 0); |
| 1643 | | |
| 1644 | | cdic_regs.data_buffer &= ~4; |
| 1645 | | |
| 1646 | | verboselog(machine, 0, "Setting CDIC interrupt line for data sector\n" ); |
| 1647 | | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| 1648 | | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 1649 | | break; |
| 1650 | 1642 | case 0x24: // Mode 2 Reset |
| 1651 | 1643 | case 0x2e: // Abort |
| 1652 | 1644 | timer_adjust_oneshot(cdic_regs.interrupt_timer, attotime_never, 0); |
| r6230 | r6231 | |
| 1709 | 1701 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 1710 | 1702 | break; |
| 1711 | 1703 | } |
| 1704 | case 0x2c: // Seek |
| 1705 | { |
| 1706 | UINT8 buffer[2560] = { 0 }; |
| 1707 | int index = 0; |
| 1708 | UINT32 msf = (cdic_regs.time & 0xffff7f00) >> 8; |
| 1709 | UINT32 next_msf = increment_cdda_frame_bcd((cdic_regs.time & 0xffff7f00) >> 8); |
| 1710 | UINT32 lba = 0; |
| 1711 | UINT8 nybbles[6] = |
| 1712 | { |
| 1713 | msf & 0x0000000f, |
| 1714 | (msf & 0x000000f0) >> 4, |
| 1715 | (msf & 0x00000f00) >> 8, |
| 1716 | (msf & 0x0000f000) >> 12, |
| 1717 | (msf & 0x000f0000) >> 16, |
| 1718 | (msf & 0x00f00000) >> 20 |
| 1719 | }; |
| 1720 | lba = nybbles[0] + nybbles[1]*10 + ((nybbles[2] + nybbles[3]*10)*75) + ((nybbles[4] + nybbles[5]*10)*75*60); |
| 1721 | |
| 1722 | timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); |
| 1723 | |
| 1724 | cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_RAW_DONTCARE); |
| 1725 | |
| 1726 | cdic_regs.data_buffer ^= 0x0001; |
| 1727 | cdic_regs.x_buffer |= 0x8000; |
| 1728 | cdic_regs.data_buffer |= 0x4000; |
| 1729 | |
| 1730 | for(index = 6; index < 2352/2; index++) |
| 1731 | { |
| 1732 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1]; |
| 1733 | } |
| 1734 | |
| 1735 | cdram[0x924/2] = 0x0041; // CTRL |
| 1736 | cdram[0x926/2] = 0x0001; // TRACK |
| 1737 | cdram[0x928/2] = 0x0000; // INDEX |
| 1738 | cdram[0x92a/2] = (cdic_regs.time >> 24) & 0x000000ff; // MIN |
| 1739 | cdram[0x92c/2] = (cdic_regs.time >> 16) & 0x000000ff; // SEC |
| 1740 | cdram[0x92e/2] = (cdic_regs.time >> 8) & 0x0000007f; // FRAC |
| 1741 | cdram[0x930/2] = 0x0000; // ZERO |
| 1742 | cdram[0x932/2] = (cdic_regs.time >> 24) & 0x000000ff; // AMIN |
| 1743 | cdram[0x934/2] = (cdic_regs.time >> 16) & 0x000000ff; // ASEC |
| 1744 | cdram[0x936/2] = (cdic_regs.time >> 8) & 0x0000007f; // AFRAC |
| 1745 | cdram[0x938/2] = 0x0000; // CRC1 |
| 1746 | cdram[0x93a/2] = 0x0000; // CRC2 |
| 1747 | |
| 1748 | cdic_regs.time = next_msf << 8; |
| 1749 | |
| 1750 | verboselog(machine, 0, "Setting CDIC interrupt line for Seek sector\n" ); |
| 1751 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| 1752 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 1753 | break; |
| 1754 | } |
| 1712 | 1755 | } |
| 1713 | 1756 | } |
| 1714 | 1757 | |
| r6230 | r6231 | |
| 1933 | 1976 | case 0x2c: // Seek |
| 1934 | 1977 | { |
| 1935 | 1978 | attotime period = timer_timeleft(cdic_regs.interrupt_timer); |
| 1979 | //if(cdic_regs.command == 0x2c) |
| 1980 | //{ |
| 1981 | // cdic_regs.time &= 0xffff0000; |
| 1982 | //} |
| 1936 | 1983 | if(!attotime_is_never(period)) |
| 1937 | 1984 | { |
| 1938 | 1985 | timer_adjust_oneshot(cdic_regs.interrupt_timer, period, 0); |