summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/dspv.cpp
blob: 05c322db88e5776e397d93816da19217ce300346 (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
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert

// Yamaha DSPV, dsp used for acoustic simulation

#include "emu.h"
#include "dspv.h"

DEFINE_DEVICE_TYPE(DSPV, dspv_device, "dspv", "Yamaha DSPV audio simulation DSP (YSS217-F/")

dspv_device::dspv_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: cpu_device(mconfig, DSPV, tag, owner, clock),
	  device_sound_interface(mconfig, *this),
	  m_program_config("program", ENDIANNESS_BIG, 16, 16, -1, address_map_constructor(FUNC(dspv_device::prg_map), this)),
	  m_data_config("data", ENDIANNESS_BIG, 16, 14, -1, address_map_constructor(FUNC(dspv_device::data_map), this))
{
}

void dspv_device::map(address_map &map)
{
	map(0x00, 0x7f).rw(FUNC(dspv_device::snd_r), FUNC(dspv_device::snd_w));

	map(0x02, 0x03).r(FUNC(dspv_device::status_r));
	map(0x06, 0x07).w(FUNC(dspv_device::prg_adr_w));
	map(0x20, 0x21).w(FUNC(dspv_device::table_adrh_w));
	map(0x22, 0x23).w(FUNC(dspv_device::table_adrl_w));
	map(0x24, 0x25).w(FUNC(dspv_device::table_data_w));
	map(0x26, 0x27).w(FUNC(dspv_device::table_zero_w));
	map(0x40, 0x7f).w(FUNC(dspv_device::prg_data_w));
}

void dspv_device::prg_map(address_map &map)
{
	map(0x0000, 0xffff).ram();
}

void dspv_device::data_map(address_map &map)
{
	map(0x0000, 0x3fff).ram();
}

void dspv_device::table_adrh_w(u16 data)
{
	m_table_adr = (m_table_adr & 0x0000ffff) | (data << 16);
}

void dspv_device::table_adrl_w(u16 data)
{
	m_table_adr = (m_table_adr & 0xffff0000) | data;
}

void dspv_device::table_data_w(u16 data)
{
	if(m_table_adr >= 0x4000)
		logerror("table_adr overflow!\n");
	m_data->write_word(m_table_adr, data);
	m_table_adr++;
}

void dspv_device::table_zero_w(u16 data)
{
	if(data)
		logerror("table_zero_w %04x\n", data);
}

void dspv_device::prg_adr_w(u16 data)
{
	m_prg_adr = data;
}

void dspv_device::prg_data_w(offs_t offset, u16 data)
{
	u16 adr = m_prg_adr + offset;
	adr = (adr << 3) | (adr >> 13);
	m_program->write_word(adr, data);
}

u16 dspv_device::status_r()
{
	if(!machine().side_effects_disabled())
		m_status ^= 0xffff;
	return m_status;
}

u16 dspv_device::snd_r(offs_t offset)
{
	logerror("r %04x %s\n", offset, machine().describe_context());
	return 0;
}

void dspv_device::snd_w(offs_t offset, u16 data)
{
	logerror("w %02x, %04x %s\n", offset, data, machine().describe_context());
}

void dspv_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
{
}

void dspv_device::device_start()
{
	m_program = &space(AS_PROGRAM);
	m_data = &space(AS_DATA);
	state_add(STATE_GENPC,     "GENPC",     m_pc).noshow();
	state_add(STATE_GENPCBASE, "CURPC",     m_pc).noshow();
	state_add(0,               "PC",        m_pc);

	set_icountptr(m_icount);

	save_item(NAME(m_pc));
	save_item(NAME(m_status));
	save_item(NAME(m_table_adr));
	save_item(NAME(m_prg_adr));
}

void dspv_device::device_reset()
{
	m_pc = 0;
	m_status = 0;
	m_table_adr = 0;
	m_prg_adr = 0;
}

uint32_t dspv_device::execute_min_cycles() const noexcept
{
	return 1;
}

uint32_t dspv_device::execute_max_cycles() const noexcept
{
	return 1;
}

uint32_t dspv_device::execute_input_lines() const noexcept
{
	return 0;
}

void dspv_device::execute_run()
{
	if(machine().debug_flags & DEBUG_FLAG_ENABLED)
		debugger_instruction_hook(m_pc);
	m_icount = 0;
}

device_memory_interface::space_config_vector dspv_device::memory_space_config() const
{
	return space_config_vector {
		std::make_pair(AS_PROGRAM, &m_program_config),
		std::make_pair(AS_DATA, &m_data_config)
	};
}

void dspv_device::state_import(const device_state_entry &entry)
{
}

void dspv_device::state_export(const device_state_entry &entry)
{
}

void dspv_device::state_string_export(const device_state_entry &entry, std::string &str) const
{
}

std::unique_ptr<util::disasm_interface> dspv_device::create_disassembler()
{
	return std::make_unique<dspv_disassembler>();
}