diff --git a/src/mame/toaplan/batsugun.cpp b/src/mame/toaplan/batsugun.cpp index e0320482cc65b..85ba5482e21a1 100644 --- a/src/mame/toaplan/batsugun.cpp +++ b/src/mame/toaplan/batsugun.cpp @@ -15,7 +15,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* Name Board No Maker Game name diff --git a/src/mame/toaplan/dogyuun.cpp b/src/mame/toaplan/dogyuun.cpp index 28230636490ab..c332ea4e6adbb 100644 --- a/src/mame/toaplan/dogyuun.cpp +++ b/src/mame/toaplan/dogyuun.cpp @@ -17,7 +17,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* Name Board No Maker Game name @@ -78,15 +77,15 @@ class dogyuun_state : public driver_device void reset_audiocpu(int state); + void base_mem(address_map &map) ATTR_COLD; void dogyuun_68k_mem(address_map &map) ATTR_COLD; - void v25_mem(address_map &map) ATTR_COLD; void dogyuunto_68k_mem(address_map &map) ATTR_COLD; void dogyuunto_sound_z80_mem(address_map &map) ATTR_COLD; + void v25_mem(address_map &map) ATTR_COLD; required_device m_coincounter; required_device m_screen; bitmap_ind8 m_custom_priority_bitmap; - bitmap_ind16 m_secondary_render_bitmap; }; void dogyuun_state::reset_audiocpu(int state) @@ -107,9 +106,7 @@ void dogyuun_state::machine_reset() void dogyuun_state::video_start() { m_screen->register_screen_bitmap(m_custom_priority_bitmap); - m_secondary_render_bitmap.reset(); m_vdp[0]->custom_priority_bitmap = &m_custom_priority_bitmap; - m_screen->register_screen_bitmap(m_secondary_render_bitmap); m_vdp[1]->custom_priority_bitmap = &m_custom_priority_bitmap; } @@ -271,26 +268,30 @@ void dogyuun_state::coin_sound_reset_w(u8 data) m_audiocpu->set_input_line(INPUT_LINE_RESET, BIT(data, B) ? CLEAR_LINE : ASSERT_LINE); } -void dogyuun_state::dogyuun_68k_mem(address_map &map) +void dogyuun_state::base_mem(address_map &map) { map(0x000000, 0x07ffff).rom(); map(0x100000, 0x103fff).ram(); + map(0x300000, 0x30000d).rw(m_vdp[0], FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); + map(0x400000, 0x400fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); + map(0x500000, 0x50000d).rw(m_vdp[1], FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); + map(0x700000, 0x700001).r(m_vdp[0], FUNC(gp9001vdp_device::vdpcount_r)); // test bit 8 +} + +void dogyuun_state::dogyuun_68k_mem(address_map &map) +{ + base_mem(map); map(0x200010, 0x200011).portr("IN1"); map(0x200014, 0x200015).portr("IN2"); map(0x200018, 0x200019).portr("SYS"); map(0x20001d, 0x20001d).w(FUNC(dogyuun_state::coin_sound_reset_w<5>)); // Coin count/lock + v25 reset line map(0x210000, 0x21ffff).rw(FUNC(dogyuun_state::shared_ram_r), FUNC(dogyuun_state::shared_ram_w)).umask16(0x00ff); - map(0x300000, 0x30000d).rw(m_vdp[0], FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); - map(0x400000, 0x400fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x500000, 0x50000d).rw(m_vdp[1], FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); - map(0x700000, 0x700001).r(m_vdp[0], FUNC(gp9001vdp_device::vdpcount_r)); // test bit 8 } void dogyuun_state::dogyuunto_68k_mem(address_map &map) { - map(0x000000, 0x07ffff).rom(); - map(0x100000, 0x103fff).ram(); + base_mem(map); map(0x218000, 0x218fff).rw(FUNC(dogyuun_state::shared_ram_r), FUNC(dogyuun_state::shared_ram_w)).umask16(0x00ff); // reads the same area as the finished game on startup, but then uses only this part map(0x21c01d, 0x21c01d).w(FUNC(dogyuun_state::coin_sound_reset_w<4>)); // Coin count/lock + Z80 reset line map(0x21c020, 0x21c021).portr("IN1"); @@ -298,10 +299,6 @@ void dogyuun_state::dogyuunto_68k_mem(address_map &map) map(0x21c028, 0x21c029).portr("SYS"); map(0x21c02c, 0x21c02d).portr("DSWA"); map(0x21c030, 0x21c031).portr("DSWB"); - map(0x300000, 0x30000d).rw(m_vdp[0], FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); - map(0x400000, 0x400fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x500000, 0x50000d).rw(m_vdp[1], FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); - map(0x700000, 0x700001).r(m_vdp[0], FUNC(gp9001vdp_device::vdpcount_r)); // test bit 8 } void dogyuun_state::dogyuunto_sound_z80_mem(address_map &map) diff --git a/src/mame/toaplan/dt7.cpp b/src/mame/toaplan/dt7.cpp index 749b7db1e16f3..d11028af50d94 100644 --- a/src/mame/toaplan/dt7.cpp +++ b/src/mame/toaplan/dt7.cpp @@ -15,6 +15,7 @@ - service mode doesn't display properly - currently only coins up with service button - sound dies after one stage? + - merge tilemap emulation into toaplan/toaplan_txtilemap.cpp? */ @@ -585,7 +586,7 @@ ROM_START( dt7 ) /* Secondary CPU is a Toaplan marked chip, (TS-007-Spy TOA PLAN) */ /* It's a NEC V25 (PLCC94) (encrypted program uploaded by main CPU) */ - /* Note, same markings as other games found in toaplan2.cpp, but table is different! */ + /* Note, same markings as other games found in toaplan/toaplan2.cpp, but table is different! */ ROM_REGION( 0x400000, "gp9001_0", 0 ) ROM_LOAD( "3a.49", 0x000000, 0x080000, CRC(ba8e378c) SHA1(d5eb4a839d6b3c2b9bf0bd87f06859a01a2c0cbf) ) diff --git a/src/mame/toaplan/enmadaio.cpp b/src/mame/toaplan/enmadaio.cpp index 2d7f6e47f2c4d..d4c1b85bab311 100644 --- a/src/mame/toaplan/enmadaio.cpp +++ b/src/mame/toaplan/enmadaio.cpp @@ -13,7 +13,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* Name Board No Maker Game name diff --git a/src/mame/toaplan/fixeight.cpp b/src/mame/toaplan/fixeight.cpp index 0d62d056d49f9..734e4876cb501 100644 --- a/src/mame/toaplan/fixeight.cpp +++ b/src/mame/toaplan/fixeight.cpp @@ -5,6 +5,7 @@ #include "gp9001.h" #include "toaplan_coincounter.h" +#include "toaplan_txtilemap.h" #include "toaplan_v25_tables.h" #include "toaplipt.h" @@ -18,7 +19,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* Name Board No Maker Game name @@ -64,9 +64,6 @@ class fixeight_state : public driver_device public: fixeight_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) - , m_tx_videoram(*this, "tx_videoram") - , m_tx_lineselect(*this, "tx_lineselect") - , m_tx_linescroll(*this, "tx_linescroll") , m_tx_gfxram(*this, "tx_gfxram") , m_shared_ram(*this, "shared_ram") , m_maincpu(*this, "maincpu") @@ -74,7 +71,7 @@ class fixeight_state : public driver_device , m_vdp(*this, "gp9001") , m_oki(*this, "oki") , m_eeprom(*this, "eeprom") - , m_gfxdecode(*this, "gfxdecode") + , m_tx_tilemap(*this, "tx_tilemap") , m_screen(*this, "screen") , m_palette(*this, "palette") { } @@ -89,8 +86,6 @@ class fixeight_state : public driver_device void fixeight_68k_mem(address_map &map) ATTR_COLD; void fixeight_v25_mem(address_map &map) ATTR_COLD; - void create_tx_tilemap(int dx = 0, int dx_flipped = 0) ATTR_COLD; - u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void screen_vblank(int state); void tx_gfxram_w(offs_t offset, u16 data, u16 mem_mask = ~0); @@ -98,18 +93,10 @@ class fixeight_state : public driver_device u8 shared_ram_r(offs_t offset) { return m_shared_ram[offset]; } void shared_ram_w(offs_t offset, u8 data) { m_shared_ram[offset] = data; } - void tx_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); - void tx_linescroll_w(offs_t offset, u16 data, u16 mem_mask = ~0); - TILE_GET_INFO_MEMBER(get_text_tile_info); - void sound_reset_w(u8 data); - tilemap_t *m_tx_tilemap = nullptr; /* Tilemap for extra-text-layer */ - required_shared_ptr m_tx_videoram; - optional_shared_ptr m_tx_lineselect; // originals only - optional_shared_ptr m_tx_linescroll; // originals only - optional_shared_ptr m_tx_gfxram; // originals only void reset_audiocpu(int state); + optional_shared_ptr m_tx_gfxram; // originals only optional_shared_ptr m_shared_ram; // originals only - 8 bit RAM shared between 68K and sound CPU required_device m_maincpu; @@ -117,7 +104,7 @@ class fixeight_state : public driver_device required_device m_vdp; required_device m_oki; optional_device m_eeprom; // originals only - required_device m_gfxdecode; + required_device m_tx_tilemap; required_device m_screen; required_device m_palette; bitmap_ind8 m_custom_priority_bitmap; @@ -164,32 +151,6 @@ void fixeight_state::reset_audiocpu(int state) } -TILE_GET_INFO_MEMBER(fixeight_state::get_text_tile_info) -{ - const u16 attrib = m_tx_videoram[tile_index]; - const u32 tile_number = attrib & 0x3ff; - const u32 color = attrib >> 10; - tileinfo.set(0, - tile_number, - color, - 0); -} - -void fixeight_state::tx_videoram_w(offs_t offset, u16 data, u16 mem_mask) -{ - COMBINE_DATA(&m_tx_videoram[offset]); - if (offset < 64*32) - m_tx_tilemap->mark_tile_dirty(offset); -} - -void fixeight_state::tx_linescroll_w(offs_t offset, u16 data, u16 mem_mask) -{ - /*** Line-Scroll RAM for Text Layer ***/ - COMBINE_DATA(&m_tx_linescroll[offset]); - - m_tx_tilemap->set_scrollx(offset, m_tx_linescroll[offset]); -} - void fixeight_state::screen_vblank(int state) { // rising edge @@ -200,22 +161,12 @@ void fixeight_state::screen_vblank(int state) } -void fixeight_state::create_tx_tilemap(int dx, int dx_flipped) -{ - m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(fixeight_state::get_text_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - - m_tx_tilemap->set_scroll_rows(8*32); /* line scrolling */ - m_tx_tilemap->set_scroll_cols(1); - m_tx_tilemap->set_scrolldx(dx, dx_flipped); - m_tx_tilemap->set_transparent_pen(0); -} - u32 fixeight_bootleg_state::screen_update_bootleg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { bitmap.fill(0, cliprect); m_custom_priority_bitmap.fill(0, cliprect); m_vdp->render_vdp(bitmap, cliprect); - m_tx_tilemap->draw(screen, bitmap, cliprect, 0); + m_tx_tilemap->draw_tilemap_bootleg(screen, bitmap, cliprect); return 0; } @@ -224,8 +175,6 @@ void fixeight_bootleg_state::video_start() m_screen->register_screen_bitmap(m_custom_priority_bitmap); m_vdp->custom_priority_bitmap = &m_custom_priority_bitmap; - create_tx_tilemap(); - /* This bootleg has additional layer offsets on the VDP */ m_vdp->set_tm_extra_offsets(0, -0x1d6 - 26, -0x1ef - 15, 0, 0); m_vdp->set_tm_extra_offsets(1, -0x1d8 - 22, -0x1ef - 15, 0, 0); @@ -241,8 +190,7 @@ void fixeight_state::video_start() m_screen->register_screen_bitmap(m_custom_priority_bitmap); m_vdp->custom_priority_bitmap = &m_custom_priority_bitmap; - m_gfxdecode->gfx(0)->set_source(reinterpret_cast(m_tx_gfxram.target())); - create_tx_tilemap(0x1d5, 0x16a); + m_tx_tilemap->gfx(0)->set_source(reinterpret_cast(m_tx_gfxram.target())); } @@ -251,21 +199,7 @@ u32 fixeight_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c bitmap.fill(0, cliprect); m_custom_priority_bitmap.fill(0, cliprect); m_vdp->render_vdp(bitmap, cliprect); - - rectangle clip = cliprect; - - /* it seems likely that flipx can be set per line! */ - /* however, none of the games does it, and emulating it in the */ - /* MAME tilemap system without being ultra slow would be tricky */ - m_tx_tilemap->set_flip(m_tx_lineselect[0] & 0x8000 ? 0 : TILEMAP_FLIPX); - - /* line select is used for 'for use in' and '8ing' screen on bbakraid, 'Raizing' logo on batrider */ - for (int y = cliprect.min_y; y <= cliprect.max_y; y++) - { - clip.min_y = clip.max_y = y; - m_tx_tilemap->set_scrolly(0, m_tx_lineselect[y] - y); - m_tx_tilemap->draw(screen, bitmap, clip, 0); - } + m_tx_tilemap->draw_tilemap(screen, bitmap, cliprect); return 0; } @@ -278,7 +212,7 @@ void fixeight_state::tx_gfxram_w(offs_t offset, u16 data, u16 mem_mask) if (oldword != data) { COMBINE_DATA(&m_tx_gfxram[offset]); - m_gfxdecode->gfx(0)->mark_dirty(offset/32); + m_tx_tilemap->gfx(0)->mark_dirty(offset/32); } } @@ -434,9 +368,9 @@ void fixeight_state::fixeight_68k_mem(address_map &map) map(0x280000, 0x28ffff).rw(FUNC(fixeight_state::shared_ram_r), FUNC(fixeight_state::shared_ram_w)).umask16(0x00ff); map(0x300000, 0x30000d).rw(m_vdp, FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); map(0x400000, 0x400fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x500000, 0x501fff).ram().w(FUNC(fixeight_state::tx_videoram_w)).share(m_tx_videoram); - map(0x502000, 0x5021ff).ram().share(m_tx_lineselect); - map(0x503000, 0x5031ff).ram().w(FUNC(fixeight_state::tx_linescroll_w)).share(m_tx_linescroll); + map(0x500000, 0x501fff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::videoram_r), FUNC(toaplan_txtilemap_device::videoram_w)); + map(0x502000, 0x5021ff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::lineselect_r), FUNC(toaplan_txtilemap_device::lineselect_w)); + map(0x503000, 0x5031ff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::linescroll_r), FUNC(toaplan_txtilemap_device::linescroll_w)); map(0x600000, 0x60ffff).ram().w(FUNC(fixeight_state::tx_gfxram_w)).share(m_tx_gfxram); map(0x700000, 0x700001).w(FUNC(fixeight_state::sound_reset_w)).umask16(0x00ff).cswidth(16); map(0x800000, 0x800001).r(m_vdp, FUNC(gp9001vdp_device::vdpcount_r)); @@ -464,7 +398,7 @@ void fixeight_bootleg_state::fixeightbl_68k_mem(address_map &map) map(0x20001c, 0x20001d).portr("DSWA"); map(0x300000, 0x30000d).rw(m_vdp, FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); map(0x400000, 0x400fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x500000, 0x501fff).ram().w(FUNC(fixeight_bootleg_state::tx_videoram_w)).share(m_tx_videoram); + map(0x500000, 0x501fff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::videoram_r), FUNC(toaplan_txtilemap_device::videoram_w)); map(0x700000, 0x700001).r(m_vdp, FUNC(gp9001vdp_device::vdpcount_r)); map(0x800000, 0x87ffff).rom().region("maincpu", 0x80000); } @@ -536,13 +470,15 @@ void fixeight_state::fixeight(machine_config &config) m_screen->screen_vblank().set(FUNC(fixeight_state::screen_vblank)); m_screen->set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, gp9001vdp_device::VDP_PALETTE_LENGTH); GP9001_VDP(config, m_vdp, 27_MHz_XTAL); m_vdp->set_palette(m_palette); m_vdp->vint_out_cb().set_inputline(m_maincpu, M68K_IRQ_4); + TOAPLAN_TXTILEMAP(config, m_tx_tilemap, 27_MHz_XTAL, m_palette, gfx); + m_tx_tilemap->set_offset(0x1d5, 0, 0x16a, 0); + /* sound hardware */ SPEAKER(config, "mono").front_center(); @@ -578,13 +514,14 @@ void fixeight_bootleg_state::fixeightbl(machine_config &config) m_screen->screen_vblank().set(FUNC(fixeight_bootleg_state::screen_vblank)); m_screen->set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx_textrom); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, gp9001vdp_device::VDP_PALETTE_LENGTH); GP9001_VDP(config, m_vdp, 27_MHz_XTAL); m_vdp->set_palette(m_palette); m_vdp->vint_out_cb().set_inputline(m_maincpu, M68K_IRQ_2, ASSERT_LINE); + TOAPLAN_TXTILEMAP(config, m_tx_tilemap, 27_MHz_XTAL, m_palette, gfx_textrom); + /* sound hardware */ SPEAKER(config, "mono").front_center(); diff --git a/src/mame/toaplan/ghox.cpp b/src/mame/toaplan/ghox.cpp index 5c77893b594fe..be4e276dc3951 100644 --- a/src/mame/toaplan/ghox.cpp +++ b/src/mame/toaplan/ghox.cpp @@ -14,7 +14,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* Name Board No Maker Game name diff --git a/src/mame/toaplan/kbash.cpp b/src/mame/toaplan/kbash.cpp index bb9c65985220f..a3b75dac95a81 100644 --- a/src/mame/toaplan/kbash.cpp +++ b/src/mame/toaplan/kbash.cpp @@ -16,7 +16,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* Name Board No Maker Game name diff --git a/src/mame/toaplan/pipibibi.cpp b/src/mame/toaplan/pipibibi.cpp index f0691d09117ef..9ffd38f1c3a47 100644 --- a/src/mame/toaplan/pipibibi.cpp +++ b/src/mame/toaplan/pipibibi.cpp @@ -15,7 +15,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* * Name Board No Maker Game name @@ -477,10 +476,10 @@ ROM_END } // anonymous namespace -GAME( 1991, pipibibs, 0, pipibibs, pipibibs, pipibibi_state, empty_init, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu, set 1)", MACHINE_SUPPORTS_SAVE ) -GAME( 1991, pipibibsa, pipibibs, pipibibs, pipibibs, pipibibi_state, empty_init, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu, set 2)", MACHINE_SUPPORTS_SAVE ) -GAME( 1991, pipibibsp, pipibibs, pipibibs, pipibibsp, pipibibi_state, empty_init, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (prototype)", MACHINE_SUPPORTS_SAVE ) +GAME( 1991, pipibibs, 0, pipibibs, pipibibs, pipibibi_state , empty_init, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu, set 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1991, pipibibsa, pipibibs, pipibibs, pipibibs, pipibibi_state, empty_init, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu, set 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1991, pipibibsp, pipibibs, pipibibs, pipibibsp, pipibibi_state, empty_init, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (prototype)", MACHINE_SUPPORTS_SAVE ) -GAME( 1991, pipibibsbl, pipibibs, pipibibsbl, pipibibsbl, pipibibi_bootleg_state, init_pipibibsbl, ROT0, "bootleg (Ryouta Kikaku)", "Pipi & Bibis / Whoopee!! (Ryouta Kikaku bootleg, encrypted)", MACHINE_SUPPORTS_SAVE ) -GAME( 1991, pipibibsbl2, pipibibs, pipibibsbl, pipibibsbl, pipibibi_bootleg_state, empty_init, ROT0, "bootleg", "Pipi & Bibis / Whoopee!! (bootleg, decrypted)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // different memory map, not scrambled -GAME( 1991, pipibibsbl3, pipibibs, pipibibsbl, pipibibsbl, pipibibi_bootleg_state, empty_init, ROT0, "bootleg (Ryouta Kikaku)", "Pipi & Bibis / Whoopee!! (Ryouta Kikaku bootleg, decrypted)", MACHINE_SUPPORTS_SAVE ) +GAME( 1991, pipibibsbl, pipibibs, pipibibsbl, pipibibsbl, pipibibi_bootleg_state, init_pipibibsbl, ROT0, "bootleg", "Pipi & Bibis / Whoopee!! (bootleg, encrypted)", MACHINE_SUPPORTS_SAVE ) +GAME( 1991, pipibibsbl2, pipibibs, pipibibsbl, pipibibsbl, pipibibi_bootleg_state, empty_init, ROT0, "bootleg", "Pipi & Bibis / Whoopee!! (bootleg, decrypted set 1)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // different memory map, not scrambled +GAME( 1991, pipibibsbl3, pipibibs, pipibibsbl, pipibibsbl, pipibibi_bootleg_state, empty_init, ROT0, "bootleg", "Pipi & Bibis / Whoopee!! (bootleg, decrypted set 2)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/toaplan/raizing.cpp b/src/mame/toaplan/raizing.cpp index 5214a0b29ca23..ead442894601b 100644 --- a/src/mame/toaplan/raizing.cpp +++ b/src/mame/toaplan/raizing.cpp @@ -116,32 +116,6 @@ void raizing_base_state::reset_audiocpu(int state) m_audiocpu->set_input_line(INPUT_LINE_RESET, state); } -TILE_GET_INFO_MEMBER(raizing_base_state::get_text_tile_info) -{ - const u16 attrib = m_tx_videoram[tile_index]; - const u32 tile_number = attrib & 0x3ff; - const u32 color = attrib >> 10; - tileinfo.set(0, - tile_number, - color, - 0); -} - -void raizing_base_state::tx_videoram_w(offs_t offset, u16 data, u16 mem_mask) -{ - COMBINE_DATA(&m_tx_videoram[offset]); - if (offset < 64*32) - m_tx_tilemap->mark_tile_dirty(offset); -} - -void raizing_base_state::tx_linescroll_w(offs_t offset, u16 data, u16 mem_mask) -{ - /*** Line-Scroll RAM for Text Layer ***/ - COMBINE_DATA(&m_tx_linescroll[offset]); - - m_tx_tilemap->set_scrollx(offset, m_tx_linescroll[offset]); -} - u32 raizing_base_state::screen_update_base(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { @@ -164,43 +138,16 @@ void raizing_base_state::screen_vblank(int state) u32 raizing_base_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { screen_update_base(screen, bitmap, cliprect); - - rectangle clip = cliprect; - - /* it seems likely that flipx can be set per line! */ - /* however, none of the games does it, and emulating it in the */ - /* MAME tilemap system without being ultra slow would be tricky */ - m_tx_tilemap->set_flip(m_tx_lineselect[0] & 0x8000 ? 0 : TILEMAP_FLIPX); - - /* line select is used for 'for use in' and '8ing' screen on bbakraid, 'Raizing' logo on batrider */ - for (int y = cliprect.min_y; y <= cliprect.max_y; y++) - { - clip.min_y = clip.max_y = y; - m_tx_tilemap->set_scrolly(0, m_tx_lineselect[y] - y); - m_tx_tilemap->draw(screen, bitmap, clip, 0); - } + m_tx_tilemap->draw_tilemap(screen, bitmap, cliprect); return 0; } -void raizing_base_state::create_tx_tilemap(int dx, int dx_flipped) -{ - m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(raizing_base_state::get_text_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - - m_tx_tilemap->set_scroll_rows(8*32); /* line scrolling */ - m_tx_tilemap->set_scroll_cols(1); - m_tx_tilemap->set_scrolldx(dx, dx_flipped); - m_tx_tilemap->set_transparent_pen(0); -} - void raizing_base_state::bgaregga_common_video_start() { m_screen->register_screen_bitmap(m_custom_priority_bitmap); m_vdp->custom_priority_bitmap = &m_custom_priority_bitmap; - - /* Create the Text tilemap for this game */ - create_tx_tilemap(0x1d4, 0x16b); } @@ -249,9 +196,9 @@ void raizing_base_state::common_mem(address_map &map, offs_t rom_limit) map(0x21c03c, 0x21c03d).r(m_vdp, FUNC(gp9001vdp_device::vdpcount_r)); map(0x300000, 0x30000d).rw(m_vdp, FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); map(0x400000, 0x400fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x500000, 0x501fff).ram().w(FUNC(raizing_base_state::tx_videoram_w)).share(m_tx_videoram); - map(0x502000, 0x502fff).ram().share(m_tx_lineselect); - map(0x503000, 0x5031ff).ram().w(FUNC(raizing_base_state::tx_linescroll_w)).share(m_tx_linescroll); + map(0x500000, 0x501fff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::videoram_r), FUNC(toaplan_txtilemap_device::videoram_w)); + map(0x502000, 0x502fff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::lineselect_r), FUNC(toaplan_txtilemap_device::lineselect_w)); + map(0x503000, 0x5031ff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::linescroll_r), FUNC(toaplan_txtilemap_device::linescroll_w)); map(0x503200, 0x503fff).ram(); } @@ -348,9 +295,6 @@ void bgaregga_bootleg_state::video_start() { m_screen->register_screen_bitmap(m_custom_priority_bitmap); m_vdp->custom_priority_bitmap = &m_custom_priority_bitmap; - - /* Create the Text tilemap for this game */ - create_tx_tilemap(4, 4); } @@ -359,7 +303,7 @@ void bgaregga_bootleg_state::video_start() u32 bgaregga_bootleg_state::screen_update_bootleg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { screen_update_base(screen, bitmap, cliprect); - m_tx_tilemap->draw(screen, bitmap, cliprect, 0); + m_tx_tilemap->draw_tilemap_bootleg(screen, bitmap, cliprect); return 0; } @@ -825,13 +769,15 @@ void sstriker_state::mahoudai(machine_config &config) m_screen->screen_vblank().set(FUNC(sstriker_state::screen_vblank)); m_screen->set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx_textrom); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, gp9001vdp_device::VDP_PALETTE_LENGTH); GP9001_VDP(config, m_vdp, 27_MHz_XTAL); m_vdp->set_palette(m_palette); m_vdp->vint_out_cb().set_inputline(m_maincpu, M68K_IRQ_4); + TOAPLAN_TXTILEMAP(config, m_tx_tilemap, 27_MHz_XTAL, m_palette, gfx_textrom); + m_tx_tilemap->set_offset(0x1d4, 0, 0x16b, 0); + /* sound hardware */ SPEAKER(config, "mono").front_center(); @@ -870,13 +816,15 @@ void bgaregga_state::bgaregga(machine_config &config) m_screen->screen_vblank().set(FUNC(bgaregga_state::screen_vblank)); m_screen->set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx_textrom); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, gp9001vdp_device::VDP_PALETTE_LENGTH); GP9001_VDP(config, m_vdp, 27_MHz_XTAL); m_vdp->set_palette(m_palette); m_vdp->vint_out_cb().set_inputline(m_maincpu, M68K_IRQ_4); + TOAPLAN_TXTILEMAP(config, m_tx_tilemap, 27_MHz_XTAL, m_palette, gfx_textrom); + m_tx_tilemap->set_offset(0x1d4, 0, 0x16b, 0); + /* sound hardware */ SPEAKER(config, "mono").front_center(); @@ -897,6 +845,7 @@ void bgaregga_bootleg_state::bgareggabl(machine_config &config) bgaregga(config); m_screen->set_screen_update(FUNC(bgaregga_bootleg_state::screen_update_bootleg)); + m_tx_tilemap->set_offset(4, 0, 4, 0); } diff --git a/src/mame/toaplan/raizing.h b/src/mame/toaplan/raizing.h index 61b8c6ef9d62a..354c217788e10 100644 --- a/src/mame/toaplan/raizing.h +++ b/src/mame/toaplan/raizing.h @@ -7,6 +7,7 @@ #include "gp9001.h" #include "toaplan_coincounter.h" +#include "toaplan_txtilemap.h" #include "toaplipt.h" #include "cpu/m68000/m68000.h" @@ -21,7 +22,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" class raizing_base_state : public driver_device @@ -29,9 +29,6 @@ class raizing_base_state : public driver_device public: raizing_base_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) - , m_tx_videoram(*this, "tx_videoram") - , m_tx_lineselect(*this, "tx_lineselect") - , m_tx_linescroll(*this, "tx_linescroll") , m_tx_gfxram(*this, "tx_gfxram") , m_audiobank(*this, "audiobank") , m_raizing_okibank{ @@ -42,7 +39,7 @@ class raizing_base_state : public driver_device , m_audiocpu(*this, "audiocpu") , m_vdp(*this, "gp9001") , m_oki(*this, "oki%u", 1U) - , m_gfxdecode(*this, "gfxdecode") + , m_tx_tilemap(*this, "tx_tilemap") , m_screen(*this, "screen") , m_palette(*this, "palette") , m_soundlatch(*this, "soundlatch%u", 1U) @@ -53,8 +50,6 @@ class raizing_base_state : public driver_device protected: u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - // used by everything - void create_tx_tilemap(int dx = 0, int dx_flipped = 0); // used by bgaregga + batrider etc. void bgaregga_common_video_start(); void raizing_z80_bankswitch_w(u8 data); @@ -84,26 +79,19 @@ class raizing_base_state : public driver_device u32 screen_update_base(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void screen_vblank(int state); - void tx_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); - void tx_linescroll_w(offs_t offset, u16 data, u16 mem_mask = ~0); - TILE_GET_INFO_MEMBER(get_text_tile_info); - void coin_w(u8 data); void reset_audiocpu(int state); - tilemap_t *m_tx_tilemap = nullptr; /* Tilemap for extra-text-layer */ - required_shared_ptr m_tx_videoram; - optional_shared_ptr m_tx_lineselect; - optional_shared_ptr m_tx_linescroll; optional_shared_ptr m_tx_gfxram; optional_memory_bank m_audiobank; // batrider and bgaregga optional_memory_bank_array<8> m_raizing_okibank[2]; optional_shared_ptr m_shared_ram; // 8 bit RAM shared between 68K and sound CPU + required_device m_maincpu; optional_device m_audiocpu; required_device m_vdp; optional_device_array m_oki; - optional_device m_gfxdecode; + required_device m_tx_tilemap; required_device m_screen; required_device m_palette; optional_device_array m_soundlatch; // tekipaki, batrider, bgaregga, batsugun diff --git a/src/mame/toaplan/raizing_batrider.cpp b/src/mame/toaplan/raizing_batrider.cpp index d3689f08b886f..2d2c9e351538b 100644 --- a/src/mame/toaplan/raizing_batrider.cpp +++ b/src/mame/toaplan/raizing_batrider.cpp @@ -239,7 +239,7 @@ void batrider_state::batrider_tx_gfxram_w(offs_t offset, u16 data, u16 mem_mask) if (oldword != data) { COMBINE_DATA(&m_tx_gfxram[offset]); - m_gfxdecode->gfx(0)->mark_dirty(offset/16); + m_tx_tilemap->gfx(0)->mark_dirty(offset/16); } } @@ -292,9 +292,7 @@ void batrider_state::video_start() m_vdp->disable_sprite_buffer(); // disable buffering on this game // Create the Text tilemap for this game - m_gfxdecode->gfx(0)->set_source(reinterpret_cast(m_tx_gfxram.target())); - - create_tx_tilemap(0x1d4, 0x16b); + m_tx_tilemap->gfx(0)->set_source(reinterpret_cast(m_tx_gfxram.target())); // Has special banking save_item(NAME(m_gfxrom_bank)); @@ -620,10 +618,10 @@ INPUT_PORTS_END void batrider_state::batrider_dma_mem(address_map &map) { - map(0x0000, 0x1fff).ram().w(FUNC(batrider_state::tx_videoram_w)).share(m_tx_videoram); + map(0x0000, 0x1fff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::videoram_r), FUNC(toaplan_txtilemap_device::videoram_w)); map(0x2000, 0x2fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x3000, 0x31ff).ram().share(m_tx_lineselect); - map(0x3200, 0x33ff).ram().w(FUNC(batrider_state::tx_linescroll_w)).share(m_tx_linescroll); + map(0x3000, 0x31ff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::lineselect_r), FUNC(toaplan_txtilemap_device::lineselect_w)); + map(0x3200, 0x33ff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::linescroll_r), FUNC(toaplan_txtilemap_device::linescroll_w)); map(0x3400, 0x7fff).ram(); map(0x8000, 0xffff).ram().w(FUNC(batrider_state::batrider_tx_gfxram_w)).share(m_tx_gfxram); } @@ -802,7 +800,6 @@ void batrider_state::batrider(machine_config &config) m_screen->screen_vblank().set(FUNC(batrider_state::screen_vblank)); m_screen->set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx_batrider); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, gp9001vdp_device::VDP_PALETTE_LENGTH); GP9001_VDP(config, m_vdp, 27_MHz_XTAL); @@ -810,6 +807,9 @@ void batrider_state::batrider(machine_config &config) m_vdp->set_tile_callback(FUNC(batrider_state::batrider_bank_cb)); m_vdp->vint_out_cb().set_inputline(m_maincpu, M68K_IRQ_2); + TOAPLAN_TXTILEMAP(config, m_tx_tilemap, 27_MHz_XTAL, m_palette, gfx_batrider); + m_tx_tilemap->set_offset(0x1d4, 0, 0x16b, 0); + // sound hardware SPEAKER(config, "mono").front_center(); @@ -866,7 +866,6 @@ void bbakraid_state::bbakraid(machine_config &config) m_screen->screen_vblank().set(FUNC(bbakraid_state::screen_vblank)); m_screen->set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx_batrider); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, gp9001vdp_device::VDP_PALETTE_LENGTH); GP9001_VDP(config, m_vdp, 27_MHz_XTAL); @@ -874,6 +873,9 @@ void bbakraid_state::bbakraid(machine_config &config) m_vdp->set_tile_callback(FUNC(bbakraid_state::batrider_bank_cb)); m_vdp->vint_out_cb().set_inputline(m_maincpu, M68K_IRQ_1); + TOAPLAN_TXTILEMAP(config, m_tx_tilemap, 27_MHz_XTAL, m_palette, gfx_batrider); + m_tx_tilemap->set_offset(0x1d4, 0, 0x16b, 0); + // sound hardware SPEAKER(config, "mono").front_center(); @@ -912,13 +914,15 @@ void nprobowl_state::nprobowl(machine_config &config) m_screen->screen_vblank().set(FUNC(nprobowl_state::screen_vblank)); m_screen->set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx_batrider); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, gp9001vdp_device::VDP_PALETTE_LENGTH); GP9001_VDP(config, m_vdp, 27_MHz_XTAL); m_vdp->set_palette(m_palette); m_vdp->vint_out_cb().set_inputline(m_maincpu, M68K_IRQ_2); + TOAPLAN_TXTILEMAP(config, m_tx_tilemap, 27_MHz_XTAL, m_palette, gfx_batrider); + m_tx_tilemap->set_offset(0x1d4, 0, 0x16b, 0); + // sound hardware SPEAKER(config, "mono").front_center(); diff --git a/src/mame/toaplan/snowbro2.cpp b/src/mame/toaplan/snowbro2.cpp index ffd36945edc22..88dc9c6207d53 100644 --- a/src/mame/toaplan/snowbro2.cpp +++ b/src/mame/toaplan/snowbro2.cpp @@ -14,7 +14,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* Name Board No Maker Game name diff --git a/src/mame/toaplan/sunwise.cpp b/src/mame/toaplan/sunwise.cpp index 7db45f2c61ca1..a3a32c3ba7756 100644 --- a/src/mame/toaplan/sunwise.cpp +++ b/src/mame/toaplan/sunwise.cpp @@ -16,7 +16,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /***************************************************************************** diff --git a/src/mame/toaplan/tekipaki.cpp b/src/mame/toaplan/tekipaki.cpp index fad8b50f8be55..0bdc468b3074b 100644 --- a/src/mame/toaplan/tekipaki.cpp +++ b/src/mame/toaplan/tekipaki.cpp @@ -15,7 +15,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* @@ -335,7 +334,7 @@ ROM_START( whoopee ) ROM_LOAD16_BYTE( "whoopee.1", 0x000000, 0x020000, CRC(28882e7e) SHA1(8fcd278a7d005eb81cd9e461139c0c0f756a4fa4) ) ROM_LOAD16_BYTE( "whoopee.2", 0x000001, 0x020000, CRC(6796f133) SHA1(d4e657be260ba3fd3f0556ade617882513b52685) ) - ROM_REGION( 0x10000, "audiocpu", 0 ) /* Sound HD647180 code */ + ROM_REGION( 0x8000, "audiocpu", 0 ) /* Sound HD647180 code */ ROM_LOAD( "hd647180.025", 0x00000, 0x08000, CRC(c02436f6) SHA1(385343f88991646ec23b385eaea82718f1251ea6) ) ROM_REGION( 0x200000, "gp9001", 0 ) diff --git a/src/mame/toaplan/toaplan_txtilemap.cpp b/src/mame/toaplan/toaplan_txtilemap.cpp new file mode 100644 index 0000000000000..d6278d6c55566 --- /dev/null +++ b/src/mame/toaplan/toaplan_txtilemap.cpp @@ -0,0 +1,157 @@ +// license:BSD-3-Clause +// copyright-holders:Quench, Yochizo, David Haywood +/*************************************************************************** + +Common Toaplan text tilemap generator usally paired with GP9001 + +Tilemap: Single 64x32 tilemap (tile size: 8x8) with Per-line scroll + +RAM format (original docs from toaplan/truxton2.cpp) + +Text RAM format $0000-1FFF (actually its probably $0000-0FFF) +---- --xx xxxx xxxx = Tile number +xxxx xx-- ---- ---- = Color (0 - 3Fh) + 40h + +Line select / flip $0000-01EF (some games go to $01FF (excess?)) +---x xxxx xxxx xxxx = Line select for each line +x--- ---- ---- ---- = X flip for each line ??? + +Line scroll $0000-01EF (some games go to $01FF (excess?)) +---- ---x xxxx xxxx = X scroll for each line + +Used in: +- toaplan/fixeight.cpp +- toaplan/raizing_batrider.cpp +- toaplan/raizing.cpp +- toaplan/truxton2.cpp + +***************************************************************************/ + + +#include "emu.h" +#include "toaplan_txtilemap.h" +#include "screen.h" + +DEFINE_DEVICE_TYPE(TOAPLAN_TXTILEMAP, toaplan_txtilemap_device, "toaplan_txtilemap", "Toaplan Text tilemap generator") + +toaplan_txtilemap_device::toaplan_txtilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, TOAPLAN_TXTILEMAP, tag, owner, clock) + , device_gfx_interface(mconfig, *this) + , m_videoram(*this, "videoram", 0x2000U, ENDIANNESS_BIG) + , m_linescroll(*this, "linescroll", 0x200U, ENDIANNESS_BIG) + , m_lineselect(*this, "lineselect", 0x1000U, ENDIANNESS_BIG) // some hardware has 4KB line select RAM + , m_tilemap(nullptr) + , m_dx(0) + , m_dy(0) + , m_dx_flipped(0) + , m_dy_flipped(0) +{ +} + +TILE_GET_INFO_MEMBER(toaplan_txtilemap_device::get_tile_info) +{ + const u16 attrib = m_videoram[tile_index]; + const u32 tile_number = attrib & 0x3ff; + const u32 color = (attrib >> 10) & 0x3f; + tileinfo.set(0, tile_number, color, 0); +} + + +void toaplan_txtilemap_device::device_start() +{ + m_tilemap = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(toaplan_txtilemap_device::get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); + + m_tilemap->set_scroll_rows(8*32); /* line scrolling */ + m_tilemap->set_scroll_cols(1); + m_tilemap->set_scrolldx(m_dx, m_dx_flipped); + m_tilemap->set_scrolldy(m_dy, m_dy_flipped); + m_tilemap->set_transparent_pen(0); +} + +void toaplan_txtilemap_device::device_reset() +{ +} + +// read/write handlers + +u16 toaplan_txtilemap_device::videoram_r(offs_t offset) +{ + return m_videoram[offset]; +} + +u16 toaplan_txtilemap_device::linescroll_r(offs_t offset) +{ + return m_linescroll[offset]; +} + +u16 toaplan_txtilemap_device::lineselect_r(offs_t offset) +{ + return m_lineselect[offset]; +} + +void toaplan_txtilemap_device::videoram_w(offs_t offset, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_videoram[offset]); + if (offset < 64*32) + m_tilemap->mark_tile_dirty(offset); +} + +void toaplan_txtilemap_device::linescroll_w(offs_t offset, u16 data, u16 mem_mask) +{ + /*** Line-Scroll RAM for Text Layer ***/ + COMBINE_DATA(&m_linescroll[offset]); + m_tilemap->set_scrollx(offset, m_linescroll[offset]); +} + +void toaplan_txtilemap_device::lineselect_w(offs_t offset, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_lineselect[offset]); +} + +// draw routine + +template +void toaplan_txtilemap_device::draw_tilemap_base(screen_device &screen, BitmapClass &bitmap, const rectangle &cliprect) +{ + rectangle clip = cliprect; + + /* it seems likely that flipx can be set per line! */ + /* however, none of the games does it, and emulating it in the */ + /* MAME tilemap system without being ultra slow would be tricky */ + m_tilemap->set_flip(m_lineselect[0] & 0x8000 ? 0 : TILEMAP_FLIPX); + + /* line select is used for 'for use in' and '8ing' screen on bbakraid, 'Raizing' logo on batrider */ + for (int y = cliprect.min_y; y <= cliprect.max_y; y++) + { + clip.min_y = clip.max_y = y; + m_tilemap->set_scrolly(0, m_lineselect[y] - y); + m_tilemap->draw(screen, bitmap, clip, 0); + } +} + +template +void toaplan_txtilemap_device::draw_tilemap_bootleg_base(screen_device &screen, BitmapClass &bitmap, const rectangle &cliprect) +{ + // bootleg hardware has no scroll RAM + m_tilemap->draw(screen, bitmap, cliprect, 0, 0); +} + +void toaplan_txtilemap_device::draw_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + draw_tilemap_base(screen, bitmap, cliprect); +} + +void toaplan_txtilemap_device::draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + draw_tilemap_base(screen, bitmap, cliprect); +} + +void toaplan_txtilemap_device::draw_tilemap_bootleg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + draw_tilemap_bootleg_base(screen, bitmap, cliprect); +} + +void toaplan_txtilemap_device::draw_tilemap_bootleg(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + draw_tilemap_bootleg_base(screen, bitmap, cliprect); +} diff --git a/src/mame/toaplan/toaplan_txtilemap.h b/src/mame/toaplan/toaplan_txtilemap.h new file mode 100644 index 0000000000000..e13047309ab39 --- /dev/null +++ b/src/mame/toaplan/toaplan_txtilemap.h @@ -0,0 +1,71 @@ +// license:BSD-3-Clause +// copyright-holders:Quench, David Haywood +/*************************************************************************** + +Common Toaplan text tilemap generator usally paired with GP9001 + +***************************************************************************/ +#ifndef MAME_TOAPLAN_TOAPLAN_TXTILEMAP_H +#define MAME_TOAPLAN_TOAPLAN_TXTILEMAP_H + +#pragma once + +#include "tilemap.h" + +class toaplan_txtilemap_device : public device_t, public device_gfx_interface +{ +public: + toaplan_txtilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + template toaplan_txtilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, T &&palette_tag, const gfx_decode_entry *gfxinfo) + : toaplan_txtilemap_device(mconfig, tag, owner, clock) + { + set_info(gfxinfo); + set_palette(std::forward(palette_tag)); + } + + // configurations + void set_offset(int dx, int dy, int dx_flipped, int dy_flipped) + { + m_dx = dx; + m_dy = dy; + m_dx_flipped = dx_flipped; + m_dy_flipped = dy_flipped; + } + + // read/write handlers + u16 videoram_r(offs_t offset); + u16 linescroll_r(offs_t offset); + u16 lineselect_r(offs_t offset); + void videoram_w(offs_t offset, u16 data, u16 mem_mask); + void linescroll_w(offs_t offset, u16 data, u16 mem_mask); + void lineselect_w(offs_t offset, u16 data, u16 mem_mask); + + // renderer + void draw_tilemap(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + void draw_tilemap_bootleg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void draw_tilemap_bootleg(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + +protected: + virtual void device_start() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; + +private: + template void draw_tilemap_base(screen_device &screen, BitmapClass &bitmap, const rectangle &cliprect); + template void draw_tilemap_bootleg_base(screen_device &screen, BitmapClass &bitmap, const rectangle &cliprect); + + TILE_GET_INFO_MEMBER(get_tile_info); + + memory_share_creator m_videoram; + memory_share_creator m_linescroll; + memory_share_creator m_lineselect; + + tilemap_t *m_tilemap = nullptr; + + int m_dx, m_dy; + int m_dx_flipped, m_dy_flipped; +}; + +DECLARE_DEVICE_TYPE(TOAPLAN_TXTILEMAP, toaplan_txtilemap_device) + +#endif // MAME_TOAPLAN_TOAPLAN_TXTILEMAP_H diff --git a/src/mame/toaplan/truxton2.cpp b/src/mame/toaplan/truxton2.cpp index af68dea56bdf4..bb32d29201cc7 100644 --- a/src/mame/toaplan/truxton2.cpp +++ b/src/mame/toaplan/truxton2.cpp @@ -5,6 +5,7 @@ #include "gp9001.h" #include "toaplan_coincounter.h" +#include "toaplan_txtilemap.h" #include "toaplipt.h" #include "cpu/m68000/m68000.h" @@ -14,7 +15,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" //#define TRUXTON2_STEREO /* Uncomment to hear truxton2 music in stereo */ @@ -39,14 +39,11 @@ class truxton2_state : public driver_device public: truxton2_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) - , m_tx_videoram(*this, "tx_videoram") - , m_tx_lineselect(*this, "tx_lineselect") - , m_tx_linescroll(*this, "tx_linescroll") , m_tx_gfxram(*this, "tx_gfxram") , m_maincpu(*this, "maincpu") , m_vdp(*this, "gp9001") , m_oki(*this, "oki") - , m_gfxdecode(*this, "gfxdecode") + , m_tx_tilemap(*this, "tx_tilemap") , m_screen(*this, "screen") , m_palette(*this, "palette") { } @@ -57,75 +54,23 @@ class truxton2_state : public driver_device virtual void video_start() override ATTR_COLD; u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void create_tx_tilemap(int dx = 0, int dx_flipped = 0); void screen_vblank(int state); void tx_gfxram_w(offs_t offset, u16 data, u16 mem_mask = ~0); void truxton2_68k_mem(address_map &map) ATTR_COLD; - void tx_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); - void tx_linescroll_w(offs_t offset, u16 data, u16 mem_mask = ~0); - TILE_GET_INFO_MEMBER(get_text_tile_info); - private: - tilemap_t *m_tx_tilemap = nullptr; /* Tilemap for extra-text-layer */ - required_shared_ptr m_tx_videoram; - required_shared_ptr m_tx_lineselect; - required_shared_ptr m_tx_linescroll; required_shared_ptr m_tx_gfxram; required_device m_maincpu; required_device m_vdp; required_device m_oki; - required_device m_gfxdecode; + required_device m_tx_tilemap; required_device m_screen; required_device m_palette; bitmap_ind8 m_custom_priority_bitmap; }; -/* - Extra-text RAM format - - Truxton 2 (and Fixeight + Raizing games have an extra-text layer) - - Text RAM format $0000-1FFF (actually its probably $0000-0FFF) - ---- --xx xxxx xxxx = Tile number - xxxx xx-- ---- ---- = Color (0 - 3Fh) + 40h - - Line select / flip $0000-01EF (some games go to $01FF (excess?)) - ---x xxxx xxxx xxxx = Line select for each line - x--- ---- ---- ---- = X flip for each line ??? - - Line scroll $0000-01EF (some games go to $01FF (excess?)) - ---- ---x xxxx xxxx = X scroll for each line -*/ - -TILE_GET_INFO_MEMBER(truxton2_state::get_text_tile_info) -{ - const u16 attrib = m_tx_videoram[tile_index]; - const u32 tile_number = attrib & 0x3ff; - const u32 color = attrib >> 10; - tileinfo.set(0, - tile_number, - color, - 0); -} - -void truxton2_state::tx_videoram_w(offs_t offset, u16 data, u16 mem_mask) -{ - COMBINE_DATA(&m_tx_videoram[offset]); - if (offset < 64*32) - m_tx_tilemap->mark_tile_dirty(offset); -} - -void truxton2_state::tx_linescroll_w(offs_t offset, u16 data, u16 mem_mask) -{ - /*** Line-Scroll RAM for Text Layer ***/ - COMBINE_DATA(&m_tx_linescroll[offset]); - - m_tx_tilemap->set_scrollx(offset, m_tx_linescroll[offset]); -} - void truxton2_state::screen_vblank(int state) @@ -143,40 +88,17 @@ u32 truxton2_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c bitmap.fill(0, cliprect); m_custom_priority_bitmap.fill(0, cliprect); m_vdp->render_vdp(bitmap, cliprect); - rectangle clip = cliprect; - - /* it seems likely that flipx can be set per line! */ - /* however, none of the games does it, and emulating it in the */ - /* MAME tilemap system without being ultra slow would be tricky */ - m_tx_tilemap->set_flip(m_tx_lineselect[0] & 0x8000 ? 0 : TILEMAP_FLIPX); - - /* line select is used for 'for use in' and '8ing' screen on bbakraid, 'Raizing' logo on batrider */ - for (int y = cliprect.min_y; y <= cliprect.max_y; y++) - { - clip.min_y = clip.max_y = y; - m_tx_tilemap->set_scrolly(0, m_tx_lineselect[y] - y); - m_tx_tilemap->draw(screen, bitmap, clip, 0); - } + m_tx_tilemap->draw_tilemap(screen, bitmap, cliprect); return 0; } -void truxton2_state::create_tx_tilemap(int dx, int dx_flipped) -{ - m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(truxton2_state::get_text_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - - m_tx_tilemap->set_scroll_rows(8*32); /* line scrolling */ - m_tx_tilemap->set_scroll_cols(1); - m_tx_tilemap->set_scrolldx(dx, dx_flipped); - m_tx_tilemap->set_transparent_pen(0); -} - void truxton2_state::tx_gfxram_w(offs_t offset, u16 data, u16 mem_mask) { const u16 oldword = m_tx_gfxram[offset]; if (oldword != data) { COMBINE_DATA(&m_tx_gfxram[offset]); - m_gfxdecode->gfx(0)->mark_dirty(offset/32); + m_tx_tilemap->gfx(0)->mark_dirty(offset/32); } } @@ -185,8 +107,7 @@ void truxton2_state::video_start() m_screen->register_screen_bitmap(m_custom_priority_bitmap); m_vdp->custom_priority_bitmap = &m_custom_priority_bitmap; - m_gfxdecode->gfx(0)->set_source(reinterpret_cast(m_tx_gfxram.target())); - create_tx_tilemap(0x1d5, 0x16a); + m_tx_tilemap->gfx(0)->set_source(reinterpret_cast(m_tx_gfxram.target())); } @@ -277,9 +198,9 @@ void truxton2_state::truxton2_68k_mem(address_map &map) map(0x100000, 0x10ffff).ram(); map(0x200000, 0x20000d).rw(m_vdp, FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write)); map(0x300000, 0x300fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x400000, 0x401fff).ram().w(FUNC(truxton2_state::tx_videoram_w)).share(m_tx_videoram); - map(0x402000, 0x402fff).ram().share(m_tx_lineselect); - map(0x403000, 0x4031ff).ram().w(FUNC(truxton2_state::tx_linescroll_w)).share(m_tx_linescroll); + map(0x400000, 0x401fff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::videoram_r), FUNC(toaplan_txtilemap_device::videoram_w)); + map(0x402000, 0x402fff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::lineselect_r), FUNC(toaplan_txtilemap_device::lineselect_w)); + map(0x403000, 0x4031ff).rw(m_tx_tilemap, FUNC(toaplan_txtilemap_device::linescroll_r), FUNC(toaplan_txtilemap_device::linescroll_w)); map(0x403200, 0x403fff).ram(); map(0x500000, 0x50ffff).ram().w(FUNC(truxton2_state::tx_gfxram_w)).share(m_tx_gfxram); map(0x600000, 0x600001).r(m_vdp, FUNC(gp9001vdp_device::vdpcount_r)); @@ -330,13 +251,15 @@ void truxton2_state::truxton2(machine_config &config) m_screen->screen_vblank().set(FUNC(truxton2_state::screen_vblank)); m_screen->set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, gp9001vdp_device::VDP_PALETTE_LENGTH); GP9001_VDP(config, m_vdp, 27_MHz_XTAL); m_vdp->set_palette(m_palette); m_vdp->vint_out_cb().set_inputline(m_maincpu, M68K_IRQ_2); + TOAPLAN_TXTILEMAP(config, m_tx_tilemap, 27_MHz_XTAL, m_palette, gfx); + m_tx_tilemap->set_offset(0x1d5, 0, 0x16a, 0); + /* sound hardware */ #ifdef TRUXTON2_STEREO // music data is stereo... SPEAKER(config, "speaker", 2).front(); diff --git a/src/mame/toaplan/vfive.cpp b/src/mame/toaplan/vfive.cpp index da6c9e17697a7..0371c24ce5e28 100644 --- a/src/mame/toaplan/vfive.cpp +++ b/src/mame/toaplan/vfive.cpp @@ -15,7 +15,6 @@ #include "emupal.h" #include "screen.h" #include "speaker.h" -#include "tilemap.h" /* Name Board No Maker Game name