Previous 15994 Revisions Next

r6148 Tuesday 20th October, 2009 at 17:20:16 UTC by Harmony
--
[src/mess/drivers]cdi.c

src/mess/drivers/cdi.c
r6147r6148
4545
4646#define ENABLE_UART_PRINTING (0)
4747
48#define VERBOSE_LEVEL   (6)
48#define VERBOSE_LEVEL   (5)
4949
5050#define ENABLE_VERBOSE_LOG (0)
5151
r6147r6148
13531353      cdic_regs.audio_buffer |= 0x8000;
13541354   }
13551355
1356   // Set the CDIC interrupt line
1357   verboselog(machine, 0, "Setting CDIC interrupt line for soundmap decode\n" );
1358   cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128);
1359   cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
1360
13561361   if(CDIC_IS_VALID_SAMPLE_BUF(cdic_regs.z_buffer & 0x3ffe))
13571362   {
13581363      attotime period;
13591364
13601365      verboselog(machine, 0, "Hit audio_sample_trigger, with cdic_regs.z_buffer == %04x, calling cdic_decode_audio_sector\n", cdic_regs.z_buffer );
13611366
1362      // Set the CDIC interrupt line
1363      verboselog(machine, 0, "Setting CDIC interrupt line for soundmap decode\n" );
1364      cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128);
1365      cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
1366
13671367      // Decode the data at Z+4, the same offset as a normal CD sector.
13681368      cdic_decode_audio_sector(machine, ((UINT8*)cdram) + (cdic_regs.z_buffer & 0x3ffe) + 4, 1);
13691369
r6147r6148
13851385   }
13861386   else
13871387   {
1388      // Swap buffer positions to indicate our new buffer position at the next read
13891388      cdic_regs.z_buffer &= 0xfffe;
1390      cdic_regs.z_buffer += 0xa00;
1391      if(cdic_regs.z_buffer == 0x3c00)
1392      {
1393         cdic_regs.z_buffer = 0x2800;
1394      }
1395
1396      cdic_regs.z_buffer &= 0xfffe;
13971389      verboselog(machine, 0, "Data is not valid, stopping playback\n" );
13981390      timer_adjust_oneshot(cdic_regs.audio_sample_timer, attotime_never, 0);
13991391   }
r6147r6148
16581650            //printf("Clearing CDIC interrupt line\n" );
16591651         }
16601652         cdic_regs.data_buffer &= ~0x4000;
1661         if(cdic_regs.data_buffer & 0x8000)
1662         {
1663            if(cdic_regs.command == 0x2c)
1664            {
1665               cdic_regs.data_buffer &= ~0x8000;
1666            }
1667         }
16681653         return temp;
16691654      }
16701655      default:
r6147r6148
17941779                  break;
17951780               case 0x2c: // Seek
17961781                  cdic_regs.data_buffer &= 0x7fff;
1782                  //cdic_regs.x_buffer |= 0x8000;
17971783                  break;
17981784               default:
17991785                  verboselog(space->machine, 0, "Unknown CDIC command: %02x\n", cdic_regs.command );
r6147r6148
23672353#define MCD212_DDR_FT_BMP2         0x0100   // Bitmap (alt.)
23682354#define MCD212_DDR_FT_RLE         0x0200   // Run-Length Encoded
23692355#define MCD212_DDR_FT_MOSAIC      0x0300   // Mosaic
2370#define MCD212_DDR_MT            0x0c00   // Mosaic File Type
2371#define MCD212_DDR_MT_2            0x0000   // 2x1
2372#define MCD212_DDR_MT_4            0x0400   // 4x1
2373#define MCD212_DDR_MT_8            0x0800   // 8x1
2374#define MCD212_DDR_MT_16         0x0c00   // 16x1
2375#define MCD212_DDR_MT_SHIFT         10
23762356
23772357static const UINT16 cdi220_lcd_char[20*22] =
23782358{
r6147r6148
29772957{
29782958   int x = 0;
29792959
2980   static int latched_rf0 = 0;
2981   static int latched_rf1 = 0;
2982   static int latched_wfa = 0;
2983   static int latched_wfb = 0;
2984   latched_wfa = mcd212.channel[0].weight_factor_a[0];
2985   latched_wfb = mcd212.channel[1].weight_factor_b[0];
2960   int latched_rf0 = 0;
2961   int latched_rf1 = 0;
2962   int latched_wfa = mcd212.channel[0].weight_factor_a[0];
2963   int latched_wfb = mcd212.channel[1].weight_factor_b[0];
2964   int reg = 0;
29862965   for(x = 0; x < 768; x++)
29872966   {
29882967      if(mcd212.channel[0].image_coding_method & MCD212_ICM_NR)
r6147r6148
30923071      }
30933072      else
30943073      {
3095         int reg = 0;
3096         for(reg = 0; reg < 8; reg++)
3074         if(reg < 8)
30973075         {
30983076            int flag = (mcd212.channel[0].region_control[reg] & MCD212_RC_RF) >> MCD212_RC_RF_SHIFT;
3099            if(mcd212.channel[0].region_control[reg] == 0)
3077            if(!(mcd212.channel[0].region_control[reg] & MCD212_RC_OP))
31003078            {
3079               for(; x < 768; x++)
3080               {
3081                  mcd212.channel[0].weight_factor_a[x] = latched_wfa;
3082                  mcd212.channel[1].weight_factor_b[x] = latched_wfb;
3083                  mcd212.region_flag_0[x] = latched_rf0;
3084                  mcd212.region_flag_1[x] = latched_rf1;
3085               }
31013086               break;
31023087            }
31033088            if(x == (mcd212.channel[0].region_control[reg] & MCD212_RC_X))
r6147r6148
31883173                     }
31893174                     break;
31903175               }
3191               break;
3176               reg++;
31923177            }
31933178         }
31943179      }
r6147r6148
32113196   UINT8 *clut_r = mcd212.channel[0].clut_r;
32123197   UINT8 *clut_g = mcd212.channel[0].clut_g;
32133198   UINT8 *clut_b = mcd212.channel[0].clut_b;
3214   UINT8 mosaic_enable = ((mcd212.channel[channel].ddr & MCD212_DDR_FT) == MCD212_DDR_FT_MOSAIC);
3215   UINT8 mosaic_factor = 1 << (((mcd212.channel[channel].ddr & MCD212_DDR_MT) >> MCD212_DDR_MT_SHIFT) + 1);
3216   int mosaic_index = 0;
32173199
32183200   //printf( "vsr before: %08x: ", vsr );
32193201   //fflush(stdout);
r6147r6148
32343216      {
32353217         case MCD212_DDR_FT_BMP:
32363218         case MCD212_DDR_FT_BMP2:
3237         case MCD212_DDR_FT_MOSAIC:
32383219            if(mcd212.channel[channel].dcr & MCD212_DCR_CM)
32393220            {
32403221               // 4-bit Bitmap
r6147r6148
32643245                        bY = bU = bV = 0x80;
32653246                        break;
32663247                  }
3267                  for(; x < 768; x += 2)
3248                  for(; x < 768; x += 4)
32683249                  {
32693250                        BYTE68K b0 = byte;
32703251                        BYTE68K bU1 = bU + mcd212_abDeltaUV[b0];
r6147r6148
32913272                        pixels_g[x + 0] = pixels_g[x + 1] = pbLimit[mcd212_abMatrixUG[bU] + mcd212_abMatrixVG[bV]];
32923273                        pixels_b[x + 0] = pixels_b[x + 1] = pbLimit[mcd212_abMatrixUB[bU]];
32933274
3294                     if(mosaic_enable)
3295                     {
3296                        for(mosaic_index = 0; mosaic_index < mosaic_factor; mosaic_index++)
3297                        {
3298                           pixels_r[x + 0 + mosaic_index*2] = pixels_r[x + 0];
3299                           pixels_g[x + 0 + mosaic_index*2] = pixels_g[x + 0];
3300                           pixels_b[x + 0 + mosaic_index*2] = pixels_b[x + 0];
3301                           pixels_r[x + 1 + mosaic_index*2] = pixels_r[x + 1];
3302                           pixels_g[x + 1 + mosaic_index*2] = pixels_g[x + 1];
3303                           pixels_b[x + 1 + mosaic_index*2] = pixels_b[x + 1];
3304                        }
3305                        x += mosaic_factor * 2;
3306                     }
3307                     else
3308                     {
3309                        x += 2;
3310                     }
3311
33123275                        bY = bY1;
33133276                        bU = bU1;
33143277                        bV = bV1;
33153278
33163279                        pbLimit = mcd212_abLimit + bY + BYTE68K_MAX;
33173280
3318                        pixels_r[x + 0] = pixels_r[x + 1] = pbLimit[mcd212_abMatrixVR[bV]];
3319                        pixels_g[x + 0] = pixels_g[x + 1] = pbLimit[mcd212_abMatrixUG[bU] + mcd212_abMatrixVG[bV]];
3320                        pixels_b[x + 0] = pixels_b[x + 1] = pbLimit[mcd212_abMatrixUB[bU]];
3281                        pixels_r[x + 2] = pixels_r[x + 3] = pbLimit[mcd212_abMatrixVR[bV]];
3282                        pixels_g[x + 2] = pixels_g[x + 3] = pbLimit[mcd212_abMatrixUG[bU] + mcd212_abMatrixVG[bV]];
3283                        pixels_b[x + 2] = pixels_b[x + 3] = pbLimit[mcd212_abMatrixUB[bU]];
33213284
3322                     if(mosaic_enable)
3323                     {
3324                        for(mosaic_index = 0; mosaic_index < mosaic_factor; mosaic_index++)
3325                        {
3326                           pixels_r[x + 0 + mosaic_index*2] = pixels_r[x + 0];
3327                           pixels_g[x + 0 + mosaic_index*2] = pixels_g[x + 0];
3328                           pixels_b[x + 0 + mosaic_index*2] = pixels_b[x + 0];
3329                           pixels_r[x + 1 + mosaic_index*2] = pixels_r[x + 1];
3330                           pixels_g[x + 1 + mosaic_index*2] = pixels_g[x + 1];
3331                           pixels_b[x + 1 + mosaic_index*2] = pixels_b[x + 1];
3332                        }
3333                        x += (mosaic_factor * 2) - 2;
3334                     }
3335
33363285                        byte = data[(vsr & 0x0007ffff) ^ 1];
33373286
33383287                     vsr++;
r6147r6148
33503299                     pixels_r[x + 1] = clut_r[clut_entry];
33513300                     pixels_g[x + 1] = clut_g[clut_entry];
33523301                     pixels_b[x + 1] = clut_b[clut_entry];
3353                     if(mosaic_enable)
3354                     {
3355                        for(mosaic_index = 0; mosaic_index < mosaic_factor; mosaic_index++)
3356                        {
3357                           pixels_r[x + 0 + mosaic_index*2] = pixels_r[x + 0];
3358                           pixels_g[x + 0 + mosaic_index*2] = pixels_g[x + 0];
3359                           pixels_b[x + 0 + mosaic_index*2] = pixels_b[x + 0];
3360                           pixels_r[x + 1 + mosaic_index*2] = pixels_r[x + 1];
3361                           pixels_g[x + 1 + mosaic_index*2] = pixels_g[x + 1];
3362                           pixels_b[x + 1 + mosaic_index*2] = pixels_b[x + 1];
3363                        }
3364                        x += (mosaic_factor * 2) - 2;
3365                     }
33663302                     byte = data[(vsr & 0x0007ffff) ^ 1];
33673303                     vsr++;
33683304                  }
r6147r6148
33743310                  {
33753311                     UINT8 even_entry = BYTE_TO_CLUT(channel, icm, byte >> 4);
33763312                     UINT8 odd_entry = BYTE_TO_CLUT(channel, icm, byte);
3377                     if(mosaic_enable)
3378                     {
3379                        for(mosaic_index = 0; mosaic_index < mosaic_factor; mosaic_index++)
3380                        {
3381                           pixels_r[x + mosaic_index] = clut_r[even_entry];
3382                           pixels_g[x + mosaic_index] = clut_g[even_entry];
3383                           pixels_b[x + mosaic_index] = clut_b[even_entry];
3384                        }
3385                        for(mosaic_index = 0; mosaic_index < mosaic_factor; mosaic_index++)
3386                        {
3387                           pixels_r[x + mosaic_factor + mosaic_index] = clut_r[odd_entry];
3388                           pixels_g[x + mosaic_factor + mosaic_index] = clut_g[odd_entry];
3389                           pixels_b[x + mosaic_factor + mosaic_index] = clut_b[odd_entry];
3390                        }
3391                        x += (mosaic_factor * 2) - 2;
3392                     }
3393                     else
3394                     {
3395                        pixels_r[x + 0] = clut_r[even_entry];
3396                        pixels_g[x + 0] = clut_g[even_entry];
3397                        pixels_b[x + 0] = clut_b[even_entry];
3398                        pixels_r[x + 1] = clut_r[odd_entry];
3399                        pixels_g[x + 1] = clut_g[odd_entry];
3400                        pixels_b[x + 1] = clut_b[odd_entry];
3401                     }
3313                     pixels_r[x + 0] = clut_r[even_entry];
3314                     pixels_g[x + 0] = clut_g[even_entry];
3315                     pixels_b[x + 0] = clut_b[even_entry];
3316                     pixels_r[x + 1] = clut_r[odd_entry];
3317                     pixels_g[x + 1] = clut_g[odd_entry];
3318                     pixels_b[x + 1] = clut_b[odd_entry];
34023319                     byte = data[(vsr & 0x0007ffff) ^ 1];
34033320                     vsr++;
34043321                  }
r6147r6148
34923409               }
34933410            }
34943411            break;
3495            /*
3412         case MCD212_DDR_FT_MOSAIC:
34963413            verboselog(machine, 0, "Unsupported display mode: Mosaic\n" );
3497            memset(pixels_r, 0x10, 768);
3498            memset(pixels_g, 0x10, 768);
3499            memset(pixels_b, 0x10, 768);
35003414            done = 1;
35013415            break;
3502            */
35033416      }
35043417   }
35053418
r6147r6148
35703483   UINT8 transparent_color_b_r = (UINT8)(mcd212.channel[1].transparent_color_b >> 16);
35713484   UINT8 transparent_color_b_g = (UINT8)(mcd212.channel[1].transparent_color_b >>  8);
35723485   UINT8 transparent_color_b_b = (UINT8)(mcd212.channel[1].transparent_color_b >>  0);
3573   UINT8 dyuv_enable_a = (mcd212.channel[0].image_coding_method & 0x0000000f) == 5;
3574   UINT8 dyuv_enable_b = ((mcd212.channel[0].image_coding_method >> 8) & 0x0000000f) == 5;
3486   UINT8 image_coding_method_a = mcd212.channel[0].image_coding_method & 0x0000000f;
3487   UINT8 image_coding_method_b = (mcd212.channel[0].image_coding_method >> 8) & 0x0000000f;
3488   UINT8 dyuv_enable_a = (image_coding_method_a == 5);
3489   UINT8 dyuv_enable_b = (image_coding_method_b == 5);
35753490   UINT8 mosaic_enable_a = (mcd212.channel[0].mosaic_hold_a & 0x800000) >> 23;
35763491   UINT8 mosaic_enable_b = (mcd212.channel[1].mosaic_hold_b & 0x800000) >> 23;
35773492   UINT8 mosaic_count_a = (mcd212.channel[0].mosaic_hold_a & 0x0000ff) << 1;
r6147r6148
36023517               plane_enable_a = 0;
36033518               break;
36043519            case 1:
3605               plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b) || dyuv_enable_a;
3520               plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b);
36063521               break;
36073522            case 3:
3608               plane_enable_a = mcd212.region_flag_0[x];
3523               plane_enable_a = !mcd212.region_flag_0[x];
36093524               break;
36103525            case 4:
3611               plane_enable_a = mcd212.region_flag_1[x];
3526               plane_enable_a = !mcd212.region_flag_1[x];
36123527               break;
36133528            case 5:
3614               plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b || dyuv_enable_a || mcd212.region_flag_0[x] == 1);
3529               plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b) && (dyuv_enable_a || mcd212.region_flag_0[x] == 0);
36153530               break;
36163531            case 6:
3617               plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b || dyuv_enable_a || mcd212.region_flag_1[x] == 1);
3532               plane_enable_a = (plane_a_r_cur != transparent_color_a_r || plane_a_g_cur != transparent_color_a_g || plane_a_b_cur != transparent_color_a_b) && (dyuv_enable_a || mcd212.region_flag_1[x] == 0);
36183533               break;
36193534            case 8:
36203535               plane_enable_a = 1;
36213536               break;
36223537            case 9:
3623               plane_enable_a = (plane_a_r_cur == transparent_color_a_r && plane_a_g_cur == transparent_color_a_g && plane_a_b_cur == transparent_color_a_b) || dyuv_enable_a;
3538               plane_enable_a = (plane_a_r_cur == transparent_color_a_r && plane_a_g_cur == transparent_color_a_g && plane_a_b_cur == transparent_color_a_b);
36243539               break;
36253540            case 11:
3626               plane_enable_a = !mcd212.region_flag_0[x];
3541               plane_enable_a = mcd212.region_flag_0[x];
36273542               break;
36283543            case 12:
3629               plane_enable_a = !mcd212.region_flag_1[x];
3544               plane_enable_a = mcd212.region_flag_1[x];
36303545               break;
36313546            case 13:
3632               plane_enable_a = (plane_a_r_cur == transparent_color_a_r && plane_a_g_cur == transparent_color_a_g && plane_a_b_cur == transparent_color_a_b) || dyuv_enable_a || mcd212.region_flag_0[x] == 0;
3547               plane_enable_a = (plane_a_r_cur == transparent_color_a_r && plane_a_g_cur == transparent_color_a_g && plane_a_b_cur == transparent_color_a_b) || dyuv_enable_a || mcd212.region_flag_0[x] == 1;
36333548               break;
36343549            case 14:
3635               plane_enable_a = (plane_a_r_cur == transparent_color_a_r && plane_a_g_cur == transparent_color_a_g && plane_a_b_cur == transparent_color_a_b) || dyuv_enable_a || mcd212.region_flag_1[x] == 0;
3550               plane_enable_a = (plane_a_r_cur == transparent_color_a_r && plane_a_g_cur == transparent_color_a_g && plane_a_b_cur == transparent_color_a_b) || dyuv_enable_a || mcd212.region_flag_1[x] == 1;
36363551               break;
36373552            default:
36383553               verboselog(machine, 0, "Unhandled transparency mode for plane A: %d\n", transparency_mode_a);
r6147r6148
36453560               plane_enable_b = 0;
36463561               break;
36473562            case 1:
3648               plane_enable_b = (plane_b_r_cur != transparent_color_b_r || plane_b_g_cur != transparent_color_b_g || plane_b_b_cur != transparent_color_b_b) || dyuv_enable_b;
3563               plane_enable_b = (plane_b_r_cur != transparent_color_b_r || plane_b_g_cur != transparent_color_b_g || plane_b_b_cur != transparent_color_b_b);
36493564               break;
36503565            case 3:
3651               plane_enable_b = mcd212.region_flag_0[x];
3566               plane_enable_b = !mcd212.region_flag_0[x];
36523567               break;
36533568            case 4:
3654               plane_enable_b = mcd212.region_flag_1[x];
3569               plane_enable_b = !mcd212.region_flag_1[x];
36553570               break;
36563571            case 5:
3657               plane_enable_b = (plane_b_r_cur != transparent_color_b_r || plane_b_g_cur != transparent_color_b_g || plane_b_b_cur != transparent_color_b_b || dyuv_enable_b || mcd212.region_flag_0[x] == 1);
3572               plane_enable_b = (plane_b_r_cur != transparent_color_b_r || plane_b_g_cur != transparent_color_b_g || plane_b_b_cur != transparent_color_b_b) && (dyuv_enable_b || mcd212.region_flag_0[x] == 0);
36583573               break;
36593574            case 6:
3660               plane_enable_b = (plane_b_r_cur != transparent_color_b_r || plane_b_g_cur != transparent_color_b_g || plane_b_b_cur != transparent_color_b_b || dyuv_enable_b || mcd212.region_flag_1[x] == 1);
3575               plane_enable_b = (plane_b_r_cur != transparent_color_b_r || plane_b_g_cur != transparent_color_b_g || plane_b_b_cur != transparent_color_b_b) && (dyuv_enable_b || mcd212.region_flag_1[x] == 0);
36613576               break;
36623577            case 8:
36633578               plane_enable_b = 1;
36643579               break;
36653580            case 9:
3666               plane_enable_b = (plane_b_r_cur == transparent_color_b_r && plane_b_g_cur == transparent_color_b_g && plane_b_b_cur == transparent_color_b_b) || dyuv_enable_b;
3581               plane_enable_b = (plane_b_r_cur == transparent_color_b_r && plane_b_g_cur == transparent_color_b_g && plane_b_b_cur == transparent_color_b_b);
36673582               break;
36683583            case 11:
3669               plane_enable_b = !mcd212.region_flag_0[x];
3584               plane_enable_b = mcd212.region_flag_0[x];
36703585               break;
36713586            case 12:
3672               plane_enable_b = !mcd212.region_flag_1[x];
3587               plane_enable_b = mcd212.region_flag_1[x];
36733588               break;
36743589            case 13:
3675               plane_enable_b = (plane_b_r_cur == transparent_color_b_r && plane_b_g_cur == transparent_color_b_g && plane_b_b_cur == transparent_color_b_b) || dyuv_enable_b || mcd212.region_flag_0[x] == 0;
3590               plane_enable_b = (plane_b_r_cur == transparent_color_b_r && plane_b_g_cur == transparent_color_b_g && plane_b_b_cur == transparent_color_b_b) || dyuv_enable_b || mcd212.region_flag_0[x] == 1;
36763591               break;
36773592            case 14:
3678               plane_enable_b = (plane_b_r_cur == transparent_color_b_r && plane_b_g_cur == transparent_color_b_g && plane_b_b_cur == transparent_color_b_b) || dyuv_enable_b || mcd212.region_flag_1[x] == 0;
3593               plane_enable_b = (plane_b_r_cur == transparent_color_b_r && plane_b_g_cur == transparent_color_b_g && plane_b_b_cur == transparent_color_b_b) || dyuv_enable_b || mcd212.region_flag_1[x] == 1;
36793594               break;
36803595            default:
36813596               verboselog(machine, 0, "Unhandled transparency mode for plane B: %d\n", transparency_mode_b);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team