Previous 15994 Revisions Next

r6065 Tuesday 13th October, 2009 at 21:04:08 UTC by Harmony
CD-i:
- Added basic CLUT4 support.
- Slightly tweaked CDIC interrupt behavior, more games boot.
- Added region support.
[src/mess/drivers]cdi.c

src/mess/drivers/cdi.c
r6064r6065
4343
4444#define ENABLE_UART_PRINTING (0)
4545
46#define VERBOSE_LEVEL   (11)
46#define VERBOSE_LEVEL   (6)
4747
4848#define ENABLE_VERBOSE_LOG (1)
4949
r6064r6065
9191static WRITE16_HANDLER( m48t08_w );
9292
9393// Platform-specific
94static void cdi220_draw_lcd(running_machine *machine, int y);
94INLINE void cdi220_draw_lcd(running_machine *machine, int y);
9595
9696// MCD212
9797static READ16_HANDLER(mcd212_r);
r6064r6065
102102INLINE void mcd212_set_dcp(int channel, UINT32 value);
103103INLINE UINT32 mcd212_get_dcp(int channel);
104104INLINE 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_process_vsr(running_machine *machine, int channel, UINT32 *pixels);
108static void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y);
109static void mcd212_mix_lines(running_machine *machine, UINT32 *plane_a, UINT32 *plane_b, UINT32 *out);
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);
110110static void mcd212_draw_scanline(running_machine *machine, int y);
111111TIMER_CALLBACK( mcd212_perform_scan );
112112static VIDEO_START(cdi);
r6064r6065
969969            }
970970         }
971971
972         if(((buffer[22] & 0x24) == 0x24) && (cdic_regs.channel & cdic_regs.audio_channel & (1 << buffer[21])))
972         if(((buffer[22] & 0x2e) == 0x24) && (cdic_regs.channel & cdic_regs.audio_channel & (1 << buffer[21])))
973973         {
974974            // Ignore the audio sector for now.
975            if(!(buffer[22] & 0x10))
976            {
977               verboselog(machine, 0, "Audio sector, ignored\n" );
978            }
979            else
980            {
981               cdic_regs.x_buffer |= 0x8000;
982
983               cdic_regs.data_buffer |= 0x4000;
984               cdic_regs.data_buffer &= 0x7fff;
985
986               verboselog(machine, 0, "EOF, access should stop here\n" );
987               //printf( "Setting CDIC interrupt line\n" );
988               verboselog(machine, 0, "Setting CDIC interrupt line\n" );
989               cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128);
990               cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
991            }
975992         }
976993         else if((buffer[22] & 0x0e) == 0x00)
977994         {
r6064r6065
9841001            cdic_regs.data_buffer |= 0x4000;
9851002            cdic_regs.data_buffer &= 0x7fff;
9861003
1004            verboselog(machine, 0, "EOF, access should stop here\n" );
9871005            //printf( "Setting CDIC interrupt line\n" );
9881006            verboselog(machine, 0, "Setting CDIC interrupt line\n" );
9891007            cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), M68K_IRQ_4, 128);
9901008            cputag_set_input_line(machine, "maincpu", M68K_IRQ_4, ASSERT_LINE);
9911009         }
9921010
993         timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed
1011         if(!(buffer[22] & 0x80))
1012         {
1013            timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); // 75Hz = 1x CD-ROM speed
1014         }
1015         else
1016         {
1017            cdic_regs.command = 0;
1018         }
9941019
9951020         break;
9961021      }
r6064r6065
14771502                  break;
14781503               case 0xf0: // Get SLAVE revision
14791504                  verboselog(space->machine, 0, "slave_w: Channel %d: Get SLAVE Revision (0xf0)\n", offset );
1480                  slave_prepare_readback(space->machine, ATTOTIME_IN_HZ(10000), 2, 2, 0x32, 0x31, 0, 0, 0xf0);
1505                  slave_prepare_readback(space->machine, ATTOTIME_IN_HZ(10000), 2, 2, 0xf0, 0x32, 0x31, 0, 0xf0);
14811506                  slave_regs.in_index = 0;
14821507                  break;
14831508               case 0xf3: // Query Pointer Type
r6064r6065
16211646{
16221647   mcd212_channel_t channel[2];
16231648   emu_timer *scan_timer;
1649   UINT8 region_flag[2];
16241650} mcd212_t;
16251651
16261652mcd212_t mcd212;
r6064r6065
16341660#define MCD212_CURCNT_BLKC         0x400000   // Blink type
16351661#define MCD212_CURCNT_EN         0x800000   // Cursor enable
16361662
1663#define MCD212_ICM_CS            0x400000   // CLUT select
1664#define MCD212_ICM_NR            0x080000   // Number of region flags
1665#define MCD212_ICM_EV            0x040000   // External video
1666#define MCD212_ICM_MODE2         0x000f00   // Plane 2
1667#define MCD212_ICM_MODE2_SHIFT      8
1668#define MCD212_ICM_MODE1         0x00000f   // Plane 1
1669#define MCD212_ICM_MODE1_SHIFT      0
1670
16371671#define MCD212_TCR_DISABLE_MX      0x800000   // Mix disable
16381672#define MCD212_TCR_TB            0x000f00   // Plane B
16391673#define MCD212_TCR_TB_SHIFT         8
r6064r6065
16581692#define MCD212_POR_AB            0         // Plane A in front of Plane B
16591693#define MCD212_POR_BA            1         // Plane B in front of Plane A
16601694
1695#define MCD212_RC_X               0x0003ff   // X position
1696#define MCD212_RC_WF            0x00fc00   // Weight position
1697#define MCD212_RC_WF_SHIFT         10
1698#define MCD212_RC_RF            0x010000   // Region flag
1699#define MCD212_RC_RF_SHIFT         16
1700#define MCD212_RC_OP            0xf00000   // Operation
1701#define MCD212_RC_OP_SHIFT         20
1702
16611703#define MCD212_CSR2R_IT1         0x0004   // Interrupt 1
16621704#define MCD212_CSR2R_IT2         0x0002   // Interrupt 2
16631705#define MCD212_CSR2R_BE            0x0001   // Bus Error
r6064r6065
17021744   0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0400, 0x0400, 0x0400, 0x0400
17031745};
17041746
1705static void cdi220_draw_lcd(running_machine *machine, int y)
1747INLINE void cdi220_draw_lcd(running_machine *machine, int y)
17061748{
17071749   bitmap_t *bitmap = tmpbitmap;
17081750   UINT32 *scanline = BITMAP_ADDR32(bitmap, y, 0);
r6064r6065
18361878      case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf:
18371879      case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
18381880      case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf:
1839         verboselog(machine, 11, "          %04xxxxx: %d: CLUT[%d] = %08x\n", channel * 0x20, channel, mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80), value );
1881         verboselog(machine, 6, "          %04xxxxx: %d: CLUT[%d] = %08x\n", channel * 0x20, channel, mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80), value );
18401882         mcd212.channel[0].clut[mcd212.channel[channel].clut_bank * 0x40 + (reg - 0x80)] = value;
18411883         break;
18421884      case 0xc0: // Image Coding Method
18431885         if(channel == 0)
18441886         {
1845            verboselog(machine, 11, "          %04xxxxx: %d: Image Coding Method = %08x\n", channel * 0x20, channel, value );
1887            verboselog(machine, 6, "          %04xxxxx: %d: Image Coding Method = %08x\n", channel * 0x20, channel, value );
18461888            mcd212.channel[channel].image_coding_method = value;
18471889         }
18481890         break;
18491891      case 0xc1: // Transparency Control
18501892         if(channel == 0)
18511893         {
1852            verboselog(machine, 11, "          %04xxxxx: %d: Transparency Control = %08x\n", channel * 0x20, channel, value );
1894            verboselog(machine, 6, "          %04xxxxx: %d: Transparency Control = %08x\n", channel * 0x20, channel, value );
18531895            mcd212.channel[channel].transparency_control = value;
18541896         }
18551897         break;
18561898      case 0xc2: // Plane Order
18571899         if(channel == 0)
18581900         {
1859            verboselog(machine, 11, "          %04xxxxx: %d: Plane Order = %08x\n", channel * 0x20, channel, value & 7);
1901            verboselog(machine, 6, "          %04xxxxx: %d: Plane Order = %08x\n", channel * 0x20, channel, value & 7);
18601902            mcd212.channel[channel].plane_order = value & 0x00000007;
18611903         }
18621904         break;
18631905      case 0xc3: // CLUT Bank Register
1864         verboselog(machine, 11, "          %04xxxxx: %d: CLUT Bank Register = %08x\n", channel * 0x20, channel, value & 3);
1906         verboselog(machine, 6, "          %04xxxxx: %d: CLUT Bank Register = %08x\n", channel * 0x20, channel, value & 3);
18651907         mcd212.channel[channel].clut_bank = channel ? (2 | (value & 0x00000001)) : (value & 0x00000003);
18661908         break;
18671909      case 0xc4: // Transparent Color A
18681910         if(channel == 0)
18691911         {
1870            verboselog(machine, 11, "          %04xxxxx: %d: Transparent Color A = %08x\n", channel * 0x20, channel, value );
1912            verboselog(machine, 6, "          %04xxxxx: %d: Transparent Color A = %08x\n", channel * 0x20, channel, value );
18711913            mcd212.channel[channel].transparent_color_a = value;
18721914         }
18731915         break;
18741916      case 0xc6: // Transparent Color B
18751917         if(channel == 1)
18761918         {
1877            verboselog(machine, 11, "          %04xxxxx: %d: Transparent Color B = %08x\n", channel * 0x20, channel, value );
1919            verboselog(machine, 6, "          %04xxxxx: %d: Transparent Color B = %08x\n", channel * 0x20, channel, value );
18781920            mcd212.channel[channel].transparent_color_b = value;
18791921         }
18801922         break;
18811923      case 0xc7: // Mask Color A
18821924         if(channel == 0)
18831925         {
1884            verboselog(machine, 11, "          %04xxxxx: %d: Mask Color A = %08x\n", channel * 0x20, channel, value );
1926            verboselog(machine, 6, "          %04xxxxx: %d: Mask Color A = %08x\n", channel * 0x20, channel, value );
18851927            mcd212.channel[channel].mask_color_a = value;
18861928         }
18871929         break;
18881930      case 0xc9: // Mask Color B
18891931         if(channel == 1)
18901932         {
1891            verboselog(machine, 11, "          %04xxxxx: %d: Mask Color B = %08x\n", channel * 0x20, channel, value );
1933            verboselog(machine, 6, "          %04xxxxx: %d: Mask Color B = %08x\n", channel * 0x20, channel, value );
18921934            mcd212.channel[channel].mask_color_b = value;
18931935         }
18941936         break;
18951937      case 0xca: // Delta YUV Absolute Start Value A
18961938         if(channel == 0)
18971939         {
1898            verboselog(machine, 11, "          %04xxxxx: %d: Delta YUV Absolute Start Value A = %08x\n", channel * 0x20, channel, value );
1940            verboselog(machine, 6, "          %04xxxxx: %d: Delta YUV Absolute Start Value A = %08x\n", channel * 0x20, channel, value );
18991941            mcd212.channel[channel].dyuv_abs_start_a = value;
19001942         }
19011943         break;
19021944      case 0xcb: // Delta YUV Absolute Start Value B
19031945         if(channel == 1)
19041946         {
1905            verboselog(machine, 11, "          %04xxxxx: %d: Delta YUV Absolute Start Value B = %08x\n", channel * 0x20, channel, value );
1947            verboselog(machine, 6, "          %04xxxxx: %d: Delta YUV Absolute Start Value B = %08x\n", channel * 0x20, channel, value );
19061948            mcd212.channel[channel].dyuv_abs_start_b = value;
19071949         }
19081950         break;
19091951      case 0xcd: // Cursor Position
19101952         if(channel == 0)
19111953         {
1912            verboselog(machine, 11, "          %04xxxxx: %d: Cursor Position = %08x\n", channel * 0x20, channel, value );
1954            verboselog(machine, 6, "          %04xxxxx: %d: Cursor Position = %08x\n", channel * 0x20, channel, value );
19131955            mcd212.channel[channel].cursor_position = value;
19141956         }
19151957         break;
r6064r6065
19361978      case 0xd6:
19371979      case 0xd7:
19381980         verboselog(machine, 6, "          %04xxxxx: %d: Region Control %d = %08x\n", channel * 0x20, channel, reg & 7, value );
1939         mcd212.channel[channel].region_control[reg & 7] = value;
1981         mcd212.channel[0].region_control[reg & 7] = value;
19401982         break;
19411983      case 0xd8: // Backdrop Color
19421984         if(channel == 0)
19431985         {
1944            verboselog(machine, 11, "          %04xxxxx: %d: Backdrop Color = %08x\n", channel * 0x20, channel, value );
1986            verboselog(machine, 6, "          %04xxxxx: %d: Backdrop Color = %08x\n", channel * 0x20, channel, value );
19451987            mcd212.channel[channel].backdrop_color = value;
19461988         }
19471989         break;
19481990      case 0xd9: // Mosaic Pixel Hold Factor A
19491991         if(channel == 0)
19501992         {
1951            verboselog(machine, 11, "          %04xxxxx: %d: Mosaic Pixel Hold Factor A = %08x\n", channel * 0x20, channel, value );
1993            verboselog(machine, 6, "          %04xxxxx: %d: Mosaic Pixel Hold Factor A = %08x\n", channel * 0x20, channel, value );
19521994            mcd212.channel[channel].mosaic_hold_a = value;
19531995         }
19541996         break;
19551997      case 0xda: // Mosaic Pixel Hold Factor B
19561998         if(channel == 1)
19571999         {
1958            verboselog(machine, 11, "          %04xxxxx: %d: Mosaic Pixel Hold Factor B = %08x\n", channel * 0x20, channel, value );
2000            verboselog(machine, 6, "          %04xxxxx: %d: Mosaic Pixel Hold Factor B = %08x\n", channel * 0x20, channel, value );
19592001            mcd212.channel[channel].mosaic_hold_b = value;
19602002         }
19612003         break;
19622004      case 0xdb: // Weight Factor A
19632005         if(channel == 0)
19642006         {
1965            verboselog(machine, 11, "          %04xxxxx: %d: Weight Factor A = %08x\n", channel * 0x20, channel, value );
2007            verboselog(machine, 6, "          %04xxxxx: %d: Weight Factor A = %08x\n", channel * 0x20, channel, value );
19662008            mcd212.channel[channel].weight_factor_a = value;
19672009         }
19682010         break;
19692011      case 0xdc: // Weight Factor B
19702012         if(channel == 1)
19712013         {
1972            verboselog(machine, 11, "          %04xxxxx: %d: Weight Factor B = %08x\n", channel * 0x20, channel, value );
2014            verboselog(machine, 6, "          %04xxxxx: %d: Weight Factor B = %08x\n", channel * 0x20, channel, value );
19732015            mcd212.channel[channel].weight_factor_b = value;
19742016         }
19752017         break;
r6064r6065
20082050   mcd212.channel[channel].dcr |= (value & 0x10) << 7;
20092051}
20102052
2011static void mcd212_process_ica(running_machine *machine, int channel)
2053INLINE void mcd212_process_ica(running_machine *machine, int channel)
20122054{
20132055   UINT16 *ica = channel ? planeb : planea;
20142056   UINT32 addr = 0x000400/2;
r6064r6065
20772119            */
20782120            break;
20792121         case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: // RELOAD DISPLAY PARAMETERS
2080            verboselog(machine, 11, "%08x: %08x: ICA %d: RELOAD DISPLAY PARAMETERS\n", addr * 2 + channel * 0x200000, cmd, channel );
2122            verboselog(machine, 6, "%08x: %08x: ICA %d: RELOAD DISPLAY PARAMETERS\n", addr * 2 + channel * 0x200000, cmd, channel );
20812123            mcd212_set_display_parameters(channel, cmd & 0x1f);
20822124            break;
20832125         default:
r6064r6065
20912133   }
20922134}
20932135
2094static void mcd212_process_dca(running_machine *machine, int channel)
2136INLINE void mcd212_process_dca(running_machine *machine, int channel)
20952137{
20962138   UINT16 *dca = channel ? planeb : planea;
20972139   UINT32 addr = (mcd212.channel[channel].dca & 0x0007ffff) / 2; //(mcd212_get_dcp(channel) & 0x0007ffff) / 2; // mcd212.channel[channel].dca / 2;
r6064r6065
21662208            */
21672209            break;
21682210         case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: // RELOAD DISPLAY PARAMETERS
2169            verboselog(machine, 11, "%08x: %08x: DCA %d: RELOAD DISPLAY PARAMETERS\n", addr * 2 + channel * 0x200000, cmd, channel );
2211            verboselog(machine, 6, "%08x: %08x: DCA %d: RELOAD DISPLAY PARAMETERS\n", addr * 2 + channel * 0x200000, cmd, channel );
21702212            mcd212_set_display_parameters(channel, cmd & 0x1f);
21712213            break;
21722214         default:
r6064r6065
22342276    return (UINT8)in;
22352277}
22362278
2237INLINE UINT8 BYTE_TO_CLUT7(int channel, UINT8 byte)
2279INLINE UINT8 BYTE_TO_CLUT(int channel, UINT8 byte)
22382280{
2239   if(channel)
2281   UINT32 icm_mask = channel ? MCD212_ICM_MODE2 : MCD212_ICM_MODE1;
2282   UINT32 icm_shift = channel ? MCD212_ICM_MODE2_SHIFT : MCD212_ICM_MODE1_SHIFT;
2283   UINT8 icm = (mcd212.channel[0].image_coding_method & icm_mask) >> icm_shift;
2284
2285   switch(icm)
22402286   {
2241      return 0x80 + (byte & 0x7f);
2287      case 3:
2288         if(channel)
2289         {
2290            return 0x80 + (byte & 0x7f);
2291         }
2292         else
2293         {
2294            return byte & 0x7f;
2295         }
2296         break;
2297      case 11:
2298         if(channel)
2299         {
2300            return 0x80 + (byte & 0x0f);
2301         }
2302         else
2303         {
2304            return byte & 0x0f;
2305         }
2306         break;
2307      default:
2308         break;
22422309   }
2310   return 0;
2311}
2312
2313INLINE void mcd212_process_region(running_machine *machine, int channel, int x)
2314{
2315   if(mcd212.channel[0].image_coding_method & MCD212_ICM_NR)
2316   {
2317      int reg = 0;
2318      int flag = 0;
2319
2320      for(flag = 0; flag < 2; flag++)
2321      {
2322         for(reg = 0; reg < 4; reg++)
2323         {
2324            if(x == (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_X))
2325            {
2326               switch(mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_OP)
2327               {
2328                  case 0: // End of region control for line
2329                     break;
2330                  case 1:
2331                  case 2:
2332                  case 3: // Not used
2333                     break;
2334                  case 4: // Change weight of plane A
2335                     mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2336                     break;
2337                  case 5:   // Not used
2338                     break;
2339                  case 6: // Change weight of plane B
2340                     mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2341                     break;
2342                  case 7:   // Not used
2343                     break;
2344                  case 8: // Reset region flag
2345                     mcd212.region_flag[flag] = 0;
2346                     break;
2347                  case 9: // Set region flag
2348                     mcd212.region_flag[flag] = 1;
2349                     break;
2350                  case 10:   // Not used
2351                  case 11:   // Not used
2352                     break;
2353                  case 12: // Reset region flag and change weight of plane A
2354                     mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2355                     mcd212.region_flag[flag] = 0;
2356                     break;
2357                  case 13: // Set region flag and change weight of plane A
2358                     mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2359                     mcd212.region_flag[flag] = 1;
2360                     break;
2361                  case 14: // Reset region flag and change weight of plane B
2362                     mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2363                     mcd212.region_flag[flag] = 0;
2364                     break;
2365                  case 15: // Set region flag and change weight of plane B
2366                     mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[flag*4 + reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2367                     mcd212.region_flag[flag] = 1;
2368                     break;
2369               }
2370               break;
2371            }
2372         }
2373      }
2374   }
22432375   else
22442376   {
2245      return byte & 0x7f;
2377      int reg = 0;
2378      for(reg = 0; reg < 8; reg++)
2379      {
2380         int flag = (mcd212.channel[0].region_control[reg] & MCD212_RC_RF) >> MCD212_RC_RF_SHIFT;
2381         if((mcd212.channel[0].region_control[reg] & MCD212_RC_X) > x)
2382         {
2383            break;
2384         }
2385         if(x == (mcd212.channel[0].region_control[reg] & MCD212_RC_X))
2386         {
2387            switch((mcd212.channel[0].region_control[reg] & MCD212_RC_OP) >> MCD212_RC_OP_SHIFT)
2388            {
2389               case 0: // End of region control for line
2390                  break;
2391               case 1:
2392               case 2:
2393               case 3: // Not used
2394                  break;
2395               case 4: // Change weight of plane A
2396                  mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2397                  verboselog(machine, 0, "New weight factor A: %d\n", mcd212.channel[0].weight_factor_a);
2398                  break;
2399               case 5:   // Not used
2400                  break;
2401               case 6: // Change weight of plane B
2402                  mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2403                  verboselog(machine, 0, "New weight factor B: %d\n", mcd212.channel[1].weight_factor_b);
2404                  break;
2405               case 7:   // Not used
2406                  break;
2407               case 8: // Reset region flag
2408                  mcd212.region_flag[flag] = 0;
2409                  break;
2410               case 9: // Set region flag
2411                  mcd212.region_flag[flag] = 1;
2412                  break;
2413               case 10:   // Not used
2414               case 11:   // Not used
2415                  break;
2416               case 12: // Reset region flag and change weight of plane A
2417                  mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2418                  mcd212.region_flag[flag] = 0;
2419                  break;
2420               case 13: // Set region flag and change weight of plane A
2421                  mcd212.channel[0].weight_factor_a = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2422                  mcd212.region_flag[flag] = 1;
2423                  break;
2424               case 14: // Reset region flag and change weight of plane B
2425                  mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2426                  mcd212.region_flag[flag] = 0;
2427                  break;
2428               case 15: // Set region flag and change weight of plane B
2429                  mcd212.channel[1].weight_factor_b = (mcd212.channel[0].region_control[reg] & MCD212_RC_WF) >> MCD212_RC_WF_SHIFT;
2430                  mcd212.region_flag[flag] = 1;
2431                  break;
2432            }
2433            break;
2434         }
2435      }
22462436   }
22472437}
22482438
2249static void mcd212_process_vsr(running_machine *machine, int channel, UINT32 *pixels)
2439INLINE void mcd212_process_vsr(running_machine *machine, int channel, UINT32 *pixels)
22502440{
22512441   UINT8 *data = channel ? (UINT8*)planeb : (UINT8*)planea;
22522442   UINT32 vsr = mcd212_get_vsr(channel) & 0x0007ffff;
22532443   UINT8 done = 0;
22542444   int x = 0;
2255   UINT32 icm_mask = channel ? 0x00000f00 : 0x0000000f;
2256   UINT32 icm_shift = channel ? 8 : 0;
2445   UINT32 icm_mask = channel ? MCD212_ICM_MODE2 : MCD212_ICM_MODE1;
2446   UINT32 icm_shift = channel ? MCD212_ICM_MODE2_SHIFT : MCD212_ICM_MODE1_SHIFT;
22572447   UINT8 icm = (mcd212.channel[0].image_coding_method & icm_mask) >> icm_shift;
22582448
22592449   //printf( "vsr before: %08x: ", vsr );
r6064r6065
22632453   {
22642454      for(; x < 768; x++)
22652455      {
2266         pixels[x++] = 0;
2267         pixels[x] = 0;
2456         pixels[x++] = 0x00101010;
2457         pixels[x] = 0x00101010;
22682458      }
22692459      return;
22702460   }
r6064r6065
23482538                        pixels[x++] = (bR << 16) | (bG << 8) | bB;
23492539
23502540                        byte = data[vsr++ ^ 1];
2541
23512542                  }
23522543                  mcd212_set_vsr(channel, vsr - 1);
23532544               }
r6064r6065
23552546               {
23562547                  for(; x < 768; x++)
23572548                  {
2358                     pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte)];
2359                     pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT7(channel, byte)];
2549                     pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
2550                     pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
23602551                     byte = data[vsr++ ^ 1];
23612552                  }
23622553                  mcd212_set_vsr(channel, vsr - 1);
23632554               }
2555               else if(icm == 11)
2556               {
2557                  for(; x < 768; x++)
2558                  {
2559                     pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte >> 4)];
2560                     pixels[x]   = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
2561                     byte = data[vsr++ ^ 1];
2562                  }
2563                  mcd212_set_vsr(channel, vsr - 1);
2564               }
23642565               else
23652566               {
23662567                  for(; x < 768; x++)
r6064r6065
23752576         case MCD212_DDR_FT_RLE:
23762577            if(mcd212.channel[channel].dcr & MCD212_DCR_CM)
23772578            {
2378               // 4-bit RLE
23792579               verboselog(machine, 0, "Unsupported display mode: 4-bit RLE\n" );
23802580               done = 1;
23812581            }
23822582            else
23832583            {
2384               // 8-bit RLE
23852584               if(byte & 0x80)
23862585               {
23872586                  // Run length
23882587                  UINT8 length = data[vsr++ ^ 1];
2389                  //printf( "%02x ", length );
2390                  //fflush(stdout);
23912588                  if(!length)
23922589                  {
23932590                     // Go to the end of the line
23942591                     for(; x < 768; x++)
23952592                     {
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)];
2593                        pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
2594                        pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
23982595                     }
23992596                     done = 1;
24002597                     mcd212_set_vsr(channel, vsr);
r6064r6065
24022599                  else
24032600                  {
24042601                     int end = x + (length * 2);
2405                     //printf( "x = %d length = %d end = %d\n", x, length * 2, end);
2406                     //fflush(stdout);
24072602                     for(; x < end && x < 768; x++)
24082603                     {
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)];
2604                        pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
2605                        pixels[x] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
24112606                     }
24122607                     if(x >= 768)
24132608                     {
r6064r6065
24192614               else
24202615               {
24212616                  // Single pixel
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)];
2617                  pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
2618                  pixels[x++] = mcd212.channel[0].clut[BYTE_TO_CLUT(channel, byte)];
24242619                  if(x >= 768)
24252620                  {
24262621                     done = 1;
r6064r6065
24462641   0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff
24472642};
24482643
2449static void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y)
2644INLINE void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y)
24502645{
24512646   if(mcd212.channel[0].cursor_control & MCD212_CURCNT_EN)
24522647   {
r6064r6065
24922687   }
24932688}
24942689
2495static void mcd212_mix_lines(running_machine *machine, UINT32 *plane_a, UINT32 *plane_b, UINT32 *out)
2690INLINE void mcd212_mix_lines(running_machine *machine, UINT32 *plane_a, UINT32 *plane_b, UINT32 *out)
24962691{
24972692   int x = 0;
24982693   UINT32 backdrop = mcd212_4bpp_color[mcd212.channel[0].backdrop_color];
24992694   for(x = 0; x < 768; x++)
25002695   {
25012696      out[x] = backdrop;
2697      mcd212_process_region(machine, 0, x);
2698      mcd212_process_region(machine, 1, x);
25022699      if(!(mcd212.channel[0].transparency_control & MCD212_TCR_DISABLE_MX))
25032700      {
25042701         INT32 weight_a = mcd212.channel[0].weight_factor_a;
r6064r6065
25422739                     plane_enable[index] = 1;
25432740                  }
25442741                  break;
2742               case 5:
2743                  // Todo
2744                  if(plane[x] != transparent_color)
2745                  {
2746                     plane_enable[index] = 1;
2747                  }
2748                  break;
25452749               case 8:
25462750                  plane_enable[index] = 1;
25472751                  break;
r6064r6065
25532757                  break;
25542758               default:
25552759                  verboselog(machine, 0, "Unhandled transparency mode for plane %c: %d\n", index ? 'B' : 'A', transparency_mode[index]);
2760                  plane_enable[index] = 1;
25562761                  break;
25572762            }
25582763         }
r6064r6065
26102815      {
26112816         // Process ICA
26122817         int index = 0;
2613         verboselog(machine, 0, "FRAME START\n" );
2818         verboselog(machine, 6, "Frame Start\n" );
26142819         mcd212.channel[0].csrr &= 0x7f;
26152820         for(index = 0; index < 2; index++)
26162821         {

Previous 15994 Revisions Next


© 1998-2018 The MESS Team