deco_mlc.cpp : Updates

Make background color blendable, Slightly simpler blending behavior, Fix spacing
This commit is contained in:
cam900 2019-09-11 23:19:25 +09:00
parent 48e3eb4174
commit f33b1ee71d
2 changed files with 62 additions and 112 deletions

View File

@ -176,7 +176,7 @@ WRITE32_MEMBER(deco_mlc_state::eeprom_w)
{ {
const u8 ebyte = (data >> 8) & 0xff; const u8 ebyte = (data >> 8) & 0xff;
// if (ebyte & 0x80) // if (ebyte & 0x80)
// { // {
m_eeprom->clk_write((ebyte & 0x2) ? ASSERT_LINE : CLEAR_LINE); m_eeprom->clk_write((ebyte & 0x2) ? ASSERT_LINE : CLEAR_LINE);
m_eeprom->di_write(ebyte & 0x1); m_eeprom->di_write(ebyte & 0x1);
m_eeprom->cs_write((ebyte & 0x4) ? ASSERT_LINE : CLEAR_LINE); m_eeprom->cs_write((ebyte & 0x4) ? ASSERT_LINE : CLEAR_LINE);
@ -232,11 +232,11 @@ WRITE32_MEMBER(deco_mlc_state::irq_ram_w)
m_maincpu->set_input_line(m_irqLevel, CLEAR_LINE); m_maincpu->set_input_line(m_irqLevel, CLEAR_LINE);
return; return;
case 0x14: /* Prepare scanline interrupt */ case 0x14: /* Prepare scanline interrupt */
if(m_irq_ram[0x14/4] == -1) // TODO: likely to be anything that doesn't fit into the screen v-pos range. if(m_irq_ram[0x14 / 4] == -1) // TODO: likely to be anything that doesn't fit into the screen v-pos range.
m_raster_irq_timer->adjust(attotime::never); m_raster_irq_timer->adjust(attotime::never);
else else
m_raster_irq_timer->adjust(m_screen->time_until_pos(m_irq_ram[0x14/4])); m_raster_irq_timer->adjust(m_screen->time_until_pos(m_irq_ram[0x14 / 4]));
//logerror("prepare scanline to fire at %d (currently on %d)\n", m_irq_ram[0x14/4], m_screen->vpos()); //logerror("prepare scanline to fire at %d (currently on %d)\n", m_irq_ram[0x14 / 4], m_screen->vpos());
return; return;
default: default:
@ -922,12 +922,13 @@ void deco_mlc_state::descramble_sound( )
for (u32 x = 0; x < length; x++) for (u32 x = 0; x < length; x++)
{ {
u32 addr = bitswap<24> (x,23,22,21,0, 20, const u32 addr = bitswap<24>(x,
19,18,17,16, 23,22,21,0, 20,
15,14,13,12, 19,18,17,16,
11,10,9, 8, 15,14,13,12,
7, 6, 5, 4, 11,10,9, 8,
3, 2, 1 ); 7, 6, 5, 4,
3, 2, 1 );
buf[addr] = rom[x]; buf[addr] = rom[x];
} }
@ -937,8 +938,8 @@ void deco_mlc_state::descramble_sound( )
READ32_MEMBER(deco_mlc_state::avengrgs_speedup_r) READ32_MEMBER(deco_mlc_state::avengrgs_speedup_r)
{ {
u32 a = m_mainram[0x89a0/4]; const u32 a = m_mainram[0x89a0 / 4];
u32 p = m_maincpu->pc(); const u32 p = m_maincpu->pc();
if ((p == 0x3234 || p == 0x32dc) && (a & 1)) m_maincpu->spin_until_interrupt(); if ((p == 0x3234 || p == 0x32dc) && (a & 1)) m_maincpu->spin_until_interrupt();
@ -955,7 +956,7 @@ void deco_mlc_state::init_avengrgs()
dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_pcflush(0x32dc); dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_pcflush(0x32dc);
dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0100000, 0x01088ff, 0, &m_mainram[0]); dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0100000, 0x01088ff, 0, &m_mainram[0]);
dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0108a00, 0x011ffff, 0, &m_mainram[0x8a00/4]); dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0108a00, 0x011ffff, 0, &m_mainram[0x8a00 / 4]);
dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0200080, 0x02000ff, 0, &m_clip_ram[0]); dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0200080, 0x02000ff, 0, &m_clip_ram[0]);
dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0280000, 0x029ffff, 0, &m_vram[0]); dynamic_cast<sh2_device *>(m_maincpu.target())->sh2drc_add_fastram(0x0280000, 0x029ffff, 0, &m_vram[0]);

