Previous 15994 Revisions Next

r11284 Sunday 24th April, 2011 at 19:31:31 UTC by Curt Coder
Refactored CDP1864 into a C++ device. (no whatsnew)
[src/emu/sound]cdp1864.c cdp1864.h
[src/mess/drivers]cosmicos.c eti660.c studio2.c tmc1800.c tmc2000e.c
[src/mess/includes]cosmicos.h eti660.h studio2.h tmc1800.h tmc2000e.h
[src/mess/video]tmc1800.c

src/emu/sound/cdp1864.c
r11283r11284
2222
2323*/
2424
25
2526#include "emu.h"
2627#include "cdp1864.h"
2728
28/***************************************************************************
29    PARAMETERS
30***************************************************************************/
3129
30
31//**************************************************************************
32//  MACROS / CONSTANTS
33//**************************************************************************
34
3235#define CDP1864_DEFAULT_LATCH      0x35
3336
3437#define CDP1864_CYCLES_DMA_START   2*8
r11283r11284
3740
3841static const int CDP1864_BACKGROUND_COLOR_SEQUENCE[] = { 2, 0, 1, 4 };
3942
40/***************************************************************************
41    TYPE DEFINITIONS
42***************************************************************************/
4343
44typedef struct _cdp1864_t cdp1864_t;
45struct _cdp1864_t
46{
47   devcb_resolved_read_line      in_rdata_func;
48   devcb_resolved_read_line      in_bdata_func;
49   devcb_resolved_read_line      in_gdata_func;
50   devcb_resolved_write_line      out_int_func;
51   devcb_resolved_write_line      out_dmao_func;
52   devcb_resolved_write_line      out_efx_func;
5344
54   screen_device *screen;   /* screen */
55   bitmap_t *bitmap;            /* bitmap */
56   sound_stream *stream;         /* sound output */
45//**************************************************************************
46//  GLOBAL VARIABLES
47//**************************************************************************
5748
58   /* video state */
59   int disp;                  /* display on */
60   int dmaout;                  /* DMA request active */
61   int bgcolor;               /* background color */
62   int con;                  /* color on */
49// devices
50const device_type CDP1864 = cdp1864_device_config::static_alloc_device_config;
6351
64   /* sound state */
65   int aoe;                  /* audio on */
66   int latch;                  /* sound latch */
67   INT16 signal;               /* current signal */
68   int incr;                  /* initial wave state */
6952
70   /* timers */
71   emu_timer *int_timer;         /* interrupt timer */
72   emu_timer *efx_timer;         /* EFx timer */
73   emu_timer *dma_timer;         /* DMA timer */
7453
75   device_t *cpu;
76};
54//**************************************************************************
55//  DEVICE CONFIGURATION
56//**************************************************************************
7757
78/***************************************************************************
79    INLINE FUNCTIONS
80***************************************************************************/
8158
82INLINE cdp1864_t *get_safe_token(device_t *device)
59//-------------------------------------------------
60//  cdp1864_device_config - constructor
61//-------------------------------------------------
62
63cdp1864_device_config::cdp1864_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
64   : device_config(mconfig, static_alloc_device_config, "CDP1864", tag, owner, clock),
65     device_config_sound_interface(mconfig, *this)
8366{
84   assert(device != NULL);
85   return (cdp1864_t *)downcast<legacy_device_base *>(device)->token();
8667}
8768
88/***************************************************************************
89    IMPLEMENTATION
90***************************************************************************/
9169
92/*-------------------------------------------------
93    TIMER_CALLBACK( cdp1864_int_tick )
94-------------------------------------------------*/
70//-------------------------------------------------
71//  static_alloc_device_config - allocate a new
72//  configuration object
73//-------------------------------------------------
9574
96static TIMER_CALLBACK( cdp1864_int_tick )
75device_config *cdp1864_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
9776{
98   device_t *device = (device_t *) ptr;
99   cdp1864_t *cdp1864 = get_safe_token(device);
77   return global_alloc(cdp1864_device_config(mconfig, tag, owner, clock));
78}
10079
101   int scanline = cdp1864->screen->vpos();
10280
103   if (scanline == CDP1864_SCANLINE_INT_START)
104   {
105      if (cdp1864->disp)
106      {
107         devcb_call_write_line(&cdp1864->out_int_func, ASSERT_LINE);
108      }
81//-------------------------------------------------
82//  alloc_device - allocate a new device object
83//-------------------------------------------------
10984
110      cdp1864->int_timer->adjust(cdp1864->screen->time_until_pos(CDP1864_SCANLINE_INT_END));
111   }
112   else
113   {
114      if (cdp1864->disp)
115      {
116         devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
117      }
118
119      cdp1864->int_timer->adjust(cdp1864->screen->time_until_pos(CDP1864_SCANLINE_INT_START));
120   }
85device_t *cdp1864_device_config::alloc_device(running_machine &machine) const
86{
87   return auto_alloc(machine, cdp1864_device(machine, *this));
12188}
12289
123/*-------------------------------------------------
124    TIMER_CALLBACK( cdp1864_efx_tick )
125-------------------------------------------------*/
12690
127static TIMER_CALLBACK( cdp1864_efx_tick )
91//-------------------------------------------------
92//  device_config_complete - perform any
93//  operations now that the configuration is
94//  complete
95//-------------------------------------------------
96
97void cdp1864_device_config::device_config_complete()
12898{
129   device_t *device = (device_t *) ptr;
130   cdp1864_t *cdp1864 = get_safe_token(device);
99   // inherit a copy of the static data
100   const cdp1864_interface *intf = reinterpret_cast<const cdp1864_interface *>(static_config());
101   if (intf != NULL)
102      *static_cast<cdp1864_interface *>(this) = *intf;
131103
132   int scanline = cdp1864->screen->vpos();
133
134   switch (scanline)
104   // or initialize to defaults if none provided
105   else
135106   {
136   case CDP1864_SCANLINE_EFX_TOP_START:
137      devcb_call_write_line(&cdp1864->out_efx_func, ASSERT_LINE);
138      cdp1864->efx_timer->adjust(cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_END));
139      break;
140
141   case CDP1864_SCANLINE_EFX_TOP_END:
142      devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
143      cdp1864->efx_timer->adjust(cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_BOTTOM_START));
144      break;
145
146   case CDP1864_SCANLINE_EFX_BOTTOM_START:
147      devcb_call_write_line(&cdp1864->out_efx_func, ASSERT_LINE);
148      cdp1864->efx_timer->adjust(cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_BOTTOM_END));
149      break;
150
151   case CDP1864_SCANLINE_EFX_BOTTOM_END:
152      devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
153      cdp1864->efx_timer->adjust(cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_START));
154      break;
107      memset(&m_in_inlace_func, 0, sizeof(m_in_inlace_func));
108      memset(&m_in_rdata_func, 0, sizeof(m_in_rdata_func));
109      memset(&m_in_bdata_func, 0, sizeof(m_in_bdata_func));
110      memset(&m_in_gdata_func, 0, sizeof(m_in_gdata_func));
111      memset(&m_out_int_func, 0, sizeof(m_out_int_func));
112      memset(&m_out_dmao_func, 0, sizeof(m_out_dmao_func));
113      memset(&m_out_efx_func, 0, sizeof(m_out_efx_func));
114      memset(&m_out_hsync_func, 0, sizeof(m_out_hsync_func));
155115   }
156116}
157117
158/*-------------------------------------------------
159    TIMER_CALLBACK( cdp1864_dma_tick )
160-------------------------------------------------*/
161118
162static TIMER_CALLBACK( cdp1864_dma_tick )
163{
164   device_t *device = (device_t *) ptr;
165   cdp1864_t *cdp1864 = get_safe_token(device);
166119
167   int scanline = cdp1864->screen->vpos();
120//**************************************************************************
121//  INLINE HELPERS
122//**************************************************************************
168123
169   if (cdp1864->dmaout)
170   {
171      if (cdp1864->disp)
172      {
173         if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END)
174         {
175            devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
176         }
177      }
124//-------------------------------------------------
125//  initialize_palette -
126//-------------------------------------------------
178127
179      cdp1864->dma_timer->adjust(machine.firstcpu->cycles_to_attotime(CDP1864_CYCLES_DMA_WAIT));
180
181      cdp1864->dmaout = 0;
182   }
183   else
184   {
185      if (cdp1864->disp)
186      {
187         if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END)
188         {
189            devcb_call_write_line(&cdp1864->out_dmao_func, ASSERT_LINE);
190         }
191      }
192
193      cdp1864->dma_timer->adjust(machine.firstcpu->cycles_to_attotime(CDP1864_CYCLES_DMA_ACTIVE));
194
195      cdp1864->dmaout = 1;
196   }
197}
198
199/*-------------------------------------------------
200    cdp1864_init_palette - initialize palette
201-------------------------------------------------*/
202
203static void cdp1864_init_palette(device_t *device, const cdp1864_interface *intf)
128inline void cdp1864_device::initialize_palette()
204129{
205   int i;
130   double res_total = m_config.m_res_r + m_config.m_res_g + m_config.m_res_b + m_config.m_res_bkg;
206131
207   double res_total = intf->res_r + intf->res_g + intf->res_b + intf->res_bkg;
132   int weight_r = (m_config.m_res_r / res_total) * 100;
133   int weight_g = (m_config.m_res_g / res_total) * 100;
134   int weight_b = (m_config.m_res_b / res_total) * 100;
135   int weight_bkg = (m_config.m_res_bkg / res_total) * 100;
208136
209   int weight_r = (intf->res_r / res_total) * 100;
210   int weight_g = (intf->res_g / res_total) * 100;
211   int weight_b = (intf->res_b / res_total) * 100;
212   int weight_bkg = (intf->res_bkg / res_total) * 100;
213
214   for (i = 0; i < 16; i++)
137   for (int i = 0; i < 16; i++)
215138   {
216      int r, g, b, luma = 0;
139      int luma = 0;
217140
218141      luma += (i & 4) ? weight_r : 0;
219142      luma += (i & 1) ? weight_g : 0;
r11283r11284
222145
223146      luma = (luma * 0xff) / 100;
224147
225      r = (i & 4) ? luma : 0;
226      g = (i & 1) ? luma : 0;
227      b = (i & 2) ? luma : 0;
148      int r = (i & 4) ? luma : 0;
149      int g = (i & 1) ? luma : 0;
150      int b = (i & 2) ? luma : 0;
228151
229      palette_set_color_rgb( device->machine(), i, r, g, b );
152      palette_set_color_rgb(machine(), i, r, g, b);
230153   }
231154}
232155
233/*-------------------------------------------------
234    cdp1864_aoe_w - audio output enable
235-------------------------------------------------*/
236156
237WRITE_LINE_DEVICE_HANDLER( cdp1864_aoe_w )
238{
239   cdp1864_t *cdp1864 = get_safe_token(device);
240157
241   if (!state)
242   {
243      cdp1864->latch = CDP1864_DEFAULT_LATCH;
244   }
158//**************************************************************************
159//  LIVE DEVICE
160//**************************************************************************
245161
246   cdp1864->aoe = state;
162//-------------------------------------------------
163//  cdp1864_device - constructor
164//-------------------------------------------------
165
166cdp1864_device::cdp1864_device(running_machine &_machine, const cdp1864_device_config &config)
167    : device_t(_machine, config),
168     device_sound_interface(_machine, config, *this),
169     m_disp(0),
170     m_dmaout(0),
171     m_bgcolor(0),
172     m_con(0),
173     m_aoe(0),
174     m_latch(CDP1864_DEFAULT_LATCH),
175      m_config(config)
176{
247177}
248178
249/*-------------------------------------------------
250    cdp1864_dispon_r - turn display on
251-------------------------------------------------*/
252179
253READ8_DEVICE_HANDLER( cdp1864_dispon_r )
180//-------------------------------------------------
181//  device_start - device-specific startup
182//-------------------------------------------------
183
184void cdp1864_device::device_start()
254185{
255   cdp1864_t *cdp1864 = get_safe_token(device);
186   // resolve callbacks
187   devcb_resolve_read_line(&m_in_inlace_func, &m_config.m_in_inlace_func, this);
188   devcb_resolve_read_line(&m_in_rdata_func, &m_config.m_in_rdata_func, this);
189   devcb_resolve_read_line(&m_in_bdata_func, &m_config.m_in_bdata_func, this);
190   devcb_resolve_read_line(&m_in_gdata_func, &m_config.m_in_gdata_func, this);
191   devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this);
192   devcb_resolve_write_line(&m_out_dmao_func, &m_config.m_out_dmao_func, this);
193   devcb_resolve_write_line(&m_out_efx_func, &m_config.m_out_efx_func, this);
194   devcb_resolve_write_line(&m_out_hsync_func, &m_config.m_out_hsync_func, this);
256195
257   cdp1864->disp = 1;
196   // initialize palette
197   initialize_palette();
258198
259   return 0xff;
260}
199   // create sound stream
200   m_stream = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate());
261201
262/*-------------------------------------------------
263    cdp1864_dispoff_r - turn display off
264-------------------------------------------------*/
202   // allocate timers
203   m_int_timer = timer_alloc(TIMER_INT);
204   m_efx_timer = timer_alloc(TIMER_EFX);
205   m_dma_timer = timer_alloc(TIMER_DMA);
206   m_hsync_timer = timer_alloc(TIMER_HSYNC);
265207
266READ8_DEVICE_HANDLER( cdp1864_dispoff_r )
267{
268   cdp1864_t *cdp1864 = get_safe_token(device);
208   // find devices
209   m_cpu = machine().device<cpu_device>(m_config.m_cpu_tag);
210   m_screen = machine().device<screen_device>(m_config.m_screen_tag);
211   m_bitmap = auto_bitmap_alloc(machine(), m_screen->width(), m_screen->height(), m_screen->format());
269212
270   cdp1864->disp = 0;
213   // register for state saving
214   save_item(NAME(m_disp));
215   save_item(NAME(m_dmaout));
216   save_item(NAME(m_bgcolor));
217   save_item(NAME(m_con));
218   save_item(NAME(m_aoe));
219   save_item(NAME(m_latch));
220   save_item(NAME(m_signal));
221   save_item(NAME(m_incr));
222}
271223
272   devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
273   devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
274224
275   return 0xff;
276}
225//-------------------------------------------------
226//  device_reset - device-specific reset
227//-------------------------------------------------
277228
278/*-------------------------------------------------
279    cdp1864_step_bgcolor_w - step background color
280-------------------------------------------------*/
281
282WRITE8_DEVICE_HANDLER( cdp1864_step_bgcolor_w )
229void cdp1864_device::device_reset()
283230{
284   cdp1864_t *cdp1864 = get_safe_token(device);
231   m_int_timer->adjust(m_screen->time_until_pos(CDP1864_SCANLINE_INT_START, 0));
232   m_efx_timer->adjust(m_screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_START, 0));
233   m_dma_timer->adjust(m_cpu->cycles_to_attotime(CDP1864_CYCLES_DMA_START));
285234
286   cdp1864->disp = 1;
235   m_disp = 0;
236   m_dmaout = 0;
287237
288   if (++cdp1864->bgcolor > 3) cdp1864->bgcolor = 0;
238   devcb_call_write_line(&m_out_int_func, CLEAR_LINE);
239   devcb_call_write_line(&m_out_dmao_func, CLEAR_LINE);
240   devcb_call_write_line(&m_out_efx_func, CLEAR_LINE);
289241}
290242
291/*-------------------------------------------------
292    cdp1864_con_w - color on write
293-------------------------------------------------*/
294243
295WRITE_LINE_DEVICE_HANDLER( cdp1864_con_w )
244//-------------------------------------------------
245//  device_timer - handle timer events
246//-------------------------------------------------
247
248void cdp1864_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
296249{
297   cdp1864_t *cdp1864 = get_safe_token(device);
250   int scanline = m_screen->vpos();
298251
299   if (!state)
252   switch (id)
300253   {
301      cdp1864->con = 0;
302   }
303}
254   case TIMER_INT:
255      if (scanline == CDP1864_SCANLINE_INT_START)
256      {
257         if (m_disp)
258         {
259            devcb_call_write_line(&m_out_int_func, ASSERT_LINE);
260         }
304261
305/*-------------------------------------------------
306    cdp1864_tone_latch_w - load tone latch
307-------------------------------------------------*/
262         m_int_timer->adjust(m_screen->time_until_pos( CDP1864_SCANLINE_INT_END, 0));
263      }
264      else
265      {
266         if (m_disp)
267         {
268            devcb_call_write_line(&m_out_int_func, CLEAR_LINE);
269         }
308270
309WRITE8_DEVICE_HANDLER( cdp1864_tone_latch_w )
310{
311   cdp1864_t *cdp1864 = get_safe_token(device);
271         m_int_timer->adjust(m_screen->time_until_pos(CDP1864_SCANLINE_INT_START, 0));
272      }
273      break;
312274
313   cdp1864->latch = data;
314}
275   case TIMER_EFX:
276      switch (scanline)
277      {
278      case CDP1864_SCANLINE_EFX_TOP_START:
279         devcb_call_write_line(&m_out_efx_func, ASSERT_LINE);
280         m_efx_timer->adjust(m_screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_END, 0));
281         break;
315282
316/*-------------------------------------------------
317    cdp1864_dma_w - write DMA byte
318-------------------------------------------------*/
283      case CDP1864_SCANLINE_EFX_TOP_END:
284         devcb_call_write_line(&m_out_efx_func, CLEAR_LINE);
285         m_efx_timer->adjust(m_screen->time_until_pos(CDP1864_SCANLINE_EFX_BOTTOM_START, 0));
286         break;
319287
320WRITE8_DEVICE_HANDLER( cdp1864_dma_w )
321{
322   cdp1864_t *cdp1864 = get_safe_token(device);
288      case CDP1864_SCANLINE_EFX_BOTTOM_START:
289         devcb_call_write_line(&m_out_efx_func, ASSERT_LINE);
290         m_efx_timer->adjust(m_screen->time_until_pos(CDP1864_SCANLINE_EFX_BOTTOM_END, 0));
291         break;
323292
324   int rdata = 1, bdata = 1, gdata = 1;
325   int sx = cdp1864->screen->hpos() + 4;
326   int y = cdp1864->screen->vpos();
327   int x;
293      case CDP1864_SCANLINE_EFX_BOTTOM_END:
294         devcb_call_write_line(&m_out_efx_func, CLEAR_LINE);
295         m_efx_timer->adjust(m_screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_START, 0));
296         break;
297      }
298      break;
328299
329   if (!cdp1864->con)
330   {
331      rdata = devcb_call_read_line(&cdp1864->in_rdata_func);
332      bdata = devcb_call_read_line(&cdp1864->in_bdata_func);
333      gdata = devcb_call_read_line(&cdp1864->in_gdata_func);
334   }
300   case TIMER_DMA:
301      if (m_dmaout)
302      {
303         if (m_disp)
304         {
305            if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END)
306            {
307               devcb_call_write_line(&m_out_dmao_func, CLEAR_LINE);
308            }
309         }
335310
336   for (x = 0; x < 8; x++)
337   {
338      int color = CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8;
311         m_dma_timer->adjust(m_cpu->cycles_to_attotime(CDP1864_CYCLES_DMA_WAIT));
339312
340      if (BIT(data, 7))
313         m_dmaout = 0;
314      }
315      else
341316      {
342         color = (gdata << 2) | (bdata << 1) | rdata;
343      }
317         if (m_disp)
318         {
319            if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END)
320            {
321               devcb_call_write_line(&m_out_dmao_func, ASSERT_LINE);
322            }
323         }
344324
345      *BITMAP_ADDR16(cdp1864->bitmap, y, sx + x) = color;
325         m_dma_timer->adjust(m_cpu->cycles_to_attotime(CDP1864_CYCLES_DMA_ACTIVE));
346326
347      data <<= 1;
327         m_dmaout = 1;
328      }
329      break;
348330   }
349331}
350332
351/*-------------------------------------------------
352    STREAM_UPDATE( cdp1864_stream_update )
353-------------------------------------------------*/
354333
355static STREAM_UPDATE( cdp1864_stream_update )
334//-------------------------------------------------
335//  sound_stream_update - handle update requests for
336//  our sound stream
337//-------------------------------------------------
338
339void cdp1864_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
356340{
357   cdp1864_t *cdp1864 = get_safe_token(device);
341   // reset the output stream
342   memset(outputs[0], 0, samples * sizeof(*outputs[0]));
358343
359   INT16 signal = cdp1864->signal;
344   INT16 signal = m_signal;
360345   stream_sample_t *buffer = outputs[0];
361346
362347   memset( buffer, 0, samples * sizeof(*buffer) );
363348
364   if (cdp1864->aoe)
349   if (m_aoe)
365350   {
366      double frequency = cdp1864->cpu->unscaled_clock() / 8 / 4 / (cdp1864->latch + 1) / 2;
367      int rate = device->machine().sample_rate() / 2;
351      double frequency = m_cpu->unscaled_clock() / 8 / 4 / (m_latch + 1) / 2;
352      int rate = machine().sample_rate() / 2;
368353
369354      /* get progress through wave */
370      int incr = cdp1864->incr;
355      int incr = m_incr;
371356
372357      if (signal < 0)
373358      {
r11283r11284
390375      }
391376
392377      /* store progress through wave */
393      cdp1864->incr = incr;
394      cdp1864->signal = signal;
378      m_incr = incr;
379      m_signal = signal;
395380   }
396381}
397382
398/*-------------------------------------------------
399    cdp1864_update - update screen
400-------------------------------------------------*/
401383
402void cdp1864_update(device_t *device, bitmap_t *bitmap, const rectangle *cliprect)
384//-------------------------------------------------
385//  dispon_r -
386//-------------------------------------------------
387
388READ8_MEMBER( cdp1864_device::dispon_r )
403389{
404   cdp1864_t *cdp1864 = get_safe_token(device);
390   m_disp = 1;
405391
406   if (cdp1864->disp)
407   {
408      copybitmap(bitmap, cdp1864->bitmap, 0, 0, 0, 0, cliprect);
409      bitmap_fill(cdp1864->bitmap, cliprect, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8);
410   }
411   else
412   {
413      bitmap_fill(bitmap, cliprect, get_black_pen(device->machine()));
414   }
392   return 0xff;
415393}
416394
417/*-------------------------------------------------
418    DEVICE_START( cdp1864 )
419-------------------------------------------------*/
420395
421static DEVICE_START( cdp1864 )
396//-------------------------------------------------
397//  dispoff_r -
398//-------------------------------------------------
399
400READ8_MEMBER( cdp1864_device::dispoff_r )
422401{
423   cdp1864_t *cdp1864 = get_safe_token(device);
424   const cdp1864_interface *intf = (const cdp1864_interface *) device->baseconfig().static_config();
402   m_disp = 0;
425403
426   /* resolve callbacks */
427   devcb_resolve_read_line(&cdp1864->in_rdata_func, &intf->in_rdata_func, device);
428   devcb_resolve_read_line(&cdp1864->in_bdata_func, &intf->in_bdata_func, device);
429   devcb_resolve_read_line(&cdp1864->in_gdata_func, &intf->in_gdata_func, device);
430   devcb_resolve_write_line(&cdp1864->out_int_func, &intf->out_int_func, device);
431   devcb_resolve_write_line(&cdp1864->out_dmao_func, &intf->out_dmao_func, device);
432   devcb_resolve_write_line(&cdp1864->out_efx_func, &intf->out_efx_func, device);
404   devcb_call_write_line(&m_out_int_func, CLEAR_LINE);
405   devcb_call_write_line(&m_out_dmao_func, CLEAR_LINE);
433406
434   /* get the cpu */
435   cdp1864->cpu = device->machine().device(intf->cpu_tag);
407   return 0xff;
408}
436409
437   /* get the screen device */
438   cdp1864->screen = downcast<screen_device *>(device->machine().device(intf->screen_tag));
439   assert(cdp1864->screen != NULL);
440410
441   /* allocate the temporary bitmap */
442   cdp1864->bitmap = auto_bitmap_alloc(device->machine(), cdp1864->screen->width(), cdp1864->screen->height(), cdp1864->screen->format());
443   bitmap_fill(cdp1864->bitmap, 0, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8);
411//-------------------------------------------------
412//  step_bgcolor_w -
413//-------------------------------------------------
444414
445   /* initialize the palette */
446   cdp1864_init_palette(device, intf);
415WRITE8_MEMBER( cdp1864_device::step_bgcolor_w )
416{
417   m_disp = 1;
447418
448   /* create sound stream */
449   cdp1864->stream = device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), cdp1864, cdp1864_stream_update);
419   m_bgcolor++;
450420
451   /* create the timers */
452   cdp1864->int_timer = device->machine().scheduler().timer_alloc(FUNC(cdp1864_int_tick), (void *)device);
453   cdp1864->efx_timer = device->machine().scheduler().timer_alloc(FUNC(cdp1864_efx_tick), (void *)device);
454   cdp1864->dma_timer = device->machine().scheduler().timer_alloc(FUNC(cdp1864_dma_tick), (void *)device);
421   if (m_bgcolor > 3)
422   {
423      m_bgcolor = 0;
424   }
425}
455426
456   /* register for state saving */
457   device->save_item(NAME(cdp1864->disp));
458   device->save_item(NAME(cdp1864->dmaout));
459   device->save_item(NAME(cdp1864->bgcolor));
460   device->save_item(NAME(cdp1864->con));
461427
462   device->save_item(NAME(cdp1864->aoe));
463   device->save_item(NAME(cdp1864->latch));
464   device->save_item(NAME(cdp1864->signal));
465   device->save_item(NAME(cdp1864->incr));
428//-------------------------------------------------
429//  tone_latch_w -
430//-------------------------------------------------
466431
467   device->save_item(NAME(*cdp1864->bitmap));
432WRITE8_MEMBER( cdp1864_device::tone_latch_w )
433{
434   m_latch = data;
468435}
469436
470/*-------------------------------------------------
471    DEVICE_RESET( cdp1864 )
472-------------------------------------------------*/
473437
474static DEVICE_RESET( cdp1864 )
438//-------------------------------------------------
439//  dma_w -
440//-------------------------------------------------
441
442WRITE8_MEMBER( cdp1864_device::dma_w )
475443{
476   cdp1864_t *cdp1864 = get_safe_token(device);
444   int rdata = 1, bdata = 1, gdata = 1;
445   int sx = m_screen->hpos() + 4;
446   int y = m_screen->vpos();
477447
478   cdp1864->int_timer->adjust(cdp1864->screen->time_until_pos(CDP1864_SCANLINE_INT_START));
479   cdp1864->efx_timer->adjust(cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_START));
480   cdp1864->dma_timer->adjust(device->machine().firstcpu->cycles_to_attotime(CDP1864_CYCLES_DMA_START));
448   if (!m_con)
449   {
450      rdata = devcb_call_read_line(&m_in_rdata_func);
451      bdata = devcb_call_read_line(&m_in_bdata_func);
452      gdata = devcb_call_read_line(&m_in_gdata_func);
453   }
481454
482   cdp1864->disp = 0;
483   cdp1864->dmaout = 0;
484   cdp1864->bgcolor = 0;
485   cdp1864->con = 1;
455   for (int x = 0; x < 8; x++)
456   {
457      int color = CDP1864_BACKGROUND_COLOR_SEQUENCE[m_bgcolor] + 8;
486458
487   devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
488   devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
489   devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
459      if (BIT(data, 7))
460      {
461         color = (gdata << 2) | (bdata << 1) | rdata;
462      }
490463
491   cdp1864_aoe_w(device, 0);
464      *BITMAP_ADDR16(m_bitmap, y, sx + x) = color;
465
466      data <<= 1;
467   }
492468}
493469
494/*-------------------------------------------------
495    DEVICE_GET_INFO( cdp1864 )
496-------------------------------------------------*/
497470
498DEVICE_GET_INFO( cdp1864 )
471//-------------------------------------------------
472//  con_w - color on write
473//-------------------------------------------------
474
475WRITE_LINE_MEMBER( cdp1864_device::con_w )
499476{
500   switch (state)
477   if (!state)
501478   {
502      /* --- the following bits of info are returned as 64-bit signed integers --- */
503      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cdp1864_t);                  break;
504      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                              break;
479      m_con = 0;
480   }
481}
505482
506      /* --- the following bits of info are returned as pointers to data or functions --- */
507      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cdp1864);         break;
508      case DEVINFO_FCT_STOP:                     /* Nothing */                              break;
509      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(cdp1864);         break;
510483
511      /* --- the following bits of info are returned as NULL-terminated strings --- */
512      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA CDP1864");                  break;
513      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA CDP1800");                  break;
514      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                        break;
515      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
516      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");            break;
484//-------------------------------------------------
485//  aoe_w - audio output enable write
486//-------------------------------------------------
487
488WRITE_LINE_MEMBER( cdp1864_device::aoe_w )
489{
490   if (!state)
491   {
492      m_latch = CDP1864_DEFAULT_LATCH;
517493   }
494
495   m_aoe = state;
518496}
519497
520498
521DEFINE_LEGACY_SOUND_DEVICE(CDP1864, cdp1864);
499//-------------------------------------------------
500//  evs_w - external vertical sync write
501//-------------------------------------------------
502
503WRITE_LINE_MEMBER( cdp1864_device::evs_w )
504{
505}
506
507
508//-------------------------------------------------
509//  update_screen -
510//-------------------------------------------------
511
512void cdp1864_device::update_screen(bitmap_t *bitmap, const rectangle *cliprect)
513{
514   if (m_disp)
515   {
516      copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect);
517      bitmap_fill(m_bitmap, cliprect, CDP1864_BACKGROUND_COLOR_SEQUENCE[m_bgcolor] + 8);
518   }
519   else
520   {
521      bitmap_fill(bitmap, cliprect, get_black_pen(machine()));
522   }
523}
src/emu/sound/cdp1864.h
r11283r11284
66    Visit http://mamedev.org for licensing and usage restrictions.
77
88**********************************************************************
9                            ________________
10            INLACE   1  ---|       \/       |---  40  Vdd
11           CLK IN_   2  ---|                |---  39  AUD
12          CLR OUT_   3  ---|                |---  38  CLR IN_
13               AOE   4  ---|                |---  37  DMA0_
14               SC1   5  ---|                |---  36  INT_
15               SC0   6  ---|                |---  35  TPA
16              MRD_   7  ---|                |---  34  TPB
17             BUS 7   8  ---|                |---  33  EVS
18             BUS 6   9  ---|                |---  32  V SYNC
19             BUS 5  10  ---|    CDP1864C    |---  31  H SYNC
20             BUS 4  11  ---|    top view    |---  30  C SYNC_
21             BUS 3  12  ---|                |---  29  RED
22             BUS 2  13  ---|                |---  28  BLUE
23             BUS 1  14  ---|                |---  27  GREEN
24             BUS 0  15  ---|                |---  26  BCK GND_
25              CON_  16  ---|                |---  25  BURST
26                N2  17  ---|                |---  24  ALT
27               EF_  18  ---|                |---  23  R DATA
28                N0  19  ---|                |---  22  G DATA
29               Vss  20  ---|________________|---  21  B DATA
9                     _____   _____
10            INLACE   1 |*    \_/     | 40  Vdd
11            CLK IN_   2 |             | 39  AUD
12           CLR OUT_   3 |             | 38  CLR IN_
13               AOE   4 |             | 37  DMA0_
14               SC1   5 |             | 36  INT_
15               SC0   6 |             | 35  TPA
16              MRD_   7 |             | 34  TPB
17             BUS 7   8 |             | 33  EVS
18             BUS 6   9 |             | 32  V SYNC
19             BUS 5  10 |   CDP1864   | 31  H SYNC
20             BUS 4  11 |             | 30  C SYNC_
21             BUS 3  12 |             | 29  RED
22             BUS 2  13 |             | 28  BLUE
23             BUS 1  14 |             | 27  GREEN
24             BUS 0  15 |             | 26  BCK GND_
25              CON_  16 |             | 25  BURST
26               N2  17 |             | 24  ALT
27               EF_  18 |             | 23  R DATA
28               N0  19 |             | 22  G DATA
29               Vss  20 |_____________| 21  B DATA
3030
3131
3232           http://homepage.mac.com/ruske/cosmacelf/cdp1864.pdf
3333
3434**********************************************************************/
3535
36#pragma once
37
3638#ifndef __CDP1864__
3739#define __CDP1864__
3840
39#include "devlegcy.h"
41#include "emu.h"
4042
4143
42/***************************************************************************
43    PARAMETERS
44***************************************************************************/
4544
45//**************************************************************************
46//  MACROS / CONSTANTS
47//**************************************************************************
48
4649#define CDP1864_CLOCK   XTAL_1_75MHz
4750
4851#define CDP1864_VISIBLE_COLUMNS   64
r11283r11284
7174#define CDP1864_SCANLINE_EFX_BOTTOM_START   CDP1864_SCANLINE_DISPLAY_END - 4
7275#define CDP1864_SCANLINE_EFX_BOTTOM_END      CDP1864_SCANLINE_DISPLAY_END
7376
74/***************************************************************************
75    MACROS / CONSTANTS
76***************************************************************************/
7777
78DECLARE_LEGACY_SOUND_DEVICE(CDP1864, cdp1864);
7978
79//**************************************************************************
80//  INTERFACE CONFIGURATION MACROS
81//**************************************************************************
82
8083#define MCFG_CDP1864_ADD(_tag, _clock, _config) \
8184   MCFG_SOUND_ADD(_tag, CDP1864, _clock) \
8285   MCFG_DEVICE_CONFIG(_config)
8386
87
8488#define MCFG_CDP1864_SCREEN_ADD(_tag, _clock) \
8589   MCFG_SCREEN_ADD(_tag, RASTER) \
8690   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) \
8791   MCFG_SCREEN_RAW_PARAMS(_clock, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START)
8892
93
8994#define CDP1864_INTERFACE(name) \
9095   const cdp1864_interface (name) =
9196
92/***************************************************************************
93    TYPE DEFINITIONS
94***************************************************************************/
9597
96enum _cdp1864_format {
97   CDP1864_NON_INTERLACED = 0,
98   CDP1864_INTERLACED
99};
100typedef enum _cdp1864_format cdp1864_format;
98#define CDP1864_NON_INTERLACED \
99   DEVCB_LINE_VCC
101100
102typedef struct _cdp1864_interface cdp1864_interface;
103struct _cdp1864_interface
101
102#define CDP1864_INTERLACED \
103   DEVCB_LINE_GND
104
105
106
107//**************************************************************************
108//  TYPE DEFINITIONS
109//**************************************************************************
110
111// ======================> cdp1864_interface
112
113struct cdp1864_interface
104114{
105   const char *cpu_tag;      /* cpu we are working with */
106   const char *screen_tag;      /* screen we are acting on */
115   const char *m_cpu_tag;
116   const char *m_screen_tag;
107117
108   cdp1864_format interlace;   /* interlace */
118   devcb_read_line            m_in_inlace_func;
109119
110   devcb_read_line            in_rdata_func;
111   devcb_read_line            in_bdata_func;
112   devcb_read_line            in_gdata_func;
120   devcb_read_line            m_in_rdata_func;
121   devcb_read_line            m_in_bdata_func;
122   devcb_read_line            m_in_gdata_func;
113123
114   /* this gets called for every change of the INT pin (pin 36) */
115   devcb_write_line         out_int_func;
124   devcb_write_line         m_out_int_func;
125   devcb_write_line         m_out_dmao_func;
126   devcb_write_line         m_out_efx_func;
127   devcb_write_line         m_out_hsync_func;
116128
117   /* this gets called for every change of the DMAO pin (pin 37) */
118   devcb_write_line         out_dmao_func;
129   double m_res_r;            // red output resistor value
130   double m_res_g;            // green output resistor value
131   double m_res_b;            // blue output resistor value
132   double m_res_bkg;         // background output resistor value
133};
119134
120   /* this gets called for every change of the EFX pin (pin 18) */
121   devcb_write_line         out_efx_func;
122135
123   double res_r;            /* red output resistor value */
124   double res_g;            /* green output resistor value */
125   double res_b;            /* blue output resistor value */
126   double res_bkg;            /* background output resistor value */
136
137// ======================> cdp1864_device_config
138
139class cdp1864_device_config :   public device_config,
140                        public device_config_sound_interface,
141                                public cdp1864_interface
142{
143    friend class cdp1864_device;
144
145    // construction/destruction
146    cdp1864_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
147
148public:
149    // allocators
150    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
151    virtual device_t *alloc_device(running_machine &machine) const;
152
153protected:
154   // device_config overrides
155   virtual void device_config_complete();
127156};
128157
129/***************************************************************************
130    PROTOTYPES
131***************************************************************************/
132158
133/* display on (0x69) */
134READ8_DEVICE_HANDLER( cdp1864_dispon_r ) ATTR_NONNULL(1);
135159
136/* display off (0x6c) */
137READ8_DEVICE_HANDLER( cdp1864_dispoff_r ) ATTR_NONNULL(1);
160// ======================> cdp1864_device
138161
139/* step background color (0x61) */
140WRITE8_DEVICE_HANDLER( cdp1864_step_bgcolor_w ) ATTR_NONNULL(1);
162class cdp1864_device :   public device_t,
163                  public device_sound_interface
164{
165    friend class cdp1864_device_config;
141166
142/* color on */
143WRITE_LINE_DEVICE_HANDLER( cdp1864_con_w ) ATTR_NONNULL(1);
167    // construction/destruction
168    cdp1864_device(running_machine &_machine, const cdp1864_device_config &_config);
144169
145/* load tone latch (0x64) */
146WRITE8_DEVICE_HANDLER( cdp1864_tone_latch_w ) ATTR_NONNULL(1);
170public:
171   DECLARE_READ8_MEMBER( dispon_r );
172   DECLARE_READ8_MEMBER( dispoff_r );
147173
148/* audio output enable */
149WRITE_LINE_DEVICE_HANDLER( cdp1864_aoe_w ) ATTR_NONNULL(1);
174   DECLARE_WRITE8_MEMBER( step_bgcolor_w );
175   DECLARE_WRITE8_MEMBER( tone_latch_w );
150176
151/* DMA write */
152WRITE8_DEVICE_HANDLER( cdp1864_dma_w ) ATTR_NONNULL(1);
177   DECLARE_WRITE8_MEMBER( dma_w );
153178
154/* screen update */
155void cdp1864_update(device_t *device, bitmap_t *bitmap, const rectangle *cliprect) ATTR_NONNULL(1) ATTR_NONNULL(2) ATTR_NONNULL(3);
179   DECLARE_WRITE_LINE_MEMBER( con_w );
180   DECLARE_WRITE_LINE_MEMBER( aoe_w );
181   DECLARE_WRITE_LINE_MEMBER( evs_w );
156182
183   void update_screen(bitmap_t *bitmap, const rectangle *cliprect);
184
185protected:
186    // device-level overrides
187    virtual void device_start();
188    virtual void device_reset();
189   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
190
191   // internal callbacks
192   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
193
194private:
195   inline void initialize_palette();
196
197   static const device_timer_id TIMER_INT = 0;
198   static const device_timer_id TIMER_EFX = 1;
199   static const device_timer_id TIMER_DMA = 2;
200   static const device_timer_id TIMER_HSYNC = 3;
201
202   devcb_resolved_read_line      m_in_inlace_func;
203   devcb_resolved_read_line      m_in_rdata_func;
204   devcb_resolved_read_line      m_in_bdata_func;
205   devcb_resolved_read_line      m_in_gdata_func;
206   devcb_resolved_write_line      m_out_int_func;
207   devcb_resolved_write_line      m_out_dmao_func;
208   devcb_resolved_write_line      m_out_efx_func;
209   devcb_resolved_write_line      m_out_hsync_func;
210
211   cpu_device *m_cpu;
212   screen_device *m_screen;      // screen
213   bitmap_t *m_bitmap;            // bitmap
214   sound_stream *m_stream;         // sound output
215
216   // video state
217   int m_disp;                  // display on
218   int m_dmaout;               // DMA request active
219   int m_bgcolor;               // background color
220   int m_con;                  // color on
221
222   // sound state
223   int m_aoe;                  // audio on
224   int m_latch;               // sound latch
225   INT16 m_signal;               // current signal
226   int m_incr;                  // initial wave state
227
228   // timers
229   emu_timer *m_int_timer;
230   emu_timer *m_efx_timer;
231   emu_timer *m_dma_timer;
232   emu_timer *m_hsync_timer;
233
234   const cdp1864_device_config &m_config;
235};
236
237
238// device type definition
239extern const device_type CDP1864;
240
241
242
157243#endif
src/mess/video/tmc1800.c
r11283r11284
5151   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
5252   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT),
5353   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1),
54   DEVCB_NULL,
5455   RES_K(1.21),   // RL64
5556   RES_K(2.05),   // RL63
5657   RES_K(2.26),   // RL61
r11283r11284
5960
6061bool tmc2000_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
6162{
62   cdp1864_update(m_cti, &bitmap, &cliprect);
63   m_cti->update_screen(&bitmap, &cliprect);
6364
6465   return 0;
6566}
r11283r11284
7778   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
7879   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT),
7980   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1),
81   DEVCB_NULL,
8082   RES_K(1.21), // R18 unconfirmed
8183   0, // not connected
8284   0, // not connected
r11283r11284
8587
8688bool nano_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
8789{
88   cdp1864_update(m_cti, &bitmap, &cliprect);
90   m_cti->update_screen(&bitmap, &cliprect);
8991
9092   return 0;
9193}
src/mess/includes/eti660.h
r11283r11284
3737   { }
3838
3939   required_device<cosmac_device> m_maincpu;
40   required_device<device_t> m_cti;
40   required_device<cdp1864_device> m_cti;
4141   required_device<device_t> m_pia;
4242   required_device<device_t> m_cassette;
4343
src/mess/includes/studio2.h
r11283r11284
7070        m_cti(*this, CDP1864_TAG)
7171   { }
7272
73   required_device<device_t> m_cti;
73   required_device<cdp1864_device> m_cti;
7474
7575   virtual void machine_reset();
7676
src/mess/includes/tmc2000e.h
r11283r11284
3333   { }
3434
3535   required_device<cpu_device> m_maincpu;
36   required_device<device_t> m_cti;
36   required_device<cdp1864_device> m_cti;
3737   required_device<device_t> m_cassette;
3838
3939   virtual void machine_start();
src/mess/includes/tmc1800.h
r11283r11284
9393   { }
9494
9595   required_device<cpu_device> m_maincpu;
96   required_device<device_t> m_cti;
96   required_device<cdp1864_device> m_cti;
9797   required_device<device_t> m_cassette;
9898   required_device<device_t> m_ram;
9999
r11283r11284
139139   { }
140140
141141   required_device<cpu_device> m_maincpu;
142   required_device<device_t> m_cti;
142   required_device<cdp1864_device> m_cti;
143143   required_device<device_t> m_cassette;
144144   required_device<device_t> m_ram;
145145
src/mess/includes/cosmicos.h
r11283r11284
5454   { }
5555
5656   required_device<cosmac_device> m_maincpu;
57   required_device<device_t> m_cti;
57   required_device<cdp1864_device> m_cti;
5858   required_device<dm9368_device> m_led;
5959   required_device<device_t> m_cassette;
6060   required_device<device_t> m_speaker;
src/mess/drivers/eti660.c
r11283r11284
4848ADDRESS_MAP_END
4949
5050static ADDRESS_MAP_START( eti660_io_map, AS_IO, 8, eti660_state )
51   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE_LEGACY(CDP1864_TAG, cdp1864_dispon_r, cdp1864_step_bgcolor_w)
51   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(CDP1864_TAG, cdp1864_device, dispon_r, step_bgcolor_w)
5252   AM_RANGE(0x02, 0x02) AM_READWRITE(pia_r, pia_w)
5353   AM_RANGE(0x03, 0x03) AM_WRITE(colorram_w)
54   AM_RANGE(0x04, 0x04) AM_DEVREADWRITE_LEGACY(CDP1864_TAG, cdp1864_dispoff_r, cdp1864_tone_latch_w)
54   AM_RANGE(0x04, 0x04) AM_DEVREADWRITE(CDP1864_TAG, cdp1864_device, dispoff_r, tone_latch_w)
5555ADDRESS_MAP_END
5656
5757/* Input Ports */
r11283r11284
114114   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
115115   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT),
116116   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1),
117   DEVCB_NULL,
117118   RES_K(2.2), /* R7 */
118119   RES_K(1),   /* R5 */
119120   RES_K(4.7), /* R6 */
r11283r11284
122123
123124bool eti660_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
124125{
125   cdp1864_update(m_cti, &bitmap, &cliprect);
126   m_cti->update_screen(&bitmap, &cliprect);
126127
127128   return 0;
128129}
r11283r11284
147148WRITE_LINE_MEMBER( eti660_state::q_w )
148149{
149150   /* CDP1864 audio output enable */
150   cdp1864_aoe_w(m_cti, state);
151   m_cti->aoe_w(state);
151152
152153   /* PULSE led */
153154   set_led_status(machine(), LED_PULSE, state);
r11283r11284
162163
163164   m_color = m_color_ram[colorram_offset];
164165
165   cdp1864_con_w(m_cti, 0); // HACK
166   cdp1864_dma_w(m_cti, offset, data);
166   m_cti->con_w(0); // HACK
167   m_cti->dma_w(space, offset, data);
167168}
168169
169170static COSMAC_INTERFACE( eti660_config )
src/mess/drivers/studio2.c
r11283r11284
250250ADDRESS_MAP_END
251251
252252static ADDRESS_MAP_START( mpt02_io_map, AS_IO, 8, mpt02_state )
253   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE_LEGACY(CDP1864_TAG, cdp1864_dispon_r, cdp1864_step_bgcolor_w)
253   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(CDP1864_TAG, cdp1864_device, dispon_r, step_bgcolor_w)
254254   AM_RANGE(0x02, 0x02) AM_WRITE_BASE(studio2_state, keylatch_w)
255   AM_RANGE(0x04, 0x04) AM_DEVREADWRITE_LEGACY(CDP1864_TAG, cdp1864_dispoff_r, cdp1864_tone_latch_w)
255   AM_RANGE(0x04, 0x04) AM_DEVREADWRITE(CDP1864_TAG, cdp1864_device, dispoff_r, tone_latch_w)
256256ADDRESS_MAP_END
257257
258258/* Input Ports */
r11283r11284
348348   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
349349   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT),
350350   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1),
351   DEVCB_NULL,
351352   RES_K(2.2),   // unverified
352353   RES_K(1),   // unverified
353354   RES_K(5.1),   // unverified
r11283r11284
356357
357358bool mpt02_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
358359{
359   cdp1864_update(m_cti, &bitmap, &cliprect);
360   m_cti->update_screen(&bitmap, &cliprect);
360361
361362   return 0;
362363}
r11283r11284
405406
406407   m_color = m_color_ram[addr];
407408
408   cdp1864_con_w(m_cti, 0); // HACK
409   cdp1864_dma_w(m_cti, offset, data);
409   m_cti->con_w(0); // HACK
410   m_cti->dma_w(space, offset, data);
410411}
411412
412413static COSMAC_INTERFACE( mpt02_cosmac_intf )
src/mess/drivers/tmc1800.c
r11283r11284
214214   m_rac = BIT(data, 0);
215215   bankswitch();
216216
217   cdp1864_tone_latch_w(m_cti, 0, data);
217   m_cti->tone_latch_w(space, 0, data);
218218}
219219
220220WRITE8_MEMBER( nano_state::bankswitch_w )
r11283r11284
225225   program->install_ram(0x0000, 0x0fff, 0, 0x7000, ram);
226226
227227   /* write to CDP1864 tone latch */
228   cdp1864_tone_latch_w(m_cti, 0, data);
228   m_cti->tone_latch_w(space, 0, data);
229229}
230230
231231READ8_MEMBER( tmc1800_state::dispon_r )
r11283r11284
277277
278278static ADDRESS_MAP_START( tmc2000_io_map, AS_IO, 8, tmc2000_state )
279279   ADDRESS_MAP_UNMAP_HIGH
280   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE_LEGACY(CDP1864_TAG, cdp1864_dispon_r, cdp1864_step_bgcolor_w)
280   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(CDP1864_TAG, cdp1864_device, dispon_r, step_bgcolor_w)
281281   AM_RANGE(0x02, 0x02) AM_WRITE(keylatch_w)
282   AM_RANGE(0x04, 0x04) AM_DEVREAD_LEGACY(CDP1864_TAG, cdp1864_dispoff_r) AM_WRITE(bankswitch_w)
282   AM_RANGE(0x04, 0x04) AM_DEVREAD(CDP1864_TAG, cdp1864_device, dispoff_r) AM_WRITE(bankswitch_w)
283283ADDRESS_MAP_END
284284
285285// OSCOM Nano
r11283r11284
290290ADDRESS_MAP_END
291291
292292static ADDRESS_MAP_START( nano_io_map, AS_IO, 8, nano_state )
293   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE_LEGACY(CDP1864_TAG, cdp1864_dispon_r, cdp1864_step_bgcolor_w)
293   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(CDP1864_TAG, cdp1864_device, dispon_r, step_bgcolor_w)
294294   AM_RANGE(0x02, 0x02) AM_WRITE(keylatch_w)
295   AM_RANGE(0x04, 0x04) AM_DEVREAD_LEGACY(CDP1864_TAG, cdp1864_dispoff_r) AM_WRITE(bankswitch_w)
295   AM_RANGE(0x04, 0x04) AM_DEVREAD(CDP1864_TAG, cdp1864_device, dispoff_r) AM_WRITE(bankswitch_w)
296296ADDRESS_MAP_END
297297
298298/* Input Ports */
r11283r11284
583583WRITE_LINE_MEMBER( tmc2000_state::q_w )
584584{
585585   /* CDP1864 audio output enable */
586   cdp1864_aoe_w(m_cti, state);
586   m_cti->aoe_w(state);
587587
588588   /* set Q led status */
589589   set_led_status(machine(), 1, state);
r11283r11284
596596{
597597   m_color = ~(m_colorram[offset & 0x1ff]) & 0x07;
598598
599   cdp1864_con_w(m_cti, 0); // HACK
600   cdp1864_dma_w(m_cti, offset, data);
599   m_cti->con_w(0); // HACK
600   m_cti->dma_w(space, offset, data);
601601}
602602
603603static COSMAC_INTERFACE( tmc2000_config )
r11283r11284
647647WRITE_LINE_MEMBER( nano_state::q_w )
648648{
649649   /* CDP1864 audio output enable */
650   cdp1864_aoe_w(m_cti, state);
650   m_cti->aoe_w(state);
651651
652652   /* set Q led status */
653653   set_led_status(machine(), 1, state);
r11283r11284
666666   DEVCB_NULL,
667667   DEVCB_DRIVER_LINE_MEMBER(nano_state, q_w),
668668   DEVCB_NULL,
669   DEVCB_DEVICE_HANDLER(CDP1864_TAG, cdp1864_dma_w),
669   DEVCB_DEVICE_MEMBER(CDP1864_TAG, cdp1864_device, dma_w),
670670   NULL,
671671   DEVCB_NULL,
672672   DEVCB_NULL
src/mess/drivers/tmc2000e.c
r11283r11284
8383ADDRESS_MAP_END
8484
8585static ADDRESS_MAP_START( tmc2000e_io_map, AS_IO, 8, tmc2000e_state )
86   AM_RANGE(0x01, 0x01) AM_DEVWRITE_LEGACY(CDP1864_TAG, cdp1864_tone_latch_w)
87   AM_RANGE(0x02, 0x02) AM_DEVWRITE_LEGACY(CDP1864_TAG, cdp1864_step_bgcolor_w)
86   AM_RANGE(0x01, 0x01) AM_DEVWRITE(CDP1864_TAG, cdp1864_device, tone_latch_w)
87   AM_RANGE(0x02, 0x02) AM_DEVWRITE(CDP1864_TAG, cdp1864_device, step_bgcolor_w)
8888   AM_RANGE(0x03, 0x03) AM_READWRITE(ascii_keyboard_r, keyboard_latch_w)
8989   AM_RANGE(0x04, 0x04) AM_READWRITE(io_r, io_w)
9090   AM_RANGE(0x05, 0x05) AM_READWRITE(vismac_r, vismac_w)
r11283r11284
141141   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
142142   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT),
143143   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1),
144   DEVCB_NULL,
144145   RES_K(2.2),   // unverified
145146   RES_K(1),   // unverified
146147   RES_K(5.1),   // unverified
r11283r11284
149150
150151bool tmc2000e_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
151152{
152   cdp1864_update(m_cti, &bitmap, &cliprect);
153   m_cti->update_screen(&bitmap, &cliprect);
153154
154155   return 0;
155156}
r11283r11284
177178WRITE_LINE_MEMBER( tmc2000e_state::q_w )
178179{
179180   // turn CDP1864 sound generator on/off
181   m_cti->aoe_w(state);
180182
181   cdp1864_aoe_w(m_cti, state);
182
183183   // set Q led status
184
185184   set_led_status(machine(), 1, state);
186185
187186   // tape out
188
189187   cassette_output(m_cassette, state ? -1.0 : +1.0);
190188
191189   // floppy control (FDC-6)
r11283r11284
195193{
196194   m_color = (m_colorram[offset & 0x3ff]) & 0x07; // 0x04 = R, 0x02 = B, 0x01 = G
197195
198   cdp1864_con_w(m_cti, 0); // HACK
199   cdp1864_dma_w(m_cti, offset, data);
196   m_cti->con_w(0); // HACK
197   m_cti->dma_w(space, offset, data);
200198}
201199
202200static COSMAC_INTERFACE( tmc2000e_config )
src/mess/drivers/cosmicos.c
r11283r11284
5151
5252   if (!m_q)
5353   {
54      data = cdp1864_dispoff_r(m_cti, 0);
54      data = m_cti->dispoff_r(space, 0);
5555   }
5656
5757   return data;
r11283r11284
6363
6464   if (!m_q)
6565   {
66      data = cdp1864_dispon_r(m_cti, 0);
66      data = m_cti->dispon_r(space, 0);
6767   }
6868
6969   return data;
r11283r11284
7373{
7474   if (m_q)
7575   {
76      cdp1864_tone_latch_w(m_cti, 0, data);
76      m_cti->tone_latch_w(space, 0, data);
7777   }
7878}
7979
r11283r11284
387387   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
388388   DEVCB_DRIVER_LINE_MEMBER(cosmicos_state, dmaout_w),
389389   DEVCB_DRIVER_LINE_MEMBER(cosmicos_state, efx_w),
390   DEVCB_NULL,
390391   RES_K(2), // R2
391392   0, // not connected
392393   0, // not connected
r11283r11284
395396
396397bool cosmicos_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
397398{
398   cdp1864_update(m_cti, &bitmap, &cliprect);
399   m_cti->update_screen(&bitmap, &cliprect);
399400
400401   return 0;
401402}
r11283r11284
470471   if (state) m_boot = 0;
471472
472473   /* CDP1864 audio enable */
473   cdp1864_aoe_w(m_cti, state);
474   m_cti->aoe_w(state);
474475
475476   m_q = state;
476477}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team