argus.cpp updates (#3586)

* argus.cpp : Remove tilemap hack of argus (Tilemap size can be larger than 65536)
argus : Add MACHINE_NO_COCKTAIL tag because Scroll is wrong when flip screen

* argus.cpp : Minor removes of duplicates

* argus.cpp : Reduce RAM usage of argus tilemap

* argus.cpp : Move butasan scanning into TILEMAP_MAPPER_MEMBER, Some reduce duplicates, Fix spacing

* argus.cpp : Fix build

* argus.cpp : Fix butasan

* argus.cpp : Fix build
This commit is contained in:
cam900 2018-07-14 01:04:52 +09:00 committed by Vas Crabb
parent 0a6538f9d9
commit e4a4f5f50e
3 changed files with 71 additions and 194 deletions

View File

@ -759,7 +759,7 @@ ROM_END
/* ( YEAR NAME PARENT MACHINE INPUT STATE INIT MONITOR COMPANY FULLNAME ) */
GAME( 1986, argus, 0, argus, argus, argus_state, empty_init, ROT270, "NMK (Jaleco license)", "Argus", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE )
GAME( 1986, argus, 0, argus, argus, argus_state, empty_init, ROT270, "NMK (Jaleco license)", "Argus", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE | MACHINE_NO_COCKTAIL )
GAME( 1986, valtric, 0, valtric, valtric, argus_state, empty_init, ROT270, "NMK (Jaleco license)", "Valtric", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE )
GAME( 1987, butasan, 0, butasan, butasan, argus_state, empty_init, ROT0, "NMK (Jaleco license)", "Butasan - Pig's & Bomber's (Japan, English)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE )
GAME( 1987, butasanj, butasan, butasan, butasan, argus_state, empty_init, ROT0, "NMK (Jaleco license)", "Butasan (Japan, Japanese)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE )

View File

@ -49,9 +49,7 @@ public:
uint16_t m_palette_intensity;
// argus specific
std::unique_ptr<uint8_t[]> m_dummy_bg0ram;
int m_lowbitscroll;
int m_prvscrollx;
uint8_t m_vrom_offset;
// butasan specific
uint8_t *m_butasan_txram;
@ -98,14 +96,15 @@ public:
DECLARE_WRITE8_MEMBER(valtric_paletteram_w);
DECLARE_WRITE8_MEMBER(valtric_unknown_w);
TILE_GET_INFO_MEMBER(argus_get_tx_tile_info);
template<int Gfx> TILE_GET_INFO_MEMBER(get_tx_tile_info);
TILE_GET_INFO_MEMBER(argus_get_bg0_tile_info);
TILE_GET_INFO_MEMBER(argus_get_bg1_tile_info);
TILE_GET_INFO_MEMBER(valtric_get_tx_tile_info);
TILE_GET_INFO_MEMBER(valtric_get_bg_tile_info);
TILE_GET_INFO_MEMBER(butasan_get_tx_tile_info);
TILE_GET_INFO_MEMBER(butasan_get_bg0_tile_info);
TILE_GET_INFO_MEMBER(butasan_get_bg1_tile_info);
TILEMAP_MAPPER_MEMBER(butasan_bg_scan);
TILEMAP_MAPPER_MEMBER(butasan_tx_scan);
virtual void machine_start() override;
DECLARE_VIDEO_START(argus);
@ -128,8 +127,6 @@ public:
void bg_setting();
// argus specific
void argus_bg0_scroll_handle();
void argus_write_dummy_rams(int dramoffs, int vromoffs);
void argus_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority);
// butasan specific

View File

@ -123,7 +123,8 @@ BG0 palette intensity ( $C47F, $C4FF )
Callbacks for the tilemap code
***************************************************************************/
TILE_GET_INFO_MEMBER(argus_state::argus_get_tx_tile_info)
template<int Gfx>
TILE_GET_INFO_MEMBER(argus_state::get_tx_tile_info)
{
uint8_t hi, lo;
@ -132,7 +133,7 @@ TILE_GET_INFO_MEMBER(argus_state::argus_get_tx_tile_info)
lo = m_txram[tile_index];
hi = m_txram[tile_index + 1];
SET_TILE_INFO_MEMBER(3,
SET_TILE_INFO_MEMBER(Gfx,
((hi & 0xc0) << 2) | lo,
hi & 0x0f,
TILE_FLIPYX((hi & 0x30) >> 4));
@ -142,10 +143,14 @@ TILE_GET_INFO_MEMBER(argus_state::argus_get_bg0_tile_info)
{
uint8_t hi, lo;
tile_index <<= 1;
// logical width is 65536(4096*16) but we load only 1024 pixel each
// for reduce RAM usage
tile_index = (((m_vrom_offset << 9) + tile_index) & 0x1ffff) << 1;
int vrom_offset = (tile_index >> 3);
tile_index = (m_vrom[0][vrom_offset & ~1] << 4) | ((m_vrom[0][vrom_offset | 1] & 0x7) << 12) | (tile_index & 0xf);
lo = m_dummy_bg0ram[tile_index];
hi = m_dummy_bg0ram[tile_index + 1];
lo = m_vrom[1][tile_index];
hi = m_vrom[1][tile_index | 1];
SET_TILE_INFO_MEMBER(1,
((hi & 0xc0) << 2) | lo,
@ -168,21 +173,6 @@ TILE_GET_INFO_MEMBER(argus_state::argus_get_bg1_tile_info)
TILE_FLIPYX((hi & 0x30) >> 4));
}
TILE_GET_INFO_MEMBER(argus_state::valtric_get_tx_tile_info)
{
uint8_t hi, lo;
tile_index <<= 1;
lo = m_txram[tile_index];
hi = m_txram[tile_index + 1];
SET_TILE_INFO_MEMBER(2,
((hi & 0xc0) << 2) | lo,
hi & 0x0f,
TILE_FLIPYX((hi & 0x30) >> 4));
}
TILE_GET_INFO_MEMBER(argus_state::valtric_get_bg_tile_info)
{
uint8_t hi, lo;
@ -202,7 +192,6 @@ TILE_GET_INFO_MEMBER(argus_state::butasan_get_tx_tile_info)
{
uint8_t hi, lo;
tile_index ^= 0x3e0;
tile_index <<= 1;
lo = m_butasan_txram[tile_index];
@ -217,14 +206,11 @@ TILE_GET_INFO_MEMBER(argus_state::butasan_get_tx_tile_info)
TILE_GET_INFO_MEMBER(argus_state::butasan_get_bg0_tile_info)
{
uint8_t hi, lo;
int attrib;
attrib = (tile_index & 0x00f) | ((tile_index & 0x3e0) >> 1) | ((tile_index & 0x010) << 5);
attrib ^= 0x0f0;
attrib <<= 1;
tile_index <<= 1;
lo = m_butasan_bg0ram[attrib];
hi = m_butasan_bg0ram[attrib + 1];
lo = m_butasan_bg0ram[tile_index];
hi = m_butasan_bg0ram[tile_index + 1];
SET_TILE_INFO_MEMBER(1,
((hi & 0xc0) << 2) | lo,
@ -234,12 +220,7 @@ TILE_GET_INFO_MEMBER(argus_state::butasan_get_bg0_tile_info)
TILE_GET_INFO_MEMBER(argus_state::butasan_get_bg1_tile_info)
{
int attrib, tile;
attrib = (tile_index & 0x00f) | ((tile_index & 0x3e0) >> 1) | ((tile_index & 0x010) << 5);
attrib ^= 0x0f0;
tile = m_butasan_bg1ram[attrib] | ((m_butasan_bg1_status & 2) << 7);
int const tile = m_butasan_bg1ram[tile_index] | ((m_butasan_bg1_status & 2) << 7);
SET_TILE_INFO_MEMBER(2,
tile,
@ -247,6 +228,17 @@ TILE_GET_INFO_MEMBER(argus_state::butasan_get_bg1_tile_info)
0);
}
TILEMAP_MAPPER_MEMBER(argus_state::butasan_bg_scan)
{
/* logical (col,row) -> memory offset */
return (col & 0x0f) | ((row ^ 0x0f) << 4) | ((col & 0x10) << 5);
}
TILEMAP_MAPPER_MEMBER(argus_state::butasan_tx_scan)
{
/* logical (col,row) -> memory offset */
return (col & 0x1f) | ((row ^ 0x1f) << 5);
}
/***************************************************************************
Initialize and destroy video hardware emulation
@ -262,31 +254,23 @@ void argus_state::reset_common()
VIDEO_START_MEMBER(argus_state,argus)
{
/* info offset w h col row */
m_bg_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::argus_get_bg0_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 32, 32);
// m_bg_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::argus_get_bg0_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 4096, 32); // full 65536 width tilemap
m_bg_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::argus_get_bg0_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 1024/16, 32);
m_bg_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::argus_get_bg1_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 32, 32);
m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::argus_get_tx_tile_info),this), TILEMAP_SCAN_COLS, 8, 8, 32, 32);
m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::get_tx_tile_info<3>),this), TILEMAP_SCAN_COLS, 8, 8, 32, 32);
m_bg_tilemap[1]->set_transparent_pen(15);
m_tx_tilemap->set_transparent_pen(15);
/* dummy RAM for back ground */
m_dummy_bg0ram = std::make_unique<uint8_t[]>(0x800);
save_item(NAME(m_bg_status));
save_item(NAME(m_flipscreen));
save_item(NAME(m_palette_intensity));
save_pointer(NAME(m_dummy_bg0ram), 0x800);
save_item(NAME(m_lowbitscroll));
save_item(NAME(m_prvscrollx));
}
VIDEO_RESET_MEMBER(argus_state,argus)
{
m_lowbitscroll = 0;
m_prvscrollx = 0;
m_bg_scrollx[0][0] = 0;
m_bg_scrollx[0][1] = 0;
memset(m_dummy_bg0ram.get(), 0, 0x800);
reset_common();
}
@ -294,7 +278,7 @@ VIDEO_START_MEMBER(argus_state,valtric)
{
/* info offset w h col row */
m_bg_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::valtric_get_bg_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 32, 32);
m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::valtric_get_tx_tile_info),this), TILEMAP_SCAN_COLS, 8, 8, 32, 32);
m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::get_tx_tile_info<2>),this), TILEMAP_SCAN_COLS, 8, 8, 32, 32);
m_tx_tilemap->set_transparent_pen(15);
@ -317,9 +301,9 @@ VIDEO_RESET_MEMBER(argus_state,valtric)
VIDEO_START_MEMBER(argus_state,butasan)
{
/* info offset w h col row */
m_bg_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::butasan_get_bg0_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_bg_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::butasan_get_bg1_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::butasan_get_tx_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
m_bg_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::butasan_get_bg0_tile_info),this), tilemap_mapper_delegate(FUNC(argus_state::butasan_bg_scan),this), 16, 16, 32, 32);
m_bg_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::butasan_get_bg1_tile_info),this), tilemap_mapper_delegate(FUNC(argus_state::butasan_bg_scan),this), 16, 16, 32, 32);
m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(argus_state::butasan_get_tx_tile_info),this), tilemap_mapper_delegate(FUNC(argus_state::butasan_tx_scan),this), 8, 8, 32, 32);
m_bg_tilemap[1]->set_transparent_pen(15);
m_tx_tilemap->set_transparent_pen(15);
@ -356,28 +340,6 @@ VIDEO_RESET_MEMBER(argus_state,butasan)
Functions for handler of MAP roms in Argus and palette color
***************************************************************************/
/* Write bg0 pattern data to dummy bg0 ram */
void argus_state::argus_write_dummy_rams(int dramoffs, int vromoffs)
{
int i;
int voffs;
int offs;
/* offset in pattern data */
offs = m_vrom[0][vromoffs] | (m_vrom[0][vromoffs + 1] << 8);
offs &= 0x7ff;
voffs = offs * 16;
for (i = 0; i < 8; i++)
{
m_dummy_bg0ram[dramoffs] = m_vrom[1][voffs];
m_dummy_bg0ram[dramoffs + 1] = m_vrom[1][voffs + 1];
m_bg_tilemap[0]->mark_tile_dirty(dramoffs >> 1);
dramoffs += 2;
voffs += 2;
}
}
void argus_state::change_palette(int color, int lo_offs, int hi_offs)
{
uint8_t lo = m_paletteram[lo_offs];
@ -613,14 +575,8 @@ WRITE8_MEMBER(argus_state::butasan_paletteram_w)
WRITE8_MEMBER(argus_state::butasan_bg1ram_w)
{
int idx;
m_butasan_bg1ram[offset] = data;
idx = (offset & 0x00f) | ((offset & 0x200) >> 5) | ((offset & 0x1f0) << 1);
idx ^= 0x0f0;
m_bg_tilemap[1]->mark_tile_dirty(idx);
m_bg_tilemap[1]->mark_tile_dirty(offset);
}
WRITE8_MEMBER(argus_state::butasan_pageselect_w)
@ -643,17 +599,12 @@ WRITE8_MEMBER(argus_state::butasan_pagedram_w)
if (!m_butasan_page_latch)
{
if (offset <= 0x07ff)
{
int idx;
idx = ((offset & 0x01e) >> 1) | ((offset & 0x400) >> 6) | (offset & 0x3e0);
idx ^= 0x1e0;
m_bg_tilemap[0]->mark_tile_dirty(idx);
}
m_bg_tilemap[0]->mark_tile_dirty(offset >> 1);
}
else
{
if (offset <= 0x07ff)
m_tx_tilemap->mark_tile_dirty((offset ^ 0x7c0) >> 1);
m_tx_tilemap->mark_tile_dirty(offset >> 1);
}
}
@ -683,8 +634,21 @@ void argus_state::bg_setting()
{
if (m_bg_tilemap[0] != nullptr)
{
m_bg_tilemap[0]->set_scrollx(0, bg_scrollx(0) & 0x1ff);
m_bg_tilemap[0]->set_scrolly(0, bg_scrolly(0) & 0x1ff);
if ((m_vrom[0] != nullptr) && (m_vrom[1] != nullptr))
{
if (m_vrom_offset != m_bg_scrollx[0][1])
{
m_vrom_offset = m_bg_scrollx[0][1];
m_bg_tilemap[0]->mark_all_dirty();
}
m_bg_tilemap[0]->set_scrollx(0, m_bg_scrollx[0][0]);
m_bg_tilemap[0]->set_scrolly(0, bg_scrolly(0));
}
else
{
m_bg_tilemap[0]->set_scrollx(0, bg_scrollx(0));
m_bg_tilemap[0]->set_scrolly(0, bg_scrolly(0));
}
}
m_bg_tilemap[1]->set_scrollx(0, bg_scrollx(1) & 0x1ff);
m_bg_tilemap[1]->set_scrolly(0, bg_scrolly(1) & 0x1ff);
@ -693,105 +657,24 @@ void argus_state::bg_setting()
{
if (m_bg_tilemap[0] != nullptr)
{
m_bg_tilemap[0]->set_scrollx(0, (bg_scrollx(0) + 256) & 0x1ff);
m_bg_tilemap[0]->set_scrolly(0, (bg_scrolly(0) + 256) & 0x1ff);
}
m_bg_tilemap[1]->set_scrollx(0, (bg_scrollx(1) + 256) & 0x1ff);
m_bg_tilemap[1]->set_scrolly(0, (bg_scrolly(1) + 256) & 0x1ff);
}
}
void argus_state::argus_bg0_scroll_handle()
{
int delta;
int dcolumn;
/* Deficit between previous and current scroll value */
delta = bg_scrollx(0) - m_prvscrollx;
m_prvscrollx = bg_scrollx(0);
if (delta == 0)
return;
if (delta > 0)
if ((m_vrom[0] != nullptr) && (m_vrom[1] != nullptr))
{
m_lowbitscroll += delta & 0xf;
dcolumn = delta >> 4;
if (m_lowbitscroll >= 16)
if (m_vrom_offset != ((m_bg_scrollx[0][1] + 1) & 0xff))
{
dcolumn++;
m_lowbitscroll -= 16;
}
if (dcolumn != 0)
{
int i, j;
int col, woffs, roffs;
col = ((bg_scrollx(0) >> 4) + 16) & 0x1f;
woffs = 32 * 2 * col;
roffs = (((bg_scrollx(0) >> 4) + 16) * 8) & 0x7fff;
if (dcolumn >= 18)
dcolumn = 18;
for (i = 0; i < dcolumn; i++)
{
for (j = 0; j < 4; j++)
{
argus_write_dummy_rams(woffs, roffs);
woffs += 16;
roffs += 2;
}
woffs -= 128;
roffs -= 16;
if (woffs < 0)
woffs += 0x800;
if (roffs < 0)
roffs += 0x8000;
}
m_vrom_offset = ((m_bg_scrollx[0][1] + 1) & 0xff);
m_bg_tilemap[0]->mark_all_dirty();
}
m_bg_tilemap[0]->set_scrollx(0, m_bg_scrollx[0][0]);
m_bg_tilemap[0]->set_scrolly(0, (bg_scrolly(0) + 256));
}
else
{
m_lowbitscroll += (delta & 0xf);
dcolumn = -(delta >> 4);
if (m_lowbitscroll <= 0)
{
dcolumn++;
m_lowbitscroll += 16;
}
if (dcolumn != 0)
{
int i, j;
int col, woffs, roffs;
col = ((bg_scrollx(0) >> 4) + 31) & 0x1f;
woffs = 32 * 2 * col;
roffs = ((bg_scrollx(0) >> 4) - 1) * 8;
if (roffs < 0)
roffs += 0x08000;
if (dcolumn >= 18)
dcolumn = 18;
for (i = 0; i < dcolumn; i++)
{
for (j = 0; j < 4; j++)
{
argus_write_dummy_rams(woffs, roffs);
woffs += 16;
roffs += 2;
}
if (woffs >= 0x800)
woffs -= 0x800;
if (roffs >= 0x8000)
roffs -= 0x8000;
m_bg_tilemap[0]->set_scrollx(0, (bg_scrollx(0) + 256));
m_bg_tilemap[0]->set_scrolly(0, (bg_scrolly(0) + 256));
}
}
m_bg_tilemap[1]->set_scrollx(0, (bg_scrollx(1) + 256) & 0x1ff);
m_bg_tilemap[1]->set_scrolly(0, (bg_scrolly(1) + 256) & 0x1ff);
}
}
@ -1122,9 +1005,6 @@ uint32_t argus_state::screen_update_argus(screen_device &screen, bitmap_rgb32 &b
{
bg_setting();
/* scroll BG0 and render tile at proper position */
argus_bg0_scroll_handle();
m_bg_tilemap[0]->draw(screen, bitmap, cliprect, 0, 0);
argus_draw_sprites(bitmap, cliprect, 0);
if (m_bg_status & 1) /* Backgound enable */