1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 #ifndef MAME_INCLUDES_VIXEN_H
4 #define MAME_INCLUDES_VIXEN_H
5 
6 #pragma once
7 
8 #include "bus/rs232/rs232.h"
9 #include "cpu/z80/z80.h"
10 #include "imagedev/floppy.h"
11 #include "machine/i8155.h"
12 #include "machine/i8251.h"
13 #include "machine/timer.h"
14 #include "bus/ieee488/ieee488.h"
15 #include "machine/ram.h"
16 #include "machine/wd_fdc.h"
17 #include "sound/discrete.h"
18 #include "emupal.h"
19 
20 #define Z8400A_TAG      "5f"
21 #define FDC1797_TAG     "5n"
22 #define P8155H_TAG      "2n"
23 #define P8155H_IO_TAG   "c7"
24 #define P8251A_TAG      "c3"
25 #define DISCRETE_TAG    "discrete"
26 #define SCREEN_TAG      "screen"
27 #define RS232_TAG       "rs232"
28 
29 class vixen_state : public driver_device
30 {
31 public:
vixen_state(const machine_config & mconfig,device_type type,const char * tag)32 	vixen_state(const machine_config &mconfig, device_type type, const char *tag)
33 		: driver_device(mconfig, type, tag)
34 		, m_maincpu(*this, Z8400A_TAG)
35 		, m_fdc(*this, FDC1797_TAG)
36 		, m_io_i8155(*this, P8155H_IO_TAG)
37 		, m_usart(*this, P8251A_TAG)
38 		, m_discrete(*this, DISCRETE_TAG)
39 		, m_ieee488(*this, IEEE488_TAG)
40 		, m_palette(*this, "palette")
41 		, m_ram(*this, RAM_TAG)
42 		, m_floppy0(*this, FDC1797_TAG":0")
43 		, m_floppy1(*this, FDC1797_TAG":1")
44 		, m_rs232(*this, RS232_TAG)
45 		, m_rom(*this, Z8400A_TAG)
46 		, m_sync_rom(*this, "video")
47 		, m_char_rom(*this, "chargen")
48 		, m_video_ram(*this, "video_ram")
49 		, m_key(*this, "KEY.%u", 0)
50 		, m_cmd_d1(0)
51 		, m_fdint(0)
52 		, m_vsync(0)
53 		, m_srq(1)
54 		, m_atn(1)
55 		, m_rxrdy(0)
56 		, m_txrdy(0)
57 	{ }
58 
59 	void vixen(machine_config &config);
60 
61 	void init_vixen();
62 
63 private:
64 	uint8_t status_r();
65 	void cmd_w(uint8_t data);
66 	uint8_t ieee488_r();
67 	uint8_t port3_r();
68 	uint8_t i8155_pa_r();
69 	void i8155_pb_w(uint8_t data);
70 	void i8155_pc_w(uint8_t data);
71 	void io_i8155_pb_w(uint8_t data);
72 	void io_i8155_pc_w(uint8_t data);
73 	DECLARE_WRITE_LINE_MEMBER( io_i8155_to_w );
74 	DECLARE_WRITE_LINE_MEMBER( srq_w );
75 	DECLARE_WRITE_LINE_MEMBER( atn_w );
76 	DECLARE_WRITE_LINE_MEMBER( rxrdy_w );
77 	DECLARE_WRITE_LINE_MEMBER( txrdy_w );
78 	DECLARE_WRITE_LINE_MEMBER( fdc_intrq_w );
79 	TIMER_DEVICE_CALLBACK_MEMBER(vsync_tick);
80 	IRQ_CALLBACK_MEMBER(vixen_int_ack);
81 	uint8_t opram_r(offs_t offset);
82 	uint8_t oprom_r(offs_t offset);
83 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
84 
85 	void bios_mem(address_map &map);
86 	void vixen_io(address_map &map);
87 	void vixen_mem(address_map &map);
88 
89 	required_device<cpu_device> m_maincpu;
90 	required_device<fd1797_device> m_fdc;
91 	required_device<i8155_device> m_io_i8155;
92 	required_device<i8251_device> m_usart;
93 	required_device<discrete_sound_device> m_discrete;
94 	required_device<ieee488_device> m_ieee488;
95 	required_device<palette_device> m_palette;
96 	required_device<ram_device> m_ram;
97 	required_device<floppy_connector> m_floppy0;
98 	required_device<floppy_connector> m_floppy1;
99 	required_device<rs232_port_device> m_rs232;
100 	required_region_ptr<uint8_t> m_rom;
101 	required_region_ptr<uint8_t> m_sync_rom;
102 	required_region_ptr<uint8_t> m_char_rom;
103 	required_shared_ptr<uint8_t> m_video_ram;
104 	required_ioport_array<8> m_key;
105 
106 	address_space *m_program;
107 
108 	virtual void machine_start() override;
109 	virtual void machine_reset() override;
110 
111 	void update_interrupt();
112 
113 	// keyboard state
114 	uint8_t m_col;
115 
116 	// interrupt state
117 	int m_cmd_d0;
118 	int m_cmd_d1;
119 
120 	bool m_fdint;
121 	int m_vsync;
122 
123 	int m_srq;
124 	int m_atn;
125 	int m_enb_srq_int;
126 	int m_enb_atn_int;
127 
128 	int m_rxrdy;
129 	int m_txrdy;
130 	int m_int_clk;
131 	int m_enb_xmt_int;
132 	int m_enb_rcv_int;
133 	int m_enb_ring_int;
134 
135 	// video state
136 	bool m_alt;
137 	bool m_256;
138 };
139 
140 #endif // MAME_INCLUDES_VIXEN_H
141