k007420: apply same sprite code mask fix as with k007121

This commit is contained in:
hap 2024-11-24 05:05:43 +01:00
parent 9feddc7241
commit 135d83ea3e
2 changed files with 63 additions and 46 deletions

View File

@ -48,9 +48,6 @@ k007342_device::k007342_device(const machine_config &mconfig, const char *tag, d
m_tilemap{ nullptr, nullptr },
m_flipscreen(false),
m_int_enabled(false),
//m_regs[8],
//m_scrollx[2],
//m_scrolly[2],
m_callback(*this)
{
}
@ -269,11 +266,7 @@ void k007342_device::get_tile_info( tile_data &tileinfo, int tile_index, uint8_t
if (!m_callback.isnull())
m_callback(layer, m_regs[1], code, color, flags);
tileinfo.set(0,
code,
color,
flags);
tileinfo.set(0, code, color, flags);
}
TILE_GET_INFO_MEMBER(k007342_device::get_tile_info0)

View File

@ -28,7 +28,6 @@ k007420_device::k007420_device(const machine_config &mconfig, const char *tag, d
, m_flipscreen(false)
, m_banklimit(0)
, m_callback(*this)
//, m_regs[8]
{
}
@ -115,50 +114,71 @@ void k007420_device::sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprec
const uint32_t bank = code & bankmask;
code &= codemask;
/* 0x080 = normal scale, 0x040 = double size, 0x100 half size */
// 0x080 = normal scale, 0x040 = double size, 0x100 half size
uint32_t zoom = m_ram[offs + 5] | ((m_ram[offs + 4] & 0x03) << 8);
if (!zoom)
continue;
zoom = 0x10000 * 128 / zoom;
uint8_t w, h;
uint8_t width, height;
switch (m_ram[offs + 4] & 0x70)
{
case 0x30: w = h = 1; break;
case 0x20: w = 2; h = 1; code &= (~1); break;
case 0x10: w = 1; h = 2; code &= (~2); break;
case 0x00: w = h = 2; code &= (~3); break;
case 0x40: w = h = 4; code &= (~3); break;
default: w = 1; h = 1;
//logerror("Unknown sprite size %02x\n",(m_ram[offs + 4] & 0x70) >> 4);
case 0x30:
width = height = 1;
break;
case 0x20:
width = 2; height = 1;
code &= ~1;
break;
case 0x10:
width = 1; height = 2;
code &= ~2;
break;
case 0x00:
width = height = 2;
code &= ~3;
break;
case 0x40:
width = height = 4;
code &= ~0xf;
break;
default:
width = 1; height = 1;
//logerror("Unknown sprite size %02x\n",(m_ram[offs + 4] & 0x70) >> 4);
break;
}
if (m_flipscreen)
{
ox = 256 - ox - ((zoom * w + (1 << 12)) >> 13);
oy = 256 - oy - ((zoom * h + (1 << 12)) >> 13);
ox = 256 - ox - ((zoom * width + (1 << 12)) >> 13);
oy = 256 - oy - ((zoom * height + (1 << 12)) >> 13);
flipx = !flipx;
flipy = !flipy;
}
if (zoom == 0x10000)
{
for (int y = 0; y < h; y++)
for (int y = 0; y < height; y++)
{
const int sy = oy + 8 * y;
for (int x = 0; x < w; x++)
for (int x = 0; x < width; x++)
{
uint32_t c = code;
const int sx = ox + 8 * x;
if (flipx)
c += xoffset[(w - 1 - x)];
c += xoffset[(width - 1 - x)];
else
c += xoffset[x];
if (flipy)
c += yoffset[(h - 1 - y)];
c += yoffset[(height - 1 - y)];
else
c += yoffset[y];
@ -174,6 +194,7 @@ void k007420_device::sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprec
sx,sy,0);
if (m_regs[2] & 0x80)
{
gfx(0)->transpen(bitmap,cliprect,
c,
color,
@ -182,26 +203,27 @@ void k007420_device::sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprec
}
}
}
}
else
{
for (int y = 0; y < h; y++)
for (int y = 0; y < height; y++)
{
const int sy = oy + ((zoom * y + (1 << 12)) >> 13);
const int zh = (oy + ((zoom * (y + 1) + (1 << 12)) >> 13)) - sy;
for (int x = 0; x < w; x++)
for (int x = 0; x < width; x++)
{
uint32_t c = code;
const int sx = ox + ((zoom * x + (1<<12)) >> 13);
const int sx = ox + ((zoom * x + (1 << 12)) >> 13);
const int zw = (ox + ((zoom * (x + 1) + (1 << 12)) >> 13)) - sx;
if (flipx)
c += xoffset[(w - 1 - x)];
c += xoffset[(width - 1 - x)];
else
c += xoffset[x];
if (flipy)
c += yoffset[(h - 1 - y)];
c += yoffset[(height - 1 - y)];
else
c += yoffset[y];
@ -218,6 +240,7 @@ void k007420_device::sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprec
(zw << 16) / 8,(zh << 16) / 8,0);
if (m_regs[2] & 0x80)
{
gfx(0)->zoom_transpen(bitmap,cliprect,
c,
color,
@ -228,6 +251,7 @@ void k007420_device::sprites_draw(bitmap_ind16 &bitmap, const rectangle &cliprec
}
}
}
}
#if 0
{
static int current_sprite = 0;