Previous 199869 Revisions Next

r20723 Monday 4th February, 2013 at 09:57:26 UTC by Robbbert
cps modernisation part 1
[src/mame/drivers]cps2.c
[src/mame/includes]cps1.h
[src/mame/video]cps1.c

trunk/src/mame/includes/cps1.h
r20722r20723
258258   DECLARE_WRITE16_MEMBER(sf2mdta_layer_w);
259259   UINT32 screen_update_fcrash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
260260   void cps1_get_video_base();
261   void cps1_gfx_decode();
262   void unshuffle(UINT64 *buf, int len);
263   void cps2_gfx_decode();
264   int gfxrom_bank_mapper(int type, int code);
265   void cps1_update_transmasks();
266   void cps1_build_palette(const UINT16* const palette_base);
267   void cps1_find_last_sprite();
268   void cps1_render_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
269   void cps2_find_last_sprite();
270   void cps2_render_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks);
271   void cps1_render_stars(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
272   void cps1_render_layer(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int primask);
273   void cps1_render_high_layer(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer);
274   void cps2_set_sprite_priorities();
275   void cps2_objram_latch();
276   UINT16 *cps2_objbase();
277
278
261279};
262280
263281/*----------- defined in drivers/cps1.c -----------*/
trunk/src/mame/video/cps1.c
r20722r20723
14931493#define CPS2_OBJ_YOFFS  0x0a    /* Y offset (always 0x0010) */
14941494
14951495
1496static void cps1_build_palette(running_machine &machine, const UINT16* const palette_base);
1497
1498
14991496MACHINE_RESET_MEMBER(cps_state,cps)
15001497{
15011498   const char *gamename = machine().system().name;
r20722r20723
15811578   fixes glitches in the ghouls intro, but it might happen at next vblank.
15821579   */
15831580   if (offset == CPS1_PALETTE_BASE)
1584      cps1_build_palette(machine(), cps1_base(machine(), CPS1_PALETTE_BASE, m_palette_align));
1581      cps1_build_palette(cps1_base(machine(), CPS1_PALETTE_BASE, m_palette_align));
15851582
15861583   // pzloop2 write to register 24 on startup. This is probably just a bug.
15871584   if (offset == 0x24 / 2 && m_cps_version == 2)
r20722r20723
17021699
17031700
17041701
1705INLINE int cps2_port( running_machine &machine, int offset )
1702void cps_state::cps1_gfx_decode()
17061703{
1707   cps_state *state = machine.driver_data<cps_state>();
1708   return state->m_output[offset / 2];
1709}
1710
1711
1712static void cps1_gfx_decode( running_machine &machine )
1713{
1714   int size = machine.root_device().memregion("gfx")->bytes();
1704   int size = memregion("gfx")->bytes();
17151705   int i, j, gfxsize;
1716   UINT8 *cps1_gfx = machine.root_device().memregion("gfx")->base();
1706   UINT8 *cps1_gfx = memregion("gfx")->base();
17171707
17181708   gfxsize = size / 4;
17191709
r20722r20723
17411731   }
17421732}
17431733
1744static void unshuffle( UINT64 *buf, int len )
1734void cps_state::unshuffle( UINT64 *buf, int len )
17451735{
17461736   int i;
17471737   UINT64 t;
r20722r20723
17641754   }
17651755}
17661756
1767static void cps2_gfx_decode( running_machine &machine )
1757void cps_state::cps2_gfx_decode()
17681758{
17691759   const int banksize = 0x200000;
1770   int size = machine.root_device().memregion("gfx")->bytes();
1760   int size = memregion("gfx")->bytes();
17711761   int i;
17721762
17731763   for (i = 0; i < size; i += banksize)
1774      unshuffle((UINT64 *)(machine.root_device().memregion("gfx")->base() + i), banksize / 8);
1764      unshuffle((UINT64 *)(memregion("gfx")->base() + i), banksize / 8);
17751765
1776   cps1_gfx_decode(machine);
1766   cps1_gfx_decode();
17771767}
17781768
17791769
17801770DRIVER_INIT_MEMBER(cps_state,cps1)
17811771{
1782   cps1_gfx_decode(machine());
1772   cps1_gfx_decode();
17831773
17841774   m_scanline1 = 0;
17851775   m_scanline2 = 0;
r20722r20723
17931783
17941784DRIVER_INIT_MEMBER(cps_state,cps2_video)
17951785{
1796   cps2_gfx_decode(machine());
1786   cps2_gfx_decode();
17971787
17981788   m_scanline1 = 262;
17991789   m_scanline2 = 262;
r20722r20723
19141904
19151905
19161906
1917static int gfxrom_bank_mapper( running_machine &machine, int type, int code )
1907int cps_state::gfxrom_bank_mapper( int type, int code )
19181908{
1919   cps_state *state = machine.driver_data<cps_state>();
1920   const struct gfx_range *range = state->m_game_config->bank_mapper;
1909   const struct gfx_range *range = m_game_config->bank_mapper;
19211910   int shift = 0;
19221911
19231912   assert(range);
r20722r20723
19421931            int i;
19431932
19441933            for (i = 0; i < range->bank; ++i)
1945               base += state->m_game_config->bank_sizes[i];
1934               base += m_game_config->bank_sizes[i];
19461935
1947            return (base + (code & (state->m_game_config->bank_sizes[range->bank] - 1))) >> shift;
1936            return (base + (code & (m_game_config->bank_sizes[range->bank] - 1))) >> shift;
19481937         }
19491938      }
19501939
r20722r20723
19891978   int attr = m_scroll1[2 * tile_index + 1];
19901979   int gfxset;
19911980
1992   code = gfxrom_bank_mapper(machine(), GFXTYPE_SCROLL1, code);
1981   code = gfxrom_bank_mapper(GFXTYPE_SCROLL1, code);
19931982
19941983   /* allows us to reproduce a problem seen with a ffight board where USA and Japanese
19951984        roms have been mixed to be reproduced (ffightub) -- it looks like each column
r20722r20723
20142003   int code = m_scroll2[2 * tile_index];
20152004   int attr = m_scroll2[2 * tile_index + 1];
20162005
2017   code = gfxrom_bank_mapper(machine(), GFXTYPE_SCROLL2, code);
2006   code = gfxrom_bank_mapper(GFXTYPE_SCROLL2, code);
20182007
20192008   SET_TILE_INFO_MEMBER(
20202009         2,
r20722r20723
20332022   int code = m_scroll3[2 * tile_index] & 0x3fff;
20342023   int attr = m_scroll3[2 * tile_index + 1];
20352024
2036   code = gfxrom_bank_mapper(machine(), GFXTYPE_SCROLL3, code);
2025   code = gfxrom_bank_mapper(GFXTYPE_SCROLL3, code);
20372026
20382027   SET_TILE_INFO_MEMBER(
20392028         3,
r20722r20723
20502039
20512040
20522041
2053static void cps1_update_transmasks( running_machine &machine )
2042void cps_state::cps1_update_transmasks()
20542043{
2055   cps_state *state = machine.driver_data<cps_state>();
20562044   int i;
20572045
20582046   for (i = 0; i < 4; i++)
r20722r20723
20602048      int mask;
20612049
20622050      /* Get transparency registers */
2063      if (state->m_game_config->priority[i] != -1)
2064         mask = state->m_cps_b_regs[state->m_game_config->priority[i] / 2] ^ 0xffff;
2051      if (m_game_config->priority[i] != -1)
2052         mask = m_cps_b_regs[m_game_config->priority[i] / 2] ^ 0xffff;
20652053      else
20662054         mask = 0xffff;  /* completely transparent if priority masks not defined (qad) */
20672055
2068      state->m_bg_tilemap[0]->set_transmask(i, mask, 0x8000);
2069      state->m_bg_tilemap[1]->set_transmask(i, mask, 0x8000);
2070      state->m_bg_tilemap[2]->set_transmask(i, mask, 0x8000);
2056      m_bg_tilemap[0]->set_transmask(i, mask, 0x8000);
2057      m_bg_tilemap[1]->set_transmask(i, mask, 0x8000);
2058      m_bg_tilemap[2]->set_transmask(i, mask, 0x8000);
20712059   }
20722060}
20732061
r20722r20723
20952083   memset(m_empty_tile, 0x0f, sizeof(m_empty_tile));
20962084
20972085   /* front masks will change at runtime to handle sprite occluding */
2098   cps1_update_transmasks(machine());
2086   cps1_update_transmasks();
20992087
21002088   for (i = 0; i < cps1_palette_entries * 16; i++)
21012089      palette_set_color(machine(), i, MAKE_RGB(0,0,0));
r20722r20723
21882176
21892177***************************************************************************/
21902178
2191static void cps1_build_palette( running_machine &machine, const UINT16* const palette_base )
2179void cps_state::cps1_build_palette( const UINT16* const palette_base )
21922180{
2193   cps_state *state = machine.driver_data<cps_state>();
21942181   int offset, page;
21952182   const UINT16 *palette_ram = palette_base;
2196   int ctrl = state->m_cps_b_regs[state->m_game_config->palette_control/2];
2183   int ctrl = m_cps_b_regs[m_game_config->palette_control/2];
21972184
21982185   /*
21992186   The palette is copied only for pages that are enabled in the ctrl
r20722r20723
22182205            g = ((palette >> 4) & 0x0f) * 0x11 * bright / 0x2d;
22192206            b = ((palette >> 0) & 0x0f) * 0x11 * bright / 0x2d;
22202207
2221            palette_set_color (machine, 0x200 * page + offset, MAKE_RGB(r, g, b));
2208            palette_set_color (machine(), 0x200 * page + offset, MAKE_RGB(r, g, b));
22222209         }
22232210      }
22242211      else
r20722r20723
22662253
22672254***************************************************************************/
22682255
2269static void cps1_find_last_sprite( running_machine &machine )    /* Find the offset of last sprite */
2256void cps_state::cps1_find_last_sprite()    /* Find the offset of last sprite */
22702257{
2271   cps_state *state = machine.driver_data<cps_state>();
22722258   int offset = 0;
22732259   /* Locate the end of table marker */
2274   while (offset < state->m_obj_size / 2)
2260   while (offset < m_obj_size / 2)
22752261   {
2276      int colour = state->m_buffered_obj[offset + 3];
2262      int colour = m_buffered_obj[offset + 3];
22772263      if ((colour & 0xff00) == 0xff00)
22782264      {
22792265         /* Marker found. This is the last sprite. */
2280         state->m_last_sprite_offset = offset - 4;
2266         m_last_sprite_offset = offset - 4;
22812267         return;
22822268      }
22832269
22842270      offset += 4;
22852271   }
22862272   /* Sprites must use full sprite RAM */
2287   state->m_last_sprite_offset = state->m_obj_size / 2 - 4;
2273   m_last_sprite_offset = m_obj_size / 2 - 4;
22882274}
22892275
22902276
2291static void cps1_render_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect )
2277void cps_state::cps1_render_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
22922278{
2293   cps_state *state = machine.driver_data<cps_state>();
22942279
22952280#define DRAWSPRITE(CODE,COLOR,FLIPX,FLIPY,SX,SY)                    \
22962281{                                                                   \
2297   if (state->flip_screen())                                           \
2282   if (flip_screen())                                           \
22982283      pdrawgfx_transpen(bitmap,\
2299            cliprect,machine.gfx[2],                            \
2284            cliprect,machine().gfx[2],                            \
23002285            CODE,                                               \
23012286            COLOR,                                              \
23022287            !(FLIPX),!(FLIPY),                                  \
2303            511-16-(SX),255-16-(SY),    machine.priority_bitmap,0x02,15);                   \
2288            511-16-(SX),255-16-(SY),    machine().priority_bitmap,0x02,15);                   \
23042289   else                                                            \
23052290      pdrawgfx_transpen(bitmap,\
2306            cliprect,machine.gfx[2],                            \
2291            cliprect,machine().gfx[2],                            \
23072292            CODE,                                               \
23082293            COLOR,                                              \
23092294            FLIPX,FLIPY,                                        \
2310            SX,SY,              machine.priority_bitmap,0x02,15);                   \
2295            SX,SY, machine().priority_bitmap,0x02,15);          \
23112296}
23122297
23132298
23142299   int i, baseadd;
2315   UINT16 *base = state->m_buffered_obj;
2300   UINT16 *base = m_buffered_obj;
23162301
23172302   /* some sf2 hacks draw the sprites in reverse order */
2318   if (state->m_game_config->bootleg_kludge == 1)
2303   if (m_game_config->bootleg_kludge == 1)
23192304   {
2320      base += state->m_last_sprite_offset;
2305      base += m_last_sprite_offset;
23212306      baseadd = -4;
23222307   }
23232308   else
r20722r20723
23252310      baseadd = 4;
23262311   }
23272312
2328   for (i = state->m_last_sprite_offset; i >= 0; i -= 4)
2313   for (i = m_last_sprite_offset; i >= 0; i -= 4)
23292314   {
23302315      int x = *(base + 0);
23312316      int y = *(base + 1);
r20722r20723
23362321//      x -= 0x20;
23372322//      y += 0x20;
23382323
2339      code = gfxrom_bank_mapper(machine, GFXTYPE_SPRITES, code);
2324      code = gfxrom_bank_mapper(GFXTYPE_SPRITES, code);
23402325
23412326      if (code != -1)
23422327      {
r20722r20723
24852470      COMBINE_DATA(&m_objram2[offset]);
24862471}
24872472
2488static UINT16 *cps2_objbase( running_machine &machine )
2473UINT16 *cps_state::cps2_objbase()
24892474{
2490   cps_state *state = machine.driver_data<cps_state>();
24912475   int baseptr;
24922476   baseptr = 0x7000;
24932477
2494   if (state->m_objram_bank & 1)
2478   if (m_objram_bank & 1)
24952479      baseptr ^= 0x0080;
24962480
24972481//popmessage("%04x %d", cps2_port(machine, CPS2_OBJ_BASE), state->m_objram_bank & 1);
24982482
24992483   if (baseptr == 0x7000)
2500      return state->m_objram1;
2484      return m_objram1;
25012485   else //if (baseptr == 0x7080)
2502      return state->m_objram2;
2486      return m_objram2;
25032487}
25042488
25052489
2506static void cps2_find_last_sprite( running_machine &machine )    /* Find the offset of last sprite */
2490void cps_state::cps2_find_last_sprite()    /* Find the offset of last sprite */
25072491{
2508   cps_state *state = machine.driver_data<cps_state>();
25092492   int offset = 0;
2510   UINT16 *base = state->m_cps2_buffered_obj;
2493   UINT16 *base = m_cps2_buffered_obj;
25112494
25122495   /* Locate the end of table marker */
2513   while (offset < state->m_cps2_obj_size / 2)
2496   while (offset < m_cps2_obj_size / 2)
25142497   {
25152498      if (base[offset + 1] >= 0x8000 || base[offset + 3] >= 0xff00)
25162499      {
25172500         /* Marker found. This is the last sprite. */
2518         state->m_cps2_last_sprite_offset = offset - 4;
2501         m_cps2_last_sprite_offset = offset - 4;
25192502         return;
25202503      }
25212504
25222505      offset += 4;
25232506   }
25242507   /* Sprites must use full sprite RAM */
2525   state->m_cps2_last_sprite_offset = state->m_cps2_obj_size / 2 - 4;
2508   m_cps2_last_sprite_offset = m_cps2_obj_size / 2 - 4;
25262509}
25272510
2528static void cps2_render_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks )
2511void cps_state::cps2_render_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int *primasks )
25292512{
2530   cps_state *state = machine.driver_data<cps_state>();
25312513
25322514#define DRAWSPRITE(CODE,COLOR,FLIPX,FLIPY,SX,SY)                                    \
25332515{                                                                                   \
2534   if (state->flip_screen())                                                           \
2516   if (flip_screen())                                                           \
25352517      pdrawgfx_transpen(bitmap,\
2536            cliprect,machine.gfx[2],                                            \
2518            cliprect,machine().gfx[2],                                            \
25372519            CODE,                                                               \
25382520            COLOR,                                                              \
25392521            !(FLIPX),!(FLIPY),                                                  \
2540            511-16-(SX),255-16-(SY),                machine.priority_bitmap,primasks[priority],15);                 \
2522            511-16-(SX),255-16-(SY), machine().priority_bitmap,primasks[priority],15);                 \
25412523   else                                                                            \
25422524      pdrawgfx_transpen(bitmap,\
2543            cliprect,machine.gfx[2],                                            \
2525            cliprect,machine().gfx[2],                                            \
25442526            CODE,                                                               \
25452527            COLOR,                                                              \
25462528            FLIPX,FLIPY,                                                        \
2547            SX,SY,                          machine.priority_bitmap,primasks[priority],15);                 \
2529            SX,SY, machine().priority_bitmap,primasks[priority],15);                 \
25482530}
25492531
25502532   int i;
2551   UINT16 *base = state->m_cps2_buffered_obj;
2552   int xoffs = 64 - cps2_port(machine, CPS2_OBJ_XOFFS);
2553   int yoffs = 16 - cps2_port(machine, CPS2_OBJ_YOFFS);
2533   UINT16 *base = m_cps2_buffered_obj;
2534   int xoffs = 64 - m_output[CPS2_OBJ_XOFFS /2];
2535   int yoffs = 16 - m_output[CPS2_OBJ_YOFFS /2];
25542536
25552537#ifdef MAME_DEBUG
2556   if (machine.input().code_pressed(KEYCODE_Z) && machine.input().code_pressed(KEYCODE_R))
2538   if (machine().input().code_pressed(KEYCODE_Z) && machine().input().code_pressed(KEYCODE_R))
25572539   {
25582540      return;
25592541   }
25602542#endif
25612543
2562   for (i = state->m_cps2_last_sprite_offset; i >= 0; i -= 4)
2544   for (i = m_cps2_last_sprite_offset; i >= 0; i -= 4)
25632545   {
25642546      int x = base[i + 0];
25652547      int y = base[i + 1];
r20722r20723
25702552
25712553      if (colour & 0x80)
25722554      {
2573         x += cps2_port(machine, CPS2_OBJ_XOFFS);  /* fix the offset of some games */
2574         y += cps2_port(machine, CPS2_OBJ_YOFFS);  /* like Marvel vs. Capcom ending credits */
2555         x += m_output[CPS2_OBJ_XOFFS /2];  /* fix the offset of some games */
2556         y += m_output[CPS2_OBJ_YOFFS /2];  /* like Marvel vs. Capcom ending credits */
25752557      }
25762558
25772559      if (colour & 0xff00)
r20722r20723
26742656
26752657
26762658
2677static void cps1_render_stars( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
2659void cps_state::cps1_render_stars( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
26782660{
2679   cps_state *state = screen.machine().driver_data<cps_state>();
26802661   int offs;
2681   UINT8 *stars_rom = state->memregion("stars")->base();
2662   UINT8 *stars_rom = memregion("stars")->base();
26822663
2683   if (!stars_rom && (state->m_stars_enabled[0] || state->m_stars_enabled[1]))
2664   if (!stars_rom && (m_stars_enabled[0] || m_stars_enabled[1]))
26842665   {
26852666#ifdef MAME_DEBUG
26862667//      popmessage("stars enabled but no stars ROM");
r20722r20723
26882669      return;
26892670   }
26902671
2691   if (state->m_stars_enabled[0])
2672   if (m_stars_enabled[0])
26922673   {
2693      for (offs = 0; offs < state->m_stars_rom_size / 2; offs++)
2674      for (offs = 0; offs < m_stars_rom_size / 2; offs++)
26942675      {
26952676         int col = stars_rom[8 * offs + 4];
26962677         if (col != 0x0f)
26972678         {
26982679            int sx = (offs / 256) * 32;
26992680            int sy = (offs % 256);
2700            sx = (sx - state->m_stars2x + (col & 0x1f)) & 0x1ff;
2701            sy = (sy - state->m_stars2y) & 0xff;
2702            if (state->flip_screen())
2681            sx = (sx - m_stars2x + (col & 0x1f)) & 0x1ff;
2682            sy = (sy - m_stars2y) & 0xff;
2683            if (flip_screen())
27032684            {
27042685               sx = 511 - sx;
27052686               sy = 255 - sy;
r20722r20723
27132694      }
27142695   }
27152696
2716   if (state->m_stars_enabled[1])
2697   if (m_stars_enabled[1])
27172698   {
2718      for (offs = 0; offs < state->m_stars_rom_size / 2; offs++)
2699      for (offs = 0; offs < m_stars_rom_size / 2; offs++)
27192700      {
27202701         int col = stars_rom[8*offs];
27212702         if (col != 0x0f)
27222703         {
27232704            int sx = (offs / 256) * 32;
27242705            int sy = (offs % 256);
2725            sx = (sx - state->m_stars1x + (col & 0x1f)) & 0x1ff;
2726            sy = (sy - state->m_stars1y) & 0xff;
2727            if (state->flip_screen())
2706            sx = (sx - m_stars1x + (col & 0x1f)) & 0x1ff;
2707            sy = (sy - m_stars1y) & 0xff;
2708            if (flip_screen())
27282709            {
27292710               sx = 511 - sx;
27302711               sy = 255 - sy;
r20722r20723
27402721}
27412722
27422723
2743static void cps1_render_layer( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int primask )
2724void cps_state::cps1_render_layer( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int primask )
27442725{
2745   cps_state *state = machine.driver_data<cps_state>();
27462726   switch (layer)
27472727   {
27482728      case 0:
2749         cps1_render_sprites(machine, bitmap, cliprect);
2729         cps1_render_sprites(bitmap, cliprect);
27502730         break;
27512731      case 1:
27522732      case 2:
27532733      case 3:
2754         state->m_bg_tilemap[layer - 1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, primask);
2734         m_bg_tilemap[layer - 1]->draw(bitmap, cliprect, TILEMAP_DRAW_LAYER1, primask);
27552735         break;
27562736   }
27572737}
27582738
2759static void cps1_render_high_layer( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer )
2739void cps_state::cps1_render_high_layer( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer )
27602740{
2761   cps_state *state = machine.driver_data<cps_state>();
27622741   bitmap_ind16 dummy_bitmap;
27632742   switch (layer)
27642743   {
r20722r20723
27682747      case 1:
27692748      case 2:
27702749      case 3:
2771         state->m_bg_tilemap[layer - 1]->draw(dummy_bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
2750         m_bg_tilemap[layer - 1]->draw(dummy_bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
27722751         break;
27732752   }
27742753}
r20722r20723
27932772   cps1_get_video_base();
27942773
27952774   /* Find the offset of the last sprite in the sprite table */
2796   cps1_find_last_sprite(machine());
2775   cps1_find_last_sprite();
27972776
27982777   if (m_cps_version == 2)
2799   {
2800      cps2_find_last_sprite(machine());
2801   }
2778      cps2_find_last_sprite();
28022779
2803   cps1_update_transmasks(machine());
2780   cps1_update_transmasks();
28042781
28052782   m_bg_tilemap[0]->set_scrollx(0, m_scroll1x);
28062783   m_bg_tilemap[0]->set_scrolly(0, m_scroll1y);
r20722r20723
28562833
28572834   if (m_cps_version == 1)
28582835   {
2859      cps1_render_layer(machine(), bitmap, cliprect, l0, 0);
2836      cps1_render_layer(bitmap, cliprect, l0, 0);
28602837
28612838      if (l1 == 0)
2862         cps1_render_high_layer(machine(), bitmap, cliprect, l0); /* prepare mask for sprites */
2839         cps1_render_high_layer(bitmap, cliprect, l0); /* prepare mask for sprites */
28632840
2864      cps1_render_layer(machine(), bitmap, cliprect, l1, 0);
2841      cps1_render_layer(bitmap, cliprect, l1, 0);
28652842
28662843      if (l2 == 0)
2867         cps1_render_high_layer(machine(), bitmap, cliprect, l1); /* prepare mask for sprites */
2844         cps1_render_high_layer(bitmap, cliprect, l1); /* prepare mask for sprites */
28682845
2869      cps1_render_layer(machine(), bitmap, cliprect, l2, 0);
2846      cps1_render_layer(bitmap, cliprect, l2, 0);
28702847
28712848      if (l3 == 0)
2872         cps1_render_high_layer(machine(), bitmap, cliprect, l2); /* prepare mask for sprites */
2849         cps1_render_high_layer(bitmap, cliprect, l2); /* prepare mask for sprites */
28732850
2874      cps1_render_layer(machine(), bitmap, cliprect, l3, 0);
2851      cps1_render_layer(bitmap, cliprect, l3, 0);
28752852   }
28762853   else
28772854   {
r20722r20723
28832860      l3pri = (m_pri_ctrl >> 4 * l3) & 0x0f;
28842861
28852862#if 0
2886if (    (cps2_port(machine(), CPS2_OBJ_BASE) != 0x7080 && cps2_port(machine(), CPS2_OBJ_BASE) != 0x7000) ||
2887      cps2_port(machine(), CPS2_OBJ_UK1) != 0x807d ||
2888      (cps2_port(machine(), CPS2_OBJ_UK2) != 0x0000 && cps2_port(machine(), CPS2_OBJ_UK2) != 0x1101 && cps2_port(machine(), CPS2_OBJ_UK2) != 0x0001))
2863if (    (m_output[CPS2_OBJ_BASE /2] != 0x7080 && m_output[CPS2_OBJ_BASE /2] != 0x7000) ||
2864      m_output[CPS2_OBJ_UK1 /2] != 0x807d ||
2865      (m_output[CPS2_OBJ_UK2 /2] != 0x0000 && m_output[CPS2_OBJ_UK2 /2] != 0x1101 && m_output[CPS2_OBJ_UK2 /2] != 0x0001))
28892866   popmessage("base %04x uk1 %04x uk2 %04x",
2890         cps2_port(machine(), CPS2_OBJ_BASE),
2891         cps2_port(machine(), CPS2_OBJ_UK1),
2892         cps2_port(machine(), CPS2_OBJ_UK2));
2867         m_output[CPS2_OBJ_BASE /2],
2868         m_output[CPS2_OBJ_UK1 /2],
2869         m_output[CPS2_OBJ_UK2 /2]);
28932870
28942871if (0 && machine().input().code_pressed(KEYCODE_Z))
28952872   popmessage("order: %d (%d) %d (%d) %d (%d) %d (%d)",l0,l0pri,l1,l1pri,l2,l2pri,l3,l3pri);
r20722r20723
29222899         }
29232900      }
29242901
2925      cps1_render_layer(machine(), bitmap, cliprect, l0, 1);
2926      cps1_render_layer(machine(), bitmap, cliprect, l1, 2);
2927      cps1_render_layer(machine(), bitmap, cliprect, l2, 4);
2928      cps2_render_sprites(machine(), bitmap, cliprect, primasks);
2902      cps1_render_layer(bitmap, cliprect, l0, 1);
2903      cps1_render_layer(bitmap, cliprect, l1, 2);
2904      cps1_render_layer(bitmap, cliprect, l2, 4);
2905      cps2_render_sprites(bitmap, cliprect, primasks);
29292906   }
29302907
29312908   return 0;
r20722r20723
29472924   }
29482925}
29492926
2950void cps2_set_sprite_priorities( running_machine &machine )
2927void cps_state::cps2_set_sprite_priorities()
29512928{
2952   cps_state *state = machine.driver_data<cps_state>();
2953   state->m_pri_ctrl = cps2_port(machine, CPS2_OBJ_PRI);
2929   m_pri_ctrl = m_output[CPS2_OBJ_PRI /2];
29542930}
29552931
2956void cps2_objram_latch( running_machine &machine )
2932void cps_state::cps2_objram_latch()
29572933{
2958   cps_state *state = machine.driver_data<cps_state>();
2959   cps2_set_sprite_priorities(machine);
2960   memcpy(state->m_cps2_buffered_obj, cps2_objbase(machine), state->m_cps2_obj_size);
2934   cps2_set_sprite_priorities();
2935   memcpy(m_cps2_buffered_obj, cps2_objbase(), m_cps2_obj_size);
29612936}
trunk/src/mame/drivers/cps2.c
r20722r20723
640640   {
641641      m_cps_b_regs[0x10/2] = 0;
642642      m_maincpu->set_input_line(4, HOLD_LINE);
643      cps2_set_sprite_priorities(timer.machine());
643      cps2_set_sprite_priorities();
644644      timer.machine().primary_screen->update_partial(param);
645645      m_scancalls++;
646646//      popmessage("IRQ4 scancounter = %04i", param);
r20722r20723
651651   {
652652      m_cps_b_regs[0x12 / 2] = 0;
653653      m_maincpu->set_input_line(4, HOLD_LINE);
654      cps2_set_sprite_priorities(timer.machine());
654      cps2_set_sprite_priorities();
655655      timer.machine().primary_screen->update_partial(param);
656656      m_scancalls++;
657657//      popmessage("IRQ4 scancounter = %04i", param);
r20722r20723
664664      m_maincpu->set_input_line(2, HOLD_LINE);
665665      if(m_scancalls)
666666      {
667         cps2_set_sprite_priorities(timer.machine());
667         cps2_set_sprite_priorities();
668668         timer.machine().primary_screen->update_partial(256);
669669      }
670      cps2_objram_latch(timer.machine());
670      cps2_objram_latch();
671671   }
672672//  popmessage("Raster calls = %i", m_scancalls);
673673}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team