summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/asc.h
blob: b074494e8c8b2334a4ba8307009e72e7930f4254 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/***************************************************************************

    asc.h

    Apple Sound Chip (ASC) 344S0063
    Enhanced Apple Sound Chip (EASC) 343S1063

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

#pragma once

#ifndef __ASC_H__
#define __ASC_H__

#include "streams.h"



//**************************************************************************
//  CONSTANTS
//**************************************************************************

// chip behavior types
enum
{
	ASC_TYPE_ASC = 0,	// original discrete Apple Sound Chip
	ASC_TYPE_EASC = 1,	// discrete Enhanced Apple Sound Chip
	ASC_TYPE_V8 = 2,	// Subset of ASC included in the V8 ASIC (LC/LCII)
	ASC_TYPE_EAGLE = 3,	// Subset of ASC included in the Eagle ASIC (Classic II)
	ASC_TYPE_SPICE = 4,	// Subset of ASC included in the Spice ASIC (Color Classic)
	ASC_TYPE_SONORA = 5,	// Subset of ASC included in the Sonora ASIC (LCIII)
	ASC_TYPE_VASP = 6,	// Subset of ASC included in the VASP ASIC  (IIvx/IIvi)
	ASC_TYPE_ARDBEG = 7	// Subset of ASC included in the Ardbeg ASIC (LC520)
};



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

#define MDRV_ASC_ADD(_tag, _clock, _type, _irqf) \
	MDRV_DEVICE_ADD(_tag, ASC, _clock) \
	MDRV_ASC_TYPE(_type) \
	MDRV_IRQ_FUNC(_irqf)

#define MDRV_ASC_REPLACE(_tag, _clock, _type, _irqf) \
	MDRV_DEVICE_REPLACE(_tag, ASC, _clock) \
	MDRV_ASC_TYPE(_type) \
	MDRV_IRQ_FUNC(_irqf)

#define MDRV_ASC_TYPE(_type) \
	asc_device_config::static_set_type(device, _type); \

#define MDRV_IRQ_FUNC(_irqf) \
	asc_device_config::static_set_irqf(device, _irqf); \


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

// ======================> asc_device_config

class asc_device_config :	public device_config, public device_config_sound_interface
{
	friend class asc_device;

	// construction/destruction
	asc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);

public:
	// allocators
	static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
	virtual device_t *alloc_device(running_machine &machine) const;

	// inline configuration helpers
	static void static_set_type(device_config *device, int type);
	static void static_set_irqf(device_config *device, void (*irqf)(running_device *device, int state));

protected:
	// inline data
	UINT8			m_type;
	void (*m_irq_func)(running_device *device, int state);
};



// ======================> asc_device

class asc_device : public device_t, public device_sound_interface
{
	friend class asc_device_config;

	// construction/destruction
	asc_device(running_machine &_machine, const asc_device_config &config);

public:
	DECLARE_READ8_MEMBER(read);
	DECLARE_WRITE8_MEMBER(write);

	sound_stream *m_stream;

protected:
	enum
	{
		R_VERSION = 0x800,
		R_MODE,
		R_CONTROL,
		R_FIFOMODE,
		R_FIFOSTAT,
		R_WTCONTROL,
		R_VOLUME,
		R_CLOCK,
		R_REG8,
		R_REG9,
		R_PLAYRECA,
		R_REGB,
		R_REGC,
		R_REGD,
		R_REGE,
		R_TEST
	};

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

	// internal callbacks
	static STREAM_UPDATE( static_stream_generate );
	virtual void stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples);

	// internal state
	const asc_device_config &m_config;

	UINT8	m_chip_type;
	void (*m_irq_cb)(running_device *device, int state);

	UINT8	m_fifo_a[0x400];
	UINT8	m_fifo_b[0x400];

	UINT8	m_regs[0x800];

	UINT32	m_phase[4], m_incr[4];

	int	m_fifo_a_rdptr, m_fifo_b_rdptr;
	int	m_fifo_a_wrptr, m_fifo_b_wrptr;
	int 	m_fifo_cap_a, m_fifo_cap_b;

	emu_timer *m_sync_timer;
};


// device type definition
extern const device_type ASC;


#endif /* __ASC_H__ */