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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert,Andreas Naive
#ifndef _AWBOARD_H_
#define _AWBOARD_H_
#include "naomig1.h"
#define MCFG_AW_ROM_BOARD_ADD(_tag, _keyregion, _irq_cb) \
MCFG_NAOMI_G1_ADD(_tag, AW_ROM_BOARD, _irq_cb) \
aw_rom_board::static_set_keyregion(*device, "^" _keyregion);
class aw_rom_board : public naomi_g1_device
{
public:
aw_rom_board(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
static void static_set_keyregion(device_t &device, const char *keyregion);
DECLARE_ADDRESS_MAP(submap, 16);
DECLARE_WRITE16_MEMBER(epr_offsetl_w); // 5f7000
DECLARE_WRITE16_MEMBER(epr_offseth_w); // 5f7004
DECLARE_WRITE16_MEMBER(mpr_record_index_w); // 5f700c
DECLARE_WRITE16_MEMBER(mpr_first_file_index_w); // 5f7010
DECLARE_WRITE16_MEMBER(mpr_file_offsetl_w); // 5f7014
DECLARE_WRITE16_MEMBER(mpr_file_offseth_w); // 5f7018
DECLARE_READ16_MEMBER(pio_r); // 5f7080
DECLARE_WRITE16_MEMBER(pio_w); // 5f7080
protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void dma_get_position(uint8_t *&base, uint32_t &limit, bool to_mainram) override;
virtual void dma_advance(uint32_t size) override;
private:
enum { EPR, MPR_RECORD, MPR_FILE };
required_memory_region m_region;
optional_memory_region m_keyregion;
uint32_t rombd_key;
uint32_t mpr_offset, mpr_bank;
uint32_t epr_offset, mpr_file_offset;
uint16_t mpr_record_index, mpr_first_file_index;
uint16_t decrypted_buf[16];
uint32_t dma_offset, dma_limit;
struct sbox_set {
uint8_t S0[32];
uint8_t S1[16];
uint8_t S2[16];
uint8_t S3[8];
};
static const int permutation_table[4][16];
static const sbox_set sboxes_table[4];
static uint16_t decrypt(uint16_t cipherText, uint32_t address, const uint32_t key);
uint16_t decrypt16(uint32_t address) { return decrypt(m_region->u16(address), address, rombd_key); }
void set_key();
void recalc_dma_offset(int mode);
};
extern const device_type AW_ROM_BOARD;
#endif
|