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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
// license:BSD-3-Clause
// copyright-holders:Sandro Ronco
/**********************************************************************
Hegener + Glaser Mephisto Sensors Board, for modular chesscomputers
- Modular
- Muenchen
- Exclusive
This device can also apply to non-modular boards if I/O is similar
Bavaria board is not emulated here, additional handlers for it are in the driver.
*********************************************************************/
#include "emu.h"
#include "mmboard.h"
DEFINE_DEVICE_TYPE(MEPHISTO_SENSORS_BOARD, mephisto_sensors_board_device, "msboard", "Mephisto Sensors Board")
DEFINE_DEVICE_TYPE(MEPHISTO_BUTTONS_BOARD, mephisto_buttons_board_device, "mbboard", "Mephisto Buttons Board")
//-------------------------------------------------
// constructor
//-------------------------------------------------
mephisto_board_device::mephisto_board_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, type, tag, owner, clock)
, m_board(*this, "board")
, m_led_pwm(*this, "led_pwm")
, m_led_out(*this, "led%u", 0U)
, m_sensordelay(attotime::from_msec(150))
, m_disable_leds(false)
{
}
mephisto_sensors_board_device::mephisto_sensors_board_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: mephisto_board_device(mconfig, MEPHISTO_SENSORS_BOARD, tag, owner, clock)
{
}
mephisto_buttons_board_device::mephisto_buttons_board_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: mephisto_board_device(mconfig, MEPHISTO_BUTTONS_BOARD, tag, owner, clock)
{
}
//-------------------------------------------------
// device_add_mconfig
//-------------------------------------------------
void mephisto_sensors_board_device::device_add_mconfig(machine_config &config)
{
set_config(config, sensorboard_device::MAGNETS);
}
void mephisto_buttons_board_device::device_add_mconfig(machine_config &config)
{
set_config(config, sensorboard_device::BUTTONS);
}
void mephisto_board_device::set_config(machine_config &config, sensorboard_device::sb_type board_type)
{
SENSORBOARD(config, m_board).set_type(board_type);
m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess));
PWM_DISPLAY(config, m_led_pwm).set_size(8, 8);
m_led_pwm->output_x().set(FUNC(mephisto_board_device::refresh_leds_w));
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void mephisto_board_device::device_start()
{
m_led_out.resolve();
m_mux = 0xff;
m_led_data = 0;
save_item(NAME(m_mux));
save_item(NAME(m_led_data));
m_board->set_delay(m_sensordelay);
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void mephisto_board_device::device_reset()
{
m_mux = 0xff;
m_led_data = 0x00;
update_led_pwm();
}
//-------------------------------------------------
// I/O handlers
//-------------------------------------------------
void mephisto_board_device::refresh_leds_w(offs_t offset, u8 data)
{
if (!m_disable_leds)
m_led_out[(offset >> 6 & 7) | (offset & 7) << 3] = data;
}
u8 mephisto_board_device::input_r()
{
u8 data = 0xff;
for (int i = 0; i < 8; i++)
if (!BIT(m_mux, i))
data &= ~m_board->read_rank(i);
return data;
}
u8 mephisto_board_device::mux_r()
{
return m_mux;
}
void mephisto_board_device::mux_w(u8 data)
{
m_mux = data;
update_led_pwm();
}
void mephisto_board_device::led_w(u8 data)
{
m_led_data = data;
update_led_pwm();
}
|