Previous 15994 Revisions Next

r6080 Wednesday 14th October, 2009 at 21:03:35 UTC by Harmony
[CDI] Significant optimization:
- Removed redudant call to mcd212_process_regions
- Refactored mcd212_process_regions to fill scanline-wide buffers for region flags and pixel weights, eliminating costly recalculation for every pixel
- Refactored color calculations to use separated R/G/B buffers to avoid constant bit-shifting / boolean arithmetic
- Un-inlined certain functions to possibly improve cache performance with better code locality
- Unrolled plane enable/disable logic to avoid frequent array lookups
Performance has increased on a 1.86GHz Core 2 Duo from 28% in a profile build to 75% profile build, flat 100% on a non-profile build
[src/mess/drivers]cdi.c

src/mess/drivers/cdi.c
r6079r6080
9191static WRITE16_HANDLER( m48t08_w );
9292
9393// Platform-specific
94INLINE void cdi220_draw_lcd(running_machine *machine, int y);
94static void cdi220_draw_lcd(running_machine *machine, int y);
9595
9696// MCD212
9797static READ16_HANDLER(mcd212_r);
9898static WRITE16_HANDLER(mcd212_w);
99INLINE void mcd212_set_register(running_machine *machine, int channel, UINT8 reg, UINT32 value);
100INLINE void mcd212_set_vsr(int channel, UINT32 value);
101INLINE UINT32 mcd212_get_vsr(int channel);
102INLINE void mcd212_set_dcp(int channel, UINT32 value);
103INLINE UINT32 mcd212_get_dcp(int channel);
104INLINE void mcd212_set_display_parameters(int channel, UINT8 value);
105INLINE void mcd212_process_ica(running_machine *machine, int channel);
106INLINE void mcd212_process_dca(running_machine *machine, int channel);
107INLINE void mcd212_process_vsr(running_machine *machine, int channel, UINT32 *pixels);
108INLINE void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y);
109INLINE void mcd212_mix_lines(running_machine *machine, UINT32 *plane_a, UINT32 *plane_b, UINT32 *out);
99static void mcd212_set_register(running_machine *machine, int channel, UINT8 reg, UINT32 value);
100static void mcd212_set_vsr(int channel, UINT32 value);
101static UINT32 mcd212_get_vsr(int channel);
102static void mcd212_set_dcp(int channel, UINT32 value);
103static UINT32 mcd212_get_dcp(int channel);
104static void mcd212_set_display_parameters(int channel, UINT8 value);
105static void mcd212_process_ica(running_machine *machine, int channel);
106static void mcd212_process_dca(running_machine *machine, int channel);
107static void mcd212_update_region_arrays(running_machine *machine);
108static void mcd212_process_vsr(running_machine *machine, int channel, UINT8 *pixels_r, UINT8 *pixels_g, UINT8 *pixels_b);
109static void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y);
110static void mcd212_mix_lines(running_machine *machine, UINT8 *plane_a_r, UINT8 *plane_a_g, UINT8 *plane_a_b, UINT8 *plane_b_r, UINT8 *plane_b_g, UINT8 *plane_b_b, UINT32 *out);
110111static void mcd212_draw_scanline(running_machine *machine, int y);
111112TIMER_CALLBACK( mcd212_perform_scan );
112113static VIDEO_START(cdi);
r6079r6080
906907   cdrom_file *cd;
907908} cdic_regs_t;
908909
910#define CDIC_SECTOR_SYNC      0
911
912#define CDIC_SECTOR_HEADER      12
913
914#define CDIC_SECTOR_MODE      15
915
916#define CDIC_SECTOR_FILE1      16
917#define CDIC_SECTOR_CHAN1      17
918#define CDIC_SECTOR_SUBMODE1   18
919#define CDIC_SECTOR_CODING1      19
920
921#define CDIC_SECTOR_FILE2      20
922#define CDIC_SECTOR_CHAN2      21
923#define CDIC_SECTOR_SUBMODE2   22
924#define CDIC_SECTOR_CODING2      23
925
926#define CDIC_SECTOR_DATA      24
927
928#define CDIC_SECTOR_SIZE      2352
929
930#define CDIC_SECTOR_DATASIZE   2048
931#define CDIC_SECTOR_AUDIOSIZE   2304
932#define CDIC_SECTOR_VIDEOSIZE   2324
933
934#define CDIC_SUBMODE_EOF      0x80
935#define CDIC_SUBMODE_RT         0x40
936#define CDIC_SUBMODE_FORM      0x20
937#define CDIC_SUBMODE_TRIG      0x10
938#define CDIC_SUBMODE_DATA      0x08
939#define CDIC_SUBMODE_AUDIO      0x04
940#define CDIC_SUBMODE_VIDEO      0x02
941#define CDIC_SUBMODE_EOR      0x01
942
909943static cdic_regs_t cdic_regs;
910944
911945static TIMER_CALLBACK( cdic_trigger_readback_int )
r6079r6080
939973         //printf( "Reading Mode %d sector from MSF location %06x\n", cdic_regs.command - 0x28, cdic_regs.time | 2 );
940974         verboselog(machine, 0, "Reading Mode %d sector from MSF location %06x\n", cdic_regs.command - 0x28, cdic_regs.time | 2 );
941975
976         cdic_regs.z_buffer ^= 0x0001;
942977         cdic_regs.data_buffer ^= 0x0001;
943978
944979         cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_RAW_DONTCARE);
r6079r6080
9741009            }
9751010         }
9761011
977         if(((buffer[22] & 0x2e) == 0x24) && (cdic_regs.channel & cdic_regs.audio_channel & (1 << buffer[21])))
1012         if(((buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_FORM | CDIC_SUBMODE_DATA | CDIC_SUBMODE_AUDIO | CDIC_SUBMODE_VIDEO)) == (CDIC_SUBMODE_FORM | CDIC_SUBMODE_AUDIO)) &&
1013            (cdic_regs.channel & cdic_regs.audio_channel & (1 << buffer[CDIC_SECTOR_CHAN2])))
9781014         {
9791015            // Ignore the audio sector for now.
980            if(!(buffer[22] & 0x10))
981            {
982               verboselog(machine, 0, "Audio sector, ignored\n" );
983            }
984            else
985            {
986               cdic_regs.x_buffer |= 0x8000;
1016            cdic_regs.x_buffer |= 0x8000;
9871017
988               cdic_regs.data_buffer |= 0x4000;
989               cdic_regs.data_buffer &= 0x7fff;
1018            cdic_regs.data_buffer |= 0x4000;
1019            cdic_regs.data_buffer &= 0x7fff;
9901020
991               //printf( "Setting CDIC interrupt line\n" );
992               verboselog(machine, 0, "Setting CDIC interrupt line\n" );
993               cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128);
994               cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
995            }
1021            //printf( "Setting CDIC interrupt line\n" );
1022            verboselog(machine, 0, "Setting CDIC interrupt line\n" );
1023            cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128);
1024            cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
9961025         }
997         else if((buffer[22] & 0x0e) == 0x00)
1026         else if((buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_DATA | CDIC_SUBMODE_AUDIO | CDIC_SUBMODE_VIDEO)) == 0x00)
9981027         {
9991028            // Ignore the audio sector for now.
1000            if(!(buffer[22] & 0x10))
1029            if(!(buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_TRIG))
10011030            {
10021031               verboselog(machine, 0, "Message sector, ignored\n" );
10031032            }
r6079r6080
10141043               cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
10151044            }
10161045         }
1017         else //if((buffer[22] & 0x04) == 0x04)
1046         else
10181047         {
10191048            cdic_regs.x_buffer |= 0x8000;
10201049
r6079r6080
10271056            cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
10281057         }
10291058
1030         timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed
1059         if(!(buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_EOF))
1060         {
1061            timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed
1062         }
10311063
10321064         break;
10331065      }
r6079r6080
13201352{
13211353   UINT16 x, y;
13221354
1323   printf( "Set mouse position: %02x %02x %02x\n", slave_regs.in_buf[0], slave_regs.in_buf[1], slave_regs.in_buf[2] );
1355   //printf( "Set mouse position: %02x %02x %02x\n", slave_regs.in_buf[0], slave_regs.in_buf[1], slave_regs.in_buf[2] );
13241356
13251357   slave_regs.fake_mouse_y = ((slave_regs.in_buf[1] & 0x0f) << 6) | (slave_regs.in_buf[0] & 0x3f);
13261358   slave_regs.fake_mouse_x = ((slave_regs.in_buf[1] & 0x70) << 3) | slave_regs.in_buf[2];
r6079r6080
16271659   UINT16 ddr;
16281660   UINT16 dcp;
16291661   UINT32 dca;
1630   UINT32 clut[256];
1662   UINT8 clut_r[256];
1663   UINT8 clut_g[256];
1664   UINT8 clut_b[256];
16311665   UINT32 image_coding_method;
16321666   UINT32 transparency_control;
16331667   UINT32 plane_order;
r6079r6080
16481682   UINT32 backdrop_color;
16491683   UINT32 mosaic_hold_a;
16501684   UINT32 mosaic_hold_b;
1651   UINT32 weight_factor_a;
1652   UINT32 weight_factor_b;
1685   UINT8 weight_factor_a[768];
1686   UINT8 weight_factor_b[768];
16531687} mcd212_channel_t;
16541688
16551689typedef struct
16561690{
16571691   mcd212_channel_t channel[2];
16581692   emu_timer *scan_timer;
1659   UINT8 region_flag[2];
1693   UINT8 region_flag_0[768];
1694   UINT8 region_flag_1[768];
16601695} mcd212_t;
16611696
16621697mcd212_t mcd212;
r6079r6080
17541789   0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0400, 0x0400, 0x0400, 0x0400
17551790};
17561791
1757INLINE void cdi220_draw_lcd(running_machine *machine, int y)
1792static void cdi220_draw_lcd(running_machine *machine, int y)
17581793{
17591794   bitmap_t *bitmap = tmpbitmap;
17601795   UINT32 *scanline = BITMAP_ADDR32(bitmap, y, 0);
r6079r6080
18761911   }
18771912}
18781913
1879INLINE void mcd212_set_register(running_machine *machine, int channel, UINT8 reg, UINT32 value)
1914static void mcd212_set_register(running_machine *machine, int channel, UINT8 reg, UINT32 value)
18801915{
18811916   switch(reg)
18821917   {
r6079r6080
18881923      case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf:
18891924      case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
18901925      case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf:
1891         verboselog(machine, 6, "          %04xxxxx: %d: CLUT[%d] = %08x\n", channel * 0x20, channel, mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80), value );
1892         mcd212.channel[0].clut[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = value;
1926         verboselog(machine, 11, "          %04xxxxx: %d: CLUT[%d] = %08x\n", channel * 0x20, channel, mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80), value );
1927         mcd212.channel[0].clut_r[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = (UINT8)(value >> 16);
1928         mcd212.channel[0].clut_g[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = (UINT8)(value >>  8);
1929         mcd212.channel[0].clut_b[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = (UINT8)(value >>  0);
18931930         break;
18941931      case 0xc0: // Image Coding Method
18951932         if(channel == 0)
r6079r6080
19892026      case 0xd7:
19902027         verboselog(machine, 6, "          %04xxxxx: %d: Region Control %d = %08x\n", channel * 0x20, channel, reg & 7, value );
19912028         mcd212.channel[0].region_control[reg & 7] = value;
2029         mcd212_update_region_arrays(machine);
19922030         break;
19932031      case 0xd8: // Backdrop Color
19942032         if(channel == 0)
r6079r6080
20152053         if(channel == 0)
20162054         {
20172055            verboselog(machine, 6, "          %04xxxxx: %d: Weight Factor A = %08x\n", channel * 0x20, channel, value );
2018            mcd212.channel[channel].weight_factor_a = value;
2056            memset(mcd212.channel[channel].weight_factor_a, value & 0x000000ff, 768);
2057            mcd212_update_region_arrays(machine);
20192058         }
20202059         break;
20212060      case 0xdc: // Weight Factor B
20222061         if(channel == 1)
20232062         {
20242063            verboselog(machine, 6, "          %04xxxxx: %d: Weight Factor B = %08x\n", channel * 0x20, channel, value );
2025            mcd212.channel[channel].weight_factor_b = value;
2064            memset(mcd212.channel[channel].weight_factor_b, value & 0x000000ff, 768);
2065            mcd212_update_region_arrays(machine);
20262066         }
20272067         break;
20282068   }
20292069}
20302070
2031INLINE void mcd212_set_vsr(int channel, UINT32 value)
2071static void mcd212_set_vsr(int channel, UINT32 value)
20322072{
20332073   mcd212.channel[channel].vsr = value & 0x0000ffff;
20342074   mcd212.channel[channel].dcr &= 0xffc0;
20352075   mcd212.channel[channel].dcr |= (value >> 16) & 0x003f;
20362076}
20372077
2038INLINE UINT32 mcd212_get_vsr(int channel)
2078static UINT32 mcd212_get_vsr(int channel)
20392079{
20402080   return ((mcd212.channel[channel].dcr & 0x3f) << 16) | mcd212.channel[channel].vsr;
20412081}
20422082
2043INLINE void mcd212_set_dcp(int channel, UINT32 value)
2083static void mcd212_set_dcp(int channel, UINT32 value)
20442084{
20452085   mcd212.channel[channel].dcp = value & 0x0000ffff;
20462086   mcd212.channel[channel].ddr &= 0xffc0;
20472087   mcd212.channel[channel].ddr |= (value >> 16) & 0x003f;
20482088}
20492089
2050INLINE UINT32 mcd212_get_dcp(int channel)
2090static UINT32 mcd212_get_dcp(int channel)
20512091{
20522092   return ((mcd212.channel[channel].ddr & 0x3f) << 16) | mcd212.channel[channel].dcp;
20532093}
20542094
2055INLINE void mcd212_set_display_parameters(int channel, UINT8 value)
2095static void mcd212_set_display_parameters(int channel, UINT8 value)
20562096{
20572097   mcd212.channel[channel].ddr &= 0xf0ff;
20582098   mcd212.channel[channel].ddr |= (value & 0x0f) << 8;
r6079r6080
20602100   mcd212.channel[channel].dcr |= (value & 0x10) << 7;
20612101}
20622102
2063INLINE void mcd212_process_ica(running_machine *machine, int channel)
2103static void mcd212_process_ica(running_machine *machine, int channel)
20642104{
20652105   UINT16 *ica = channel ? planeb : planea;
20662106   UINT32 addr = 0x000400/2;
r6079r6080
21432183   }
21442184}
21452185
2146INLINE void mcd212_process_dca(running_machine *machine, int channel)
2186static void mcd212_process_dca(running_machine *machine, int channel)
21472187{
21482188   UINT16 *dca = channel ? planeb : planea;
21492189   UINT32 addr = (mcd212.channel[channel].dca & 0x0007ffff) / 2; //(mcd212_get_dcp(channel) & 0x0007ffff) / 2; // mcd212.channel[channel].dca / 2;
r6079r6080
23222362   return 0;
23232363}
23242364
2325INLINE void mcd212_process_region(running_machine *machine, int channel, int x)
2365static void mcd212_update_region_arrays(running_machine *machine)
23262366{
2327   if(mcd212.channel[0].image_coding_method & MCD212_ICM_NR)
2367   int x = 0;
2368   for(x = 0; x < 768; x++)
23282369   {
2329      int reg = 0;
2330      int flag = 0;
2370      if(mcd212.channel[0].image_coding_method & MCD212_ICM_NR)
2371      {
2372         int reg = 0;
2373         int flag = 0;
23312374
2332      for(flag = 0; flag < 2; flag++)
2375         for(flag = 0; flag < 2; flag++)
2376         {
2377            for(reg = 0; reg < 4; reg++)
2378            {
2379               if(x > (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_X))
2380               {
2381                  break;
2382               }
2383               if(x == (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_X))
2384               {
2385                  switch(mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_OP)
2386                  {
2387                     case 0: // End of region control for line
2388                        break;
2389                     case 1:
2390                     case 2:
2391                     case 3: // Not used
2392                        break;
2393                     case 4: // Change weight of plane A
2394                        mcd212.channel[0].weight_factor_a[x] = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2395                        break;
2396                     case 5:   // Not used
2397                        break;
2398                     case 6: // Change weight of plane B
2399                        mcd212.channel[1].weight_factor_b[x] = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2400                        break;
2401                     case 7:   // Not used
2402                        break;
2403                     case 8: // Reset region flag
2404                        if(flag)
2405                        {
2406                           mcd212.region_flag_1[x] = 0;
2407                        }
2408                        else
2409                        {
2410                           mcd212.region_flag_0[x] = 0;
2411                        }
2412                        break;
2413                     case 9: // Set region flag
2414                        if(flag)
2415                        {
2416                           mcd212.region_flag_1[x] = 1;
2417                        }
2418                        else
2419                        {
2420                           mcd212.region_flag_0[x] = 1;
2421                        }
2422                        break;
2423                     case 10:   // Not used
2424                     case 11:   // Not used
2425                        break;
2426                     case 12: // Reset region flag and change weight of plane A
2427                        mcd212.channel[0].weight_factor_a[x] = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2428                        if(flag)
2429                        {
2430                           mcd212.region_flag_1[x] = 0;
2431                        }
2432                        else
2433                        {
2434                           mcd212.region_flag_0[x] = 0;
2435                        }
2436                        break;
2437                     case 13: // Set region flag and change weight of plane A
2438                        mcd212.channel[0].weight_factor_a[x] = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2439                        if(flag)
2440                        {
2441                           mcd212.region_flag_1[x] = 1;
2442                        }
2443                        else
2444                        {
2445                           mcd212.region_flag_0[x] = 1;
2446                        }
2447                        break;
2448                     case 14: // Reset region flag and change weight of plane B
2449                        mcd212.channel[1].weight_factor_b[x] = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2450                        if(flag)
2451                        {
2452                           mcd212.region_flag_1[x] = 0;
2453                        }
2454                        else
2455                        {
2456                           mcd212.region_flag_0[x] = 0;
2457                        }
2458                        break;
2459                     case 15: // Set region flag and change weight of plane B
2460                        mcd212.channel[1].weight_factor_b[x] = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2461                        if(flag)
2462                        {
2463                           mcd212.region_flag_1[x] = 1;
2464                        }
2465                        else
2466                        {
2467                           mcd212.region_flag_0[x] = 1;
2468                        }
2469                        break;
2470                  }
2471               }
2472            }
2473         }
2474      }
2475      else
23332476      {
2334         for(reg = 0; reg < 4; reg++)
2477         int reg = 0;
2478         for(reg = 0; reg < 8; reg++)
23352479         {
2336            if(x == (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_X))
2480            int flag = (mcd212.channel[0].region_control[reg] & MCD212_RC_RF) >> MCD212_RC_RF_SHIFT;
2481            if(x > (mcd212.channel[0].region_control[reg] & MCD212_RC_X))
23372482            {
2338               switch(mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_OP)
2483               return;
2484            }
2485            if(x == (mcd212.channel[0].region_control[reg] & MCD212_RC_X))
2486            {
2487               switch((mcd212.channel[0].region_control[reg] & MCD212_RC_OP) >> MCD212_RC_OP_SHIFT)
23392488               {
23402489                  case 0: // End of region control for line
23412490                     break;
r6079r6080
23442493                  case 3: // Not used
23452494                     break;
23462495                  case 4: // Change weight of plane A
2347                     mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2496                     mcd212.channel[0].weight_factor_a[x] = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2497                     verboselog(machine, 0, "New weight factor A: %d\n", mcd212.channel[0].weight_factor_a[x]);
23482498                     break;
23492499                  case 5:   // Not used
23502500                     break;
23512501                  case 6: // Change weight of plane B
2352                     mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2502                     mcd212.channel[1].weight_factor_b[x] = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2503                     verboselog(machine, 0, "New weight factor B: %d\n", mcd212.channel[1].weight_factor_b[x]);
23532504                     break;
23542505                  case 7:   // Not used
23552506                     break;
23562507                  case 8: // Reset region flag
2357                     mcd212.region_flag[flag] = 0;
2508                     if(flag)
2509                     {
2510                        mcd212.region_flag_1[x] = 0;
2511                     }
2512                     else
2513                     {
2514                        mcd212.region_flag_0[x] = 0;
2515                     }
23582516                     break;
23592517                  case 9: // Set region flag
2360                     mcd212.region_flag[flag] = 1;
2518                     if(flag)
2519                     {
2520                        mcd212.region_flag_1[x] = 1;
2521                     }
2522                     else
2523                     {
2524                        mcd212.region_flag_0[x] = 1;
2525                     }
23612526                     break;
23622527                  case 10:   // Not used
23632528                  case 11:   // Not used
23642529                     break;
23652530                  case 12: // Reset region flag and change weight of plane A
2366                     mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2367                     mcd212.region_flag[flag] = 0;
2531                     mcd212.channel[0].weight_factor_a[x] = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2532                     if(flag)
2533                     {
2534                        mcd212.region_flag_1[x] = 0;
2535                     }
2536                     else
2537                     {
2538                        mcd212.region_flag_0[x] = 0;
2539                     }
23682540                     break;
23692541                  case 13: // Set region flag and change weight of plane A
2370                     mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2371                     mcd212.region_flag[flag] = 1;
2542                     mcd212.channel[0].weight_factor_a[x] = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2543                     if(flag)
2544                     {
2545                        mcd212.region_flag_1[x] = 1;
2546                     }
2547                     else
2548                     {
2549                        mcd212.region_flag_0[x] = 1;
2550                     }
23722551                     break;
23732552                  case 14: // Reset region flag and change weight of plane B
2374                     mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2375                     mcd212.region_flag[flag] = 0;
2553                     mcd212.channel[1].weight_factor_b[x] = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2554                     if(flag)
2555                     {
2556                        mcd212.region_flag_1[x] = 0;
2557                     }
2558                     else
2559                     {
2560                        mcd212.region_flag_0[x] = 0;
2561                     }
23762562                     break;
23772563                  case 15: // Set region flag and change weight of plane B
2378                     mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2379                     mcd212.region_flag[flag] = 1;
2564                     mcd212.channel[1].weight_factor_b[x] = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2565                     if(flag)
2566                     {
2567                        mcd212.region_flag_1[x] = 1;
2568                     }
2569                     else
2570                     {
2571                        mcd212.region_flag_0[x] = 1;
2572                     }
23802573                     break;
23812574               }
23822575            }
23832576         }
23842577      }
23852578   }
2386   else
2387   {
2388      int reg = 0;
2389      for(reg = 0; reg < 8; reg++)
2390      {
2391         int flag = (mcd212.channel[0].region_control[reg] & MCD212_RC_RF) >> MCD212_RC_RF_SHIFT;
2392         if((mcd212.channel[0].region_control[reg] & MCD212_RC_X) > x)
2393         {
2394            break;
2395         }
2396         if(x == (mcd212.channel[0].region_control[reg] & MCD212_RC_X))
2397         {
2398            switch((mcd212.channel[0].region_control[reg] & MCD212_RC_OP) >> MCD212_RC_OP_SHIFT)
2399            {
2400               case 0: // End of region control for line
2401                  break;
2402               case 1:
2403               case 2:
2404               case 3: // Not used
2405                  break;
2406               case 4: // Change weight of plane A
2407                  mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2408                  verboselog(machine, 0, "New weight factor A: %d\n", mcd212.channel[0].weight_factor_a);
2409                  break;
2410               case 5:   // Not used
2411                  break;
2412               case 6: // Change weight of plane B
2413                  mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2414                  verboselog(machine, 0, "New weight factor B: %d\n", mcd212.channel[1].weight_factor_b);
2415                  break;
2416               case 7:   // Not used
2417                  break;
2418               case 8: // Reset region flag
2419                  mcd212.region_flag[flag] = 0;
2420                  break;
2421               case 9: // Set region flag
2422                  mcd212.region_flag[flag] = 1;
2423                  break;
2424               case 10:   // Not used
2425               case 11:   // Not used
2426                  break;
2427               case 12: // Reset region flag and change weight of plane A
2428                  mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2429                  mcd212.region_flag[flag] = 0;
2430                  break;
2431               case 13: // Set region flag and change weight of plane A
2432                  mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2433                  mcd212.region_flag[flag] = 1;
2434                  break;
2435               case 14: // Reset region flag and change weight of plane B
2436                  mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2437                  mcd212.region_flag[flag] = 0;
2438                  break;
2439               case 15: // Set region flag and change weight of plane B
2440                  mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2441                  mcd212.region_flag[flag] = 1;
2442                  break;
2443            }
2444         }
2445      }
2446   }
24472579}
24482580
2449INLINE void mcd212_process_vsr(running_machine *machine, int channel, UINT32 *pixels)
2581static void mcd212_process_vsr(running_machine *machine, int channel, UINT8 *pixels_r, UINT8 *pixels_g, UINT8 *pixels_b)
24502582{
24512583   UINT8 *data = channel ? (UINT8*)planeb : (UINT8*)planea;
24522584   UINT32 vsr = mcd212_get_vsr(channel) & 0x0007ffff;
r6079r6080
24552587   UINT32 icm_mask = channel ? MCD212_ICM_MODE2 : MCD212_ICM_MODE1;
24562588   UINT32 icm_shift = channel ? MCD212_ICM_MODE2_SHIFT : MCD212_ICM_MODE1_SHIFT;
24572589   UINT8 icm = (mcd212.channel[0].image_coding_method & icm_mask) >> icm_shift;
2590   UINT8 *clut_r = mcd212.channel[0].clut_r;
2591   UINT8 *clut_g = mcd212.channel[0].clut_g;
2592   UINT8 *clut_b = mcd212.channel[0].clut_b;
24582593
24592594   //printf( "vsr before: %08x: ", vsr );
24602595   //fflush(stdout);
24612596
24622597   if(!icm || !vsr)
24632598   {
2464      for(; x < 768; x++)
2465      {
2466         pixels[x++] = 0x00101010;
2467         pixels[x] = 0x00101010;
2468      }
2599      memset(pixels_r, 0x10, 768);
2600      memset(pixels_g, 0x10, 768);
2601      memset(pixels_b, 0x10, 768);
24692602      return;
24702603   }
24712604
24722605   while(!done)
24732606   {
2474      UINT8 byte = data[vsr++ ^ 1];
2475      //printf( "%02x ", byte );
2476      //fflush(stdout);
2607      UINT8 byte = data[(vsr & 0x0007ffff) ^ 1];
2608      vsr++;
24772609      switch(mcd212.channel[channel].ddr & MCD212_DDR_FT)
24782610      {
24792611         case MCD212_DDR_FT_BMP:
r6079r6080
25072639                        bY = bU = bV = 0x80;
25082640                        break;
25092641                  }
2510                  for(; x < 768;)
2642                  for(; x < 768; x += 4)
25112643                  {
25122644                        BYTE68K b0 = byte;
25132645                        BYTE68K bU1 = bU + mcd212_abDeltaUV[b0];
25142646                        BYTE68K bY0 = bY + mcd212_abDeltaY[b0];
25152647
2516                        BYTE68K b1 = data[vsr++ ^ 1];
2648                        BYTE68K b1 = data[(vsr & 0x0007ffff) ^ 1];
25172649                        BYTE68K bV1 = bV + mcd212_abDeltaUV[b1];
25182650                        BYTE68K bY1 = bY0 + mcd212_abDeltaY[b1];
25192651
r6079r6080
25212653                        BYTE68K bV0 = (bV + bV1) >> 1;
25222654
25232655                     BYTE68K *pbLimit;
2524                     BYTE68K bB, bG, bR;
25252656
2657                     vsr++;
2658
25262659                     bY = bY0;
25272660                     bU = bU0;
25282661                     bV = bV0;
25292662
25302663                        pbLimit = mcd212_abLimit + bY + BYTE68K_MAX;
2531                        bB = pbLimit[mcd212_abMatrixUB[bU]];
2532                        bG = pbLimit[mcd212_abMatrixUG[bU] + mcd212_abMatrixVG[bV]];
2533                        bR = pbLimit[mcd212_abMatrixVR[bV]];
25342664
2535                        pixels[x++] = (bR << 16) | (bG << 8) | bB;
2536                        pixels[x++] = (bR << 16) | (bG << 8) | bB;
2665                        pixels_r[x + 0] = pixels_r[x + 1] = pbLimit[mcd212_abMatrixVR[bV]];
2666                        pixels_g[x + 0] = pixels_g[x + 1] = pbLimit[mcd212_abMatrixUG[bU] + mcd212_abMatrixVG[bV]];
2667                        pixels_b[x + 0] = pixels_b[x + 1] = pbLimit[mcd212_abMatrixUB[bU]];
25372668
25382669                        bY = bY1;
25392670                        bU = bU1;
25402671                        bV = bV1;
25412672
25422673                        pbLimit = mcd212_abLimit + bY + BYTE68K_MAX;
2543                        bB = pbLimit[mcd212_abMatrixUB[bU]];
2544                        bG = pbLimit[mcd212_abMatrixUG[bU] + mcd212_abMatrixVG[bV]];
2545                        bR = pbLimit[mcd212_abMatrixVR[bV]];
25462674
2547                        pixels[x++] = (bR << 16) | (bG << 8) | bB;
2548                        pixels[x++] = (bR << 16) | (bG << 8) | bB;
2675                        pixels_r[x + 2] = pixels_r[x + 3] = pbLimit[mcd212_abMatrixVR[bV]];
2676                        pixels_g[x + 2] = pixels_g[x + 3] = pbLimit[mcd212_abMatrixUG[bU] + mcd212_abMatrixVG[bV]];
2677                        pixels_b[x + 2] = pixels_b[x + 3] = pbLimit[mcd212_abMatrixUB[bU]];
25492678
2550                        byte = data[vsr++ ^ 1];
2679                        byte = data[(vsr & 0x0007ffff) ^ 1];
25512680
2681                     vsr++;
25522682                  }
2553                  mcd212_set_vsr(channel, vsr - 1);
2683                  mcd212_set_vsr(channel, (vsr - 1) & 0x0007ffff);
25542684               }
25552685               else if(icm == 3 || icm == 4)
25562686               {
2557                  for(; x < 768; x++)
2687                  for(; x < 768; x += 2)
25582688                  {
2559                     pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2560                     pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2561                     byte = data[vsr++ ^ 1];
2689                     UINT8 clut_entry = BYTE_TO_CLUT(channel, icm, byte);
2690                     pixels_r[x + 0] = clut_r[clut_entry];
2691                     pixels_g[x + 0] = clut_g[clut_entry];
2692                     pixels_b[x + 0] = clut_b[clut_entry];
2693                     pixels_r[x + 1] = clut_r[clut_entry];
2694                     pixels_g[x + 1] = clut_g[clut_entry];
2695                     pixels_b[x + 1] = clut_b[clut_entry];
2696                     byte = data[(vsr & 0x0007ffff) ^ 1];
2697                     vsr++;
25622698                  }
2563                  mcd212_set_vsr(channel, vsr - 1);
2699                  mcd212_set_vsr(channel, (vsr - 1) & 0x0007ffff);
25642700               }
25652701               else if(icm == 11)
25662702               {
2567                  for(; x < 768; x++)
2703                  for(; x < 768; x += 2)
25682704                  {
2569                     pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte >> 4)];
2570                     pixels[x]   = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2571                     byte = data[vsr++ ^ 1];
2705                     UINT8 even_entry = BYTE_TO_CLUT(channel, icm, byte >> 4);
2706                     UINT8 odd_entry = BYTE_TO_CLUT(channel, icm, byte);
2707                     pixels_r[x + 0] = clut_r[even_entry];
2708                     pixels_g[x + 0] = clut_g[even_entry];
2709                     pixels_b[x + 0] = clut_b[even_entry];
2710                     pixels_r[x + 1] = clut_r[odd_entry];
2711                     pixels_g[x + 1] = clut_g[odd_entry];
2712                     pixels_b[x + 1] = clut_b[odd_entry];
2713                     byte = data[(vsr & 0x0007ffff) ^ 1];
2714                     vsr++;
25722715                  }
2573                  mcd212_set_vsr(channel, vsr - 1);
2716                  mcd212_set_vsr(channel, (vsr - 1) & 0x0007ffff);
25742717               }
25752718               else
25762719               {
25772720                  for(; x < 768; x++)
25782721                  {
2579                     pixels[x++] = 0x00101010;
2580                     pixels[x] = 0x00101010;
2722                     pixels_r[x] = 0x10;
2723                     pixels_g[x] = 0x10;
2724                     pixels_b[x] = 0x10;
25812725                  }
25822726               }
25832727            }
r6079r6080
25942738               if(byte & 0x80)
25952739               {
25962740                  // Run length
2597                  UINT8 length = data[vsr++ ^ 1];
2741                  UINT8 length = data[((vsr++) & 0x0007ffff) ^ 1];
25982742                  if(!length)
25992743                  {
2744                     UINT8 clut_entry = BYTE_TO_CLUT(channel, icm, byte);
2745                     UINT8 r = clut_r[clut_entry];
2746                     UINT8 g = clut_g[clut_entry];
2747                     UINT8 b = clut_b[clut_entry];
26002748                     // Go to the end of the line
26012749                     for(; x < 768; x++)
26022750                     {
2603                        pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2604                        pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2751                        pixels_r[x] = r;
2752                        pixels_g[x] = g;
2753                        pixels_b[x] = b;
2754                        x++;
2755                        pixels_r[x] = r;
2756                        pixels_g[x] = g;
2757                        pixels_b[x] = b;
26052758                     }
26062759                     done = 1;
26072760                     mcd212_set_vsr(channel, vsr);
r6079r6080
26092762                  else
26102763                  {
26112764                     int end = x + (length * 2);
2765                     UINT8 clut_entry = BYTE_TO_CLUT(channel, icm, byte);
2766                     UINT8 r = clut_r[clut_entry];
2767                     UINT8 g = clut_g[clut_entry];
2768                     UINT8 b = clut_b[clut_entry];
26122769                     for(; x < end && x < 768; x++)
26132770                     {
2614                        pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2615                        pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2771                        pixels_r[x] = r;
2772                        pixels_g[x] = g;
2773                        pixels_b[x] = b;
2774                        x++;
2775                        pixels_r[x] = r;
2776                        pixels_g[x] = g;
2777                        pixels_b[x] = b;
26162778                     }
26172779                     if(x >= 768)
26182780                     {
r6079r6080
26242786               else
26252787               {
26262788                  // Single pixel
2627                  pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2628                  pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, icm, byte)];
2789                  UINT8 clut_entry = BYTE_TO_CLUT(channel, icm, byte);
2790                  pixels_r[x] = clut_r[clut_entry];
2791                  pixels_g[x] = clut_g[clut_entry];
2792                  pixels_b[x] = clut_b[clut_entry];
2793                  x++;
2794                  pixels_r[x] = clut_r[clut_entry];
2795                  pixels_g[x] = clut_g[clut_entry];
2796                  pixels_b[x] = clut_b[clut_entry];
2797                  x++;
26292798                  if(x >= 768)
26302799                  {
26312800                     done = 1;
r6079r6080
26512820   0x00101010, 0x001010e6, 0x0010e610, 0x0010e6e6, 0x00e61010, 0x00e610e6, 0x00e6e610, 0x00e6e6e6
26522821};
26532822
2654INLINE void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y)
2823static void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y)
26552824{
26562825   if(mcd212.channel[0].cursor_control & MCD212_CURCNT_EN)
26572826   {
r6079r6080
26962865   }
26972866}
26982867
2699INLINE void mcd212_mix_lines(running_machine *machine, UINT32 *plane_a, UINT32 *plane_b, UINT32 *out)
2868static void mcd212_mix_lines(running_machine *machine, UINT8 *plane_a_r, UINT8 *plane_a_g, UINT8 *plane_a_b, UINT8 *plane_b_r, UINT8 *plane_b_g, UINT8 *plane_b_b, UINT32 *out)
27002869{
27012870   int x = 0;
27022871   UINT32 backdrop = mcd212_4bpp_color[mcd212.channel[0].backdrop_color];
2872   UINT8 transparency_mode_a = (mcd212.channel[0].transparency_control >> 0) & 0x0f;
2873   UINT8 transparency_mode_b = (mcd212.channel[0].transparency_control >> 8) & 0x0f;
2874   UINT8 transparent_color_a_r = (UINT8)(mcd212.channel[0].transparent_color_a >> 16);
2875   UINT8 transparent_color_a_g = (UINT8)(mcd212.channel[0].transparent_color_a >>  8);
2876   UINT8 transparent_color_a_b = (UINT8)(mcd212.channel[0].transparent_color_a >>  0);
2877   UINT8 transparent_color_b_r = (UINT8)(mcd212.channel[1].transparent_color_b >> 16);
2878   UINT8 transparent_color_b_g = (UINT8)(mcd212.channel[1].transparent_color_b >>  8);
2879   UINT8 transparent_color_b_b = (UINT8)(mcd212.channel[1].transparent_color_b >>  0);
27032880   for(x = 0; x < 768; x++)
27042881   {
27052882      out[x] = backdrop;
2706      mcd212_process_region(machine, 0, x);
2707      mcd212_process_region(machine, 1, x);
27082883      if(!(mcd212.channel[0].transparency_control & MCD212_TCR_DISABLE_MX))
27092884      {
2710         INT32 weight_a = mcd212.channel[0].weight_factor_a;
2711         INT32 weight_b = mcd212.channel[1].weight_factor_b;
2712         INT32 ar = (plane_a[x] >> 16) & 0x000000ff;
2713         INT32 ag = (plane_a[x] >>  8) & 0x000000ff;
2714         INT32 ab = (plane_a[x] >>  0) & 0x000000ff;
2715         INT32 br = (plane_b[x] >> 16) & 0x000000ff;
2716         INT32 bg = (plane_b[x] >>  8) & 0x000000ff;
2717         INT32 bb = (plane_b[x] >>  0) & 0x000000ff;
2718         UINT8 abr = MCD212_LIM((MCD212_LIM(ar - 16) * weight_a) / 64 + (MCD212_LIM(br - 16) * weight_b) / 64 + 16);
2719         UINT8 abg = MCD212_LIM((MCD212_LIM(ag - 16) * weight_a) / 64 + (MCD212_LIM(bg - 16) * weight_b) / 64 + 16);
2720         UINT8 abb = MCD212_LIM((MCD212_LIM(ab - 16) * weight_a) / 64 + (MCD212_LIM(bb - 16) * weight_b) / 64 + 16);
2885         UINT8 abr = MCD212_LIM(((MCD212_LIM((INT32)plane_a_r[x] - 16) * mcd212.channel[0].weight_factor_a[x]) >> 6) + ((MCD212_LIM((INT32)plane_b_r[x] - 16) * mcd212.channel[1].weight_factor_b[x]) >> 6) + 16);
2886         UINT8 abg = MCD212_LIM(((MCD212_LIM((INT32)plane_a_g[x] - 16) * mcd212.channel[0].weight_factor_a[x]) >> 6) + ((MCD212_LIM((INT32)plane_b_g[x] - 16) * mcd212.channel[1].weight_factor_b[x]) >> 6) + 16);
2887         UINT8 abb = MCD212_LIM(((MCD212_LIM((INT32)plane_a_b[x] - 16) * mcd212.channel[0].weight_factor_a[x]) >> 6) + ((MCD212_LIM((INT32)plane_b_b[x] - 16) * mcd212.channel[1].weight_factor_b[x]) >> 6) + 16);
27212888         out[x] = (abr << 16) | (abg << 8) | abb;
27222889      }
27232890      else
27242891      {
2725         UINT8 transparency_mode[2] =
2892         UINT8 plane_enable_a = 0;
2893         UINT8 plane_enable_b = 0;
2894         UINT8 plane_a_r_cur = plane_a_r[x];
2895         UINT8 plane_a_g_cur = plane_a_g[x];
2896         UINT8 plane_a_b_cur = plane_a_b[x];
2897         UINT8 plane_b_r_cur = plane_b_r[x];
2898         UINT8 plane_b_g_cur = plane_b_g[x];
2899         UINT8 plane_b_b_cur = plane_b_b[x];
2900         switch(transparency_mode_a)
27262901         {
2727            (mcd212.channel[0].transparency_control >> 0) & 0x0f,
2728            (mcd212.channel[0].transparency_control >> 8) & 0x0f
2729         };
2730         UINT8 plane_enable[2] =
2902            case 0:
2903               plane_enable_a = 0;
2904               break;
2905            case 1:
2906               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);
2907               break;
2908            case 3:
2909               plane_enable_a = mcd212.region_flag_0[x];
2910               break;
2911            case 4:
2912               plane_enable_a = mcd212.region_flag_1[x];
2913               break;
2914            case 5:
2915               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 || mcd212.region_flag_0[x] == 1);
2916               break;
2917            case 6:
2918               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 || mcd212.region_flag_1[x] == 1);
2919               break;
2920            case 8:
2921               plane_enable_a = 1;
2922               break;
2923            case 9:
2924               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);
2925               break;
2926            case 11:
2927               plane_enable_a = !mcd212.region_flag_0[x];
2928               break;
2929            case 12:
2930               plane_enable_a = !mcd212.region_flag_1[x];
2931               break;
2932            case 13:
2933               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 && mcd212.region_flag_0[x] == 0);
2934               break;
2935            case 14:
2936               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 && mcd212.region_flag_1[x] == 0);
2937               break;
2938            default:
2939               verboselog(machine, 0, "Unhandled transparency mode for plane A: %d\n", transparency_mode_a);
2940               plane_enable_a = 1;
2941               break;
2942         }
2943         switch(transparency_mode_b)
27312944         {
2732            0,
2733            0
2734         };
2735         int index = 0;
2736         for(index = 0; index < 2; index++)
2737         {
2738            UINT32 *plane = index ? plane_b : plane_a;
2739            UINT32 transparent_color = index ? mcd212.channel[1].transparent_color_b : mcd212.channel[0].transparent_color_a;
2740            switch(transparency_mode[index])
2741            {
2742               case 0:
2743                  plane_enable[index] = 0;
2744                  break;
2745               case 1:
2746                  if(plane[x] != transparent_color)
2747                  {
2748                     plane_enable[index] = 1;
2749                  }
2750                  break;
2751               case 5:
2752                  // Todo
2753                  if(plane[x] != transparent_color)
2754                  {
2755                     plane_enable[index] = 1;
2756                  }
2757                  break;
2758               case 8:
2759                  plane_enable[index] = 1;
2760                  break;
2761               case 9:
2762                  if(plane[x] == transparent_color)
2763                  {
2764                     plane_enable[index] = 1;
2765                  }
2766                  break;
2767               default:
2768                  verboselog(machine, 0, "Unhandled transparency mode for plane %c: %d\n", index ? 'B' : 'A', transparency_mode[index]);
2769                  plane_enable[index] = 1;
2770                  break;
2771            }
2945            case 0:
2946               plane_enable_b = 0;
2947               break;
2948            case 1:
2949               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);
2950               break;
2951            case 3:
2952               plane_enable_b = mcd212.region_flag_0[x];
2953               break;
2954            case 4:
2955               plane_enable_b = mcd212.region_flag_1[x];
2956               break;
2957            case 5:
2958               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 || mcd212.region_flag_0[x] == 1);
2959               break;
2960            case 6:
2961               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 || mcd212.region_flag_1[x] == 1);
2962               break;
2963            case 8:
2964               plane_enable_b = 1;
2965               break;
2966            case 9:
2967               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);
2968               break;
2969            case 11:
2970               plane_enable_b = !mcd212.region_flag_0[x];
2971               break;
2972            case 12:
2973               plane_enable_b = !mcd212.region_flag_1[x];
2974               break;
2975            case 13:
2976               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 && mcd212.region_flag_0[x] == 0);
2977               break;
2978            case 14:
2979               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 && mcd212.region_flag_1[x] == 0);
2980               break;
2981            default:
2982               verboselog(machine, 0, "Unhandled transparency mode for plane B: %d\n", transparency_mode_b);
2983               plane_enable_b = 1;
2984               break;
27722985         }
27732986         switch(mcd212.channel[0].plane_order)
27742987         {
27752988            case MCD212_POR_AB:
2776               if(plane_enable[0])
2989               if(plane_enable_a)
27772990               {
2778                  out[x] = plane_a[x];
2991                  out[x] = (plane_a_r_cur << 16) | (plane_a_g_cur << 8) | plane_a_b_cur;
27792992               }
2780               else if(plane_enable[1])
2993               else if(plane_enable_b)
27812994               {
2782                  out[x] = plane_b[x];
2995                  out[x] = (plane_b_r_cur << 16) | (plane_b_g_cur << 8) | plane_b_b_cur;
27832996               }
27842997               break;
27852998            case MCD212_POR_BA:
2786               if(plane_enable[1])
2999               if(plane_enable_b)
27873000               {
2788                  out[x] = plane_b[x];
3001                  out[x] = (plane_b_r_cur << 16) | (plane_b_g_cur << 8) | plane_b_b_cur;
27893002               }
2790               else if(plane_enable[0])
3003               else if(plane_enable_a)
27913004               {
2792                  out[x] = plane_a[x];
3005                  out[x] = (plane_a_r_cur << 16) | (plane_a_g_cur << 8) | plane_a_b_cur;
27933006               }
27943007               break;
27953008         }
r6079r6080
28003013static void mcd212_draw_scanline(running_machine *machine, int y)
28013014{
28023015   bitmap_t *bitmap = tmpbitmap;
2803   UINT32 plane_a[768];
2804   UINT32 plane_b[768];
3016   UINT8 plane_a_r[768], plane_a_g[768], plane_a_b[768];
3017   UINT8 plane_b_r[768], plane_b_g[768], plane_b_b[768];
28053018   UINT32 out[768];
28063019   UINT32 *scanline = BITMAP_ADDR32(bitmap, y, 0);
28073020   int x;
2808   mcd212_process_vsr(machine, 0, plane_a);
2809   mcd212_process_vsr(machine, 1, plane_b);
2810   mcd212_mix_lines(machine, plane_a, plane_b, out);
3021   mcd212_process_vsr(machine, 0, plane_a_r, plane_a_g, plane_a_b);
3022   mcd212_process_vsr(machine, 1, plane_b_r, plane_b_g, plane_b_b);
3023   mcd212_mix_lines(machine, plane_a_r, plane_a_g, plane_a_b, plane_b_r, plane_b_g, plane_b_b, out);
28113024   for(x = 0; x < 768; x++)
28123025   {
28133026      scanline[x] = out[x];
r6079r6080
30193232*************************/
30203233
30213234static MACHINE_DRIVER_START( cdimono1 )
3022   MDRV_CPU_ADD("maincpu", SCC68070, CLOCK_A/2)   /* SCC-68070 CCA84 datasheet */
3235   MDRV_CPU_ADD("maincpu", SCC68070, CLOCK_A/3)
30233236   MDRV_CPU_PROGRAM_MAP(cdimono1_mem)
30243237
30253238   MDRV_SCREEN_ADD("screen", RASTER)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team