1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 #pragma once
4 
5 #ifndef MAME_INCLUDES_POLY880_H
6 #define MAME_INCLUDES_POLY880_H
7 
8 
9 #include "cpu/z80/z80.h"
10 #include "machine/z80daisy.h"
11 #include "imagedev/cassette.h"
12 #include "machine/z80pio.h"
13 #include "machine/z80ctc.h"
14 #include "machine/ram.h"
15 #include "sound/spkrdev.h"
16 #include "speaker.h"
17 
18 #define SCREEN_TAG      "screen"
19 #define Z80_TAG         "i1"
20 #define Z80CTC_TAG      "i4"
21 #define Z80PIO1_TAG     "i2"
22 #define Z80PIO2_TAG     "i3"
23 
24 class poly880_state : public driver_device
25 {
26 public:
poly880_state(const machine_config & mconfig,device_type type,const char * tag)27 	poly880_state(const machine_config &mconfig, device_type type, const char *tag)
28 		: driver_device(mconfig, type, tag)
29 		, m_maincpu(*this, Z80_TAG)
30 		, m_cassette(*this, "cassette")
31 		, m_ki(*this, "KI%u", 1U)
32 		, m_speaker(*this, "speaker")
33 		, m_digits(*this, "digit%u", 0U)
34 		, m_nmi(false)
35 	{ }
36 
37 	void poly880(machine_config &config);
38 
39 	DECLARE_INPUT_CHANGED_MEMBER( trigger_reset );
40 	DECLARE_INPUT_CHANGED_MEMBER( trigger_nmi );
41 
42 private:
43 	required_device<z80_device> m_maincpu;
44 	required_device<cassette_image_device> m_cassette;
45 	required_ioport_array<3> m_ki;
46 	required_device<speaker_sound_device> m_speaker;
47 	output_finder<8> m_digits;
48 
49 	virtual void machine_start() override;
50 
51 	void cldig_w(uint8_t data);
52 	DECLARE_WRITE_LINE_MEMBER( ctc_z0_w );
53 	DECLARE_WRITE_LINE_MEMBER( ctc_z1_w );
54 	void pio1_pa_w(uint8_t data);
55 	uint8_t pio1_pb_r();
56 	void pio1_pb_w(uint8_t data);
57 
58 	void update_display();
59 
60 	/* display state */
61 	uint8_t m_digit;
62 	uint8_t m_segment;
63 	bool m_nmi;
64 	void poly880_io(address_map &map);
65 	void poly880_mem(address_map &map);
66 };
67 
68 #endif
69