1 // license:GPL-2.0+
2 // copyright-holders:Curt Coder,Dirk Best
3 #ifndef MAME_INCLUDES_PX8_H
4 #define MAME_INCLUDES_PX8_H
5 
6 #pragma once
7 
8 
9 #include "cpu/z80/z80.h"
10 #include "cpu/m6800/m6801.h"
11 #include "imagedev/cassette.h"
12 #include "machine/ram.h"
13 #include "machine/i8251.h"
14 #include "bus/epson_sio/pf10.h"
15 #include "emupal.h"
16 
17 #include "bus/generic/slot.h"
18 #include "bus/generic/carts.h"
19 
20 #define UPD70008_TAG    "4a"
21 #define UPD7508_TAG     "2e"
22 #define HD6303_TAG      "13d"
23 #define SED1320_TAG     "7c"
24 #define I8251_TAG       "13e"
25 #define UPD7001_TAG     "1d"
26 #define SCREEN_TAG      "screen"
27 
28 #define PX8_VIDEORAM_MASK   0x17ff
29 
30 class px8_state : public driver_device
31 {
32 public:
px8_state(const machine_config & mconfig,device_type type,const char * tag)33 	px8_state(const machine_config &mconfig, device_type type, const char *tag)
34 		: driver_device(mconfig, type, tag)
35 		, m_maincpu(*this, UPD70008_TAG)
36 		, m_cassette(*this, "cassette")
37 		, m_ram(*this, RAM_TAG)
38 		, m_video_ram(*this, "video_ram")
39 		, m_leds(*this, "led_%u", 0U)
40 	{ }
41 
42 	void px8(machine_config &config);
43 
44 private:
45 	required_device<cpu_device> m_maincpu;
46 	required_device<cassette_image_device> m_cassette;
47 	required_device<ram_device> m_ram;
48 	/* video state */
49 	required_shared_ptr<uint8_t> m_video_ram;         /* LCD video RAM */
50 	output_finder<3> m_leds;
51 
52 	virtual void machine_start() override;
53 	virtual void machine_reset() override;
54 
55 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
56 
57 	uint8_t gah40m_r(offs_t offset);
58 	void gah40m_w(offs_t offset, uint8_t data);
59 	uint8_t gah40s_r(offs_t offset);
60 	void gah40s_w(offs_t offset, uint8_t data);
61 	void gah40s_ier_w(uint8_t data);
62 	uint8_t krtn_0_3_r();
63 	uint8_t krtn_4_7_r();
64 	void ksc_w(uint8_t data);
65 
66 	void bankswitch();
67 	uint8_t krtn_read();
68 
69 	/* GAH40M state */
70 	uint16_t m_icr;               /* input capture register */
71 	uint16_t m_frc;               /* free running counter */
72 	uint8_t m_ier;                /* interrupt acknowledge register */
73 	uint8_t m_isr;                /* interrupt status register */
74 	uint8_t m_sio;                /* serial I/O register */
75 	int m_bank0;                /* */
76 
77 	/* GAH40S state */
78 	uint16_t m_cnt;               /* microcassette tape counter */
79 	int m_swpr;             /* P-ROM power switch */
80 	uint16_t m_pra;               /* P-ROM address */
81 	uint8_t m_prd;                /* P-ROM data */
82 
83 	/* memory state */
84 	int m_bk2;              /* */
85 
86 	/* keyboard state */
87 	int m_ksc;              /* keyboard scan column */
88 	void px8_palette(palette_device &palette) const;
89 	void px8_io(address_map &map);
90 	void px8_mem(address_map &map);
91 	void px8_slave_mem(address_map &map);
92 };
93 
94 #endif
95