summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/mmboard.h
blob: b0c612a2681c4269db6503845fe3f98ce138dd7f (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
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
138
139
140
// license:BSD-3-Clause
// copyright-holders:Sandro Ronco
/**********************************************************************

    Mephisto Modular

*********************************************************************/

#ifndef MAME_MACHINE_MMBOARD_H
#define MAME_MACHINE_MMBOARD_H

#pragma once


#include "sound/beep.h"
#include "video/hd44780.h"
#include "screen.h"
#include "speaker.h"


//**************************************************************************
//  INTERFACE CONFIGURATION MACROS
//**************************************************************************

#define MCFG_MEPHISTO_SENSORS_BOARD_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, MEPHISTO_SENSORS_BOARD, 0) \

#define MCFG_MEPHISTO_BUTTONS_BOARD_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, MEPHISTO_BUTTONS_BOARD, 0) \

#define MCFG_MEPHISTO_BOARD_DISABLE_LEDS(_val) \
	downcast<mephisto_board_device &>(*device).set_disable_leds(_val);

#define MCFG_MEPHISTO_DISPLAY_MODUL_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, MEPHISTO_DISPLAY_MODUL, 0)


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> mephisto_board_device

class mephisto_board_device : public device_t
{
public:
	// construction/destruction
	mephisto_board_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);

	// configuration helpers
	void set_disable_leds(int _disable_leds) { m_disable_leds = _disable_leds; }

	DECLARE_READ8_MEMBER(input_r);
	DECLARE_WRITE8_MEMBER(led_w);
	DECLARE_READ8_MEMBER(mux_r);
	DECLARE_WRITE8_MEMBER(mux_w);

	TIMER_CALLBACK_MEMBER(leds_update_callback);
	TIMER_CALLBACK_MEMBER(leds_refresh_callback);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	required_ioport_array<8> m_sensors;
	output_finder<256> m_led;
	emu_timer *              m_leds_update_timer;
	emu_timer *              m_leds_refresh_timer;
	bool                     m_disable_leds;
	uint8_t                  m_mux;
	uint8_t                  m_leds;
	uint8_t                  m_leds_state[64];
};

// ======================> mephisto_sensors_board_device

class mephisto_sensors_board_device : public mephisto_board_device
{
public:
	// construction/destruction
	mephisto_sensors_board_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

protected:

	// optional information overrides
	virtual ioport_constructor device_input_ports() const override;
};


// ======================> mephisto_buttons_board_device

class mephisto_buttons_board_device : public mephisto_board_device
{
public:
	// construction/destruction
	mephisto_buttons_board_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

protected:

	// optional information overrides
	virtual ioport_constructor device_input_ports() const override;
};


// ======================> mephisto_display_modul_device

class mephisto_display_modul_device : public device_t
{
public:
	// construction/destruction
	mephisto_display_modul_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	DECLARE_WRITE8_MEMBER(latch_w);
	DECLARE_WRITE8_MEMBER(io_w);

	DECLARE_PALETTE_INIT(lcd_palette);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void device_add_mconfig(machine_config &config) override;

private:
	optional_device<hd44780_device> m_lcdc;
	required_device<beep_device> m_beeper;
	uint8_t m_latch;
	uint8_t m_ctrl;
};


// device type definition
DECLARE_DEVICE_TYPE(MEPHISTO_SENSORS_BOARD, mephisto_sensors_board_device)
DECLARE_DEVICE_TYPE(MEPHISTO_BUTTONS_BOARD, mephisto_buttons_board_device)
DECLARE_DEVICE_TYPE(MEPHISTO_DISPLAY_MODUL, mephisto_display_modul_device)


#endif // MAME_MACHINE_MMBOARD_H