summaryrefslogtreecommitdiffstats
path: root/src/mame/drivers/mpu4crystal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/mpu4crystal.cpp')
-rw-r--r--src/mame/drivers/mpu4crystal.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/mame/drivers/mpu4crystal.cpp b/src/mame/drivers/mpu4crystal.cpp
index df07f00c1b6..47c42a99915 100644
--- a/src/mame/drivers/mpu4crystal.cpp
+++ b/src/mame/drivers/mpu4crystal.cpp
@@ -17,9 +17,72 @@ public:
mpu4_state(mconfig, type, tag)
{
}
+
+ void init_crystali();
+ void init_crystal();
+ void init_m_frkstn();
+
+private:
+ uint8_t crystal_sound_r();
+ void crystal_sound_w(uint8_t data);
};
+uint8_t mpu4crystal_machines_state::crystal_sound_r()
+{
+ return machine().rand();
+}
+
+//this may be a YMZ280B
+void mpu4crystal_machines_state::crystal_sound_w(uint8_t data)
+{
+ logerror("crystal_sound_w %02x\n",data);
+}
+
+void mpu4crystal_machines_state::init_m_frkstn()
+{
+ address_space &space = m_maincpu->space(AS_PROGRAM);
+ init_m4default();
+ space.install_read_handler(0x0880, 0x0880, read8smo_delegate(*this, FUNC(mpu4crystal_machines_state::crystal_sound_r)));
+ space.install_write_handler(0x0881, 0x0881, write8smo_delegate(*this, FUNC(mpu4crystal_machines_state::crystal_sound_w)));
+}
+
+// thanks to Project Amber for descramble information
+static void descramble_crystal(uint8_t* region, int start, int end, uint8_t extra_xor)
+{
+ for (int i=start;i<end;i++)
+ {
+ uint8_t x = region[i];
+ switch (i & 0x58)
+ {
+ case 0x00: // same as 0x08
+ case 0x08: x = bitswap<8>( x^0xca , 3,2,1,0,7,4,6,5 ); break;
+ case 0x10: x = bitswap<8>( x^0x30 , 3,0,4,6,1,5,7,2 ); break;
+ case 0x18: x = bitswap<8>( x^0x89 , 4,1,2,5,7,0,6,3 ); break;
+ case 0x40: x = bitswap<8>( x^0x14 , 6,1,4,3,2,5,0,7 ); break;
+ case 0x48: x = bitswap<8>( x^0x40 , 1,0,3,2,5,4,7,6 ); break;
+ case 0x50: x = bitswap<8>( x^0xcb , 3,2,1,0,7,6,5,4 ); break;
+ case 0x58: x = bitswap<8>( x^0xc0 , 2,3,6,0,5,1,7,4 ); break;
+ }
+ region[i] = x ^ extra_xor;
+ }
+}
+
+
+void mpu4crystal_machines_state::init_crystal()
+{
+ init_m_frkstn();
+ descramble_crystal(memregion( "maincpu" )->base(), 0x0000, 0x10000, 0x00);
+}
+
+void mpu4crystal_machines_state::init_crystali()
+{
+ init_m_frkstn();
+ descramble_crystal(memregion( "maincpu" )->base(), 0x0000, 0x10000, 0xff); // invert after decrypt?!
+}
+
+
+
#define M4FRKSTN_SOUND \
ROM_REGION( 0x40000, "upd", 0 ) \
ROM_LOAD("fr1snd.bin", 0x00000, 0x40000, CRC(2d77bbde) SHA1(0397ede538e913dc2972e260589022564fcd8fe4) )