summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/atarixga.h
diff options
context:
space:
mode:
author Phil Bennett <p.j.bennett@gmail.com>2016-10-26 11:29:07 -0700
committer Phil Bennett <p.j.bennett@gmail.com>2016-10-26 11:29:07 -0700
commite6d92ba43c9ce9de15af484ccf0326e2ec0024cf (patch)
treebceb674cb0b932913ea7cd41884d09cf98510657 /src/mame/machine/atarixga.h
parent777be34dfe86e6329e62bfb3411796f501d1edeb (diff)
- Reverse-engineered Space Lords security FPGA and implemented decryption code [Morten Shearman Kirkegaard, Samuel Neves, Peter Wilhelmsen]
New games added or promoted from NOT_WORKING status Space Lords [Morten Shearman Kirkegaard, Samuel Neves, Peter Wilhelmsen]
Diffstat (limited to 'src/mame/machine/atarixga.h')
-rw-r--r--src/mame/machine/atarixga.h81
1 files changed, 69 insertions, 12 deletions
diff --git a/src/mame/machine/atarixga.h b/src/mame/machine/atarixga.h
index 933cf68fce7..ddd920c5a5c 100644
--- a/src/mame/machine/atarixga.h
+++ b/src/mame/machine/atarixga.h
@@ -4,30 +4,54 @@
atarixga.h
- Atari XGA encryption FPGA
+ Atari XGA encryption FPGAs
*************************************************************************/
#ifndef __MACHINE_ATARIXGA__
#define __MACHINE_ATARIXGA__
-extern const device_type ATARI_XGA;
+extern const device_type ATARI_136094_0072;
+extern const device_type ATARI_136095_0072;
-class atari_xga_device : public device_t
+class atari_xga_device : public device_t
{
public:
// construction/destruction
- atari_xga_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ atari_xga_device(const machine_config &mconfig, device_type type, const char *tag,
+ device_t *owner, uint32_t clock, const char *name, const char *shortname)
+ : device_t(mconfig, type, name, tag, owner, clock, shortname, __FILE__)
+ {}
- DECLARE_WRITE32_MEMBER(write);
- DECLARE_READ32_MEMBER(read);
+ virtual DECLARE_WRITE32_MEMBER(write) = 0;
+ virtual DECLARE_READ32_MEMBER(read) = 0;
protected:
+ virtual void device_start() = 0;
+ virtual void device_reset() = 0;
+
+ std::unique_ptr<uint16_t[]> m_ram; // CY7C185-45PC, only 16-Kbit used
+};
+
+class atari_136094_0072_device : public atari_xga_device
+{
+public:
+ atari_136094_0072_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual DECLARE_WRITE32_MEMBER(write) override;
+ virtual DECLARE_READ32_MEMBER(read) override;
+
+protected:
virtual void device_start() override;
virtual void device_reset() override;
private:
static const size_t RAM_WORDS = 2048;
+
+ uint16_t powers2(uint8_t k, uint16_t x);
+ uint16_t lfsr2(uint16_t x);
+ uint16_t lfsr1(uint16_t x);
+ uint16_t decipher(uint8_t k, uint16_t c);
enum fpga_mode
{
@@ -35,19 +59,52 @@ private:
FPGA_SETKEY,
FPGA_DECIPHER
};
+
+ fpga_mode m_mode;
+ uint16_t m_address; // last written address
+ uint16_t m_ciphertext; // last written ciphertext
+};
+class atari_136095_0072_device : public atari_xga_device
+{
+public:
+ atari_136095_0072_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ DECLARE_WRITE32_MEMBER(polylsb_write);
+ DECLARE_READ32_MEMBER(polylsb_read);
+
+ virtual DECLARE_WRITE32_MEMBER(write) override;
+ virtual DECLARE_READ32_MEMBER(read) override;
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+private:
+ static const size_t RAM_WORDS = 4096;
+
uint16_t powers2(uint8_t k, uint16_t x);
uint16_t lfsr2(uint16_t x);
uint16_t lfsr1(uint16_t x);
- uint16_t parity(uint16_t x);
- size_t popcount(uint16_t x);
- uint16_t ctz(uint16_t x);
uint16_t decipher(uint8_t k, uint16_t c);
+ enum fpga_mode
+ {
+ FPGA_SETKEY,
+ FPGA_DECIPHER,
+ FPGA_PROCESS,
+ FPGA_RESULT
+ };
+
+ struct
+ {
+ uint16_t addr;
+ uint32_t data[64];
+ } m_update;
+
fpga_mode m_mode;
- uint16_t m_address; // last written address
- uint16_t m_ciphertext; // last written ciphertext
- std::unique_ptr<uint16_t[]> m_ram; // CY7C185-45PC, only 16-Kbit used
+ uint8_t m_poly_lsb;
+ uint16_t m_reply;
};