1 // license:BSD-3-Clause
2 // copyright-holders:Ryan Holtz
3 /******************************************************************************
4 *
5 *   Sony PlayStation 2 disc controller device skeleton
6 *
7 *   To Do:
8 *     Everything
9 *
10 */
11 
12 #ifndef MAME_MACHINE_IOPCDVD_H
13 #define MAME_MACHINE_IOPCDVD_H
14 
15 #pragma once
16 
17 #include "iopintc.h"
18 
19 class iop_cdvd_device : public device_t
20 {
21 public:
22 	template <typename T>
iop_cdvd_device(const machine_config & mconfig,const char * tag,device_t * owner,T && intc_tag)23 	iop_cdvd_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&intc_tag)
24 		: iop_cdvd_device(mconfig, tag, owner, (uint32_t)0)
25 	{
26 		m_intc.set_tag(std::forward<T>(intc_tag));
27 	}
28 
29 	iop_cdvd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
30 	virtual ~iop_cdvd_device() override;
31 
32 	uint8_t read(offs_t offset);
33 	void write(offs_t offset, uint8_t data);
34 
35 protected:
36 	virtual void device_start() override;
37 	virtual void device_reset() override;
38 
39 	void handle_data_command(uint8_t data);
40 	void data_fifo_push(uint8_t data);
41 	uint8_t data_fifo_pop();
42 
43 	enum
44 	{
45 		CDVD_STATUS_IDLE = 0x40,
46 	};
47 
48 	required_device<iop_intc_device> m_intc;
49 
50 	enum
51 	{
52 		CHAN_SERVO = 0,
53 		CHAN_DATA = 1
54 	};
55 
56 	struct drive_channel_t
57 	{
58 		uint8_t m_buffer[0x10]; // Buffer size is a total guess
59 		uint8_t m_curr;
60 		uint8_t m_end;
61 
62 		uint8_t m_status;
63 		uint8_t m_command;
64 	};
65 
66 	drive_channel_t m_channel[2];
67 
68 	static const size_t BUFFER_SIZE;
69 };
70 
71 DECLARE_DEVICE_TYPE(SONYIOP_CDVD, iop_cdvd_device)
72 
73 #endif // MAME_MACHINE_IOPCDVD_H
74