1 // license:BSD-3-Clause
2 // copyright-holders:Philip Bennett
3 /***************************************************************************
4 
5     JPM IMPACT with Video hardware
6 
7 ****************************************************************************/
8 #include "machine/meters.h"
9 #include "machine/roc10937.h"
10 #include "machine/steppers.h"
11 #include "machine/timer.h"
12 #include "cpu/tms34010/tms34010.h"
13 #include "sound/upd7759.h"
14 #include "emupal.h"
15 
16 struct duart_t
17 {
18 	uint8_t MR1A, MR2A;
19 	uint8_t SRA, CSRA;
20 	uint8_t CRA;
21 	uint8_t RBA, TBA;
22 
23 	uint8_t IPCR;
24 	uint8_t ACR;
25 	uint8_t ISR, IMR;
26 
27 	union
28 	{
29 		uint8_t CUR, CLR;
30 		uint16_t CR;
31 	};
32 	union
33 	{
34 		uint8_t CTUR, CTLR;
35 		uint16_t CT;
36 	};
37 
38 	int tc;
39 
40 	uint8_t MR1B, MR2B;
41 	uint8_t SRB, CSRB;
42 	uint8_t CRB;
43 	uint8_t RBB, TBB;
44 
45 	uint8_t IVR;
46 	uint8_t IP;
47 	uint8_t OP;
48 	uint8_t OPR;
49 	uint8_t OPCR;
50 };
51 
52 struct bt477_t
53 {
54 	uint8_t address;
55 	uint8_t addr_cnt;
56 	uint8_t pixmask;
57 	uint8_t command;
58 	rgb_t color;
59 };
60 
61 class jpmimpct_state : public driver_device
62 {
63 public:
jpmimpct_state(const machine_config & mconfig,device_type type,const char * tag)64 	jpmimpct_state(const machine_config &mconfig, device_type type, const char *tag)
65 		: driver_device(mconfig, type, tag)
66 		, m_duart_1_timer(*this, "duart_1_timer")
67 		, m_vfd(*this, "vfd")
68 		, m_vram(*this, "vram")
69 		, m_maincpu(*this, "maincpu")
70 		, m_upd7759(*this, "upd")
71 		, m_palette(*this, "palette")
72 		, m_dsp(*this, "dsp")
73 		, m_reel(*this, "reel%u", 0U)
74 		, m_meters(*this, "meters")
75 		, m_digits(*this, "digit%u", 0U)
76 		, m_lamp_output(*this, "lamp%u", 0U)
77 	{ }
78 
79 	void impctawp(machine_config &config);
80 	void jpmimpct(machine_config &config);
81 
82 private:
DECLARE_WRITE_LINE_MEMBER(reel_optic_cb)83 	template <unsigned N> DECLARE_WRITE_LINE_MEMBER(reel_optic_cb) { if (state) m_optic_pattern |= (1 << N); else m_optic_pattern &= ~(1 << N); }
84 	uint16_t duart_1_r(offs_t offset);
85 	void duart_1_w(offs_t offset, uint16_t data);
86 	uint16_t duart_2_r(offs_t offset);
87 	void duart_2_w(uint16_t data);
88 	uint16_t inputs1_r(offs_t offset);
89 	uint16_t unk_r();
90 	void unk_w(uint16_t data);
91 	uint16_t jpmio_r();
92 	void jpmio_w(offs_t offset, uint16_t data);
93 	uint16_t inputs1awp_r(offs_t offset);
94 	uint16_t optos_r();
95 	uint16_t prot_1_r();
96 	uint16_t prot_0_r();
97 	void jpmioawp_w(offs_t offset, uint16_t data);
98 	uint16_t ump_r();
99 	void jpmimpct_bt477_w(offs_t offset, uint16_t data);
100 	uint16_t jpmimpct_bt477_r(offs_t offset);
101 	void volume_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
102 	void upd7759_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
103 	uint16_t upd7759_r(offs_t offset, uint16_t mem_mask = ~0);
104 	uint8_t hopper_b_r();
105 	uint8_t hopper_c_r();
106 	void payen_a_w(uint8_t data);
107 	void display_c_w(uint8_t data);
108 	DECLARE_WRITE_LINE_MEMBER(tms_irq);
109 	TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg);
110 	TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg);
111 	TMS340X0_SCANLINE_RGB32_CB_MEMBER(scanline_update);
112 	DECLARE_MACHINE_START(jpmimpct);
113 	DECLARE_MACHINE_RESET(jpmimpct);
114 	DECLARE_VIDEO_START(jpmimpct);
115 	DECLARE_MACHINE_START(impctawp);
116 	DECLARE_MACHINE_RESET(impctawp);
117 	TIMER_DEVICE_CALLBACK_MEMBER(duart_1_timer_event);
118 	void awp68k_program_map(address_map &map);
119 	void m68k_program_map(address_map &map);
120 	void tms_program_map(address_map &map);
121 
122 	uint8_t m_tms_irq;
123 	uint8_t m_duart_1_irq;
124 	struct duart_t m_duart_1;
125 	uint8_t m_touch_cnt;
126 	uint8_t m_touch_data[3];
127 	int m_lamp_strobe;
128 	uint8_t m_Lamps[256];
129 	int m_optic_pattern;
130 	int m_payen;
131 	int m_alpha_clock;
132 	int m_hopinhibit;
133 	int m_slidesout;
134 	int m_hopper[3];
135 	int m_motor[3];
136 	struct bt477_t m_bt477;
137 	void jpm_draw_lamps(int data, int lamp_strobe);
138 	void update_irqs();
139 
140 	required_device<timer_device> m_duart_1_timer;
141 	optional_device<s16lf01_device> m_vfd;
142 	optional_shared_ptr<uint16_t> m_vram;
143 	required_device<cpu_device> m_maincpu;
144 	required_device<upd7759_device> m_upd7759;
145 	optional_device<palette_device> m_palette;
146 	optional_device<tms34010_device> m_dsp;
147 	optional_device_array<stepper_device, 6> m_reel;
148 	required_device<meters_device> m_meters;
149 	output_finder<300> m_digits;
150 	output_finder<256> m_lamp_output;
151 };
152