From 969616a04315489baf21edc48d275028fe5b96ce Mon Sep 17 00:00:00 2001 From: Osso Date: Sat, 20 Dec 2014 08:23:37 +0100 Subject: [PATCH] asteroid.c: fixed save state problem for astdelux1 (nw) --- src/mame/drivers/asteroid.c | 12 +++++++---- src/mame/includes/asteroid.h | 41 ++++++++++++++++++++++++------------ src/mame/machine/asteroid.c | 10 ++++++--- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/mame/drivers/asteroid.c b/src/mame/drivers/asteroid.c index 1921c768ea2..7009823ce1e 100644 --- a/src/mame/drivers/asteroid.c +++ b/src/mame/drivers/asteroid.c @@ -1013,7 +1013,11 @@ DRIVER_INIT_MEMBER(asteroid_state,asterock) m_maincpu->space(AS_PROGRAM).install_read_handler(0x2000, 0x2007, read8_delegate(FUNC(asteroid_state::asterock_IN0_r),this)); } - +DRIVER_INIT_MEMBER(asteroid_state,astdelux) +{ + save_item(NAME(m_astdelux_bankswitch)); + machine().save().register_postload(save_prepost_delegate(FUNC(asteroid_state::astdelux_bankswitch_restore), this)); +} /************************************* * @@ -1032,9 +1036,9 @@ GAME( 1979, meteorts, asteroid, asteroid, asteroid, driver_device, 0, GAME( 1979, meteorho, asteroid, asteroid, asteroid, driver_device, 0, ROT0, "bootleg (Hoei)", "Meteor (bootleg of Asteroids)", GAME_SUPPORTS_SAVE ) GAME( 1979, hyperspc, asteroid, asteroid, asteroid, driver_device, 0, ROT0, "bootleg (Rumiano)", "Hyperspace (bootleg of Asteroids)", GAME_SUPPORTS_SAVE ) -GAMEL(1980, astdelux, 0, astdelux, astdelux, driver_device, 0, ROT0, "Atari", "Asteroids Deluxe (rev 3)", GAME_SUPPORTS_SAVE, layout_astdelux ) -GAMEL(1980, astdelux2, astdelux, astdelux, astdelux, driver_device, 0, ROT0, "Atari", "Asteroids Deluxe (rev 2)", GAME_SUPPORTS_SAVE, layout_astdelux ) -GAMEL(1980, astdelux1, astdelux, astdelux, astdelux, driver_device, 0, ROT0, "Atari", "Asteroids Deluxe (rev 1)", GAME_SUPPORTS_SAVE, layout_astdelux ) +GAMEL(1980, astdelux, 0, astdelux, astdelux, asteroid_state, astdelux, ROT0, "Atari", "Asteroids Deluxe (rev 3)", GAME_SUPPORTS_SAVE, layout_astdelux ) +GAMEL(1980, astdelux2, astdelux, astdelux, astdelux, asteroid_state, astdelux, ROT0, "Atari", "Asteroids Deluxe (rev 2)", GAME_SUPPORTS_SAVE, layout_astdelux ) +GAMEL(1980, astdelux1, astdelux, astdelux, astdelux, asteroid_state, astdelux, ROT0, "Atari", "Asteroids Deluxe (rev 1)", GAME_SUPPORTS_SAVE, layout_astdelux ) GAME( 1979, llander, 0, llander, llander, driver_device, 0, ROT0, "Atari", "Lunar Lander (rev 2)", GAME_SUPPORTS_SAVE ) GAME( 1979, llander1, llander, llander, llander1, driver_device, 0, ROT0, "Atari", "Lunar Lander (rev 1)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/asteroid.h b/src/mame/includes/asteroid.h index 63a70f268fc..a19c6a1a7a6 100644 --- a/src/mame/includes/asteroid.h +++ b/src/mame/includes/asteroid.h @@ -12,15 +12,25 @@ class asteroid_state : public driver_device public: asteroid_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_ram1(*this, "ram1"), - m_ram2(*this, "ram2"), - m_discrete(*this, "discrete") , m_maincpu(*this, "maincpu"), - m_dvg(*this, "dvg") { } + m_dvg(*this, "dvg"), + m_discrete(*this, "discrete"), + m_ram1(*this, "ram1"), + m_ram2(*this, "ram2") { } + /* devices */ + required_device m_maincpu; + required_device m_dvg; + required_device m_discrete; + + /* memory pointers */ optional_shared_ptr m_ram1; optional_shared_ptr m_ram2; - required_device m_discrete; + + int m_astdelux_bankswitch; // for postload + + void astdelux_bankswitch_restore(); + DECLARE_WRITE8_MEMBER(astdelux_coin_counter_w); DECLARE_WRITE8_MEMBER(llander_led_w); DECLARE_READ8_MEMBER(asteroid_IN0_r); @@ -30,13 +40,6 @@ public: DECLARE_WRITE8_MEMBER(asteroid_bank_switch_w); DECLARE_WRITE8_MEMBER(astdelux_bank_switch_w); DECLARE_WRITE8_MEMBER(astdelux_led_w); - DECLARE_CUSTOM_INPUT_MEMBER(clock_r); - DECLARE_DRIVER_INIT(asterock); - DECLARE_DRIVER_INIT(asteroidb); - virtual void machine_reset(); - INTERRUPT_GEN_MEMBER(asteroid_interrupt); - INTERRUPT_GEN_MEMBER(asterock_interrupt); - INTERRUPT_GEN_MEMBER(llander_interrupt); DECLARE_WRITE8_MEMBER(asteroid_explode_w); DECLARE_WRITE8_MEMBER(asteroid_thump_w); DECLARE_WRITE8_MEMBER(asteroid_sounds_w); @@ -44,9 +47,19 @@ public: DECLARE_WRITE8_MEMBER(asteroid_noise_reset_w); DECLARE_WRITE8_MEMBER(llander_snd_reset_w); DECLARE_WRITE8_MEMBER(llander_sounds_w); + + DECLARE_CUSTOM_INPUT_MEMBER(clock_r); + + INTERRUPT_GEN_MEMBER(asteroid_interrupt); + INTERRUPT_GEN_MEMBER(asterock_interrupt); + INTERRUPT_GEN_MEMBER(llander_interrupt); + + DECLARE_DRIVER_INIT(asterock); + DECLARE_DRIVER_INIT(asteroidb); + DECLARE_DRIVER_INIT(astdelux); + + virtual void machine_reset(); DECLARE_MACHINE_RESET(llander); - required_device m_maincpu; - required_device m_dvg; }; /*----------- defined in audio/asteroid.c -----------*/ diff --git a/src/mame/machine/asteroid.c b/src/mame/machine/asteroid.c index 3476410521c..a485d1f66bc 100644 --- a/src/mame/machine/asteroid.c +++ b/src/mame/machine/asteroid.c @@ -112,7 +112,13 @@ WRITE8_MEMBER(asteroid_state::asteroid_bank_switch_w) WRITE8_MEMBER(asteroid_state::astdelux_bank_switch_w) { - if (data & 0x80) + m_astdelux_bankswitch = data; + astdelux_bankswitch_restore(); +} + +void asteroid_state::astdelux_bankswitch_restore() +{ + if (m_astdelux_bankswitch & 0x80) { membank("bank1")->set_base(m_ram2); membank("bank2")->set_base(m_ram1); @@ -124,13 +130,11 @@ WRITE8_MEMBER(asteroid_state::astdelux_bank_switch_w) } } - WRITE8_MEMBER(asteroid_state::astdelux_led_w) { set_led_status(machine(), offset, (data & 0x80) ? 0 : 1); } - void asteroid_state::machine_reset() { asteroid_bank_switch_w(m_maincpu->space(AS_PROGRAM), 0, 0);