From cd8acecaf5e260183b71c4737f76980aacfbbb1c Mon Sep 17 00:00:00 2001 From: cam900 Date: Sat, 23 Nov 2019 11:40:05 +0900 Subject: tmap038.cpp : Add tile size check related to vram is found, Move mirroring map into driver --- src/mame/drivers/cave.cpp | 10 +++++----- src/mame/video/cave.cpp | 8 ++++---- src/mame/video/tmap038.cpp | 24 ++++++++---------------- src/mame/video/tmap038.h | 20 +++++++++++--------- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/mame/drivers/cave.cpp b/src/mame/drivers/cave.cpp index 460854cae48..a7c79374c02 100644 --- a/src/mame/drivers/cave.cpp +++ b/src/mame/drivers/cave.cpp @@ -464,7 +464,7 @@ void cave_state::ddonpach_map(address_map &map) map(0x400000, 0x40ffff).ram().share("spriteram.0"); // Sprites map(0x500000, 0x507fff).m(m_tilemap[0], FUNC(tilemap038_device::vram_map)); // Layer 0 map(0x600000, 0x607fff).m(m_tilemap[1], FUNC(tilemap038_device::vram_map)); // Layer 1 - map(0x700000, 0x70ffff).m(m_tilemap[2], FUNC(tilemap038_device::vram_8x8_map)); // Layer 2 + map(0x700000, 0x703fff).mirror(0x00c000).m(m_tilemap[2], FUNC(tilemap038_device::vram_8x8_map)); // Layer 2 map(0x800000, 0x80007f).writeonly().share("videoregs.0"); // Video Regs map(0x800000, 0x800007).r(FUNC(cave_state::irq_cause_r)); // IRQ Cause map(0x900000, 0x900005).rw(m_tilemap[0], FUNC(tilemap038_device::vregs_r), FUNC(tilemap038_device::vregs_w)); // Layer 0 Control @@ -500,7 +500,7 @@ void cave_state::donpachi_map(address_map &map) map(0x100000, 0x10ffff).ram(); // RAM map(0x200000, 0x207fff).m(m_tilemap[1], FUNC(tilemap038_device::vram_map)); // Layer 1 map(0x300000, 0x307fff).m(m_tilemap[0], FUNC(tilemap038_device::vram_map)); // Layer 0 - map(0x400000, 0x407fff).m(m_tilemap[2], FUNC(tilemap038_device::vram_8x8_map)); // Layer 2 + map(0x400000, 0x403fff).mirror(0x004000).m(m_tilemap[2], FUNC(tilemap038_device::vram_8x8_map)); // Layer 2 map(0x500000, 0x50ffff).ram().share("spriteram.0"); // Sprites map(0x600000, 0x600005).rw(m_tilemap[1], FUNC(tilemap038_device::vregs_r), FUNC(tilemap038_device::vregs_w)); // Layer 1 Control map(0x700000, 0x700005).rw(m_tilemap[0], FUNC(tilemap038_device::vregs_r), FUNC(tilemap038_device::vregs_w)); // Layer 0 Control @@ -740,8 +740,8 @@ void cave_state::mazinger_map(address_map &map) map(0x300000, 0x300007).r(FUNC(cave_state::irq_cause_r)); // IRQ Cause map(0x300068, 0x300069).w("watchdog", FUNC(watchdog_timer_device::reset16_w)); // Watchdog map(0x30006e, 0x30006f).rw(FUNC(cave_state::soundlatch_ack_r), FUNC(cave_state::sound_cmd_w)); // From Sound CPU - map(0x400000, 0x407fff).m(m_tilemap[1], FUNC(tilemap038_device::vram_8x8_map)); // Layer 1 - map(0x500000, 0x507fff).m(m_tilemap[0], FUNC(tilemap038_device::vram_8x8_map)); // Layer 0 + map(0x400000, 0x403fff).mirror(0x004000).m(m_tilemap[1], FUNC(tilemap038_device::vram_8x8_map)); // Layer 1 + map(0x500000, 0x503fff).mirror(0x004000).m(m_tilemap[0], FUNC(tilemap038_device::vram_8x8_map)); // Layer 0 map(0x600000, 0x600005).rw(m_tilemap[1], FUNC(tilemap038_device::vregs_r), FUNC(tilemap038_device::vregs_w)); // Layer 1 Control map(0x700000, 0x700005).rw(m_tilemap[0], FUNC(tilemap038_device::vregs_r), FUNC(tilemap038_device::vregs_w)); // Layer 0 Control map(0x800000, 0x800001).portr("IN0"); // Inputs @@ -937,7 +937,7 @@ void cave_state::pwrinst2_map(address_map &map) map(0x800000, 0x807fff).m(m_tilemap[2], FUNC(tilemap038_device::vram_map)); // Layer 2 map(0x880000, 0x887fff).m(m_tilemap[0], FUNC(tilemap038_device::vram_map)); // Layer 0 map(0x900000, 0x907fff).m(m_tilemap[1], FUNC(tilemap038_device::vram_map)); // Layer 1 - map(0x980000, 0x987fff).m(m_tilemap[3], FUNC(tilemap038_device::vram_8x8_map)); // Layer 3 + map(0x980000, 0x983fff).mirror(0x004000).m(m_tilemap[3], FUNC(tilemap038_device::vram_8x8_map)); // Layer 3 map(0xa00000, 0xa0ffff).ram().share("spriteram.0"); // Sprites map(0xa10000, 0xa1ffff).ram(); // Sprites? map(0xa80000, 0xa8007f).ram().r(FUNC(cave_state::donpachi_videoregs_r)).share("videoregs.0"); // Video Regs diff --git a/src/mame/video/cave.cpp b/src/mame/video/cave.cpp index c5ae187ff2b..d43266a74ca 100644 --- a/src/mame/video/cave.cpp +++ b/src/mame/video/cave.cpp @@ -1116,10 +1116,10 @@ inline void cave_state::tilemap_draw(int chip, /* An additional 8 pixel offset for layers with 8x8 tiles. Plus Layer 0 is displaced by 1 pixel wrt Layer 1, so is Layer 2 wrt Layer 1 */ - if (TILEMAP == m_tilemap[0]) offs_x -= (TILEMAP->tiledim() ? 1 : (1 + 8)); - else if (TILEMAP == m_tilemap[1]) offs_x -= (TILEMAP->tiledim() ? 2 : (2 + 8)); - else if (TILEMAP == m_tilemap[2]) offs_x -= (TILEMAP->tiledim() ? 3 : (3 + 8)); - else if (TILEMAP == m_tilemap[3]) offs_x -= (TILEMAP->tiledim() ? 4 : (4 + 8)); + if (TILEMAP == m_tilemap[0]) offs_x -= (TILEMAP->tile_is_16x16() ? 1 : (1 + 8)); + else if (TILEMAP == m_tilemap[1]) offs_x -= (TILEMAP->tile_is_16x16() ? 2 : (2 + 8)); + else if (TILEMAP == m_tilemap[2]) offs_x -= (TILEMAP->tile_is_16x16() ? 3 : (3 + 8)); + else if (TILEMAP == m_tilemap[3]) offs_x -= (TILEMAP->tile_is_16x16() ? 4 : (4 + 8)); const int sx = TILEMAP->scrollx() - m_videoregs[chip][0] + (flipx ? (offs_x + 2) : -offs_x); const int sy = TILEMAP->scrolly() - m_videoregs[chip][1] + (flipy ? (offs_y + 2) : -offs_y); diff --git a/src/mame/video/tmap038.cpp b/src/mame/video/tmap038.cpp index 95759c2be75..38259e030e8 100644 --- a/src/mame/video/tmap038.cpp +++ b/src/mame/video/tmap038.cpp @@ -123,7 +123,7 @@ void tilemap038_device::vram_16x16_writeonly_map(address_map &map) 4000-7fff range for tiles, so we have to write the data there. */ void tilemap038_device::vram_8x8_map(address_map &map) { - map(0x0000, 0x3fff).mirror(0x4000).rw(FUNC(tilemap038_device::vram_8x8_r), FUNC(tilemap038_device::vram_8x8_w)).share("vram_8x8"); + map(0x0000, 0x3fff).rw(FUNC(tilemap038_device::vram_8x8_r), FUNC(tilemap038_device::vram_8x8_w)).share("vram_8x8"); } DEFINE_DEVICE_TYPE(TMAP038, tilemap038_device, "tmap038", "038 Tilemap generator") @@ -143,9 +143,9 @@ tilemap038_device::tilemap038_device(const machine_config &mconfig, const char * TILE_GET_INFO_MEMBER(tilemap038_device::get_tile_info) { - u32 tile, code, color, pri; + u32 tile, code = 0, color = 0, pri = 0; - if (m_tiledim) + if (tile_is_16x16()) { tile = (tile_index % (512 / 8)) / 2 + ((tile_index / (512 / 8)) / 2) * (512 / 16); tile = (m_vram_16x16 != nullptr) ? ((m_vram_16x16[tile * 2] << 16) + m_vram_16x16[(tile * 2) + 1]) : 0; @@ -160,7 +160,7 @@ TILE_GET_INFO_MEMBER(tilemap038_device::get_tile_info) if (!m_038_cb.isnull()) m_038_cb(true, color, pri, code); } - else + else if (tile_is_8x8()) { tile = (m_vram_8x8 != nullptr) ? ((m_vram_8x8[tile_index * 2] << 16) + m_vram_8x8[(tile_index * 2) + 1]) : 0; @@ -185,11 +185,6 @@ void tilemap038_device::device_start() if (m_vram_16x16 == nullptr && m_vram_8x8 == nullptr) fatalerror("Tilemap 038 %s: VRAM not found",this->tag()); - if (m_vram_8x8 == nullptr) - m_tiledim = true; - else if (m_vram_16x16 == nullptr) - m_tiledim = false; - m_tmap = &machine().tilemap().create( *m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tilemap038_device::get_tile_info)), @@ -217,8 +212,8 @@ u16 tilemap038_device::vram_8x8_r(offs_t offset) void tilemap038_device::vram_8x8_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_vram_8x8[offset]); - if (!m_tiledim) - m_tmap->mark_tile_dirty(offset/2); + if (tile_is_8x8()) + m_tmap->mark_tile_dirty(offset >> 1); } u16 tilemap038_device::vram_16x16_r(offs_t offset) @@ -229,9 +224,9 @@ u16 tilemap038_device::vram_16x16_r(offs_t offset) void tilemap038_device::vram_16x16_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_vram_16x16[offset]); - if (m_tiledim) + if (tile_is_16x16()) { - offset /= 2; + offset >>= 1; offset = (offset % (512 / 16)) * 2 + (offset / (512 / 16)) * (512 / 8) * 2; m_tmap->mark_tile_dirty(offset + 0); m_tmap->mark_tile_dirty(offset + 1); @@ -242,9 +237,6 @@ void tilemap038_device::vram_16x16_w(offs_t offset, u16 data, u16 mem_mask) void tilemap038_device::prepare() { - /* Enable layers */ - m_tmap->enable(enable()); - // refresh tile size if (m_vram_8x8 != nullptr && m_vram_16x16 != nullptr) { diff --git a/src/mame/video/tmap038.h b/src/mame/video/tmap038.h index 24506f553dc..3a0773c24cf 100644 --- a/src/mame/video/tmap038.h +++ b/src/mame/video/tmap038.h @@ -69,18 +69,20 @@ public: u16 vregs(offs_t offset) const { return m_vregs[offset]; } // vregs - bool flipx() const { return BIT(~m_vregs[0], 15); } - bool rowscroll_en() const { return BIT(m_vregs[0], 14) && (m_lineram != nullptr); } - u16 scrollx() const { return m_vregs[0] & 0x1ff; } + bool flipx() const { return BIT(~m_vregs[0], 15); } + bool rowscroll_en() const { return BIT(m_vregs[0], 14) && (m_lineram != nullptr); } + u16 scrollx() const { return m_vregs[0] & 0x1ff; } - bool flipy() const { return BIT(~m_vregs[1], 15); } - bool rowselect_en() const { return BIT(m_vregs[1], 14) && (m_lineram != nullptr); } - bool tiledim() const { return m_tiledim; } - u16 scrolly() const { return m_vregs[1] & 0x1ff; } + bool flipy() const { return BIT(~m_vregs[1], 15); } + bool rowselect_en() const { return BIT(m_vregs[1], 14) && (m_lineram != nullptr); } + bool tiledim() const { return m_tiledim; } + u16 scrolly() const { return m_vregs[1] & 0x1ff; } - bool enable() const { return BIT(~m_vregs[2], 4); } - u16 external() const { return m_vregs[2] & 0xf; } + bool enable() const { return BIT(~m_vregs[2], 4); } + u16 external() const { return m_vregs[2] & 0xf; } + bool tile_is_8x8() const { return (!m_tiledim) || (m_vram_16x16 == nullptr); } + bool tile_is_16x16() const { return m_tiledim || (m_vram_8x8 == nullptr); } protected: virtual void device_start() override; virtual void device_reset() override; -- cgit v1.2.3