From 208fbb7dddd9266828ce6d47b93003a5476af586 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Sun, 28 Feb 2016 16:35:40 +0100 Subject: [PATCH] thoop2.cpp: oki memory map instead of memcpy (nw) --- src/mame/drivers/thoop2.cpp | 90 ++++++++++++++++++++----------------- src/mame/includes/thoop2.h | 32 +++++++------ src/mame/video/thoop2.cpp | 27 ++++++----- 3 files changed, 82 insertions(+), 67 deletions(-) diff --git a/src/mame/drivers/thoop2.cpp b/src/mame/drivers/thoop2.cpp index 756d5a87bb5..54f2181ece1 100644 --- a/src/mame/drivers/thoop2.cpp +++ b/src/mame/drivers/thoop2.cpp @@ -20,47 +20,20 @@ pf: but some gameplay bugs - sprite positioning is incorrect, no enemies, jump a #include "sound/okim6295.h" #include "includes/thoop2.h" -static const gfx_layout thoop2_tilelayout = + +void thoop2_state::machine_start() { - 8,8, /* 8x8 tiles */ - 0x400000/16, /* number of tiles */ - 4, /* 4 bpp */ - { 0*0x400000*8+8, 0*0x400000*8, 1*0x400000*8+8, 1*0x400000*8 }, - { 0, 1, 2, 3, 4, 5, 6, 7 }, - { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 }, - 16*8 -}; - -static const gfx_layout thoop2_tilelayout_16 = -{ - 16,16, /* 16x16 tiles */ - 0x400000/64, /* number of tiles */ - 4, /* 4 bpp */ - { 0*0x400000*8+8, 0*0x400000*8, 1*0x400000*8+8, 1*0x400000*8 }, - { 0, 1, 2, 3, 4, 5, 6, 7, - 16*16+0, 16*16+1, 16*16+2, 16*16+3, 16*16+4, 16*16+5, 16*16+6, 16*16+7 }, - { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, - 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, - 64*8 -}; - - -static GFXDECODE_START( thoop2 ) - GFXDECODE_ENTRY( "gfx1", 0x000000, thoop2_tilelayout, 0, 64 ) - GFXDECODE_ENTRY( "gfx1", 0x000000, thoop2_tilelayout_16, 0, 64 ) -GFXDECODE_END - + membank("okibank")->configure_entries(0, 16, memregion("oki")->base(), 0x10000); +} WRITE16_MEMBER(thoop2_state::OKIM6295_bankswitch_w) { - UINT8 *RAM = memregion("oki")->base(); - if (ACCESSING_BITS_0_7){ - memcpy(&RAM[0x30000], &RAM[0x40000 + (data & 0x0f)*0x10000], 0x10000); - } + membank("okibank")->set_entry(data & 0x0f); + } } -WRITE16_MEMBER(thoop2_state::thoop2_coin_w) +WRITE16_MEMBER(thoop2_state::coin_w) { if (ACCESSING_BITS_0_7){ switch ((offset >> 3)){ @@ -88,7 +61,7 @@ READ16_MEMBER(thoop2_state::DS5002FP_R) static ADDRESS_MAP_START( thoop2_map, AS_PROGRAM, 16, thoop2_state ) AM_RANGE(0x000000, 0x0fffff) AM_ROM /* ROM */ - AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(thoop2_vram_w) AM_SHARE("videoram") /* Video RAM */ + AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(vram_w) AM_SHARE("videoram") /* Video RAM */ AM_RANGE(0x108000, 0x108007) AM_WRITEONLY AM_SHARE("vregs") /* Video Registers */ AM_RANGE(0x10800c, 0x10800d) AM_WRITE(watchdog_reset16_w) /* INT 6 ACK/Watchdog timer */ AM_RANGE(0x200000, 0x2007ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")/* Palette */ @@ -100,13 +73,19 @@ static ADDRESS_MAP_START( thoop2_map, AS_PROGRAM, 16, thoop2_state ) AM_RANGE(0x700008, 0x700009) AM_READ_PORT("SYSTEM") AM_RANGE(0x70000c, 0x70000d) AM_WRITE(OKIM6295_bankswitch_w) /* OKI6295 bankswitch */ AM_RANGE(0x70000e, 0x70000f) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff) /* OKI6295 data register */ - AM_RANGE(0x70000a, 0x70005b) AM_WRITE(thoop2_coin_w) /* Coin Counters + Coin Lockout */ + AM_RANGE(0x70000a, 0x70005b) AM_WRITE(coin_w) /* Coin Counters + Coin Lockout */ AM_RANGE(0xfeff00, 0xfeff01) AM_READ(DS5002FP_R) AM_RANGE(0xfeff02, 0xfeff03) AM_WRITENOP /* pf: 0xfeff02 and 0xfeff03 need to remain zero always */ AM_RANGE(0xfe0000, 0xfeffff) AM_RAM /* Work RAM (partially shared with DS5002FP) */ ADDRESS_MAP_END +static ADDRESS_MAP_START( oki_map, AS_0, 8, thoop2_state ) + AM_RANGE(0x00000, 0x2ffff) AM_ROM + AM_RANGE(0x30000, 0x3ffff) AM_ROMBANK("okibank") +ADDRESS_MAP_END + + static INPUT_PORTS_START( thoop2 ) PORT_START("DSW1") PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_B ) ) @@ -188,6 +167,37 @@ static INPUT_PORTS_START( thoop2 ) INPUT_PORTS_END +static const gfx_layout thoop2_tilelayout = +{ + 8,8, /* 8x8 tiles */ + 0x400000/16, /* number of tiles */ + 4, /* 4 bpp */ + { 0*0x400000*8+8, 0*0x400000*8, 1*0x400000*8+8, 1*0x400000*8 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 }, + 16*8 +}; + +static const gfx_layout thoop2_tilelayout_16 = +{ + 16,16, /* 16x16 tiles */ + 0x400000/64, /* number of tiles */ + 4, /* 4 bpp */ + { 0*0x400000*8+8, 0*0x400000*8, 1*0x400000*8+8, 1*0x400000*8 }, + { 0, 1, 2, 3, 4, 5, 6, 7, + 16*16+0, 16*16+1, 16*16+2, 16*16+3, 16*16+4, 16*16+5, 16*16+6, 16*16+7 }, + { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, + 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, + 64*8 +}; + + +static GFXDECODE_START( thoop2 ) + GFXDECODE_ENTRY( "gfx1", 0x000000, thoop2_tilelayout, 0, 64 ) + GFXDECODE_ENTRY( "gfx1", 0x000000, thoop2_tilelayout_16, 0, 64 ) +GFXDECODE_END + + static MACHINE_CONFIG_START( thoop2, thoop2_state ) /* basic machine hardware */ @@ -201,7 +211,7 @@ static MACHINE_CONFIG_START( thoop2, thoop2_state ) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) MCFG_SCREEN_SIZE(32*16, 32*16) MCFG_SCREEN_VISIBLE_AREA(0, 320-1, 16, 256-1) - MCFG_SCREEN_UPDATE_DRIVER(thoop2_state, screen_update_thoop2) + MCFG_SCREEN_UPDATE_DRIVER(thoop2_state, screen_update) MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", thoop2) @@ -212,6 +222,7 @@ static MACHINE_CONFIG_START( thoop2, thoop2_state ) MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified + MCFG_DEVICE_ADDRESS_MAP(AS_0, oki_map) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END @@ -228,10 +239,9 @@ ROM_START( thoop2 ) ROM_LOAD( "th2-h8.32m", 0x000000, 0x400000, CRC(60328a11) SHA1(fcdb374d2fc7ef5351a4181c471d192199dc2081) ) ROM_LOAD( "th2-h12.32m", 0x400000, 0x400000, CRC(b25c2d3e) SHA1(d70f3e4e2432d80c2ac87cd81208ada303bac04a) ) - ROM_REGION( 0x140000, "oki", 0 ) /* ADPCM samples - sound chip is OKIM6295 */ + ROM_REGION( 0x100000, "oki", 0 ) /* ADPCM samples - sound chip is OKIM6295 */ ROM_LOAD( "th2-c1.080", 0x000000, 0x100000, CRC(8fac8c30) SHA1(8e49bb596144761eae95f3e1266e57fb386664f2) ) - ROM_RELOAD( 0x040000, 0x100000 ) /* 0x00000-0x2ffff is fixed, 0x30000-0x3ffff is bank switched */ ROM_END -GAME( 1994, thoop2, 0, thoop2, thoop2, driver_device, 0, ROT0, "Gaelco", "TH Strikes Back", MACHINE_UNEMULATED_PROTECTION | MACHINE_NOT_WORKING ) +GAME( 1994, thoop2, 0, thoop2, thoop2, driver_device, 0, ROT0, "Gaelco", "TH Strikes Back", MACHINE_UNEMULATED_PROTECTION | MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/thoop2.h b/src/mame/includes/thoop2.h index 066f4ffbde2..5ff44c9c3b6 100644 --- a/src/mame/includes/thoop2.h +++ b/src/mame/includes/thoop2.h @@ -5,30 +5,36 @@ class thoop2_state : public driver_device public: thoop2_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_videoram(*this, "videoram"), - m_vregs(*this, "vregs"), - m_spriteram(*this, "spriteram"), m_maincpu(*this, "maincpu"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") { } + m_palette(*this, "palette"), + m_videoram(*this, "videoram"), + m_vregs(*this, "vregs"), + m_spriteram(*this, "spriteram") { } + + required_device m_maincpu; + required_device m_gfxdecode; + required_device m_palette; required_shared_ptr m_videoram; required_shared_ptr m_vregs; required_shared_ptr m_spriteram; + int m_sprite_count[5]; std::unique_ptr m_sprite_table[5]; tilemap_t *m_pant[2]; + DECLARE_WRITE16_MEMBER(OKIM6295_bankswitch_w); - DECLARE_WRITE16_MEMBER(thoop2_coin_w); + DECLARE_WRITE16_MEMBER(coin_w); DECLARE_READ16_MEMBER(DS5002FP_R); - DECLARE_WRITE16_MEMBER(thoop2_vram_w); - TILE_GET_INFO_MEMBER(get_tile_info_thoop2_screen0); - TILE_GET_INFO_MEMBER(get_tile_info_thoop2_screen1); + DECLARE_WRITE16_MEMBER(vram_w); + + virtual void machine_start() override; virtual void video_start() override; - UINT32 screen_update_thoop2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void thoop2_sort_sprites(); + + TILE_GET_INFO_MEMBER(get_tile_info_screen0); + TILE_GET_INFO_MEMBER(get_tile_info_screen1); + UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void sort_sprites(); void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri); - required_device m_maincpu; - required_device m_gfxdecode; - required_device m_palette; }; diff --git a/src/mame/video/thoop2.cpp b/src/mame/video/thoop2.cpp index e2b826941c5..91b87645583 100644 --- a/src/mame/video/thoop2.cpp +++ b/src/mame/video/thoop2.cpp @@ -38,7 +38,7 @@ 1 | x------- -------- | flip y */ -TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info_thoop2_screen0) +TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info_screen0) { int data = m_videoram[tile_index << 1]; int data2 = m_videoram[(tile_index << 1) + 1]; @@ -50,7 +50,7 @@ TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info_thoop2_screen0) } -TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info_thoop2_screen1) +TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info_screen1) { int data = m_videoram[(0x1000/2) + (tile_index << 1)]; int data2 = m_videoram[(0x1000/2) + (tile_index << 1) + 1]; @@ -67,7 +67,7 @@ TILE_GET_INFO_MEMBER(thoop2_state::get_tile_info_thoop2_screen1) ***************************************************************************/ -WRITE16_MEMBER(thoop2_state::thoop2_vram_w) +WRITE16_MEMBER(thoop2_state::vram_w) { COMBINE_DATA(&m_videoram[offset]); m_pant[offset >> 11]->mark_tile_dirty(((offset << 1) & 0x0fff) >> 2); @@ -81,17 +81,18 @@ WRITE16_MEMBER(thoop2_state::thoop2_vram_w) void thoop2_state::video_start() { - int i; - - m_pant[0] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(thoop2_state::get_tile_info_thoop2_screen0),this),TILEMAP_SCAN_ROWS,16,16,32,32); - m_pant[1] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(thoop2_state::get_tile_info_thoop2_screen1),this),TILEMAP_SCAN_ROWS,16,16,32,32); + m_pant[0] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(thoop2_state::get_tile_info_screen0),this),TILEMAP_SCAN_ROWS,16,16,32,32); + m_pant[1] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(thoop2_state::get_tile_info_screen1),this),TILEMAP_SCAN_ROWS,16,16,32,32); m_pant[0]->set_transmask(0,0xff01,0x00ff); /* pens 1-7 opaque, pens 0, 8-15 transparent */ m_pant[1]->set_transmask(0,0xff01,0x00ff); /* pens 1-7 opaque, pens 0, 8-15 transparent */ - for (i = 0; i < 5; i++){ + for (int i = 0; i < 5; i++){ m_sprite_table[i] = std::make_unique(512); + save_pointer(NAME(m_sprite_table[i].get()), 512, i); } + + save_item(NAME(m_sprite_count)); } /*************************************************************************** @@ -100,17 +101,15 @@ void thoop2_state::video_start() ***************************************************************************/ -void thoop2_state::thoop2_sort_sprites() +void thoop2_state::sort_sprites() { - int i; - m_sprite_count[0] = 0; m_sprite_count[1] = 0; m_sprite_count[2] = 0; m_sprite_count[3] = 0; m_sprite_count[4] = 0; - for (i = 3; i < (0x1000 - 6)/2; i += 4){ + for (int i = 3; i < (0x1000 - 6)/2; i += 4){ int color = (m_spriteram[i+2] & 0x7e00) >> 9; int priority = (m_spriteram[i] & 0x3000) >> 12; @@ -194,7 +193,7 @@ void thoop2_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, ***************************************************************************/ -UINT32 thoop2_state::screen_update_thoop2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +UINT32 thoop2_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { /* set scroll registers */ m_pant[0]->set_scrolly(0, m_vregs[0]); @@ -202,7 +201,7 @@ UINT32 thoop2_state::screen_update_thoop2(screen_device &screen, bitmap_ind16 &b m_pant[1]->set_scrolly(0, m_vregs[2]); m_pant[1]->set_scrollx(0, m_vregs[3]); - thoop2_sort_sprites(); + sort_sprites(); bitmap.fill(0, cliprect );