diff options
author | angelosa <salese_corp_ltd@email.it> | 2017-10-31 16:44:35 +0100 |
---|---|---|
committer | angelosa <salese_corp_ltd@email.it> | 2017-10-31 16:45:21 +0100 |
commit | 6fd1943ae230b38b2a481500312d5077789c3527 (patch) | |
tree | 10eb0e6e2d3beb9840abac88584e854fac268b5a | |
parent | ac6c08eb74bd8aba39e8015f68ee732f99da164c (diff) |
dec0.cpp: emulated sound protection state machine for Sly Spy and get rid of ROM patch [Angelo Salese]
-rw-r--r-- | src/mame/drivers/dec0.cpp | 68 | ||||
-rw-r--r-- | src/mame/includes/dec0.h | 6 | ||||
-rw-r--r-- | src/mame/machine/dec0.cpp | 6 |
3 files changed, 68 insertions, 12 deletions
diff --git a/src/mame/drivers/dec0.cpp b/src/mame/drivers/dec0.cpp index 5a010d14dd6..d49b112a038 100644 --- a/src/mame/drivers/dec0.cpp +++ b/src/mame/drivers/dec0.cpp @@ -48,7 +48,7 @@ ToDo: - graphics are completely broken in Secret Agent (bootleg); - Fighting Fantasy (bootleg) doesn't move on when killing the Lamia, is the MCU involved? - Hook up the 68705 in Midnight Resistance (bootleg) (it might not be used, leftover from the Fighting Fantasy bootleg on the same PCB?) -- Get rid of ROM patches in Sly Spy and Hippodrome; +- Get rid of ROM patch in Hippodrome; - background pen in Birdie Try is presumably wrong. - Pixel clock frequency isn't verified; - Finally, get a proper decap of the MCUs used by Dragonninja and Birdie Try; @@ -564,7 +564,7 @@ READ16_MEMBER(dec0_state::slyspy_state_r) static ADDRESS_MAP_START( slyspy_protection_map, AS_PROGRAM, 16, dec0_state ) - AM_RANGE(0x04000, 0x04001) AM_MIRROR(0x30000) AM_READ(slyspy_state_r) + AM_RANGE(0x04000, 0x04001) AM_MIRROR(0x30000) AM_READ(slyspy_state_r) AM_WRITENOP AM_RANGE(0x0a000, 0x0a001) AM_MIRROR(0x30000) AM_WRITE(slyspy_state_w) // Default state (called by Traps 1, 3, 4, 7, C) AM_RANGE(0x00000, 0x00007) AM_DEVWRITE("tilegen2", deco_bac06_device, pf_control_0_w) @@ -669,15 +669,59 @@ ADDRESS_MAP_END /* Physical memory map (21 bits) */ static ADDRESS_MAP_START( slyspy_s_map, AS_PROGRAM, 8, dec0_state ) AM_RANGE(0x000000, 0x00ffff) AM_ROM - AM_RANGE(0x090000, 0x090001) AM_DEVWRITE("ym2", ym3812_device, write) - AM_RANGE(0x0a0000, 0x0a0001) AM_READNOP /* Protection counter */ - AM_RANGE(0x0b0000, 0x0b0001) AM_DEVWRITE("ym1", ym2203_device, write) - AM_RANGE(0x0e0000, 0x0e0001) AM_DEVREADWRITE("oki", okim6295_device, read, write) - AM_RANGE(0x0f0000, 0x0f0001) AM_DEVREAD("soundlatch", generic_latch_8_device, read) + AM_RANGE(0x080000, 0x0fffff) AM_DEVICE("sndprotect", address_map_bank_device, amap8 ) AM_RANGE(0x1f0000, 0x1f1fff) AM_RAMBANK("bank8") AM_RANGE(0x1ff400, 0x1ff403) AM_DEVWRITE("audiocpu", h6280_device, irq_status_w) ADDRESS_MAP_END +// sly spy sound state protection machine emulation +// similar to the video state machine +// current bank is at 0x1f0045, incremented by 1 then here is read +READ8_MEMBER(dec0_state::slyspy_sound_state_r) +{ + m_slyspy_sound_state ++; + m_slyspy_sound_state &= 3; + m_sndprotect->set_bank(m_slyspy_sound_state); + + // returned value doesn't matter + return 0xff; +} + +READ8_MEMBER(dec0_state::slyspy_sound_state_reset_r) +{ + m_slyspy_sound_state = 0; + m_sndprotect->set_bank(m_slyspy_sound_state); + + // returned value doesn't matter + return 0xff; +} + +static ADDRESS_MAP_START( slyspy_sound_protection_map, AS_PROGRAM, 8, dec0_state ) + AM_RANGE(0x020000, 0x020001) AM_MIRROR(0x180000) AM_READ(slyspy_sound_state_r) /* Protection counter */ + AM_RANGE(0x050000, 0x050001) AM_MIRROR(0x180000) AM_READ(slyspy_sound_state_reset_r) + // state 0 + AM_RANGE(0x010000, 0x010001) AM_DEVWRITE("ym2", ym3812_device, write) + AM_RANGE(0x030000, 0x030001) AM_DEVWRITE("ym1", ym2203_device, write) + AM_RANGE(0x060000, 0x060001) AM_DEVREADWRITE("oki", okim6295_device, read, write) + AM_RANGE(0x070000, 0x070001) AM_DEVREAD("soundlatch", generic_latch_8_device, read) + // state 1 + AM_RANGE(0x090000, 0x090001) AM_DEVREADWRITE("oki", okim6295_device, read, write) + AM_RANGE(0x0c0000, 0x0c0001) AM_DEVREAD("soundlatch", generic_latch_8_device, read) + AM_RANGE(0x0e0000, 0x0e0001) AM_DEVWRITE("ym1", ym2203_device, write) + AM_RANGE(0x0f0000, 0x0f0001) AM_DEVWRITE("ym2", ym3812_device, write) + // state 2 + AM_RANGE(0x110000, 0x110001) AM_DEVREAD("soundlatch", generic_latch_8_device, read) + AM_RANGE(0x130000, 0x130001) AM_DEVREADWRITE("oki", okim6295_device, read, write) + AM_RANGE(0x140000, 0x140001) AM_DEVWRITE("ym1", ym2203_device, write) + AM_RANGE(0x170000, 0x170001) AM_DEVWRITE("ym2", ym3812_device, write) + // state 3 + AM_RANGE(0x190000, 0x190001) AM_DEVWRITE("ym2", ym3812_device, write) + AM_RANGE(0x1c0000, 0x1c0001) AM_DEVWRITE("ym1", ym2203_device, write) + AM_RANGE(0x1e0000, 0x1e0001) AM_DEVREAD("soundlatch", generic_latch_8_device, read) + AM_RANGE(0x1f0000, 0x1f0001) AM_DEVREADWRITE("oki", okim6295_device, read, write) +ADDRESS_MAP_END + + static ADDRESS_MAP_START( midres_s_map, AS_PROGRAM, 8, dec0_state ) AM_RANGE(0x000000, 0x00ffff) AM_ROM AM_RANGE(0x108000, 0x108001) AM_DEVWRITE("ym2", ym3812_device, write) @@ -1906,6 +1950,8 @@ MACHINE_RESET_MEMBER(dec0_state,slyspy) // set initial memory map m_slyspy_state = 0; m_pfprotect->set_bank(m_slyspy_state); + m_slyspy_sound_state = 0; + m_sndprotect->set_bank(m_slyspy_sound_state); } static MACHINE_CONFIG_DERIVED( slyspy, dec1 ) @@ -1925,6 +1971,14 @@ static MACHINE_CONFIG_DERIVED( slyspy, dec1 ) MCFG_ADDRESS_MAP_BANK_ADDRBUS_WIDTH(18) MCFG_ADDRESS_MAP_BANK_STRIDE(0x10000) + MCFG_DEVICE_ADD("sndprotect", ADDRESS_MAP_BANK, 0) + MCFG_DEVICE_PROGRAM_MAP(slyspy_sound_protection_map) + MCFG_ADDRESS_MAP_BANK_ENDIANNESS(ENDIANNESS_LITTLE) + MCFG_ADDRESS_MAP_BANK_DATABUS_WIDTH(8) + MCFG_ADDRESS_MAP_BANK_ADDRBUS_WIDTH(21) + MCFG_ADDRESS_MAP_BANK_STRIDE(0x80000) + + /* video hardware */ MCFG_SCREEN_MODIFY("screen") MCFG_SCREEN_UPDATE_DRIVER(dec0_state, screen_update_slyspy) diff --git a/src/mame/includes/dec0.h b/src/mame/includes/dec0.h index b748b05a5d0..38a29f172b7 100644 --- a/src/mame/includes/dec0.h +++ b/src/mame/includes/dec0.h @@ -28,6 +28,7 @@ public: m_tilegen3(*this, "tilegen3"), m_spritegen(*this, "spritegen"), m_pfprotect(*this, "pfprotect"), + m_sndprotect(*this, "sndprotect"), m_soundlatch(*this, "soundlatch"), m_ram(*this, "ram"), m_spriteram(*this, "spriteram"), @@ -45,6 +46,7 @@ public: optional_device<deco_bac06_device> m_tilegen3; optional_device<deco_mxc06_device> m_spritegen; optional_device<address_map_bank_device> m_pfprotect; + optional_device<address_map_bank_device> m_sndprotect; required_device<generic_latch_8_device> m_soundlatch; required_shared_ptr<uint16_t> m_ram; @@ -57,6 +59,7 @@ public: uint16_t m_i8751_return; uint16_t m_i8751_command; int m_slyspy_state; + int m_slyspy_sound_state; int m_hippodrm_msb; int m_hippodrm_lsb; uint8_t m_i8751_ports[4]; @@ -84,6 +87,9 @@ public: DECLARE_WRITE16_MEMBER(dec0_priority_w); DECLARE_READ16_MEMBER(ffantasybl_242024_r); + DECLARE_READ8_MEMBER(slyspy_sound_state_r); + DECLARE_READ8_MEMBER(slyspy_sound_state_reset_r); + DECLARE_DRIVER_INIT(robocop); DECLARE_DRIVER_INIT(hippodrm); DECLARE_DRIVER_INIT(hbarrel); diff --git a/src/mame/machine/dec0.cpp b/src/mame/machine/dec0.cpp index 0dc090e32be..20399c58776 100644 --- a/src/mame/machine/dec0.cpp +++ b/src/mame/machine/dec0.cpp @@ -366,14 +366,10 @@ DRIVER_INIT_MEMBER(dec0_state,hippodrm) DRIVER_INIT_MEMBER(dec0_state,slyspy) { - uint8_t *RAM = memregion("audiocpu")->base(); h6280_decrypt("audiocpu"); - /* Slyspy sound cpu has some protection */ - RAM[0xf2d] = 0xea; - RAM[0xf2e] = 0xea; - save_item(NAME(m_slyspy_state)); + save_item(NAME(m_slyspy_sound_state)); } DRIVER_INIT_MEMBER(dec0_state,robocop) |