1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 
4 #ifndef MAME_INCLUDES_HUEBLER_H
5 #define MAME_INCLUDES_HUEBLER_H
6 
7 #define SCREEN_TAG      "screen"
8 #define Z80_TAG         "z80"
9 #define Z80CTC_TAG      "z80ctc"
10 #define Z80SIO_TAG      "z80sio"
11 #define Z80PIO1_TAG     "z80pio1"
12 #define Z80PIO2_TAG     "z80pio2"
13 
14 #include "cpu/z80/z80.h"
15 #include "machine/z80daisy.h"
16 #include "imagedev/cassette.h"
17 #include "machine/ram.h"
18 #include "machine/timer.h"
19 #include "machine/z80pio.h"
20 #include "machine/z80sio.h"
21 #include "machine/z80ctc.h"
22 #include "emupal.h"
23 
24 class amu880_state : public driver_device
25 {
26 public:
amu880_state(const machine_config & mconfig,device_type type,const char * tag)27 	amu880_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_sio(*this, Z80SIO_TAG)
32 		, m_palette(*this, "palette")
33 		, m_kb_rom(*this, "keyboard")
34 		, m_char_rom(*this, "chargen")
35 		, m_video_ram(*this, "video_ram")
36 		, m_key_row(*this, "Y%u", 0)
37 		, m_special(*this, "SPECIAL")
38 		, m_key_d6(0)
39 		, m_key_d7(0)
40 		, m_key_a8(1)
41 	{ }
42 
43 	void amu880(machine_config &config);
44 
45 protected:
46 	virtual void machine_start() override;
machine_reset()47 	virtual void machine_reset() override { m_maincpu->set_pc(0xf000); }
48 
49 private:
50 	required_device<z80_device> m_maincpu;
51 	required_device<cassette_image_device> m_cassette;
52 	required_device<z80sio_device> m_sio;
53 	required_device<palette_device> m_palette;
54 	required_memory_region m_kb_rom;
55 	required_memory_region m_char_rom;
56 	required_shared_ptr<uint8_t> m_video_ram;
57 	required_ioport_array<16> m_key_row;
58 	required_ioport m_special;
59 
60 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
61 
62 	uint8_t keyboard_r(offs_t offset);
63 
64 	void scan_keyboard();
65 
66 	// keyboard state
67 	int m_key_d6;
68 	int m_key_d7;
69 	int m_key_a4;
70 	int m_key_a5;
71 	int m_key_a8;
72 
73 	// video state
74 	TIMER_DEVICE_CALLBACK_MEMBER(keyboard_tick);
75 	DECLARE_WRITE_LINE_MEMBER(ctc_z0_w);
76 	DECLARE_WRITE_LINE_MEMBER(ctc_z2_w);
77 	DECLARE_WRITE_LINE_MEMBER(cassette_w);
78 	void amu880_io(address_map &map);
79 	void amu880_mem(address_map &map);
80 
81 	// cassette variables
82 	u8 m_cnt;
83 	bool m_cassbit;
84 };
85 
86 #endif
87