Previous 15994 Revisions Next

r6021 Friday 9th October, 2009 at 02:10:58 UTC by Harmony
CD-i: Grab bag of updates:
- Improved CDIC sector filtering
- Improved VDSC emulation
- Fixed DCA interrupt vector, many more games boot and run
[src/mess/drivers]cdi.c

src/mess/drivers/cdi.c
r6020r6021
1111
1212*******************************************************************************
1313
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
3014STATUS:
3115
32BIOSes will run until attempting an OS call using the methods described here:
33http://www.icdia.co.uk/microware/tech/tech_2.pdf
16Some games will start up, but fail horribly.
3417
3518TODO:
3619
3720-Proper handling of the 68070 (68k with 32 address lines instead of 24)
3821 & handle the extra features properly (UART,DMA,Timers etc.)
3922
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)
4124
42-Inputs;
25-Unknown sound chip (CD-i ADPCM);
4326
44-Unknown sound chip (it's an ADPCM with eight channels);
45
46-Many unknown memory maps;
47
4827*******************************************************************************/
4928
5029
r6020r6021
6443
6544#define ENABLE_UART_PRINTING (0)
6645
67#define VERBOSE_LEVEL   (0)
46#define VERBOSE_LEVEL   (11)
6847
48#define ENABLE_VERBOSE_LOG (0)
49
50#if ENABLE_VERBOSE_LOG
6951INLINE void verboselog(running_machine *machine, int n_level, const char *s_fmt, ...)
7052{
7153   if( VERBOSE_LEVEL >= n_level )
r6020r6021
7860      logerror( "%08x: %s", cpu_get_pc(cputag_get_cpu(machine, "maincpu")), buf );
7961   }
8062}
63#else
64#define verboselog(x,y,z,...)
65#endif
8166
8267/***********************
8368* Forward declarations *
r6020r6021
959944         cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_RAW_DONTCARE);
960945         for(index = 6; index < 2352/2; index++)
961946         {
947            if(cdic_regs.time == 0x00332300 || cdic_regs.time == 0x00332400)
948            {
949               //printf( "%02x %02x ", buffer[index*2], buffer[index*2 + 1] );
950            }
962951            cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1];
963952         }
953         //printf( "\n" );
964954
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
986955         cdic_regs.time += 0x100;
987956         if((cdic_regs.time & 0x00000f00) == 0xa00)
988957         {
r6020r6021
1004973               }
1005974            }
1006975         }
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
10071000         break;
10081001      }
10091002      case 0x2e: // Abort
r6020r6021
11141107         for(index = start / 2; index < (start / 2 + count); index++)
11151108         {
11161109            memory[index] = cdram[src_index++];
1110            if(cdic_regs.time == 0x00332400 || cdic_regs.time == 0x00332500)
1111            {
1112               printf( "%04x ", cdram[src_index - 1] );
1113            }
11171114         }
1115         printf( "\n" );
11181116         scc68070_regs.dma.channel[0].memory_address_counter += scc68070_regs.dma.channel[0].transfer_counter * 2;
11191117         break;
11201118      }
r6020r6021
15451543   UINT16 vsr;
15461544   UINT16 ddr;
15471545   UINT16 dcp;
1546   UINT32 dca;
15481547   UINT32 clut[256];
15491548   UINT32 image_coding_method;
15501549   UINT32 transparency_control;
r6020r6021
16941693            verboselog(space->machine, 12, "mcd212_r: Status Register %d: %02x & %04x\n", channel + 1, mcd212.channel[1 - (offset / 8)].csrr, mem_mask);
16951694            if(channel == 0)
16961695            {
1697               return mcd212.channel[0].csrr | 0x20;
1696               return mcd212.channel[0].csrr;
16981697            }
16991698            else
17001699            {
17011700               UINT8 old_csr = mcd212.channel[1].csrr;
17021701               UINT8 interrupt1 = (scc68070_regs.lir >> 4) & 7;
1703               UINT8 interrupt2 = scc68070_regs.lir & 7;
1702               //UINT8 interrupt2 = scc68070_regs.lir & 7;
17041703               mcd212.channel[1].csrr &= ~(MCD212_CSR2R_IT1 | MCD212_CSR2R_IT2);
17051704               if(interrupt1)
17061705               {
17071706                  cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_1 + (interrupt1 - 1), CLEAR_LINE);
17081707               }
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               //}
17131712               return old_csr;
17141713            }
17151714         }
r6020r6021
17221721      case 0x12/2:
17231722         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);
17241723         return mcd212.channel[1 - (offset / 8)].dcr;
1725         break;
17261724      case 0x04/2:
17271725      case 0x14/2:
17281726         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);
17291727         return mcd212.channel[1 - (offset / 8)].vsr;
1730         break;
17311728      case 0x08/2:
17321729      case 0x18/2:
17331730         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);
17341731         return mcd212.channel[1 - (offset / 8)].ddr;
1735         break;
17361732      case 0x0a/2:
17371733      case 0x1a/2:
17381734         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);
17391735         return mcd212.channel[1 - (offset / 8)].dcp;
1740         break;
17411736      default:
17421737         verboselog(space->machine, 2, "mcd212_r: Unknown Register %d & %04x\n", (1 - (offset / 8)) + 1, mem_mask);
17431738         break;
r6020r6021
20122007         case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f:
20132008            verboselog(machine, 11, "%08x: %08x: ICA %d: INTERRUPT\n", addr * 2 + channel * 0x200000, cmd, channel );
20142009            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))
20162011            {
20172012               UINT8 interrupt = (scc68070_regs.lir >> 4) & 7;
20182013               if(interrupt)
r6020r6021
20212016                  cputag_set_input_line(machine, "maincpu", M68K_IRQ_1 + (interrupt - 1), ASSERT_LINE);
20222017               }
20232018            }
2019            /*
20242020            if(mcd212.channel[1].csrr & MCD212_CSR2R_IT2)
20252021            {
20262022               UINT8 interrupt = scc68070_regs.lir & 7;
r6020r6021
20302026                  cputag_set_input_line(machine, "maincpu", M68K_IRQ_1 + (interrupt - 1), ASSERT_LINE);
20312027               }
20322028            }
2029            */
20332030            break;
20342031         case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: // RELOAD DISPLAY PARAMETERS
20352032            verboselog(machine, 11, "%08x: %08x: ICA %d: RELOAD DISPLAY PARAMETERS\n", addr * 2 + channel * 0x200000, cmd, channel );
r6020r6021
20492046static void mcd212_process_dca(running_machine *machine, int channel)
20502047{
20512048   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;
20532050   UINT32 cmd = 0;
20542051   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 );
20562055   while(1)
20572056   {
20582057      UINT8 stop = 0;
r6020r6021
20682067            break;
20692068         case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: // NOP
20702069         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 );
20722071            break;
20732072         case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: // RELOAD DCP
20742073         case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
r6020r6021
20782077         case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f:
20792078            verboselog(machine, 11, "%08x: %08x: DCA %d: RELOAD DCP and STOP\n", addr * 2 + channel * 0x200000, cmd, channel );
20802079            mcd212_set_dcp(channel, cmd & 0x001fffff);
2080            addr = (cmd & 0x0007ffff) / 2;
2081            addr_changed = 1;
20812082            stop = 1;
20822083            break;
20832084         case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: // RELOAD VSR
r6020r6021
20952096         case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f:
20962097            verboselog(machine, 11, "%08x: %08x: DCA %d: INTERRUPT\n", addr * 2 + channel * 0x200000, cmd, channel );
20972098            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))
20992100            {
21002101               UINT8 interrupt = (scc68070_regs.lir >> 4) & 7;
21012102               if(interrupt)
21022103               {
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);
21042105                  cputag_set_input_line(machine, "maincpu", M68K_IRQ_1 + (interrupt - 1), ASSERT_LINE);
21052106               }
21062107            }
2108            /*
21072109            if(mcd212.channel[1].csrr & MCD212_CSR2R_IT2)
21082110            {
21092111               UINT8 interrupt = scc68070_regs.lir & 7;
r6020r6021
21132115                  cputag_set_input_line(machine, "maincpu", M68K_IRQ_1 + (interrupt - 1), ASSERT_LINE);
21142116               }
21152117            }
2118            */
21162119            break;
21172120         case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: // RELOAD DISPLAY PARAMETERS
21182121            verboselog(machine, 11, "%08x: %08x: DCA %d: RELOAD DISPLAY PARAMETERS\n", addr * 2 + channel * 0x200000, cmd, channel );
r6020r6021
21272130         break;
21282131      }
21292132   }
2133   mcd212.channel[channel].dca = addr * 2;
21302134}
21312135
21322136static UINT8 mcd212_dyuv_quantizer[16] = { 0, 1, 4, 9, 16, 27, 44, 79, 128, 177, 212, 229, 240, 247, 252, 255 };
r6020r6021
21642168         pixels[x++] = 0x00070707;
21652169         pixels[x] = 0x00070707;
21662170      }
2167      done = 1;
2171      return;
21682172   }
21692173
21702174   while(!done)
r6020r6021
21842188            else
21852189            {
21862190               // 8-bit Bitmap
2187               UINT32 mask = channel ? 0x00000f00 : 0x0000000f;
2188               UINT32 shift = channel ? 8 : 0;
21892191               if(icm == 5)
21902192               {
21912193                  UINT8 y;
r6020r6021
22402242                  }
22412243                  mcd212_set_vsr(channel, vsr - 1);
22422244               }
2243               else if(((mcd212.channel[0].image_coding_method & mask) >> shift) == 0x3)
2245               else if(icm == 3)
22442246               {
22452247                  for(; x < 768; x++)
22462248                  {
r6020r6021
24802482      {
24812483         // Process ICA
24822484         int index = 0;
2485         verboselog(machine, 0, "FRAME START\n" );
24832486         mcd212.channel[0].csrr &= 0x7f;
24842487         for(index = 0; index < 2; index++)
24852488         {
r6020r6021
25052508         {
25062509            if(mcd212.channel[index].dcr & MCD212_DCR_DCA)
25072510            {
2511               if(scanline == 22)
2512               {
2513                  mcd212.channel[index].dca = mcd212_get_dcp(index);
2514               }
25082515               mcd212_process_dca(machine, index);
25092516            }
25102517         }
2518         if(scanline == 261)
2519         {
2520            mcd212.channel[0].csrr ^= 0x20;
2521         }
25112522      }
25122523   }
25132524   timer_adjust_oneshot(mcd212.scan_timer, video_screen_get_time_until_pos(machine->primary_screen, ( scanline + 1 ) % 262, 0), 0);
r6020r6021
26232634   device_reset(cputag_get_cpu(machine, "maincpu"));
26242635
26252636   cdic_regs.z_buffer = 0;
2637   cdic_regs.channel = 0xffffffff;
26262638}
26272639
26282640/*************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team