mirror of
https://github.com/holub/mame
synced 2025-06-07 21:33:45 +03:00
Merge pull request #5948 from cam900/tmap038_mirror
tmap038.cpp : Add tile size check related to vram is found, Move mirroring map into driver
This commit is contained in:
commit
709bed482f
@ -464,7 +464,7 @@ void cave_state::ddonpach_map(address_map &map)
|
|||||||
map(0x400000, 0x40ffff).ram().share("spriteram.0"); // Sprites
|
map(0x400000, 0x40ffff).ram().share("spriteram.0"); // Sprites
|
||||||
map(0x500000, 0x507fff).m(m_tilemap[0], FUNC(tilemap038_device::vram_map)); // Layer 0
|
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(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, 0x80007f).writeonly().share("videoregs.0"); // Video Regs
|
||||||
map(0x800000, 0x800007).r(FUNC(cave_state::irq_cause_r)); // IRQ Cause
|
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
|
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(0x100000, 0x10ffff).ram(); // RAM
|
||||||
map(0x200000, 0x207fff).m(m_tilemap[1], FUNC(tilemap038_device::vram_map)); // Layer 1
|
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(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(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(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(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(0x300000, 0x300007).r(FUNC(cave_state::irq_cause_r)); // IRQ Cause
|
||||||
map(0x300068, 0x300069).w("watchdog", FUNC(watchdog_timer_device::reset16_w)); // Watchdog
|
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(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(0x400000, 0x403fff).mirror(0x004000).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(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(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(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
|
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(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(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(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(0xa00000, 0xa0ffff).ram().share("spriteram.0"); // Sprites
|
||||||
map(0xa10000, 0xa1ffff).ram(); // Sprites?
|
map(0xa10000, 0xa1ffff).ram(); // Sprites?
|
||||||
map(0xa80000, 0xa8007f).ram().r(FUNC(cave_state::donpachi_videoregs_r)).share("videoregs.0"); // Video Regs
|
map(0xa80000, 0xa8007f).ram().r(FUNC(cave_state::donpachi_videoregs_r)).share("videoregs.0"); // Video Regs
|
||||||
|
@ -1116,10 +1116,10 @@ inline void cave_state::tilemap_draw(int chip,
|
|||||||
/* An additional 8 pixel offset for layers with 8x8 tiles. Plus
|
/* 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 0 is displaced by 1 pixel wrt Layer 1, so is Layer 2 wrt
|
||||||
Layer 1 */
|
Layer 1 */
|
||||||
if (TILEMAP == m_tilemap[0]) offs_x -= (TILEMAP->tiledim() ? 1 : (1 + 8));
|
if (TILEMAP == m_tilemap[0]) offs_x -= (TILEMAP->tile_is_16x16() ? 1 : (1 + 8));
|
||||||
else if (TILEMAP == m_tilemap[1]) offs_x -= (TILEMAP->tiledim() ? 2 : (2 + 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->tiledim() ? 3 : (3 + 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->tiledim() ? 4 : (4 + 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 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);
|
const int sy = TILEMAP->scrolly() - m_videoregs[chip][1] + (flipy ? (offs_y + 2) : -offs_y);
|
||||||
|
@ -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. */
|
4000-7fff range for tiles, so we have to write the data there. */
|
||||||
void tilemap038_device::vram_8x8_map(address_map &map)
|
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")
|
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)
|
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 = (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;
|
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())
|
if (!m_038_cb.isnull())
|
||||||
m_038_cb(true, color, pri, code);
|
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;
|
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)
|
if (m_vram_16x16 == nullptr && m_vram_8x8 == nullptr)
|
||||||
fatalerror("Tilemap 038 %s: VRAM not found",this->tag());
|
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_tmap = &machine().tilemap().create(
|
||||||
*m_gfxdecode,
|
*m_gfxdecode,
|
||||||
tilemap_get_info_delegate(*this, FUNC(tilemap038_device::get_tile_info)),
|
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)
|
void tilemap038_device::vram_8x8_w(offs_t offset, u16 data, u16 mem_mask)
|
||||||
{
|
{
|
||||||
COMBINE_DATA(&m_vram_8x8[offset]);
|
COMBINE_DATA(&m_vram_8x8[offset]);
|
||||||
if (!m_tiledim)
|
if (tile_is_8x8())
|
||||||
m_tmap->mark_tile_dirty(offset/2);
|
m_tmap->mark_tile_dirty(offset >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 tilemap038_device::vram_16x16_r(offs_t offset)
|
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)
|
void tilemap038_device::vram_16x16_w(offs_t offset, u16 data, u16 mem_mask)
|
||||||
{
|
{
|
||||||
COMBINE_DATA(&m_vram_16x16[offset]);
|
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;
|
offset = (offset % (512 / 16)) * 2 + (offset / (512 / 16)) * (512 / 8) * 2;
|
||||||
m_tmap->mark_tile_dirty(offset + 0);
|
m_tmap->mark_tile_dirty(offset + 0);
|
||||||
m_tmap->mark_tile_dirty(offset + 1);
|
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()
|
void tilemap038_device::prepare()
|
||||||
{
|
{
|
||||||
/* Enable layers */
|
|
||||||
m_tmap->enable(enable());
|
|
||||||
|
|
||||||
// refresh tile size
|
// refresh tile size
|
||||||
if (m_vram_8x8 != nullptr && m_vram_16x16 != nullptr)
|
if (m_vram_8x8 != nullptr && m_vram_16x16 != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -81,6 +81,8 @@ public:
|
|||||||
bool enable() const { return BIT(~m_vregs[2], 4); }
|
bool enable() const { return BIT(~m_vregs[2], 4); }
|
||||||
u16 external() const { return m_vregs[2] & 0xf; }
|
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:
|
protected:
|
||||||
virtual void device_start() override;
|
virtual void device_start() override;
|
||||||
virtual void device_reset() override;
|
virtual void device_reset() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user