Previous 15994 Revisions Next

r11281 Saturday 23rd April, 2011 at 21:33:13 UTC by Curt Coder
Refactored CDP1863, VP550, and VP595 into C++ devices. (no whatsnew)
[src/emu/sound]cdp1863.c cdp1863.h
[src/mess/audio]vp550.c vp550.h vp595.c vp595.h
[src/mess/drivers]vip.c
[src/mess/includes]vip.h

src/emu/sound/cdp1863.c
r11280r11281
1515
1616*/
1717
18#include "emu.h"
1918#include "cdp1863.h"
2019
21/***************************************************************************
22    PARAMETERS
23***************************************************************************/
2420
21
22//**************************************************************************
23//  MACROS / CONSTANTS
24//**************************************************************************
25
26#define LOG 0
27
28
2529#define CDP1863_DEFAULT_LATCH   0x35
2630
27/***************************************************************************
28    TYPE DEFINITIONS
29***************************************************************************/
3031
31typedef struct _cdp1863_t cdp1863_t;
32struct _cdp1863_t
33{
34   int clock1;                  /* clock 1 */
35   int clock2;                  /* clock 2 */
3632
37   sound_stream *stream;         /* sound output */
33//**************************************************************************
34//  GLOBAL VARIABLES
35//**************************************************************************
3836
39   /* sound state */
40   int oe;                     /* output enable */
41   int latch;                  /* sound latch */
42   INT16 signal;               /* current signal */
43   int incr;                  /* initial wave state */
44};
37// devices
38const device_type CDP1863 = cdp1863_device_config::static_alloc_device_config;
4539
46/***************************************************************************
47    INLINE FUNCTIONS
48***************************************************************************/
4940
50INLINE cdp1863_t *get_safe_token(device_t *device)
41
42//**************************************************************************
43//  DEVICE CONFIGURATION
44//**************************************************************************
45
46//-------------------------------------------------
47//  cdp1863_device_config - constructor
48//-------------------------------------------------
49
50cdp1863_device_config::cdp1863_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
51   : device_config(mconfig, static_alloc_device_config, "CDP1863", tag, owner, clock),
52     device_config_sound_interface(mconfig, *this)
5153{
52   assert(device != NULL);
53   return (cdp1863_t *)downcast<legacy_device_base *>(device)->token();
5454}
5555
56INLINE cdp1863_config *get_safe_config(device_t *device)
56
57//-------------------------------------------------
58//  static_alloc_device_config - allocate a new
59//  configuration object
60//-------------------------------------------------
61
62device_config *cdp1863_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
5763{
58   assert(device != NULL);
59   return (cdp1863_config *)downcast<const legacy_device_config_base &>(device->baseconfig()).inline_config();
64   return global_alloc(cdp1863_device_config(mconfig, tag, owner, clock));
6065}
6166
62/***************************************************************************
63    IMPLEMENTATION
64***************************************************************************/
6567
66/*-------------------------------------------------
67    cdp1863_str_w - tone latch write
68-------------------------------------------------*/
68//-------------------------------------------------
69//  alloc_device - allocate a new device object
70//-------------------------------------------------
6971
70WRITE8_DEVICE_HANDLER( cdp1863_str_w )
72device_t *cdp1863_device_config::alloc_device(running_machine &machine) const
7173{
72   cdp1863_t *cdp1863 = get_safe_token(device);
73
74   cdp1863->latch = data;
74   return auto_alloc(machine, cdp1863_device(machine, *this));
7575}
7676
77/*-------------------------------------------------
78    cdp1863_oe_w - output enable write
79------------------------------------------------*/
8077
81WRITE_LINE_DEVICE_HANDLER( cdp1863_oe_w )
78//-------------------------------------------------
79//  static_set_config - configuration helper
80//-------------------------------------------------
81
82void cdp1863_device_config::static_set_config(device_config *device, int clock2)
8283{
83   cdp1863_t *cdp1863 = get_safe_token(device);
84
85   cdp1863->oe = state;
84   cdp1863_device_config *cdp1863 = downcast<cdp1863_device_config *>(device);
85   
86   cdp1863->m_clock2 = clock2;
8687}
8788
88/*-------------------------------------------------
89    cdp1863_set_clk1 - set clock 1 frequency
90------------------------------------------------*/
9189
92void cdp1863_set_clk1(device_t *device, int frequency)
90
91//**************************************************************************
92//  LIVE DEVICE
93//**************************************************************************
94
95//-------------------------------------------------
96//  cdp1863_device - constructor
97//-------------------------------------------------
98
99cdp1863_device::cdp1863_device(running_machine &_machine, const cdp1863_device_config &config)
100    : device_t(_machine, config),
101     device_sound_interface(_machine, config, *this),
102     m_stream(NULL),
103     m_clock1(clock()),
104     m_clock2(config.m_clock2),
105      m_config(config)
93106{
94   cdp1863_t *cdp1863 = get_safe_token(device);
95
96   cdp1863->clock1 = frequency;
97107}
98108
99/*-------------------------------------------------
100    cdp1863_set_clk2 - set clock 2 frequency
101------------------------------------------------*/
102109
103void cdp1863_set_clk2(device_t *device, int frequency)
110//-------------------------------------------------
111//  device_start - device-specific startup
112//-------------------------------------------------
113
114void cdp1863_device::device_start()
104115{
105   cdp1863_t *cdp1863 = get_safe_token(device);
116   // create sound stream
117   m_stream = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate());
106118
107   cdp1863->clock2 = frequency;
119   // register for state saving
120   save_item(NAME(m_clock1));
121   save_item(NAME(m_clock2));
122   save_item(NAME(m_oe));
123   save_item(NAME(m_latch));
124   save_item(NAME(m_signal));
125   save_item(NAME(m_incr));
108126}
109127
110/*-------------------------------------------------
111    STREAM_UPDATE( cdp1863_stream_update )
112-------------------------------------------------*/
113128
114static STREAM_UPDATE( cdp1863_stream_update )
129//-------------------------------------------------
130//  sound_stream_update - handle update requests for
131//  our sound stream
132//-------------------------------------------------
133
134void cdp1863_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
115135{
116   cdp1863_t *cdp1863 = get_safe_token(device);
136   // reset the output stream
137   memset(outputs[0], 0, samples * sizeof(*outputs[0]));
117138
118   INT16 signal = cdp1863->signal;
139   INT16 signal = m_signal;
119140   stream_sample_t *buffer = outputs[0];
120141
121142   memset( buffer, 0, samples * sizeof(*buffer) );
122143
123   if (cdp1863->oe)
144   if (m_oe)
124145   {
125146      double frequency;
126      int rate = device->machine().sample_rate() / 2;
147      int rate = machine().sample_rate() / 2;
127148
128      /* get progress through wave */
129      int incr = cdp1863->incr;
149      // get progress through wave
150      int incr = m_incr;
130151
131      if (cdp1863->clock1 > 0)
152      if (m_clock1 > 0)
132153      {
133         /* CLK1 is pre-divided by 4 */
134         frequency = cdp1863->clock1 / 4 / (cdp1863->latch + 1) / 2;
154         // CLK1 is pre-divided by 4
155         frequency = m_clock1 / 4 / (m_latch + 1) / 2;
135156      }
136157      else
137158      {
138         /* CLK2 is pre-divided by 8 */
139         frequency = cdp1863->clock2 / 8 / (cdp1863->latch + 1) / 2;
159         // CLK2 is pre-divided by 8
160         frequency = m_clock2 / 8 / (m_latch + 1) / 2;
140161      }
141162
142163      if (signal < 0)
r11280r11281
159180         }
160181      }
161182
162      /* store progress through wave */
163      cdp1863->incr = incr;
164      cdp1863->signal = signal;
183      // store progress through wave
184      m_incr = incr;
185      m_signal = signal;
165186   }
166187}
167188
168/*-------------------------------------------------
169    DEVICE_START( cdp1863 )
170-------------------------------------------------*/
171189
172static DEVICE_START( cdp1863 )
190//-------------------------------------------------
191//  str_w - latch write
192//-------------------------------------------------
193
194WRITE8_MEMBER( cdp1863_device::str_w )
173195{
174   cdp1863_t *cdp1863 = get_safe_token(device);
175   const cdp1863_config *config = get_safe_config(device);
196   m_latch = data;
197}
176198
177   /* set initial values */
178   cdp1863->stream = device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), cdp1863, cdp1863_stream_update);
179   cdp1863->clock1 = device->clock();
180   cdp1863->clock2 = config->clock2;
181   cdp1863->oe = 1;
182199
183   /* register for state saving */
184   device->save_item(NAME(cdp1863->clock1));
185   device->save_item(NAME(cdp1863->clock2));
186   device->save_item(NAME(cdp1863->oe));
187   device->save_item(NAME(cdp1863->latch));
188   device->save_item(NAME(cdp1863->signal));
189   device->save_item(NAME(cdp1863->incr));
200//-------------------------------------------------
201//  str_w - latch write
202//-------------------------------------------------
203
204void cdp1863_device::str_w(UINT8 data)
205{
206   m_latch = data;
190207}
191208
192/*-------------------------------------------------
193    DEVICE_RESET( cdp1863 )
194-------------------------------------------------*/
195209
196static DEVICE_RESET( cdp1863 )
210//-------------------------------------------------
211//  oe_w - output enable write
212//-------------------------------------------------
213
214WRITE_LINE_MEMBER( cdp1863_device::oe_w )
197215{
198   cdp1863_t *cdp1863 = get_safe_token(device);
199
200   cdp1863->latch = CDP1863_DEFAULT_LATCH;
216   m_oe = state;
201217}
202218
203/*-------------------------------------------------
204    DEVICE_GET_INFO( cdp1863 )
205-------------------------------------------------*/
206219
207DEVICE_GET_INFO( cdp1863 )
220//-------------------------------------------------
221//  set_clk1 - set clock 1
222//-------------------------------------------------
223
224void cdp1863_device::set_clk1(int clock)
208225{
209   switch (state)
210   {
211      /* --- the following bits of info are returned as 64-bit signed integers --- */
212      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cdp1863_t);            break;
213      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(cdp1863_config);         break;
226   m_clock1 = clock;
227}
214228
215      /* --- the following bits of info are returned as pointers to data or functions --- */
216      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cdp1863);   break;
217      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
218      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(cdp1863);   break;
219229
220      /* --- the following bits of info are returned as NULL-terminated strings --- */
221      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA CDP1863");            break;
222      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA CDP1800");            break;
223      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
224      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
225      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");      break;
226   }
230//-------------------------------------------------
231//  set_clk2 - set clock 2
232//-------------------------------------------------
233
234void cdp1863_device::set_clk2(int clock)
235{
236   m_clock2 = clock;
227237}
228
229
230DEFINE_LEGACY_SOUND_DEVICE(CDP1863, cdp1863);
src/emu/sound/cdp1863.h
r11280r11281
1818
1919**********************************************************************/
2020
21#pragma once
22
2123#ifndef __CDP1863__
2224#define __CDP1863__
2325
24#include "devlegcy.h"
26#include "emu.h"
2527
26/***************************************************************************
27    MACROS / CONSTANTS
28***************************************************************************/
2928
30DECLARE_LEGACY_SOUND_DEVICE(CDP1863, cdp1863);
3129
32#define MCFG_CDP1863_ADD(_tag, _clock1, _clock2) \
33   MCFG_SOUND_ADD(_tag, CDP1863, _clock1) \
34   MCFG_DEVICE_CONFIG_DATA32(cdp1863_config, clock2, _clock2)
30//**************************************************************************
31//  INTERFACE CONFIGURATION MACROS
32//**************************************************************************
3533
36#define CDP1863_INTERFACE(name) \
37   const cdp1863_interface (name) =
34#define MCFG_CDP1863_ADD(_tag, _clock, _clock2) \
35   MCFG_DEVICE_ADD(_tag, CDP1863, _clock) \
36   cdp1863_device_config::static_set_config(device, _clock2);
3837
39/***************************************************************************
40    TYPE DEFINITIONS
41***************************************************************************/
4238
43typedef struct _cdp1863_config cdp1863_config;
44struct _cdp1863_config
39
40//**************************************************************************
41//  TYPE DEFINITIONS
42//**************************************************************************
43
44// ======================> cdp1863_device_config
45
46class cdp1863_device_config :   public device_config,
47                        public device_config_sound_interface
4548{
46   int clock2;            /* the clock 2 (pin 2) of the chip */
49    friend class cdp1863_device;
50
51    // construction/destruction
52    cdp1863_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
53
54public:
55    // allocators
56    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
57    virtual device_t *alloc_device(running_machine &machine) const;
58
59   // inline configuration helpers
60   static void static_set_config(device_config *device, int clock2);
61
62private:
63   int m_clock2;
4764};
4865
49/***************************************************************************
50    PROTOTYPES
51***************************************************************************/
5266
53/* load tone latch */
54WRITE8_DEVICE_HANDLER( cdp1863_str_w );
67// ======================> cdp1863_device
5568
56/* output enable */
57WRITE_LINE_DEVICE_HANDLER( cdp1863_oe_w );
69class cdp1863_device :   public device_t,
70                  public device_sound_interface
71{
72    friend class cdp1863_device_config;
5873
59/* clock setters */
60void cdp1863_set_clk1(device_t *device, int frequency) ATTR_NONNULL(1);
61void cdp1863_set_clk2(device_t *device, int frequency) ATTR_NONNULL(1);
74    // construction/destruction
75    cdp1863_device(running_machine &_machine, const cdp1863_device_config &_config);
6276
77public:
78   DECLARE_WRITE8_MEMBER( str_w );
79   void str_w(UINT8 data);
80   
81   DECLARE_WRITE_LINE_MEMBER( oe_w );
82   
83   void set_clk1(int clock);
84   void set_clk2(int clock);
85
86protected:
87    // device-level overrides
88    virtual void device_start();
89
90   // internal callbacks
91   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
92
93private:
94   sound_stream *m_stream;
95
96   int m_clock1;               // clock 1
97   int m_clock2;               // clock 2
98
99   // sound state
100   int m_oe;                  // output enable
101   int m_latch;               // sound latch
102   INT16 m_signal;               // current signal
103   int m_incr;                  // initial wave state
104   
105   const cdp1863_device_config &m_config;
106};
107
108
109// device type definition
110extern const device_type CDP1863;
111
112
113
63114#endif
src/mess/audio/vp550.c
r11280r11281
77
88*********************************************************************/
99
10/*
10#include "vp550.h"
11#include "machine/devhelpr.h"
1112
12    TODO:
1313
14    - tempo control
15    - mono/stereo mode
16    - VP551 memory map
1714
18*/
15//**************************************************************************
16//  MACROS / CONSTANTS
17//**************************************************************************
1918
20#include "emu.h"
21#include "vp550.h"
22#include "cpu/cosmac/cosmac.h"
23#include "sound/cdp1863.h"
24
25/***************************************************************************
26    PARAMETERS
27***************************************************************************/
28
2919#define LOG 0
3020
31#define MAX_CHANNELS   4
3221
3322#define CDP1863_A_TAG   "u1"
3423#define CDP1863_B_TAG   "u2"
3524#define CDP1863_C_TAG   "cdp1863c"
3625#define CDP1863_D_TAG   "cdp1863d"
3726
27
3828enum
3929{
4030   CHANNEL_A = 0,
r11280r11281
4333   CHANNEL_D
4434};
4535
46/***************************************************************************
47    TYPE DEFINITIONS
48***************************************************************************/
4936
50typedef struct _vp550_t vp550_t;
51struct _vp550_t
52{
53   int channels;                  /* number of channels */
5437
55   /* devices */
56   device_t *cdp1863[MAX_CHANNELS];
57   timer_device *sync_timer;
58};
38//**************************************************************************
39//  GLOBAL VARIABLES
40//**************************************************************************
5941
60/***************************************************************************
61    INLINE FUNCTIONS
62***************************************************************************/
42// devices
43const device_type VP550 = vp550_device_config::static_alloc_device_config;
44const device_type VP551 = vp550_device_config::static_alloc_device_config;
6345
64INLINE vp550_t *get_safe_token(device_t *device)
65{
66   assert(device != NULL);
67   assert((device->type() == VP550) || (device->type() == VP551));
68   return (vp550_t *)downcast<legacy_device_base *>(device)->token();
69}
7046
71/***************************************************************************
72    IMPLEMENTATION
73***************************************************************************/
7447
75/*-------------------------------------------------
76    vp550_q_w - Q line write
77-------------------------------------------------*/
48//**************************************************************************
49//  DEVICE CONFIGURATION
50//**************************************************************************
7851
79WRITE_LINE_DEVICE_HANDLER( vp550_q_w )
80{
81   vp550_t *vp550 = get_safe_token(device);
52GENERIC_DEVICE_CONFIG_SETUP(vp550, "VP550")
8253
83   int channel;
8454
85   for (channel = CHANNEL_A; channel < vp550->channels; channel++)
86   {
87      cdp1863_oe_w(vp550->cdp1863[channel], state);
88   }
89}
55//-------------------------------------------------
56//  static_set_config - configuration helper
57//-------------------------------------------------
9058
91/*-------------------------------------------------
92    vp550_sc1_w - SC1 line write
93-------------------------------------------------*/
94
95WRITE_LINE_DEVICE_HANDLER( vp550_sc1_w )
59void vp550_device_config::static_set_config(device_config *device, int variant)
9660{
97   if (state)
98   {
99      device_set_input_line(device, COSMAC_INPUT_LINE_INT, CLEAR_LINE);
61   vp550_device_config *vp550 = downcast<vp550_device_config *>(device);
10062
101      if (LOG) logerror("VP550 Clear Interrupt\n");
102   }
63   vp550->m_variant = variant;
10364}
10465
105/*-------------------------------------------------
106    vp550_octave_w - octave select write
107-------------------------------------------------*/
10866
109static WRITE8_DEVICE_HANDLER( vp550_octave_w )
110{
111   vp550_t *vp550 = get_safe_token(device);
67//-------------------------------------------------
68//  MACHINE_CONFIG_FRAGMENT( vp550 )
69//-------------------------------------------------
11270
113   int channel = (data >> 2) & 0x03;
114   int clock = 0;
71static MACHINE_CONFIG_FRAGMENT( vp550 )
72   MCFG_CDP1863_ADD(CDP1863_A_TAG, 0, 0)
73   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
11574
116   if (data & 0x10)
117   {
118      switch (data & 0x03)
119      {
120      case 0: clock = device->clock() / 8; break;
121      case 1: clock = device->clock() / 4; break;
122      case 2: clock = device->clock() / 2; break;
123      case 3: clock = device->clock();      break;
124      }
125   }
75   MCFG_CDP1863_ADD(CDP1863_B_TAG, 0, 0)
76   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
77MACHINE_CONFIG_END
12678
127   if (vp550->cdp1863[channel]) cdp1863_set_clk2(vp550->cdp1863[channel], clock);
12879
129   if (LOG) logerror("VP550 Clock %c: %u Hz\n", 'A' + channel, clock);
130}
80//-------------------------------------------------
81//  MACHINE_CONFIG_FRAGMENT( vp551 )
82//-------------------------------------------------
13183
132/*-------------------------------------------------
133    vp550_vlmn_w - amplitude write
134-------------------------------------------------*/
84static MACHINE_CONFIG_FRAGMENT( vp551 )
85   MCFG_CDP1863_ADD(CDP1863_A_TAG, 0, 0)
86   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
13587
136static WRITE8_DEVICE_HANDLER( vp550_vlmn_w )
137{
138   //float gain = 0.625f * (data & 0x0f);
88   MCFG_CDP1863_ADD(CDP1863_B_TAG, 0, 0)
89   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
13990
140//  sound_set_output_gain(device, 0, gain);
91   MCFG_CDP1863_ADD(CDP1863_C_TAG, 0, 0)
92   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
14193
142   if (LOG) logerror("VP550 '%s' Volume: %u\n", device->tag(), data & 0x0f);
143}
94   MCFG_CDP1863_ADD(CDP1863_D_TAG, 0, 0)
95   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
96MACHINE_CONFIG_END
14497
145/*-------------------------------------------------
146    vp550_sync_w - interrupt enable write
147-------------------------------------------------*/
14898
149static WRITE8_DEVICE_HANDLER( vp550_sync_w )
150{
151   downcast<timer_device *>(device)->enable(BIT(data, 0));
99//-------------------------------------------------
100//  machine_config_additions - device-specific
101//  machine configurations
102//-------------------------------------------------
152103
153   if (LOG) logerror("VP550 Interrupt Enable: %u\n", BIT(data, 0));
154}
155
156/*-------------------------------------------------
157    vp550_install_readwrite_handler - install
158    or uninstall write handlers
159-------------------------------------------------*/
160
161void vp550_install_write_handlers(device_t *device, address_space *program, int enabled)
104machine_config_constructor vp550_device_config::device_mconfig_additions() const
162105{
163   vp550_t *vp550 = get_safe_token(device);
164
165   if (enabled)
106   switch (m_variant)
166107   {
167      program->install_legacy_write_handler(*vp550->cdp1863[CHANNEL_A], 0x8001, 0x8001, FUNC(cdp1863_str_w));
168      program->install_legacy_write_handler(*vp550->cdp1863[CHANNEL_B], 0x8002, 0x8002, FUNC(cdp1863_str_w));
169      program->install_legacy_write_handler(*device, 0x8003, 0x8003, FUNC(vp550_octave_w));
170      program->install_legacy_write_handler(*vp550->cdp1863[CHANNEL_A], 0x8010, 0x8010, FUNC(vp550_vlmn_w));
171      program->install_legacy_write_handler(*vp550->cdp1863[CHANNEL_B], 0x8020, 0x8020, FUNC(vp550_vlmn_w));
172      program->install_legacy_write_handler(*vp550->sync_timer, 0x8030, 0x8030, FUNC(vp550_sync_w));
108   default:
109   case TYPE_VP550:
110      return MACHINE_CONFIG_NAME( vp550 );
111   
112   case TYPE_VP551:
113      return MACHINE_CONFIG_NAME( vp551 );
173114   }
174   else
175   {
176      program->unmap_write(0x8001, 0x8001);
177      program->unmap_write(0x8002, 0x8002);
178      program->unmap_write(0x8003, 0x8003);
179      program->unmap_write(0x8010, 0x8010);
180      program->unmap_write(0x8020, 0x8020);
181      program->unmap_write(0x8030, 0x8030);
182   }
183115}
184116
185/*-------------------------------------------------
186    vp551_install_readwrite_handler - install
187    or uninstall write handlers
188-------------------------------------------------*/
189117
190void vp551_install_write_handlers(device_t *device, address_space *program, int enabled)
191{
192}
193118
194/*-------------------------------------------------
195    TIMER_DEVICE_CALLBACK( sync_tick )
196-------------------------------------------------*/
119//**************************************************************************
120//  LIVE DEVICE
121//**************************************************************************
197122
198static TIMER_DEVICE_CALLBACK( sync_tick )
199{
200   device_set_input_line(timer.machine().firstcpu, COSMAC_INPUT_LINE_INT, ASSERT_LINE);
123//-------------------------------------------------
124//  vp550_device - constructor
125//-------------------------------------------------
201126
202   if (LOG) logerror("VP550 Interrupt\n");
127vp550_device::vp550_device(running_machine &_machine, const vp550_device_config &config)
128    : device_t(_machine, config),
129     m_pfg_a(*this, CDP1863_A_TAG),
130     m_pfg_b(*this, CDP1863_B_TAG),
131     m_pfg_c(*this, CDP1863_C_TAG),
132     m_pfg_d(*this, CDP1863_D_TAG),
133      m_config(config)
134{
203135}
204136
205/*-------------------------------------------------
206    MACHINE_DRIVER( vp550 )
207-------------------------------------------------*/
208137
209static MACHINE_CONFIG_FRAGMENT( vp550 )
210   MCFG_TIMER_ADD_PERIODIC("sync", sync_tick, attotime::from_hz(50))
138//-------------------------------------------------
139//  device_start - device-specific startup
140//-------------------------------------------------
211141
212   MCFG_CDP1863_ADD(CDP1863_A_TAG, 0, 0)
213   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
142void vp550_device::device_start()
143{
144   // allocate timers
145   m_sync_timer = timer_alloc();
146   m_sync_timer->adjust(attotime::from_hz(50), 0, attotime::from_hz(50));
147   m_sync_timer->enable(0);
148}
214149
215   MCFG_CDP1863_ADD(CDP1863_B_TAG, 0, 0)
216   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
217MACHINE_CONFIG_END
218150
219/*-------------------------------------------------
220    MACHINE_DRIVER( vp551 )
221-------------------------------------------------*/
151//-------------------------------------------------
152//  device_timer - handler timer events
153//-------------------------------------------------
222154
223static MACHINE_CONFIG_FRAGMENT( vp551 )
224   MCFG_FRAGMENT_ADD(vp550)
155void vp550_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
156{
157   if (LOG) logerror("VP550 '%s' Interrupt\n", tag());
225158
226   MCFG_CDP1863_ADD(CDP1863_C_TAG, 0, 0)
227   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
159   device_set_input_line(machine().firstcpu, COSMAC_INPUT_LINE_INT, ASSERT_LINE);
160}
228161
229   MCFG_CDP1863_ADD(CDP1863_D_TAG, 0, 0)
230   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
231MACHINE_CONFIG_END
232162
233/*-------------------------------------------------
234    DEVICE_START( vp550 )
235-------------------------------------------------*/
163//-------------------------------------------------
164//  octave_w - octave select write
165//-------------------------------------------------
236166
237static DEVICE_START( vp550 )
167WRITE8_MEMBER( vp550_device::octave_w )
238168{
239   vp550_t *vp550 = get_safe_token(device);
169   int channel = (data >> 2) & 0x03;
170   int clock2 = 0;
240171
241   /* look up devices */
242   vp550->cdp1863[CHANNEL_A] = device->machine().device("vp550:u1");
243   vp550->cdp1863[CHANNEL_B] = device->machine().device("vp550:u2");
244   vp550->sync_timer = device->machine().device<timer_device>("vp550:sync");
172   if (data & 0x10)
173   {
174      switch (data & 0x03)
175      {
176      case 0: clock2 = clock() / 8; break;
177      case 1: clock2 = clock() / 4; break;
178      case 2: clock2 = clock() / 2; break;
179      case 3: clock2 = clock();    break;
180      }
181   }
245182
246   /* set initial values */
247   vp550->channels = 2;
183   switch (channel)
184   {
185   case CHANNEL_A: m_pfg_a->set_clk2(clock2); break;
186   case CHANNEL_B: m_pfg_b->set_clk2(clock2); break;
187   case CHANNEL_C: if (m_pfg_c) m_pfg_c->set_clk2(clock2); break;
188   case CHANNEL_D: if (m_pfg_d) m_pfg_d->set_clk2(clock2); break;
189   }
190   
191   if (LOG) logerror("VP550 '%s' Clock %c: %u Hz\n", tag(), 'A' + channel, clock2);
248192}
249193
250/*-------------------------------------------------
251    DEVICE_START( vp551 )
252-------------------------------------------------*/
253194
254static DEVICE_START( vp551 )
255{
256   vp550_t *vp550 = get_safe_token(device);
195//-------------------------------------------------
196//  vlmna_w - channel A amplitude write
197//-------------------------------------------------
257198
258   /* look up devices */
259   vp550->cdp1863[CHANNEL_A] = device->subdevice(CDP1863_A_TAG);
260   vp550->cdp1863[CHANNEL_B] = device->subdevice(CDP1863_B_TAG);
261   vp550->cdp1863[CHANNEL_C] = device->subdevice(CDP1863_C_TAG);
262   vp550->cdp1863[CHANNEL_D] = device->subdevice(CDP1863_D_TAG);
263   vp550->sync_timer = downcast<timer_device *>(device->subdevice("sync"));
264
265   /* set initial values */
266   vp550->channels = 4;
199WRITE8_MEMBER( vp550_device::vlmna_w )
200{
201   if (LOG) logerror("VP550 '%s' A Volume: %u\n", tag(), data & 0x0f);
267202}
268203
269/*-------------------------------------------------
270    DEVICE_RESET( vp550 )
271-------------------------------------------------*/
272204
273static DEVICE_RESET( vp550 )
274{
275   vp550_t *vp550 = get_safe_token(device);
205//-------------------------------------------------
206//  vlmnb_w - channel B amplitude write
207//-------------------------------------------------
276208
277   /* reset chips */
278   vp550->cdp1863[CHANNEL_A]->reset();
279   vp550->cdp1863[CHANNEL_B]->reset();
280
281   /* disable interrupt timer */
282   vp550->sync_timer->enable(0);
283
284   /* clear interrupt */
285   device_set_input_line(device->machine().firstcpu, COSMAC_INPUT_LINE_INT, CLEAR_LINE);
209WRITE8_MEMBER( vp550_device::vlmnb_w )
210{
211   if (LOG) logerror("VP550 '%s' B Volume: %u\n", tag(), data & 0x0f);
286212}
287213
288/*-------------------------------------------------
289    DEVICE_RESET( vp551 )
290-------------------------------------------------*/
291214
292static DEVICE_RESET( vp551 )
215//-------------------------------------------------
216//  sync_w - interrupt enable write
217//-------------------------------------------------
218
219WRITE8_MEMBER( vp550_device::sync_w )
293220{
294   vp550_t *vp550 = get_safe_token(device);
221   if (LOG) logerror("VP550 '%s' Interrupt Enable: %u\n", tag(), BIT(data, 0));
295222
296   DEVICE_RESET_CALL(vp550);
297
298   /* reset chips */
299   vp550->cdp1863[CHANNEL_C]->reset();
300   vp550->cdp1863[CHANNEL_D]->reset();
223   m_sync_timer->enable(BIT(data, 0));
301224}
302225
303/*-------------------------------------------------
304    DEVICE_GET_INFO( vp550 )
305-------------------------------------------------*/
306226
307DEVICE_GET_INFO( vp550 )
227//-------------------------------------------------
228//  q_w -
229//-------------------------------------------------
230
231WRITE_LINE_MEMBER( vp550_device::q_w )
308232{
309   switch (state)
310   {
311      /* --- the following bits of info are returned as 64-bit signed integers --- */
312      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(vp550_t);               break;
313      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
233   m_pfg_a->oe_w(state);
234   m_pfg_b->oe_w(state);
235   if (m_pfg_c) m_pfg_c->oe_w(state);
236   if (m_pfg_d) m_pfg_d->oe_w(state);
237}
314238
315      /* --- the following bits of info are returned as pointers --- */
316      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME( vp550 );   break;
317239
318      /* --- the following bits of info are returned as pointers to data or functions --- */
319      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(vp550);      break;
320      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
321      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(vp550);      break;
240//-------------------------------------------------
241//  sc1_w -
242//-------------------------------------------------
322243
323      /* --- the following bits of info are returned as NULL-terminated strings --- */
324      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA VP550");            break;
325      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA VIP");               break;
326      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
327      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
328      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
244WRITE_LINE_MEMBER( vp550_device::sc1_w )
245{
246   if (state)
247   {
248      if (LOG) logerror("VP550 '%s' Clear Interrupt\n", tag());
249   
250      device_set_input_line(machine().firstcpu, COSMAC_INPUT_LINE_INT, CLEAR_LINE);
329251   }
330252}
331253
332/*-------------------------------------------------
333    DEVICE_GET_INFO( vp551 )
334-------------------------------------------------*/
335254
336DEVICE_GET_INFO( vp551 )
255//-------------------------------------------------
256//  install_write_handlers -
257//-------------------------------------------------
258
259void vp550_device::install_write_handlers(address_space *space, bool enabled)
337260{
338   switch (state)
261   if (enabled)
339262   {
340      /* --- the following bits of info are returned as 64-bit signed integers --- */
341      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(vp550_t);               break;
342      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
343
344      /* --- the following bits of info are returned as pointers --- */
345      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME( vp551 );   break;
346
347      /* --- the following bits of info are returned as pointers to data or functions --- */
348      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(vp551);      break;
349      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
350      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(vp551);      break;
351
352      /* --- the following bits of info are returned as NULL-terminated strings --- */
353      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA VP551");            break;
354      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA VIP");               break;
355      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
356      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
357      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
263      space->install_write_handler(0x8001, 0x8001, write8_delegate(FUNC(cdp1863_device::str_w), (cdp1863_device*)m_pfg_a));
264      space->install_write_handler(0x8002, 0x8002, write8_delegate(FUNC(cdp1863_device::str_w), (cdp1863_device*)m_pfg_b));
265      space->install_write_handler(0x8003, 0x8003, write8_delegate(FUNC(vp550_device::octave_w), this));
266      space->install_write_handler(0x8010, 0x8010, write8_delegate(FUNC(vp550_device::vlmna_w), this));
267      space->install_write_handler(0x8020, 0x8020, write8_delegate(FUNC(vp550_device::vlmnb_w), this));
268      space->install_write_handler(0x8030, 0x8030, write8_delegate(FUNC(vp550_device::sync_w), this));
358269   }
270   else
271   {
272      space->unmap_write(0x8001, 0x8001);
273      space->unmap_write(0x8002, 0x8002);
274      space->unmap_write(0x8003, 0x8003);
275      space->unmap_write(0x8010, 0x8010);
276      space->unmap_write(0x8020, 0x8020);
277      space->unmap_write(0x8030, 0x8030);
278   }
359279}
360
361DEFINE_LEGACY_DEVICE(VP550, vp550);
362DEFINE_LEGACY_DEVICE(VP551, vp551);
src/mess/audio/vp550.h
r11280r11281
77
88**********************************************************************/
99
10#pragma once
11
1012#ifndef __VP550__
1113#define __VP550__
1214
13#include "devcb.h"
15#include "emu.h"
16#include "cpu/cosmac/cosmac.h"
17#include "sound/cdp1863.h"
1418
15/***************************************************************************
16    MACROS / CONSTANTS
17***************************************************************************/
1819
20
21//**************************************************************************
22//  MACROS / CONSTANTS
23//**************************************************************************
24
1925#define VP550_TAG   "vp550"
2026#define VP551_TAG   "vp551"
2127
22DECLARE_LEGACY_DEVICE(VP550, vp550);
23DECLARE_LEGACY_DEVICE(VP551, vp551);
2428
29
30//**************************************************************************
31//  INTERFACE CONFIGURATION MACROS
32//**************************************************************************
33
2534#define MCFG_VP550_ADD(_clock) \
26   MCFG_DEVICE_ADD(VP550_TAG, VP550, _clock)
35   MCFG_DEVICE_ADD(VP550_TAG, VP550, _clock) \
36   vp550_device_config::static_set_config(device, vp550_device_config::TYPE_VP550);
2737
38
2839#define MCFG_VP551_ADD(_clock) \
29   MCFG_DEVICE_ADD(VP551_TAG, VP551, _clock)
40   MCFG_DEVICE_ADD(VP551_TAG, VP551, _clock) \
41   vp550_device_config::static_set_config(device, vp550_device_config::TYPE_VP551);
3042
31/***************************************************************************
32    PROTOTYPES
33***************************************************************************/
34/* Q line */
35WRITE_LINE_DEVICE_HANDLER( vp550_q_w ) ATTR_NONNULL(1);
3643
37/* SC1 line */
38WRITE_LINE_DEVICE_HANDLER( vp550_sc1_w ) ATTR_NONNULL(1);
3944
40/* install write handlers */
41void vp550_install_write_handlers(device_t *device, address_space *program, int enabled) ATTR_NONNULL(1) ATTR_NONNULL(2);
42void vp551_install_write_handlers(device_t *device, address_space *program, int enabled) ATTR_NONNULL(1) ATTR_NONNULL(2);
45//**************************************************************************
46//  TYPE DEFINITIONS
47//**************************************************************************
4348
44#endif /* __VP550__ */
49// ======================> vp550_device_config
50
51class vp550_device_config :   public device_config
52{
53    friend class vp550_device;
54
55    // construction/destruction
56    vp550_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
57
58public:
59   enum
60   {
61      TYPE_VP550 = 0,
62      TYPE_VP551
63   };
64
65   // allocators
66    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
67    virtual device_t *alloc_device(running_machine &machine) const;
68
69   // inline configuration helpers
70   static void static_set_config(device_config *device, int variant);
71
72   // optional information overrides
73   virtual machine_config_constructor device_mconfig_additions() const;
74
75private:
76   int m_variant;
77};
78
79
80// ======================> vp550_device
81
82class vp550_device :   public device_t
83{
84    friend class vp550_device_config;
85
86    // construction/destruction
87    vp550_device(running_machine &_machine, const vp550_device_config &_config);
88
89public:
90   DECLARE_WRITE8_MEMBER( octave_w );
91   DECLARE_WRITE8_MEMBER( vlmna_w );
92   DECLARE_WRITE8_MEMBER( vlmnb_w );
93   DECLARE_WRITE8_MEMBER( sync_w );
94   DECLARE_WRITE_LINE_MEMBER( q_w );
95   DECLARE_WRITE_LINE_MEMBER( sc1_w );
96
97   void install_write_handlers(address_space *space, bool enabled);
98
99protected:
100    // device-level overrides
101    virtual void device_start();
102   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
103
104private:
105   required_device<cdp1863_device> m_pfg_a;
106   required_device<cdp1863_device> m_pfg_b;
107   optional_device<cdp1863_device> m_pfg_c;
108   optional_device<cdp1863_device> m_pfg_d;
109
110   // timers
111   emu_timer *m_sync_timer;
112   
113   const vp550_device_config &m_config;
114};
115
116
117// device type definition
118extern const device_type VP550;
119extern const device_type VP551;
120
121
122
123#endif
src/mess/audio/vp595.c
r11280r11281
77
88*********************************************************************/
99
10#include "emu.h"
1110#include "vp595.h"
12#include "sound/cdp1863.h"
11#include "machine/devhelpr.h"
1312
14/***************************************************************************
15    PARAMETERS
16***************************************************************************/
1713
14
15//**************************************************************************
16//  MACROS / CONSTANTS
17//**************************************************************************
18
1819#define CDP1863_TAG      "u1"
1920#define CDP1863_XTAL   440560
2021
21/***************************************************************************
22    TYPE DEFINITIONS
23***************************************************************************/
2422
25typedef struct _vp595_t vp595_t;
26struct _vp595_t
27{
28   /* devices */
29   device_t *cdp1863;
30};
3123
32/***************************************************************************
33    INLINE FUNCTIONS
34***************************************************************************/
24//**************************************************************************
25//  GLOBAL VARIABLES
26//**************************************************************************
3527
36INLINE vp595_t *get_safe_token(device_t *device)
37{
38   assert(device != NULL);
39   assert(device->type() == VP595);
40   return (vp595_t *)downcast<legacy_device_base *>(device)->token();
41}
28// devices
29const device_type VP595 = vp595_device_config::static_alloc_device_config;
4230
43/***************************************************************************
44    IMPLEMENTATION
45***************************************************************************/
4631
47/*-------------------------------------------------
48    vp595_q_w - Q line write
49-------------------------------------------------*/
5032
51WRITE_LINE_DEVICE_HANDLER( vp595_q_w )
52{
53   vp595_t *vp595 = get_safe_token(device);
33//**************************************************************************
34//  DEVICE CONFIGURATION
35//**************************************************************************
5436
55   cdp1863_oe_w(vp595->cdp1863, state);
56}
37GENERIC_DEVICE_CONFIG_SETUP(vp595, "VP595")
5738
58/*-------------------------------------------------
59    vp595_cdp1863_w - CDP1863 latch write
60-------------------------------------------------*/
6139
62static WRITE8_DEVICE_HANDLER( vp595_cdp1863_w )
63{
64   /* inject 0x80 instead of 0x00 */
65   if (data == 0) data = 0x80;
40//-------------------------------------------------
41//  MACHINE_CONFIG_FRAGMENT( vp595 )
42//-------------------------------------------------
6643
67   cdp1863_str_w(device, 0, data);
68}
44static MACHINE_CONFIG_FRAGMENT( vp595 )
45   MCFG_CDP1863_ADD(CDP1863_TAG, 0, CDP1863_XTAL)
46   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
47MACHINE_CONFIG_END
6948
70/*-------------------------------------------------
71    vp595_install_readwrite_handler - install
72    or uninstall write handlers
73-------------------------------------------------*/
7449
75void vp595_install_write_handlers(device_t *device, address_space *io, int enabled)
76{
77   vp595_t *vp595 = get_safe_token(device);
50//-------------------------------------------------
51//  machine_config_additions - device-specific
52//  machine configurations
53//-------------------------------------------------
7854
79   if (enabled)
80   {
81      io->install_legacy_write_handler(*vp595->cdp1863, 0x03, 0x03, FUNC(vp595_cdp1863_w));
82   }
83   else
84   {
85      io->unmap_write(0x03, 0x03);
86   }
55machine_config_constructor vp595_device_config::device_mconfig_additions() const
56{
57   return MACHINE_CONFIG_NAME( vp595 );
8758}
8859
89/*-------------------------------------------------
90    MACHINE_DRIVER( vp595 )
91-------------------------------------------------*/
9260
93static MACHINE_CONFIG_FRAGMENT( vp595 )
94   MCFG_CDP1863_ADD(CDP1863_TAG, 0, 0) // TODO: clock2 should be CDP1863_XTAL
95   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
96MACHINE_CONFIG_END
9761
98/*-------------------------------------------------
99    DEVICE_START( vp595 )
100-------------------------------------------------*/
62//**************************************************************************
63//  LIVE DEVICE
64//**************************************************************************
10165
102static DEVICE_START( vp595 )
66//-------------------------------------------------
67//  vp595_device - constructor
68//-------------------------------------------------
69
70vp595_device::vp595_device(running_machine &_machine, const vp595_device_config &config)
71    : device_t(_machine, config),
72     m_pfg(*this, CDP1863_TAG),
73      m_config(config)
10374{
104   vp595_t *vp595 = get_safe_token(device);
75}
10576
106   /* look up devices */
107   vp595->cdp1863 = device->subdevice(CDP1863_TAG);
10877
109   /* HACK workaround */
110   cdp1863_set_clk2(vp595->cdp1863, CDP1863_XTAL);
78//-------------------------------------------------
79//  device_start - device-specific startup
80//-------------------------------------------------
81
82void vp595_device::device_start()
83{
11184}
11285
113/*-------------------------------------------------
114    DEVICE_GET_INFO( vp595 )
115-------------------------------------------------*/
11686
117DEVICE_GET_INFO( vp595 )
87//-------------------------------------------------
88//  latch_w -
89//-------------------------------------------------
90
91WRITE8_MEMBER( vp595_device::latch_w )
11892{
119   switch (state)
120   {
121      /* --- the following bits of info are returned as 64-bit signed integers --- */
122      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(vp595_t);               break;
123      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
93   if (!data) data = 0x80;
12494
125      /* --- the following bits of info are returned as pointers --- */
126      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME( vp595 );   break;
95   m_pfg->str_w(data);
96}
12797
128      /* --- the following bits of info are returned as pointers to data or functions --- */
129      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(vp595);      break;
130      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
131      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
13298
133      /* --- the following bits of info are returned as NULL-terminated strings --- */
134      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA VP595");            break;
135      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA VIP");               break;
136      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
137      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
138      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
139   }
99//-------------------------------------------------
100//  q_w -
101//-------------------------------------------------
102
103WRITE_LINE_MEMBER( vp595_device::q_w )
104{
105   m_pfg->oe_w(state);
140106}
141107
142DEFINE_LEGACY_DEVICE(VP595, vp595);
108
109//-------------------------------------------------
110//  install_write_handlers -
111//-------------------------------------------------
112
113void vp595_device::install_write_handlers(address_space *space, bool enabled)
114{
115   if (enabled)
116   {
117      space->install_write_handler(0x03, 0x03, write8_delegate(FUNC(cdp1863_device::str_w), (cdp1863_device*)m_pfg));
118   }
119   else
120   {
121      space->unmap_write(0x03, 0x03);
122   }
123}
src/mess/audio/vp595.h
r11280r11281
77
88**********************************************************************/
99
10#pragma once
11
1012#ifndef __VP595__
1113#define __VP595__
1214
13#include "devcb.h"
15#include "emu.h"
16#include "sound/cdp1863.h"
1417
15/***************************************************************************
16    MACROS / CONSTANTS
17***************************************************************************/
1818
19
20//**************************************************************************
21//  MACROS / CONSTANTS
22//**************************************************************************
23
1924#define VP595_TAG   "vp595"
2025
21DECLARE_LEGACY_DEVICE(VP595, vp595);
2226
23#define MCFG_VP595_ADD \
27
28//**************************************************************************
29//  INTERFACE CONFIGURATION MACROS
30//**************************************************************************
31
32#define MCFG_VP595_ADD() \
2433   MCFG_DEVICE_ADD(VP595_TAG, VP595, 0)
2534
26/***************************************************************************
27    PROTOTYPES
28***************************************************************************/
29/* Q line */
30WRITE_LINE_DEVICE_HANDLER( vp595_q_w ) ATTR_NONNULL(1);
3135
32/* install write handlers */
33void vp595_install_write_handlers(device_t *device, address_space *io, int enabled) ATTR_NONNULL(1) ATTR_NONNULL(2);
3436
35#endif /* __VP595__ */
37//**************************************************************************
38//  TYPE DEFINITIONS
39//**************************************************************************
40
41// ======================> vp595_device_config
42
43class vp595_device_config :   public device_config
44{
45    friend class vp595_device;
46
47    // construction/destruction
48    vp595_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
49
50public:
51    // allocators
52    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
53    virtual device_t *alloc_device(running_machine &machine) const;
54
55   // optional information overrides
56   virtual machine_config_constructor device_mconfig_additions() const;
57};
58
59
60// ======================> vp595_device
61
62class vp595_device :   public device_t
63{
64    friend class vp595_device_config;
65
66    // construction/destruction
67    vp595_device(running_machine &_machine, const vp595_device_config &_config);
68
69public:
70   DECLARE_WRITE8_MEMBER( latch_w );
71   DECLARE_WRITE_LINE_MEMBER( q_w );
72
73   void install_write_handlers(address_space *space, bool enabled);
74
75protected:
76    // device-level overrides
77    virtual void device_start();
78
79private:
80   required_device<cdp1863_device> m_pfg;
81   
82   const vp595_device_config &m_config;
83};
84
85
86// device type definition
87extern const device_type VP595;
88
89
90
91#endif
src/mess/includes/vip.h
r11280r11281
7878   required_device<cdp1862_device> m_cgc;
7979   required_device<device_t> m_cassette;
8080   required_device<device_t> m_beeper;
81   required_device<device_t> m_vp595;
82   required_device<device_t> m_vp550;
83   required_device<device_t> m_vp551;
81   required_device<vp595_device> m_vp595;
82   required_device<vp550_device> m_vp550;
83   required_device<vp550_device> m_vp551;
8484   required_device<device_t> m_ram;
8585
8686   virtual void machine_start();
src/mess/drivers/vip.c
r11280r11281
486486
487487static COSMAC_SC_WRITE( vip_sc_w )
488488{
489   vip_state *state = device->machine().driver_data<vip_state>();
490
489491   switch (input_port_read(device->machine(), "SOUND"))
490492   {
491493   case SOUND_VP550:
492      vp550_sc1_w(device, BIT(sc, 1)); // device = CPU since the handler calls device_set_input_line on it!
494      state->m_vp550->sc1_w(BIT(sc, 1));
493495      break;
494496
495497   case SOUND_VP551:
496      vp550_sc1_w(device, BIT(sc, 1)); // device = CPU since the handler calls device_set_input_line on it!
498      state->m_vp551->sc1_w(BIT(sc, 1));
497499      break;
498500   }
499501}
r11280r11281
505507   {
506508   case SOUND_SPEAKER:
507509      discrete_sound_w(m_beeper, NODE_01, state);
508      vp595_q_w(m_vp595, 0);
509      vp550_q_w(m_vp550, 0);
510      m_vp595->q_w(0);
511      m_vp550->q_w(0);
510512      break;
511513
512514   case SOUND_VP595:
513515      discrete_sound_w(m_beeper, NODE_01, 0);
514      vp595_q_w(m_vp595, state);
515      vp550_q_w(m_vp550, 0);
516      m_vp595->q_w(state);
517      m_vp550->q_w(0);
516518      break;
517519
518520   case SOUND_VP550:
519521   case SOUND_VP551:
520522      discrete_sound_w(m_beeper, NODE_01, 0);
521      vp595_q_w(m_vp595, 0);
522      vp550_q_w(m_vp550, state);
523      m_vp595->q_w(0);
524      m_vp550->q_w(state);
523525      break;
524526   }
525527
r11280r11281
592594
593595   /* reset sound */
594596   discrete_sound_w(m_beeper, NODE_01, 0);
595   vp595_q_w(m_vp595, 0);
596   vp550_q_w(m_vp550, 0);
597   vp550_q_w(m_vp551, 0);
597   m_vp595->q_w(0);
598   m_vp550->q_w(0);
599   m_vp551->q_w(0);
598600
599601   /* register for state saving */
600602   state_save_register_global_pointer(machine(), m_colorram, VP590_COLOR_RAM_SIZE);
r11280r11281
634636   switch (input_port_read(machine(), "SOUND"))
635637   {
636638   case SOUND_SPEAKER:
637      vp595_install_write_handlers(m_vp595, io, 0);
638      vp550_install_write_handlers(m_vp550, program, 0);
639      vp551_install_write_handlers(m_vp551, program, 0);
639      m_vp595->install_write_handlers(io, false);
640      m_vp550->install_write_handlers(program, false);
641      m_vp551->install_write_handlers(program, false);
640642      break;
641643
642644   case SOUND_VP595:
643      vp550_install_write_handlers(m_vp550, program, 0);
644      vp551_install_write_handlers(m_vp551, program, 0);
645      vp595_install_write_handlers(m_vp595, io, 1);
645      m_vp595->install_write_handlers(io, true);
646      m_vp550->install_write_handlers(program, false);
647      m_vp551->install_write_handlers(program, false);
646648      break;
647649
648650   case SOUND_VP550:
649      vp595_install_write_handlers(m_vp595, io, 0);
650      vp551_install_write_handlers(m_vp551, program, 0);
651      vp550_install_write_handlers(m_vp550, program, 1);
651      m_vp595->install_write_handlers(io, false);
652      m_vp550->install_write_handlers(program, true);
653      m_vp551->install_write_handlers(program, false);
652654      break;
653655
654656   case SOUND_VP551:
655      vp595_install_write_handlers(m_vp595, io, 0);
656      vp550_install_write_handlers(m_vp550, program, 0);
657      vp551_install_write_handlers(m_vp551, program, 1);
657      m_vp595->install_write_handlers(io, false);
658      m_vp550->install_write_handlers(program, false);
659      m_vp551->install_write_handlers(program, true);
658660      break;
659661   }
660662
r11280r11281
695697   MCFG_SOUND_CONFIG_DISCRETE(vip)
696698   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
697699
698   MCFG_VP595_ADD
700   MCFG_VP595_ADD()
699701   MCFG_VP550_ADD(XTAL_3_52128MHz/2)
700702   MCFG_VP551_ADD(XTAL_3_52128MHz/2)
701703

Previous 15994 Revisions Next


© 1998-2018 The MESS Team