summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/atarixga.h
diff options
context:
space:
mode:
author Phil Bennett <p.j.bennett@gmail.com>2016-06-13 09:10:46 -0700
committer Phil Bennett <p.j.bennett@gmail.com>2016-06-13 09:10:46 -0700
commit1c684345f338d3453af99f5ce9309b7dddf29b8d (patch)
treed22cdd296f225e3c6dff45ce308f9506a63acfee /src/mame/machine/atarixga.h
parentd881a058e41717b11f1d3323c2f5ab41a1dfa0bb (diff)
- Reverse-engineered Moto Frenzy security FPGA and implemented decryption code [Morten Shearman Kirkegaard, Samuel Neves, Peter Wilhelmsen]
New games added or promoted from NOT_WORKING status Moto Frenzy [Morten Shearman Kirkegaard, Samuel Neves, Peter Wilhelmsen]
Diffstat (limited to 'src/mame/machine/atarixga.h')
-rw-r--r--src/mame/machine/atarixga.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/mame/machine/atarixga.h b/src/mame/machine/atarixga.h
new file mode 100644
index 00000000000..710aedb22c2
--- /dev/null
+++ b/src/mame/machine/atarixga.h
@@ -0,0 +1,54 @@
+// license:BSD-3-Clause
+// copyright-holders:Morten Shearman Kirkegaard, Samuel Neves, Peter Wilhelmsen
+/*************************************************************************
+
+ atarixga.h
+
+ Atari XGA encryption FPGA
+
+*************************************************************************/
+
+#ifndef __MACHINE_ATARIXGA__
+#define __MACHINE_ATARIXGA__
+
+extern const device_type ATARI_XGA;
+
+class atari_xga_device : public device_t
+{
+public:
+ // construction/destruction
+ atari_xga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ DECLARE_WRITE32_MEMBER(write);
+ DECLARE_READ32_MEMBER(read);
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+private:
+ static const size_t RAM_WORDS = 2048;
+
+ enum fpga_mode
+ {
+ FPGA_RESET,
+ FPGA_SETKEY,
+ FPGA_DECIPHER
+ };
+
+ UINT16 powers2(UINT8 k, UINT16 x);
+ UINT16 lfsr2(UINT16 x);
+ UINT16 lfsr1(UINT16 x);
+ UINT16 parity(UINT16 x);
+ size_t popcount(UINT16 x);
+ UINT16 ctz(UINT16 x);
+ UINT16 decipher(UINT8 k, UINT16 c);
+
+ fpga_mode m_mode;
+ UINT16 m_address; // last written address
+ UINT16 m_ciphertext; // last written ciphertext
+ std::unique_ptr<UINT16[]> m_ram; // CY7C185-45PC, only 16-Kbit used
+};
+
+
+#endif