1 // license:BSD-3-Clause
2 // copyright-holders:hap
3 /*
4 
5   TMS1000 MCU series tabletops/handhelds or other simple devices.
6 
7 */
8 
9 #ifndef MAME_INCLUDES_HH_TMS1K_H
10 #define MAME_INCLUDES_HH_TMS1K_H
11 
12 #pragma once
13 
14 #include "cpu/tms1000/tms1000.h"
15 #include "cpu/tms1000/tms1000c.h"
16 #include "cpu/tms1000/tms1100.h"
17 #include "cpu/tms1000/tms1400.h"
18 #include "cpu/tms1000/tms0970.h"
19 #include "cpu/tms1000/tms0980.h"
20 #include "cpu/tms1000/tms0270.h"
21 #include "cpu/tms1000/tp0320.h"
22 #include "video/pwm.h"
23 #include "sound/spkrdev.h"
24 
25 
26 class hh_tms1k_state : public driver_device
27 {
28 public:
hh_tms1k_state(const machine_config & mconfig,device_type type,const char * tag)29 	hh_tms1k_state(const machine_config &mconfig, device_type type, const char *tag) :
30 		driver_device(mconfig, type, tag),
31 		m_maincpu(*this, "maincpu"),
32 		m_display(*this, "display"),
33 		m_speaker(*this, "speaker"),
34 		m_inputs(*this, "IN.%u", 0),
35 		m_out_power(*this, "power")
36 	{ }
37 
38 	// devices
39 	required_device<tms1k_base_device> m_maincpu;
40 	optional_device<pwm_display_device> m_display;
41 	optional_device<speaker_sound_device> m_speaker;
42 	optional_ioport_array<18> m_inputs; // max 18
43 	output_finder<> m_out_power; // power state, eg. led
44 
45 	// misc common
46 	u16 m_r;                        // MCU R-pins data
47 	u16 m_o;                        // MCU O-pins data
48 	u32 m_inp_mux;                  // multiplexed inputs mask
49 	bool m_power_on;
50 
51 	u32 m_grid;                     // VFD/LED current row data
52 	u32 m_plate;                    // VFD/LED current column data
53 
54 	u8 read_inputs(int columns);
55 	u8 read_rotated_inputs(int columns, u8 rowmask = 0xf);
56 	virtual DECLARE_INPUT_CHANGED_MEMBER(reset_button);
57 	virtual DECLARE_INPUT_CHANGED_MEMBER(power_button);
58 	virtual DECLARE_WRITE_LINE_MEMBER(auto_power_off);
59 	virtual void power_off();
60 	void set_power(bool state);
61 
62 	void switch_change(int sel, u32 mask, bool next);
DECLARE_INPUT_CHANGED_MEMBER(switch_next)63 	template<int Sel> DECLARE_INPUT_CHANGED_MEMBER(switch_next) { if (newval) switch_change(Sel, param, true); }
DECLARE_INPUT_CHANGED_MEMBER(switch_prev)64 	template<int Sel> DECLARE_INPUT_CHANGED_MEMBER(switch_prev) { if (newval) switch_change(Sel, param, false); }
65 
66 protected:
67 	virtual void machine_start() override;
68 	virtual void machine_reset() override;
69 };
70 
71 
72 #endif // MAME_INCLUDES_HH_TMS1K_H
73