Previous 199869 Revisions Next

r20904 Sunday 10th February, 2013 at 19:06:01 UTC by Wilbert Pol
(MESS) vii.c: Reduce tagmap lookups (nw)
[src/mess/drivers]vii.c

trunk/src/mess/drivers/vii.c
r20903r20904
152152protected:
153153   optional_memory_region m_region_cart;
154154   required_ioport m_io_p1;
155
156   void vii_blit(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT32 xoff, UINT32 yoff, UINT32 attr, UINT32 ctrl, UINT32 bitmap_addr, UINT16 tile);
157   void vii_blit_page(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 bitmap_addr, UINT16 *regs);
158   void vii_blit_sprite(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 base_addr);
159   void vii_blit_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth);
155160};
156161
157162enum
r20903r20904
225230   state->m_screen[offset].b = expand_rgb5_to_rgb8(rgb);
226231}
227232
228static void vii_blit(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT32 xoff, UINT32 yoff, UINT32 attr, UINT32 ctrl, UINT32 bitmap_addr, UINT16 tile)
233void vii_state::vii_blit(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT32 xoff, UINT32 yoff, UINT32 attr, UINT32 ctrl, UINT32 bitmap_addr, UINT16 tile)
229234{
230   vii_state *state = machine.driver_data<vii_state>();
231   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
235   address_space &space = m_maincpu->space(AS_PROGRAM);
232236
233237   UINT32 h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
234238   UINT32 w = 8 << ((attr & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
r20903r20904
272276
273277         if((ctrl & 0x0010) && yy < 240)
274278         {
275            xx = (xx - (INT16)state->m_p_rowscroll[yy]) & 0x01ff;
279            xx = (xx - (INT16)m_p_rowscroll[yy]) & 0x01ff;
276280         }
277281
278282         if(xx < 320 && yy < 240)
279283         {
280            UINT16 rgb = state->m_p_palette[pal];
284            UINT16 rgb = m_p_palette[pal];
281285            if(!(rgb & 0x8000))
282286            {
283287               if (attr & 0x4000)
284288               {
285                  vii_mix_pixel(state, xx + 320*yy, rgb);
289                  vii_mix_pixel(this, xx + 320*yy, rgb);
286290               }
287291               else
288292               {
289                  vii_set_pixel(state, xx + 320*yy, rgb);
293                  vii_set_pixel(this, xx + 320*yy, rgb);
290294               }
291295            }
292296         }
r20903r20904
294298   }
295299}
296300
297static void vii_blit_page(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 bitmap_addr, UINT16 *regs)
301void vii_state::vii_blit_page(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 bitmap_addr, UINT16 *regs)
298302{
299303   UINT32 x0, y0;
300304   UINT32 xscroll = regs[0];
r20903r20904
304308   UINT32 tilemap = regs[4];
305309   UINT32 palette_map = regs[5];
306310   UINT32 h, w, hn, wn;
307   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
311   address_space &space = m_maincpu->space(AS_PROGRAM);
308312
309313   if(!(ctrl & PAGE_ENABLE_MASK))
310314   {
r20903r20904
358362         yy = ((h*y0 - yscroll + 0x10) & 0xff) - 0x10;
359363         xx = (w*x0 - xscroll) & 0x1ff;
360364
361         vii_blit(machine, bitmap, cliprect, xx, yy, tileattr, tilectrl, bitmap_addr, tile);
365         vii_blit(bitmap, cliprect, xx, yy, tileattr, tilectrl, bitmap_addr, tile);
362366      }
363367   }
364368}
365369
366static void vii_blit_sprite(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 base_addr)
370void vii_state::vii_blit_sprite(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth, UINT32 base_addr)
367371{
368   vii_state *state = machine.driver_data<vii_state>();
369   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
372   address_space &space = m_maincpu->space(AS_PROGRAM);
370373   UINT16 tile, attr;
371374   INT16 x, y;
372375   UINT32 h, w;
373   UINT32 bitmap_addr = 0x40 * state->m_video_regs[0x22];
376   UINT32 bitmap_addr = 0x40 * m_video_regs[0x22];
374377
375378   tile = space.read_word((base_addr + 0) << 1);
376379   x = space.read_word((base_addr + 1) << 1);
r20903r20904
387390      return;
388391   }
389392
390   if(state->m_centered_coordinates)
393   if(m_centered_coordinates)
391394   {
392395      x = 160 + x;
393396      y = 120 - y;
r20903r20904
402405   x &= 0x01ff;
403406   y &= 0x01ff;
404407
405   vii_blit(machine, bitmap, cliprect, x, y, attr, 0, bitmap_addr, tile);
408   vii_blit(bitmap, cliprect, x, y, attr, 0, bitmap_addr, tile);
406409}
407410
408static void vii_blit_sprites(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth)
411void vii_state::vii_blit_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int depth)
409412{
410   vii_state *state = machine.driver_data<vii_state>();
411413   UINT32 n;
412414
413   if (!(state->m_video_regs[0x42] & 1))
415   if (!(m_video_regs[0x42] & 1))
414416   {
415417      return;
416418   }
r20903r20904
419421   {
420422      //if(space.read_word((0x2c00 + 4*n) << 1))
421423      {
422         vii_blit_sprite(machine, bitmap, cliprect, depth, 0x2c00 + 4*n);
424         vii_blit_sprite(bitmap, cliprect, depth, 0x2c00 + 4*n);
423425      }
424426   }
425427}
r20903r20904
434436
435437   for(i = 0; i < 4; i++)
436438   {
437      vii_blit_page(machine(), bitmap, cliprect, i, 0x40 * m_video_regs[0x20], m_video_regs + 0x10);
438      vii_blit_page(machine(), bitmap, cliprect, i, 0x40 * m_video_regs[0x21], m_video_regs + 0x16);
439      vii_blit_sprites(machine(), bitmap, cliprect, i);
439      vii_blit_page(bitmap, cliprect, i, 0x40 * m_video_regs[0x20], m_video_regs + 0x10);
440      vii_blit_page(bitmap, cliprect, i, 0x40 * m_video_regs[0x21], m_video_regs + 0x16);
441      vii_blit_sprites(bitmap, cliprect, i);
440442   }
441443
442444   for(y = 0; y < 240; y++)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team