diff --git a/src/mame/taito/darius.cpp b/src/mame/taito/darius.cpp index 84b308f1b40..bd185162d00 100644 --- a/src/mame/taito/darius.cpp +++ b/src/mame/taito/darius.cpp @@ -268,7 +268,7 @@ TILE_GET_INFO_MEMBER(darius_state::get_fg_tile_info) u16 code = (m_fg_ram[tile_index + 0x2000] & 0x7ff); u16 attr = m_fg_ram[tile_index]; - tileinfo.set(2, + tileinfo.set(1, code, (attr & 0x7f), TILE_FLIPYX((attr & 0xc000) >> 14)); @@ -276,7 +276,7 @@ TILE_GET_INFO_MEMBER(darius_state::get_fg_tile_info) void darius_state::video_start() { - m_gfxdecode->gfx(2)->set_granularity(16); + m_gfxdecode->gfx(1)->set_granularity(16); m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(darius_state::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); m_fg_tilemap->set_transparent_pen(0); @@ -858,10 +858,13 @@ static const gfx_layout textlayout = static GFXDECODE_START( gfx_darius ) GFXDECODE_ENTRY( "sprites", 0, tilelayout, 0, 128 ) /* sprites */ - GFXDECODE_ENTRY( "pc080sn", 0, gfx_8x8x4_packed_msb, 0, 128 ) /* scr tiles */ GFXDECODE_ENTRY( "text", 0, textlayout, 0, 128 ) /* top layer scr tiles */ GFXDECODE_END +static GFXDECODE_START( gfx_darius_tmap ) + GFXDECODE_ENTRY( "pc080sn", 0, gfx_8x8x4_packed_msb, 0, 128 ) /* scr tiles */ +GFXDECODE_END + /******************************************************************************* MACHINE DRIVERS @@ -962,12 +965,10 @@ void darius_state::darius(machine_config &config) rscreen.set_screen_update(FUNC(darius_state::screen_update_right)); rscreen.set_palette(m_palette); - PC080SN(config, m_pc080sn, 0); - m_pc080sn->set_gfx_region(1); + PC080SN(config, m_pc080sn, 0, m_palette, gfx_darius_tmap); m_pc080sn->set_offsets(-16, 8); m_pc080sn->set_yinvert(0); m_pc080sn->set_dblwidth(1); - m_pc080sn->set_gfxdecode_tag(m_gfxdecode); /* sound hardware */ SPEAKER(config, "lspeaker").front_left(); diff --git a/src/mame/taito/opwolf.cpp b/src/mame/taito/opwolf.cpp index 9f7ee70f255..a476932abed 100644 --- a/src/mame/taito/opwolf.cpp +++ b/src/mame/taito/opwolf.cpp @@ -913,12 +913,9 @@ void opwolf_state::opwolf(machine_config &config) screen.set_screen_update(FUNC(opwolf_state::screen_update)); screen.set_palette("palette"); - GFXDECODE(config, "gfxdecode", "palette", gfx_opwolf); PALETTE(config, "palette").set_format(palette_device::xRGBRRRRGGGGBBBB_bit0, 2048); - PC080SN(config, m_pc080sn, 0); - m_pc080sn->set_gfx_region(0); - m_pc080sn->set_gfxdecode_tag("gfxdecode"); + PC080SN(config, m_pc080sn, 0, "palette", gfx_opwolf); PC090OJ(config, m_pc090oj, 0); m_pc090oj->set_palette("palette"); @@ -987,12 +984,9 @@ void opwolf_state::opwolfb(machine_config &config) /* OSC clocks unknown for the screen.set_screen_update(FUNC(opwolf_state::screen_update)); screen.set_palette("palette"); - GFXDECODE(config, "gfxdecode", "palette", gfx_opwolf); PALETTE(config, "palette").set_format(palette_device::xRGBRRRRGGGGBBBB_bit0, 2048); - PC080SN(config, m_pc080sn, 0); - m_pc080sn->set_gfx_region(0); - m_pc080sn->set_gfxdecode_tag("gfxdecode"); + PC080SN(config, m_pc080sn, 0, "palette", gfx_opwolf); PC090OJ(config, m_pc090oj, 0); m_pc090oj->set_palette("palette"); diff --git a/src/mame/taito/pc080sn.cpp b/src/mame/taito/pc080sn.cpp index 4de91c850cb..bc94abf85b5 100644 --- a/src/mame/taito/pc080sn.cpp +++ b/src/mame/taito/pc080sn.cpp @@ -46,20 +46,19 @@ Control registers #include "taito_helper.h" #include "screen.h" -#define PC080SN_RAM_SIZE 0x10000 +static constexpr u32 PC080SN_RAM_SIZE = 0x10000; #define TOPSPEED_ROAD_COLORS DEFINE_DEVICE_TYPE(PC080SN, pc080sn_device, "pc080sn", "Taito PC080SN") pc080sn_device::pc080sn_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, PC080SN, tag, owner, clock), - m_ram(nullptr), - m_gfxnum(0), - m_x_offset(0), - m_y_offset(0), - m_y_invert(0), - m_dblwidth(0), - m_gfxdecode(*this, finder_base::DUMMY_TAG) + : device_t(mconfig, PC080SN, tag, owner, clock) + , device_gfx_interface(mconfig, *this) + , m_ram(nullptr) + , m_x_offset(0) + , m_y_offset(0) + , m_y_invert(0) + , m_dblwidth(false) { for (auto & elem : m_ctrl) elem = 0; @@ -79,19 +78,16 @@ pc080sn_device::pc080sn_device(const machine_config &mconfig, const char *tag, d void pc080sn_device::device_start() { - if(!m_gfxdecode->started()) - throw device_missing_dependencies(); - /* use the given gfx set for bg tiles */ if (!m_dblwidth) /* standard tilemaps */ { - m_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(pc080sn_device::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); - m_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(pc080sn_device::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_tilemap[0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(pc080sn_device::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_tilemap[1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(pc080sn_device::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); } else /* double width tilemaps */ { - m_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(pc080sn_device::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); - m_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(pc080sn_device::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); + m_tilemap[0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(pc080sn_device::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); + m_tilemap[1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(pc080sn_device::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); } m_tilemap[0]->set_transparent_pen(0); @@ -132,7 +128,7 @@ void pc080sn_device::device_post_load() DEVICE HANDLERS *****************************************************************************/ -void pc080sn_device::common_get_pc080sn_bg_tile_info( tile_data &tileinfo, int tile_index, u16 *ram, int gfxnum ) +void pc080sn_device::common_get_tile_info(tile_data &tileinfo, int tile_index, u16 *ram) { u16 code, attr; @@ -147,7 +143,7 @@ void pc080sn_device::common_get_pc080sn_bg_tile_info( tile_data &tileinfo, int t attr = ram[tile_index]; } - tileinfo.set(gfxnum, + tileinfo.set(0, code, (attr & 0x1ff), TILE_FLIPYX((attr & 0xc000) >> 14)); @@ -155,33 +151,12 @@ void pc080sn_device::common_get_pc080sn_bg_tile_info( tile_data &tileinfo, int t TILE_GET_INFO_MEMBER(pc080sn_device::get_bg_tile_info) { - common_get_pc080sn_bg_tile_info( tileinfo, tile_index, m_bg_ram[0], m_gfxnum ); -} - -void pc080sn_device::common_get_pc080sn_fg_tile_info( tile_data &tileinfo, int tile_index, u16 *ram, int gfxnum ) -{ - u16 code,attr; - - if (!m_dblwidth) - { - code = (ram[2 * tile_index + 1] & 0x3fff); - attr = ram[2 * tile_index]; - } - else - { - code = (ram[tile_index + 0x2000] & 0x3fff); - attr = ram[tile_index]; - } - - tileinfo.set(gfxnum, - code, - (attr & 0x1ff), - TILE_FLIPYX((attr & 0xc000) >> 14)); + common_get_tile_info(tileinfo, tile_index, m_bg_ram[0]); } TILE_GET_INFO_MEMBER(pc080sn_device::get_fg_tile_info) { - common_get_pc080sn_fg_tile_info( tileinfo, tile_index, m_bg_ram[1], m_gfxnum ); + common_get_tile_info(tileinfo, tile_index, m_bg_ram[1]); } u16 pc080sn_device::word_r(offs_t offset) @@ -258,7 +233,7 @@ void pc080sn_device::ctrl_word_w(offs_t offset, u16 data, u16 mem_mask) { case 0x00: { - int flip = (data & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; + u32 const flip = (data & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; m_tilemap[0]->set_flip(flip); m_tilemap[1]->set_flip(flip); @@ -290,17 +265,15 @@ void pc080sn_device::set_trans_pen( int tilemap_num, int pen ) void pc080sn_device::tilemap_update( ) { - int j; - m_tilemap[0]->set_scrolly(0, m_bgscrolly[0]); m_tilemap[1]->set_scrolly(0, m_bgscrolly[1]); if (!m_dblwidth) { - for (j = 0; j < 256; j++) + for (int j = 0; j < 256; j++) m_tilemap[0]->set_scrollx((j + m_bgscrolly[0]) & 0x1ff, m_bgscrollx[0] - m_bgscroll_ram[0][j]); - for (j = 0; j < 256; j++) + for (int j = 0; j < 256; j++) m_tilemap[1]->set_scrollx((j + m_bgscrolly[1]) & 0x1ff, m_bgscrollx[1] - m_bgscroll_ram[1][j]); } else @@ -313,12 +286,10 @@ void pc080sn_device::tilemap_update( ) static u16 topspeed_get_road_pixel_color( u16 pixel, u16 color ) { - u16 road_body_color, off_road_color, pixel_type; - /* Color changes based on screenshots from game flyer */ - pixel_type = (pixel % 0x10); - road_body_color = (pixel & 0x7ff0) + 4; - off_road_color = road_body_color + 1; + u16 pixel_type = (pixel % 0x10); + u16 road_body_color = (pixel & 0x7ff0) + 4; + u16 off_road_color = road_body_color + 1; if ((color & 0xffe0) == 0xffe0) { @@ -372,12 +343,12 @@ void pc080sn_device::topspeed_custom_draw(screen_device &screen, bitmap_ind16 &b int flip = 0; - int min_x = cliprect.min_x; - int max_x = cliprect.max_x; - int min_y = cliprect.min_y; - int max_y = cliprect.max_y; - int screen_width = max_x - min_x + 1; - int width_mask = 0x1ff; /* underlying tilemap */ + int const min_x = cliprect.min_x; + int const max_x = cliprect.max_x; + int const min_y = cliprect.min_y; + int const max_y = cliprect.max_y; + int const screen_width = max_x - min_x + 1; + int const width_mask = 0x1ff; /* underlying tilemap */ if (!flip) { @@ -392,9 +363,9 @@ void pc080sn_device::topspeed_custom_draw(screen_device &screen, bitmap_ind16 &b for (int y = min_y; y <= max_y; y++) { - int src_y_index = y_index & 0x1ff; /* tilemaps are 512 px up/down */ - int row_index = (src_y_index - m_bgscrolly[layer]) & 0x1ff; - u16 color = color_ctrl_ram[(row_index + m_y_offset - 2) & 0xff]; + int const src_y_index = y_index & 0x1ff; /* tilemaps are 512 px up/down */ + int const row_index = (src_y_index - m_bgscrolly[layer]) & 0x1ff; + u16 const color = color_ctrl_ram[(row_index + m_y_offset - 2) & 0xff]; int x_index = sx - (m_bgscroll_ram[layer][row_index]); @@ -444,10 +415,10 @@ void pc080sn_device::tilemap_draw(screen_device &screen, bitmap_ind16 &bitmap, c void pc080sn_device::tilemap_draw_offset(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, u8 priority, int x_offset, int y_offset, u8 pmask) { - int basedx = -16 - m_x_offset; - int basedxflip = -16 + m_x_offset; - int basedy = m_y_offset; - int basedyflip = -m_y_offset; + int const basedx = -16 - m_x_offset; + int const basedxflip = -16 + m_x_offset; + int const basedy = m_y_offset; + int const basedyflip = -m_y_offset; m_tilemap[layer]->set_scrolldx(basedx + x_offset, basedxflip + x_offset); m_tilemap[layer]->set_scrolldy(basedy + y_offset, basedyflip + y_offset); @@ -464,14 +435,12 @@ void pc080sn_device::tilemap_draw_special(screen_device &screen, bitmap_ind16 &b void pc080sn_device::restore_scroll() { - int flip; - m_bgscrollx[0] = -m_ctrl[0]; m_bgscrollx[1] = -m_ctrl[1]; m_bgscrolly[0] = -m_ctrl[2]; m_bgscrolly[1] = -m_ctrl[3]; - flip = (m_ctrl[4] & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; + u32 const flip = (m_ctrl[4] & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; m_tilemap[0]->set_flip(flip); m_tilemap[1]->set_flip(flip); } diff --git a/src/mame/taito/pc080sn.h b/src/mame/taito/pc080sn.h index 6a08cc10fee..75836d328de 100644 --- a/src/mame/taito/pc080sn.h +++ b/src/mame/taito/pc080sn.h @@ -8,16 +8,20 @@ #include "tilemap.h" -class pc080sn_device : public device_t +class pc080sn_device : public device_t, public device_gfx_interface { public: pc080sn_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + template pc080sn_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, T &&palette_tag, const gfx_decode_entry *gfxinfo) + : pc080sn_device(mconfig, tag, owner, clock) + { + set_info(gfxinfo); + set_palette(std::forward(palette_tag)); + } // configuration - template void set_gfxdecode_tag(T &&tag) { m_gfxdecode.set_tag(std::forward(tag)); } - void set_gfx_region(int gfxregion) { m_gfxnum = gfxregion; } void set_yinvert(int y_inv) { m_y_invert = y_inv; } - void set_dblwidth(int dblwidth) { m_dblwidth = dblwidth; } + void set_dblwidth(bool dblwidth) { m_dblwidth = dblwidth; } void set_offsets(int x_offset, int y_offset) { m_x_offset = x_offset; @@ -33,8 +37,7 @@ public: TILE_GET_INFO_MEMBER(get_bg_tile_info); TILE_GET_INFO_MEMBER(get_fg_tile_info); - void common_get_pc080sn_bg_tile_info( tile_data &tileinfo, int tile_index, u16 *ram, int gfxnum ); - void common_get_pc080sn_fg_tile_info( tile_data &tileinfo, int tile_index, u16 *ram, int gfxnum ); + void common_get_tile_info(tile_data &tileinfo, int tile_index, u16 *ram); void set_scroll(int tilemap_num, int scrollx, int scrolly); void set_trans_pen(int tilemap_num, int pen); @@ -65,12 +68,9 @@ private: tilemap_t *m_tilemap[2]; - int m_gfxnum; int m_x_offset, m_y_offset; int m_y_invert; - int m_dblwidth; - - required_device m_gfxdecode; + bool m_dblwidth; }; DECLARE_DEVICE_TYPE(PC080SN, pc080sn_device) diff --git a/src/mame/taito/rastan.cpp b/src/mame/taito/rastan.cpp index 68c95c5df89..80ac0995349 100644 --- a/src/mame/taito/rastan.cpp +++ b/src/mame/taito/rastan.cpp @@ -452,11 +452,9 @@ void rastan_state::rastan(machine_config &config) screen.set_screen_update(FUNC(rastan_state::screen_update)); screen.set_palette("palette"); - GFXDECODE(config, "gfxdecode", "palette", gfx_rastan); PALETTE(config, "palette").set_format(palette_device::xBGR_555, 2048); - PC080SN(config, m_pc080sn, 0); - m_pc080sn->set_gfxdecode_tag("gfxdecode"); + PC080SN(config, m_pc080sn, 0, "palette", gfx_rastan); PC090OJ(config, m_pc090oj, 0); m_pc090oj->set_palette("palette"); @@ -821,5 +819,5 @@ GAME( 1987, rastsaga, rastan, rastan, rastsaga, rastan_state, empty_init, ROT GAME( 1987, rastanb, rastan, rastan, rastsaga, rastan_state, empty_init, ROT0, "Taito Corporation Japan", "Rastan (World, earlier code base)", MACHINE_SUPPORTS_SAVE ) GAME( 1987, rastanub, rastan, rastan, rastsaga, rastan_state, empty_init, ROT0, "Taito America Corporation", "Rastan (US, earlier code base)", MACHINE_SUPPORTS_SAVE ) GAME( 1987, rastsagaa, rastan, rastan, rastsaga, rastan_state, empty_init, ROT0, "Taito Corporation", "Rastan Saga (Japan Rev 1, earlier code base)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, rastsagaabl, rastan, rastan, rastsaga, rastan_state, empty_init, ROT0, "Taito Corporation", "Rastan Saga (bootleg, Japan Rev 1, earlier code base)", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, rastsagaabl, rastan, rastan, rastsaga, rastan_state, empty_init, ROT0, "bootleg", "Rastan Saga (bootleg, Japan Rev 1, earlier code base)", MACHINE_SUPPORTS_SAVE ) GAME( 1987, rastsagab, rastan, rastan, rastsaga, rastan_state, empty_init, ROT0, "Taito Corporation", "Rastan Saga (Japan, earlier code base)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/taito/rbisland.cpp b/src/mame/taito/rbisland.cpp index 28dd4295676..bb5a8dd6d25 100644 --- a/src/mame/taito/rbisland.cpp +++ b/src/mame/taito/rbisland.cpp @@ -349,7 +349,6 @@ public: m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), m_pc080sn(*this, "pc080sn"), - m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette") { } @@ -358,7 +357,6 @@ protected: required_device m_maincpu; required_device m_audiocpu; required_device m_pc080sn; - required_device m_gfxdecode; required_device m_palette; }; @@ -398,6 +396,7 @@ class jumping_state : public base_state public: jumping_state(const machine_config &mconfig, device_type type, const char *tag) : base_state(mconfig, type, tag), + m_gfxdecode(*this, "gfxdecode"), m_spriteram(*this, "spriteram") { } @@ -415,6 +414,9 @@ private: void main_map(address_map &map); void sound_map(address_map &map); + // devices + required_device m_gfxdecode; + // memory pointers required_shared_ptr m_spriteram; @@ -767,6 +769,9 @@ static const gfx_layout jumping_spritelayout = static GFXDECODE_START( gfx_jumping ) GFXDECODE_ENTRY( "sprites", 0, jumping_spritelayout, 0, 0x80 ) // OBJ 16x16 +GFXDECODE_END + +static GFXDECODE_START( gfx_jumping_tmap ) GFXDECODE_ENTRY( "pc080sn", 0, jumping_tilelayout, 0, 0x80 ) // SCR 8x8 GFXDECODE_END @@ -833,12 +838,9 @@ void rbisland_state::rbisland(machine_config &config) screen.set_screen_update(FUNC(rbisland_state::screen_update)); screen.set_palette(m_palette); - GFXDECODE(config, m_gfxdecode, m_palette, gfx_rbisland); PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 2048); - PC080SN(config, m_pc080sn, 0); - m_pc080sn->set_gfx_region(0); - m_pc080sn->set_gfxdecode_tag(m_gfxdecode); + PC080SN(config, m_pc080sn, 0, m_palette, gfx_rbisland); PC090OJ(config, m_pc090oj, 0); m_pc090oj->set_palette(m_palette); @@ -884,10 +886,8 @@ void jumping_state::jumping(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_jumping); PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 2048); - PC080SN(config, m_pc080sn, 0); - m_pc080sn->set_gfx_region(1); + PC080SN(config, m_pc080sn, 0, m_palette, gfx_jumping_tmap); m_pc080sn->set_yinvert(1); - m_pc080sn->set_gfxdecode_tag(m_gfxdecode); // sound hardware SPEAKER(config, "mono").front_center(); diff --git a/src/mame/taito/topspeed.cpp b/src/mame/taito/topspeed.cpp index 8d95263d6e8..b3253f3b04b 100644 --- a/src/mame/taito/topspeed.cpp +++ b/src/mame/taito/topspeed.cpp @@ -908,10 +908,13 @@ static const gfx_layout tile16x8_layout = static GFXDECODE_START( gfx_topspeed ) GFXDECODE_ENTRY( "sprites", 0x0, tile16x8_layout, 0, 256 ) // Sprite parts - GFXDECODE_ENTRY( "pc080sn", 0x0, gfx_8x8x4_packed_msb, 0, 512 ) // Playfield // Road Lines gfxdecodable ? GFXDECODE_END +static GFXDECODE_START( gfx_topspeed_tmap ) + GFXDECODE_ENTRY( "pc080sn", 0x0, gfx_8x8x4_packed_msb, 0, 512 ) // Playfield +GFXDECODE_END + /*********************************************************** MACHINE DRIVERS @@ -963,15 +966,11 @@ void topspeed_state::topspeed(machine_config &config) z80ctc_device& ctc(Z80CTC(config, "ctc", XTAL(16'000'000) / 4)); ctc.zc_callback<0>().set(FUNC(topspeed_state::z80ctc_to0)); - PC080SN(config, m_pc080sn[0], 0); - m_pc080sn[0]->set_gfx_region(1); + PC080SN(config, m_pc080sn[0], 0, "palette", gfx_topspeed_tmap); m_pc080sn[0]->set_offsets(0, 8); - m_pc080sn[0]->set_gfxdecode_tag(m_gfxdecode); - PC080SN(config, m_pc080sn[1], 0); - m_pc080sn[1]->set_gfx_region(1); + PC080SN(config, m_pc080sn[1], 0, "palette", gfx_topspeed_tmap); m_pc080sn[1]->set_offsets(0, 8); - m_pc080sn[1]->set_gfxdecode_tag(m_gfxdecode); pc060ha_device &ciu(PC060HA(config, "ciu", 0)); ciu.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI);