summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/rs232/xvd701.h
blob: 93a907c9a16b004f55bc1dc7e316fbda7ddda1fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// license:BSD-3-Clause
// copyright-holders:smf
#ifndef MAME_BUS_RS232_XVD701_H
#define MAME_BUS_RS232_XVD701_H

#include "rs232.h"
#include "diserial.h"

class jvc_xvd701_device : public device_t,
		public device_serial_interface,
		public device_rs232_port_interface
{
public:
	jvc_xvd701_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

	virtual WRITE_LINE_MEMBER( input_txd ) override { device_serial_interface::rx_w(state); }
protected:
	virtual ioport_constructor device_input_ports() const override;
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void device_add_mconfig(machine_config &config) override;

	virtual void tra_callback() override;
	virtual void tra_complete() override;
	virtual void rcv_complete() override;

private:
	enum jvc_xvd701_media_type : uint32_t
	{
		JVC_MEDIA_VCD = 0,
		JVC_MEDIA_DVD = 1,
	};

	enum jvc_xvd701_playback_status : uint32_t
	{
		STATUS_STOP = 0,
		STATUS_PLAYING = 1,
		STATUS_PAUSE = 2,
	};

	TIMER_CALLBACK_MEMBER(send_response);
	unsigned char sum(unsigned char *buffer, int length);
	void create_packet(unsigned char status, const unsigned char response[6]);

	bool seek_chapter(int chapter);

	jvc_xvd701_media_type m_media_type;

	unsigned char m_command[11];
	unsigned char m_response[11];
	int m_response_index;
	emu_timer *m_timer_response;

	jvc_xvd701_playback_status m_playback_status;

	unsigned char m_jlip_id;
	bool m_is_powered;

	int m_chapter;

	enum : unsigned char {
		STATUS_UNKNOWN_COMMAND = 1,
		STATUS_OK = 3,
		STATUS_ERROR = 5,
	};
	const unsigned char NO_RESPONSE[6] = { 0 };
};

DECLARE_DEVICE_TYPE(JVC_XVD701, jvc_xvd701_device)

#endif // MAME_BUS_RS232_XVD701_H