1 // license:BSD-3-Clause
2 // copyright-holders:Ryan Holtz
3 /******************************************************************************
4 
5     CD-i Mono-I SLAVE MCU HLE
6     -------------------
7 
8 *******************************************************************************
9 
10 STATUS:
11 - Just enough for the Mono-I CD-i board to work somewhat properly.
12 
13 TODO:
14 - Proper LLE.
15 
16 *******************************************************************************/
17 
18 #ifndef MAME_MACHINE_CDISLAVEHLE_H
19 #define MAME_MACHINE_CDISLAVEHLE_H
20 
21 #pragma once
22 
23 #include "sound/dmadac.h"
24 
25 //**************************************************************************
26 //  TYPE DEFINITIONS
27 //**************************************************************************
28 
29 // ======================> cdislave_hle_device
30 
31 class cdislave_hle_device : public device_t
32 {
33 public:
34 	// construction/destruction
35 	cdislave_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
36 
int_callback()37 	auto int_callback() { return m_int_callback.bind(); }
38 
39 	// external callbacks
40 	DECLARE_INPUT_CHANGED_MEMBER( mouse_update );
41 
get_lcd_state()42 	uint8_t* get_lcd_state() { return m_lcd_state; }
43 
44 	uint16_t slave_r(offs_t offset);
45 	void slave_w(offs_t offset, uint16_t data);
46 
47 protected:
48 	// device-level overrides
49 	virtual void device_resolve_objects() override;
50 	virtual void device_start() override;
51 	virtual void device_reset() override;
52 	virtual ioport_constructor device_input_ports() const override;
53 
54 	// internal callbacks
55 	TIMER_CALLBACK_MEMBER( trigger_readback_int );
56 
57 private:
58 	devcb_write_line m_int_callback;
59 
60 	required_device_array<dmadac_sound_device, 2> m_dmadac;
61 
62 	required_ioport m_mousex;
63 	required_ioport m_mousey;
64 	required_ioport m_mousebtn;
65 
66 	// internal state
67 	class channel_state
68 	{
69 	public:
channel_state()70 		channel_state() { }
71 
72 		uint8_t m_out_buf[4];
73 		uint8_t m_out_index;
74 		uint8_t m_out_count;
75 		uint8_t m_out_cmd;
76 	};
77 
78 	channel_state m_channel[4];
79 	emu_timer *m_interrupt_timer;
80 
81 	uint8_t m_in_buf[17];
82 	uint8_t m_in_index;
83 	uint8_t m_in_count;
84 
85 	uint8_t m_polling_active;
86 
87 	uint8_t m_xbus_interrupt_enable;
88 
89 	uint8_t m_lcd_state[16];
90 
91 	uint16_t m_real_mouse_x;
92 	uint16_t m_real_mouse_y;
93 
94 	uint16_t m_fake_mouse_x;
95 	uint16_t m_fake_mouse_y;
96 
97 	// static internal members
98 
99 	// non-static internal members
100 	void prepare_readback(const attotime &delay, uint8_t channel, uint8_t count, uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3, uint8_t cmd);
101 	void perform_mouse_update();
102 	void set_mouse_position();
103 };
104 
105 
106 // device type definition
107 DECLARE_DEVICE_TYPE(CDI_SLAVE_HLE, cdislave_hle_device)
108 
109 #endif // MAME_MACHINE_CDISLAVEHLE_H
110