summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/sid.h
blob: 0b0af441879b6018f3810535871ba376008e1342 (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
// license:BSD-3-Clause
// copyright-holders:Peter Trauner
#ifndef MAME_SOUND_SID_H
#define MAME_SOUND_SID_H

#pragma once

/*
  approximation of the sid6581 chip
  this part is for one chip,
*/

#include "sidvoice.h"

/* private area */
struct SID6581_t
{
	static constexpr uint8_t max_voices = 3;

	device_t *device = nullptr;
	sound_stream *mixer_channel = nullptr; // mame stream/ mixer channel

	int type = 0;
	uint32_t clock = 0;

	uint16_t PCMfreq = 0; // samplerate of the current systems soundcard/DAC
	uint32_t PCMsid = 0, PCMsidNoise = 0;

#if 0
	/* following depends on type */
	ptr2sidVoidFunc ModeNormalTable[16]{ nullptr };
	ptr2sidVoidFunc ModeRingTable[16]{ nullptr };
	// for speed reason it could be better to make them global!
	uint8_t *waveform30 = nullptr;
	uint8_t *waveform50 = nullptr;
	uint8_t *waveform60 = nullptr;
	uint8_t *waveform70 = nullptr;
#endif
	int reg[0x20]{ 0 };

//  bool sidKeysOn[0x20]{ false }, sidKeysOff[0x20]{ false };

	uint8_t masterVolume = 0;
	uint16_t masterVolumeAmplIndex = 0;

	struct
	{
		int Enabled = 0;
		uint8_t Type = 0, CurType = 0;
		float Dy = 0.0, ResDy = 0.0;
		uint16_t Value = 0;
	} filter;

	sidOperator optr[max_voices];
	int optr3_outputmask = 0;

	void init();

	bool reset();

	void postload();

	int port_r(running_machine &machine, int offset);
	void port_w(int offset, int data);

	void fill_buffer(write_stream_view &buffer);

private:
	void syncEm();
};

#endif // MAME_SOUND_SID_H