From 493194ac6f1716076d926048eb986ad381ea4286 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Thu, 13 Jun 2013 12:26:12 +0000 Subject: [PATCH] Modernized Taito PC080SN video device. [Osso] --- src/mame/drivers/darius.c | 8 +- src/mame/drivers/opwolf.c | 16 +- src/mame/drivers/rainbow.c | 14 +- src/mame/drivers/rastan.c | 8 +- src/mame/drivers/topspeed.c | 16 +- src/mame/video/darius.c | 6 +- src/mame/video/opwolf.c | 6 +- src/mame/video/rainbow.c | 16 +- src/mame/video/rastan.c | 6 +- src/mame/video/taitoic.c | 356 +++++++++++++++--------------------- src/mame/video/taitoic.h | 74 ++++---- src/mame/video/topspeed.c | 12 +- 12 files changed, 246 insertions(+), 292 deletions(-) diff --git a/src/mame/drivers/darius.c b/src/mame/drivers/darius.c index f3de20ee61b..4cce6e9fe0d 100644 --- a/src/mame/drivers/darius.c +++ b/src/mame/drivers/darius.c @@ -241,10 +241,10 @@ static ADDRESS_MAP_START( darius_map, AS_PROGRAM, 16, darius_state ) AM_RANGE(0x0a0000, 0x0a0001) AM_WRITE(cpua_ctrl_w) AM_RANGE(0x0b0000, 0x0b0001) AM_WRITE(darius_watchdog_w) AM_RANGE(0xc00000, 0xc0007f) AM_READWRITE(darius_ioc_r, darius_ioc_w) /* inputs, sound */ - AM_RANGE(0xd00000, 0xd0ffff) AM_DEVREADWRITE_LEGACY("pc080sn", pc080sn_word_r, pc080sn_word_w) /* tilemaps */ - AM_RANGE(0xd20000, 0xd20003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_yscroll_word_w) - AM_RANGE(0xd40000, 0xd40003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_xscroll_word_w) - AM_RANGE(0xd50000, 0xd50003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_ctrl_word_w) + AM_RANGE(0xd00000, 0xd0ffff) AM_DEVREADWRITE("pc080sn", pc080sn_device, word_r, word_w) /* tilemaps */ + AM_RANGE(0xd20000, 0xd20003) AM_DEVWRITE("pc080sn", pc080sn_device, yscroll_word_w) + AM_RANGE(0xd40000, 0xd40003) AM_DEVWRITE("pc080sn", pc080sn_device, xscroll_word_w) + AM_RANGE(0xd50000, 0xd50003) AM_DEVWRITE("pc080sn", pc080sn_device, ctrl_word_w) AM_RANGE(0xd80000, 0xd80fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_word_w) AM_SHARE("paletteram")/* palette */ AM_RANGE(0xe00100, 0xe00fff) AM_RAM AM_SHARE("spriteram") AM_RANGE(0xe01000, 0xe02fff) AM_RAM AM_SHARE("share2") diff --git a/src/mame/drivers/opwolf.c b/src/mame/drivers/opwolf.c index 921872938d1..a764e5ab202 100644 --- a/src/mame/drivers/opwolf.c +++ b/src/mame/drivers/opwolf.c @@ -369,11 +369,11 @@ static ADDRESS_MAP_START( opwolf_map, AS_PROGRAM, 16, opwolf_state ) AM_RANGE(0x3c0000, 0x3c0001) AM_WRITENOP /* watchdog ?? */ AM_RANGE(0x3e0000, 0x3e0001) AM_READNOP AM_DEVWRITE8("tc0140syt", tc0140syt_device, tc0140syt_port_w, 0xff00) AM_RANGE(0x3e0002, 0x3e0003) AM_DEVREADWRITE8("tc0140syt", tc0140syt_device, tc0140syt_comm_r, tc0140syt_comm_w, 0xff00) - AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE_LEGACY("pc080sn", pc080sn_word_r, pc080sn_word_w) + AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE("pc080sn", pc080sn_device, word_r, word_w) AM_RANGE(0xc10000, 0xc1ffff) AM_WRITEONLY /* error in init code (?) */ - AM_RANGE(0xc20000, 0xc20003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_yscroll_word_w) - AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_xscroll_word_w) - AM_RANGE(0xc50000, 0xc50003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_ctrl_word_w) + AM_RANGE(0xc20000, 0xc20003) AM_DEVWRITE("pc080sn", pc080sn_device, yscroll_word_w) + AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE("pc080sn", pc080sn_device, xscroll_word_w) + AM_RANGE(0xc50000, 0xc50003) AM_DEVWRITE("pc080sn", pc080sn_device, ctrl_word_w) AM_RANGE(0xd00000, 0xd03fff) AM_DEVREADWRITE_LEGACY("pc090oj", pc090oj_word_r, pc090oj_word_w) /* sprite ram */ ADDRESS_MAP_END @@ -390,11 +390,11 @@ static ADDRESS_MAP_START( opwolfb_map, AS_PROGRAM, 16, opwolf_state ) AM_RANGE(0x3c0000, 0x3c0001) AM_WRITENOP /* watchdog ?? */ AM_RANGE(0x3e0000, 0x3e0001) AM_READNOP AM_DEVWRITE8("tc0140syt", tc0140syt_device, tc0140syt_port_w, 0xff00) AM_RANGE(0x3e0002, 0x3e0003) AM_DEVREADWRITE8("tc0140syt", tc0140syt_device, tc0140syt_comm_r, tc0140syt_comm_w, 0xff00) - AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE_LEGACY("pc080sn", pc080sn_word_r, pc080sn_word_w) + AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE("pc080sn", pc080sn_device, word_r, word_w) AM_RANGE(0xc10000, 0xc1ffff) AM_WRITEONLY /* error in init code (?) */ - AM_RANGE(0xc20000, 0xc20003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_yscroll_word_w) - AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_xscroll_word_w) - AM_RANGE(0xc50000, 0xc50003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_ctrl_word_w) + AM_RANGE(0xc20000, 0xc20003) AM_DEVWRITE("pc080sn", pc080sn_device, yscroll_word_w) + AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE("pc080sn", pc080sn_device, xscroll_word_w) + AM_RANGE(0xc50000, 0xc50003) AM_DEVWRITE("pc080sn", pc080sn_device, ctrl_word_w) AM_RANGE(0xd00000, 0xd03fff) AM_DEVREADWRITE_LEGACY("pc090oj", pc090oj_word_r, pc090oj_word_w) /* sprite ram */ ADDRESS_MAP_END diff --git a/src/mame/drivers/rainbow.c b/src/mame/drivers/rainbow.c index 8ce415b85a1..ea108e30bd7 100644 --- a/src/mame/drivers/rainbow.c +++ b/src/mame/drivers/rainbow.c @@ -357,10 +357,10 @@ static ADDRESS_MAP_START( rbisland_map, AS_PROGRAM, 16, rbisland_state ) AM_RANGE(0x800000, 0x8007ff) AM_READWRITE(rbisland_cchip_ram_r,rbisland_cchip_ram_w) AM_RANGE(0x800802, 0x800803) AM_READWRITE(rbisland_cchip_ctrl_r,rbisland_cchip_ctrl_w) AM_RANGE(0x800c00, 0x800c01) AM_WRITE(rbisland_cchip_bank_w) - AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE_LEGACY("pc080sn", pc080sn_word_r, pc080sn_word_w) - AM_RANGE(0xc20000, 0xc20003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_yscroll_word_w) - AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_xscroll_word_w) - AM_RANGE(0xc50000, 0xc50003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_ctrl_word_w) + AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE("pc080sn", pc080sn_device, word_r, word_w) + AM_RANGE(0xc20000, 0xc20003) AM_DEVWRITE("pc080sn", pc080sn_device, yscroll_word_w) + AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE("pc080sn", pc080sn_device, xscroll_word_w) + AM_RANGE(0xc50000, 0xc50003) AM_DEVWRITE("pc080sn", pc080sn_device, ctrl_word_w) AM_RANGE(0xd00000, 0xd03fff) AM_DEVREADWRITE_LEGACY("pc090oj", pc090oj_word_r, pc090oj_word_w) /* sprite ram + other stuff */ ADDRESS_MAP_END @@ -377,12 +377,12 @@ static ADDRESS_MAP_START( jumping_map, AS_PROGRAM, 16, rbisland_state ) AM_RANGE(0x3c0000, 0x3c0001) AM_WRITENOP /* watchdog? */ AM_RANGE(0x400006, 0x400007) AM_WRITE(jumping_sound_w) AM_RANGE(0x420000, 0x420001) AM_READNOP /* read, but result not used */ - AM_RANGE(0x430000, 0x430003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_yscroll_word_w) + AM_RANGE(0x430000, 0x430003) AM_DEVWRITE("pc080sn", pc080sn_device, yscroll_word_w) AM_RANGE(0x440000, 0x4407ff) AM_RAM AM_SHARE("spriteram") AM_RANGE(0x800000, 0x80ffff) AM_WRITENOP /* original c-chip location (not used) */ - AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE_LEGACY("pc080sn", pc080sn_word_r, pc080sn_word_w) + AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE("pc080sn", pc080sn_device, word_r, word_w) AM_RANGE(0xc20000, 0xc20003) AM_WRITENOP /* seems it is a leftover from rbisland: scroll y written here too */ - AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_xscroll_word_w) + AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE("pc080sn", pc080sn_device, xscroll_word_w) AM_RANGE(0xd00000, 0xd01fff) AM_RAM /* original spriteram location, needed for Attract Mode */ ADDRESS_MAP_END diff --git a/src/mame/drivers/rastan.c b/src/mame/drivers/rastan.c index d8daaaa73dd..d9088824d9a 100644 --- a/src/mame/drivers/rastan.c +++ b/src/mame/drivers/rastan.c @@ -215,10 +215,10 @@ static ADDRESS_MAP_START( rastan_map, AS_PROGRAM, 16, rastan_state ) AM_RANGE(0x3c0000, 0x3c0001) AM_WRITE(watchdog_reset16_w) AM_RANGE(0x3e0000, 0x3e0001) AM_READNOP AM_DEVWRITE8("tc0140syt", tc0140syt_device, tc0140syt_port_w, 0x00ff) AM_RANGE(0x3e0002, 0x3e0003) AM_DEVREADWRITE8("tc0140syt", tc0140syt_device, tc0140syt_comm_r, tc0140syt_comm_w, 0x00ff) - AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE_LEGACY("pc080sn", pc080sn_word_r, pc080sn_word_w) - AM_RANGE(0xc20000, 0xc20003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_yscroll_word_w) - AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_xscroll_word_w) - AM_RANGE(0xc50000, 0xc50003) AM_DEVWRITE_LEGACY("pc080sn", pc080sn_ctrl_word_w) + AM_RANGE(0xc00000, 0xc0ffff) AM_DEVREADWRITE("pc080sn", pc080sn_device, word_r, word_w) + AM_RANGE(0xc20000, 0xc20003) AM_DEVWRITE("pc080sn", pc080sn_device, yscroll_word_w) + AM_RANGE(0xc40000, 0xc40003) AM_DEVWRITE("pc080sn", pc080sn_device, xscroll_word_w) + AM_RANGE(0xc50000, 0xc50003) AM_DEVWRITE("pc080sn", pc080sn_device, ctrl_word_w) AM_RANGE(0xd00000, 0xd03fff) AM_DEVREADWRITE_LEGACY("pc090oj", pc090oj_word_r, pc090oj_word_w) /* sprite ram */ ADDRESS_MAP_END diff --git a/src/mame/drivers/topspeed.c b/src/mame/drivers/topspeed.c index 52f1debaf4d..f12c55bc046 100644 --- a/src/mame/drivers/topspeed.c +++ b/src/mame/drivers/topspeed.c @@ -503,14 +503,14 @@ static ADDRESS_MAP_START( topspeed_map, AS_PROGRAM, 16, topspeed_state ) AM_RANGE(0x7e0002, 0x7e0003) AM_DEVREADWRITE8("tc0140syt", tc0140syt_device, tc0140syt_comm_r, tc0140syt_comm_w, 0x00ff) AM_RANGE(0x800000, 0x8003ff) AM_RAM AM_SHARE("raster_ctrl") AM_RANGE(0x800400, 0x80ffff) AM_RAM - AM_RANGE(0xa00000, 0xa0ffff) AM_DEVREADWRITE_LEGACY("pc080sn_1", pc080sn_word_r, pc080sn_word_w) - AM_RANGE(0xa20000, 0xa20003) AM_DEVWRITE_LEGACY("pc080sn_1", pc080sn_yscroll_word_w) - AM_RANGE(0xa40000, 0xa40003) AM_DEVWRITE_LEGACY("pc080sn_1", pc080sn_xscroll_word_w) - AM_RANGE(0xa50000, 0xa50003) AM_DEVWRITE_LEGACY("pc080sn_1", pc080sn_ctrl_word_w) - AM_RANGE(0xb00000, 0xb0ffff) AM_DEVREADWRITE_LEGACY("pc080sn_2", pc080sn_word_r, pc080sn_word_w) - AM_RANGE(0xb20000, 0xb20003) AM_DEVWRITE_LEGACY("pc080sn_2", pc080sn_yscroll_word_w) - AM_RANGE(0xb40000, 0xb40003) AM_DEVWRITE_LEGACY("pc080sn_2", pc080sn_xscroll_word_w) - AM_RANGE(0xb50000, 0xb50003) AM_DEVWRITE_LEGACY("pc080sn_2", pc080sn_ctrl_word_w) + AM_RANGE(0xa00000, 0xa0ffff) AM_DEVREADWRITE("pc080sn_1", pc080sn_device, word_r, word_w) + AM_RANGE(0xa20000, 0xa20003) AM_DEVWRITE("pc080sn_1", pc080sn_device, yscroll_word_w) + AM_RANGE(0xa40000, 0xa40003) AM_DEVWRITE("pc080sn_1", pc080sn_device, xscroll_word_w) + AM_RANGE(0xa50000, 0xa50003) AM_DEVWRITE("pc080sn_1", pc080sn_device, ctrl_word_w) + AM_RANGE(0xb00000, 0xb0ffff) AM_DEVREADWRITE("pc080sn_2", pc080sn_device, word_r, word_w) + AM_RANGE(0xb20000, 0xb20003) AM_DEVWRITE("pc080sn_2", pc080sn_device, yscroll_word_w) + AM_RANGE(0xb40000, 0xb40003) AM_DEVWRITE("pc080sn_2", pc080sn_device, xscroll_word_w) + AM_RANGE(0xb50000, 0xb50003) AM_DEVWRITE("pc080sn_2", pc080sn_device, ctrl_word_w) AM_RANGE(0xd00000, 0xd00fff) AM_RAM AM_SHARE("spriteram") AM_RANGE(0xe00000, 0xe0ffff) AM_RAM AM_SHARE("spritemap") ADDRESS_MAP_END diff --git a/src/mame/video/darius.c b/src/mame/video/darius.c index a1b5e6b5802..0746b1bd388 100644 --- a/src/mame/video/darius.c +++ b/src/mame/video/darius.c @@ -88,16 +88,16 @@ void darius_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect UINT32 darius_state::update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffs) { - pc080sn_tilemap_update(m_pc080sn); + m_pc080sn->tilemap_update(); // draw bottom layer(always active) - pc080sn_tilemap_draw_offset(m_pc080sn, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0, -xoffs, 0); + m_pc080sn->tilemap_draw_offset(bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0, -xoffs, 0); /* Sprites can be under/over the layer below text layer */ draw_sprites(bitmap, cliprect, 0, xoffs, -8); // draw sprites with priority 0 which are under the mid layer // draw middle layer - pc080sn_tilemap_draw_offset(m_pc080sn, bitmap, cliprect, 1, 0, 0, -xoffs, 0); + m_pc080sn->tilemap_draw_offset(bitmap, cliprect, 1, 0, 0, -xoffs, 0); draw_sprites(bitmap, cliprect, 1, xoffs, -8); // draw sprites with priority 1 which are over the mid layer diff --git a/src/mame/video/opwolf.c b/src/mame/video/opwolf.c index da8d7fb58ec..c53dcbb49d9 100644 --- a/src/mame/video/opwolf.c +++ b/src/mame/video/opwolf.c @@ -38,15 +38,15 @@ UINT32 opwolf_state::screen_update_opwolf(screen_device &screen, bitmap_ind16 &b { int layer[2]; - pc080sn_tilemap_update(m_pc080sn); + m_pc080sn->tilemap_update(); layer[0] = 0; layer[1] = 1; machine().priority_bitmap.fill(0, cliprect); - pc080sn_tilemap_draw(m_pc080sn, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); - pc080sn_tilemap_draw(m_pc080sn, bitmap, cliprect, layer[1], 0, 2); + m_pc080sn->tilemap_draw(bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); + m_pc080sn->tilemap_draw(bitmap, cliprect, layer[1], 0, 2); pc090oj_draw_sprites(m_pc090oj, bitmap, cliprect, 1); diff --git a/src/mame/video/rainbow.c b/src/mame/video/rainbow.c index 09addefc964..86cb55ce1f4 100644 --- a/src/mame/video/rainbow.c +++ b/src/mame/video/rainbow.c @@ -42,15 +42,15 @@ UINT32 rbisland_state::screen_update_rainbow(screen_device &screen, bitmap_ind16 { int layer[2]; - pc080sn_tilemap_update(m_pc080sn); + m_pc080sn->tilemap_update(); layer[0] = 0; layer[1] = 1; machine().priority_bitmap.fill(0, cliprect); - pc080sn_tilemap_draw(m_pc080sn, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); - pc080sn_tilemap_draw(m_pc080sn, bitmap, cliprect, layer[1], 0, 2); + m_pc080sn->tilemap_draw(bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); + m_pc080sn->tilemap_draw(bitmap, cliprect, layer[1], 0, 2); pc090oj_draw_sprites(m_pc090oj, bitmap, cliprect, 1); return 0; @@ -69,7 +69,7 @@ the Y settings are active low. VIDEO_START_MEMBER(rbisland_state,jumping) { - pc080sn_set_trans_pen(m_pc080sn, 1, 15); + m_pc080sn->set_trans_pen(1, 15); m_sprite_ctrl = 0; m_sprites_flipscreen = 0; @@ -86,17 +86,17 @@ UINT32 rbisland_state::screen_update_jumping(screen_device &screen, bitmap_ind16 int offs, layer[2]; int sprite_colbank = (m_sprite_ctrl & 0xe0) >> 1; - pc080sn_tilemap_update(m_pc080sn); + m_pc080sn->tilemap_update(); /* Override values, or foreground layer is in wrong position */ - pc080sn_set_scroll(m_pc080sn, 1, 16, 0); + m_pc080sn->set_scroll(1, 16, 0); layer[0] = 0; layer[1] = 1; machine().priority_bitmap.fill(0, cliprect); - pc080sn_tilemap_draw(m_pc080sn, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 0); + m_pc080sn->tilemap_draw(bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 0); /* Draw the sprites. 128 sprites in total */ for (offs = m_spriteram.bytes() / 2 - 8; offs >= 0; offs -= 8) @@ -122,7 +122,7 @@ UINT32 rbisland_state::screen_update_jumping(screen_device &screen, bitmap_ind16 } } - pc080sn_tilemap_draw(m_pc080sn, bitmap, cliprect, layer[1], 0, 0); + m_pc080sn->tilemap_draw(bitmap, cliprect, layer[1], 0, 0); #if 0 { diff --git a/src/mame/video/rastan.c b/src/mame/video/rastan.c index 15d267a214a..b7c995047f2 100644 --- a/src/mame/video/rastan.c +++ b/src/mame/video/rastan.c @@ -33,15 +33,15 @@ UINT32 rastan_state::screen_update_rastan(screen_device &screen, bitmap_ind16 &b { int layer[2]; - pc080sn_tilemap_update(m_pc080sn); + m_pc080sn->tilemap_update(); layer[0] = 0; layer[1] = 1; machine().priority_bitmap.fill(0, cliprect); - pc080sn_tilemap_draw(m_pc080sn, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); - pc080sn_tilemap_draw(m_pc080sn, bitmap, cliprect, layer[1], 0, 2); + m_pc080sn->tilemap_draw(bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); + m_pc080sn->tilemap_draw(bitmap, cliprect, layer[1], 0, 2); pc090oj_draw_sprites(m_pc090oj, bitmap, cliprect, 0); return 0; diff --git a/src/mame/video/taitoic.c b/src/mame/video/taitoic.c index 78028da3ac5..ebe3cdc54c0 100644 --- a/src/mame/video/taitoic.c +++ b/src/mame/video/taitoic.c @@ -544,53 +544,88 @@ INLINE void taitoic_drawscanline( bitmap_ind16 &bitmap, const rectangle &cliprec /* */ /***************************************************************************/ -struct pc080sn_state -{ - UINT16 ctrl[8]; - - UINT16 * ram; - UINT16 * bg_ram[2]; - UINT16 * bgscroll_ram[2]; - - int bgscrollx[2], bgscrolly[2]; - int xoffs, yoffs; - - tilemap_t *tilemap[2]; - int bg_gfx; - int yinvert, dblwidth; -}; - #define PC080SN_RAM_SIZE 0x10000 -/***************************************************************************** - INLINE FUNCTIONS -*****************************************************************************/ +const device_type PC080SN = &device_creator; -INLINE pc080sn_state *pc080sn_get_safe_token( device_t *device ) +pc080sn_device::pc080sn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, PC080SN, "Taito PC080SN", tag, owner, clock) { - assert(device != NULL); - assert(device->type() == PC080SN); - - return (pc080sn_state *)downcast(device)->token(); } -INLINE const pc080sn_interface *pc080sn_get_interface( device_t *device ) +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void pc080sn_device::device_config_complete() { - assert(device != NULL); - assert((device->type() == PC080SN)); - return (const pc080sn_interface *) device->static_config(); + // inherit a copy of the static data + const pc080sn_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + } +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void pc080sn_device::device_start() +{ + /* use the given gfx set for bg tiles */ + if (!m_dblwidth) /* standard tilemaps */ + { + m_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + } + else /* double width tilemaps */ + { + m_tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); + m_tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); + } + + m_tilemap[0]->set_transparent_pen(0); + m_tilemap[1]->set_transparent_pen(0); + + m_tilemap[0]->set_scrolldx(-16 + m_x_offset, -16 - m_x_offset); + m_tilemap[0]->set_scrolldy(m_y_offset, -m_y_offset); + m_tilemap[1]->set_scrolldx(-16 + m_x_offset, -16 - m_x_offset); + m_tilemap[1]->set_scrolldy(m_y_offset, -m_y_offset); + + if (!m_dblwidth) + { + m_tilemap[0]->set_scroll_rows(512); + m_tilemap[1]->set_scroll_rows(512); + } + + m_ram = auto_alloc_array_clear(machine(), UINT16, PC080SN_RAM_SIZE / 2); + + m_bg_ram[0] = m_ram + 0x0000 /2; + m_bg_ram[1] = m_ram + 0x8000 /2; + m_bgscroll_ram[0] = m_ram + 0x4000 /2; + m_bgscroll_ram[1] = m_ram + 0xc000 /2; + + save_pointer(NAME(m_ram), PC080SN_RAM_SIZE / 2); + save_item(NAME(m_ctrl)); + machine().save().register_postload(save_prepost_delegate(FUNC(pc080sn_device::restore_scroll), this)); + } /***************************************************************************** DEVICE HANDLERS *****************************************************************************/ -INLINE void common_get_pc080sn_bg_tile_info( running_machine &machine, device_t *device, tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) +void pc080sn_device::common_get_pc080sn_bg_tile_info( tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); UINT16 code, attr; - - if (!pc080sn->dblwidth) + + if (!m_dblwidth) { code = (ram[2 * tile_index + 1] & 0x3fff); attr = ram[2 * tile_index]; @@ -601,19 +636,23 @@ INLINE void common_get_pc080sn_bg_tile_info( running_machine &machine, device_t attr = ram[tile_index]; } - SET_TILE_INFO( + SET_TILE_INFO_MEMBER( gfxnum, code, (attr & 0x1ff), TILE_FLIPYX((attr & 0xc000) >> 14)); } -INLINE void common_get_pc080sn_fg_tile_info( running_machine &machine, device_t *device, tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ) +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, UINT16 *ram, int gfxnum ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); UINT16 code,attr; - - if (!pc080sn->dblwidth) + + if (!m_dblwidth) { code = (ram[2 * tile_index + 1] & 0x3fff); attr = ram[2 * tile_index]; @@ -624,104 +663,87 @@ INLINE void common_get_pc080sn_fg_tile_info( running_machine &machine, device_t attr = ram[tile_index]; } - SET_TILE_INFO( + SET_TILE_INFO_MEMBER( gfxnum, code, (attr & 0x1ff), TILE_FLIPYX((attr & 0xc000) >> 14)); } -TILE_GET_INFO_MEMBER(pc080sn_device::pc080sn_get_bg_tile_info) +TILE_GET_INFO_MEMBER(pc080sn_device::get_fg_tile_info) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(this); - common_get_pc080sn_bg_tile_info(machine(), this, tileinfo, tile_index, pc080sn->bg_ram[0], pc080sn->bg_gfx); + common_get_pc080sn_fg_tile_info( tileinfo, tile_index, m_bg_ram[1], m_gfxnum ); } -TILE_GET_INFO_MEMBER(pc080sn_device::pc080sn_get_fg_tile_info) +READ16_MEMBER( pc080sn_device::word_r ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(this); - common_get_pc080sn_fg_tile_info(machine(), this, tileinfo, tile_index, pc080sn->bg_ram[1], pc080sn->bg_gfx); + return m_ram[offset]; } - -READ16_DEVICE_HANDLER( pc080sn_word_r ) +WRITE16_MEMBER( pc080sn_device::word_w ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); - return pc080sn->ram[offset]; -} + COMBINE_DATA(&m_ram[offset]); -WRITE16_DEVICE_HANDLER( pc080sn_word_w ) -{ - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); - - COMBINE_DATA(&pc080sn->ram[offset]); - - if (!pc080sn->dblwidth) + if (!m_dblwidth) { if (offset < 0x2000) - pc080sn->tilemap[0]->mark_tile_dirty(offset / 2); + m_tilemap[0]->mark_tile_dirty(offset / 2); else if (offset >= 0x4000 && offset < 0x6000) - pc080sn->tilemap[1]->mark_tile_dirty((offset & 0x1fff) / 2); + m_tilemap[1]->mark_tile_dirty((offset & 0x1fff) / 2); } else { if (offset < 0x4000) - pc080sn->tilemap[0]->mark_tile_dirty((offset & 0x1fff)); + m_tilemap[0]->mark_tile_dirty((offset & 0x1fff)); else if (offset >= 0x4000 && offset < 0x8000) - pc080sn->tilemap[1]->mark_tile_dirty((offset & 0x1fff)); + m_tilemap[1]->mark_tile_dirty((offset & 0x1fff)); } } -WRITE16_DEVICE_HANDLER( pc080sn_xscroll_word_w ) +WRITE16_MEMBER( pc080sn_device::xscroll_word_w ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); + COMBINE_DATA(&m_ctrl[offset]); - COMBINE_DATA(&pc080sn->ctrl[offset]); - - data = pc080sn->ctrl[offset]; + data = m_ctrl[offset]; switch (offset) { case 0x00: - pc080sn->bgscrollx[0] = -data; + m_bgscrollx[0] = -data; break; case 0x01: - pc080sn->bgscrollx[1] = -data; + m_bgscrollx[1] = -data; break; } } -WRITE16_DEVICE_HANDLER( pc080sn_yscroll_word_w ) +WRITE16_MEMBER( pc080sn_device::yscroll_word_w ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); + COMBINE_DATA(&m_ctrl[offset + 2]); - COMBINE_DATA(&pc080sn->ctrl[offset + 2]); + data = m_ctrl[offset + 2]; - data = pc080sn->ctrl[offset + 2]; - - if (pc080sn->yinvert) + if (m_y_invert) data = -data; switch (offset) { case 0x00: - pc080sn->bgscrolly[0] = -data; + m_bgscrolly[0] = -data; break; case 0x01: - pc080sn->bgscrolly[1] = -data; + m_bgscrolly[1] = -data; break; } } -WRITE16_DEVICE_HANDLER( pc080sn_ctrl_word_w ) +WRITE16_MEMBER( pc080sn_device::ctrl_word_w ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); + COMBINE_DATA(&m_ctrl[offset + 4]); - COMBINE_DATA(&pc080sn->ctrl[offset + 4]); - - data = pc080sn->ctrl[offset + 4]; + data = m_ctrl[offset + 4]; switch (offset) { @@ -729,8 +751,8 @@ WRITE16_DEVICE_HANDLER( pc080sn_ctrl_word_w ) { int flip = (data & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; - pc080sn->tilemap[0]->set_flip(flip); - pc080sn->tilemap[1]->set_flip(flip); + m_tilemap[0]->set_flip(flip); + m_tilemap[1]->set_flip(flip); break; } } @@ -743,43 +765,39 @@ WRITE16_DEVICE_HANDLER( pc080sn_ctrl_word_w ) /* This routine is needed as an override by Jumping, which doesn't set proper scroll values for foreground tilemap */ -void pc080sn_set_scroll( device_t *device, int tilemap_num, int scrollx, int scrolly ) +void pc080sn_device::set_scroll( int tilemap_num, int scrollx, int scrolly ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); - - pc080sn->tilemap[tilemap_num]->set_scrollx(0, scrollx); - pc080sn->tilemap[tilemap_num]->set_scrolly(0, scrolly); + m_tilemap[tilemap_num]->set_scrollx(0, scrollx); + m_tilemap[tilemap_num]->set_scrolly(0, scrolly); } /* This routine is needed as an override by Jumping */ -void pc080sn_set_trans_pen( device_t *device, int tilemap_num, int pen ) +void pc080sn_device::set_trans_pen( int tilemap_num, int pen ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); - pc080sn->tilemap[tilemap_num]->set_transparent_pen(pen); + m_tilemap[tilemap_num]->set_transparent_pen(pen); } -void pc080sn_tilemap_update( device_t *device ) +void pc080sn_device::tilemap_update( ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); int j; - pc080sn->tilemap[0]->set_scrolly(0, pc080sn->bgscrolly[0]); - pc080sn->tilemap[1]->set_scrolly(0, pc080sn->bgscrolly[1]); + m_tilemap[0]->set_scrolly(0, m_bgscrolly[0]); + m_tilemap[1]->set_scrolly(0, m_bgscrolly[1]); - if (!pc080sn->dblwidth) + if (!m_dblwidth) { for (j = 0; j < 256; j++) - pc080sn->tilemap[0]->set_scrollx((j + pc080sn->bgscrolly[0]) & 0x1ff, pc080sn->bgscrollx[0] - pc080sn->bgscroll_ram[0][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++) - pc080sn->tilemap[1]->set_scrollx((j + pc080sn->bgscrolly[1]) & 0x1ff, pc080sn->bgscrollx[1] - pc080sn->bgscroll_ram[1][j]); + m_tilemap[1]->set_scrollx((j + m_bgscrolly[1]) & 0x1ff, m_bgscrollx[1] - m_bgscroll_ram[1][j]); } else { - pc080sn->tilemap[0]->set_scrollx(0, pc080sn->bgscrollx[0]); - pc080sn->tilemap[1]->set_scrollx(0, pc080sn->bgscrollx[1]); + m_tilemap[0]->set_scrollx(0, m_bgscrollx[0]); + m_tilemap[1]->set_scrollx(0, m_bgscrollx[1]); } } @@ -833,16 +851,14 @@ static UINT16 topspeed_get_road_pixel_color( UINT16 pixel, UINT16 color ) } -static void topspeed_custom_draw( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, - UINT32 priority, UINT16 *color_ctrl_ram ) +void pc080sn_device::topspeed_custom_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *color_ctrl_ram ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); UINT16 *dst16, *src16; UINT8 *tsrc; UINT16 scanline[1024]; /* won't be called by a wide-screen game, but just in case... */ - bitmap_ind16 &srcbitmap = pc080sn->tilemap[layer]->pixmap(); - bitmap_ind8 &flagsbitmap = pc080sn->tilemap[layer]->flagsmap(); + bitmap_ind16 &srcbitmap = m_tilemap[layer]->pixmap(); + bitmap_ind8 &flagsbitmap = m_tilemap[layer]->flagsmap(); UINT16 a, color; int sx, x_index; @@ -860,8 +876,8 @@ static void topspeed_custom_draw( device_t *device, bitmap_ind16 &bitmap, const if (!flip) { - sx = pc080sn->bgscrollx[layer] + 16 - pc080sn->xoffs; - y_index = pc080sn->bgscrolly[layer] + min_y - pc080sn->yoffs; + sx = m_bgscrollx[layer] + 16 - m_x_offset; + y_index = m_bgscrolly[layer] + min_y - m_y_offset; } else // never used { @@ -877,10 +893,10 @@ static void topspeed_custom_draw( device_t *device, bitmap_ind16 &bitmap, const do { src_y_index = y_index & 0x1ff; /* tilemaps are 512 px up/down */ - row_index = (src_y_index - pc080sn->bgscrolly[layer]) & 0x1ff; - color = color_ctrl_ram[(row_index + pc080sn->yoffs - 2) & 0xff]; + row_index = (src_y_index - m_bgscrolly[layer]) & 0x1ff; + color = color_ctrl_ram[(row_index + m_y_offset - 2) & 0xff]; - x_index = sx - (pc080sn->bgscroll_ram[layer][row_index]); + x_index = sx - (m_bgscroll_ram[layer][row_index]); src16 = &srcbitmap.pix16(src_y_index); tsrc = &flagsbitmap.pix8(src_y_index); @@ -916,7 +932,7 @@ static void topspeed_custom_draw( device_t *device, bitmap_ind16 &bitmap, const } } - taitoic_drawscanline(bitmap, cliprect, 0, y, scanline, (flags & TILEMAP_DRAW_OPAQUE) ? 0 : 1, ROT0, device->machine().priority_bitmap, priority); + taitoic_drawscanline(bitmap, cliprect, 0, y, scanline, (flags & TILEMAP_DRAW_OPAQUE) ? 0 : 1, ROT0, machine().priority_bitmap, priority); y_index++; if (!machine_flip) @@ -927,120 +943,46 @@ static void topspeed_custom_draw( device_t *device, bitmap_ind16 &bitmap, const while ((!machine_flip && y <= max_y) || (machine_flip && y >= min_y)); } -void pc080sn_tilemap_draw( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority ) +void pc080sn_device::tilemap_draw( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); - pc080sn->tilemap[layer]->draw(bitmap, cliprect, flags, priority); + m_tilemap[layer]->draw(bitmap, cliprect, flags, priority); } -void pc080sn_tilemap_draw_offset( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, int xoffs, int yoffs ) +void pc080sn_device::tilemap_draw_offset( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, int x_offset, int y_offset ) { - pc080sn_state *pc080sn = pc080sn_get_safe_token(device); - int basedx = -16 - pc080sn->xoffs; - int basedxflip = -16 + pc080sn->xoffs; - int basedy = pc080sn->yoffs; - int basedyflip = -pc080sn->yoffs; + int basedx = -16 - m_x_offset; + int basedxflip = -16 + m_x_offset; + int basedy = m_y_offset; + int basedyflip = -m_y_offset; - pc080sn->tilemap[layer]->set_scrolldx(basedx + xoffs, basedxflip + xoffs); - pc080sn->tilemap[layer]->set_scrolldy(basedy + yoffs, basedyflip + yoffs); - pc080sn->tilemap[layer]->draw(bitmap, cliprect, flags, priority); - pc080sn->tilemap[layer]->set_scrolldx(basedx, basedxflip); - pc080sn->tilemap[layer]->set_scrolldy(basedy, basedyflip); + m_tilemap[layer]->set_scrolldx(basedx + x_offset, basedxflip + x_offset); + m_tilemap[layer]->set_scrolldy(basedy + y_offset, basedyflip + y_offset); + m_tilemap[layer]->draw(bitmap, cliprect, flags, priority); + m_tilemap[layer]->set_scrolldx(basedx, basedxflip); + m_tilemap[layer]->set_scrolldy(basedy, basedyflip); } -void pc080sn_tilemap_draw_special( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *ram ) +void pc080sn_device::tilemap_draw_special( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *ram ) { - topspeed_custom_draw(device, bitmap, cliprect, layer, flags, priority, ram); + pc080sn_device::topspeed_custom_draw(bitmap, cliprect, layer, flags, priority, ram); } -void pc080sn_device::pc080sn_restore_scroll() +void pc080sn_device::restore_scroll() { - pc080sn_state *pc080sn = pc080sn_get_safe_token(this); + int flip; - pc080sn->bgscrollx[0] = -pc080sn->ctrl[0]; - pc080sn->bgscrollx[1] = -pc080sn->ctrl[1]; - pc080sn->bgscrolly[0] = -pc080sn->ctrl[2]; - pc080sn->bgscrolly[1] = -pc080sn->ctrl[3]; + 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 = (pc080sn->ctrl[4] & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; - pc080sn->tilemap[0]->set_flip(flip); - pc080sn->tilemap[1]->set_flip(flip); + flip = (m_ctrl[4] & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0; + m_tilemap[0]->set_flip(flip); + m_tilemap[1]->set_flip(flip); } -const device_type PC080SN = &device_creator; - -pc080sn_device::pc080sn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, PC080SN, "Taito PC080SN", tag, owner, clock) -{ - m_token = global_alloc_clear(pc080sn_state); -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void pc080sn_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void pc080sn_device::device_start() -{ - pc080sn_state *pc080sn = pc080sn_get_safe_token(this); - const pc080sn_interface *intf = pc080sn_get_interface(this); - - /* use the given gfx set for bg tiles */ - pc080sn->bg_gfx = intf->gfxnum; - - pc080sn->yinvert = intf->y_invert; - pc080sn->dblwidth = intf->dblwidth; - pc080sn->xoffs = intf->x_offset; - pc080sn->yoffs = intf->y_offset; - - if (!pc080sn->dblwidth) /* standard tilemaps */ - { - pc080sn->tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::pc080sn_get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); - pc080sn->tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::pc080sn_get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); - } - else /* double width tilemaps */ - { - pc080sn->tilemap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::pc080sn_get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); - pc080sn->tilemap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(pc080sn_device::pc080sn_get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); - } - - pc080sn->tilemap[0]->set_transparent_pen(0); - pc080sn->tilemap[1]->set_transparent_pen(0); - - pc080sn->tilemap[0]->set_scrolldx(-16 + pc080sn->xoffs, -16 - pc080sn->xoffs); - pc080sn->tilemap[0]->set_scrolldy(pc080sn->yoffs, -pc080sn->yoffs); - pc080sn->tilemap[1]->set_scrolldx(-16 + pc080sn->xoffs, -16 - pc080sn->xoffs); - pc080sn->tilemap[1]->set_scrolldy(pc080sn->yoffs, -pc080sn->yoffs); - - if (!pc080sn->dblwidth) - { - pc080sn->tilemap[0]->set_scroll_rows(512); - pc080sn->tilemap[1]->set_scroll_rows(512); - } - - pc080sn->ram = auto_alloc_array_clear(machine(), UINT16, PC080SN_RAM_SIZE / 2); - - pc080sn->bg_ram[0] = pc080sn->ram + 0x0000 /2; - pc080sn->bg_ram[1] = pc080sn->ram + 0x8000 /2; - pc080sn->bgscroll_ram[0] = pc080sn->ram + 0x4000 /2; - pc080sn->bgscroll_ram[1] = pc080sn->ram + 0xc000 /2; - - save_pointer(NAME(pc080sn->ram), PC080SN_RAM_SIZE / 2); - save_item(NAME(pc080sn->ctrl)); - machine().save().register_postload(save_prepost_delegate(FUNC(pc080sn_device::pc080sn_restore_scroll), this)); - -} /***************************************************************************/ /* */ diff --git a/src/mame/video/taitoic.h b/src/mame/video/taitoic.h index ad88f303f62..0e84e6f76f5 100644 --- a/src/mame/video/taitoic.h +++ b/src/mame/video/taitoic.h @@ -17,11 +17,11 @@ struct pc080sn_interface { - int gfxnum; + int m_gfxnum; - int x_offset, y_offset; - int y_invert; - int dblwidth; + int m_x_offset, m_y_offset; + int m_y_invert; + int m_dblwidth; }; @@ -100,25 +100,54 @@ struct tc0180vcu_interface int tx_color_base; }; -class pc080sn_device : public device_t +class pc080sn_device : public device_t, + pc080sn_interface { public: pc080sn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~pc080sn_device() { global_free(m_token); } + ~pc080sn_device() {} + + DECLARE_READ16_MEMBER( word_r ); + DECLARE_WRITE16_MEMBER( word_w ); + DECLARE_WRITE16_MEMBER( xscroll_word_w ); + DECLARE_WRITE16_MEMBER( yscroll_word_w ); + DECLARE_WRITE16_MEMBER( ctrl_word_w ); + + 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, UINT16 *ram, int gfxnum ); + void common_get_pc080sn_fg_tile_info( tile_data &tileinfo, int tile_index, UINT16 *ram, int gfxnum ); - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } - void pc080sn_restore_scroll(); -protected: + void set_scroll(int tilemap_num, int scrollx, int scrolly); + void set_trans_pen(int tilemap_num, int pen); + void tilemap_update(); + void tilemap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority); + void tilemap_draw_offset(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, int xoffs, int yoffs); + void topspeed_custom_draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *color_ctrl_ram); + + /* For Topspeed */ + void tilemap_draw_special(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *ram); + + void restore_scroll(); + + protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); -private: + + private: // internal state - void *m_token; + UINT16 m_ctrl[8]; - TILE_GET_INFO_MEMBER(pc080sn_get_bg_tile_info); - TILE_GET_INFO_MEMBER(pc080sn_get_fg_tile_info); + UINT16 *m_ram; + UINT16 *m_bg_ram[2]; + UINT16 *m_bgscroll_ram[2]; + + int m_bgscrollx[2], m_bgscrolly[2]; + + tilemap_t *m_tilemap[2]; + }; extern const device_type PC080SN; @@ -379,23 +408,6 @@ extern const device_type TC0180VCU; DEVICE I/O FUNCTIONS ***************************************************************************/ -/** PC080SN **/ -DECLARE_READ16_DEVICE_HANDLER( pc080sn_word_r ); -DECLARE_WRITE16_DEVICE_HANDLER( pc080sn_word_w ); -DECLARE_WRITE16_DEVICE_HANDLER( pc080sn_xscroll_word_w ); -DECLARE_WRITE16_DEVICE_HANDLER( pc080sn_yscroll_word_w ); -DECLARE_WRITE16_DEVICE_HANDLER( pc080sn_ctrl_word_w ); - -void pc080sn_set_scroll(device_t *device, int tilemap_num, int scrollx, int scrolly); -void pc080sn_set_trans_pen(device_t *device, int tilemap_num, int pen); -void pc080sn_tilemap_update(device_t *device); -void pc080sn_tilemap_draw(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority); -void pc080sn_tilemap_draw_offset(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, int xoffs, int yoffs); - -/* For Topspeed */ -void pc080sn_tilemap_draw_special(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, UINT32 priority, UINT16 *ram); - - /** PC090OJ **/ DECLARE_READ16_DEVICE_HANDLER( pc090oj_word_r ); DECLARE_WRITE16_DEVICE_HANDLER( pc090oj_word_w ); diff --git a/src/mame/video/topspeed.c b/src/mame/video/topspeed.c index 9b4f74b990c..e905335d6a7 100644 --- a/src/mame/video/topspeed.c +++ b/src/mame/video/topspeed.c @@ -144,8 +144,8 @@ UINT32 topspeed_state::screen_update_topspeed(screen_device &screen, bitmap_ind1 } #endif - pc080sn_tilemap_update(m_pc080sn_1); - pc080sn_tilemap_update(m_pc080sn_2); + m_pc080sn_1->tilemap_update(); + m_pc080sn_2->tilemap_update(); /* Tilemap layer priority seems hardwired (the order is odd, too) */ layer[0] = 1; @@ -159,22 +159,22 @@ UINT32 topspeed_state::screen_update_topspeed(screen_device &screen, bitmap_ind1 #ifdef MAME_DEBUG if (m_dislayer[3] == 0) #endif - pc080sn_tilemap_draw(m_pc080sn_2, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); + m_pc080sn_2->tilemap_draw(bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); #ifdef MAME_DEBUG if (m_dislayer[2] == 0) #endif - pc080sn_tilemap_draw_special(m_pc080sn_2, bitmap, cliprect, layer[1], 0, 2, m_raster_ctrl); + m_pc080sn_2->tilemap_draw_special(bitmap, cliprect, layer[1], 0, 2, m_raster_ctrl); #ifdef MAME_DEBUG if (m_dislayer[1] == 0) #endif - pc080sn_tilemap_draw_special(m_pc080sn_1, bitmap, cliprect, layer[2], 0, 4, m_raster_ctrl + 0x100); + m_pc080sn_1->tilemap_draw_special(bitmap, cliprect, layer[2], 0, 4, m_raster_ctrl + 0x100); #ifdef MAME_DEBUG if (m_dislayer[0] == 0) #endif - pc080sn_tilemap_draw(m_pc080sn_1, bitmap, cliprect, layer[3], 0, 8); + m_pc080sn_1->tilemap_draw(bitmap, cliprect, layer[3], 0, 8); #ifdef MAME_DEBUG if (m_dislayer[4] == 0)