summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/gamate.h
blob: 868df1157a6ae0949c195cd37137b5a85ce81119 (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
// license:GPL-2.0+
// copyright-holders:Peter Trauner
/*****************************************************************************
 *
 * includes/gamate.h
 *
 ****************************************************************************/

#ifndef GAMATE_H_
#define GAMATE_H_

#include "cpu/m6502/m6502.h"
#include "bus/generic/slot.h"
#include "bus/generic/carts.h"


// ======================> gamate_sound_device

class gamate_sound_device : public device_t, public device_sound_interface
{
public:
	gamate_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	~gamate_sound_device() { }

	DECLARE_WRITE8_MEMBER( device_w );
	DECLARE_READ8_MEMBER( device_r );

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:

	static const int DAConverter[];
	static int Value2Volume(int volume) { return DAConverter[volume]*1; }

	sound_stream *m_mixer_channel;
	struct Tone
	{
		Tone() :
			envelope_on(false),
			level(false),
			tone(false), full_cycle(false),
			volume(0),
			pos(0),
			size(0)
			{}

		bool envelope_on, level;
		bool tone/*else noise*/, full_cycle/* else square signal/pulse */;
		int volume;
		int pos, size;
	};

	enum
	{
		Right,
		Left,
		Both
	};

	Tone m_channels[3];

	struct Noise
	{
		Noise():
			state(1),
			level(false),
			step(0.0),
			pos(0.0)
			{}

		int state;
		bool level;
		double step, pos;
	} noise;

	struct Envelope
	{
		Envelope():
			control(0),
			index(0),
			first(false)
			{}

		int control;
		int index;
		bool first;
		double step, pos;
	} envelope;

	UINT8 reg[14];
};

extern const device_type GAMATE_SND;

#endif /* GAMATE_H_ */