summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/cdp1863.h
blob: 85143f25a4acb1eb8b7b3000b3a5b2f6da759393 (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
/**********************************************************************

    RCA CDP1863 CMOS 8-Bit Programmable Frequency Generator emulation

    Copyright MESS Team.
    Visit http://mamedev.org for licensing and usage restrictions.

**********************************************************************
                            _____   _____
                _RESET   1 |*    \_/     | 16  Vdd
                 CLK 2   2 |             | 15  OE
                 CLK 1   3 |             | 14  OUT
                   STR   4 |   CDP1863   | 13  DO7
                   DI0   5 |             | 12  DI6
                   DI1   6 |             | 11  DI5
                   DI2   7 |             | 10  DI4
                   Vss   8 |_____________| 9   DI3

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

#pragma once

#ifndef __CDP1863__
#define __CDP1863__

#include "emu.h"



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

#define MCFG_CDP1863_ADD(_tag, _clock, _clock2) \
	MCFG_DEVICE_ADD(_tag, CDP1863, _clock) \
	cdp1863_device_config::static_set_config(device, _clock2);



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

// ======================> cdp1863_device_config

class cdp1863_device_config :   public device_config,
								public device_config_sound_interface
{
    friend class cdp1863_device;

    // construction/destruction
    cdp1863_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_config(device_config *device, int clock2);

private:
	int m_clock2;
};


// ======================> cdp1863_device

class cdp1863_device :	public device_t,
						public device_sound_interface
{
    friend class cdp1863_device_config;

    // construction/destruction
    cdp1863_device(running_machine &_machine, const cdp1863_device_config &_config);

public:
	DECLARE_WRITE8_MEMBER( str_w );
	void str_w(UINT8 data);
	
	DECLARE_WRITE_LINE_MEMBER( oe_w );
	
	void set_clk1(int clock);
	void set_clk2(int clock);

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

	// internal callbacks
	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);

private:
	sound_stream *m_stream;

	int m_clock1;					// clock 1
	int m_clock2;					// clock 2

	// sound state
	int m_oe;						// output enable
	int m_latch;					// sound latch
	INT16 m_signal;					// current signal
	int m_incr;						// initial wave state
	
	const cdp1863_device_config &m_config;
};


// device type definition
extern const device_type CDP1863;



#endif