summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/video/pcd.h
blob: 52b61298d52d53b5ca745ab13edee58e02a1ab29 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// license:BSD-3-Clause
// copyright-holders:Carl

#ifndef _PCD_H_
#define _PCD_H_

#include "emu.h"
#include "machine/pic8259.h"
#include "video/scn2674.h"

#define MCFG_PCX_VIDEO_TXD_HANDLER(_devcb) \
	devcb = &pcx_video_device::set_txd_handler(*device, DEVCB_##_devcb);

class pcdx_video_device : public device_t
{
public:
	pcdx_video_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);

	virtual DECLARE_ADDRESS_MAP(map, 16) = 0;
	DECLARE_READ8_MEMBER(detect_r);
	DECLARE_WRITE8_MEMBER(detect_w);
	DECLARE_PALETTE_INIT(pcdx);

protected:
	required_device<cpu_device> m_maincpu;
	required_device<cpu_device> m_mcu;
	required_device<scn2674_device> m_crtc;
	required_device<palette_device> m_palette;
	required_device<gfxdecode_device> m_gfxdecode;
};

class pcd_video_device : public pcdx_video_device
{
public:
	pcd_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);

	DECLARE_ADDRESS_MAP(map, 16);
	DECLARE_ADDRESS_MAP(vram_map, 8);
	DECLARE_READ8_MEMBER(mcu_r);
	DECLARE_WRITE8_MEMBER(mcu_w);
	DECLARE_WRITE8_MEMBER(vram_sw_w);
	DECLARE_READ8_MEMBER(vram_r);
	DECLARE_WRITE8_MEMBER(vram_w);

	virtual const rom_entry *device_rom_region() const;
	virtual machine_config_constructor device_mconfig_additions() const;
	SCN2674_DRAW_CHARACTER_MEMBER(display_pixels);
protected:
	void device_start();
	void device_reset();
private:
	dynamic_buffer m_vram;
	dynamic_buffer m_charram;
	UINT8 m_vram_sw;
};

class pcx_video_device : public pcdx_video_device,
							public device_serial_interface
{
public:
	pcx_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	template<class _Object> static devcb_base &set_txd_handler(device_t &device, _Object object) { return downcast<pcx_video_device &>(device).m_txd_handler.set_callback(object); }

	DECLARE_ADDRESS_MAP(map, 16);
	DECLARE_READ8_MEMBER(term_r);
	DECLARE_WRITE8_MEMBER(term_w);
	DECLARE_READ8_MEMBER(term_mcu_r);
	DECLARE_WRITE8_MEMBER(term_mcu_w);
	DECLARE_READ8_MEMBER(rx_callback);
	DECLARE_WRITE8_MEMBER(tx_callback);
	DECLARE_READ8_MEMBER(vram_r);
	DECLARE_WRITE8_MEMBER(vram_w);
	DECLARE_READ8_MEMBER(vram_latch_r);
	DECLARE_WRITE8_MEMBER(vram_latch_w);
	DECLARE_READ8_MEMBER(unk_r);
	DECLARE_WRITE8_MEMBER(p1_w);

	virtual const rom_entry *device_rom_region() const;
	virtual machine_config_constructor device_mconfig_additions() const;
	SCN2674_DRAW_CHARACTER_MEMBER(display_pixels);
protected:
	void device_start();
	void device_reset();
	void tra_callback();
	void rcv_complete();
	void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
private:
	dynamic_buffer m_vram;
	required_region_ptr<UINT8> m_charrom;
	required_device<pic8259_device> m_pic2;
	devcb_write_line m_txd_handler;
	UINT8 m_term_key, m_term_char, m_term_stat, m_vram_latch_r[2], m_vram_latch_w[2], m_p1;
};

extern const device_type PCD_VIDEO;
extern const device_type PCX_VIDEO;

#endif