summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/a2bus/ssprite.cpp
blob: 14889c2a83df7342aa1008bcf2e5fb5a849fdefd (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
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Golden Child
/*********************************************************************

    ssprite.cpp

    Implementation of the Synetix SuperSprite

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

#include "emu.h"
#include "ssprite.h"

#include "sound/ay8910.h"
#include "sound/tms5220.h"
#include "video/tms9928a.h"

#include "speaker.h"


namespace {

/***************************************************************************
    PARAMETERS
***************************************************************************/

#define TMS_TAG "ssprite_tms"
#define TMS5220_TAG "ssprite_tms5220"
#define AY_TAG "ssprite_ay"
#define SCREEN_TAG "screen"

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

class a2bus_ssprite_device:
	public device_t,
	public device_a2bus_card_interface
{
public:
	// construction/destruction
	a2bus_ssprite_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

protected:
	a2bus_ssprite_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock);

	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void device_add_mconfig(machine_config &config) override;

	// overrides of standard a2bus slot functions
	virtual uint8_t read_c0nx(uint8_t offset) override;
	virtual void write_c0nx(uint8_t offset, uint8_t data) override;

private:
	DECLARE_WRITE_LINE_MEMBER( tms_irq_w );

	required_device<tms9918a_device> m_tms;
	required_device<ay8910_device> m_ay;
	required_device<tms5220_device> m_tms5220;
};

//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------

void a2bus_ssprite_device::device_add_mconfig(machine_config &config)
{
	TMS9918A(config, m_tms, XTAL(10'738'635)).set_screen(SCREEN_TAG);
	m_tms->set_vram_size(0x4000); // 16k of VRAM
	m_tms->int_callback().set(FUNC(a2bus_ssprite_device::tms_irq_w));
	SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER);

	SPEAKER(config, "mono").front_center();
	AY8912(config, m_ay, XTAL::u(1022727)).add_route(ALL_OUTPUTS, "mono", 1.0);
	TMS5220(config, m_tms5220, XTAL::u(640000)).add_route(ALL_OUTPUTS, "mono", 1.0);
}

//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

a2bus_ssprite_device::a2bus_ssprite_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	a2bus_ssprite_device(mconfig, A2BUS_SSPRITE, tag, owner, clock)
{
}

a2bus_ssprite_device::a2bus_ssprite_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock) :
	device_t(mconfig, type, tag, owner, clock),
	device_a2bus_card_interface(mconfig, *this),
	m_tms(*this, TMS_TAG),
	m_ay(*this, AY_TAG),
	m_tms5220(*this, TMS5220_TAG)
{
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void a2bus_ssprite_device::device_start()
{
}

void a2bus_ssprite_device::device_reset()
{
}

/*
    C0nx map: (info from Synetix SuperSprite Owners manual.pdf page 33 of 266)
    0 - TMS9918 VDP vram read/write
    1 - TMS9918 VDP register write
    2 - TMS5220 Speech read/write
    3 - Video Switch APPLE VIDEO IN OFF
    4 - Video Switch APPLE VIDEO IN ON
    5 - Video Switch APPLE ONLY OUT
    6 - Video Switch MIX VDP/EXTERNAL VIDEO
    7 - TMS 9918 WRITE ONLY/FRAME RESET
    C - AY Sound data write
    D - AY Sound data write
    E - AY Sound register write or data read
    F - AY Sound register write or data read
*/


uint8_t a2bus_ssprite_device::read_c0nx(uint8_t offset)
{
	switch (offset)
	{
		case 0:
			return m_tms->vram_read();
		case 1:
			return m_tms->register_read();
		case 2:
			return 0x1f | m_tms5220->status_r();
		case 14:
		case 15:
			return m_ay->data_r();
	}

	return 0xff;
}

void a2bus_ssprite_device::write_c0nx(uint8_t offset, uint8_t data)
{
	switch (offset)
	{
		case 0:
			m_tms->vram_write(data);
			break;
		case 1:
			m_tms->register_write(data);
			break;
		case 2:
			m_tms5220->data_w(data);
			break;
		case 12:
		case 13:
			m_ay->data_w(data);
			break;
		case 14:
		case 15:
			m_ay->address_w(data);
			break;
	}
}

WRITE_LINE_MEMBER( a2bus_ssprite_device::tms_irq_w )
{
	if (state)
		raise_slot_irq();
	else
		lower_slot_irq();
}

} // anonymous namespace


//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DEFINE_DEVICE_TYPE_PRIVATE(A2BUS_SSPRITE, device_a2bus_card_interface, a2bus_ssprite_device, "a2ssprite", "Synetix SuperSprite")