From d1f79a39b3c85cf29357bc3b7ded89900563ea44 Mon Sep 17 00:00:00 2001 From: Robbbert Date: Thu, 23 Aug 2018 00:43:21 +1000 Subject: [PATCH] cvs : - huncholy,superbik,hero : simulate protection instead of patching it out [iq_132, Robbbert] - proper privacy of functions --- src/mame/drivers/cvs.cpp | 113 ++++++++++++++++------------------- src/mame/drivers/galaxia.cpp | 4 +- src/mame/includes/cvs.h | 22 ++++--- 3 files changed, 67 insertions(+), 72 deletions(-) diff --git a/src/mame/drivers/cvs.cpp b/src/mame/drivers/cvs.cpp index 8c376d0ffaf..cb8ae39a1b7 100644 --- a/src/mame/drivers/cvs.cpp +++ b/src/mame/drivers/cvs.cpp @@ -1549,23 +1549,21 @@ ROM_END * *************************************/ +READ8_MEMBER(cvs_state::huncholy_prot_r) +{ + if (offset == 1) + { + m_protection_counter++; + if ((m_protection_counter & 0x0f) == 0x01) return 0x00; + return 0xff; + } + + return 0; // offset 0 +} + void cvs_state::init_huncholy() { - uint8_t *ROM = memregion("maincpu")->base(); - - /* patch out protection */ - ROM[0x0082] = 0xc0; - ROM[0x0083] = 0xc0; - ROM[0x0084] = 0xc0; - ROM[0x00b7] = 0xc0; - ROM[0x00b8] = 0xc0; - ROM[0x00b9] = 0xc0; - ROM[0x00d9] = 0xc0; - ROM[0x00da] = 0xc0; - ROM[0x00db] = 0xc0; - ROM[0x4456] = 0xc0; - ROM[0x4457] = 0xc0; - ROM[0x4458] = 0xc0; + m_maincpu->space(AS_PROGRAM).install_read_handler(0x6ff1, 0x6ff2, read8_delegate(FUNC(cvs_state::huncholy_prot_r),this)); } @@ -1578,57 +1576,48 @@ void cvs_state::init_hunchbaka() } +READ8_MEMBER(cvs_state::superbik_prot_r) +{ + m_protection_counter++; + if ((m_protection_counter & 0x0f) == 0x02) return 0; + return 0xff; +} + void cvs_state::init_superbik() { - uint8_t *ROM = memregion("maincpu")->base(); - - /* patch out protection */ - ROM[0x0079] = 0xc0; - ROM[0x007a] = 0xc0; - ROM[0x007b] = 0xc0; - ROM[0x0081] = 0xc0; - ROM[0x0082] = 0xc0; - ROM[0x0083] = 0xc0; - ROM[0x00b6] = 0xc0; - ROM[0x00b7] = 0xc0; - ROM[0x00b8] = 0xc0; - ROM[0x0168] = 0xc0; - ROM[0x0169] = 0xc0; - ROM[0x016a] = 0xc0; - - ROM[0x413f] = 0xc0; - ROM[0x4140] = 0xc0; - ROM[0x4141] = 0xc0; - - /* and speed up the protection check */ - ROM[0x0099] = 0xc0; - ROM[0x009a] = 0xc0; - ROM[0x009b] = 0xc0; - ROM[0x00bb] = 0xc0; - ROM[0x00bc] = 0xc0; - ROM[0x00bd] = 0xc0; + m_protection_counter = 0; + m_maincpu->space(AS_PROGRAM).install_read_handler(0x73f1, 0x73f2, read8_delegate(FUNC(cvs_state::superbik_prot_r),this)); } +READ8_MEMBER(cvs_state::hero_prot_r) +{ + u8 *ROM = memregion("maincpu")->base() + 0x73f0; + + switch (offset + 0x73f0) + { + case 0x73f0: // pc: 7d, ab9 + return 0xff; // 0x03 at this address in ROM + + case 0x73f1: // pc: 83, read and then overwritten by 0x73f2 read + return 0; // 0x02 at this address in ROM + + case 0x73f2: // pc: 86, needs to match read from 0x73f0 + return 0xff & 0x7e; // 0x04 at this address in ROM + + case 0x73f9: // pc: A9f, not sure what this is suppose to do? + return 0x00; // 0x1e at this address in ROM + + case 0x73fe: // aa8 + return 0xff; // 0x5e at this address in ROM + } + + return ROM[offset]; +} + void cvs_state::init_hero() { - uint8_t *ROM = memregion("maincpu")->base(); - - /* patch out protection */ - ROM[0x0087] = 0xc0; - ROM[0x0088] = 0xc0; - ROM[0x0aa1] = 0xc0; - ROM[0x0aa2] = 0xc0; - ROM[0x0aa3] = 0xc0; - ROM[0x0aaf] = 0xc0; - ROM[0x0ab0] = 0xc0; - ROM[0x0ab1] = 0xc0; - ROM[0x0abd] = 0xc0; - ROM[0x0abe] = 0xc0; - ROM[0x0abf] = 0xc0; - ROM[0x4de0] = 0xc0; - ROM[0x4de1] = 0xc0; - ROM[0x4de2] = 0xc0; + m_maincpu->space(AS_PROGRAM).install_read_handler(0x73f0, 0x73ff, read8_delegate(FUNC(cvs_state::hero_prot_r),this)); } @@ -1672,8 +1661,8 @@ GAME( 1982, diggerc, 0, cvs, diggerc, cvs_state, empty_init, ROT90 GAME( 1983, heartatk, 0, cvs, heartatk, cvs_state, empty_init, ROT90, "Century Electronics", "Heart Attack", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) GAME( 1983, hunchbak, 0, cvs, hunchbak, cvs_state, empty_init, ROT90, "Century Electronics", "Hunchback (set 1)", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) GAME( 1983, hunchbaka, hunchbak, cvs, hunchbak, cvs_state, init_hunchbaka, ROT90, "Century Electronics", "Hunchback (set 2)", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) -GAME( 1983, superbik, 0, cvs, superbik, cvs_state, init_superbik, ROT90, "Century Electronics", "Superbike", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_UNEMULATED_PROTECTION | MACHINE_SUPPORTS_SAVE ) -GAME( 1983, raiders, 0, cvs, raiders, cvs_state, init_raiders, ROT90, "Century Electronics", "Raiders", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) -GAME( 1983, raidersr3, raiders, cvs, raiders, cvs_state, init_raiders, ROT90, "Century Electronics", "Raiders (Rev.3)", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) +GAME( 1983, superbik, 0, cvs, superbik, cvs_state, init_superbik, ROT90, "Century Electronics", "Superbike", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) +GAME( 1983, raiders, 0, cvs, raiders, cvs_state, init_raiders, ROT90, "Century Electronics", "Raiders", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_UNEMULATED_PROTECTION| MACHINE_SUPPORTS_SAVE ) +GAME( 1983, raidersr3, raiders, cvs, raiders, cvs_state, init_raiders, ROT90, "Century Electronics", "Raiders (Rev.3)", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_UNEMULATED_PROTECTION| MACHINE_SUPPORTS_SAVE ) GAME( 1984, hero, 0, cvs, hero, cvs_state, init_hero, ROT90, "Century Electronics / Seatongrove Ltd", "Hero", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) // (C) 1984 CVS on titlescreen, (C) 1983 Seatongrove on highscore screen GAME( 1984, huncholy, 0, cvs, huncholy, cvs_state, init_huncholy, ROT90, "Century Electronics / Seatongrove Ltd", "Hunchback Olympic", MACHINE_NO_COCKTAIL | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/galaxia.cpp b/src/mame/drivers/galaxia.cpp index 69fdfa9beb7..39a90258bd0 100644 --- a/src/mame/drivers/galaxia.cpp +++ b/src/mame/drivers/galaxia.cpp @@ -308,7 +308,7 @@ MACHINE_CONFIG_START(galaxia_state::galaxia) MCFG_DEVICE_IO_MAP(galaxia_io_map) MCFG_DEVICE_DATA_MAP(galaxia_data_map) MCFG_S2650_SENSE_INPUT(READLINE("screen", screen_device, vblank)) - MCFG_S2650_FLAG_OUTPUT(WRITELINE(*this, cvs_state, write_s2650_flag)) + MCFG_S2650_FLAG_OUTPUT(WRITELINE(*this, galaxia_state, write_s2650_flag)) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -352,7 +352,7 @@ MACHINE_CONFIG_START(galaxia_state::astrowar) MCFG_DEVICE_IO_MAP(galaxia_io_map) MCFG_DEVICE_DATA_MAP(galaxia_data_map) MCFG_S2650_SENSE_INPUT(READLINE("screen", screen_device, vblank)) - MCFG_S2650_FLAG_OUTPUT(WRITELINE(*this, cvs_state, write_s2650_flag)) + MCFG_S2650_FLAG_OUTPUT(WRITELINE(*this, galaxia_state, write_s2650_flag)) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) diff --git a/src/mame/includes/cvs.h b/src/mame/includes/cvs.h index 49499306105..3687b2971c8 100644 --- a/src/mame/includes/cvs.h +++ b/src/mame/includes/cvs.h @@ -48,8 +48,20 @@ public: , m_lamps(*this, "lamp%u", 1U) { } + void init_raiders(); + void init_huncholy(); + void init_hero(); + void init_superbik(); + void init_hunchbaka(); + void cvs(machine_config &config); + +protected: + + DECLARE_WRITE_LINE_MEMBER(write_s2650_flag); // used by galaxia_state + DECLARE_READ8_MEMBER(huncholy_prot_r); + DECLARE_READ8_MEMBER(superbik_prot_r); + DECLARE_READ8_MEMBER(hero_prot_r); DECLARE_READ_LINE_MEMBER(speech_rom_read_bit); - DECLARE_WRITE_LINE_MEMBER(write_s2650_flag); DECLARE_WRITE_LINE_MEMBER(cvs_slave_cpu_interrupt); DECLARE_READ8_MEMBER(cvs_input_r); DECLARE_WRITE8_MEMBER(cvs_speech_rom_address_lo_w); @@ -75,11 +87,6 @@ public: DECLARE_WRITE8_MEMBER(cvs_unknown_w); DECLARE_WRITE8_MEMBER(cvs_tms5110_ctl_w); DECLARE_WRITE8_MEMBER(cvs_tms5110_pdc_w); - void init_raiders(); - void init_huncholy(); - void init_hero(); - void init_superbik(); - void init_hunchbaka(); DECLARE_VIDEO_START(cvs); DECLARE_PALETTE_INIT(cvs); uint32_t screen_update_cvs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); @@ -90,14 +97,12 @@ public: void cvs_init_stars(); void cvs_update_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, const pen_t star_pen, bool update_always); void start_393hz_timer(); - void cvs(machine_config &config); void cvs_dac_cpu_map(address_map &map); void cvs_main_cpu_data_map(address_map &map); void cvs_main_cpu_io_map(address_map &map); void cvs_main_cpu_map(address_map &map); void cvs_speech_cpu_map(address_map &map); -protected: virtual void machine_start() override; virtual void machine_reset() override; @@ -123,6 +128,7 @@ protected: int m_s2650_flag; emu_timer *m_cvs_393hz_timer; uint8_t m_cvs_393hz_clock; + uint8_t m_protection_counter; uint8_t m_character_banking_mode; uint16_t m_character_ram_page_start;