summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/hyprolyb.cpp
blob: 77ff8034ae55510444cd7020c70c5462e7b078ed (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
// license:BSD-3-Clause
// copyright-holders:Chris Hardy
#include "emu.h"
#include "cpu/m6800/m6800.h"
#include "audio/hyprolyb.h"

DEFINE_DEVICE_TYPE(HYPROLYB_ADPCM, hyprolyb_adpcm_device, "hyprolyb_adpcm", "Hyper Olympics Audio")

hyprolyb_adpcm_device::hyprolyb_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, HYPROLYB_ADPCM, tag, owner, clock)
	, device_sound_interface(mconfig, *this)
	, m_audiocpu(*this, ":audiocpu")
	, m_soundlatch2(*this, ":soundlatch2")
	, m_msm(*this, ":msm")
	, m_adpcm_ready(0)
	, m_adpcm_busy(0)
	, m_vck_ready(0)
{
}


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

void hyprolyb_adpcm_device::device_start()
{
	save_item(NAME(m_adpcm_ready));  // only bootlegs
	save_item(NAME(m_adpcm_busy));
	save_item(NAME(m_vck_ready));
}

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

void hyprolyb_adpcm_device::device_reset()
{
	m_adpcm_ready = 0;
	m_adpcm_busy = 0;
	m_vck_ready = 0;
}

void hyprolyb_adpcm_device::write(uint8_t data)
{
	m_soundlatch2->write(data);
	m_adpcm_ready = 0x80;
}

uint8_t hyprolyb_adpcm_device::busy_r()
{
	return m_adpcm_busy ? 0x10 : 0x00;
}

void hyprolyb_adpcm_device::msm_data_w(uint8_t data)
{
	m_msm->data_w(data);
	m_adpcm_busy = ~data & 0x80;
}

uint8_t hyprolyb_adpcm_device::msm_vck_r()
{
	uint8_t old = m_vck_ready;
	m_vck_ready = 0x00;
	return old;
}

uint8_t hyprolyb_adpcm_device::ready_r()
{
	return m_adpcm_ready;
}

uint8_t hyprolyb_adpcm_device::data_r()
{
	m_adpcm_ready = 0x00;
	return m_soundlatch2->read();
}

void hyprolyb_adpcm_device::vck_callback( int st )
{
	m_vck_ready = 0x80;
}

//-------------------------------------------------
//  sound_stream_update_legacy - handle a stream update
//-------------------------------------------------

void hyprolyb_adpcm_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
{
	// should never get here
	fatalerror("sound_stream_update_legacy called; not applicable to legacy sound devices\n");
}