summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/phoenix.h
blob: 217b613411640c1237d2e61c0f6053936f297f9c (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
// license:BSD-3-Clause
// copyright-holders:Richard Davies
#ifndef MAME_AUDIO_PHOENIX_H
#define MAME_AUDIO_PHOENIX_H

#pragma once

#include "sound/discrete.h"
#include "sound/tms36xx.h"


class phoenix_sound_device : public device_t, public device_sound_interface
{
public:
	phoenix_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);

	DECLARE_WRITE8_MEMBER( control_a_w );
	DECLARE_WRITE8_MEMBER( control_b_w );

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

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

private:
	struct c_state
	{
		int32_t counter;
		int32_t level;
	};

	struct n_state
	{
		int32_t counter;
		int32_t polyoffs;
		int32_t polybit;
		int32_t lowpass_counter;
		int32_t lowpass_polybit;
	};

	// internal state
	struct c_state      m_c24_state;
	struct c_state      m_c25_state;
	struct n_state      m_noise_state;
	uint8_t               m_sound_latch_a;
	sound_stream *      m_channel;
	std::unique_ptr<uint32_t[]>                m_poly18;
	required_device<discrete_device> m_discrete;
	required_device<tms36xx_device> m_tms;

	int update_c24(int samplerate);
	int update_c25(int samplerate);
	int noise(int samplerate);
};

DECLARE_DEVICE_TYPE(PHOENIX_SOUND, phoenix_sound_device)

DISCRETE_SOUND_EXTERN(phoenix_discrete);

#endif // MAME_AUDIO_PHOENIX_H