summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/i5000.h
blob: fce3659d07280f736695d0fc6c76c4152b136cda (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
// license:BSD-3-Clause
// copyright-holders:hap
/***************************************************************************

    i5000.h - Imagetek I5000 sound emulator

***************************************************************************/

#pragma once

#ifndef __I5000_H__
#define __I5000_H__

#include "sound/okiadpcm.h"


//**************************************************************************
//  INTERFACE CONFIGURATION MACROS
//**************************************************************************

#define MCFG_I5000_SND_ADD(_tag, _clock) \
	MCFG_DEVICE_ADD(_tag, I5000_SND, _clock)

#define MCFG_I5000_SND_REPLACE(_tag, _clock) \
	MCFG_DEVICE_REPLACE(_tag, I5000_SND, _clock)


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

class i5000snd_device : public device_t,
						public device_sound_interface
{
public:
	// construction/destruction
	i5000snd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);

	DECLARE_READ16_MEMBER(read);
	DECLARE_WRITE16_MEMBER(write);

	sound_stream *m_stream;

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;

private:
	struct channel_t
	{
		bool is_playing;
		oki_adpcm_state m_adpcm;

		UINT32 address;
		int freq_timer;
		int freq_base;
		int freq_min;
		UINT16 sample;
		UINT8 shift_pos;
		UINT8 shift_amount;
		UINT8 shift_mask;
		int vol_r;
		int vol_l;
		int output_r;
		int output_l;

	};

	channel_t m_channels[16];

	UINT16 m_regs[0x80];

	UINT16 *m_rom_base;
	UINT32 m_rom_mask;

	int m_lut_volume[0x100];

	bool read_sample(int ch);
	void write_reg16(UINT8 reg, UINT16 data);
};


// device type definition
extern const device_type I5000_SND;

#endif /* __I5000_H__ */