summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/pleiads.h
blob: 0c116bd1b266640f760fef96905b80bf3343d2d0 (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
// license:GPL-2.0+
// copyright-holders:Juergen Buchmueller
#include "sound/tms36xx.h"

struct pl_t_state
{
		pl_t_state():
		counter(0),
		output(0),
		max_freq(0) {}

	int counter;
	int output;
	int max_freq;
};

struct pl_c_state
{
		pl_c_state():
		counter(0),
		level(0),
		charge_time(0),
		discharge_time(0) {}

	int counter;
	int level;
	double charge_time;
	double discharge_time;
};

struct pl_n_state
{
		pl_n_state():
		counter(0),
		polyoffs(0),
		freq(0) {}

	int counter;
	int polyoffs;
	int freq;
};

class pleiads_sound_device : public device_t,
									public device_sound_interface
{
public:
	pleiads_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	pleiads_sound_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
	~pleiads_sound_device() {}

	DECLARE_WRITE8_MEMBER( control_a_w );
	DECLARE_WRITE8_MEMBER( control_b_w );
	DECLARE_WRITE8_MEMBER( control_c_w );

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

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

	void common_start();
	inline int tone1(int samplerate);
	inline int update_pb4(int samplerate);
	inline int tone23(int samplerate);
	inline int update_c_pc4(int samplerate);
	inline int update_c_pc5(int samplerate);
	inline int update_c_pa5(int samplerate);
	inline int tone4(int samplerate);
	inline int update_c_pa6(int samplerate);
	inline int noise(int samplerate);

	// internal state
	tms36xx_device *m_tms;
	sound_stream *m_channel;

	int m_sound_latch_a;
	int m_sound_latch_b;
	int m_sound_latch_c;    /* part of the videoreg_w latch */

	UINT32 *m_poly18;
	int m_polybit;

	pl_t_state m_tone1;
	pl_t_state m_tone2;
	pl_t_state m_tone3;
	pl_t_state m_tone4;

	pl_c_state m_pa5;
	pl_c_state m_pa6;
	pl_c_state m_pb4;
	pl_c_state m_pc4;
	pl_c_state m_pc5;

	pl_n_state m_noise;

	int m_pa5_resistor;
	int m_pc5_resistor;
	int m_polybit_resistor;
	int m_opamp_resistor;
};

extern const device_type PLEIADS;

class naughtyb_sound_device : public pleiads_sound_device
{
public:
	naughtyb_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
protected:
	// device-level overrides
	virtual void device_config_complete();
	virtual void device_start();

	// sound stream update overrides
	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
private:
	// internal state
};

extern const device_type NAUGHTYB;

class popflame_sound_device : public pleiads_sound_device
{
public:
	popflame_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
protected:
	// device-level overrides
	virtual void device_config_complete();
	virtual void device_start();

	// sound stream update overrides
	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
private:
	// internal state
};

extern const device_type POPFLAME;