From 09fa96295ce5c27e4cce941c6343e6c5880d9fca Mon Sep 17 00:00:00 2001 From: mamehaze Date: Tue, 4 Nov 2014 00:51:52 +0000 Subject: just test code (nw) --- src/mame/drivers/stv.c | 2 +- src/mame/includes/stv.h | 10 ++++++---- src/mame/machine/315-5881_crypt.c | 4 +++- src/mame/machine/315-5881_crypt.h | 2 +- src/mame/machine/stvprot.c | 11 +++++++++-- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/mame/drivers/stv.c b/src/mame/drivers/stv.c index 42b67c9eab9..4f15d799d73 100644 --- a/src/mame/drivers/stv.c +++ b/src/mame/drivers/stv.c @@ -1023,7 +1023,7 @@ static MACHINE_CONFIG_START( stv, stv_state ) MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) MCFG_DEVICE_ADD("315_5881", SEGA315_5881_CRYPT, 0) - //MCFG_SET_READ_CALLBACK(stv_state, read_callback) + MCFG_SET_READ_CALLBACK(stv_state, crypt_read_callback) MACHINE_CONFIG_END /* diff --git a/src/mame/includes/stv.h b/src/mame/includes/stv.h index 849db7a5f21..4fafe420c46 100644 --- a/src/mame/includes/stv.h +++ b/src/mame/includes/stv.h @@ -35,8 +35,7 @@ public: m_cart3(*this, "stv_slot3"), m_cart4(*this, "stv_slot4"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_cryptdevice(*this, "315_5881") + m_palette(*this, "palette") { } @@ -170,7 +169,6 @@ public: required_device m_gfxdecode; required_device m_palette; - optional_device m_cryptdevice; bitmap_rgb32 m_tmpbitmap; @@ -700,7 +698,8 @@ public: stv_state(const machine_config &mconfig, device_type type, const char *tag) : saturn_state(mconfig, type, tag), m_adsp(*this, "adsp"), - m_adsp_pram(*this, "adsp_pram") + m_adsp_pram(*this, "adsp_pram"), + m_cryptdevice(*this, "315_5881") { } @@ -835,6 +834,9 @@ public: DECLARE_WRITE32_MEMBER( decathlt_prot2_w ); void write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which); void install_decathlt_protection(); + + optional_device m_cryptdevice; + UINT16 crypt_read_callback(UINT32 addr); }; diff --git a/src/mame/machine/315-5881_crypt.c b/src/mame/machine/315-5881_crypt.c index 7731d43a901..c19b431aef7 100644 --- a/src/mame/machine/315-5881_crypt.c +++ b/src/mame/machine/315-5881_crypt.c @@ -65,7 +65,7 @@ void sega_315_5881_crypt_device::device_reset() buffer_bit = 0; } -void sega_315_5881_crypt_device::do_decrypt(UINT8 *&base) +UINT16 sega_315_5881_crypt_device::do_decrypt(UINT8 *&base) { if(!enc_ready) enc_start(); @@ -80,6 +80,8 @@ void sega_315_5881_crypt_device::do_decrypt(UINT8 *&base) base = buffer + buffer_pos; buffer_pos += 2; } + + return (base[0] << 8) | base[1]; } void sega_315_5881_crypt_device::set_addr_low(UINT16 data) diff --git a/src/mame/machine/315-5881_crypt.h b/src/mame/machine/315-5881_crypt.h index fcea2a21a2d..6d667aef807 100644 --- a/src/mame/machine/315-5881_crypt.h +++ b/src/mame/machine/315-5881_crypt.h @@ -19,7 +19,7 @@ public: sega_315_5881_crypt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - void do_decrypt(UINT8 *&base); + UINT16 do_decrypt(UINT8 *&base); void set_addr_low(UINT16 data); void set_addr_high(UINT16 data); void set_subkey(UINT16 data); diff --git a/src/mame/machine/stvprot.c b/src/mame/machine/stvprot.c index 901cf83e003..378ecca0136 100644 --- a/src/mame/machine/stvprot.c +++ b/src/mame/machine/stvprot.c @@ -590,6 +590,8 @@ READ32_MEMBER( stv_state::common_prot_r ) logerror("A-Bus control protection read at %06x with data = %08x Returning = %08x Would otherwise return = %08x\n",space.device().safe_pc(),m_abus_protkey, retdata, realret); + //UINT16 res = m_cryptdevice->do_decrypt(base); + m_ctrl_index += 4; return retdata; @@ -604,7 +606,11 @@ READ32_MEMBER( stv_state::common_prot_r ) } - +UINT16 stv_state::crypt_read_callback(UINT32 addr) +{ + const UINT8 *base = m_cart_reg[0]->base() + 2*addr; + return base[1] | (base[0] << 8); +} WRITE32_MEMBER ( stv_state::common_prot_w ) { @@ -627,7 +633,7 @@ WRITE32_MEMBER ( stv_state::common_prot_w ) { COMBINE_DATA(&m_abus_protkey); - m_cryptdevice->set_subkey(m_abus_protkey); + m_cryptdevice->set_subkey(m_abus_protkey>>16); int a_bus_vector; @@ -665,6 +671,7 @@ void stv_state::install_astrass_protection() { install_common_protection(); m_prot_readback = astrass_prot_read_callback; +// m_cryptdevice->set_key(0x00000000); } void stv_state::install_ffreveng_protection() -- cgit v1.2.3