Previous 15994 Revisions Next

r11129 Sunday 10th April, 2011 at 08:38:01 UTC by Curt Coder
Deleted unused files, this is already in emu folder. (no whatsnew)
[src/mess/audio]cdp1863.c cdp1863.h

src/mess/audio/cdp1863.c
r11128r11129
1/*
2
3    TODO:
4
5    - what happens if you connect both clocks?
6    - convert to sound device when possible
7
8*/
9
10#include "emu.h"
11#include "streams.h"
12#include "audio/cdp1863.h"
13
14#define CDP1863_DEFAULT_LATCH   0x35
15
16typedef struct _cdp1863_t cdp1863_t;
17struct _cdp1863_t
18{
19   const cdp1863_interface *intf;   /* interface */
20
21   sound_stream *stream;         /* sound output */
22
23   /* sound state */
24   int oe;                     /* output enable */
25   int latch;                  /* sound latch */
26   INT16 signal;               /* current signal */
27   int incr;                  /* initial wave state */
28};
29
30INLINE cdp1863_t *get_safe_token(device_t *device)
31{
32   assert(device != NULL);
33
34   return (cdp1863_t *)downcast<legacy_device_base *>(device)->token();
35}
36
37/* Load Tone Latch */
38
39WRITE8_DEVICE_HANDLER( cdp1863_str_w )
40{
41   cdp1863_t *cdp1863 = get_safe_token(device);
42   double frequency;
43
44   cdp1863->latch = data;
45
46   if (cdp1863->intf->clock1 > 0)
47   {
48      /* CLK1 is pre-divided by 4 */
49      frequency = cdp1863->intf->clock1 / 4 / (data + 1) / 2;
50   }
51   else
52   {
53      /* CLK2 is pre-divided by 8 */
54      frequency = cdp1863->intf->clock2 / 8 / (data + 1) / 2;
55   }
56
57   beep_set_frequency(0, frequency);
58}
59
60/* Output Enable */
61
62void cdp1863_oe_w(device_t *device, int level)
63{
64   cdp1863_t *cdp1863 = get_safe_token(device);
65
66   cdp1863->oe = level;
67
68   beep_set_state(0, level);
69}
70
71#ifdef UNUSED_FUNCTION
72static void cdp1863_sound_update(device_t *device, stream_sample_t **inputs, stream_sample_t **_buffer, int length)
73{
74   cdp1863_t *cdp1863 = get_safe_token(device);
75
76   INT16 signal = cdp1863->signal;
77   stream_sample_t *buffer = _buffer[0];
78
79   memset(buffer, 0, length * sizeof(*buffer));
80
81   if (cdp1863->oe)
82   {
83      double frequency;
84      int rate = device->machine().sample_rate() / 2;
85
86      /* get progress through wave */
87      int incr = cdp1863->incr;
88
89      if (cdp1863->intf->clock1 > 0)
90      {
91         /* CLK1 is pre-divided by 4 */
92         frequency = cdp1863->intf->clock1 / 4 / (cdp1863->latch + 1) / 2;
93      }
94      else
95      {
96         /* CLK2 is pre-divided by 8 */
97         frequency = cdp1863->intf->clock2 / 8 / (cdp1863->latch + 1) / 2;
98      }
99
100      if (signal < 0)
101      {
102         signal = -0x7fff;
103      }
104      else
105      {
106         signal = 0x7fff;
107      }
108
109      while( length-- > 0 )
110      {
111         *buffer++ = signal;
112         incr -= frequency;
113         while( incr < 0 )
114         {
115            incr += rate;
116            signal = -signal;
117         }
118      }
119
120      /* store progress through wave */
121      cdp1863->incr = incr;
122      cdp1863->signal = signal;
123   }
124}
125#endif
126
127/* Device Interface */
128
129static DEVICE_START( cdp1863 )
130{
131   cdp1863_t *cdp1863 = get_safe_token(device);
132
133   /* validate arguments */
134   assert(device != NULL);
135   assert(device->tag() != NULL);
136
137   cdp1863->intf = device->baseconfig().static_config();
138
139   assert(cdp1863->intf != NULL);
140   assert((cdp1863->intf->clock1 > 0) || (cdp1863->intf->clock2 > 0));
141
142   cdp1863->oe = 1;
143
144   /* register for state saving */
145   device->save_item(NAME(cdp1863->oe));
146   device->save_item(NAME(cdp1863->latch));
147   device->save_item(NAME(cdp1863->signal));
148   device->save_item(NAME(cdp1863->incr));
149}
150
151static DEVICE_RESET( cdp1863 )
152{
153   cdp1863_t *cdp1863 = get_safe_token(device);
154
155   cdp1863->latch = CDP1863_DEFAULT_LATCH;
156}
157
158DEVICE_GET_INFO( cdp1863 )
159{
160   switch (state)
161   {
162      /* --- the following bits of info are returned as 64-bit signed integers --- */
163      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cdp1863_t);            break;
164      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
165
166      /* --- the following bits of info are returned as pointers to data or functions --- */
167      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cdp1863);   break;
168      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
169      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(cdp1863);   break;
170
171      /* --- the following bits of info are returned as NULL-terminated strings --- */
172      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA CDP1863");               break;
173      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA CDP1800");               break;
174      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                     break;
175      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
176      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");         break;
177   }
178}
179
180DEFINE_LEGACY_DEVICE(CDP1863, cdp1863);
src/mess/audio/cdp1863.h
r11128r11129
1/*
2
3              CDP1863 CMOS 8-Bit Programmable Frequency Generator
4
5                                ________________
6                _RESET   1  ---|       \/       |---  16  Vdd
7                 CLK 2   2  ---|                |---  15  OE
8                 CLK 1   3  ---|                |---  14  OUT
9                   STR   4  ---|    CDP1863C    |---  13  DI7
10                   DI0   5  ---|                |---  12  DI6
11                   DI1   6  ---|                |---  11  DI5
12                   DI2   7  ---|                |---  10  DI4
13                   Vss   8  ---|________________|---  9   DI3
14
15*/
16
17#ifndef __CDP1863__
18#define __CDP1863__
19
20#include "sound/beep.h"
21
22DECLARE_LEGACY_DEVICE(CDP1863, cdp1863);
23
24/* interface */
25typedef struct _cdp1863_interface cdp1863_interface;
26struct _cdp1863_interface
27{
28   int clock1;               /* the clock 1 (pin 3) of the chip */
29   int clock2;               /* the clock 2 (pin 2) of the chip */
30};
31#define CDP1863_INTERFACE(name) const cdp1863_interface (name)=
32
33/* load tone latch */
34WRITE8_DEVICE_HANDLER( cdp1863_str_w );
35
36/* output enable */
37void cdp1863_oe_w(device_t *device, int level);
38
39#endif

Previous 15994 Revisions Next


© 1998-2018 The MESS Team