From adbda4b6f05f1efde5ea4d38fc6eea7cb7015723 Mon Sep 17 00:00:00 2001 From: David Haywood Date: Mon, 6 Aug 2018 22:50:16 +0100 Subject: some tweaks to 315-5838 (decathlt) based on further observations (nw) (#3831) * some tweaks to 315-5838 (decathlt) based on further observations (nw) * fix debugging (nw) --- src/mame/drivers/model2.cpp | 56 ++++++++++++++++++++-------- src/mame/drivers/stv.cpp | 58 ++++++++++++++--------------- src/mame/includes/model2.h | 6 ++- src/mame/includes/stv.h | 6 +-- src/mame/machine/315-5838_317-0229_comp.cpp | 10 ++--- 5 files changed, 82 insertions(+), 54 deletions(-) diff --git a/src/mame/drivers/model2.cpp b/src/mame/drivers/model2.cpp index 3bf90552b6d..67e9d9c0a41 100644 --- a/src/mame/drivers/model2.cpp +++ b/src/mame/drivers/model2.cpp @@ -1418,6 +1418,12 @@ void model2a_state::model2a_5881_mem(address_map &map) model2_5881_mem(map); } +void model2a_state::model2a_0229_mem(address_map &map) +{ + model2a_crx_mem(map); + model2_0229_mem(map); +} + /* 2B-CRX overrides */ void model2b_state::model2b_crx_mem(address_map &map) { @@ -1458,6 +1464,12 @@ void model2b_state::model2b_5881_mem(address_map &map) model2_5881_mem(map); } +void model2b_state::model2b_0229_mem(address_map &map) +{ + model2b_crx_mem(map); + model2_0229_mem(map); +} + /* 2C-CRX overrides */ void model2c_state::model2c_crx_mem(address_map &map) { @@ -2720,16 +2732,16 @@ MACHINE_CONFIG_START(model2a_state::model2a_5881) MCFG_SET_READ_CALLBACK(model2_state, crypt_read_callback) MACHINE_CONFIG_END -void model2a_state::sega5838_map(address_map &map) -{ - // TODO: shares the ram at 1d80000, add it to main map so it can be shared here - //map(0x000000, 0xffffff).bankr("protbank"); -} + MACHINE_CONFIG_START(model2a_state::model2a_0229) model2a(config); + + MCFG_DEVICE_MODIFY("maincpu") + MCFG_DEVICE_PROGRAM_MAP(model2a_0229_mem) + MCFG_DEVICE_ADD("317_0229", SEGA315_5838_COMP, 0) - MCFG_DEVICE_ADDRESS_MAP(0, sega5838_map) + MCFG_DEVICE_ADDRESS_MAP(0, sega_0229_map) MACHINE_CONFIG_END void model2a_state::zeroguna(machine_config &config) @@ -2790,8 +2802,12 @@ MACHINE_CONFIG_END MACHINE_CONFIG_START(model2b_state::model2b_0229) model2b(config); + + MCFG_DEVICE_MODIFY("maincpu") + MCFG_DEVICE_PROGRAM_MAP(model2b_0229_mem) + MCFG_DEVICE_ADD("317_0229", SEGA315_5838_COMP, 0) -// MCFG_SET_5838_READ_CALLBACK(model2_state, crypt_read_callback) + MCFG_DEVICE_ADDRESS_MAP(0, sega_0229_map) MACHINE_CONFIG_END void model2b_state::indy500(machine_config &config) @@ -6568,7 +6584,6 @@ void model2_state::init_sgt24h() READ32_MEMBER(model2_state::doa_prot_r) { // doa only reads 16-bits at a time, while STV reads 32-bits - uint32 ret = 0; if (mem_mask&0xffff0000) ret |= (m_0229crypt->data_r(space,0,0xffff)<<16); @@ -6591,6 +6606,24 @@ READ32_MEMBER(model2_state::doa_unk_r) return retval; } +void model2_state::sega_0229_map(address_map &map) +{ + // view the protection device has into RAM, this might need endian swapping + map(0x000000, 0x007fff).ram().share("protram0229"); +} + +/* common map for 0229 protection */ +void model2_state::model2_0229_mem(address_map &map) +{ + // the addresses here suggest this is only connected to a 0x8000 byte window, not 0x80000 like ST-V + map(0x01d80000, 0x01d87fff).ram().share("protram0229"); + map(0x01d87ff0, 0x01d87ff3).w(m_0229crypt, FUNC(sega_315_5838_comp_device::srcaddr_w)); + map(0x01d87ff4, 0x01d87ff7).w(m_0229crypt, FUNC(sega_315_5838_comp_device::data_w_doa)); + map(0x01d87ff8, 0x01d87ffb).r(FUNC(model2_state::doa_prot_r)); + + // is this protection related? it's in the same ram range but other games with the device don't use the address for any kind of status doesn't access the device otherwise? + map(0x01d8400c, 0x01d8400f).r(FUNC(model2_state::doa_unk_r)); +} void model2_state::init_doa() { @@ -6598,13 +6631,6 @@ void model2_state::init_doa() ROM[0x630 / 4] = 0x08000004; ROM[0x808 / 4] = 0x08000004; - // protection ram is 1d80000 - - m_maincpu->space(AS_PROGRAM).install_read_handler(0x01d8400c, 0x01d8400f, read32_delegate(FUNC(model2_state::doa_unk_r), this)); // is this protection related? it's in the same ram range but other games with the device don't use the address for any kind of status - m_maincpu->space(AS_PROGRAM).install_write_handler(0x01d87ff0, 0x01d87ff3, write32_delegate(FUNC(sega_315_5838_comp_device::srcaddr_w), (sega_315_5838_comp_device*)m_0229crypt)); // set compressed data source address (always set 0, data is in RAM) - m_maincpu->space(AS_PROGRAM).install_write_handler(0x01d87ff4, 0x01d87ff7, write32_delegate(FUNC(sega_315_5838_comp_device::data_w_doa), (sega_315_5838_comp_device*)m_0229crypt)); // upload tab - m_maincpu->space(AS_PROGRAM).install_read_handler(0x01d87ff8, 0x01d87ffb, read32_delegate(FUNC(model2_state::doa_prot_r), this)); // read decompressed data - m_0229crypt->set_hack_mode(sega_315_5838_comp_device::HACK_MODE_DOA); } diff --git a/src/mame/drivers/stv.cpp b/src/mame/drivers/stv.cpp index 92f90dcfbd2..af9ac9660da 100644 --- a/src/mame/drivers/stv.cpp +++ b/src/mame/drivers/stv.cpp @@ -951,30 +951,16 @@ void stv_state::init_ffreveng() init_stv(); } -READ32_MEMBER(stv_state::decathlt_prot_higher_r) -{ - if (m_newprotection_element) - { - m_newprotection_element = false; - m_5838crypt->debug_helper(1); - } - - m_protbank->set_entry(1); // if the protection device is accessed at this address data is fetched from 0x03000000 - uint32 ret = 0; - if (mem_mask & 0xffff0000) ret |= (m_5838crypt->data_r(space, offset, mem_mask)<<16); - if (mem_mask & 0x0000ffff) ret |= m_5838crypt->data_r(space, offset, mem_mask); - return ret; -} -READ32_MEMBER(stv_state::decathlt_prot_lower_r) +READ32_MEMBER(stv_state::decathlt_prot_r) { + // needs to be a way to indicate if device is enabled and fall through to cartridge data if not? if (m_newprotection_element) { m_newprotection_element = false; - m_5838crypt->debug_helper(0); + m_5838crypt->debug_helper(m_protbankval); } - m_protbank->set_entry(0); // if the protection device is accessed at this address data is fetched from 0x02000000 uint32 ret = 0; if (mem_mask & 0xffff0000) ret |= (m_5838crypt->data_r(space, offset, mem_mask)<<16); if (mem_mask & 0x0000ffff) ret |= m_5838crypt->data_r(space, offset, mem_mask); @@ -983,22 +969,36 @@ READ32_MEMBER(stv_state::decathlt_prot_lower_r) WRITE32_MEMBER(stv_state::decathlt_prot_srcaddr_w) { + int offs = offset * 4; + + m_protbankval = (offs & 0x1800000)>>23; + m_protbank->set_entry(m_protbankval); // if the protection device is accessed at this address data is fetched from 0x02000000 m_newprotection_element = true; - m_5838crypt->srcaddr_w(space,offset,data,mem_mask); + + if ((offs & 0x7fffff) == 0x7FFFF0) + { + m_5838crypt->srcaddr_w(space, offset, data, mem_mask); + } + else if ((offs & 0x7fffff) == 0x7FFFF4) + { + m_5838crypt->data_w(space, offset, data, mem_mask); + } } void stv_state::init_decathlt() { - m_maincpu->space(AS_PROGRAM).install_write_handler(0x37FFFF0, 0x37FFFF3, write32_delegate(FUNC(stv_state::decathlt_prot_srcaddr_w), this)); // set compressed data source address - m_maincpu->space(AS_PROGRAM).install_write_handler(0x37FFFF4, 0x37FFFF7, write32_delegate(FUNC(sega_315_5838_comp_device::data_w), (sega_315_5838_comp_device*)m_5838crypt)); // upload tables - m_maincpu->space(AS_PROGRAM).install_read_handler(0x37FFFF8, 0x37FFFFb, read32_delegate(FUNC(stv_state::decathlt_prot_higher_r), this)); // read decompressed data - - m_maincpu->space(AS_PROGRAM).install_write_handler(0x27FFFF0, 0x27FFFF3, write32_delegate(FUNC(stv_state::decathlt_prot_srcaddr_w), this)); // set compressed data source address - m_maincpu->space(AS_PROGRAM).install_write_handler(0x27FFFF4, 0x27FFFF7, write32_delegate(FUNC(sega_315_5838_comp_device::data_w), (sega_315_5838_comp_device*)m_5838crypt)); // upload tables - m_maincpu->space(AS_PROGRAM).install_read_handler(0x27FFFF8, 0x27FFFFb, read32_delegate(FUNC(stv_state::decathlt_prot_lower_r), this)); // read decompressed data - - m_protbank->configure_entry(0, memregion("cart")->base()); - m_protbank->configure_entry(1, memregion("cart")->base() + 0x1000000); + m_maincpu->space(AS_PROGRAM).install_write_handler(0x2000000, 0x37fffff, write32_delegate(FUNC(stv_state::decathlt_prot_srcaddr_w), this)); // set compressed data source address, write data + + // really needs installing over the whole range, with fallbacks to read rom if device is disabled or isn't accessed on given address + m_maincpu->space(AS_PROGRAM).install_read_handler(0x27ffff8, 0x27ffffb, read32_delegate(FUNC(stv_state::decathlt_prot_r), this)); // read decompressed data + m_maincpu->space(AS_PROGRAM).install_read_handler(0x2fffff8, 0x2fffffb, read32_delegate(FUNC(stv_state::decathlt_prot_r), this)); // ^ + m_maincpu->space(AS_PROGRAM).install_read_handler(0x37ffff8, 0x37ffffb, read32_delegate(FUNC(stv_state::decathlt_prot_r), this)); // ^ + + m_protbank->configure_entry(0, memregion("cart")->base() + 0x0000000); + m_protbank->configure_entry(1, memregion("cart")->base() + 0x0800000); + m_protbank->configure_entry(2, memregion("cart")->base() + 0x1000000); + //m_protbank->configure_entry(3, memregion("cart")->base() + 0x1800000); + m_protbank->set_entry(0); m_newprotection_element = false; @@ -1203,7 +1203,7 @@ MACHINE_CONFIG_END void stv_state::sega5838_map(address_map &map) { - map(0x000000, 0xffffff).bankr("protbank"); + map(0x000000, 0x7fffff).bankr("protbank"); } MACHINE_CONFIG_START(stv_state::stv_5838) diff --git a/src/mame/includes/model2.h b/src/mame/includes/model2.h index 2b8258ae99c..c69b2fe143d 100644 --- a/src/mame/includes/model2.h +++ b/src/mame/includes/model2.h @@ -187,6 +187,7 @@ protected: DECLARE_WRITE16_MEMBER(vertical_sync_w); DECLARE_READ32_MEMBER(doa_prot_r); DECLARE_READ32_MEMBER(doa_unk_r); + void sega_0229_map(address_map &map); int m_prot_a; void raster_init(memory_region *texture_rom); @@ -233,6 +234,7 @@ protected: void geo_sharc_map(address_map &map); void model2_base_mem(address_map &map); void model2_5881_mem(address_map &map); + void model2_0229_mem(address_map &map); void model2_snd(address_map &map); void debug_init(); @@ -459,8 +461,6 @@ public: DECLARE_MACHINE_RESET(model2a); - void sega5838_map(address_map &map); - void manxtt(machine_config &config); void manxttdx(machine_config &config); void model2a(machine_config &config); @@ -474,6 +474,7 @@ public: protected: void model2a_crx_mem(address_map &map); void model2a_5881_mem(address_map &map); + void model2a_0229_mem(address_map &map); }; /***************************** @@ -514,6 +515,7 @@ protected: void model2b_crx_mem(address_map &map); void model2b_5881_mem(address_map &map); + void model2b_0229_mem(address_map &map); // TODO: split into own class void rchase2_iocpu_map(address_map &map); void rchase2_ioport_map(address_map &map); diff --git a/src/mame/includes/stv.h b/src/mame/includes/stv.h index 8acb0fb20a2..4fe65fc663b 100644 --- a/src/mame/includes/stv.h +++ b/src/mame/includes/stv.h @@ -134,11 +134,11 @@ private: uint32_t m_abus_protenable; uint32_t m_abus_protkey; - READ32_MEMBER(decathlt_prot_higher_r); - READ32_MEMBER(decathlt_prot_lower_r); + READ32_MEMBER(decathlt_prot_r); void sega5838_map(address_map &map); optional_memory_bank m_protbank; - bool m_newprotection_element; // debug helper only + bool m_newprotection_element; // debug helper only, doesn't need saving + int m_protbankval; // debug helper only, doesn't need saving WRITE32_MEMBER(decathlt_prot_srcaddr_w); uint32_t m_a_bus[4]; diff --git a/src/mame/machine/315-5838_317-0229_comp.cpp b/src/mame/machine/315-5838_317-0229_comp.cpp index 6a30032f579..5716f30ddb6 100644 --- a/src/mame/machine/315-5838_317-0229_comp.cpp +++ b/src/mame/machine/315-5838_317-0229_comp.cpp @@ -38,7 +38,7 @@ DEFINE_DEVICE_TYPE(SEGA315_5838_COMP, sega_315_5838_comp_device, "sega315_5838", sega_315_5838_comp_device::sega_315_5838_comp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, SEGA315_5838_COMP, tag, owner, clock), - device_rom_interface(mconfig, *this, 24), + device_rom_interface(mconfig, *this, 23), m_hackmode(0) { } @@ -148,7 +148,7 @@ uint8_t sega_315_5838_comp_device::get_decompressed_byte(void) if (!(m_srcoffset & 1)) { uint16_t temp = read_word((m_srcoffset*2)^2); - logerror("%s: read data %02x\n", machine().describe_context(), temp); + logerror("%s: read data %04x\n", machine().describe_context(), temp); #ifdef SEGA315_DUMP_DEBUG if (m_fp) { @@ -172,7 +172,7 @@ uint8_t sega_315_5838_comp_device::get_decompressed_byte(void) } m_srcoffset++; - m_srcoffset &= 0x00ffffff; + m_srcoffset &= 0x007fffff; return ret; } } @@ -186,7 +186,7 @@ uint16_t sega_315_5838_comp_device::source_word_r() { uint16_t tempdata = read_word((m_srcoffset*2)^2); m_srcoffset++; - m_srcoffset &= 0x00ffffff; + m_srcoffset &= 0x007fffff; if (m_srcoffset == m_srcstart) // if we've wrapped around to where we started something has gone wrong with the transfer, abandon m_abort = true; @@ -204,7 +204,7 @@ uint16_t sega_315_5838_comp_device::source_word_r() void sega_315_5838_comp_device::set_prot_addr(uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_srcoffset); - m_srcoffset &= 0x00ffffff; + m_srcoffset &= 0x007fffff; m_srcstart = m_srcoffset; m_abort = false; -- cgit v1.2.3