public uint32_t screen_update_pacman(screen_device screen, bitmap_ind16 bitmap, rectangle cliprect) { if (m_bgpriority != 0) { bitmap.fill(0, cliprect); } else { m_bg_tilemap.draw(screen, bitmap, cliprect, tilemap_global.TILEMAP_DRAW_OPAQUE, 0); } if (m_spriteram != null) { ListBytesPointer spriteram = m_spriteram.target; //uint8_t *spriteram = m_spriteram; ListBytesPointer spriteram_2 = m_spriteram2.target; //uint8_t *spriteram_2 = m_spriteram2; int offs; rectangle spriteclip = new rectangle(2 * 8, 34 * 8 - 1, 0 * 8, 28 * 8 - 1); spriteclip.intersection(cliprect); // spriteclip &= cliprect; /* Draw the sprites. Note that it is important to draw them exactly in this */ /* order, to have the correct priorities. */ for (offs = (int)m_spriteram.bytes() - 2; offs > 2 * 2; offs -= 2) { int color; int sx; int sy; byte fx; byte fy; if (m_inv_spr != 0) { sx = spriteram_2[offs + 1]; sy = 240 - (spriteram_2[offs]); } else { sx = 272 - spriteram_2[offs + 1]; sy = spriteram_2[offs] - 31; } fx = (byte)((spriteram[offs] & 1) ^ m_inv_spr); fy = (byte)((spriteram[offs] & 2) ^ ((m_inv_spr) << 1)); color = (spriteram[offs + 1] & 0x1f) | (m_colortablebank << 5) | (m_palettebank << 6); m_gfxdecode.target.digfx.gfx(1).transmask(bitmap, spriteclip, (UInt32)((spriteram[offs] >> 2) | (m_spritebank << 6)), (UInt32)color, fx, fy, sx, sy, m_palette.target.palette_interface.transpen_mask(m_gfxdecode.target.digfx.gfx(1), (UInt32)color & 0x3f, 0)); /* also plot the sprite with wraparound (tunnel in Crush Roller) */ m_gfxdecode.target.digfx.gfx(1).transmask(bitmap, spriteclip, (UInt32)((spriteram[offs] >> 2) | (m_spritebank << 6)), (UInt32)color, fx, fy, sx - 256, sy, m_palette.target.palette_interface.transpen_mask(m_gfxdecode.target.digfx.gfx(1), (UInt32)color & 0x3f, 0)); } /* In the Pac Man based games (NOT Pengo) the first two sprites must be offset */ /* one pixel to the left to get a more correct placement */ for (offs = 2 * 2; offs >= 0; offs -= 2) { int color; int sx; int sy; byte fx; byte fy; if (m_inv_spr != 0) { sx = spriteram_2[offs + 1]; sy = 240 - (spriteram_2[offs]); } else { sx = 272 - spriteram_2[offs + 1]; sy = spriteram_2[offs] - 31; } color = (spriteram[offs + 1] & 0x1f) | (m_colortablebank << 5) | (m_palettebank << 6); fx = (byte)((spriteram[offs] & 1) ^ m_inv_spr); fy = (byte)((spriteram[offs] & 2) ^ ((m_inv_spr) << 1)); m_gfxdecode.target.digfx.gfx(1).transmask(bitmap, spriteclip, (UInt32)((spriteram[offs] >> 2) | (m_spritebank << 6)), (UInt32)color, fx, fy, sx, sy + m_xoffsethack, m_palette.target.palette_interface.transpen_mask(m_gfxdecode.target.digfx.gfx(1), (UInt32)color & 0x3f, 0)); /* also plot the sprite with wraparound (tunnel in Crush Roller) */ m_gfxdecode.target.digfx.gfx(1).transmask(bitmap, spriteclip, (UInt32)((spriteram[offs] >> 2) | (m_spritebank << 6)), (UInt32)color, fx, fy, sx - 256, sy + m_xoffsethack, m_palette.target.palette_interface.transpen_mask(m_gfxdecode.target.digfx.gfx(1), (UInt32)color & 0x3f, 0)); } } if (m_bgpriority != 0) { m_bg_tilemap.draw(screen, bitmap, cliprect, 0, 0); } return(0); }