summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/ti99x/videowrp.cpp
blob: bb6f01f6a8980f007409b79fb3ac6668de23a97a (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
// license:LGPL-2.1+
// copyright-holders:Michael Zapf
/****************************************************************************

    TI-99/4(A) and /8 Video subsystem
    This device actually wraps the naked video chip implementation

    EVPC (Enhanced Video Processor Card) from SNUG
    based on v9938 (may also be equipped with v9958)
    Can be used with TI-99/4A as an add-on card; internal VDP must be removed

    The SGCPU ("TI-99/4P") only runs with EVPC

    We also include a class wrapper for the sound chip here.

    Michael Zapf

    October 2010
    February 2012: Rewritten as class

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

#include "emu.h"
#include "videowrp.h"
#include "sound/sn76496.h"

/*
    Constructors
*/
ti_video_device::ti_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)
: bus8z_device(mconfig, type, name, tag, owner, clock, shortname, source), 
m_tms9928a(nullptr)
{
}

ti_std_video_device::ti_std_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: ti_video_device(mconfig, TI99VIDEO, "TI99 STD Video subsystem", tag, owner, clock, "ti99_video", __FILE__)
{
}

ti_exp_video_device::ti_exp_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: ti_video_device(mconfig, V9938VIDEO, "TI99 EXP Video subsystem", tag, owner, clock, "v9938_video", __FILE__), m_v9938(nullptr)
{
}

ti_sound_sn94624_device::ti_sound_sn94624_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: ti_sound_system_device(mconfig, TISOUND_94624, "Onboard sound (SN94624)", tag, owner, clock, "ti_sound_sn94624", __FILE__)
{
}

ti_sound_sn76496_device::ti_sound_sn76496_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: ti_sound_system_device(mconfig, TISOUND_76496, "Onboard sound (SN76496)", tag, owner, clock, "ti_sound_sn76496", __FILE__)
{
}

/*****************************************************************************/
/*
    Memory access (TI-99/4A and TI-99/8)
*/
READ8Z_MEMBER( ti_std_video_device::readz )
{
	if (space.debugger_access()) return;

	if (offset & 2)
	{       /* read VDP status */
		*value = m_tms9928a->register_read(space, 0);
	}
	else
	{       /* read VDP RAM */
		*value = m_tms9928a->vram_read(space, 0);
	}
}

WRITE8_MEMBER( ti_std_video_device::write )
{
	if (space.debugger_access()) return;

	if (offset & 2)
	{   /* write VDP address */
		m_tms9928a->register_write(space, 0, data);
	}
	else
	{   /* write VDP data */
		m_tms9928a->vram_write(space, 0, data);
	}
}

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

/*
    Memory access (EVPC) via 16 bit bus
*/
READ16_MEMBER( ti_exp_video_device::read16 )
{
	if (space.debugger_access()) return 0;

	if (offset & 1)
	{   /* read VDP status */
		return ((int) m_v9938->status_r()) << 8;
	}
	else
	{   /* read VDP RAM */
		return ((int) m_v9938->vram_r()) << 8;
	}
}

WRITE16_MEMBER( ti_exp_video_device::write16 )
{
	if (space.debugger_access()) return;

	switch (offset & 3)
	{
	case 0:
		/* write VDP data */
		m_v9938->vram_w((data >> 8) & 0xff);
		break;
	case 1:
		/* write VDP address */
		m_v9938->command_w((data >> 8) & 0xff);
		break;
	case 2:
		/* write VDP palette */
		m_v9938->palette_w((data >> 8) & 0xff);
		break;
	case 3:
		/* write VDP register pointer (indirect access) */
		m_v9938->register_w((data >> 8) & 0xff);
		break;
	}
}

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

/*
    Video read (Geneve) via 8 bit bus
*/
READ8Z_MEMBER( ti_exp_video_device::readz )
{
	if (space.debugger_access()) return;

	if (offset & 2)
	{   /* read VDP status */
		*value = m_v9938->status_r();
	}
	else
	{   /* read VDP RAM */
		*value = m_v9938->vram_r();
	}
}

/*
    Video write (Geneve)
*/
WRITE8_MEMBER( ti_exp_video_device::write )
{
	if (space.debugger_access()) return;

	switch (offset & 6)
	{
	case 0:
		/* write VDP data */
		m_v9938->vram_w(data);
		break;
	case 2:
		/* write VDP address */
		m_v9938->command_w(data);
		break;
	case 4:
		/* write VDP palette */
		m_v9938->palette_w(data);
		break;
	case 6:
		/* write VDP register pointer (indirect access) */
		m_v9938->register_w(data);
		break;
	}
}

/**************************************************************************/
// Interfacing to mouse attached to v9938

void ti_exp_video_device::video_update_mouse(int delta_x, int delta_y, int buttons)
{
	m_v9938->update_mouse_state(delta_x, delta_y, buttons & 3);
}

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

void ti_video_device::device_start(void)
{
	m_tms9928a = static_cast<tms9928a_device*>(machine().device(VDP_TAG));
}

void ti_exp_video_device::device_start(void)
{
	m_v9938 = static_cast<v9938_device*>(machine().device(VDP_TAG));
}

void ti_video_device::device_reset(void)
{
}

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

/*
    Sound subsystem.
    TODO: Seriously consider to simplify this by connecting to the datamux
    directly. We don't do anything reasonable here.
*/

WRITE8_MEMBER( ti_sound_system_device::write )
{
	if (space.debugger_access()) return;
	m_sound_chip->write(space, 0, data);
}

void ti_sound_system_device::device_start(void)
{
	m_console_ready.resolve();
	m_sound_chip = subdevice<sn76496_base_device>(TISOUNDCHIP_TAG);
}

WRITE_LINE_MEMBER( ti_sound_system_device::sound_ready )
{
	m_console_ready(state);
}

MACHINE_CONFIG_FRAGMENT( sn94624 )
	MCFG_SPEAKER_STANDARD_MONO("sound_out")

	MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN94624, 3579545/8) /* 3.579545 MHz */
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "sound_out", 0.75)
	MCFG_SN76496_READY_HANDLER(WRITELINE(ti_sound_system_device, sound_ready))
MACHINE_CONFIG_END

MACHINE_CONFIG_FRAGMENT( sn76496 )
	MCFG_SPEAKER_STANDARD_MONO("sound_out")

	MCFG_SOUND_ADD(TISOUNDCHIP_TAG, SN76496, 3579545)   /* 3.579545 MHz */
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "sound_out", 0.75)
	MCFG_SN76496_READY_HANDLER(WRITELINE(ti_sound_system_device, sound_ready))
MACHINE_CONFIG_END

machine_config_constructor ti_sound_sn94624_device::device_mconfig_additions() const
{
	return MACHINE_CONFIG_NAME( sn94624 );
}

machine_config_constructor ti_sound_sn76496_device::device_mconfig_additions() const
{
	return MACHINE_CONFIG_NAME( sn76496 );
}

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

const device_type TI99VIDEO = &device_creator<ti_std_video_device>;
const device_type V9938VIDEO = &device_creator<ti_exp_video_device>;
const device_type TISOUND_94624 = &device_creator<ti_sound_sn94624_device>;
const device_type TISOUND_76496 = &device_creator<ti_sound_sn76496_device>;