summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Ivan Vangelista <mesgnet@yahoo.it>2021-06-02 17:06:42 +0200
committer Ivan Vangelista <mesgnet@yahoo.it>2021-06-02 17:06:42 +0200
commit682090918b341dde053e4d7ace418d3d6bbbf4f0 (patch)
treebd1b0f71884c936061913869da22ee4c48b29a8e
parentc5e60d15540251e50f948f4186986dd19f1b84b2 (diff)
stv.cpp: moved the few remaining protection functions in stvprot.cpp to the driver file and eliminated strvprot.*
-rw-r--r--scripts/target/mame/arcade.lua2
-rw-r--r--src/mame/drivers/stv.cpp92
-rw-r--r--src/mame/includes/stv.h2
-rw-r--r--src/mame/machine/stvprot.cpp94
-rw-r--r--src/mame/machine/stvprot.h2
5 files changed, 90 insertions, 102 deletions
diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua
index 3535c5dfbeb..f0b1b2531cb 100644
--- a/scripts/target/mame/arcade.lua
+++ b/scripts/target/mame/arcade.lua
@@ -3631,8 +3631,6 @@ files {
MAME_DIR .. "src/mame/machine/saturn_cdb.cpp",
MAME_DIR .. "src/mame/machine/saturn_cdb.h",
MAME_DIR .. "src/mame/includes/stv.h",
- MAME_DIR .. "src/mame/machine/stvprot.cpp",
- MAME_DIR .. "src/mame/machine/stvprot.h",
MAME_DIR .. "src/mame/machine/315-5838_317-0229_comp.cpp",
MAME_DIR .. "src/mame/machine/315-5838_317-0229_comp.h",
MAME_DIR .. "src/mame/drivers/suprloco.cpp",
diff --git a/src/mame/drivers/stv.cpp b/src/mame/drivers/stv.cpp
index 0a8233de3a5..a19ce9caaf2 100644
--- a/src/mame/drivers/stv.cpp
+++ b/src/mame/drivers/stv.cpp
@@ -9,7 +9,7 @@
TODO:
- clean this up!
- - Properly emulate the protection chips, used by several games (check stvprot.cpp for more info)
+ - Properly emulate the protection chips, used by several games
(per-game issues)
- stress: accesses the Sound Memory Expansion Area (0x05a80000-0x05afffff), unknown purpose;
@@ -43,7 +43,6 @@
#include "cpu/sh/sh2.h"
#include "machine/smpc.h"
#include "machine/stvcd.h"
-#include "machine/stvprot.h"
#include "sound/scsp.h"
#include "softlist.h"
@@ -264,6 +263,93 @@ void stv_state::hop_ioga_w(offs_t offset, uint8_t data)
stv_ioga_w(offset, data);
}
+
+// ST-V hookup for 315-5881 encryption/compression chip
+
+/*
+ Known ST-V Games using this kind of protection
+
+ Astra Superstars (text layer gfx transfer)
+ Elandoree (gfx transfer of textures)
+ Final Fight Revenge (boot vectors etc.)
+ Radiant Silvergun (game start protection)
+ Steep Slope Sliders (gfx transfer of character portraits)
+ Tecmo World Cup '98 (Tecmo logo, player movement)
+
+*/
+
+/*************************************
+*
+* Common Handlers
+*
+*************************************/
+
+uint32_t stv_state::common_prot_r(offs_t offset)
+{
+ uint32_t *ROM = (uint32_t *)memregion("abus")->base();
+
+ if(m_abus_protenable & 0x00010000)//protection calculation is activated
+ {
+ if(offset == 3)
+ {
+ uint8_t* base;
+ uint16_t res = m_cryptdevice->do_decrypt(base);
+ uint16_t res2 = m_cryptdevice->do_decrypt(base);
+ res = ((res & 0xff00) >> 8) | ((res & 0x00ff) << 8);
+ res2 = ((res2 & 0xff00) >> 8) | ((res2 & 0x00ff) << 8);
+
+ return res2 | (res << 16);
+ }
+ return m_a_bus[offset];
+ }
+ else
+ {
+ if(m_a_bus[offset] != 0) return m_a_bus[offset];
+ else return ROM[(0x02fffff0/4)+offset];
+ }
+}
+
+
+uint16_t stv_state::crypt_read_callback(uint32_t addr)
+{
+ uint16_t dat= m_maincpu->space().read_word((0x02000000+2*addr));
+ return ((dat&0xff00)>>8)|((dat&0x00ff)<<8);
+}
+
+void stv_state::common_prot_w(offs_t offset, uint32_t data, uint32_t mem_mask)
+{
+ COMBINE_DATA(&m_a_bus[offset]);
+
+ if (offset == 0)
+ {
+ COMBINE_DATA(&m_abus_protenable);
+ }
+ else if(offset == 2)
+ {
+ if (ACCESSING_BITS_16_31) m_cryptdevice->set_addr_low(data >> 16);
+ if (ACCESSING_BITS_0_15) m_cryptdevice->set_addr_high(data&0xffff);
+
+ }
+ else if(offset == 3)
+ {
+ COMBINE_DATA(&m_abus_protkey);
+
+ m_cryptdevice->set_subkey(m_abus_protkey>>16);
+ }
+}
+
+void stv_state::install_common_protection()
+{
+ m_maincpu->space(AS_PROGRAM).install_read_handler(0x4fffff0, 0x4ffffff, read32sm_delegate(*this, FUNC(stv_state::common_prot_r)));
+ m_maincpu->space(AS_PROGRAM).install_write_handler(0x4fffff0, 0x4ffffff, write32s_delegate(*this, FUNC(stv_state::common_prot_w)));
+}
+
+void stv_state::stv_register_protection_savestates()
+{
+ save_item(NAME(m_a_bus));
+}
+
+
/*
06013AE8: MOV.L @($D4,PC),R5
@@ -1265,7 +1351,7 @@ MACHINE_START_MEMBER(stv_state, stv)
save_item(NAME(m_scsp_last_line));
save_item(NAME(m_vdp2.odd));
- stv_register_protection_savestates(); // machine/stvprot.c
+ stv_register_protection_savestates();
m_audiocpu->set_reset_callback(*this, FUNC(stv_state::m68k_reset_callback));
}
diff --git a/src/mame/includes/stv.h b/src/mame/includes/stv.h
index 48ccc7fe5f4..b9a1983e225 100644
--- a/src/mame/includes/stv.h
+++ b/src/mame/includes/stv.h
@@ -125,7 +125,7 @@ private:
uint8_t m_ioga_portg;
uint16_t m_serial_tx;
- // protection specific variables and functions (see machine/stvprot.cpp)
+ // protection specific variables and functions
uint32_t m_abus_protenable;
uint32_t m_abus_protkey;
diff --git a/src/mame/machine/stvprot.cpp b/src/mame/machine/stvprot.cpp
deleted file mode 100644
index 91906ff28ff..00000000000
--- a/src/mame/machine/stvprot.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:David Haywood, Angelo Salese, Olivier Galibert, Mariusz Wojcieszek, R. Belmont
-/* ST-V hookup for 315-5881 encryption/compression chip */
-
-/*
-
- Known ST-V Games using this kind of protection
-
- Astra Superstars (text layer gfx transfer)
- Elandoree (gfx transfer of textures)
- Final Fight Revenge (boot vectors etc.)
- Radiant Silvergun (game start protection)
- Steep Slope Sliders (gfx transfer of character portraits)
- Tecmo World Cup '98 (tecmo logo, player movement)
-
-*/
-
-#include "emu.h"
-#include "includes/stv.h"
-
-
-
-
-
-/*************************************
-*
-* Common Handlers
-*
-*************************************/
-
-uint32_t stv_state::common_prot_r(offs_t offset)
-{
- uint32_t *ROM = (uint32_t *)machine().root_device().memregion("abus")->base();
-
- if(m_abus_protenable & 0x00010000)//protection calculation is activated
- {
- if(offset == 3)
- {
- uint8_t* base;
- uint16_t res = m_cryptdevice->do_decrypt(base);
- uint16_t res2 = m_cryptdevice->do_decrypt(base);
- res = ((res & 0xff00) >> 8) | ((res & 0x00ff) << 8);
- res2 = ((res2 & 0xff00) >> 8) | ((res2 & 0x00ff) << 8);
-
- return res2 | (res << 16);
- }
- return m_a_bus[offset];
- }
- else
- {
- if(m_a_bus[offset] != 0) return m_a_bus[offset];
- else return ROM[(0x02fffff0/4)+offset];
- }
-}
-
-
-uint16_t stv_state::crypt_read_callback(uint32_t addr)
-{
- uint16_t dat= m_maincpu->space().read_word((0x02000000+2*addr));
- return ((dat&0xff00)>>8)|((dat&0x00ff)<<8);
-}
-
-void stv_state::common_prot_w(offs_t offset, uint32_t data, uint32_t mem_mask)
-{
- COMBINE_DATA(&m_a_bus[offset]);
-
- if (offset == 0)
- {
- COMBINE_DATA(&m_abus_protenable);
- }
- else if(offset == 2)
- {
- if (ACCESSING_BITS_16_31) m_cryptdevice->set_addr_low(data >> 16);
- if (ACCESSING_BITS_0_15) m_cryptdevice->set_addr_high(data&0xffff);
-
- }
- else if(offset == 3)
- {
- COMBINE_DATA(&m_abus_protkey);
-
- m_cryptdevice->set_subkey(m_abus_protkey>>16);
- }
-}
-
-void stv_state::install_common_protection()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0x4fffff0, 0x4ffffff, read32sm_delegate(*this, FUNC(stv_state::common_prot_r)));
- m_maincpu->space(AS_PROGRAM).install_write_handler(0x4fffff0, 0x4ffffff, write32s_delegate(*this, FUNC(stv_state::common_prot_w)));
-}
-
-void stv_state::stv_register_protection_savestates()
-{
- save_item(NAME(m_a_bus));
-}
diff --git a/src/mame/machine/stvprot.h b/src/mame/machine/stvprot.h
deleted file mode 100644
index 6acafefe66a..00000000000
--- a/src/mame/machine/stvprot.h
+++ /dev/null
@@ -1,2 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:David Haywood, Angelo Salese, Olivier Galibert, Mariusz Wojcieszek, R. Belmont