yunsun16.cpp : Cleanups

Cleanup duplicates, Reduce runtime tag lookups, Reduce unused, Fix notes, Cleanup tilemap scanning
This commit is contained in:
cam900 2018-09-04 20:46:06 +09:00 committed by Vas Crabb
parent b3617e279b
commit 6f94dfc951
3 changed files with 64 additions and 97 deletions

View File

@ -107,7 +107,14 @@ Stephh's notes (based on the games M68000 code and some tests) :
WRITE8_MEMBER(yunsun16_state::sound_bank_w)
{
membank("okibank")->set_entry(data & 3);
m_okibank->set_entry(data & 3);
}
template<int Layer>
WRITE16_MEMBER(yunsun16_state::vram_w)
{
COMBINE_DATA(&m_vram[Layer][offset]);
m_tilemap[Layer]->mark_tile_dirty(offset / 2);
}
void yunsun16_state::main_map(address_map &map)
@ -129,8 +136,8 @@ void yunsun16_state::main_map(address_map &map)
map(0x800189, 0x800189).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); // Sound
map(0x8001fe, 0x8001ff).nopw(); // ? 0 (during int)
map(0x900000, 0x903fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); // Palette
map(0x908000, 0x90bfff).ram().w(FUNC(yunsun16_state::vram_1_w)).share("vram_1"); // Layer 1
map(0x90c000, 0x90ffff).ram().w(FUNC(yunsun16_state::vram_0_w)).share("vram_0"); // Layer 0
map(0x908000, 0x90bfff).ram().w(FUNC(yunsun16_state::vram_w<1>)).share("vram_1"); // Layer 1
map(0x90c000, 0x90ffff).ram().w(FUNC(yunsun16_state::vram_w<0>)).share("vram_0"); // Layer 0
map(0x910000, 0x910fff).ram().share("spriteram"); // Sprites
map(0xff0000, 0xffffff).ram();
}
@ -565,25 +572,20 @@ void yunsun16_state::machine_start()
{
save_item(NAME(m_sprites_scrolldx));
save_item(NAME(m_sprites_scrolldy));
if (m_okibank)
{
m_okibank->configure_entries(0, 0x80000 / 0x20000, memregion("oki")->base(), 0x20000);
}
}
void yunsun16_state::machine_reset()
{
m_sprites_scrolldx = -0x40;
m_sprites_scrolldy = -0x0f;
}
MACHINE_START_MEMBER(yunsun16_state, shocking)
{
machine_start();
membank("okibank")->configure_entries(0, 0x80000 / 0x20000, memregion("oki")->base(), 0x20000);
membank("okibank")->set_entry(0);
}
MACHINE_RESET_MEMBER(yunsun16_state, shocking)
{
machine_reset();
membank("okibank")->set_entry(0);
if (m_okibank)
{
m_okibank->set_entry(0);
}
}
/***************************************************************************
@ -601,18 +603,16 @@ MACHINE_CONFIG_START(yunsun16_state::magicbub)
MCFG_DEVICE_PROGRAM_MAP(sound_map)
MCFG_DEVICE_IO_MAP(sound_port_map)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_RAW_PARAMS(XTAL(16'000'000)/2, 512, 0x20, 0x180-0x20, 260, 0, 0xe0) /* TODO: completely inaccurate */
MCFG_SCREEN_UPDATE_DRIVER(yunsun16_state, screen_update_yunsun16)
MCFG_SCREEN_UPDATE_DRIVER(yunsun16_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_yunsun16)
MCFG_PALETTE_ADD("palette", 8192)
MCFG_PALETTE_FORMAT(xRRRRRGGGGGBBBBB)
/* sound hardware */
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
@ -641,13 +641,10 @@ MACHINE_CONFIG_START(yunsun16_state::shocking)
MCFG_DEVICE_PROGRAM_MAP(main_map)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", yunsun16_state, irq2_line_hold)
MCFG_MACHINE_START_OVERRIDE(yunsun16_state, shocking)
MCFG_MACHINE_RESET_OVERRIDE(yunsun16_state, shocking)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_RAW_PARAMS(XTAL(16'000'000)/2, 512, 0, 0x180-4, 260, 0, 0xe0) /* TODO: completely inaccurate */
MCFG_SCREEN_UPDATE_DRIVER(yunsun16_state, screen_update_yunsun16)
MCFG_SCREEN_UPDATE_DRIVER(yunsun16_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_yunsun16)

View File

