1 // license:BSD-3-Clause
2 // copyright-holders:Paul Daniels
3 /*****************************************************************************
4  *
5  * includes/p2000t.h
6  *
7  ****************************************************************************/
8 
9 #ifndef MAME_INCLUDES_P2000T_H
10 #define MAME_INCLUDES_P2000T_H
11 
12 #pragma once
13 
14 #include "cpu/z80/z80.h"
15 #include "sound/spkrdev.h"
16 #include "video/saa5050.h"
17 #include "machine/p2000t_mdcr.h"
18 #include "machine/ram.h"
19 #include "emupal.h"
20 
21 
22 class p2000t_state : public driver_device
23 {
24 public:
p2000t_state(const machine_config & mconfig,device_type type,const char * tag)25 	p2000t_state(const machine_config &mconfig, device_type type, const char *tag)
26 		: driver_device(mconfig, type, tag)
27 		, m_videoram(*this, "videoram")
28 		, m_maincpu(*this, "maincpu")
29 		, m_speaker(*this, "speaker")
30 		, m_mdcr(*this, "mdcr")
31 		, m_ram(*this, RAM_TAG)
32 		, m_bank(*this, "bank")
33 		, m_keyboard(*this, "KEY.%u", 0)
34 	{
35 	}
36 
37 	void p2000t(machine_config &config);
38 
39 protected:
40 	uint8_t p2000t_port_000f_r(offs_t offset);
41 	uint8_t p2000t_port_202f_r();
42 	void p2000t_port_101f_w(uint8_t data);
43 	void p2000t_port_303f_w(uint8_t data);
44 	void p2000t_port_505f_w(uint8_t data);
45 	void p2000t_port_707f_w(uint8_t data);
46 	void p2000t_port_888b_w(uint8_t data);
47 	void p2000t_port_8c90_w(uint8_t data);
48 	void p2000t_port_9494_w(uint8_t data);
49 	uint8_t videoram_r(offs_t offset);
50 	virtual void machine_start() override;
51 
52 	INTERRUPT_GEN_MEMBER(p2000_interrupt);
53 
54 	void p2000t_mem(address_map &map);
55 	void p2000t_io(address_map &map);
56 
57 	required_shared_ptr<uint8_t> m_videoram;
58 
59 	required_device<cpu_device> m_maincpu;
60 	required_device<speaker_sound_device> m_speaker;
61 	required_device<mdcr_device> m_mdcr;
62 	required_device<ram_device> m_ram;
63 	required_memory_bank m_bank;
64 
65 private:
66 	required_ioport_array<10> m_keyboard;
67 	uint8_t m_port_101f;
68 	uint8_t m_port_202f;
69 	uint8_t m_port_303f;
70 	uint8_t m_port_707f;
71 };
72 
73 class p2000m_state : public p2000t_state
74 {
75 public:
p2000m_state(const machine_config & mconfig,device_type type,const char * tag)76 	p2000m_state(const machine_config &mconfig, device_type type, const char *tag)
77 		: p2000t_state(mconfig, type, tag)
78 		, m_gfxdecode(*this, "gfxdecode")
79 		, m_palette(*this, "palette")
80 	{
81 	}
82 
83 	void p2000m(machine_config &config);
84 
85 protected:
86 	virtual void video_start() override;
87 	void p2000m_palette(palette_device &palette) const;
88 	uint32_t screen_update_p2000m(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
89 
90 	void p2000m_mem(address_map &map);
91 
92 private:
93 	required_device<gfxdecode_device> m_gfxdecode;
94 	required_device<palette_device> m_palette;
95 
96 	int8_t m_frame_count;
97 };
98 
99 #endif // MAME_INCLUDES_P2000T_H
100