Previous 15994 Revisions Next

r5726 Monday 14th September, 2009 at 09:45:45 UTC by Curt Coder
[VIP] Added VP550 sync interrupt.
[src/mess/audio]vp550.c vp550.h
[src/mess/drivers]vip.c

src/mess/audio/vp550.c
r5725r5726
1111
1212   TODO:
1313
14   - octave (CD22100)
15   - amplitude (CD4508)
16   - tempo interrupt
14   - tempo control
1715   - mono/stereo mode
16   - VP551 memory map
1817
1918*/
2019
r5725r5726
2726    PARAMETERS
2827***************************************************************************/
2928
29#define LOG 0
30
31#define MAX_CHANNELS   4
32
3033#define CDP1863_A_TAG   "u1"
3134#define CDP1863_B_TAG   "u2"
35#define CDP1863_C_TAG   "cdp1863c"
36#define CDP1863_D_TAG   "cdp1863d"
3237
38enum
39{
40   CHANNEL_A = 0,
41   CHANNEL_B,
42   CHANNEL_C,
43   CHANNEL_D
44};
45
3346/***************************************************************************
3447    TYPE DEFINITIONS
3548***************************************************************************/
r5725r5726
3750typedef struct _vp550_t vp550_t;
3851struct _vp550_t
3952{
40   int ie;                        /* interrupt enable */
53   int channels;                  /* number of channels */
4154
4255   /* devices */
43   const device_config *cdp1863_a;
44   const device_config *cdp1863_b;
56   const device_config *cdp1863[MAX_CHANNELS];
57   const device_config *sync_timer;
4558};
4659
4760/***************************************************************************
r5725r5726
5265{
5366   assert(device != NULL);
5467   assert(device->token != NULL);
55   assert(device->type == VP550);
68   assert((device->type == VP550) || (device->type == VP551));
5669   return (vp550_t *)device->token;
5770}
5871
r5725r5726
6881{
6982   vp550_t *vp550 = get_safe_token(device);
7083
71   cdp1863_oe_w(vp550->cdp1863_a, state);
72   cdp1863_oe_w(vp550->cdp1863_b, state);
84   int channel;
85
86   for (channel = CHANNEL_A; channel < vp550->channels; channel++)
87   {
88      cdp1863_oe_w(vp550->cdp1863[channel], state);
89   }
7390}
7491
7592/*-------------------------------------------------
76    vp550_octave_w -
93    vp550_sc1_w - SC1 line write
7794-------------------------------------------------*/
7895
96WRITE_LINE_DEVICE_HANDLER( vp550_sc1_w )
97{
98   if (state)
99   {
100      cpu_set_input_line(device->machine->firstcpu, CDP1802_INPUT_LINE_INT, CLEAR_LINE);
101
102      if (LOG) logerror("VP550 Clear Interrupt\n");
103   }
104}
105
106/*-------------------------------------------------
107    vp550_octave_w - octave select write
108-------------------------------------------------*/
109
79110static WRITE8_DEVICE_HANDLER( vp550_octave_w )
80111{
112   vp550_t *vp550 = get_safe_token(device);
113
114   int channel = (data >> 2) & 0x03;
115   int clock = 0;
116
117   if (data & 0x10)
118   {
119      switch (data & 0x03)
120      {
121      case 0: clock = device->clock / 8; break;
122      case 1: clock = device->clock / 4; break;
123      case 2: clock = device->clock / 2; break;
124      case 3: clock = device->clock;      break;
125      }
126   }
127
128   if (vp550->cdp1863[channel]) cdp1863_set_clk2(vp550->cdp1863[channel], clock);
129
130   if (LOG) logerror("VP550 Clock %c: %u Hz\n", 'A' + channel, clock);
81131}
82132
83133/*-------------------------------------------------
r5725r5726
86136
87137static WRITE8_DEVICE_HANDLER( vp550_vlmna_w )
88138{
139   vp550_t *vp550 = get_safe_token(device);
140   float gain = 0.625f * (data & 0x0f);
141
142   sound_set_output_gain(vp550->cdp1863[CHANNEL_A], 0, gain);
143
144   if (LOG) logerror("VP550 Volume A: %u\n", data & 0x0f);
89145}
90146
91147/*-------------------------------------------------
r5725r5726
94150
95151static WRITE8_DEVICE_HANDLER( vp550_vlmnb_w )
96152{
153   vp550_t *vp550 = get_safe_token(device);
154   float gain = 0.625f * (data & 0x0f);
155
156   sound_set_output_gain(vp550->cdp1863[CHANNEL_B], 0, gain);
157
158   if (LOG) logerror("VP550 Volume B: %u\n", data & 0x0f);
97159}
98160
99161/*-------------------------------------------------
r5725r5726
102164
103165static WRITE8_DEVICE_HANDLER( vp550_sync_w )
104166{
167   vp550_t *vp550 = get_safe_token(device);
168
169   timer_device_enable(vp550->sync_timer, BIT(data, 0));
170   
171   if (LOG) logerror("VP550 Interrupt Enable: %u\n", BIT(data, 0));
105172}
106173
107174/*-------------------------------------------------
r5725r5726
115182
116183   if (enabled)
117184   {
118      memory_install_write8_device_handler(program, vp550->cdp1863_a, 0x8001, 0x8001, 0, 0, cdp1863_str_w);
119      memory_install_write8_device_handler(program, vp550->cdp1863_b, 0x8002, 0x8002, 0, 0, cdp1863_str_w);
185      memory_install_write8_device_handler(program, vp550->cdp1863[CHANNEL_A], 0x8001, 0x8001, 0, 0, cdp1863_str_w);
186      memory_install_write8_device_handler(program, vp550->cdp1863[CHANNEL_B], 0x8002, 0x8002, 0, 0, cdp1863_str_w);
120187      memory_install_write8_device_handler(program, device, 0x8003, 0x8003, 0, 0, vp550_octave_w);
121188      memory_install_write8_device_handler(program, device, 0x8010, 0x8010, 0, 0, vp550_vlmna_w);
122189      memory_install_write8_device_handler(program, device, 0x8020, 0x8020, 0, 0, vp550_vlmnb_w);
r5725r5726
134201}
135202
136203/*-------------------------------------------------
204    TIMER_DEVICE_CALLBACK( sync_tick )
205-------------------------------------------------*/
206
207static TIMER_DEVICE_CALLBACK( sync_tick )
208{
209   cpu_set_input_line(timer->machine->firstcpu, CDP1802_INPUT_LINE_INT, ASSERT_LINE);
210   
211   if (LOG) logerror("VP550 Interrupt\n");
212}
213
214/*-------------------------------------------------
137215    MACHINE_DRIVER( vp550 )
138216-------------------------------------------------*/
139217
140218static MACHINE_DRIVER_START( vp550 )
219   MDRV_TIMER_ADD_PERIODIC("sync", sync_tick, HZ(50))
220
141221   MDRV_CDP1863_ADD(CDP1863_A_TAG, 0, 0)
142222   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
143223
r5725r5726
146226MACHINE_DRIVER_END
147227
148228/*-------------------------------------------------
229    MACHINE_DRIVER( vp551 )
230-------------------------------------------------*/
231
232static MACHINE_DRIVER_START( vp551 )
233   MDRV_IMPORT_FROM(vp550)
234
235   MDRV_CDP1863_ADD(CDP1863_C_TAG, 0, 0)
236   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
237
238   MDRV_CDP1863_ADD(CDP1863_D_TAG, 0, 0)
239   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
240MACHINE_DRIVER_END
241
242/*-------------------------------------------------
149243    DEVICE_START( vp550 )
150244-------------------------------------------------*/
151245
r5725r5726
154248   vp550_t *vp550 = get_safe_token(device);
155249
156250   /* look up devices */
157   vp550->cdp1863_a = devtag_get_device(device->machine, "vp550:u1");
158   vp550->cdp1863_b = devtag_get_device(device->machine, "vp550:u2");
159   assert(vp550->cdp1863_a != NULL);
160   assert(vp550->cdp1863_b != NULL);
251   vp550->cdp1863[CHANNEL_A] = devtag_get_device(device->machine, "vp550:u1");
252   vp550->cdp1863[CHANNEL_B] = devtag_get_device(device->machine, "vp550:u2");
253   vp550->sync_timer = devtag_get_device(device->machine, "vp550:sync");
161254
162   /* register for state saving */
163   state_save_register_global(device->machine, vp550->ie);
255   /* set initial values */
256   vp550->channels = 2;
164257}
165258
166259/*-------------------------------------------------
260    DEVICE_START( vp551 )
261-------------------------------------------------*/
262
263static DEVICE_START( vp551 )
264{
265   vp550_t *vp550 = get_safe_token(device);
266
267   /* look up devices */
268   vp550->cdp1863[CHANNEL_A] = devtag_get_device(device->machine, "vp551:u1");
269   vp550->cdp1863[CHANNEL_B] = devtag_get_device(device->machine, "vp551:u2");
270   vp550->cdp1863[CHANNEL_C] = devtag_get_device(device->machine, "vp551:cdp1863c");
271   vp550->cdp1863[CHANNEL_D] = devtag_get_device(device->machine, "vp551:cdp1863d");
272   vp550->sync_timer = devtag_get_device(device->machine, "vp551:sync");
273
274   /* set initial values */
275   vp550->channels = 4;
276}
277
278/*-------------------------------------------------
167279    DEVICE_RESET( vp550 )
168280-------------------------------------------------*/
169281
r5725r5726
171283{
172284   vp550_t *vp550 = get_safe_token(device);
173285
174   device_reset(vp550->cdp1863_a);
175   device_reset(vp550->cdp1863_b);
286   /* reset chips */
287   device_reset(vp550->cdp1863[CHANNEL_A]);
288   device_reset(vp550->cdp1863[CHANNEL_B]);
176289
290   /* disable interrupt timer */
291   timer_device_enable(vp550->sync_timer, 0);
292
293   /* clear interrupt */
177294   cpu_set_input_line(device->machine->firstcpu, CDP1802_INPUT_LINE_INT, CLEAR_LINE);
178295}
179296
180297/*-------------------------------------------------
298    DEVICE_RESET( vp551 )
299-------------------------------------------------*/
300
301static DEVICE_RESET( vp551 )
302{
303   vp550_t *vp550 = get_safe_token(device);
304
305   DEVICE_RESET_CALL(vp550);
306
307   /* reset chips */
308   device_reset(vp550->cdp1863[CHANNEL_C]);
309   device_reset(vp550->cdp1863[CHANNEL_D]);
310}
311
312/*-------------------------------------------------
181313    DEVICE_GET_INFO( vp550 )
182314-------------------------------------------------*/
183315
r5725r5726
206338      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
207339   }
208340}
341
342/*-------------------------------------------------
343    DEVICE_GET_INFO( vp551 )
344-------------------------------------------------*/
345
346DEVICE_GET_INFO( vp551 )
347{
348   switch (state)
349   {
350      /* --- the following bits of info are returned as 64-bit signed integers --- */
351      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(vp550_t);               break;
352      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
353      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
354
355      /* --- the following bits of info are returned as pointers --- */
356      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = machine_config_vp551;break;
357
358      /* --- the following bits of info are returned as pointers to data or functions --- */
359      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(vp551);      break;
360      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
361      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(vp551);      break;
362
363      /* --- the following bits of info are returned as NULL-terminated strings --- */
364      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA VP551");            break;
365      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA VIP");               break;
366      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
367      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
368      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
369   }
370}
src/mess/audio/vp550.h
r5725r5726
1717***************************************************************************/
1818
1919#define VP550_TAG   "vp550"
20#define VP551_TAG   "vp551"
2021
2122#define VP550 DEVICE_GET_INFO_NAME(vp550)
23#define VP551 DEVICE_GET_INFO_NAME(vp551)
2224
2325#define MDRV_VP550_ADD(_clock) \
2426   MDRV_DEVICE_ADD(VP550_TAG, VP550, _clock)
2527
28#define MDRV_VP551_ADD(_clock) \
29   MDRV_DEVICE_ADD(VP551_TAG, VP551, _clock)
30
2631/***************************************************************************
2732    PROTOTYPES
2833***************************************************************************/
2934
3035/* device interface */
3136DEVICE_GET_INFO( vp550 );
37DEVICE_GET_INFO( vp551 );
3238
3339/* Q line */
3440WRITE_LINE_DEVICE_HANDLER( vp550_q_w ) ATTR_NONNULL(1);
3541
42/* SC1 line */
43WRITE_LINE_DEVICE_HANDLER( vp550_sc1_w ) ATTR_NONNULL(1);
44
3645/* install write handlers */
3746void vp550_install_write_handlers(const device_config *device, const address_space *program, int enabled) ATTR_NONNULL(1) ATTR_NONNULL(2);
3847
src/mess/drivers/vip.c
r5725r5726
533533   return flags;
534534}
535535
536static CDP1802_SC_WRITE( vip_sc_w )
537{
538   vip_state *driver_state = device->machine->driver_data;
539
540   switch (input_port_read(device->machine, "SOUND"))
541   {
542   case VIP_SOUND_VP550:
543      vp550_sc1_w(driver_state->vp550, sc1);
544      break;
545
546   case VIP_SOUND_VP551:
547//      vp551_sc1_w(driver_state->vp551, sc1);
548      break;
549   }
550}
551
536552static WRITE_LINE_DEVICE_HANDLER( vip_q_w )
537553{
538554   vip_state *driver_state = device->machine->driver_data;
r5725r5726
600616{
601617   vip_mode_r,
602618   vip_ef_r,
603   NULL,
619   vip_sc_w,
604620   DEVCB_LINE(vip_q_w),
605621   DEVCB_NULL,
606622   DEVCB_HANDLER(vip_dma_w)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team