src/mess/drivers/cdi.c
| r6020 | r6021 | |
| 11 | 11 | |
| 12 | 12 | ******************************************************************************* |
| 13 | 13 | |
| 14 | | |
| 15 | | *** Hardware Notes *** |
| 16 | | |
| 17 | | These are actually the specs of the Philips CD-i console. |
| 18 | | |
| 19 | | Identified: |
| 20 | | |
| 21 | | - CPU: 1x Philips SCC 68070 CCA84 (16 bits Microprocessor, PLCC) @ 15 MHz |
| 22 | | - VSC: 1x Philips SCC 66470 CAB (Video and System Controller, QFP) |
| 23 | | |
| 24 | | - Crystals: 1x 30.0000 MHz. |
| 25 | | 1x 19.6608 MHz. |
| 26 | | |
| 27 | | |
| 28 | | ******************************************************************************* |
| 29 | | |
| 30 | 14 | STATUS: |
| 31 | 15 | |
| 32 | | BIOSes will run until attempting an OS call using the methods described here: |
| 33 | | http://www.icdia.co.uk/microware/tech/tech_2.pdf |
| 16 | Some games will start up, but fail horribly. |
| 34 | 17 | |
| 35 | 18 | TODO: |
| 36 | 19 | |
| 37 | 20 | -Proper handling of the 68070 (68k with 32 address lines instead of 24) |
| 38 | 21 | & handle the extra features properly (UART,DMA,Timers etc.) |
| 39 | 22 | |
| 40 | | -Proper emulation of the 66470 and/or MCD212 Video Chip (still many unhandled features) |
| 23 | -Full emulation of the 66470 and/or MCD212 Video Chip (still many unhandled features) |
| 41 | 24 | |
| 42 | | -Inputs; |
| 25 | -Unknown sound chip (CD-i ADPCM); |
| 43 | 26 | |
| 44 | | -Unknown sound chip (it's an ADPCM with eight channels); |
| 45 | | |
| 46 | | -Many unknown memory maps; |
| 47 | | |
| 48 | 27 | *******************************************************************************/ |
| 49 | 28 | |
| 50 | 29 | |
| r6020 | r6021 | |
| 64 | 43 | |
| 65 | 44 | #define ENABLE_UART_PRINTING (0) |
| 66 | 45 | |
| 67 | | #define VERBOSE_LEVEL (0) |
| 46 | #define VERBOSE_LEVEL (11) |
| 68 | 47 | |
| 48 | #define ENABLE_VERBOSE_LOG (0) |
| 49 | |
| 50 | #if ENABLE_VERBOSE_LOG |
| 69 | 51 | INLINE void verboselog(running_machine *machine, int n_level, const char *s_fmt, ...) |
| 70 | 52 | { |
| 71 | 53 | if( VERBOSE_LEVEL >= n_level ) |
| r6020 | r6021 | |
| 78 | 60 | logerror( "%08x: %s", cpu_get_pc(cputag_get_cpu(machine, "maincpu")), buf ); |
| 79 | 61 | } |
| 80 | 62 | } |
| 63 | #else |
| 64 | #define verboselog(x,y,z,...) |
| 65 | #endif |
| 81 | 66 | |
| 82 | 67 | /*********************** |
| 83 | 68 | * Forward declarations * |
| r6020 | r6021 | |
| 959 | 944 | cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_RAW_DONTCARE); |
| 960 | 945 | for(index = 6; index < 2352/2; index++) |
| 961 | 946 | { |
| 947 | if(cdic_regs.time == 0x00332300 || cdic_regs.time == 0x00332400) |
| 948 | { |
| 949 | //printf( "%02x %02x ", buffer[index*2], buffer[index*2 + 1] ); |
| 950 | } |
| 962 | 951 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1]; |
| 963 | 952 | } |
| 953 | //printf( "\n" ); |
| 964 | 954 | |
| 965 | | printf( "Setting CDIC interrupt line\n" ); |
| 966 | | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); |
| 967 | | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| 968 | | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 969 | | |
| 970 | | timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed |
| 971 | | |
| 972 | | /* This is wrong, can't figure out right now what's right |
| 973 | | if(cdic_regs.audio_channel & 0x8000) |
| 974 | | { |
| 975 | | cdic_regs.z_buffer |= 0x2000; |
| 976 | | cdic_regs.audio_buffer |= 0x8000; |
| 977 | | } |
| 978 | | else |
| 979 | | {*/ |
| 980 | | cdic_regs.x_buffer |= 0x8000; |
| 981 | | //} |
| 982 | | |
| 983 | | cdic_regs.data_buffer |= 0x4000; |
| 984 | | cdic_regs.data_buffer &= 0x7fff; |
| 985 | | |
| 986 | 955 | cdic_regs.time += 0x100; |
| 987 | 956 | if((cdic_regs.time & 0x00000f00) == 0xa00) |
| 988 | 957 | { |
| r6020 | r6021 | |
| 1004 | 973 | } |
| 1005 | 974 | } |
| 1006 | 975 | } |
| 976 | |
| 977 | if(((buffer[22] & 0x24) == 0x24) && (cdic_regs.channel & cdic_regs.audio_channel & (1 << buffer[21]))) |
| 978 | { |
| 979 | // Ignore the audio sector for now. |
| 980 | } |
| 981 | else if((buffer[22] & 0x0e) == 0x00) |
| 982 | { |
| 983 | // Empty message sector, ignore it |
| 984 | } |
| 985 | else //if((buffer[22] & 0x04) == 0x04) |
| 986 | { |
| 987 | cdic_regs.x_buffer |= 0x8000; |
| 988 | |
| 989 | cdic_regs.data_buffer |= 0x4000; |
| 990 | cdic_regs.data_buffer &= 0x7fff; |
| 991 | |
| 992 | printf( "Setting CDIC interrupt line\n" ); |
| 993 | verboselog(machine, 0, "Setting CDIC interrupt line\n" ); |
| 994 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128); |
| 995 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE); |
| 996 | } |
| 997 | |
| 998 | timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed |
| 999 | |
| 1007 | 1000 | break; |
| 1008 | 1001 | } |
| 1009 | 1002 | case 0x2e: // Abort |
| r6020 | r6021 | |
| 1114 | 1107 | for(index = start / 2; index < (start / 2 + count); index++) |
| 1115 | 1108 | { |
| 1116 | 1109 | memory[index] = cdram[src_index++]; |
| 1110 | if(cdic_regs.time == 0x00332400 || cdic_regs.time == 0x00332500) |
| 1111 | { |
| 1112 | printf( "%04x ", cdram[src_index - 1] ); |
| 1113 | } |
| 1117 | 1114 | } |
| 1115 | printf( "\n" ); |
| 1118 | 1116 | scc68070_regs.dma.channel[0].memory_address_counter += scc68070_regs.dma.channel[0].transfer_counter * 2; |
| 1119 | 1117 | break; |
| 1120 | 1118 | } |
| r6020 | r6021 | |
| 1545 | 1543 | UINT16 vsr; |
| 1546 | 1544 | UINT16 ddr; |
| 1547 | 1545 | UINT16 dcp; |
| 1546 | UINT32 dca; |
| 1548 | 1547 | UINT32 clut[256]; |
| 1549 | 1548 | UINT32 image_coding_method; |
| 1550 | 1549 | UINT32 transparency_control; |
| r6020 | r6021 | |
| 1694 | 1693 | verboselog(space->machine, 12, "mcd212_r: Status Register %d: %02x & %04x\n", channel + 1, mcd212.channel[1 - (offset / 8)].csrr, mem_mask); |
| 1695 | 1694 | if(channel == 0) |
| 1696 | 1695 | { |
| 1697 | | return mcd212.channel[0].csrr | 0x20; |
| 1696 | return mcd212.channel[0].csrr; |
| 1698 | 1697 | } |
| 1699 | 1698 | else |
| 1700 | 1699 | { |
| 1701 | 1700 | UINT8 old_csr = mcd212.channel[1].csrr; |
| 1702 | 1701 | UINT8 interrupt1 = (scc68070_regs.lir >> 4) & 7; |
| 1703 | | UINT8 interrupt2 = scc68070_regs.lir & 7; |
| 1702 | //UINT8 interrupt2 = scc68070_regs.lir & 7; |
| 1704 | 1703 | mcd212.channel[1].csrr &= ~(MCD212_CSR2R_IT1 | MCD212_CSR2R_IT2); |
| 1705 | 1704 | if(interrupt1) |
| 1706 | 1705 | { |
| 1707 | 1706 | cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_1 + (interrupt1 - 1), CLEAR_LINE); |
| 1708 | 1707 | } |
| 1709 | | if(interrupt2) |
| 1710 | | { |
| 1711 | | cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_1 + (interrupt2 - 1), CLEAR_LINE); |
| 1712 | | } |
| 1708 | //if(interrupt2) |
| 1709 | //{ |
| 1710 | // cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_1 + (interrupt2 - 1), CLEAR_LINE); |
| 1711 | //} |
| 1713 | 1712 | return old_csr; |
| 1714 | 1713 | } |
| 1715 | 1714 | } |
| r6020 | r6021 | |
| 1722 | 1721 | case 0x12/2: |
| 1723 | 1722 | verboselog(space->machine, 2, "mcd212_r: Display Command Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].dcr, mem_mask); |
| 1724 | 1723 | return mcd212.channel[1 - (offset / 8)].dcr; |
| 1725 | | break; |
| 1726 | 1724 | case 0x04/2: |
| 1727 | 1725 | case 0x14/2: |
| 1728 | 1726 | verboselog(space->machine, 2, "mcd212_r: Video Start Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].vsr, mem_mask); |
| 1729 | 1727 | return mcd212.channel[1 - (offset / 8)].vsr; |
| 1730 | | break; |
| 1731 | 1728 | case 0x08/2: |
| 1732 | 1729 | case 0x18/2: |
| 1733 | 1730 | verboselog(space->machine, 2, "mcd212_r: Display Decoder Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].ddr, mem_mask); |
| 1734 | 1731 | return mcd212.channel[1 - (offset / 8)].ddr; |
| 1735 | | break; |
| 1736 | 1732 | case 0x0a/2: |
| 1737 | 1733 | case 0x1a/2: |
| 1738 | 1734 | verboselog(space->machine, 2, "mcd212_r: DCA Pointer Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, mcd212.channel[1 - (offset / 8)].dcp, mem_mask); |
| 1739 | 1735 | return mcd212.channel[1 - (offset / 8)].dcp; |
| 1740 | | break; |
| 1741 | 1736 | default: |
| 1742 | 1737 | verboselog(space->machine, 2, "mcd212_r: Unknown Register %d & %04x\n", (1 - (offset / 8)) + 1, mem_mask); |
| 1743 | 1738 | break; |
| r6020 | r6021 | |
| 2012 | 2007 | case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f: |
| 2013 | 2008 | verboselog(machine, 11, "%08x: %08x: ICA %d: INTERRUPT\n", addr * 2 + channel * 0x200000, cmd, channel ); |
| 2014 | 2009 | mcd212.channel[1].csrr |= 1 << (2 - channel); |
| 2015 | | if(mcd212.channel[1].csrr & MCD212_CSR2R_IT1) |
| 2010 | if(mcd212.channel[1].csrr & (MCD212_CSR2R_IT1 | MCD212_CSR2R_IT2)) |
| 2016 | 2011 | { |
| 2017 | 2012 | UINT8 interrupt = (scc68070_regs.lir >> 4) & 7; |
| 2018 | 2013 | if(interrupt) |
| r6020 | r6021 | |
| 2021 | 2016 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_1 + (interrupt - 1), ASSERT_LINE); |
| 2022 | 2017 | } |
| 2023 | 2018 | } |
| 2019 | /* |
| 2024 | 2020 | if(mcd212.channel[1].csrr & MCD212_CSR2R_IT2) |
| 2025 | 2021 | { |
| 2026 | 2022 | UINT8 interrupt = scc68070_regs.lir & 7; |
| r6020 | r6021 | |
| 2030 | 2026 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_1 + (interrupt - 1), ASSERT_LINE); |
| 2031 | 2027 | } |
| 2032 | 2028 | } |
| 2029 | */ |
| 2033 | 2030 | break; |
| 2034 | 2031 | case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: // RELOAD DISPLAY PARAMETERS |
| 2035 | 2032 | verboselog(machine, 11, "%08x: %08x: ICA %d: RELOAD DISPLAY PARAMETERS\n", addr * 2 + channel * 0x200000, cmd, channel ); |
| r6020 | r6021 | |
| 2049 | 2046 | static void mcd212_process_dca(running_machine *machine, int channel) |
| 2050 | 2047 | { |
| 2051 | 2048 | UINT16 *dca = channel ? planeb : planea; |
| 2052 | | UINT32 addr = mcd212_get_dcp(channel) / 2; |
| 2049 | UINT32 addr = (mcd212.channel[channel].dca & 0x0007ffff) / 2; //(mcd212_get_dcp(channel) & 0x0007ffff) / 2; // mcd212.channel[channel].dca / 2; |
| 2053 | 2050 | UINT32 cmd = 0; |
| 2054 | 2051 | UINT32 count = 0; |
| 2055 | | UINT32 max = (mcd212.channel[channel].dcr & MCD212_DCR_CM) ? 64 : 32; |
| 2052 | UINT32 max = 64; //(mcd212.channel[channel].dcr & MCD212_DCR_CM) ? 64 : 32; |
| 2053 | UINT8 addr_changed = 0; |
| 2054 | //printf( "max = %d\n", max ); |
| 2056 | 2055 | while(1) |
| 2057 | 2056 | { |
| 2058 | 2057 | UINT8 stop = 0; |
| r6020 | r6021 | |
| 2068 | 2067 | break; |
| 2069 | 2068 | case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: // NOP |
| 2070 | 2069 | case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: |
| 2071 | | verboselog(machine, 12, "%08x: %08x: DCA %d: NOP\n", addr * 2 + channel * 0x200000, cmd, channel ); |
| 2070 | verboselog(machine, 11, "%08x: %08x: DCA %d: NOP\n", addr * 2 + channel * 0x200000, cmd, channel ); |
| 2072 | 2071 | break; |
| 2073 | 2072 | case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: // RELOAD DCP |
| 2074 | 2073 | case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: |
| r6020 | r6021 | |
| 2078 | 2077 | case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f: |
| 2079 | 2078 | verboselog(machine, 11, "%08x: %08x: DCA %d: RELOAD DCP and STOP\n", addr * 2 + channel * 0x200000, cmd, channel ); |
| 2080 | 2079 | mcd212_set_dcp(channel, cmd & 0x001fffff); |
| 2080 | addr = (cmd & 0x0007ffff) / 2; |
| 2081 | addr_changed = 1; |
| 2081 | 2082 | stop = 1; |
| 2082 | 2083 | break; |
| 2083 | 2084 | case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: // RELOAD VSR |
| r6020 | r6021 | |
| 2095 | 2096 | case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f: |
| 2096 | 2097 | verboselog(machine, 11, "%08x: %08x: DCA %d: INTERRUPT\n", addr * 2 + channel * 0x200000, cmd, channel ); |
| 2097 | 2098 | mcd212.channel[1].csrr |= 1 << (2 - channel); |
| 2098 | | if(mcd212.channel[1].csrr & MCD212_CSR2R_IT1) |
| 2099 | if(mcd212.channel[1].csrr & (MCD212_CSR2R_IT1 | MCD212_CSR2R_IT2)) |
| 2099 | 2100 | { |
| 2100 | 2101 | UINT8 interrupt = (scc68070_regs.lir >> 4) & 7; |
| 2101 | 2102 | if(interrupt) |
| 2102 | 2103 | { |
| 2103 | | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_1 + (interrupt - 1), 24 + interrupt); |
| 2104 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_1 + (interrupt - 1), 56 + interrupt); |
| 2104 | 2105 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_1 + (interrupt - 1), ASSERT_LINE); |
| 2105 | 2106 | } |
| 2106 | 2107 | } |
| 2108 | /* |
| 2107 | 2109 | if(mcd212.channel[1].csrr & MCD212_CSR2R_IT2) |
| 2108 | 2110 | { |
| 2109 | 2111 | UINT8 interrupt = scc68070_regs.lir & 7; |
| r6020 | r6021 | |
| 2113 | 2115 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_1 + (interrupt - 1), ASSERT_LINE); |
| 2114 | 2116 | } |
| 2115 | 2117 | } |
| 2118 | */ |
| 2116 | 2119 | break; |
| 2117 | 2120 | case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: // RELOAD DISPLAY PARAMETERS |
| 2118 | 2121 | verboselog(machine, 11, "%08x: %08x: DCA %d: RELOAD DISPLAY PARAMETERS\n", addr * 2 + channel * 0x200000, cmd, channel ); |
| r6020 | r6021 | |
| 2127 | 2130 | break; |
| 2128 | 2131 | } |
| 2129 | 2132 | } |
| 2133 | mcd212.channel[channel].dca = addr * 2; |
| 2130 | 2134 | } |
| 2131 | 2135 | |
| 2132 | 2136 | static UINT8 mcd212_dyuv_quantizer[16] = { 0, 1, 4, 9, 16, 27, 44, 79, 128, 177, 212, 229, 240, 247, 252, 255 }; |
| r6020 | r6021 | |
| 2164 | 2168 | pixels[x++] = 0x00070707; |
| 2165 | 2169 | pixels[x] = 0x00070707; |
| 2166 | 2170 | } |
| 2167 | | done = 1; |
| 2171 | return; |
| 2168 | 2172 | } |
| 2169 | 2173 | |
| 2170 | 2174 | while(!done) |
| r6020 | r6021 | |
| 2184 | 2188 | else |
| 2185 | 2189 | { |
| 2186 | 2190 | // 8-bit Bitmap |
| 2187 | | UINT32 mask = channel ? 0x00000f00 : 0x0000000f; |
| 2188 | | UINT32 shift = channel ? 8 : 0; |
| 2189 | 2191 | if(icm == 5) |
| 2190 | 2192 | { |
| 2191 | 2193 | UINT8 y; |
| r6020 | r6021 | |
| 2240 | 2242 | } |
| 2241 | 2243 | mcd212_set_vsr(channel, vsr - 1); |
| 2242 | 2244 | } |
| 2243 | | else if(((mcd212.channel[0].image_coding_method & mask) >> shift) == 0x3) |
| 2245 | else if(icm == 3) |
| 2244 | 2246 | { |
| 2245 | 2247 | for(; x < 768; x++) |
| 2246 | 2248 | { |
| r6020 | r6021 | |
| 2480 | 2482 | { |
| 2481 | 2483 | // Process ICA |
| 2482 | 2484 | int index = 0; |
| 2485 | verboselog(machine, 0, "FRAME START\n" ); |
| 2483 | 2486 | mcd212.channel[0].csrr &= 0x7f; |
| 2484 | 2487 | for(index = 0; index < 2; index++) |
| 2485 | 2488 | { |
| r6020 | r6021 | |
| 2505 | 2508 | { |
| 2506 | 2509 | if(mcd212.channel[index].dcr & MCD212_DCR_DCA) |
| 2507 | 2510 | { |
| 2511 | if(scanline == 22) |
| 2512 | { |
| 2513 | mcd212.channel[index].dca = mcd212_get_dcp(index); |
| 2514 | } |
| 2508 | 2515 | mcd212_process_dca(machine, index); |
| 2509 | 2516 | } |
| 2510 | 2517 | } |
| 2518 | if(scanline == 261) |
| 2519 | { |
| 2520 | mcd212.channel[0].csrr ^= 0x20; |
| 2521 | } |
| 2511 | 2522 | } |
| 2512 | 2523 | } |
| 2513 | 2524 | timer_adjust_oneshot(mcd212.scan_timer, video_screen_get_time_until_pos(machine->primary_screen, ( scanline + 1 ) % 262, 0), 0); |
| r6020 | r6021 | |
| 2623 | 2634 | device_reset(cputag_get_cpu(machine, "maincpu")); |
| 2624 | 2635 | |
| 2625 | 2636 | cdic_regs.z_buffer = 0; |
| 2637 | cdic_regs.channel = 0xffffffff; |
| 2626 | 2638 | } |
| 2627 | 2639 | |
| 2628 | 2640 | /************************* |