@ -22,12 +22,11 @@ public:
m_screen(*this, "screen"),
m_palette(*this, "palette"),
m_soundlatch(*this, "soundlatch"),
m_vram_0(*this, "vram_0"),
m_vram_1(*this, "vram_1"),
m_scrollram_0(*this, "scrollram_0"),
m_scrollram_1(*this, "scrollram_1"),
m_vram(*this, "vram_%u", 0U),
m_scrollram(*this, "scrollram_%u", 0U),
m_priorityram(*this, "priorityram"),
m_spriteram(*this, "spriteram") { }
m_spriteram(*this, "spriteram"),
m_okibank(*this, "okibank") { }
void magicbub(machine_config &config);
void shocking(machine_config &config);
@ -41,36 +40,31 @@ private:
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
optional_device<generic_latch_8_device> m_soundlatch; // not shocking
optional_device<generic_latch_8_device> m_soundlatch; // magicbub
/* memory pointers */
required_shared_ptr<uint16_t> m_vram_0;
required_shared_ptr<uint16_t> m_vram_1;
required_shared_ptr<uint16_t> m_scrollram_0;
required_shared_ptr<uint16_t> m_scrollram_1;
required_shared_ptr_array<uint16_t, 2> m_vram;
required_shared_ptr_array<uint16_t, 2> m_scrollram;
required_shared_ptr<uint16_t> m_priorityram;
required_shared_ptr<uint16_t> m_spriteram;
optional_memory_bank m_okibank;
/* other video-related elements */
tilemap_t *m_tilemap_0;
tilemap_t *m_tilemap_1;
tilemap_t *m_tilemap[2];
int m_sprites_scrolldx;
int m_sprites_scrolldy;
DECLARE_WRITE8_MEMBER(sound_bank_w);
DECLARE_WRITE16_MEMBER(magicbub_sound_command_w);
DECLARE_WRITE16_MEMBER(vram_0_w);
DECLARE_WRITE16_MEMBER(vram_1_w);
template<int Layer> DECLARE_WRITE16_MEMBER(vram_w);
DECLARE_MACHINE_START(shocking);
DECLARE_MACHINE_RESET(shocking);
TILEMAP_MAPPER_MEMBER(tilemap_scan_pages);
TILE_GET_INFO_MEMBER(get_tile_info_0);
TILE_GET_INFO_MEMBER(get_tile_info_1);
template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info);
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
uint32_t screen_update_yunsun16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
void main_map(address_map &map);

View File