View File

@ -29,13 +29,13 @@ void deco_mlc_state::video_start()
} }
// temp_bitmap = std::make_unique<bitmap_rgb32>(512, 512); // temp_bitmap = std::make_unique<bitmap_rgb32>(512, 512);
m_buffered_spriteram = std::make_unique<u16[]>(0x3000/4); m_buffered_spriteram = std::make_unique<u16[]>(0x3000 / 4);
m_spriteram_spare = std::make_unique<u16[]>(0x3000/4); m_spriteram_spare = std::make_unique<u16[]>(0x3000 / 4);
m_spriteram = std::make_unique<u16[]>(0x3000/4); m_spriteram = std::make_unique<u16[]>(0x3000 / 4);
save_pointer(NAME(m_spriteram), 0x3000/4); save_pointer(NAME(m_spriteram), 0x3000 / 4);
save_pointer(NAME(m_spriteram_spare), 0x3000/4); save_pointer(NAME(m_spriteram_spare), 0x3000 / 4);
save_pointer(NAME(m_buffered_spriteram), 0x3000/4); save_pointer(NAME(m_buffered_spriteram), 0x3000 / 4);
} }
@ -45,7 +45,7 @@ void deco_mlc_state::drawgfxzoomline(u32* dest, u8* pri,const rectangle &clip,gf
int scalex, int srcline, int shadowMode ) int scalex, int srcline, int shadowMode )
{ {
if (!scalex) return; if (!scalex) return;
const u32 alphaMode = m_irq_ram[0x04/4] & 0xc0; const u32 alphaMode = m_irq_ram[0x04 / 4] & 0xc0;
/* /*
scalex and scaley are 16.16 fixed point numbers scalex and scaley are 16.16 fixed point numbers
@ -80,9 +80,9 @@ void deco_mlc_state::drawgfxzoomline(u32* dest, u8* pri,const rectangle &clip,gf
if (sx < clip.left()) if (sx < clip.left())
{ /* clip left */ { /* clip left */
int pixels = clip.left()-sx; int pixels = clip.left() - sx;
sx += pixels; sx += pixels;
x_index_base += pixels*dx; x_index_base += pixels * dx;
} }
/* NS 980211 - fixed incorrect clipping */ /* NS 980211 - fixed incorrect clipping */
if (ex > clip.right() + 1) if (ex > clip.right() + 1)
@ -98,107 +98,42 @@ void deco_mlc_state::drawgfxzoomline(u32* dest, u8* pri,const rectangle &clip,gf
const u8 *code_base2 = gfx->get_data(code2 % gfx->elements()); const u8 *code_base2 = gfx->get_data(code2 % gfx->elements());
const u8 *source1 = code_base1 + (srcline) * gfx->rowbytes(); const u8 *source1 = code_base1 + (srcline) * gfx->rowbytes();
const u8 *source2 = code_base2 + (srcline) * gfx->rowbytes(); const u8 *source2 = code_base2 + (srcline) * gfx->rowbytes();
/* no alpha */ // alphaMode & 0xc0 = 0xc0 : Shadow, 0 : Alpha or Pre-shadowed, Other bits unknown
if (!shadowMode) if (shadowMode && (alphaMode & 0xc0))
{ { /* TODO : 8bpp and shadow can use simultaneously? */
if (alphaMode & 0xc0) int x, x_index = x_index_base;
for (x = sx; x < ex; x++)
{ {
int x, x_index = x_index_base; if (!(pri[x] & 0x80))
for (x = sx; x < ex; x++)
{ {
if (!(pri[x] & 0x80)) int c = source1[x_index >> 16];
{ if (use8bpp)
int c = source1[x_index >> 16]; c = (c << 4) | source2[x_index >> 16];
if (use8bpp)
c = (c << 4) | source2[x_index >> 16];
if (c != transparent_color) if (c != transparent_color)
{ pri[x] |= shadowMode; // Mark it shadow / hilighted
u32 col = pal[c];
if ((pri[x] & 0x3) && ((pri[x] & 0x3) != 0x3))
{
const u8 a = (col >> 24) & 0xff;
const u8 r = (col >> 16) & 0xff;
const u8 g = (col >> 8) & 0xff;
const u8 b = (col >> 0) & 0xff;
if (pri[x] & 1) // shadow
{
col = rgb_t(a, r >> 1, g >> 1, b >> 1);
}
else if (pri[x] & 2) // hilight
{
col = rgb_t(a, 0x80 | (r >> 1), 0x80 | (g >> 1), 0x80 | (b >> 1));
}
}
dest[x] = col;
pri[x] |= 0x80; // Mark it drawn
}
}
x_index += dx;
}
}
else
{
int x, x_index = x_index_base;
for (x = sx; x < ex; x++)
{
if (!(pri[x] & 0x80))
{
int c = source1[x_index >> 16];
if (use8bpp)
c = (c << 4) | source2[x_index >> 16];
if (c != transparent_color)
{
dest[x] = pal[c];
pri[x] |= 0x80; // Mark it drawn
}
}
x_index += dx;
} }
x_index += dx;
} }
} }
// alphaMode & 0xc0 = 0xc0 : Shadow, 0 : Alpha or Pre-shadowed, Other bits unknown
else else
{ {
if (alphaMode & 0xc0) int x, x_index = x_index_base;
{ /* TODO : 8bpp and shadow can use simultaneously? */ for (x = sx; x < ex; x++)
int x, x_index = x_index_base;
for (x = sx; x < ex; x++)
{
if (!(pri[x] & 0x80))
{
int c = source1[x_index >> 16];
if (use8bpp)
c = (c << 4) | source2[x_index >> 16];
if (c != transparent_color)
pri[x] |= shadowMode; // Mark it shadow / hilighted
}
x_index += dx;
}
}
else
{ {
int x, x_index = x_index_base; if (!(pri[x] & 0x80))
for (x = sx; x < ex; x++)
{ {
if (!(pri[x] & 0x80)) int c = source1[x_index >> 16];
{ if (use8bpp)
int c = source1[x_index >> 16]; c = (c << 4) | source2[x_index >> 16];
if (use8bpp)
c = (c << 4) | source2[x_index >> 16];
if (c != transparent_color) if (c != transparent_color)
{ {
dest[x] = (shadowMode == 3) ? pal[c] : alpha_blend_r32(pal[c], shadowMode & 2 ? ~0 : 0, 0x80); dest[x] = pal[c];
pri[x] |= 0x80; // Mark it drawn pri[x] |= 0x80 | shadowMode; // Mark it drawn
}
} }
x_index += dx;
} }
x_index += dx;
} }
} }
} }
@ -224,7 +159,7 @@ void deco_mlc_state::draw_sprites(const rectangle &cliprect, int scanline, u32*
//printf("%d - (%08x %08x %08x) (%08x %08x %08x) (%08x %08x %08x)\n", scanline, m_irq_ram[6], m_irq_ram[7], m_irq_ram[8], m_irq_ram[9], m_irq_ram[10], m_irq_ram[11] , m_irq_ram[12] , m_irq_ram[13] , m_irq_ram[14]); //printf("%d - (%08x %08x %08x) (%08x %08x %08x) (%08x %08x %08x)\n", scanline, m_irq_ram[6], m_irq_ram[7], m_irq_ram[8], m_irq_ram[9], m_irq_ram[10], m_irq_ram[11] , m_irq_ram[12] , m_irq_ram[13] , m_irq_ram[14]);
for (int offs = 0; offs < (0x3000/4); offs += 8) for (int offs = 0; offs < (0x3000 / 4); offs += 8)
{ {
if ((spriteram[offs + 0] & 0x8000) == 0) if ((spriteram[offs + 0] & 0x8000) == 0)
continue; continue;
@ -601,7 +536,7 @@ WRITE_LINE_MEMBER(deco_mlc_state::screen_vblank_mlc)
lookup table. Without buffering incorrect one frame glitches are seen lookup table. Without buffering incorrect one frame glitches are seen
in several places, especially in Hoops. in several places, especially in Hoops.
*/ */
std::copy(&m_spriteram[0], &m_spriteram[0x3000/4], &m_buffered_spriteram[0]); std::copy(&m_spriteram[0], &m_spriteram[0x3000 / 4], &m_buffered_spriteram[0]);
} }
} }
@ -625,6 +560,20 @@ u32 deco_mlc_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, c
printf("\n"); printf("\n");
*/ */
draw_sprites(cliprect, i, dest, pri); draw_sprites(cliprect, i, dest, pri);
for (int x = cliprect.left(); x <= cliprect.right(); x++)
{
u32 col = dest[x];
const u8 shadow_flag = pri[x] & 3;
if ((shadow_flag & 3) && (shadow_flag != 3))
{
if (shadow_flag & 1) // shadow
col = (col & 0xff000000) | ((col & 0xfefefe) >> 1);
else if (shadow_flag & 2) // hilight
col = (col & 0xff000000) | ((col & 0xfefefe) >> 1) | 0x808080;
dest[x] = col;
}
}
} }
return 0; return 0;
} }