summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/spectrum/uspeech.cpp
blob: ae3f49250afe3ff6a26db95b82087cc6fa9b032d (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
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes,Thomas Busse
/**********************************************************************

    Spectrum Currah MicroSpeech emulation

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

#include "emu.h"
#include "uspeech.h"
#include "speaker.h"



//**************************************************************************
//  MACROS/CONSTANTS
//**************************************************************************

#define SP0256_TAG      "sp0256"


//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE(SPECTRUM_USPEECH, spectrum_uspeech_device, "spectrum_uspeech", "Spectrum Currah \xC2\xB5Speech")


//-------------------------------------------------
//  ROM( uspeech )
//-------------------------------------------------

ROM_START( uspeech )
	ROM_REGION(0x0800, "rom", 0)
	ROM_LOAD("currah.rom", 0x0000, 0x0800, CRC(ce7cf52e) SHA1(90dbba5afbf07949df9cbdcb0a8ec0b106340422))

	ROM_REGION(0x10000, SP0256_TAG, 0)
	ROM_LOAD( "sp0256a-al2.bin", 0x1000, 0x0800, CRC(b504ac15) SHA1(e60fcb5fa16ff3f3b69d36c7a6e955744d3feafc) )
ROM_END


//-------------------------------------------------
//  rom_region - device-specific ROM region
//-------------------------------------------------

const tiny_rom_entry *spectrum_uspeech_device::device_rom_region() const
{
	return ROM_NAME( uspeech );
}


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

MACHINE_CONFIG_START(spectrum_uspeech_device::device_add_mconfig)
	MCFG_SPEAKER_STANDARD_MONO("mono")
	MCFG_SOUND_ADD(SP0256_TAG, SP0256, XTAL(14'000'000) / 4)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END


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

//-------------------------------------------------
//  spectrum_uspeech_device - constructor
//-------------------------------------------------

spectrum_uspeech_device::spectrum_uspeech_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, SPECTRUM_USPEECH, tag, owner, clock),
	device_spectrum_expansion_interface(mconfig, *this),
	m_nsp(*this, SP0256_TAG),
	m_rom(*this, "rom")
{
}


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

void spectrum_uspeech_device::device_start()
{
	m_slot = dynamic_cast<spectrum_expansion_slot_device *>(owner());
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void spectrum_uspeech_device::device_reset()
{
	m_romcs = 0;
}


//**************************************************************************
//  IMPLEMENTATION
//**************************************************************************

READ_LINE_MEMBER(spectrum_uspeech_device::romcs)
{
	return m_romcs;
}


READ8_MEMBER(spectrum_uspeech_device::mreq_r)
{
	uint8_t data;

	if (!machine().side_effect_disabled() && (offset == 0x38))
	{
		m_romcs = !m_romcs;
	}

	switch (offset)
	{
	case 0x1000:
		data = !m_nsp->lrq_r(); // (m_nsp->lrq_r() && (m_nsp->sby_r() != 0)) ? 0x00 : 0x01;
		break;
	default:
		data = m_rom->base()[offset & 0x7ff];
		break;
	}

	return data;
}

WRITE8_MEMBER(spectrum_uspeech_device::mreq_w)
{
	switch (offset)
	{
	case 0x1000:
		// allophone
		m_nsp->ald_w(space, 0, data & 0x3f);
		break;

	case 0x3000:
		// intonation low
		m_nsp->set_clock(3500000); // CK / 4 ??
		break;

	case 0x3001:
		// intonation high
		m_nsp->set_clock(3800000); // TODO: the exact frequency is unknown
		break;
	}
}