summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/pc_t1t.h
blob: a1484d0d05fd77c5e3c03f5c3a2247abd56d4666 (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol
#ifndef MAME_VIDEO_PC_T1T_H
#define MAME_VIDEO_PC_T1T_H

#pragma once

#include "video/mc6845.h"
#include "machine/ram.h"
#include "machine/bankdev.h"
#include "machine/pic8259.h"
#include "emupal.h"

#define T1000_SCREEN_NAME   "screen"
#define T1000_MC6845_NAME   "mc6845_t1000"

class pc_t1t_device :  public device_t, public device_video_interface
{
public:
	DECLARE_WRITE_LINE_MEMBER( t1000_de_changed );
	uint8_t read(offs_t offset);

	virtual MC6845_UPDATE_ROW( crtc_update_row );
	MC6845_UPDATE_ROW( t1000_text_inten_update_row );
	MC6845_UPDATE_ROW( t1000_text_blink_update_row );
	MC6845_UPDATE_ROW( t1000_gfx_4bpp_update_row );
	MC6845_UPDATE_ROW( t1000_gfx_2bpp_update_row );
	MC6845_UPDATE_ROW( t1000_gfx_2bpp_tga_update_row );
	MC6845_UPDATE_ROW( t1000_gfx_1bpp_update_row );

	void vram_map(address_map &map);

protected:
	// used in tandy1000hx; used in pcjr???
	struct reg
	{
		reg()
		{
			index = 0;
			memset(&data, 0, sizeof(data));
		}

		uint8_t index;
		uint8_t data[0x20];
		/* see vgadoc
		   0 mode control 1
		   1 palette mask
		   2 border color
		   3 mode control 2
		   4 reset
		   0x10-0x1f palette registers
		*/
	};

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

	required_device<mc6845_device> m_mc6845;
	uint8_t m_mode_control, m_color_select;
	uint8_t m_status;

	struct reg m_reg;

	uint16_t m_bank;

	int m_pc_framecnt;

	uint8_t *m_displayram;

	uint8_t  *m_chr_gen;
	uint8_t  m_chr_size;
	uint16_t m_ra_offset;

	uint8_t   m_address_data_ff;

	int     m_update_row_type;
	uint8_t   m_display_enable;
	uint8_t   m_vsync;
	uint8_t   m_palette_base;

	void pcjr_palette(palette_device &palette) const;

	int mode_control_r();
	void color_select_w(int data);
	int color_select_r();
	int status_r();
	void lightpen_strobe_w(int data);
	void vga_index_w(int data);
	int vga_data_r();
	int bank_r();

	required_device<palette_device> m_palette;
	required_device<ram_device> m_ram;
	required_device<address_map_bank_device> m_vram;
};

class pcvideo_t1000_device :  public pc_t1t_device
{
public:
	// construction/destruction
	pcvideo_t1000_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void write(offs_t offset, uint8_t data);
	DECLARE_WRITE_LINE_MEMBER( disable_w );

protected:
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;

private:
	void mode_switch();
	void vga_data_w(int data);
	void bank_w(int data);
	void mode_control_w(int data);
	bool m_disable;

	DECLARE_WRITE_LINE_MEMBER( t1000_vsync_changed );
};

DECLARE_DEVICE_TYPE(PCVIDEO_T1000, pcvideo_t1000_device)

class pcvideo_pcjr_device :  public pc_t1t_device
{
public:
	// construction/destruction
	pcvideo_pcjr_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void write(offs_t offset, uint8_t data);

	DECLARE_WRITE_LINE_MEMBER( de_changed );
	MC6845_UPDATE_ROW( pcjx_text_update_row );
	MC6845_UPDATE_ROW( pcjr_gfx_2bpp_high_update_row );

protected:
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;

	required_device<pic8259_device> m_pic8259;
	uint8_t   *m_jxkanji;

private:
	void pc_pcjr_mode_switch();
	void pc_pcjr_vga_data_w(int data);
	void pc_pcjr_bank_w(int data);
	void pc_pcjx_bank_w(int data);

	DECLARE_WRITE_LINE_MEMBER( pcjr_vsync_changed );

	virtual MC6845_UPDATE_ROW( crtc_update_row ) override;
};

DECLARE_DEVICE_TYPE(PCVIDEO_PCJR, pcvideo_pcjr_device)

#endif // MAME_VIDEO_PC_T1T_H