1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 #ifndef MAME_INCLUDES_LC80_H
4 #define MAME_INCLUDES_LC80_H
5 
6 #pragma once
7 
8 #include "cpu/z80/z80.h"
9 #include "machine/z80daisy.h"
10 #include "imagedev/cassette.h"
11 #include "machine/ram.h"
12 #include "machine/z80pio.h"
13 #include "machine/z80ctc.h"
14 #include "sound/spkrdev.h"
15 
16 #define SCREEN_TAG      "screen"
17 #define Z80_TAG         "d201"
18 #define Z80CTC_TAG      "d208"
19 #define Z80PIO1_TAG     "d206"
20 #define Z80PIO2_TAG     "d207"
21 //#define SPEAKER_TAG       "b237"
22 
23 class lc80_state : public driver_device
24 {
25 public:
lc80_state(const machine_config & mconfig,device_type type,const char * tag)26 	lc80_state(const machine_config &mconfig, device_type type, const char *tag)
27 		: driver_device(mconfig, type, tag),
28 			m_maincpu(*this, Z80_TAG),
29 			m_pio2(*this, Z80PIO2_TAG),
30 			m_cassette(*this, "cassette"),
31 			m_speaker(*this, "speaker"),
32 			m_ram(*this, RAM_TAG),
33 			m_y(*this, "Y%u", 0U),
34 			m_digits(*this, "digit%u", 0U),
35 			m_out_led(*this, "led0")
36 	{ }
37 
38 	void lc80_2(machine_config &config);
39 	void lc80(machine_config &config);
40 
41 	DECLARE_INPUT_CHANGED_MEMBER( trigger_reset );
42 	DECLARE_INPUT_CHANGED_MEMBER( trigger_nmi );
43 
44 private:
45 	required_device<cpu_device> m_maincpu;
46 	required_device<z80pio_device> m_pio2;
47 	required_device<cassette_image_device> m_cassette;
48 	required_device<speaker_sound_device> m_speaker;
49 	required_device<ram_device> m_ram;
50 	required_ioport_array<4> m_y;
51 	output_finder<6> m_digits;
52 	output_finder<> m_out_led;
53 
54 	virtual void machine_start() override;
55 
56 	DECLARE_WRITE_LINE_MEMBER( ctc_z0_w );
57 	DECLARE_WRITE_LINE_MEMBER( ctc_z1_w );
58 	DECLARE_WRITE_LINE_MEMBER( ctc_z2_w );
59 	void pio1_pa_w(uint8_t data);
60 	uint8_t pio1_pb_r();
61 	void pio1_pb_w(uint8_t data);
62 	uint8_t pio2_pb_r();
63 
64 	void update_display();
65 
66 	// display state
67 	uint8_t m_digit;
68 	uint8_t m_segment;
69 	void lc80_io(address_map &map);
70 	void lc80_mem(address_map &map);
71 	//void lc80e_mem(address_map &map);
72 };
73 
74 #endif // MAME_INCLUDES_LC80_H
75