hvyunit.c: added save state support, moved to configured banking (nw)

This commit is contained in:
Ivan Vangelista 2015-05-08 18:13:37 +02:00
parent 1d12e0e909
commit dae60116d6

View File

@ -78,17 +78,26 @@ class hvyunit_state : public driver_device
public: public:
hvyunit_state(const machine_config &mconfig, device_type type, const char *tag) hvyunit_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag), : driver_device(mconfig, type, tag),
m_videoram(*this, "videoram"),
m_colorram(*this, "colorram"),
m_mastercpu(*this, "master"), m_mastercpu(*this, "master"),
m_slavecpu(*this, "slave"), m_slavecpu(*this, "slave"),
m_mermaid(*this, "mermaid"), m_mermaid(*this, "mermaid"),
m_soundcpu(*this, "soundcpu"), m_soundcpu(*this, "soundcpu"),
m_pandora(*this, "pandora"), m_pandora(*this, "pandora"),
m_gfxdecode(*this, "gfxdecode"), m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette") m_palette(*this, "palette"),
m_videoram(*this, "videoram"),
m_colorram(*this, "colorram")
{ } { }
/* Devices */
required_device<cpu_device> m_mastercpu;
required_device<cpu_device> m_slavecpu;
required_device<cpu_device> m_mermaid;
required_device<cpu_device> m_soundcpu;
required_device<kaneko_pandora_device> m_pandora;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
/* Video */ /* Video */
required_shared_ptr<UINT8> m_videoram; required_shared_ptr<UINT8> m_videoram;
required_shared_ptr<UINT8> m_colorram; required_shared_ptr<UINT8> m_colorram;
@ -105,15 +114,6 @@ public:
UINT8 m_mermaid_int0_l; UINT8 m_mermaid_int0_l;
UINT8 m_mermaid_p[4]; UINT8 m_mermaid_p[4];
/* Devices */
required_device<cpu_device> m_mastercpu;
required_device<cpu_device> m_slavecpu;
required_device<cpu_device> m_mermaid;
required_device<cpu_device> m_soundcpu;
required_device<kaneko_pandora_device> m_pandora;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
DECLARE_WRITE8_MEMBER(trigger_nmi_on_slave_cpu); DECLARE_WRITE8_MEMBER(trigger_nmi_on_slave_cpu);
DECLARE_WRITE8_MEMBER(master_bankswitch_w); DECLARE_WRITE8_MEMBER(master_bankswitch_w);
DECLARE_WRITE8_MEMBER(mermaid_data_w); DECLARE_WRITE8_MEMBER(mermaid_data_w);
@ -135,13 +135,17 @@ public:
DECLARE_WRITE8_MEMBER(mermaid_p2_w); DECLARE_WRITE8_MEMBER(mermaid_p2_w);
DECLARE_READ8_MEMBER(mermaid_p3_r); DECLARE_READ8_MEMBER(mermaid_p3_r);
DECLARE_WRITE8_MEMBER(mermaid_p3_w); DECLARE_WRITE8_MEMBER(mermaid_p3_w);
TILE_GET_INFO_MEMBER(get_bg_tile_info); TILE_GET_INFO_MEMBER(get_bg_tile_info);
virtual void machine_start(); virtual void machine_start();
virtual void machine_reset(); virtual void machine_reset();
virtual void video_start(); virtual void video_start();
UINT32 screen_update_hvyunit(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void screen_eof_hvyunit(screen_device &screen, bool state); UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
TIMER_DEVICE_CALLBACK_MEMBER(hvyunit_scanline); void screen_eof(screen_device &screen, bool state);
TIMER_DEVICE_CALLBACK_MEMBER(scanline);
}; };
@ -153,7 +157,16 @@ public:
void hvyunit_state::machine_start() void hvyunit_state::machine_start()
{ {
// TODO: Save state membank("master_bank")->configure_entries(0, 8, memregion("master")->base(), 0x4000);
membank("slave_bank")->configure_entries(0, 4, memregion("slave")->base(), 0x4000);
membank("sound_bank")->configure_entries(0, 4, memregion("soundcpu")->base(), 0x4000);
save_item(NAME(m_data_to_mermaid));
save_item(NAME(m_data_to_z80));
save_item(NAME(m_mermaid_to_z80_full));
save_item(NAME(m_z80_to_mermaid_full));
save_item(NAME(m_mermaid_int0_l));
save_item(NAME(m_mermaid_p));
} }
void hvyunit_state::machine_reset() void hvyunit_state::machine_reset()
@ -182,9 +195,13 @@ TILE_GET_INFO_MEMBER(hvyunit_state::get_bg_tile_info)
void hvyunit_state::video_start() void hvyunit_state::video_start()
{ {
m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hvyunit_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(hvyunit_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
save_item(NAME(m_scrollx));
save_item(NAME(m_scrolly));
save_item(NAME(m_port0_data));
} }
UINT32 hvyunit_state::screen_update_hvyunit(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) UINT32 hvyunit_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{ {
#define SX_POS 96 #define SX_POS 96
#define SY_POS 0 #define SY_POS 0
@ -198,7 +215,7 @@ UINT32 hvyunit_state::screen_update_hvyunit(screen_device &screen, bitmap_ind16
return 0; return 0;
} }
void hvyunit_state::screen_eof_hvyunit(screen_device &screen, bool state) void hvyunit_state::screen_eof(screen_device &screen, bool state)
{ {
// rising edge // rising edge
if (state) if (state)
@ -221,10 +238,7 @@ WRITE8_MEMBER(hvyunit_state::trigger_nmi_on_slave_cpu)
WRITE8_MEMBER(hvyunit_state::master_bankswitch_w) WRITE8_MEMBER(hvyunit_state::master_bankswitch_w)
{ {
unsigned char *ROM = memregion("master")->base(); membank("master_bank")->set_entry(data & 7);
int bank = data & 7;
ROM = &ROM[0x4000 * bank];
membank("bank1")->set_base(ROM);
} }
WRITE8_MEMBER(hvyunit_state::mermaid_data_w) WRITE8_MEMBER(hvyunit_state::mermaid_data_w)
@ -273,12 +287,8 @@ WRITE8_MEMBER(hvyunit_state::hu_colorram_w)
WRITE8_MEMBER(hvyunit_state::slave_bankswitch_w) WRITE8_MEMBER(hvyunit_state::slave_bankswitch_w)
{ {
unsigned char *ROM = memregion("slave")->base();
int bank = (data & 0x03);
m_port0_data = data; m_port0_data = data;
ROM = &ROM[0x4000 * bank]; membank("slave_bank")->set_entry(data & 3);
membank("bank2")->set_base(ROM);
} }
WRITE8_MEMBER(hvyunit_state::hu_scrollx_w) WRITE8_MEMBER(hvyunit_state::hu_scrollx_w)
@ -306,11 +316,7 @@ WRITE8_MEMBER(hvyunit_state::coin_count_w)
WRITE8_MEMBER(hvyunit_state::sound_bankswitch_w) WRITE8_MEMBER(hvyunit_state::sound_bankswitch_w)
{ {
unsigned char *ROM = memregion("soundcpu")->base(); membank("sound_bank")->set_entry(data & 3);
int bank = data & 0x3;
ROM = &ROM[0x4000 * bank];
membank("bank3")->set_base(ROM);
} }
@ -407,7 +413,7 @@ WRITE8_MEMBER(hvyunit_state::mermaid_p3_w)
static ADDRESS_MAP_START( master_memory, AS_PROGRAM, 8, hvyunit_state ) static ADDRESS_MAP_START( master_memory, AS_PROGRAM, 8, hvyunit_state )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("master_bank")
AM_RANGE(0xc000, 0xcfff) AM_DEVREADWRITE("pandora", kaneko_pandora_device, spriteram_r, spriteram_w) AM_RANGE(0xc000, 0xcfff) AM_DEVREADWRITE("pandora", kaneko_pandora_device, spriteram_r, spriteram_w)
AM_RANGE(0xd000, 0xdfff) AM_RAM AM_RANGE(0xd000, 0xdfff) AM_RAM
AM_RANGE(0xe000, 0xffff) AM_RAM AM_SHARE("share1") AM_RANGE(0xe000, 0xffff) AM_RAM AM_SHARE("share1")
@ -423,7 +429,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( slave_memory, AS_PROGRAM, 8, hvyunit_state ) static ADDRESS_MAP_START( slave_memory, AS_PROGRAM, 8, hvyunit_state )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank2") AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("slave_bank")
AM_RANGE(0xc000, 0xc3ff) AM_RAM_WRITE(hu_videoram_w) AM_SHARE("videoram") AM_RANGE(0xc000, 0xc3ff) AM_RAM_WRITE(hu_videoram_w) AM_SHARE("videoram")
AM_RANGE(0xc400, 0xc7ff) AM_RAM_WRITE(hu_colorram_w) AM_SHARE("colorram") AM_RANGE(0xc400, 0xc7ff) AM_RAM_WRITE(hu_colorram_w) AM_SHARE("colorram")
AM_RANGE(0xd000, 0xd1ff) AM_RAM_DEVWRITE("palette", palette_device, write_ext) AM_SHARE("palette_ext") AM_RANGE(0xd000, 0xd1ff) AM_RAM_DEVWRITE("palette", palette_device, write_ext) AM_SHARE("palette_ext")
@ -449,7 +455,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( sound_memory, AS_PROGRAM, 8, hvyunit_state ) static ADDRESS_MAP_START( sound_memory, AS_PROGRAM, 8, hvyunit_state )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank3") AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("sound_bank")
AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_RANGE(0xc000, 0xc7ff) AM_RAM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -615,7 +621,7 @@ GFXDECODE_END
*************************************/ *************************************/
/* Main Z80 uses IM2 */ /* Main Z80 uses IM2 */
TIMER_DEVICE_CALLBACK_MEMBER(hvyunit_state::hvyunit_scanline) TIMER_DEVICE_CALLBACK_MEMBER(hvyunit_state::scanline)
{ {
int scanline = param; int scanline = param;
@ -638,7 +644,7 @@ static MACHINE_CONFIG_START( hvyunit, hvyunit_state )
MCFG_CPU_ADD("master", Z80, 6000000) MCFG_CPU_ADD("master", Z80, 6000000)
MCFG_CPU_PROGRAM_MAP(master_memory) MCFG_CPU_PROGRAM_MAP(master_memory)
MCFG_CPU_IO_MAP(master_io) MCFG_CPU_IO_MAP(master_io)
MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", hvyunit_state, hvyunit_scanline, "screen", 0, 1) MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", hvyunit_state, scanline, "screen", 0, 1)
MCFG_CPU_ADD("slave", Z80, 6000000) MCFG_CPU_ADD("slave", Z80, 6000000)
MCFG_CPU_PROGRAM_MAP(slave_memory) MCFG_CPU_PROGRAM_MAP(slave_memory)
@ -660,8 +666,8 @@ static MACHINE_CONFIG_START( hvyunit, hvyunit_state )
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
MCFG_SCREEN_SIZE(256, 256) MCFG_SCREEN_SIZE(256, 256)
MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 16, 240-1) MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 16, 240-1)
MCFG_SCREEN_UPDATE_DRIVER(hvyunit_state, screen_update_hvyunit) MCFG_SCREEN_UPDATE_DRIVER(hvyunit_state, screen_update)
MCFG_SCREEN_VBLANK_DRIVER(hvyunit_state, screen_eof_hvyunit) MCFG_SCREEN_VBLANK_DRIVER(hvyunit_state, screen_eof)
MCFG_SCREEN_PALETTE("palette") MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", hvyunit) MCFG_GFXDECODE_ADD("gfxdecode", "palette", hvyunit)
@ -803,7 +809,7 @@ ROM_END
* *
*************************************/ *************************************/
GAME( 1988, hvyunit, 0, hvyunit, hvyunit, driver_device, 0, ROT0, "Kaneko / Taito", "Heavy Unit (World)", GAME_NO_COCKTAIL ) GAME( 1988, hvyunit, 0, hvyunit, hvyunit, driver_device, 0, ROT0, "Kaneko / Taito", "Heavy Unit (World)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1988, hvyunitj, hvyunit, hvyunit, hvyunitj, driver_device, 0, ROT0, "Kaneko / Taito", "Heavy Unit (Japan, Newer)", GAME_NO_COCKTAIL ) GAME( 1988, hvyunitj, hvyunit, hvyunit, hvyunitj, driver_device, 0, ROT0, "Kaneko / Taito", "Heavy Unit (Japan, Newer)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1988, hvyunitjo,hvyunit, hvyunit, hvyunitj, driver_device, 0, ROT0, "Kaneko / Taito", "Heavy Unit (Japan, Older)", GAME_NO_COCKTAIL ) GAME( 1988, hvyunitjo,hvyunit, hvyunit, hvyunitj, driver_device, 0, ROT0, "Kaneko / Taito", "Heavy Unit (Japan, Older)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1988, hvyunitu, hvyunit, hvyunit, hvyunitj, driver_device, 0, ROT0, "Kaneko / Taito", "Heavy Unit -U.S.A. Version- (US)", GAME_NO_COCKTAIL ) GAME( 1988, hvyunitu, hvyunit, hvyunit, hvyunitj, driver_device, 0, ROT0, "Kaneko / Taito", "Heavy Unit -U.S.A. Version- (US)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )