Out Run: simpler sprite logic (#10420)

This commit is contained in:
Jose Tejada 2022-10-16 10:39:20 +02:00 committed by GitHub
parent cab27c66bf
commit d188072d81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1154,57 +1154,48 @@ void sega_outrun_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip
int xacc = 0; int xacc = 0;
int x; int x;
// non-flipped case data[7] = addr;
if (!flip) for (x = xpos; (xdelta > 0 && x <= cliprect.max_x) || (xdelta < 0 && x >= cliprect.min_x);)
{ {
// start at the word before because we preincrement below uint32_t pixels = spritedata[data[7]];
data[7] = addr - 1; if (flip)
for (x = xpos; (xdelta > 0 && x <= cliprect.max_x) || (xdelta < 0 && x >= cliprect.min_x); )
{ {
uint32_t pixels = spritedata[++data[7]]; data[7]--;
// draw four pixels
int pix;
pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200;
pix = (pixels >> 24) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200;
pix = (pixels >> 20) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200;
pix = (pixels >> 16) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200;
pix = (pixels >> 12) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200;
pix = (pixels >> 8) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200;
pix = (pixels >> 4) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200;
pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200;
// stop if the second-to-last pixel in the group was 0xf
if ((pixels & 0x000000f0) == 0x000000f0)
break;
} }
}
// flipped case
else else
{ {
// start at the word after because we predecrement below data[7]++;
data[7] = addr + 1; pixels =
for (x = xpos; (xdelta > 0 && x <= cliprect.max_x) || (xdelta < 0 && x >= cliprect.min_x); ) (( pixels << 28) & 0xf0000000) |
{ (( pixels << 20) & 0x0f000000) |
uint32_t pixels = spritedata[--data[7]]; (( pixels << 12) & 0x00f00000) |
(( pixels << 4) & 0x000f0000) |
(( pixels >> 4) & 0x0000f000) |
(( pixels >> 12) & 0x00000f00) |
(( pixels >> 20) & 0x000000f0) |
(( pixels >> 28) & 0x0000000f);
}
bool last_data = (pixels & 0x0f00'0000) == 0x0f00'0000;
// draw four pixels // draw eight pixels
int pix; for (int k=0; k<8; k++)
pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200; {
pix = (pixels >> 4) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200; int pix = pixels & 0xf;
pix = (pixels >> 8) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200; while (xacc < 0x200)
pix = (pixels >> 12) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200; {
pix = (pixels >> 16) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200; if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15)
pix = (pixels >> 20) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200; dest[x] = colpri | pix;
pix = (pixels >> 24) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200; x += xdelta;
pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { if (x >= cliprect.min_x && x <= cliprect.max_x && pix != 0 && pix != 15) dest[x] = colpri | pix; x += xdelta; xacc += hzoom; } xacc -= 0x200; xacc += hzoom;
}
xacc -= 0x200;
pixels>>=4;
}
// stop if the second-to-last pixel in the group was 0xf // stop if the second-to-last pixel in the group was 0xf
if ((pixels & 0x0f000000) == 0x0f000000) if (last_data)
break; break;
} }
}
// update bounds // update bounds
if (x > maxx) maxx = x; if (x > maxx) maxx = x;