1 // license:BSD-3-Clause
2 // copyright-holders: Joakim Larsson Edström
3 #ifndef MAME_BUS_ISA_EIS_HGB107X_H
4 #define MAME_BUS_ISA_EIS_HGB107X_H
5 
6 #pragma once
7 
8 #include "isa.h"
9 #include "video/mc6845.h"
10 #include "emupal.h"
11 #include "screen.h"
12 
13 //**************************************************************************
14 //  TYPE DEFINITIONS
15 //**************************************************************************
16 
17 class isa8_epc_mda_device : public device_t, public device_isa8_card_interface
18 {
19 public:
20 	// construction/destruction
21 	isa8_epc_mda_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
22 
23 	uint8_t io_read(offs_t offset);
24 	void io_write(offs_t offset, uint8_t data);
25 	uint8_t status_r();
26 	void mode_control_w(uint8_t data);
27 	DECLARE_WRITE_LINE_MEMBER(hsync_changed);
28 	DECLARE_WRITE_LINE_MEMBER(vsync_changed);
29 
30 	/* Monitor */
31 	DECLARE_INPUT_CHANGED_MEMBER(monitor_changed);
32 
33 protected:
34 	isa8_epc_mda_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
35 
36 	// device-level overrides
37 	virtual void device_start() override;
38 	virtual void device_reset() override;
39 
40 	// optional information overrides
41 	virtual void device_add_mconfig(machine_config &config) override;
42 	virtual const tiny_rom_entry *device_rom_region() const override;
43 	virtual ioport_constructor device_input_ports() const override;
44 
45 private:
46 	inline int get_xres();
47 	inline int get_yres();
48 
49 	enum {
50 		VM_COLS80 = 0x01,
51 		VM_GRAPH  = 0x02,
52 		VM_HOR640 = 0x04,
53 		VM_MONO   = 0x08,
54 		VM_VER400 = 0x10
55 	};
56 
57 	enum {
58 		MR1_COLS80 = 0x01,
59 		MR1_GRAPH = 0x02,
60 		MR1_VIDEO = 0x08,
61 		MR1_HOR640 = 0x10,
62 		MR1_BLINK = 0x20
63 	};
64 
65 	enum {
66 		MR2_COLEMU = 0x04,
67 		MR2_CHRSET = 0x40,
68 		MR2_VER400 = 0x80
69 	};
70 
71 	enum {
72 		ATTR_BLINK = 0x80,
73 		ATTR_BACKG = 0x70,
74 		ATTR_INTEN = 0x08,
75 		ATTR_FOREG = 0x07,
76 		ATTR_ULINE = 0x01,
77 	};
78 
79 	required_device<mc6845_device> m_crtc;
80 	MC6845_UPDATE_ROW( crtc_update_row );
81 
82 	std::unique_ptr<uint8_t[]>   m_soft_chr_gen;
83 	required_ioport m_s1;
84 	uint8_t m_color_mode;
85 	uint8_t m_mode_control2;
86 	required_device<screen_device> m_screen;
87 	required_ioport m_io_monitor;
88 	required_region_ptr<uint8_t> m_chargen;
89 
90 	uint8_t m_vmode;
91 	rgb_t (*m_pal)[4];
92 	rgb_t m_3111_pal[4];
93 	rgb_t m_371x_pal[4];
94 	bool m_installed;
95 	hd6845s_device *m_hd6845s;
96 public:
97 	int m_framecnt;
98 
99 	uint8_t   m_mode_control;
100 
101 	int     m_update_row_type;
102 	uint8_t   *m_chr_gen;
103 	uint8_t   m_vsync;
104 	uint8_t   m_hsync;
105 	std::vector<uint8_t> m_videoram;
106 	uint8_t   m_pixel;
107 };
108 
109 // device type definition
110 DECLARE_DEVICE_TYPE(ISA8_EPC_MDA, isa8_epc_mda_device)
111 
112 #endif // MAME_BUS_ISA_EIS_HGB107X_H
113