summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cam900 <dbtlrchl@naver.com>2019-06-20 04:20:51 +0900
committer R. Belmont <rb6502@users.noreply.github.com>2019-06-19 15:20:51 -0400
commitc5d5ab1140cc37158b05ad600e4bbbd5f4cb333f (patch)
tree2f49acda315442fb44bac8bf59aaf98f614ce291
parent7c8e3694bac9d6ac679c35aba5ea4bd52b2ba02e (diff)
tc009xlvc.cpp : Updates (#5240)
* tc009xlvc.cpp : Updates Internalize on-chip functions (ROM / RAM bankswitching, GFX, IRQ vector and enables, Palette, Vregs), Use address_map_bank_device for ram banks, Simplify handlers, Reduce unnecessary values, Lines, Pointers, Duplicates, Fix spacings, Use shorter / correct type values, Add notes dfruit.cpp, lastbank.cpp : Reduce unnecessary address map lastbank.cpp : Correct audiocpu ROM region size * tc0091lvc.cpp : currently disabled offset check * tc009xlvc.cpp : Use lw8 for bypass unmapped write * tc009xlvc.cpp : Move notes * dfruit.cpp, lastbank.cpp : Add docs for Internal maps * tc009xlvc.cpp : Fix lines * dfruit.cpp, lastbank.cpp : Fix notes * lastbank.cpp : Fix copy-n-paste error * tc009xlvc.cpp : Fix notes * tc009xlvc.cpp : Use lr8 for bankswitched ROM reading * tc009xlvc.cpp : Add notes * tc009xlvc.cpp : Fix notes * tc009xlvc.cpp : Fix notes * tc009xlvc.cpp : Add notes * tc009xlvc.cpp : Fix notes * tc009xlvc.cpp : Reduce duplicate * tc009xlvc.cpp : Externalize internal io maps * dfruit.cpp, lastbank.cpp : Reduce unnecessary changes * tc009xlvc.cpp : Move this, too * dfruit.cpp, lastbank.cpp : Fix address map range * tc009xlvc.cpp : Fix spacing
-rw-r--r--src/devices/machine/tc009xlvc.cpp396
-rw-r--r--src/devices/machine/tc009xlvc.h104
-rw-r--r--src/mame/drivers/dfruit.cpp183
-rw-r--r--src/mame/drivers/lastbank.cpp158
4 files changed, 235 insertions, 606 deletions
diff --git a/src/devices/machine/tc009xlvc.cpp b/src/devices/machine/tc009xlvc.cpp
index a870dee98a6..a0a474996ef 100644
--- a/src/devices/machine/tc009xlvc.cpp
+++ b/src/devices/machine/tc009xlvc.cpp
@@ -14,172 +14,122 @@
#include "emu.h"
#include "machine/tc009xlvc.h"
+#include "emupal.h"
#include "screen.h"
DEFINE_DEVICE_TYPE(TC0091LVC, tc0091lvc_device, "tc009xlvc", "Taito TC0091LVC")
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_paletteram_r)
-{
- return m_palette_ram[offset & 0x1ff];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_paletteram_w)
+void tc0091lvc_device::vram_w(offs_t offset, u8 data)
{
- m_palette_ram[offset & 0x1ff] = data;
+ // TODO : offset 0x0000 - 0x3fff is not used?
+ m_vram[offset] = data;
+ gfx(2)->mark_dirty(offset / 32);
+ if (offset >= 0x8000 && offset < 0x9000) // 0x8000-0x9000 bg 0
{
- uint8_t r,g,b,i;
- uint16_t pal;
-
- pal = (m_palette_ram[offset & ~1]<<0) | (m_palette_ram[offset | 1]<<8);
-
- i = (pal & 0x7000) >> 12;
- b = (pal & 0x0f00) >> 8;
- g = (pal & 0x00f0) >> 4;
- r = (pal & 0x000f) >> 0;
-
- r <<= 1;
- g <<= 1;
- b <<= 1;
-
- /* TODO: correct? */
- b |= ((i & 4) >> 2);
- g |= ((i & 2) >> 1);
- r |= (i & 1);
-
- m_gfxdecode->palette().set_pen_color(offset / 2, pal5bit(r), pal5bit(g), pal5bit(b));
+ offset -= 0x8000;
+ bg_tilemap[0]->mark_tile_dirty(offset/2);
+ }
+ else if (offset >= 0x9000 && offset < 0xa000) // 0x9000-0xa000 bg 1
+ {
+ offset -= 0x9000;
+ bg_tilemap[1]->mark_tile_dirty(offset/2);
+ }
+ else if (offset >= 0xa000 && offset < 0xb000) // 0xa000-0xb000 text
+ {
+ offset -= 0xa000;
+ tx_tilemap->mark_tile_dirty(offset/2);
}
}
-READ8_MEMBER(tc0091lvc_device::vregs_r)
-{
- return m_vregs[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::vregs_w)
+void tc0091lvc_device::vregs_w(offs_t offset, u8 data)
{
- if((offset & 0xfc) == 0)
+ if ((offset & 0xfc) == 0)
{
- bg0_tilemap->mark_all_dirty();
- bg1_tilemap->mark_all_dirty();
+ bg_tilemap[0]->mark_all_dirty();
+ bg_tilemap[1]->mark_all_dirty();
}
m_vregs[offset] = data;
}
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_bitmap_r)
-{
- return m_bitmap_ram[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_bitmap_w)
-{
- m_bitmap_ram[offset] = data;
-}
-
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_pcg1_r)
+void tc0091lvc_device::ram_bank_w(offs_t offset, u8 data)
{
- return m_pcg1_ram[offset];
+ m_ram_bank[offset] = data;
+ m_bankdev[offset]->set_bank(m_ram_bank[offset]);
}
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_pcg1_w)
+static const gfx_layout layout_8x8 =
{
- m_pcg1_ram[offset] = data;
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0x4000) / 32);
- tx_tilemap->mark_all_dirty();
-}
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_pcg2_r)
-{
- return m_pcg2_ram[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_pcg2_w)
-{
- m_pcg2_ram[offset] = data;
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0xc000) / 32);
- tx_tilemap->mark_all_dirty();
-}
-
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_vram0_r)
-{
- return m_vram0[offset];
-}
-
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_vram0_w)
-{
- m_vram0[offset] = data;
- bg0_tilemap->mark_tile_dirty(offset/2);
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0x8000) / 32);
- tx_tilemap->mark_all_dirty();
-
-}
+ 8, 8,
+ RGN_FRAC(1,1),
+ 4,
+ { 8, 12, 0, 4 },
+ { STEP4(3,-1), STEP4(4*4+3,-1) },
+ { STEP8(0,4*4*2) },
+ 8*8*4
+};
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_vram1_r)
+static const gfx_layout layout_16x16 =
{
- return m_vram1[offset];
-}
+ 16, 16,
+ RGN_FRAC(1,1),
+ 4,
+ { 8, 12, 0, 4 },
+ { STEP4(3,-1), STEP4(4*4+3,-1), STEP4(8*8*4+3,-1), STEP4(8*8*4+4*4+3,-1) },
+ { STEP8(0,4*4*2), STEP8(8*8*4*2,4*4*2) },
+ 8*8*4*4
+};
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_vram1_w)
-{
- m_vram1[offset] = data;
- bg1_tilemap->mark_tile_dirty(offset/2);
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0x9000) / 32);
- tx_tilemap->mark_all_dirty();
-}
+GFXDECODE_MEMBER(tc0091lvc_device::gfxinfo)
+ GFXDECODE_DEVICE("gfx", 0, layout_8x8, 0, 16)
+ GFXDECODE_DEVICE("gfx", 0, layout_16x16, 0, 16)
+ GFXDECODE_DEVICE_RAM("vram", 0, layout_8x8, 0, 16)
+GFXDECODE_END
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_tvram_r)
+void tc0091lvc_device::cpu_map(address_map &map)
{
- return m_tvram[offset];
-}
+ // 0x0000-0x7fff ROM (0x0000-0x5fff Fixed, 0x6000-0x7fff Bankswitched)
+ map(0x0000, 0x5fff).r(FUNC(tc0091lvc_device::rom_r));
+ map(0x6000, 0x7fff).lr8("banked_rom_r", [this](offs_t offset) { return rom_r((m_rom_bank << 13) | (offset & 0x1fff)); });
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_tvram_w)
-{
- m_tvram[offset] = data;
- tx_tilemap->mark_tile_dirty(offset/2);
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0xa000) / 32);
- tx_tilemap->mark_all_dirty();
-}
+ // 0x8000-0xbfff External mappable area
-READ8_MEMBER(tc0091lvc_device::tc0091lvc_spr_r)
-{
- return m_sprram[offset];
-}
+ // 0xc000-0xfdff RAM banks (Connected in VRAMs, 4KB boundary)
+ map(0xc000, 0xcfff).m(m_bankdev[0], FUNC(address_map_bank_device::amap8));
+ map(0xd000, 0xdfff).m(m_bankdev[1], FUNC(address_map_bank_device::amap8));
+ map(0xe000, 0xefff).m(m_bankdev[2], FUNC(address_map_bank_device::amap8));
+ map(0xf000, 0xfdff).m(m_bankdev[3], FUNC(address_map_bank_device::amap8));
-WRITE8_MEMBER(tc0091lvc_device::tc0091lvc_spr_w)
-{
- m_sprram[offset] = data;
- m_gfxdecode->gfx(m_gfx_index)->mark_dirty((offset+0xb000) / 32);
- tx_tilemap->mark_all_dirty();
+ // 0xfe00-0xffff Internal functions
}
-void tc0091lvc_device::tc0091lvc_map8(address_map &map)
+void tc0091lvc_device::banked_map(address_map &map)
{
- map(0x014000, 0x017fff).rw(FUNC(tc0091lvc_device::tc0091lvc_pcg1_r), FUNC(tc0091lvc_device::tc0091lvc_pcg1_w));
- map(0x018000, 0x018fff).rw(FUNC(tc0091lvc_device::tc0091lvc_vram0_r), FUNC(tc0091lvc_device::tc0091lvc_vram0_w));
- map(0x019000, 0x019fff).rw(FUNC(tc0091lvc_device::tc0091lvc_vram1_r), FUNC(tc0091lvc_device::tc0091lvc_vram1_w));
- map(0x01a000, 0x01afff).rw(FUNC(tc0091lvc_device::tc0091lvc_tvram_r), FUNC(tc0091lvc_device::tc0091lvc_tvram_w));
- map(0x01b000, 0x01bfff).rw(FUNC(tc0091lvc_device::tc0091lvc_spr_r), FUNC(tc0091lvc_device::tc0091lvc_spr_w));
- map(0x01c000, 0x01ffff).rw(FUNC(tc0091lvc_device::tc0091lvc_pcg2_r), FUNC(tc0091lvc_device::tc0091lvc_pcg2_w));
- map(0x040000, 0x05ffff).rw(FUNC(tc0091lvc_device::tc0091lvc_bitmap_r), FUNC(tc0091lvc_device::tc0091lvc_bitmap_w));
- map(0x080000, 0x0801ff).rw(FUNC(tc0091lvc_device::tc0091lvc_paletteram_r), FUNC(tc0091lvc_device::tc0091lvc_paletteram_w));
+ map(0x010000, 0x01ffff).readonly().share("vram");
+ // note, the way tiles are addressed suggests that 0x0000-0x3fff of this might be usable,
+ // but we don't map it anywhere, so the first tiles are always blank at the moment.
+ map(0x014000, 0x01ffff).lw8("vram_w", [this](offs_t offset, u8 data) { vram_w(offset + 0x4000, data); });
+ map(0x040000, 0x05ffff).ram().share("bitmap_ram");
+ map(0x080000, 0x0801ff).ram().w("palette", FUNC(palette_device::write8)).share("palette");
}
-tc0091lvc_device::tc0091lvc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+tc0091lvc_device::tc0091lvc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, TC0091LVC, tag, owner, clock)
- , device_memory_interface(mconfig, *this)
- , m_space_config("tc0091lvc", ENDIANNESS_LITTLE, 8,20, 0, address_map_constructor(FUNC(tc0091lvc_device::tc0091lvc_map8), this))
- , m_gfxdecode(*this, finder_base::DUMMY_TAG)
+ , device_gfx_interface(mconfig, *this, gfxinfo, "palette")
+ , m_bankdev(*this, "bankdev_%u", 0U)
+ , m_vram(*this, "vram")
+ , m_bitmap_ram(*this, "bitmap_ram")
+ , m_rom(*this, DEVICE_SELF)
{
}
-TILE_GET_INFO_MEMBER(tc0091lvc_device::get_bg0_tile_info)
+template<unsigned Offset>
+TILE_GET_INFO_MEMBER(tc0091lvc_device::get_tile_info)
{
- int attr = m_vram0[2 * tile_index + 1];
- int code = m_vram0[2 * tile_index]
+ const u16 attr = m_vram[Offset + (2 * tile_index) + 1];
+ const u16 code = m_vram[Offset + (2 * tile_index)]
| ((attr & 0x03) << 8)
| ((m_vregs[(attr & 0xc) >> 2]) << 10);
// | (state->m_horshoes_gfxbank << 12);
@@ -190,112 +140,82 @@ TILE_GET_INFO_MEMBER(tc0091lvc_device::get_bg0_tile_info)
0);
}
-TILE_GET_INFO_MEMBER(tc0091lvc_device::get_bg1_tile_info)
+TILE_GET_INFO_MEMBER(tc0091lvc_device::get_tx_tile_info)
{
- int attr = m_vram1[2 * tile_index + 1];
- int code = m_vram1[2 * tile_index]
- | ((attr & 0x03) << 8)
- | ((m_vregs[(attr & 0xc) >> 2]) << 10);
-// | (state->m_horshoes_gfxbank << 12);
+ const u16 attr = m_vram[0xa000 + (2 * tile_index) + 1];
+ const u16 code = m_vram[0xa000 + (2 * tile_index)]
+ | ((attr & 0x07) << 8);
- SET_TILE_INFO_MEMBER(0,
+ SET_TILE_INFO_MEMBER(2,
code,
(attr & 0xf0) >> 4,
0);
}
-TILE_GET_INFO_MEMBER(tc0091lvc_device::get_tx_tile_info)
-{
- int attr = m_tvram[2 * tile_index + 1];
- uint16_t code = m_tvram[2 * tile_index]
- | ((attr & 0x07) << 8);
- SET_TILE_INFO_MEMBER(m_gfx_index,
- code,
- (attr & 0xf0) >> 4,
- 0);
+void tc0091lvc_device::device_add_mconfig(machine_config &config)
+{
+ for (int i = 0; i < 4; i++)
+ {
+ ADDRESS_MAP_BANK(config, m_bankdev[i]).set_map(&tc0091lvc_device::banked_map).set_options(ENDIANNESS_LITTLE, 8, 20, 0x1000);
+ }
+ PALETTE(config, "palette", palette_device::BLACK).set_format(palette_device::xBGRBBBBGGGGRRRR_bit0, 0x100);
}
-static const gfx_layout char_layout =
+void tc0091lvc_device::device_post_load()
{
- 8, 8,
- 0x10000 / (8 * 4), // need to specify exact number because we create dynamically
- 4,
- { 8, 12, 0, 4 },
- { 3, 2, 1, 0, 19, 18, 17, 16},
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
- 8*8*4
-};
+ for (int i = 0; i < 4; i++)
+ m_bankdev[i]->set_bank(m_ram_bank[i]);
+}
void tc0091lvc_device::device_start()
{
- if(!m_gfxdecode->started())
- throw device_missing_dependencies();
+ std::fill_n(&m_vram[0], m_vram.bytes(), 0);
+ std::fill_n(&m_bitmap_ram[0], m_bitmap_ram.bytes(), 0);
+ std::fill(std::begin(m_ram_bank), std::end(m_ram_bank), 0);
+ for (int i = 0; i < 4; i++)
+ m_bankdev[i]->set_bank(m_ram_bank[i]);
- memset(m_palette_ram, 0, ARRAY_LENGTH(m_palette_ram));
- memset(m_vregs, 0, ARRAY_LENGTH(m_vregs));
- memset(m_bitmap_ram, 0, ARRAY_LENGTH(m_bitmap_ram));
- memset(m_pcg_ram, 0, ARRAY_LENGTH(m_pcg_ram));
- memset(m_sprram_buffer, 0, ARRAY_LENGTH(m_sprram_buffer));
+ m_rom_bank = 0;
- // note, the way tiles are addressed suggests that 0x0000-0x3fff of this might be usable,
- // but we don't map it anywhere, so the first tiles are always blank at the moment.
- m_pcg1_ram = m_pcg_ram + 0x4000;
- m_pcg2_ram = m_pcg_ram + 0xc000;
- m_vram0 = m_pcg_ram + 0x8000;
- m_vram1 = m_pcg_ram + 0x9000;
- m_tvram = m_pcg_ram + 0xa000;
- m_sprram = m_pcg_ram + 0xb000;
+ m_vregs = make_unique_clear<u8[]>(0x100);
+ m_sprram_buffer = make_unique_clear<u8[]>(0x400);
- tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_tx_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
- bg0_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_bg0_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
- bg1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_bg1_tile_info),this),TILEMAP_SCAN_ROWS,8,8,64,32);
+ tx_tilemap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_tx_tile_info), this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
+ bg_tilemap[0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_tile_info<0x8000>), this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
+ bg_tilemap[1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(tc0091lvc_device::get_tile_info<0x9000>), this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
tx_tilemap->set_transparent_pen(0);
- bg0_tilemap->set_transparent_pen(0);
- bg1_tilemap->set_transparent_pen(0);
+ bg_tilemap[0]->set_transparent_pen(0);
+ bg_tilemap[1]->set_transparent_pen(0);
tx_tilemap->set_scrolldx(-8, -8);
- bg0_tilemap->set_scrolldx(28, -11);
- bg1_tilemap->set_scrolldx(38, -21);
-
- for (m_gfx_index = 0; m_gfx_index < MAX_GFX_ELEMENTS; m_gfx_index++)
- if (m_gfxdecode->gfx(m_gfx_index) == nullptr)
- break;
-
- //printf("m_gfx_index %d\n", m_gfx_index);
-
- device_palette_interface &palette = m_gfxdecode->palette();
- m_gfxdecode->set_gfx(m_gfx_index, std::make_unique<gfx_element>(&palette, char_layout, (uint8_t *)m_pcg_ram, 0, palette.entries() / 16, 0));
-}
-
-device_memory_interface::space_config_vector tc0091lvc_device::memory_space_config() const
-{
- return space_config_vector {
- std::make_pair(0, &m_space_config)
- };
+ bg_tilemap[0]->set_scrolldx(28, -11);
+ bg_tilemap[1]->set_scrolldx(38, -21);
+
+ save_item(NAME(m_irq_vector));
+ save_item(NAME(m_irq_enable));
+ save_item(NAME(m_ram_bank));
+ save_item(NAME(m_rom_bank));
+ save_pointer(NAME(m_vregs), 0x100);
+ save_pointer(NAME(m_sprram_buffer), 0x400);
}
-void tc0091lvc_device::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, uint8_t global_flip )
+void tc0091lvc_device::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, u8 global_flip)
{
- gfx_element *gfx = m_gfxdecode->gfx(1);
- int count;
-
- for(count=0;count<0x3e7;count+=8)
+ for (int count = 0; count < 0x3e7; count += 8)
{
- int x,y,spr_offs,col,fx,fy;
-
- spr_offs = m_sprram_buffer[count+0]|(m_sprram_buffer[count+1]<<8);
- x = m_sprram_buffer[count+4]|(m_sprram_buffer[count+5]<<8);
+ const u32 code = m_sprram_buffer[count + 0] | (m_sprram_buffer[count + 1] << 8);
+ int x = m_sprram_buffer[count + 4] | (m_sprram_buffer[count + 5] << 8);
if (x >= 320)
x -= 512;
- y = m_sprram_buffer[count+6];
- col = (m_sprram_buffer[count+2])&0x0f;
- fx = m_sprram_buffer[count+3] & 0x1;
- fy = m_sprram_buffer[count+3] & 0x2;
+ int y = m_sprram_buffer[count + 6];
+ const u32 col = (m_sprram_buffer[count + 2]) & 0x0f;
+ int fx = m_sprram_buffer[count + 3] & 0x1;
+ int fy = m_sprram_buffer[count + 3] & 0x2;
if (global_flip)
{
@@ -305,38 +225,32 @@ void tc0091lvc_device::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap
fy = !fy;
}
- gfx->prio_transpen(bitmap,cliprect,spr_offs,col,fx,fy,x,y,screen.priority(),(col & 0x08) ? 0xaa : 0x00,0);
+ gfx(1)->prio_transpen(bitmap, cliprect, code, col, fx, fy, x, y, screen.priority(), (col & 0x08) ? 0xaa : 0x00, 0);
}
}
-uint32_t tc0091lvc_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+u32 tc0091lvc_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- uint32_t count;
- int x,y;
- uint8_t global_flip;
-
- bitmap.fill(m_gfxdecode->palette().black_pen(), cliprect);
+ bitmap.fill(palette().black_pen(), cliprect);
- if((m_vregs[4] & 0x20) == 0)
+ if ((m_vregs[4] & 0x20) == 0)
return 0;
- global_flip = m_vregs[4] & 0x10;
+ const u8 global_flip = m_vregs[4] & 0x10;
- if((m_vregs[4] & 0x7) == 7) // 8bpp bitmap enabled
+ if ((m_vregs[4] & 0x7) == 7) // 8bpp bitmap enabled
{
- count = 0;
+ u32 count = 0;
- for (y=0;y<256;y++)
+ for (int y = 0; y < 256; y++)
{
- for (x=0;x<512;x++)
+ for (int x = 0; x < 512; x++)
{
- int res_x, res_y;
+ const int res_x = (global_flip) ? 320 - x : x;
+ const int res_y = (global_flip) ? 256 - y : y;
- res_x = (global_flip) ? 320-x : x;
- res_y = (global_flip) ? 256-y : y;
-
- if(screen.visible_area().contains(res_x, res_y))
- bitmap.pix16(res_y, res_x) = m_gfxdecode->palette().pen(m_bitmap_ram[count]);
+ if (cliprect.contains(res_x, res_y))
+ bitmap.pix16(res_y, res_x) = palette().pen(m_bitmap_ram[count]);
count++;
}
@@ -344,43 +258,41 @@ uint32_t tc0091lvc_device::screen_update(screen_device &screen, bitmap_ind16 &bi
}
else
{
- int dx, dy;
-
machine().tilemap().set_flip_all(global_flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
- dx = m_bg0_scroll[0] | (m_bg0_scroll[1] << 8);
+ int dx = m_bg_scroll[0][0] | (m_bg_scroll[0][1] << 8);
if (global_flip) { dx = ((dx & 0xfffc) | ((dx - 3) & 0x0003)) ^ 0xf; dx += 192; }
- dy = m_bg0_scroll[2];
+ int dy = m_bg_scroll[0][2];
- bg0_tilemap->set_scrollx(0, -dx);
- bg0_tilemap->set_scrolly(0, -dy);
+ bg_tilemap[0]->set_scrollx(0, -dx);
+ bg_tilemap[0]->set_scrolly(0, -dy);
- dx = m_bg1_scroll[0] | (m_bg1_scroll[1] << 8);
+ dx = m_bg_scroll[1][0] | (m_bg_scroll[1][1] << 8);
if (global_flip) { dx = ((dx & 0xfffc) | ((dx - 3) & 0x0003)) ^ 0xf; dx += 192; }
- dy = m_bg1_scroll[2];
+ dy = m_bg_scroll[1][2];
- bg1_tilemap->set_scrollx(0, -dx);
- bg1_tilemap->set_scrolly(0, -dy);
+ bg_tilemap[1]->set_scrollx(0, -dx);
+ bg_tilemap[1]->set_scrolly(0, -dy);
tx_tilemap->set_scrollx(0, (global_flip) ? -192 : 0);
screen.priority().fill(0, cliprect);
- bg1_tilemap->draw(screen, bitmap, cliprect, 0,0);
- bg0_tilemap->draw(screen, bitmap, cliprect, 0,(m_vregs[4] & 0x8) ? 0 : 1);
+ bg_tilemap[1]->draw(screen, bitmap, cliprect, 0, 0);
+ bg_tilemap[0]->draw(screen, bitmap, cliprect, 0, (m_vregs[4] & 0x8) ? 0 : 1);
draw_sprites(screen, bitmap, cliprect, global_flip);
- tx_tilemap->draw(screen, bitmap, cliprect, 0,0);
+ tx_tilemap->draw(screen, bitmap, cliprect, 0, 0);
}
return 0;
}
void tc0091lvc_device::screen_eof(void)
{
- memcpy(m_sprram_buffer,m_sprram,0x400);
- m_bg0_scroll[0] = m_sprram_buffer[0x3f4];
- m_bg0_scroll[1] = m_sprram_buffer[0x3f5];
- m_bg0_scroll[2] = m_sprram_buffer[0x3f6];
-
- m_bg1_scroll[0] = m_sprram_buffer[0x3fc];
- m_bg1_scroll[1] = m_sprram_buffer[0x3fd];
- m_bg1_scroll[2] = m_sprram_buffer[0x3fe];
+ std::copy_n(&m_vram[0xb000], 0x400, &m_sprram_buffer[0]);
+ m_bg_scroll[0][0] = m_sprram_buffer[0x3f4];
+ m_bg_scroll[0][1] = m_sprram_buffer[0x3f5];
+ m_bg_scroll[0][2] = m_sprram_buffer[0x3f6];
+
+ m_bg_scroll[1][0] = m_sprram_buffer[0x3fc];
+ m_bg_scroll[1][1] = m_sprram_buffer[0x3fd];
+ m_bg_scroll[1][2] = m_sprram_buffer[0x3fe];
}
diff --git a/src/devices/machine/tc009xlvc.h b/src/devices/machine/tc009xlvc.h
index 296ebd92349..4c316540eaf 100644
--- a/src/devices/machine/tc009xlvc.h
+++ b/src/devices/machine/tc009xlvc.h
@@ -6,81 +6,77 @@
***************************************************************************/
-#ifndef MAME_MACHINE_TL009XLVC_H
-#define MAME_MACHINE_TL009XLVC_H
+#ifndef MAME_MACHINE_TC009XLVC_H
+#define MAME_MACHINE_TC009XLVC_H
#pragma once
+#include "machine/bankdev.h"
-class tc0091lvc_device : public device_t, public device_memory_interface
+class tc0091lvc_device : public device_t, public device_gfx_interface
{
public:
- tc0091lvc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- // configuration
- template <typename T> void set_gfxdecode_tag(T &&tag) { m_gfxdecode.set_tag(std::forward<T>(tag)); }
-
- DECLARE_READ8_MEMBER( vregs_r );
- DECLARE_WRITE8_MEMBER( vregs_w );
-
- uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+ tc0091lvc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+ // memory handlers
+ u8 rom_r(offs_t offset) { return m_rom[offset & m_rom.mask()]; }
+
+ // internal functions
+ u8 vregs_r(offs_t offset) { return m_vregs[offset]; }
+ void vregs_w(offs_t offset, u8 data);
+ u8 irq_vector_r(offs_t offset) { return m_irq_vector[offset]; }
+ void irq_vector_w(offs_t offset, u8 data) { m_irq_vector[offset] = data; }
+ u8 irq_enable_r() { return m_irq_enable; }
+ void irq_enable_w(u8 data) { m_irq_enable = data; }
+ u8 ram_bank_r(offs_t offset) { return m_ram_bank[offset]; }
+ void ram_bank_w(offs_t offset, u8 data);
+ u8 rom_bank_r() { return m_rom_bank; }
+ void rom_bank_w(u8 data) { m_rom_bank = data; }
+
+ // getters
+ u8 irq_vector(offs_t offset) { return m_irq_vector[offset]; }
+ u8 irq_enable() { return m_irq_enable; }
+
+ u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void screen_eof();
+ void cpu_map(address_map &map);
+
protected:
+ virtual void device_add_mconfig(machine_config &config) override;
+ virtual void device_post_load() override;
virtual void device_start() override;
- virtual space_config_vector memory_space_config() const override;
private:
- void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, uint8_t global_flip);
-
- DECLARE_READ8_MEMBER( tc0091lvc_paletteram_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_paletteram_w );
- DECLARE_READ8_MEMBER( tc0091lvc_bitmap_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_bitmap_w );
- DECLARE_READ8_MEMBER( tc0091lvc_pcg1_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_pcg1_w );
- DECLARE_READ8_MEMBER( tc0091lvc_pcg2_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_pcg2_w );
- DECLARE_READ8_MEMBER( tc0091lvc_vram0_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_vram0_w );
- DECLARE_READ8_MEMBER( tc0091lvc_vram1_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_vram1_w );
- DECLARE_READ8_MEMBER( tc0091lvc_spr_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_spr_w );
- DECLARE_READ8_MEMBER( tc0091lvc_tvram_r );
- DECLARE_WRITE8_MEMBER( tc0091lvc_tvram_w );
-
- TILE_GET_INFO_MEMBER(get_bg0_tile_info);
- TILE_GET_INFO_MEMBER(get_bg1_tile_info);
+ void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, u8 global_flip);
+
+ void vram_w(offs_t offset, u8 data);
+
+ template<unsigned Offset> TILE_GET_INFO_MEMBER(get_tile_info);
TILE_GET_INFO_MEMBER(get_tx_tile_info);
- void tc0091lvc_map8(address_map &map);
+ void banked_map(address_map &map);
- uint8_t *m_pcg1_ram;
- uint8_t *m_pcg2_ram;
- uint8_t *m_vram0;
- uint8_t *m_vram1;
- uint8_t *m_sprram;
- uint8_t *m_tvram;
- uint8_t m_bg0_scroll[4];
- uint8_t m_bg1_scroll[4];
+ u8 m_bg_scroll[2][4];
- tilemap_t *bg0_tilemap;
- tilemap_t *bg1_tilemap;
+ tilemap_t *bg_tilemap[2];
tilemap_t *tx_tilemap;
- int m_gfx_index; // for RAM tiles
+ DECLARE_GFXDECODE_MEMBER(gfxinfo);
- uint8_t m_palette_ram[0x200];
- uint8_t m_vregs[0x100];
- uint8_t m_bitmap_ram[0x20000];
- uint8_t m_pcg_ram[0x10000];
- uint8_t m_sprram_buffer[0x400];
+ u8 m_irq_vector[3];
+ u8 m_irq_enable;
+ u8 m_ram_bank[4];
+ u8 m_rom_bank;
+ std::unique_ptr<u8[]> m_vregs;
+ std::unique_ptr<u8[]> m_sprram_buffer;
- address_space_config m_space_config;
- required_device<gfxdecode_device> m_gfxdecode;
+ required_device_array<address_map_bank_device, 4> m_bankdev;
+ required_shared_ptr<u8> m_vram;
+ required_shared_ptr<u8> m_bitmap_ram;
+ required_region_ptr<u8> m_rom;
};
DECLARE_DEVICE_TYPE(TC0091LVC, tc0091lvc_device)
-#endif // MAME_MACHINE_TL009XLVC_H
+#endif // MAME_MACHINE_TC009XLVC_H
diff --git a/src/mame/drivers/dfruit.cpp b/src/mame/drivers/dfruit.cpp
index 70ffd2dfddf..45dbfd85a95 100644
--- a/src/mame/drivers/dfruit.cpp
+++ b/src/mame/drivers/dfruit.cpp
@@ -25,7 +25,6 @@
#include "machine/tc009xlvc.h"
#include "machine/timer.h"
#include "sound/2203intf.h"
-#include "emupal.h"
#include "screen.h"
#include "speaker.h"
@@ -48,35 +47,8 @@ private:
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(screen_vblank);
- uint8_t m_ram_bank[4];
- uint8_t m_rom_bank;
- uint8_t m_irq_vector[3];
- uint8_t m_irq_enable;
-
- DECLARE_READ8_MEMBER(dfruit_rom_r);
-
- DECLARE_READ8_MEMBER(dfruit_ram_0_r);
- DECLARE_READ8_MEMBER(dfruit_ram_1_r);
- DECLARE_READ8_MEMBER(dfruit_ram_2_r);
- DECLARE_READ8_MEMBER(dfruit_ram_3_r);
- DECLARE_WRITE8_MEMBER(dfruit_ram_0_w);
- DECLARE_WRITE8_MEMBER(dfruit_ram_1_w);
- DECLARE_WRITE8_MEMBER(dfruit_ram_2_w);
- DECLARE_WRITE8_MEMBER(dfruit_ram_3_w);
-
- DECLARE_READ8_MEMBER(dfruit_rom_bank_r);
- DECLARE_WRITE8_MEMBER(dfruit_rom_bank_w);
- DECLARE_READ8_MEMBER(dfruit_ram_bank_r);
- DECLARE_WRITE8_MEMBER(dfruit_ram_bank_w);
- DECLARE_READ8_MEMBER(dfruit_irq_vector_r);
- DECLARE_WRITE8_MEMBER(dfruit_irq_vector_w);
- DECLARE_READ8_MEMBER(dfruit_irq_enable_r);
- DECLARE_WRITE8_MEMBER(dfruit_irq_enable_w);
-
DECLARE_WRITE8_MEMBER(output_w);
-
- uint8_t ram_bank_r(uint16_t offset, uint8_t bank_num);
- void ram_bank_w(uint16_t offset, uint8_t data, uint8_t bank_num);
+
TIMER_DEVICE_CALLBACK_MEMBER(scanline_callback);
void dfruit_map(address_map &map);
void tc0091lvc_map(address_map &map);
@@ -103,92 +75,20 @@ WRITE_LINE_MEMBER(dfruit_state::screen_vblank)
}
}
-READ8_MEMBER(dfruit_state::dfruit_rom_r)
-{
- uint8_t *ROM = memregion("maincpu")->base();
-
- return ROM[offset + m_rom_bank * 0x2000];
-}
-
-READ8_MEMBER(dfruit_state::dfruit_rom_bank_r)
-{
- return m_rom_bank;
-}
-
-WRITE8_MEMBER(dfruit_state::dfruit_rom_bank_w)
-{
- m_rom_bank = data;
-}
-
-READ8_MEMBER(dfruit_state::dfruit_irq_vector_r)
-{
- return m_irq_vector[offset];
-}
-
-WRITE8_MEMBER(dfruit_state::dfruit_irq_vector_w)
-{
- m_irq_vector[offset] = data;
-}
-
-READ8_MEMBER(dfruit_state::dfruit_irq_enable_r)
-{
- return m_irq_enable;
-}
-
-WRITE8_MEMBER(dfruit_state::dfruit_irq_enable_w)
-{
- m_irq_enable = data;
-}
-
-READ8_MEMBER(dfruit_state::dfruit_ram_bank_r)
-{
- return m_ram_bank[offset];
-}
-
-WRITE8_MEMBER(dfruit_state::dfruit_ram_bank_w)
-{
- m_ram_bank[offset] = data;
-}
-
-uint8_t dfruit_state::ram_bank_r(uint16_t offset, uint8_t bank_num)
-{
- return m_vdp->space().read_byte(offset + (m_ram_bank[bank_num]) * 0x1000);;
-}
-
-void dfruit_state::ram_bank_w(uint16_t offset, uint8_t data, uint8_t bank_num)
-{
- m_vdp->space().write_byte(offset + (m_ram_bank[bank_num]) * 0x1000, data);;
-}
-
-READ8_MEMBER(dfruit_state::dfruit_ram_0_r) { return ram_bank_r(offset, 0); }
-READ8_MEMBER(dfruit_state::dfruit_ram_1_r) { return ram_bank_r(offset, 1); }
-READ8_MEMBER(dfruit_state::dfruit_ram_2_r) { return ram_bank_r(offset, 2); }
-READ8_MEMBER(dfruit_state::dfruit_ram_3_r) { return ram_bank_r(offset, 3); }
-WRITE8_MEMBER(dfruit_state::dfruit_ram_0_w) { ram_bank_w(offset, data, 0); }
-WRITE8_MEMBER(dfruit_state::dfruit_ram_1_w) { ram_bank_w(offset, data, 1); }
-WRITE8_MEMBER(dfruit_state::dfruit_ram_2_w) { ram_bank_w(offset, data, 2); }
-WRITE8_MEMBER(dfruit_state::dfruit_ram_3_w) { ram_bank_w(offset, data, 3); }
void dfruit_state::tc0091lvc_map(address_map &map)
{
- map(0x0000, 0x5fff).rom();
- map(0x6000, 0x7fff).r(FUNC(dfruit_state::dfruit_rom_r));
+ map(0x0000, 0xfdff).m(m_vdp, FUNC(tc0091lvc_device::cpu_map));
map(0x8000, 0x9fff).ram();
- map(0xc000, 0xcfff).rw(FUNC(dfruit_state::dfruit_ram_0_r), FUNC(dfruit_state::dfruit_ram_0_w));
- map(0xd000, 0xdfff).rw(FUNC(dfruit_state::dfruit_ram_1_r), FUNC(dfruit_state::dfruit_ram_1_w));
- map(0xe000, 0xefff).rw(FUNC(dfruit_state::dfruit_ram_2_r), FUNC(dfruit_state::dfruit_ram_2_w));
- map(0xf000, 0xfdff).rw(FUNC(dfruit_state::dfruit_ram_3_r), FUNC(dfruit_state::dfruit_ram_3_w));
-
map(0xfe00, 0xfeff).rw(m_vdp, FUNC(tc0091lvc_device::vregs_r), FUNC(tc0091lvc_device::vregs_w));
- map(0xff00, 0xff02).rw(FUNC(dfruit_state::dfruit_irq_vector_r), FUNC(dfruit_state::dfruit_irq_vector_w));
- map(0xff03, 0xff03).rw(FUNC(dfruit_state::dfruit_irq_enable_r), FUNC(dfruit_state::dfruit_irq_enable_w));
- map(0xff04, 0xff07).rw(FUNC(dfruit_state::dfruit_ram_bank_r), FUNC(dfruit_state::dfruit_ram_bank_w));
- map(0xff08, 0xff08).rw(FUNC(dfruit_state::dfruit_rom_bank_r), FUNC(dfruit_state::dfruit_rom_bank_w));
+ map(0xff00, 0xff02).rw(m_vdp, FUNC(tc0091lvc_device::irq_vector_r), FUNC(tc0091lvc_device::irq_vector_w));
+ map(0xff03, 0xff03).rw(m_vdp, FUNC(tc0091lvc_device::irq_enable_r), FUNC(tc0091lvc_device::irq_enable_w));
+ map(0xff04, 0xff07).rw(m_vdp, FUNC(tc0091lvc_device::ram_bank_r), FUNC(tc0091lvc_device::ram_bank_w));
+ map(0xff08, 0xff08).rw(m_vdp, FUNC(tc0091lvc_device::rom_bank_r), FUNC(tc0091lvc_device::rom_bank_w));
}
-
void dfruit_state::dfruit_map(address_map &map)
{
tc0091lvc_map(map);
@@ -371,68 +271,23 @@ static INPUT_PORTS_START( gemcrush )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
INPUT_PORTS_END
-static const gfx_layout bg2_layout =
-{
- 8, 8,
- RGN_FRAC(1,1),
- 4,
- { 8, 12, 0, 4 },
- { 3, 2, 1, 0, 19, 18, 17, 16 },
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
- 8*8*4
-};
-
-#define O 8*8*4
-#define O2 2*O
-static const gfx_layout sp2_layout =
-{
- 16, 16,
- RGN_FRAC(1,1),
- 4,
- { 8, 12, 0, 4 },
- { 3, 2, 1, 0, 19, 18, 17, 16, O+3, O+2, O+1, O+0, O+19, O+18, O+17, O+16 },
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, O2+0*32, O2+1*32, O2+2*32, O2+3*32, O2+4*32, O2+5*32, O2+6*32, O2+7*32 },
- 8*8*4*4
-};
-#undef O
-#undef O2
-
-#if 0
-static const gfx_layout char_layout =
-{
- 8, 8,
- 1024,
- 4,
- { 8, 12, 0, 4 },
- { 3, 2, 1, 0, 19, 18, 17, 16},
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
- 8*8*4
-};
-#endif
-
-static GFXDECODE_START( gfx_dfruit )
- GFXDECODE_ENTRY( "gfx1", 0, bg2_layout, 0, 16 )
- GFXDECODE_ENTRY( "gfx1", 0, sp2_layout, 0, 16 )
- //GFXDECODE_ENTRY( nullptr, 0, char_layout, 0, 16 ) // Ram-based
-GFXDECODE_END
-
TIMER_DEVICE_CALLBACK_MEMBER(dfruit_state::scanline_callback)
{
int scanline = param;
- if (scanline == 240 && (m_irq_enable & 4))
+ if (scanline == 240 && (m_vdp->irq_enable() & 4))
{
- m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_irq_vector[2]); // TC0091LVC
+ m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_vdp->irq_vector(2)); // TC0091LVC
}
- if (scanline == 0 && (m_irq_enable & 2))
+ if (scanline == 0 && (m_vdp->irq_enable() & 2))
{
- m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_irq_vector[1]); // TC0091LVC
+ m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_vdp->irq_vector(1)); // TC0091LVC
}
- if (scanline == 196 && (m_irq_enable & 1))
+ if (scanline == 196 && (m_vdp->irq_enable() & 1))
{
- //m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_irq_vector[0]); // TC0091LVC
+ //m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_vdp->irq_vector(0)); // TC0091LVC
}
}
@@ -461,13 +316,9 @@ void dfruit_state::dfruit(machine_config &config)
screen.set_visarea(0*8, 40*8-1, 2*8, 30*8-1);
screen.set_screen_update(FUNC(dfruit_state::screen_update));
screen.screen_vblank().set(FUNC(dfruit_state::screen_vblank));
- screen.set_palette("palette");
-
- GFXDECODE(config, "gfxdecode", "palette", gfx_dfruit);
- PALETTE(config, "palette").set_entries(0x100);
+ screen.set_palette("tc0091lvc:palette");
TC0091LVC(config, m_vdp, 0);
- m_vdp->set_gfxdecode_tag("gfxdecode");
i8255_device &ppi(I8255A(config, "i8255"));
ppi.in_pa_callback().set_ioport("IN0");
@@ -490,18 +341,18 @@ void dfruit_state::dfruit(machine_config &config)
***************************************************************************/
ROM_START( dfruit )
- ROM_REGION( 0x40000, "maincpu", 0 )
+ ROM_REGION( 0x40000, "tc0091lvc", 0 )
ROM_LOAD( "n-3800ii_ver.1.20.ic2", 0x00000, 0x40000, CRC(4e7c3700) SHA1(17bc731a91460d8f67c2b2b6e038641d57cf93be) )
- ROM_REGION( 0x80000, "gfx1", 0 )
+ ROM_REGION( 0x80000, "tc0091lvc:gfx", 0 )
ROM_LOAD( "c2.ic10", 0x00000, 0x80000, CRC(d869ab24) SHA1(382e874a846855a7f6f8811625aaa30d9dfa1ce2) )
ROM_END
ROM_START( gemcrush )
- ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASE00 )
+ ROM_REGION( 0x40000, "tc0091lvc", ROMREGION_ERASE00 )
ROM_LOAD( "gcj_00.ic2", 0x000000, 0x040000, CRC(e1431390) SHA1(f1f63e23d4b73cc099adddeadcf1ea3e27688bcd) ) /* ST M27C2001 EPROM */
- ROM_REGION( 0x80000, "gfx1", ROMREGION_ERASE00 )
+ ROM_REGION( 0x80000, "tc0091lvc:gfx", ROMREGION_ERASE00 )
ROM_LOAD( "gcj_01.ic10", 0x000000, 0x080000, CRC(5b9e7a6e) SHA1(345357feed8e80e6a06093fcb69f2b38063d057a) ) /* HN27C4096 EPROM */
ROM_END
diff --git a/src/mame/drivers/lastbank.cpp b/src/mame/drivers/lastbank.cpp
index 3bae4eb2926..c160ec71668 100644
--- a/src/mame/drivers/lastbank.cpp
+++ b/src/mame/drivers/lastbank.cpp
@@ -19,7 +19,6 @@
#include "machine/nvram.h"
#include "machine/tc009xlvc.h"
#include "machine/timer.h"
-#include "emupal.h"
#include "screen.h"
#include "speaker.h"
@@ -35,13 +34,10 @@ public:
, m_vdp(*this, "tc0091lvc")
, m_oki(*this, "oki")
, m_essnd(*this, "essnd")
- , m_mainbank(*this, "mainbank")
{ }
void lastbank(machine_config &config);
- void init_lastbank();
-
DECLARE_CUSTOM_INPUT_MEMBER(sound_status_r);
private:
@@ -50,37 +46,19 @@ private:
required_device<okim6295_device> m_oki;
required_device<es8712_device> m_essnd;
- required_memory_bank m_mainbank;
-
virtual void machine_start() override;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(screen_vblank);
- uint8_t m_ram_bank[4];
- uint8_t m_rom_bank;
- uint8_t m_irq_vector[3];
- uint8_t m_irq_enable;
uint8_t m_mux_data;
uint8_t m_sound_flags;
- template<int Bank> DECLARE_READ8_MEMBER(ram_r);
- template<int Bank> DECLARE_WRITE8_MEMBER(ram_w);
-
DECLARE_WRITE8_MEMBER(output_w);
DECLARE_READ8_MEMBER(mux_0_r);
DECLARE_WRITE8_MEMBER(mux_w);
DECLARE_WRITE8_MEMBER(sound_flags_w);
- DECLARE_READ8_MEMBER(rom_bank_r);
- DECLARE_WRITE8_MEMBER(rom_bank_w);
- DECLARE_READ8_MEMBER(ram_bank_r);
- DECLARE_WRITE8_MEMBER(ram_bank_w);
- DECLARE_READ8_MEMBER(irq_vector_r);
- DECLARE_WRITE8_MEMBER(irq_vector_w);
- DECLARE_READ8_MEMBER(irq_enable_r);
- DECLARE_WRITE8_MEMBER(irq_enable_w);
-
TIMER_DEVICE_CALLBACK_MEMBER(irq_scanline);
void lastbank_audio_io(address_map &map);
void lastbank_audio_map(address_map &map);
@@ -90,10 +68,6 @@ private:
void lastbank_state::machine_start()
{
- save_item(NAME(m_ram_bank));
- save_item(NAME(m_rom_bank));
- save_item(NAME(m_irq_vector));
- save_item(NAME(m_irq_enable));
save_item(NAME(m_mux_data));
save_item(NAME(m_sound_flags));
}
@@ -115,62 +89,6 @@ WRITE_LINE_MEMBER(lastbank_state::screen_vblank)
}
}
-READ8_MEMBER(lastbank_state::rom_bank_r)
-{
- return m_rom_bank;
-}
-
-WRITE8_MEMBER(lastbank_state::rom_bank_w)
-{
- if (m_rom_bank != data)
- {
- m_rom_bank = data;
- m_mainbank->set_entry(m_rom_bank);
- }
-}
-
-READ8_MEMBER(lastbank_state::irq_vector_r)
-{
- return m_irq_vector[offset];
-}
-
-WRITE8_MEMBER(lastbank_state::irq_vector_w)
-{
- m_irq_vector[offset] = data;
-}
-
-READ8_MEMBER(lastbank_state::irq_enable_r)
-{
- return m_irq_enable;
-}
-
-WRITE8_MEMBER(lastbank_state::irq_enable_w)
-{
- m_irq_enable = data;
-}
-
-READ8_MEMBER(lastbank_state::ram_bank_r)
-{
- return m_ram_bank[offset];
-}
-
-WRITE8_MEMBER(lastbank_state::ram_bank_w)
-{
- m_ram_bank[offset] = data;
-}
-
-template<int Bank>
-READ8_MEMBER(lastbank_state::ram_r)
-{
- return m_vdp->space().read_byte(offset + (m_ram_bank[Bank]) * 0x1000);;
-}
-
-template<int Bank>
-WRITE8_MEMBER(lastbank_state::ram_w)
-{
- m_vdp->space().write_byte(offset + (m_ram_bank[Bank]) * 0x1000,data);;
-}
-
READ8_MEMBER(lastbank_state::mux_0_r)
{
@@ -230,21 +148,15 @@ CUSTOM_INPUT_MEMBER(lastbank_state::sound_status_r)
void lastbank_state::tc0091lvc_map(address_map &map)
{
- map(0x0000, 0x5fff).rom();
- map(0x6000, 0x7fff).bankr("mainbank");
+ map(0x0000, 0xfdff).m(m_vdp, FUNC(tc0091lvc_device::cpu_map));
map(0x8000, 0x9fff).ram().share("nvram");
- map(0xc000, 0xcfff).rw(FUNC(lastbank_state::ram_r<0>), FUNC(lastbank_state::ram_w<0>));
- map(0xd000, 0xdfff).rw(FUNC(lastbank_state::ram_r<1>), FUNC(lastbank_state::ram_w<1>));
- map(0xe000, 0xefff).rw(FUNC(lastbank_state::ram_r<2>), FUNC(lastbank_state::ram_w<2>));
- map(0xf000, 0xfdff).rw(FUNC(lastbank_state::ram_r<3>), FUNC(lastbank_state::ram_w<3>));
-
map(0xfe00, 0xfeff).rw(m_vdp, FUNC(tc0091lvc_device::vregs_r), FUNC(tc0091lvc_device::vregs_w));
- map(0xff00, 0xff02).rw(FUNC(lastbank_state::irq_vector_r), FUNC(lastbank_state::irq_vector_w));
- map(0xff03, 0xff03).rw(FUNC(lastbank_state::irq_enable_r), FUNC(lastbank_state::irq_enable_w));
- map(0xff04, 0xff07).rw(FUNC(lastbank_state::ram_bank_r), FUNC(lastbank_state::ram_bank_w));
- map(0xff08, 0xff08).rw(FUNC(lastbank_state::rom_bank_r), FUNC(lastbank_state::rom_bank_w));
+ map(0xff00, 0xff02).rw(m_vdp, FUNC(tc0091lvc_device::irq_vector_r), FUNC(tc0091lvc_device::irq_vector_w));
+ map(0xff03, 0xff03).rw(m_vdp, FUNC(tc0091lvc_device::irq_enable_r), FUNC(tc0091lvc_device::irq_enable_w));
+ map(0xff04, 0xff07).rw(m_vdp, FUNC(tc0091lvc_device::ram_bank_r), FUNC(tc0091lvc_device::ram_bank_w));
+ map(0xff08, 0xff08).rw(m_vdp, FUNC(tc0091lvc_device::rom_bank_r), FUNC(tc0091lvc_device::rom_bank_w));
}
void lastbank_state::lastbank_map(address_map &map)
@@ -465,50 +377,18 @@ static INPUT_PORTS_START( lastbank )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
INPUT_PORTS_END
-static const gfx_layout bg2_layout =
-{
- 8, 8,
- RGN_FRAC(1,1),
- 4,
- { 8, 12, 0, 4 },
- { 3, 2, 1, 0, 19, 18, 17, 16 },
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
- 8*8*4
-};
-
-#define O 8*8*4
-#define O2 2*O
-static const gfx_layout sp2_layout =
-{
- 16, 16,
- RGN_FRAC(1,1),
- 4,
- { 8, 12, 0, 4 },
- { 3, 2, 1, 0, 19, 18, 17, 16, O+3, O+2, O+1, O+0, O+19, O+18, O+17, O+16 },
- { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, O2+0*32, O2+1*32, O2+2*32, O2+3*32, O2+4*32, O2+5*32, O2+6*32, O2+7*32 },
- 8*8*4*4
-};
-#undef O
-#undef O2
-
-
-static GFXDECODE_START( gfx_lastbank )
- GFXDECODE_ENTRY( "gfx1", 0, bg2_layout, 0, 16 )
- GFXDECODE_ENTRY( "gfx1", 0, sp2_layout, 0, 16 )
-GFXDECODE_END
-
TIMER_DEVICE_CALLBACK_MEMBER(lastbank_state::irq_scanline)
{
int scanline = param;
- if (scanline == 240 && (m_irq_enable & 4))
+ if (scanline == 240 && (m_vdp->irq_enable() & 4))
{
- m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_irq_vector[2]); // Z80
+ m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_vdp->irq_vector(2)); // TC0091LVC
}
- if (scanline == 0 && (m_irq_enable & 2))
+ if (scanline == 0 && (m_vdp->irq_enable() & 2))
{
- m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_irq_vector[1]); // Z80
+ m_maincpu->set_input_line_and_vector(0, HOLD_LINE, m_vdp->irq_vector(1)); // TC0091LVC
}
}
@@ -539,13 +419,9 @@ void lastbank_state::lastbank(machine_config &config)
screen.set_visarea(0*8, 40*8-1, 2*8, 30*8-1);
screen.set_screen_update(FUNC(lastbank_state::screen_update));
screen.screen_vblank().set(FUNC(lastbank_state::screen_vblank));
- screen.set_palette("palette");
-
- GFXDECODE(config, "gfxdecode", "palette", gfx_lastbank );
- PALETTE(config, "palette").set_entries(0x100);
+ screen.set_palette("tc0091lvc:palette");
TC0091LVC(config, m_vdp, 0);
- m_vdp->set_gfxdecode_tag("gfxdecode");
// MCFG_VIDEO_START_OVERRIDE(lastbank_state,lastbank)
@@ -578,13 +454,13 @@ void lastbank_state::lastbank(machine_config &config)
***************************************************************************/
ROM_START( lastbank )
- ROM_REGION( 0x40000, "maincpu", 0 )
+ ROM_REGION( 0x40000, "tc0091lvc", 0 )
ROM_LOAD( "3.u9", 0x00000, 0x40000, CRC(f430e1f0) SHA1(dd5b697f5c2250d98911f4c7d3e7d4cc16b0b40f) )
- ROM_REGION( 0x40000, "audiocpu", 0 )
+ ROM_REGION( 0x10000, "audiocpu", 0 )
ROM_LOAD( "8.u48", 0x00000, 0x10000, CRC(3a7bfe10) SHA1(7dc543e11d3c0b9872fcc622339ade25383a1eb3) )
- ROM_REGION( 0x120000, "gfx1", 0 )
+ ROM_REGION( 0x120000, "tc0091lvc:gfx", 0 )
ROM_LOAD( "u11", 0x000000, 0x100000, CRC(2588d82d) SHA1(426f6821862d54123e53410e2776586ddf6b21e7) )
ROM_LOAD( "5.u10", 0x100000, 0x020000, CRC(51f3c5a7) SHA1(73d4c8817fe96d75be32c43e816e93c52b5d2b27) )
@@ -595,10 +471,4 @@ ROM_START( lastbank )
ROM_LOAD( "7.u60", 0x00000, 0x80000, CRC(41be7146) SHA1(00f1c0d5809efccf888e27518a2a5876c4b633d8) )
ROM_END
-void lastbank_state::init_lastbank()
-{
- uint32_t max = memregion("maincpu")->bytes() / 0x2000;
- m_mainbank->configure_entries(0, max, memregion("maincpu")->base(), 0x2000);
-}
-
-GAME( 1994, lastbank, 0, lastbank, lastbank, lastbank_state, init_lastbank, ROT0, "Excellent System", "Last Bank (v1.16)", 0 )
+GAME( 1994, lastbank, 0, lastbank, lastbank, lastbank_state, empty_init, ROT0, "Excellent System", "Last Bank (v1.16)", 0 )