Previous 15994 Revisions Next

r6056 Monday 12th October, 2009 at 23:04:38 UTC by Harmony
CD-i: Corrected CLUT behavior to be more in line with real hardware. [CD-i Fan, Harmony]
[src/mess/drivers]cdi.c

src/mess/drivers/cdi.c
r6055r6056
944944         cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_RAW_DONTCARE);
945945         for(index = 6; index < 2352/2; index++)
946946         {
947            if(cdic_regs.time == 0x00332300 || cdic_regs.time == 0x00332400)
948            {
949               //printf( "%02x %02x ", buffer[index*2], buffer[index*2 + 1] );
950            }
951947            cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1];
952948         }
953         //printf( "\n" );
954949
955950         cdic_regs.time += 0x100;
956951         if((cdic_regs.time & 0x00000f00) == 0xa00)
r6055r6056
11751170   UINT8 xbus_interrupt_enable;
11761171
11771172   UINT8 lcd_state[16];
1173
1174   UINT16 real_mouse_x;
1175   UINT16 real_mouse_y;
1176
1177   UINT16 fake_mouse_x;
1178   UINT16 fake_mouse_y;
11781179} slave_regs_t;
11791180
11801181static slave_regs_t slave_regs;
r6055r6056
12061207   UINT16 y = input_port_read(machine, "MOUSEY");
12071208   UINT8 buttons = input_port_read(machine, "MOUSEBTN");
12081209
1210   UINT16 old_mouse_x = slave_regs.real_mouse_x;
1211   UINT16 old_mouse_y = slave_regs.real_mouse_y;
1212
1213   slave_regs.real_mouse_x = x & 0x3ff;
1214   slave_regs.real_mouse_y = y & 0x3ff;
1215
1216   if(slave_regs.real_mouse_x == 0xffff)
1217   {
1218      slave_regs.fake_mouse_x = slave_regs.real_mouse_x;
1219      slave_regs.fake_mouse_y = slave_regs.real_mouse_y;
1220   }
1221   else
1222   {
1223      old_mouse_x = 0xffff;
1224      old_mouse_y = 0xffff;
1225      slave_regs.fake_mouse_x = x & 0x3ff;
1226      slave_regs.fake_mouse_y = y & 0x3ff;
1227   }
1228
1229   slave_regs.fake_mouse_x += (slave_regs.real_mouse_x - old_mouse_x);
1230   slave_regs.fake_mouse_y += (slave_regs.real_mouse_y - old_mouse_y);
1231
1232   x = slave_regs.fake_mouse_x;
1233   y = slave_regs.fake_mouse_y;
1234
12091235   if(slave_regs.polling_active)
12101236   {
12111237      slave_prepare_readback(machine, ATTOTIME_IN_HZ(10000), 0, 4, ((x & 0x380) >> 7) | (buttons << 4), x & 0x7f, (y & 0x380) >> 7, y & 0x7f, 0xf7);
r6055r6056
12511277   return 0xff;
12521278}
12531279
1280static void set_mouse_position(running_machine* machine)
1281{
1282   UINT16 x, y;
1283
1284   printf( "old fake mouse x: %04x\n", slave_regs.fake_mouse_x );
1285   printf( "old fake mouse y: %04x\n", slave_regs.fake_mouse_y );
1286
1287   slave_regs.fake_mouse_y = (slave_regs.fake_mouse_y & 0xff80) | (slave_regs.in_buf[1] & 0x7f);
1288   slave_regs.fake_mouse_x = (slave_regs.fake_mouse_x & 0xff80) | (slave_regs.in_buf[2] & 0x7f);
1289
1290   x = slave_regs.fake_mouse_x;
1291   y = slave_regs.fake_mouse_y;
1292
1293   printf( "new fake mouse x: %04x\n", slave_regs.fake_mouse_x );
1294   printf( "new fake mouse y: %04x\n", slave_regs.fake_mouse_y );
1295
1296   if(slave_regs.polling_active)
1297   {
1298      slave_prepare_readback(machine, ATTOTIME_IN_HZ(10000), 0, 4, (x & 0x380) >> 7, x & 0x7f, (y & 0x380) >> 7, y & 0x7f, 0xf7);
1299   }
1300}
1301
12541302static WRITE16_HANDLER( slave_w )
12551303{
12561304   switch(offset)
r6055r6056
12731321                  case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee: case 0xef:
12741322                  case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7:
12751323                  case 0xf8: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xfd: case 0xfe: case 0xff:   // Update Mouse Position
1276                     //perform_mouse_update(space->machine);
1324                     set_mouse_position(space->machine);
12771325                     memset(slave_regs.in_buf, 0, 17);
12781326                     slave_regs.in_index = 0;
12791327                     slave_regs.in_count = 0;
r6055r6056
17891837      case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
17901838      case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf:
17911839         verboselog(machine, 11, "          %04xxxxx: %d: CLUT[%d] = %08x\n", channel * 0x20, channel, mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80), value );
1792         mcd212.channel[channel].clut[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = value;
1840         mcd212.channel[0].clut[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = value;
17931841         break;
17941842      case 0xc0: // Image Coding Method
17951843         if(channel == 0)
r6055r6056
18141862         break;
18151863      case 0xc3: // CLUT Bank Register
18161864         verboselog(machine, 11, "          %04xxxxx: %d: CLUT Bank Register = %08x\n", channel * 0x20, channel, value & 3);
1817         mcd212.channel[channel].clut_bank = value & 0x00000003;
1865         mcd212.channel[channel].clut_bank = channel ? (2 | (value & 0x00000001)) : (value & 0x00000003);
18181866         break;
18191867      case 0xc4: // Transparent Color A
18201868         if(channel == 0)
r6055r6056
18871935      case 0xd5:
18881936      case 0xd6:
18891937      case 0xd7:
1890         verboselog(machine, 11, "          %04xxxxx: %d: Region Control %d = %08x\n", channel * 0x20, channel, reg & 7, value );
1938         verboselog(machine, 6, "          %04xxxxx: %d: Region Control %d = %08x\n", channel * 0x20, channel, reg & 7, value );
18911939         mcd212.channel[channel].region_control[reg & 7] = value;
18921940         break;
18931941      case 0xd8: // Backdrop Color
r6055r6056
20492097   UINT32 addr = (mcd212.channel[channel].dca & 0x0007ffff) / 2; //(mcd212_get_dcp(channel) & 0x0007ffff) / 2; // mcd212.channel[channel].dca / 2;
20502098   UINT32 cmd = 0;
20512099   UINT32 count = 0;
2052   UINT32 max = 64; //(mcd212.channel[channel].dcr & MCD212_DCR_CM) ? 64 : 32;
2100   UINT32 max = 64;
20532101   UINT8 addr_changed = 0;
20542102   //printf( "max = %d\n", max );
20552103   while(1)
r6055r6056
21302178         break;
21312179      }
21322180   }
2181   if(!addr_changed)
2182   {
2183      if(count < max)
2184      {
2185         addr += (max - count) >> 1;
2186      }
2187   }
21332188   mcd212.channel[channel].dca = addr * 2;
21342189}
21352190
r6055r6056
21792234    return (UINT8)in;
21802235}
21812236
2237INLINE UINT8 BYTE_TO_CLUT7(int channel, UINT8 byte)
2238{
2239   if(channel)
2240   {
2241      return 0x80 + (byte & 0x7f);
2242   }
2243   else
2244   {
2245      return byte & 0x7f;
2246   }
2247}
2248
21822249static void mcd212_process_vsr(running_machine *machine, int channel, UINT32 *pixels)
21832250{
21842251   UINT8 *data = channel ? (UINT8*)planeb : (UINT8*)planea;
r6055r6056
21922259   //printf( "vsr before: %08x: ", vsr );
21932260   //fflush(stdout);
21942261
2195   if(!icm)
2262   if(!icm || !vsr)
21962263   {
21972264      for(; x < 768; x++)
21982265      {
r6055r6056
22882355               {
22892356                  for(; x < 768; x++)
22902357                  {
2291                     pixels[x++] = mcd212.channel[channel].clut[((channel == 1) ? 0x80 : 0x00) + (byte & 0x7f)];
2292                     pixels[x] = mcd212.channel[channel].clut[((channel == 1) ? 0x80 : 0x00) + (byte & 0x7f)];
2358                     pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte)];
2359                     pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte)];
22932360                     byte = data[vsr++ ^ 1];
22942361                  }
22952362                  mcd212_set_vsr(channel, vsr - 1);
r6055r6056
23262393                     // Go to the end of the line
23272394                     for(; x < 768; x++)
23282395                     {
2329                        pixels[x++] = mcd212.channel[channel].clut[byte & 0x7f];
2330                        pixels[x] = mcd212.channel[channel].clut[byte & 0x7f];
2396                        pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)];
2397                        pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)];
23312398                     }
23322399                     done = 1;
23332400                     mcd212_set_vsr(channel, vsr);
r6055r6056
23392406                     //fflush(stdout);
23402407                     for(; x < end && x < 768; x++)
23412408                     {
2342                        pixels[x++] = mcd212.channel[channel].clut[byte & 0x7f];
2343                        pixels[x] = mcd212.channel[channel].clut[byte & 0x7f];
2409                        pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)];
2410                        pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)];
23442411                     }
23452412                     if(x >= 768)
23462413                     {
r6055r6056
23522419               else
23532420               {
23542421                  // Single pixel
2355                  pixels[x++] = mcd212.channel[channel].clut[byte & 0x7f];
2356                  pixels[x++] = mcd212.channel[channel].clut[byte & 0x7f];
2422                  pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)];
2423                  pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte & 0x7f)];
23572424                  if(x >= 768)
23582425                  {
23592426                     done = 1;
r6055r6056
27282795
27292796   cdic_regs.z_buffer = 0;
27302797   cdic_regs.channel = 0xffffffff;
2798
2799   slave_regs.real_mouse_x = 0xffff;
2800   slave_regs.real_mouse_y = 0xffff;
27312801}
27322802
27332803/*************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team