blob: 1c77be39b981f05547476435f8333123786ea7fe (
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
|
// license:BSD-3-Clause
// copyright-holders:Valley Bell
#ifndef MAME_SOUND_ROLANDPCM_H
#define MAME_SOUND_ROLANDPCM_H
#pragma once
#include "dirom.h"
class mb87419_mb87420_device : public device_t, public device_sound_interface, public device_rom_interface<22>
{
public:
mb87419_mb87420_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
auto int_callback() { return m_int_callback.bind(); }
u8 read(offs_t offset);
void write(offs_t offset, u8 data);
protected:
// device-level overrides
virtual void device_resolve_objects() override;
virtual void device_start() override;
virtual void device_reset() override;
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
// device_rom_interface overrides
virtual void rom_bank_updated() override;
static int16_t decode_sample(int8_t data);
static int16_t sample_interpolate(int16_t smp1, int16_t smp2, uint16_t frac);
private:
static constexpr unsigned NUM_CHANNELS = 32;
struct pcm_channel
{
pcm_channel() { }
// registers
uint16_t mode = 0;
uint16_t bank = 0;
uint16_t step = 0; // 2.14 fixed point (0x4000 equals 32000 Hz)
uint16_t volume = 0;
uint32_t start = 0; // start address (18.14 fixed point)
uint16_t end = 0; // end offset (high word)
uint16_t loop = 0; // loop offset (high word)
// work variables
bool enable = false;
int8_t play_dir = 0; // playing direction, -1 [backwards] / 0 [stopped] / +1 [forwards]
uint32_t addr = 0; // current address
int16_t smpl_cur = 0; // current sample
int16_t smpl_nxt = 0; // next sample
};
devcb_write_line m_int_callback;
uint32_t m_clock; // clock
uint32_t m_rate; // sample rate (usually 32000 Hz)
sound_stream* m_stream; // stream handle
pcm_channel m_chns[NUM_CHANNELS]; // channel memory
uint8_t m_sel_chn; // selected channel
};
DECLARE_DEVICE_TYPE(MB87419_MB87420, mb87419_mb87420_device)
#endif // MAME_SOUND_ROLANDPCM_H
|