summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/mb88303.h
blob: 058f58f212bf2b04a95beff08b604784ff48e735 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
/***********************************************************************

    Fujitsu MB88303 NMOS Television Display Controller (TVDC) emulation

************************************************************************
                            _____   _____
                /RESET   1 |*    \_/     | 22  Vcc
                   DO0   2 |             | 21  DA7
                   DO1   3 |             | 20  DA6
                   DO2   4 |             | 19  DA5
                   VOW   5 |             | 18  DA4
                  /VOB   6 |   MB88303   | 17  DA3
                /VSYNC   7 |             | 16  DA2
                /HSYNC   8 |             | 15  DA1
                    EX   9 |             | 14  DA0
                     X  10 |             | 13  ADM
                   Vss  11 |_____________| 12  LDI

************************************************************************/

#ifndef MAME_VIDEO_MB88303_H
#define MAME_VIDEO_MB88303_H

#pragma once



//**************************************************************************
//  INTERFACE CONFIGURATION MACROS
//**************************************************************************

#define MCFG_MB88303_VOW_CALLBACK(_write) \
	devcb = &downcast<mb88303_device &>(*device).set_vow_callback(DEVCB_##_write);

#define MCFG_MB88303_VOBN_CALLBACK(_write) \
	devcb = &downcast<mb88303_device &>(*device).set_vob_n_callback(DEVCB_##_write);

#define MCFG_MB88303_DO_CALLBACK(_write) \
	devcb = &downcast<mb88303_device &>(*device).set_do_callback(DEVCB_##_write);


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> mb88303_device

class mb88303_device :  public device_t
{
public:
	static constexpr unsigned VISIBLE_COLUMNS = 20;
	static constexpr unsigned VISIBLE_LINES   = 9;

	// construction/destruction
	mb88303_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	template <class Object> devcb_base &set_vow_callback(Object &&cb) { return m_write_vow.set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_vobn_callback(Object &&cb) { return m_write_vobn.set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_do_callback(Object &&cb) { return m_write_do.set_callback(std::forward<Object>(cb)); }

	DECLARE_WRITE8_MEMBER(da_w);
	DECLARE_WRITE_LINE_MEMBER(adm_w);
	DECLARE_WRITE_LINE_MEMBER(reset_n_w);
	DECLARE_WRITE_LINE_MEMBER(ldi_w);
	DECLARE_WRITE_LINE_MEMBER(hsync_n_w);
	DECLARE_WRITE_LINE_MEMBER(vsync_n_w);

	void update_bitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	enum
	{
		HSZ0        = 0x01,
		HSZ1        = 0x02,
		VSZ0        = 0x04,
		VSZ1        = 0x08,
		BLK         = 0x10,
		BLKB        = 0x20,
		BLINK       = 0x40,

		HSZ0_BIT    = 0,
		HSZ1_BIT    = 1,
		VSZ0_BIT    = 2,
		VSZ1_BIT    = 3,
		BLK_BIT     = 4,
		BLKB_BIT    = 5,
		BLINK_BIT   = 6,
	};

	void hdpr_w(uint8_t data); // Horizontal Display Position Register
	void vdpr_w(uint8_t data); // Vertical Display Position Register
	void dcr_w(uint8_t data); // Display Control Register
	void gor_w(uint8_t data); // General Output Register

	void process_data();
	bool blank_display();
	bool show_background();
	bool enable_blinking();
	uint8_t hsize();
	uint8_t vsize();

	devcb_write_line m_write_vow;
	devcb_write_line m_write_vobn;
	devcb_write8 m_write_do;

	uint8_t m_da;
	uint8_t m_adm;
	uint8_t m_reset_n;
	uint8_t m_ldi;
	uint8_t m_hsync_n;
	uint8_t m_vsync_n;

	uint8_t m_display_mem[180];
	uint8_t m_horiz_display_pos;
	uint8_t m_vert_display_pos;
	uint8_t m_display_ctrl;
	uint8_t m_general_out;
	uint8_t m_address;

	bool m_addr_inc_mode;

	static const uint8_t s_character_data[0x40][7];
};


// device type definition
DECLARE_DEVICE_TYPE(MB88303, mb88303_device)

#endif // MAME_VIDEO_MB88303_H