Previous 15994 Revisions Next

r5967 Monday 5th October, 2009 at 02:08:54 UTC by Harmony
A number of CD-i CD handling fixes. Some games attempt (and succeed in showing the first frame of) the opening Philips CD-i animation. [CD-i Fan, Harmony]
[src/mess/drivers]cdi.c

src/mess/drivers/cdi.c
r5966r5967
66
77    Preliminary MAME driver by Roberto Fresca, David Haywood & Angelo Salese
88    MESS improvements by Harmony
9    Help provided by CD-i Fan
910
1011
1112*******************************************************************************
r5966r5967
804805      case 0x400c/2:
805806      case 0x404c/2:
806807         verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Memory Address Counter (High Word): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask);
807         scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter &= mem_mask << 16;
808         scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter &= ~(mem_mask << 16);
808809         scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter |= data << 16;
809810         break;
810811      case 0x400e/2:
811812      case 0x404e/2:
812813         verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Memory Address Counter (Low Word): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask);
813         scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter &= (0xffff0000) | mem_mask;
814         scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter &= ~mem_mask;
814815         scc68070_regs.dma.channel[(offset - 0x2000) / 32].memory_address_counter |= data;
815816         break;
816817      case 0x4014/2:
817818      case 0x4054/2:
818819         verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Device Address Counter (High Word): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask);
819         scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter &= mem_mask << 16;
820         scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter &= ~(mem_mask << 16);
820821         scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter |= data << 16;
821822         break;
822823      case 0x4016/2:
823824      case 0x4056/2:
824825         verboselog(space->machine, 2, "scc68070_periphs_w: DMA(%d) Device Address Counter (Low Word): %04x & %04x\n", (offset - 0x2000) / 32, data, mem_mask);
825         scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter &= (0xffff0000) | mem_mask;
826         scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter &= ~mem_mask;
826827         scc68070_regs.dma.channel[(offset - 0x2000) / 32].device_address_counter |= data;
827828         break;
828829
r5966r5967
927928   switch(cdic_regs.command)
928929   {
929930      case 0x29: // Read Mode 1
931      case 0x2a: // Read Mode 2
930932      {
931933         UINT8 buffer[2560] = { 0 };
932934         UINT32 msf = cdic_regs.time >> 8;
r5966r5967
948950            nybbles[3]--;
949951         }
950952         lba = nybbles[0] + nybbles[1]*10 + ((nybbles[2] + nybbles[3]*10)*75) + ((nybbles[4] + nybbles[5]*10)*75*60);
951         printf( "Reading Mode 1 sector from MSF location %06x\n", cdic_regs.time | 2 );
952         verboselog(machine, 0, "Reading Mode 1 sector from MSF location %06x\n", cdic_regs.time | 2 );
953         cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_MODE1);
953
954         printf( "Reading Mode %d sector from MSF location %06x\n", cdic_regs.command - 0x28, cdic_regs.time | 2 );
955         verboselog(machine, 0, "Reading Mode %d sector from MSF location %06x\n", cdic_regs.command - 0x28, cdic_regs.time | 2 );
956
954957         cdic_regs.data_buffer ^= 0x0001;
955         for(index = 0; index < 2048/2; index++)
958
959         cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_RAW_DONTCARE);
960         for(index = 6; index < 2352/2; index++)
956961         {
957            cdram[0xa00/2 + index] = (buffer[index*2 + 1] << 8) | buffer[index*2];
962            cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1];
958963         }
959964
960965         printf( "Setting CDIC interrupt line\n" );
961966         verboselog(machine, 0, "Setting CDIC interrupt line\n" );
962967         cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128);
963968         cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
964         timer_adjust_oneshot(cdic_regs.interrupt_timer, attotime_never, 0);
969
970         timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed
971
965972         cdic_regs.x_buffer |= 0x8000;
966         cdic_regs.data_buffer |= cdic_regs.buffer_target;
967         cdic_regs.buffer_target ^= 1;
968         break;
969      }
970      case 0x2a: // Read Mode 2
971      {
972         UINT8 buffer[2448] = { 0 };
973         UINT32 msf = cdic_regs.time >> 8;
974         UINT32 lba = 0;
975         int index = 0;
976         UINT8 nybbles[6] =
973
974         cdic_regs.data_buffer |= 0x4000;
975         cdic_regs.data_buffer &= 0x7fff;
976
977         cdic_regs.time += 0x100;
978         if((cdic_regs.time & 0x00000f00) == 0xa00)
977979         {
978             msf & 0x0000000f,
979            (msf & 0x000000f0) >> 4,
980            (msf & 0x00000f00) >> 8,
981            (msf & 0x0000f000) >> 12,
982            (msf & 0x000f0000) >> 16,
983            (msf & 0x00f00000) >> 20
984         };
985         nybbles[2] -= 2;
986         if(nybbles[2] > 9)
987         {
988            nybbles[2] += 10;
989            nybbles[3]--;
980            cdic_regs.time &= 0xfffff0ff;
981            cdic_regs.time += 0x00001000;
990982         }
991         lba = nybbles[0] + nybbles[1]*10 + ((nybbles[2] + nybbles[3]*10)*75) + ((nybbles[4] + nybbles[5]*10)*75*60);
992         printf( "Reading Mode 2 sector from MSF location %06x\n", cdic_regs.time | 2 );
993         verboselog(machine, 0, "Reading Mode 2 sector from MSF location %06x\n", cdic_regs.time | 2 );
994
995         cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_MODE2);
996         cdic_regs.data_buffer ^= 0x0001;
997         for(index = 0; index < 2352/2; index++)
983         if((cdic_regs.time & 0x0000ff00) == 0x7500)
998984         {
999            cdram[0xa00/2 + index] = (buffer[index*2 + 1] << 8) | buffer[index*2];
985            cdic_regs.time &= 0xffff00ff;
986            cdic_regs.time += 0x00010000;
987            if((cdic_regs.time & 0xf0000) == 0xa0000)
988            {
989               cdic_regs.time &= 0xfff0ffff;
990               cdic_regs.time += 0x100000;
991               if((cdic_regs.time & 0xf00000) == 0xf00000)
992               {
993                  cdic_regs.time &= 0xff0fffff;
994                  cdic_regs.time += 0x01000000;
995               }
996            }
1000997         }
1001
1002         printf( "Setting CDIC interrupt line\n" );
1003         verboselog(machine, 0, "Setting CDIC interrupt line\n" );
1004         cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128);
1005         cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
1006         timer_adjust_oneshot(cdic_regs.interrupt_timer, attotime_never, 0);
1007         cdic_regs.x_buffer |= 0x8000;
1008         cdic_regs.data_buffer |= cdic_regs.buffer_target;
1009         cdic_regs.buffer_target ^= 1;
1010998         break;
1011999      }
1012      case 0x2e:
1000      case 0x2e: // Abort
1001         timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed
1002         cdic_regs.data_buffer &= 0x7fff;
10131003         break;
10141004   }
10151005}
r5966r5967
10471037      case 0x3ffe/2:
10481038      {
10491039         UINT16 temp = cdic_regs.data_buffer;
1050         cdic_regs.data_buffer &= 0x7fff;
10511040         cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_4, CLEAR_LINE);
10521041         verboselog(space->machine, 0, "cdic_r: Data buffer Register = %04x & %04x\n", temp, mem_mask);
10531042         verboselog(space->machine, 0, "Clearing CDIC interrupt line\n" );
10541043         printf("Clearing CDIC interrupt line\n" );
1055         return temp | 1;
1044         return temp;
10561045      }
10571046      default:
10581047         verboselog(space->machine, 0, "cdic_r: UNIMPLEMENTED: Unknown address: %04x & %04x\n", offset*2, mem_mask);
r5966r5967
10701059         COMBINE_DATA(&cdic_regs.command);
10711060         break;
10721061      case 0x3c02/2: // Time register (MSW)
1073         cdic_regs.time &= 0x0000ffff;
1062         cdic_regs.time &= ~(mem_mask << 16);
10741063         cdic_regs.time |= (data & mem_mask) << 16;
10751064         verboselog(space->machine, 0, "cdic_w: Time Register (MSW) = %04x & %04x\n", data, mem_mask);
10761065         break;
10771066      case 0x3c04/2: // Time register (LSW)
1078         cdic_regs.time &= 0xffff0000;
1067         cdic_regs.time &= ~mem_mask;
10791068         cdic_regs.time |= data & mem_mask;
10801069         verboselog(space->machine, 0, "cdic_w: Time Register (LSW) = %04x & %04x\n", data, mem_mask);
10811070         break;
r5966r5967
10841073         COMBINE_DATA(&cdic_regs.file);
10851074         break;
10861075      case 0x3c08/2: // Channel register (MSW)
1087         cdic_regs.channel &= 0x0000ffff;
1076         cdic_regs.channel &= ~(mem_mask << 16);
10881077         cdic_regs.channel |= (data & mem_mask) << 16;
10891078         verboselog(space->machine, 0, "cdic_w: Channel Register (MSW) = %04x & %04x\n", data, mem_mask);
10901079         break;
10911080      case 0x3c0a/2: // Channel register (LSW)
1092         cdic_regs.channel &= 0xffff0000;
1081         cdic_regs.channel &= ~mem_mask;
10931082         cdic_regs.channel |= data & mem_mask;
10941083         verboselog(space->machine, 0, "cdic_w: Channel Register (LSW) = %04x & %04x\n", data, mem_mask);
10951084         break;
r5966r5967
11041093         UINT32 index = 0;
11051094         UINT32 src_index = (data & 0x7fff) >> 1;
11061095         UINT16 *memory = planea;
1096         verboselog(space->machine, 0, "memory address counter: %08x\n", scc68070_regs.dma.channel[0].memory_address_counter);
11071097         verboselog(space->machine, 0, "cdic_w: DMA Control Register = %04x & %04x\n", data, mem_mask);
11081098         verboselog(space->machine, 0, "Doing copy, transferring %04x bytes\n", count * 2 );
11091099         printf("Doing copy, transferring %04x bytes\n", count * 2 );
r5966r5967
11141104         }
11151105         for(index = start / 2; index < (start / 2 + count); index++)
11161106         {
1117            memory[index] = (cdram[src_index] >> 8) | (cdram[src_index] << 8);
1118            src_index++;
1107            memory[index] = cdram[src_index++];
11191108         }
11201109         scc68070_regs.dma.channel[0].memory_address_counter += scc68070_regs.dma.channel[0].transfer_counter * 2;
11211110         break;
r5966r5967
11321121      {
11331122         verboselog(space->machine, 0, "cdic_w: Data Buffer Register = %04x & %04x\n", data, mem_mask);
11341123         COMBINE_DATA(&cdic_regs.data_buffer);
1135         if((cdic_regs.data_buffer & 0xc000) == 0xc000)
1124         cdic_regs.data_buffer &= 0xbfff;
1125         if(cdic_regs.data_buffer & 0x8000)
11361126         {
1137            timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(60), 0);
1127            switch(cdic_regs.command)
1128            {
1129               case 0x23: // Reset Mode 1
1130               case 0x24: // Reset Mode 2
1131               case 0x2e: // Abort
1132                  timer_adjust_oneshot(cdic_regs.interrupt_timer, attotime_never, 0);
1133                  cdic_regs.data_buffer &= 0x3fff;
1134                  break;
1135               case 0x29: // Read Mode 1
1136               case 0x2a: // Read Mode 2
1137                  timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed
1138                  break;
1139            }
11381140         }
11391141         break;
11401142      }
r5966r5967
14651467
14661468static READ16_HANDLER( m48t08_r )
14671469{
1468   verboselog(space->machine, 11, "m48t08_r: %04x = %02x & %04x\n", offset, m48t08.nvram[offset], mem_mask );
1470   verboselog(space->machine, 6, "m48t08_r: %04x = %02x & %04x\n", offset, m48t08.nvram[offset], mem_mask );
14691471   return m48t08.nvram[offset] << 8;
14701472}
14711473
14721474static WRITE16_HANDLER( m48t08_w )
14731475{
1474   verboselog(space->machine, 11, "m48t08_w: %04x = %02x\n", offset, data >> 8);
1476   verboselog(space->machine, 6, "m48t08_w: %04x = %02x\n", offset, data >> 8);
14751477   switch(offset)
14761478   {
14771479      case 0x1ff9:
r5966r5967
25382540*      Memory maps       *
25392541*************************/
25402542
2543static WRITE16_HANDLER(cdic_ram_w)
2544{
2545   verboselog(space->machine, 0, "cdic_ram_w: %08x = %04x & %04x\n", 0x00300000 + offset*2, data, mem_mask);
2546   COMBINE_DATA(&cdram[offset]);
2547}
2548
25412549static READ16_HANDLER(cdic_ram_r)
25422550{
25432551   verboselog(space->machine, 0, "cdic_ram_r: %08x = %04x & %04x\n", 0x00300000 + offset*2, cdram[offset], mem_mask);
r5966r5967
25512559   AM_RANGE(0x00301400, 0x00301403) AM_READ(uart_loopback_enable)
25522560   //AM_RANGE(0x00301404, 0x00303bff) AM_RAM
25532561#else
2554   AM_RANGE(0x00300000, 0x00303bff) AM_READ(cdic_ram_r) AM_BASE(&cdram)
2562   AM_RANGE(0x00300000, 0x00303bff) AM_READWRITE(cdic_ram_r, cdic_ram_w) AM_BASE(&cdram)
25552563#endif
25562564   AM_RANGE(0x00303c00, 0x00303fff) AM_READWRITE(cdic_r, cdic_w)
25572565   AM_RANGE(0x00310000, 0x00317fff) AM_READWRITE(slave_r, slave_w)
r5966r5967
26432651   ROM_REGION(0x80000, "maincpu", 0)
26442652   ROM_SYSTEM_BIOS( 0, "mcdi200", "Magnavox CD-i 200" )
26452653   ROMX_LOAD( "cdi200.rom", 0x000000, 0x80000, CRC(40c4e6b9) SHA1(d961de803c89b3d1902d656ceb9ce7c02dccb40a), ROM_BIOS(1) )
2654   ROM_SYSTEM_BIOS( 1, "mcdi200", "Philips CD-i 220 F2" )
2655   ROMX_LOAD( "cdi220b.rom", 0x000000, 0x80000, CRC(279683ca) SHA1(53360a1f21ddac952e95306ced64186a3fc0b93e), ROM_BIOS(2) )
26462656   // This one is a Mono-IV board, needs to be a separate driver
26472657   //ROM_SYSTEM_BIOS( 1, "pcdi490", "Philips CD-i 490" )
26482658   //ROMX_LOAD( "cdi490.rom", 0x000000, 0x80000, CRC(e115f45b) SHA1(f71be031a5dfa837de225081b2ddc8dcb74a0552), ROM_BIOS(2) )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team