@ -34,53 +34,29 @@
***************************************************************************/
#define TMAP_GFX (0)
/*
#define TILES_PER_PAGE_X (0x10)
#define TILES_PER_PAGE_Y (0x10)
#define PAGES_PER_TMAP_X (0x4)
#define PAGES_PER_TMAP_Y (0x4)
*/
TILEMAP_MAPPER_MEMBER(yunsun16_state::tilemap_scan_pages)
{
return (row / TILES_PER_PAGE_Y) * TILES_PER_PAGE_X * TILES_PER_PAGE_Y * PAGES_PER_TMAP_X +
(row % TILES_PER_PAGE_Y) +
(col / TILES_PER_PAGE_X) * TILES_PER_PAGE_X * TILES_PER_PAGE_Y +
(col % TILES_PER_PAGE_X) * TILES_PER_PAGE_Y;
return ((row & 0x30) << 6) | ((col & 0x3f) << 4) | (row & 0xf);
}
TILE_GET_INFO_MEMBER(yunsun16_state::get_tile_info_0)
template<int Layer>
TILE_GET_INFO_MEMBER(yunsun16_state::get_tile_info)
{
uint16_t code = m_vram_0[2 * tile_index + 0];
uint16_t attr = m_vram_0[2 * tile_index + 1];
SET_TILE_INFO_MEMBER(TMAP_GFX,
uint16_t code = m_vram[Layer][2 * tile_index + 0];
uint16_t attr = m_vram[Layer][2 * tile_index + 1];
SET_TILE_INFO_MEMBER(0,
code,
attr & 0xf,
(attr & 0x20) ? TILE_FLIPX : 0);
}
TILE_GET_INFO_MEMBER(yunsun16_state::get_tile_info_1)
{
uint16_t code = m_vram_1[2 * tile_index + 0];
uint16_t attr = m_vram_1[2 * tile_index + 1];
SET_TILE_INFO_MEMBER(TMAP_GFX,
code,
attr & 0xf,
(attr & 0x20) ? TILE_FLIPX : 0);
}
WRITE16_MEMBER(yunsun16_state::vram_0_w)
{
COMBINE_DATA(&m_vram_0[offset]);
m_tilemap_0->mark_tile_dirty(offset / 2);
}
WRITE16_MEMBER(yunsun16_state::vram_1_w)
{
COMBINE_DATA(&m_vram_1[offset]);
m_tilemap_1->mark_tile_dirty(offset / 2);
}
/***************************************************************************
@ -92,21 +68,21 @@ WRITE16_MEMBER(yunsun16_state::vram_1_w)
void yunsun16_state::video_start()
{
m_tilemap_0 = &machine().tilemap().create(
*m_gfxdecode, tilemap_get_info_delegate(FUNC(yunsun16_state::get_tile_info_0),this),tilemap_mapper_delegate(FUNC(yunsun16_state::tilemap_scan_pages),this),
16,16, TILES_PER_PAGE_X*PAGES_PER_TMAP_X,TILES_PER_PAGE_Y*PAGES_PER_TMAP_Y);
m_tilemap_1 = &machine().tilemap().create(
*m_gfxdecode, tilemap_get_info_delegate(FUNC(yunsun16_state::get_tile_info_1),this),tilemap_mapper_delegate(FUNC(yunsun16_state::tilemap_scan_pages),this),
16,16, TILES_PER_PAGE_X*PAGES_PER_TMAP_X,TILES_PER_PAGE_Y*PAGES_PER_TMAP_Y);
m_tilemap[0] = &machine().tilemap().create(
*m_gfxdecode, tilemap_get_info_delegate(FUNC(yunsun16_state::get_tile_info<0>),this),tilemap_mapper_delegate(FUNC(yunsun16_state::tilemap_scan_pages),this),
16, 16, 0x40, 0x40);
m_tilemap[1] = &machine().tilemap().create(
*m_gfxdecode, tilemap_get_info_delegate(FUNC(yunsun16_state::get_tile_info<1>),this),tilemap_mapper_delegate(FUNC(yunsun16_state::tilemap_scan_pages),this),
16, 16, 0x40, 0x40);
m_tilemap_0->set_scrolldx(-0x34, 0);
m_tilemap_1->set_scrolldx(-0x38, 0);
m_tilemap[0]->set_scrolldx(-0x34, 0);
m_tilemap[1]->set_scrolldx(-0x38, 0);
m_tilemap_0->set_scrolldy(-0x10, 0);
m_tilemap_1->set_scrolldy(-0x10, 0);
m_tilemap[0]->set_scrolldy(-0x10, 0);
m_tilemap[1]->set_scrolldy(-0x10, 0);
m_tilemap_0->set_transparent_pen(0xff);
m_tilemap_1->set_transparent_pen(0xff);
m_tilemap[0]->set_transparent_pen(0xff);
m_tilemap[1]->set_transparent_pen(0xff);
}
@ -193,13 +169,13 @@ void yunsun16_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap,
***************************************************************************/
uint32_t yunsun16_state::screen_update_yunsun16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
uint32_t yunsun16_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_tilemap_0->set_scrollx(0, m_scrollram_0[0]);
m_tilemap_0->set_scrolly(0, m_scrollram_0[1]);
m_tilemap[0]->set_scrollx(0, m_scrollram[0][0]);
m_tilemap[0]->set_scrolly(0, m_scrollram[0][1]);
m_tilemap_1->set_scrollx(0, m_scrollram_1[0]);
m_tilemap_1->set_scrolly(0, m_scrollram_1[1]);
m_tilemap[1]->set_scrollx(0, m_scrollram[1][0]);
m_tilemap[1]->set_scrolly(0, m_scrollram[1][1]);
//popmessage("%04X", *m_priorityram);
@ -208,16 +184,16 @@ uint32_t yunsun16_state::screen_update_yunsun16(screen_device &screen, bitmap_in
if ((*m_priorityram & 0x0c) == 4)
{
/* The color of the this layer's transparent pen goes below everything */
m_tilemap_0->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
m_tilemap_0->draw(screen, bitmap, cliprect, 0, 1);
m_tilemap_1->draw(screen, bitmap, cliprect, 0, 2);
m_tilemap[0]->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
m_tilemap[0]->draw(screen, bitmap, cliprect, 0, 1);
m_tilemap[1]->draw(screen, bitmap, cliprect, 0, 2);
}
else if ((*m_priorityram & 0x0c) == 8)
{
/* The color of the this layer's transparent pen goes below everything */
m_tilemap_1->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
m_tilemap_1->draw(screen, bitmap, cliprect, 0, 1);
m_tilemap_0->draw(screen, bitmap, cliprect, 0, 2);
m_tilemap[1]->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
m_tilemap[1]->draw(screen, bitmap, cliprect, 0, 1);
m_tilemap[0]->draw(screen, bitmap, cliprect, 0, 2);
}
draw_sprites(screen, bitmap, cliprect);