summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/swp20.h
blob: 1086fd8b7920878d7fe06eaa8537cf94f6d13fc8 (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
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert

// Yamaha SWP20, rompler

#ifndef MAME_SOUND_SWP20_H
#define MAME_SOUND_SWP20_H

#pragma once

#include "dirom.h"

class swp20_device : public device_t, public device_sound_interface, public device_rom_interface<23+2, 1, 0, ENDIANNESS_LITTLE>
{
public:
	swp20_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 11289600);

	void map(address_map &map) ATTR_COLD;

protected:
	virtual void device_start() override ATTR_COLD;
	virtual void device_reset() override ATTR_COLD;
	virtual void sound_stream_update(sound_stream &stream) override;

private:
	sound_stream *m_stream;

	std::array<u8,  0x20>  m_pan_l;
	std::array<u8,  0x20>  m_pan_r;
	std::array<u16, 0x20>  m_pitch;
	std::array<u32, 0x20>  m_sample_start;
	std::array<u16, 0x20>  m_sample_end;
	std::array<u8,  0x20>  m_sample_format;
	std::array<u32, 0x20>  m_sample_address;

	u16 m_waverom_val;
	u8 m_waverom_access;

	u8 m_eq_port;
	bool m_eq_address;
	u8 m_voice;
	u32 m_keyon;
	u32 m_keyoff;

	void voice_w(u8 data);

	void pan_l_w(u8 data);
	u8 pan_l_r();
	void pan_r_w(u8 data);
	u8 pan_r_r();
	template<int sel> void pitch_w(u8 data);
	template<int sel> u8 pitch_r();
	template<int sel> void sample_start_w(u8 data);
	template<int sel> u8 sample_start_r();
	template<int sel> void sample_end_w(u8 data);
	template<int sel> u8 sample_end_r();
	void sample_format_w(u8 data);
	u8 sample_format_r();
	template<int sel> void sample_address_w(u8 data);
	template<int sel> u8 sample_address_r();

	void waverom_access_w(u8 data);
	template<int sel> u8 waverom_val_r();

	// Generic upload port, connected to the EQ on the first swp20
	void eq_w(u8 data);

	// Generic catch-all
	u8 snd_r(offs_t offset);
	void snd_w(offs_t offset, u8 data);
};

DECLARE_DEVICE_TYPE(SWP20, swp20_device)

#endif // MAME_SOUND_SWP20_H