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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// license:BSD-3-Clause
// copyright-holders:David Haywood
#ifndef MAME_MACHINE_SEC_H
#define MAME_MACHINE_SEC_H
#pragma once
#include "emu.h"
/* commands */
enum
{
SEC_REQUEST_STATUS = 0x20,
SEC_REQUEST_MARKET = 0x21,
SEC_REQEUST_LAST_ERROR = 0x22,
SEC_REQUEST_VERSION = 0x23,
SEC_REQUEST_COUNT_VAL = 0x24,
SEC_REQUEST_LAST_CMD = 0x25,
SEC_REQUEST_FINGERPRNT = 0x26,
SEC_SET_NUM_COUNTERS = 0x30,
SEC_SET_MARKET = 0x31,
SEC_SET_COUNTER_TXT = 0x32,
SEC_SHOW_TEXT = 0x40,
SEC_SHOW_COUNTER_VAL = 0x41,
SEC_SHOW_COUNTER_TXT = 0x42,
SEC_SHOW_BITPATTERN = 0x43,
SEC_COUNT_INC_SMALL = 0x50,
SEC_COUNT_INC_MED = 0x51,
SEC_COUNT_INC_LARGE = 0x52,
SEC_COUNT_CYCLE_DISP = 0x54,
SEC_STOP_CYCLE = 0x55,
SEC_SELF_TEST = 0x5c,
SEC_DAT = 0x60,
SEC_ACK = 0x61
};
class sec_device : public device_t
{
public:
// construction/destruction
sec_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
/* serial interface */
DECLARE_WRITE_LINE_MEMBER(clk_w);
DECLARE_WRITE_LINE_MEMBER(data_w);
DECLARE_WRITE_LINE_MEMBER(cs_w);
int data_r();
protected:
virtual void device_start() override;
virtual void device_reset() override;
private:
static const size_t MAX_COUNTERS = 32;
// stuff the SEC stores
int m_counters[MAX_COUNTERS]{};
char m_strings[MAX_COUNTERS][8]{};
uint8_t m_market = 0;
uint8_t m_nocnt = 0;
uint8_t m_last = 0;
// serial comms
uint8_t m_curbyte = 0;
uint8_t m_data = 0;
uint8_t m_clk = 0;
uint8_t m_clks = 0;
uint8_t m_rxpos = 0;
uint8_t m_rxclk = 0;
uint8_t m_rxdat = 0;
uint8_t m_rxlen = 0;
uint8_t m_chars_left = 0;
uint8_t m_reqpos = 0;
// communication buffer
uint8_t m_request[12]{};
uint8_t m_reply[8]{};
bool m_enabled = false;
// execute command
void do_command(void);
// command handlers
void cmd_nop(void);
void cmd_set_txt(void);
void cmd_inc_sml(void);
void cmd_inc_med(void);
void cmd_inc_lrg(void);
void cmd_set_ncn(void);
void cmd_set_mrk(void);
void cmd_get_sta(void);
void cmd_get_mrk(void);
void cmd_get_err(void);
void cmd_get_fpr(void);
void cmd_get_lst(void);
void cmd_get_ver(void);
void cmd_get_cnt(void);
uint8_t calc_byte_sum(int length);
};
DECLARE_DEVICE_TYPE(SEC, sec_device)
#endif // MAME_MACHINE_SEC_H
|