summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/igs036crypt.h
blob: c4d559f48d0263d830e626273b1a26b99c5da93b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// license:BSD-3-Clause
// copyright-holders:Andreas Naive,David Haywood
#ifndef _IGS036CRYPT_H_
#define _IGS036CRYPT_H_

#include "emu.h"

class igs036_decryptor
{
public:
	igs036_decryptor(const uint16_t* game_key);
	void decrypter_rom(memory_region* region);
	uint16_t decrypt(uint16_t cipherword, int word_address)const;
	uint16_t deobfuscate(uint16_t cipherword, int word_address)const;

private:
	const uint16_t* key;

	static int (*rot_enabling[16][4])(int);
	static int (*rot_direction[4][8])(int);
	static const uint16_t triggers[16][2];

	int rotation(int address)const;
	uint16_t rol(uint16_t num, int shift)const;
	int rot_enabled(int address, const int* group)const ;
	int rot_group(int address, const int* group)const;
};

extern const uint16_t  orleg2_key[0x100];
extern const uint16_t  m312cn_key[0x100];
extern const uint16_t cjddzsp_key[0x100];
extern const uint16_t   cjdh2_key[0x100];
extern const uint16_t    kov3_key[0x100];
extern const uint16_t    kov2_key[0x100];
extern const uint16_t  ddpdoj_key[0x100];

#endif