Previous 15994 Revisions Next

r14912 Saturday 14th April, 2012 at 12:18:47 UTC by Wilbert Pol
[SMS] Prevent a crash in sms1pal and some optimizations. [Enik Land]
[src/mess/drivers]sms.c
[src/mess/includes]sms.h
[src/mess/machine]sms.c

src/mess/machine/sms.c
r14911r14912
734734WRITE8_HANDLER( sms_io_control_w )
735735{
736736   sms_state *state = space->machine().driver_data<sms_state>();
737   bool hcount_latch = false;
737738
738739   if (data & 0x08)
739740   {
740741      /* check if TH pin level is high (1) and was low last time */
741742      if (data & 0x80 && !(state->m_ctrl_reg & 0x80))
742743      {
743         sms_vdp_hcount_latch(space);
744         hcount_latch = true;
744745      }
745746      sms_input_write(space, 0, (data & 0x20) >> 5);
746747   }
r14911r14912
749750   {
750751      if (data & 0x20 && !(state->m_ctrl_reg & 0x20))
751752      {
752         sms_vdp_hcount_latch(space);
753         hcount_latch = true;
753754      }
754755      sms_input_write(space, 1, (data & 0x80) >> 7);
755756   }
756757
758   if (hcount_latch)
759   {
760      sms_vdp_hcount_latch(space);
761   }
762
757763   state->m_ctrl_reg = data;
758764}
759765
r14911r14912
22132219}
22142220
22152221
2216static void sms_black_bitmap( const screen_device &screen, bitmap_rgb32 &bitmap )
2217{
2218   const int width = screen.width();
2219   const int height = screen.height();
2220   int x, y;
2221
2222   for (y = 0; y < height; y++)
2223      for (x = 0; x < width; x++)
2224         bitmap.pix32(y, x) = MAKE_RGB(0,0,0);
2225}
2226
22272222VIDEO_START( sms1 )
22282223{
22292224   sms_state *state = machine.driver_data<sms_state>();
r14911r14912
22382233SCREEN_UPDATE_RGB32( sms1 )
22392234{
22402235   sms_state *state = screen.machine().driver_data<sms_state>();
2241   UINT8 sscope = input_port_read_safe(screen.machine(), "SEGASCOPE", 0x00);
2242   UINT8 sscope_binocular_hack = input_port_read_safe(screen.machine(), "SSCOPE_BINOCULAR", 0x00);
2236   UINT8 sscope = 0;
2237   UINT8 sscope_binocular_hack;
22432238   UINT8 occluded_view = 0;
22442239
2245   // without SegaScope, both LCDs for glasses go black
2246   if ((&screen != state->m_main_scr) && !sscope)
2247      occluded_view = 1;
2240   if (&screen != state->m_main_scr)
2241   {
2242      sscope = input_port_read_safe(screen.machine(), "SEGASCOPE", 0x00);
2243      if (!sscope)
2244      {
2245         occluded_view = 1;
2246      }
2247      else if (&screen == state->m_left_lcd)
2248      {
2249         // with SegaScope, sscope_state 0 = left screen OFF, right screen ON
2250         if (!(state->m_sscope_state & 0x01))
2251            occluded_view = 1;
2252      }
2253      else // it's right LCD
2254      {
2255         // with SegaScope, sscope_state 1 = left screen ON, right screen OFF
2256         if (state->m_sscope_state & 0x01)
2257            occluded_view = 1;
2258      }
2259   }
22482260
2249   // with SegaScope, sscope_state 0 = left screen OFF, right screen ON
2250   if (!(state->m_sscope_state & 0x01) && (&screen == state->m_left_lcd))
2251      occluded_view = 1;
2252
2253   // with SegaScope, sscope_state 1 = left screen ON, right screen OFF
2254   if ((state->m_sscope_state & 0x01) && (&screen == state->m_right_lcd))
2255      occluded_view = 1;
2256
22572261   if (!occluded_view)
22582262   {
22592263      state->m_vdp->screen_update(screen, bitmap, cliprect);
22602264
22612265      // HACK: fake 3D->2D handling (if enabled, it repeats each frame twice on the selected lens)
22622266      // save a copy of current bitmap for the binocular hack
2263      if (sscope && (&screen == state->m_left_lcd) && (sscope_binocular_hack & 0x01))
2264         copybitmap(state->m_prevleft_bitmap, bitmap, 0, 0, 0, 0, cliprect);
2265      if (sscope && (&screen == state->m_right_lcd) && (sscope_binocular_hack & 0x02))
2266         copybitmap(state->m_prevright_bitmap, bitmap, 0, 0, 0, 0, cliprect);
2267      if (sscope)
2268      {
2269         sscope_binocular_hack = input_port_read_safe(screen.machine(), "SSCOPE_BINOCULAR", 0x00);
2270
2271         if (&screen == state->m_left_lcd)
2272         {
2273            if (sscope_binocular_hack & 0x01)
2274               copybitmap(state->m_prevleft_bitmap, bitmap, 0, 0, 0, 0, cliprect);
2275         }
2276         else // it's right LCD
2277         {
2278            if (sscope_binocular_hack & 0x02)
2279               copybitmap(state->m_prevright_bitmap, bitmap, 0, 0, 0, 0, cliprect);
2280         }
2281      }
22672282   }
22682283   else
22692284   {
2270      sms_black_bitmap(screen, bitmap);
2271
22722285      // HACK: fake 3D->2D handling (if enabled, it repeats each frame twice on the selected lens)
22732286      // use the copied bitmap for the binocular hack
2274      if (sscope && (&screen == state->m_left_lcd) && (sscope_binocular_hack & 0x01))
2275         copybitmap(bitmap, state->m_prevleft_bitmap, 0, 0, 0, 0, cliprect);
2276      if (sscope && (&screen == state->m_right_lcd) && (sscope_binocular_hack & 0x02))
2277         copybitmap(bitmap, state->m_prevright_bitmap, 0, 0, 0, 0, cliprect);
2287      if (sscope)
2288      {
2289         sscope_binocular_hack = input_port_read_safe(screen.machine(), "SSCOPE_BINOCULAR", 0x00);
2290
2291         if (&screen == state->m_left_lcd)
2292         {
2293            if (sscope_binocular_hack & 0x01)
2294            {
2295               copybitmap(bitmap, state->m_prevleft_bitmap, 0, 0, 0, 0, cliprect);
2296               return 0;
2297            }
2298         }
2299         else // it's right LCD
2300         {
2301            if (sscope_binocular_hack & 0x02)
2302            {
2303               copybitmap(bitmap, state->m_prevright_bitmap, 0, 0, 0, 0, cliprect);
2304               return 0;
2305            }
2306         }
2307      }
2308      bitmap.fill(RGB_BLACK);
22782309   }
22792310
22802311   return 0;
r14911r14912
22932324   screen_device *screen = machine.first_screen();
22942325
22952326   screen->register_screen_bitmap(state->m_prev_bitmap);
2296   screen->register_screen_bitmap(state->m_tmp_bitmap);
22972327   state->save_item(NAME(state->m_prev_bitmap));
22982328}
22992329
r14911r14912
23042334   int height = screen.height();
23052335   int x, y;
23062336
2307   state->m_vdp->screen_update(screen, state->m_tmp_bitmap, cliprect);
2337   bitmap_rgb32 &vdp_bitmap = state->m_vdp->get_bitmap();
23082338
23092339   // HACK: fake LCD persistence effect
23102340   // (it would be better to generalize this in the core, to be used for all LCD systems)
23112341   for (y = 0; y < height; y++)
23122342   {
2313      UINT32 *line0 = &state->m_tmp_bitmap.pix32(y);
2343      UINT32 *linedst = &bitmap.pix32(y);
2344      UINT32 *line0 = &vdp_bitmap.pix32(y);
23142345      UINT32 *line1 = &state->m_prev_bitmap.pix32(y);
23152346      for (x = 0; x < width; x++)
23162347      {
r14911r14912
23252356         UINT8 r = (UINT8)((r0 + r1) >> 1);
23262357         UINT8 g = (UINT8)((g0 + g1) >> 1);
23272358         UINT8 b = (UINT8)((b0 + b1) >> 1);
2328         bitmap.pix32(y, x) = (r << 16) | (g << 8) | b;
2359         linedst[x] = (r << 16) | (g << 8) | b;
23292360      }
23302361   }
2331   copybitmap(state->m_prev_bitmap, state->m_tmp_bitmap, 0, 0, 0, 0, cliprect);
2362   copybitmap(state->m_prev_bitmap, vdp_bitmap, 0, 0, 0, 0, cliprect);
23322363
23332364   return 0;
23342365}
src/mess/includes/sms.h
r14911r14912
5959   UINT8 m_input_port1;
6060
6161   // for gamegear LCD persistence hack
62   bitmap_rgb32 m_tmp_bitmap;
6362   bitmap_rgb32 m_prev_bitmap;
6463
6564   // for 3D glass binocular hack
src/mess/drivers/sms.c
r14911r14912
531531
532532   MCFG_DEFAULT_LAYOUT(layout_sms1)
533533
534   MCFG_VIDEO_START(sms1)
535
534536   MCFG_SEGA315_5124_ADD("sms_vdp", _315_5124_pal_intf)
535537MACHINE_CONFIG_END
536538

Previous 15994 Revisions Next


© 1998-2018 The MESS Team