From f52cce362748d08ed5c9d7fafe4689b9fef6bae9 Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Sun, 24 Apr 2011 17:05:04 +0000 Subject: [PATCH] Implemented irq ack mechanism and fixed CPU clock speeds in Cop 01 and Mighty Guy, this fixes last boss crashes in Mighty Guy [Angelo Salese] new working game ---------------- Mighty Guy [Angelo Salese] --- src/mame/drivers/cop01.c | 42 +++++++++++++++++++++++++++------------ src/mame/includes/cop01.h | 1 + 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/mame/drivers/cop01.c b/src/mame/drivers/cop01.c index 604d71b09df..f26386f3586 100644 --- a/src/mame/drivers/cop01.c +++ b/src/mame/drivers/cop01.c @@ -8,7 +8,6 @@ driver by Carlos A. Lozano TODO: ---- mightguy: -- crashes during the confrontation with the final boss (only tested with Invincibility on) - missing emulation of the 1412M2 protection chip, used by the sound CPU. @@ -59,6 +58,8 @@ Mighty Guy board layout: #define MIGHTGUY_HACK 0 #define TIMER_RATE 12000 /* total guess */ +#define MAINCPU_CLOCK XTAL_12MHz +#define AUDIOCPU_CLOCK XTAL_8MHz /************************************* * @@ -70,7 +71,7 @@ static WRITE8_HANDLER( cop01_sound_command_w ) { cop01_state *state = space->machine().driver_data(); soundlatch_w(space, offset, data); - device_set_input_line_and_vector(state->m_audiocpu, 0, HOLD_LINE, 0xff); + device_set_input_line(state->m_audiocpu, 0, ASSERT_LINE ); } static READ8_HANDLER( cop01_sound_command_r ) @@ -99,6 +100,20 @@ static CUSTOM_INPUT( mightguy_area_r ) return (input_port_read(field->port->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00; } +static WRITE8_HANDLER( cop01_irq_ack_w ) +{ + cop01_state *state = space->machine().driver_data(); + + device_set_input_line(state->m_maincpu, 0, CLEAR_LINE ); +} + +static READ8_HANDLER( cop01_sound_irq_ack_w ) +{ + cop01_state *state = space->machine().driver_data(); + + device_set_input_line(state->m_audiocpu, 0, CLEAR_LINE ); + return 0; +} /************************************* * @@ -123,7 +138,7 @@ static ADDRESS_MAP_START( io_map, AS_IO, 8 ) AM_RANGE(0x04, 0x04) AM_READ_PORT("DSW2") AM_RANGE(0x40, 0x43) AM_WRITE(cop01_vreg_w) AM_RANGE(0x44, 0x44) AM_WRITE(cop01_sound_command_w) - AM_RANGE(0x45, 0x45) AM_WRITE(watchdog_reset_w) /* ? */ + AM_RANGE(0x45, 0x45) AM_WRITE(cop01_irq_ack_w) /* ? */ ADDRESS_MAP_END static ADDRESS_MAP_START( mightguy_io_map, AS_IO, 8 ) @@ -135,12 +150,12 @@ static ADDRESS_MAP_START( mightguy_io_map, AS_IO, 8 ) AM_RANGE(0x04, 0x04) AM_READ_PORT("DSW2") AM_RANGE(0x40, 0x43) AM_WRITE(cop01_vreg_w) AM_RANGE(0x44, 0x44) AM_WRITE(cop01_sound_command_w) - AM_RANGE(0x45, 0x45) AM_WRITE(watchdog_reset_w) /* ? */ + AM_RANGE(0x45, 0x45) AM_WRITE(cop01_irq_ack_w) /* ? */ ADDRESS_MAP_END static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM - AM_RANGE(0x8000, 0x8000) AM_READNOP /* irq ack? */ + AM_RANGE(0x8000, 0x8000) AM_READ(cop01_sound_irq_ack_w) AM_RANGE(0xc000, 0xc7ff) AM_RAM ADDRESS_MAP_END @@ -416,6 +431,7 @@ static MACHINE_START( cop01 ) { cop01_state *state = machine.driver_data(); + state->m_maincpu = machine.device("maincpu"); state->m_audiocpu = machine.device("audiocpu"); state->save_item(NAME(state->m_pulse)); @@ -439,12 +455,12 @@ static MACHINE_RESET( cop01 ) static MACHINE_CONFIG_START( cop01, cop01_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80, 4000000) /* ???? */ + MCFG_CPU_ADD("maincpu", Z80, MAINCPU_CLOCK/2) /* unknown divider */ MCFG_CPU_PROGRAM_MAP(cop01_map) MCFG_CPU_IO_MAP(io_map) - MCFG_CPU_VBLANK_INT("screen", irq0_line_hold) + MCFG_CPU_VBLANK_INT("screen", irq0_line_assert) - MCFG_CPU_ADD("audiocpu", Z80, 3000000) /* ???? */ + MCFG_CPU_ADD("audiocpu", Z80, AUDIOCPU_CLOCK/4) /* unknown divider */ MCFG_CPU_PROGRAM_MAP(sound_map) MCFG_CPU_IO_MAP(audio_io_map) @@ -482,12 +498,12 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_START( mightguy, cop01_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80, 4000000) /* ???? */ + MCFG_CPU_ADD("maincpu", Z80, MAINCPU_CLOCK/2) /* unknown divider */ MCFG_CPU_PROGRAM_MAP(cop01_map) MCFG_CPU_IO_MAP(mightguy_io_map) - MCFG_CPU_VBLANK_INT("screen", irq0_line_hold) + MCFG_CPU_VBLANK_INT("screen", irq0_line_assert) - MCFG_CPU_ADD("audiocpu", Z80, 3000000) /* ???? */ + MCFG_CPU_ADD("audiocpu", Z80, AUDIOCPU_CLOCK/4) /* unknown divider */ MCFG_CPU_PROGRAM_MAP(sound_map) MCFG_CPU_IO_MAP(mightguy_audio_io_map) @@ -512,7 +528,7 @@ static MACHINE_CONFIG_START( mightguy, cop01_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("ymsnd", YM3526, 4000000) + MCFG_SOUND_ADD("ymsnd", YM3526, AUDIOCPU_CLOCK/2) /* unknown divider */ MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END @@ -660,4 +676,4 @@ static DRIVER_INIT( mightguy ) GAME( 1985, cop01, 0, cop01, cop01, 0, ROT0, "Nichibutsu", "Cop 01 (set 1)", GAME_SUPPORTS_SAVE ) GAME( 1985, cop01a, cop01, cop01, cop01, 0, ROT0, "Nichibutsu", "Cop 01 (set 2)", GAME_SUPPORTS_SAVE ) -GAME( 1986, mightguy, 0, mightguy, mightguy, mightguy, ROT270, "Nichibutsu", "Mighty Guy", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1986, mightguy, 0, mightguy, mightguy, mightguy, ROT270, "Nichibutsu", "Mighty Guy", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/cop01.h b/src/mame/includes/cop01.h index 56a057f3790..5e01824ca52 100644 --- a/src/mame/includes/cop01.h +++ b/src/mame/includes/cop01.h @@ -26,6 +26,7 @@ public: int m_timer; // kludge for ym3526 in mightguy /* devices */ + cpu_device *m_maincpu; cpu_device *m_audiocpu; };