summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/tiaintf.cpp
blob: da0f0c27759b3aa39e131744067879a4a8f20daa (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
// license:GPL-2.0+
// copyright-holders:Ron Fries,Dan Boris
#include "emu.h"
#include "tiaintf.h"
#include "tiasound.h"

// device type definition
DEFINE_DEVICE_TYPE(TIA, tia_device, "tia_sound", "Atari TIA (Sound)")


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

//-------------------------------------------------
//  tia_device - constructor
//-------------------------------------------------

tia_device::tia_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, TIA, tag, owner, clock),
		device_sound_interface(mconfig, *this),
		m_channel(nullptr),
		m_chip(nullptr)
{
}


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

void tia_device::device_start()
{
	m_channel = stream_alloc(0, 1, clock());
	m_chip = tia_sound_init(this, clock(), clock(), 16);
	if (!m_chip)
		throw emu_fatalerror("tia_device(%s): Error creating TIA chip", tag());
}


//-------------------------------------------------
//  device_stop - device-specific stop
//-------------------------------------------------

void tia_device::device_stop()
{
	tia_sound_free(m_chip);
}


//-------------------------------------------------
//  sound_stream_update - handle a stream update
//-------------------------------------------------

void tia_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
	tia_process(m_chip, outputs[0], samples);
}


WRITE8_MEMBER( tia_device::tia_sound_w )
{
	m_channel->update();
	tia_write(m_chip, offset, data);
}