Optimize DrawSprites - goes from 8% CPU time with perf top

to 4%
This commit is contained in:
twinaphex 2014-06-22 06:23:17 +02:00
parent 515ee061c1
commit 7e82d450df

View File

@ -701,45 +701,30 @@ static void DrawSprites(vdc_t *vdc, const int32 end, uint16 *spr_linebuf)
{
const uint8 *pix_source = vdc->spr_tile_cache[SpriteList[i].no][SpriteList[i].sub_y];
int increment = -1;
int32 x_second = 15;
if(SpriteList[i].flags & SPRF_HFLIP)
{
for(int32 x = 0; x < 16; x++)
{
const uint32 raw_pixel = pix_source[x];
if(raw_pixel)
{
if(((uint32)pos + x) >= (uint32)end) // Covers negative and overflowing the right side(to prevent spurious sprite hits)
continue;
if(dest_pix[x] & 0x100)
{
vdc->status |= VDCS_CR;
VDC_DEBUG("Sprite hit IRQ");
HuC6280_IRQBegin(MDFN_IQIRQ1);
}
dest_pix[x] = raw_pixel | prio_or;
}
}
int increment = 1;
int32 x_second = 0;
}
else
{
for(int32 x = 0; x < 16; x++)
{
const uint32 raw_pixel = pix_source[15 - x];
if(raw_pixel)
{
if(((uint32)pos + x) >= (uint32)end) // Covers negative and overflowing the right side(to prevent spurious sprite hits)
continue;
if(dest_pix[x] & 0x100)
for(int32 x = 0; x < 16; x++, x_second += increment)
{
const uint32 raw_pixel = pix_source[x_second];
if(raw_pixel)
{
vdc->status |= VDCS_CR;
VDC_DEBUG("Sprite hit IRQ");
HuC6280_IRQBegin(MDFN_IQIRQ1);
if(((uint32)pos + x) >= (uint32)end) // Covers negative and overflowing the right side(to prevent spurious sprite hits)
continue;
if(dest_pix[x] & 0x100)
{
vdc->status |= VDCS_CR;
VDC_DEBUG("Sprite hit IRQ");
HuC6280_IRQBegin(MDFN_IQIRQ1);
}
dest_pix[x] = raw_pixel | prio_or;
}
dest_pix[x] = raw_pixel | prio_or;
}
}
}
} // End sprite0 handling
else // No sprite0 hit: