Previous 15994 Revisions Next

r5706 Saturday 12th September, 2009 at 10:41:33 UTC by Curt Coder
RCA video chip cleanup.
[src/emu/sound]cdp1864.c* cdp1864.h* cdp1869.h sound.mak
[src/mess]mess.mak
[src/mess/drivers]elf.c studio2.c tmc1800.c tmc2000e.c vip.c
[src/mess/includes]studio2.h tmc1800.h tmc2000e.h vip.h
[src/mess/video]cdp1861.c cdp1861.h cdp1862.c cdp1862.h cdp1864.c cdp1864.h tmc1800.c

src/emu/sound/cdp1869.h
r5705r5706
9292   MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_CDP1869) \
9393   MDRV_DEVICE_CONFIG(_config)
9494
95#define CDP1869_INTERFACE(_name) const cdp1869_interface (_name) =
95#define CDP1869_INTERFACE(_name) \
96   const cdp1869_interface (_name) =
9697
9798#define CDP1869_CHAR_RAM_READ(name) UINT8 name(const device_config *device, UINT16 pma, UINT8 cma)
9899#define CDP1869_CHAR_RAM_WRITE(name) void name(const device_config *device, UINT16 pma, UINT8 cma, UINT8 data)
src/emu/sound/cdp1864.c
r0r5706
1/**********************************************************************
2 
3    RCA CDP1864C COS/MOS PAL Compatible Color TV Interface
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10/*
11 
12    TODO:
13 
14   - interlace mode
15   - PAL output, currently using RGB
16   - cpu synchronization
17 
18      SC1 and SC0 are used to provide CDP1864C-to-CPU synchronization for a jitter-free display.
19      During every horizontal sync the CDP1864C samples SC0 and SC1 for SC0 = 1 and SC1 = 0
20      (CDP1800 execute state). Detection of a fetch cycle causes the CDP1864C to skip cycles to
21      attain synchronization. (i.e. picture moves 8 pixels to the right)
22 
23*/
24 
25#include "driver.h"
26#include "cdp1864.h"
27#include "sndintrf.h"
28#include "streams.h"
29#include "cpu/cdp1802/cdp1802.h"
30 
31/***************************************************************************
32    PARAMETERS
33***************************************************************************/
34 
35#define CDP1864_DEFAULT_LATCH      0x35
36 
37#define CDP1864_CYCLES_DMA_START   2*8
38#define CDP1864_CYCLES_DMA_ACTIVE   8*8
39#define CDP1864_CYCLES_DMA_WAIT      6*8
40 
41static const int CDP1864_BACKGROUND_COLOR_SEQUENCE[] = { 2, 0, 1, 4 };
42 
43/***************************************************************************
44    TYPE DEFINITIONS
45***************************************************************************/
46 
47typedef struct _cdp1864_t cdp1864_t;
48struct _cdp1864_t
49{
50   devcb_resolved_read_line      in_rdata_func;
51   devcb_resolved_read_line      in_bdata_func;
52   devcb_resolved_read_line      in_gdata_func;
53   devcb_resolved_write_line      out_int_func;
54   devcb_resolved_write_line      out_dmao_func;
55   devcb_resolved_write_line      out_efx_func;
56 
57   const device_config *screen;   /* screen */
58   bitmap_t *bitmap;            /* bitmap */
59   sound_stream *stream;         /* sound output */
60 
61   /* video state */
62   int disp;                  /* display on */
63   int dmaout;                  /* DMA request active */
64   int bgcolor;               /* background color */
65   int con;                  /* color on */
66 
67   /* sound state */
68   int aoe;                  /* audio on */
69   int latch;                  /* sound latch */
70   INT16 signal;               /* current signal */
71   int incr;                  /* initial wave state */
72 
73   /* timers */
74   emu_timer *int_timer;         /* interrupt timer */
75   emu_timer *efx_timer;         /* EFx timer */
76   emu_timer *dma_timer;         /* DMA timer */
77 
78   const device_config *cpu;
79};
80 
81/***************************************************************************
82    INLINE FUNCTIONS
83***************************************************************************/
84 
85INLINE cdp1864_t *get_safe_token(const device_config *device)
86{
87   assert(device != NULL);
88   assert(device->token != NULL);
89   return (cdp1864_t *)device->token;
90}
91 
92/***************************************************************************
93    IMPLEMENTATION
94***************************************************************************/
95 
96/*-------------------------------------------------
97    TIMER_CALLBACK( cdp1864_int_tick )
98-------------------------------------------------*/
99 
100static TIMER_CALLBACK( cdp1864_int_tick )
101{
102   const device_config *device = ptr;
103   cdp1864_t *cdp1864 = get_safe_token(device);
104 
105   int scanline = video_screen_get_vpos(cdp1864->screen);
106 
107   if (scanline == CDP1864_SCANLINE_INT_START)
108   {
109      if (cdp1864->disp)
110      {
111         devcb_call_write_line(&cdp1864->out_int_func, ASSERT_LINE);
112      }
113 
114      timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_END, 0), 0);
115   }
116   else
117   {
118      if (cdp1864->disp)
119      {
120         devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
121      }
122 
123      timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_START, 0), 0);
124   }
125}
126 
127/*-------------------------------------------------
128    TIMER_CALLBACK( cdp1864_efx_tick )
129-------------------------------------------------*/
130 
131static TIMER_CALLBACK( cdp1864_efx_tick )
132{
133   const device_config *device = ptr;
134   cdp1864_t *cdp1864 = get_safe_token(device);
135 
136   int scanline = video_screen_get_vpos(cdp1864->screen);
137 
138   switch (scanline)
139   {
140   case CDP1864_SCANLINE_EFX_TOP_START:
141      devcb_call_write_line(&cdp1864->out_efx_func, ASSERT_LINE);
142      timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_END, 0), 0);
143      break;
144 
145   case CDP1864_SCANLINE_EFX_TOP_END:
146      devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
147      timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_BOTTOM_START, 0), 0);
148      break;
149 
150   case CDP1864_SCANLINE_EFX_BOTTOM_START:
151      devcb_call_write_line(&cdp1864->out_efx_func, ASSERT_LINE);
152      timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_BOTTOM_END, 0), 0);
153      break;
154 
155   case CDP1864_SCANLINE_EFX_BOTTOM_END:
156      devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
157      timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0);
158      break;
159   }
160}
161 
162/*-------------------------------------------------
163    TIMER_CALLBACK( cdp1864_dma_tick )
164-------------------------------------------------*/
165 
166static TIMER_CALLBACK( cdp1864_dma_tick )
167{
168   const device_config *device = ptr;
169   cdp1864_t *cdp1864 = get_safe_token(device);
170 
171   int scanline = video_screen_get_vpos(cdp1864->screen);
172 
173   if (cdp1864->dmaout)
174   {
175      if (cdp1864->disp)
176      {
177         if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END)
178         {
179            devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
180         }
181      }
182 
183      timer_adjust_oneshot(cdp1864->dma_timer, cpu_clocks_to_attotime(machine->firstcpu, CDP1864_CYCLES_DMA_WAIT), 0);
184 
185      cdp1864->dmaout = 0;
186   }
187   else
188   {
189      if (cdp1864->disp)
190      {
191         if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END)
192         {
193            devcb_call_write_line(&cdp1864->out_dmao_func, ASSERT_LINE);
194         }
195      }
196 
197      timer_adjust_oneshot(cdp1864->dma_timer, cpu_clocks_to_attotime(machine->firstcpu, CDP1864_CYCLES_DMA_ACTIVE), 0);
198 
199      cdp1864->dmaout = 1;
200   }
201}
202 
203/*-------------------------------------------------
204    cdp1864_init_palette - initialize palette
205-------------------------------------------------*/
206 
207static void cdp1864_init_palette(const device_config *device, const cdp1864_interface *intf)
208{
209   int i;
210 
211   double res_total = intf->res_r + intf->res_g + intf->res_b + intf->res_bkg;
212 
213   int weight_r = (intf->res_r / res_total) * 100;
214   int weight_g = (intf->res_g / res_total) * 100;
215   int weight_b = (intf->res_b / res_total) * 100;
216   int weight_bkg = (intf->res_bkg / res_total) * 100;
217 
218   for (i = 0; i < 16; i++)
219   {
220      int r, g, b, luma = 0;
221 
222      luma += (i & 4) ? weight_r : 0;
223      luma += (i & 1) ? weight_g : 0;
224      luma += (i & 2) ? weight_b : 0;
225      luma += (i & 8) ? 0 : weight_bkg;
226 
227      luma = (luma * 0xff) / 100;
228 
229      r = (i & 4) ? luma : 0;
230      g = (i & 1) ? luma : 0;
231      b = (i & 2) ? luma : 0;
232 
233      palette_set_color_rgb( device->machine, i, r, g, b );
234   }
235}
236 
237/*-------------------------------------------------
238    cdp1864_aoe_w - audio output enable
239-------------------------------------------------*/
240 
241WRITE_LINE_DEVICE_HANDLER( cdp1864_aoe_w )
242{
243   cdp1864_t *cdp1864 = get_safe_token(device);
244 
245   if (!state)
246   {
247      cdp1864->latch = CDP1864_DEFAULT_LATCH;
248   }
249 
250   cdp1864->aoe = state;
251}
252 
253/*-------------------------------------------------
254    cdp1864_dispon_r - turn display on
255-------------------------------------------------*/
256 
257READ8_DEVICE_HANDLER( cdp1864_dispon_r )
258{
259   cdp1864_t *cdp1864 = get_safe_token(device);
260 
261   cdp1864->disp = 1;
262 
263   return 0xff;
264}
265 
266/*-------------------------------------------------
267    cdp1864_dispoff_r - turn display off
268-------------------------------------------------*/
269 
270READ8_DEVICE_HANDLER( cdp1864_dispoff_r )
271{
272   cdp1864_t *cdp1864 = get_safe_token(device);
273 
274   cdp1864->disp = 0;
275 
276   devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
277   devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
278 
279   return 0xff;
280}
281 
282/*-------------------------------------------------
283    cdp1864_step_bgcolor_w - step background color
284-------------------------------------------------*/
285 
286WRITE8_DEVICE_HANDLER( cdp1864_step_bgcolor_w )
287{
288   cdp1864_t *cdp1864 = get_safe_token(device);
289 
290   cdp1864->disp = 1;
291 
292   if (++cdp1864->bgcolor > 3) cdp1864->bgcolor = 0;
293}
294 
295/*-------------------------------------------------
296    cdp1864_con_w - color on write
297-------------------------------------------------*/
298 
299WRITE_LINE_DEVICE_HANDLER( cdp1864_con_w )
300{
301   cdp1864_t *cdp1864 = get_safe_token(device);
302 
303   if (!state)
304   {
305      cdp1864->con = 0;
306   }
307}
308 
309/*-------------------------------------------------
310    cdp1864_tone_latch_w - load tone latch
311-------------------------------------------------*/
312 
313WRITE8_DEVICE_HANDLER( cdp1864_tone_latch_w )
314{
315   cdp1864_t *cdp1864 = get_safe_token(device);
316 
317   cdp1864->latch = data;
318}
319 
320/*-------------------------------------------------
321    cdp1864_dma_w - write DMA byte
322-------------------------------------------------*/
323 
324WRITE8_DEVICE_HANDLER( cdp1864_dma_w )
325{
326   cdp1864_t *cdp1864 = get_safe_token(device);
327 
328   int rdata = 1, bdata = 1, gdata = 1;
329   int sx = video_screen_get_hpos(cdp1864->screen) + 4;
330   int y = video_screen_get_vpos(cdp1864->screen);
331   int x;
332 
333   if (!cdp1864->con)
334   {
335      rdata = devcb_call_read_line(&cdp1864->in_rdata_func);
336      bdata = devcb_call_read_line(&cdp1864->in_bdata_func);
337      gdata = devcb_call_read_line(&cdp1864->in_gdata_func);
338   }
339 
340   for (x = 0; x < 8; x++)
341   {
342      int color = CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8;
343 
344      if (BIT(data, 7))
345      {
346         color = (gdata << 2) | (bdata << 1) | rdata;
347      }
348 
349      *BITMAP_ADDR16(cdp1864->bitmap, y, sx + x) = color;
350 
351      data <<= 1;
352   }
353}
354 
355/*-------------------------------------------------
356    STREAM_UPDATE( cdp1864_stream_update )
357-------------------------------------------------*/
358 
359static STREAM_UPDATE( cdp1864_stream_update )
360{
361   cdp1864_t *cdp1864 = get_safe_token(device);
362 
363   INT16 signal = cdp1864->signal;
364   stream_sample_t *buffer = outputs[0];
365 
366   memset( buffer, 0, samples * sizeof(*buffer) );
367 
368   if (cdp1864->aoe)
369   {
370      double frequency = cpu_get_clock(cdp1864->cpu) / 8 / 4 / (cdp1864->latch + 1) / 2;
371      int rate = device->machine->sample_rate / 2;
372 
373      /* get progress through wave */
374      int incr = cdp1864->incr;
375 
376      if (signal < 0)
377      {
378         signal = -0x7fff;
379      }
380      else
381      {
382         signal = 0x7fff;
383      }
384 
385      while( samples-- > 0 )
386      {
387         *buffer++ = signal;
388         incr -= frequency;
389         while( incr < 0 )
390         {
391            incr += rate;
392            signal = -signal;
393         }
394      }
395 
396      /* store progress through wave */
397      cdp1864->incr = incr;
398      cdp1864->signal = signal;
399   }
400}
401 
402/*-------------------------------------------------
403    cdp1864_update - update screen
404-------------------------------------------------*/
405 
406void cdp1864_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
407{
408   cdp1864_t *cdp1864 = get_safe_token(device);
409 
410   if (cdp1864->disp)
411   {
412      copybitmap(bitmap, cdp1864->bitmap, 0, 0, 0, 0, cliprect);
413      bitmap_fill(cdp1864->bitmap, cliprect, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8);
414   }
415   else
416   {
417      bitmap_fill(bitmap, cliprect, get_black_pen(device->machine));
418   }
419}
420 
421/*-------------------------------------------------
422    DEVICE_START( cdp1864 )
423-------------------------------------------------*/
424 
425static DEVICE_START( cdp1864 )
426{
427   cdp1864_t *cdp1864 = get_safe_token(device);
428   const cdp1864_interface *intf = (const cdp1864_interface *) device->static_config;
429 
430   /* resolve callbacks */
431   devcb_resolve_read_line(&cdp1864->in_rdata_func, &intf->in_rdata_func, device);
432   devcb_resolve_read_line(&cdp1864->in_bdata_func, &intf->in_bdata_func, device);
433   devcb_resolve_read_line(&cdp1864->in_gdata_func, &intf->in_gdata_func, device);
434   devcb_resolve_write_line(&cdp1864->out_int_func, &intf->out_int_func, device);
435   devcb_resolve_write_line(&cdp1864->out_dmao_func, &intf->out_dmao_func, device);
436   devcb_resolve_write_line(&cdp1864->out_efx_func, &intf->out_efx_func, device);
437 
438   /* get the cpu */
439   cdp1864->cpu = cputag_get_cpu(device->machine, intf->cpu_tag);
440 
441   /* get the screen device */
442   cdp1864->screen = devtag_get_device(device->machine, intf->screen_tag);
443   assert(cdp1864->screen != NULL);
444 
445   /* allocate the temporary bitmap */
446   cdp1864->bitmap = auto_bitmap_alloc(device->machine, video_screen_get_width(cdp1864->screen), video_screen_get_height(cdp1864->screen), video_screen_get_format(cdp1864->screen));
447   bitmap_fill(cdp1864->bitmap, 0, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8);
448 
449   /* initialize the palette */
450   cdp1864_init_palette(device, intf);
451 
452   /* create sound stream */
453   cdp1864->stream = stream_create(device, 0, 1, device->machine->sample_rate, cdp1864, cdp1864_stream_update);
454 
455   /* create the timers */
456   cdp1864->int_timer = timer_alloc(device->machine, cdp1864_int_tick, (void *)device);
457   cdp1864->efx_timer = timer_alloc(device->machine, cdp1864_efx_tick, (void *)device);
458   cdp1864->dma_timer = timer_alloc(device->machine, cdp1864_dma_tick, (void *)device);
459 
460   /* register for state saving */
461   state_save_register_device_item(device, 0, cdp1864->disp);
462   state_save_register_device_item(device, 0, cdp1864->dmaout);
463   state_save_register_device_item(device, 0, cdp1864->bgcolor);
464   state_save_register_device_item(device, 0, cdp1864->con);
465 
466   state_save_register_device_item(device, 0, cdp1864->aoe);
467   state_save_register_device_item(device, 0, cdp1864->latch);
468   state_save_register_device_item(device, 0, cdp1864->signal);
469   state_save_register_device_item(device, 0, cdp1864->incr);
470 
471   state_save_register_bitmap(device->machine, "cdp1864", device->tag, 0, "cdp1864->bitmap", cdp1864->bitmap);
472}
473 
474/*-------------------------------------------------
475    DEVICE_RESET( cdp1864 )
476-------------------------------------------------*/
477 
478static DEVICE_RESET( cdp1864 )
479{
480   cdp1864_t *cdp1864 = get_safe_token(device);
481 
482   timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_START, 0), 0);
483   timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0);
484   timer_adjust_oneshot(cdp1864->dma_timer, cpu_clocks_to_attotime(device->machine->firstcpu, CDP1864_CYCLES_DMA_START), 0);
485 
486   cdp1864->disp = 0;
487   cdp1864->dmaout = 0;
488   cdp1864->bgcolor = 0;
489   cdp1864->con = 1;
490 
491   devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
492   devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
493   devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
494 
495   cdp1864_aoe_w(device, 0);
496}
497 
498/*-------------------------------------------------
499    DEVICE_GET_INFO( cdp1864 )
500-------------------------------------------------*/
501 
502DEVICE_GET_INFO( cdp1864 )
503{
504   switch (state)
505   {
506      /* --- the following bits of info are returned as 64-bit signed integers --- */
507      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cdp1864_t);                  break;
508      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                              break;
509      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;               break;
510 
511      /* --- the following bits of info are returned as pointers to data or functions --- */
512      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cdp1864);         break;
513      case DEVINFO_FCT_STOP:                     /* Nothing */                              break;
514      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(cdp1864);         break;
515 
516      /* --- the following bits of info are returned as NULL-terminated strings --- */
517      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA CDP1864");                  break;
518      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA CDP1800");                  break;
519      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                        break;
520      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
521      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");            break;
522   }
523}
src/emu/sound/cdp1864.h
r0r5706
1/**********************************************************************
2 
3    RCA CDP1864C COS/MOS PAL Compatible Color TV Interface
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************
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
30 
31 
32         http://homepage.mac.com/ruske/cosmacelf/cdp1864.pdf
33 
34**********************************************************************/
35 
36#ifndef __CDP1864__
37#define __CDP1864__
38 
39#include "devcb.h"
40 
41/***************************************************************************
42    PARAMETERS
43***************************************************************************/
44 
45#define CDP1864_CLOCK   XTAL_1_75MHz
46 
47#define CDP1864_VISIBLE_COLUMNS   64
48#define CDP1864_VISIBLE_LINES   192
49 
50#define CDP1864_HBLANK_END       1 * 8
51#define CDP1864_HBLANK_START   13 * 8
52#define CDP1864_HSYNC_START       0 * 8
53#define CDP1864_HSYNC_END       1 * 8
54#define CDP1864_SCREEN_START    4 * 8
55#define CDP1864_SCREEN_END      12 * 8
56#define CDP1864_SCREEN_WIDTH   14 * 8
57 
58#define CDP1864_TOTAL_SCANLINES            312
59 
60#define CDP1864_SCANLINE_VBLANK_START      CDP1864_TOTAL_SCANLINES - 4
61#define CDP1864_SCANLINE_VBLANK_END         20
62#define CDP1864_SCANLINE_VSYNC_START      0
63#define CDP1864_SCANLINE_VSYNC_END         4
64#define CDP1864_SCANLINE_DISPLAY_START      60 // ???
65#define CDP1864_SCANLINE_DISPLAY_END      CDP1864_SCANLINE_DISPLAY_START + CDP1864_VISIBLE_LINES
66#define CDP1864_SCANLINE_INT_START         CDP1864_SCANLINE_DISPLAY_START - 2
67#define CDP1864_SCANLINE_INT_END         CDP1864_SCANLINE_DISPLAY_START
68#define CDP1864_SCANLINE_EFX_TOP_START      CDP1864_SCANLINE_DISPLAY_START - 4
69#define CDP1864_SCANLINE_EFX_TOP_END      CDP1864_SCANLINE_DISPLAY_START
70#define CDP1864_SCANLINE_EFX_BOTTOM_START   CDP1864_SCANLINE_DISPLAY_END - 4
71#define CDP1864_SCANLINE_EFX_BOTTOM_END      CDP1864_SCANLINE_DISPLAY_END
72 
73/***************************************************************************
74    MACROS / CONSTANTS
75***************************************************************************/
76 
77#define CDP1864      DEVICE_GET_INFO_NAME(cdp1864)
78#define SOUND_CDP1864 CDP1864
79 
80#define MDRV_CDP1864_ADD(_tag, _clock, _config) \
81   MDRV_DEVICE_ADD(_tag, SOUND, _clock) \
82   MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_CDP1864) \
83   MDRV_DEVICE_CONFIG(_config)
84 
85#define CDP1864_INTERFACE(name) \
86   const cdp1864_interface (name) =
87 
88/***************************************************************************
89    TYPE DEFINITIONS
90***************************************************************************/
91 
92typedef enum _cdp1864_format cdp1864_format;
93enum _cdp1864_format {
94   CDP1864_NON_INTERLACED = 0,
95   CDP1864_INTERLACED
96};
97 
98typedef struct _cdp1864_interface cdp1864_interface;
99struct _cdp1864_interface
100{
101   const char *cpu_tag;      /* cpu we are working with */
102   const char *screen_tag;      /* screen we are acting on */
103 
104   cdp1864_format interlace;   /* interlace */
105 
106   devcb_read_line            in_rdata_func;
107   devcb_read_line            in_bdata_func;
108   devcb_read_line            in_gdata_func;
109 
110   /* this gets called for every change of the INT pin (pin 36) */
111   devcb_write_line         out_int_func;
112 
113   /* this gets called for every change of the DMAO pin (pin 37) */
114   devcb_write_line         out_dmao_func;
115 
116   /* this gets called for every change of the EFX pin (pin 18) */
117   devcb_write_line         out_efx_func;
118 
119   double res_r;            /* red output resistor value */
120   double res_g;            /* green output resistor value */
121   double res_b;            /* blue output resistor value */
122   double res_bkg;            /* background output resistor value */
123};
124 
125/***************************************************************************
126    PROTOTYPES
127***************************************************************************/
128 
129/* device interface */
130DEVICE_GET_INFO( cdp1864 );
131 
132/* display on (0x69) */
133READ8_DEVICE_HANDLER( cdp1864_dispon_r ) ATTR_NONNULL(1);
134 
135/* display off (0x6c) */
136READ8_DEVICE_HANDLER( cdp1864_dispoff_r ) ATTR_NONNULL(1);
137 
138/* step background color (0x61) */
139WRITE8_DEVICE_HANDLER( cdp1864_step_bgcolor_w ) ATTR_NONNULL(1);
140 
141/* color on */
142WRITE_LINE_DEVICE_HANDLER( cdp1864_con_w ) ATTR_NONNULL(1);
143 
144/* load tone latch (0x64) */
145WRITE8_DEVICE_HANDLER( cdp1864_tone_latch_w ) ATTR_NONNULL(1);
146 
147/* audio output enable */
148WRITE_LINE_DEVICE_HANDLER( cdp1864_aoe_w ) ATTR_NONNULL(1);
149 
150/* DMA write */
151WRITE8_DEVICE_HANDLER( cdp1864_dma_w ) ATTR_NONNULL(1);
152 
153/* screen update */
154void cdp1864_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) ATTR_NONNULL(1) ATTR_NONNULL(2) ATTR_NONNULL(3);
155 
156#endif
src/emu/sound/sound.mak
r5705r5706
206206
207207
208208#-------------------------------------------------
209# RCA CDP1864
210#-------------------------------------------------
211
212SOUNDDEFS += -DHAS_CDP1864=$(if $(filter CDP1864,$(SOUNDS)),1,0)
213
214ifneq ($(filter CDP1864,$(SOUNDS)),)
215SOUNDOBJS += $(SOUNDOBJ)/cdp1864.o
216endif
217
218
219
220#-------------------------------------------------
209221# RCA CDP1869
210222#-------------------------------------------------
211223
src/mess/video/cdp1864.c
r5705r5706
1/*
2
3    TODO:
4
5   - interlace mode
6   - PAL output, currently using RGB
7    - connect to sound system when possible
8   - cpu synchronization
9
10      SC1 and SC0 are used to provide CDP1864C-to-CPU synchronization for a jitter-free display.
11      During every horizontal sync the CDP1864C samples SC0 and SC1 for SC0 = 1 and SC1 = 0
12      (CDP1800 execute state). Detection of a fetch cycle causes the CDP1864C to skip cycles to
13      attain synchronization. (i.e. picture moves 8 pixels to the right)
14
15*/
16
17#include "driver.h"
18#include "sndintrf.h"
19#include "streams.h"
20#include "cpu/cdp1802/cdp1802.h"
21#include "sound/beep.h"
22#include "video/cdp1864.h"
23
24/***************************************************************************
25    PARAMETERS
26***************************************************************************/
27
28#define CDP1864_DEFAULT_LATCH   0x35
29
30#define CDP1864_CYCLES_DMA_START   2*8
31#define CDP1864_CYCLES_DMA_ACTIVE   8*8
32#define CDP1864_CYCLES_DMA_WAIT      6*8
33
34static const int CDP1864_BACKGROUND_COLOR_SEQUENCE[] = { 2, 0, 1, 4 };
35
36/***************************************************************************
37    TYPE DEFINITIONS
38***************************************************************************/
39
40typedef struct _cdp1864_t cdp1864_t;
41struct _cdp1864_t
42{
43   devcb_resolved_write_line   out_int_func;
44   devcb_resolved_write_line   out_dmao_func;
45   devcb_resolved_write_line   out_efx_func;
46
47   const device_config *screen;   /* screen */
48   bitmap_t *bitmap;            /* bitmap */
49   sound_stream *stream;         /* sound output */
50
51   /* video state */
52   int disp;                  /* display on */
53   int dmaout;                  /* DMA request active */
54   int bgcolor;               /* background color */
55
56   /* sound state */
57   int audio;                  /* audio on */
58   int latch;                  /* sound latch */
59   INT16 signal;               /* current signal */
60   int incr;                  /* initial wave state */
61
62   /* timers */
63   emu_timer *int_timer;         /* interrupt timer */
64   emu_timer *efx_timer;         /* EFx timer */
65   emu_timer *dma_timer;         /* DMA timer */
66
67   const device_config *cpu;
68};
69
70/***************************************************************************
71    INLINE FUNCTIONS
72***************************************************************************/
73
74INLINE cdp1864_t *get_safe_token(const device_config *device)
75{
76   assert(device != NULL);
77   assert(device->token != NULL);
78
79   return (cdp1864_t *)device->token;
80}
81
82INLINE const cdp1864_interface *get_interface(const device_config *device)
83{
84   assert(device != NULL);
85   assert((device->type == CDP1864));
86   return (const cdp1864_interface *) device->static_config;
87}
88
89/***************************************************************************
90    IMPLEMENTATION
91***************************************************************************/
92
93/*-------------------------------------------------
94    TIMER_CALLBACK( cdp1864_int_tick )
95-------------------------------------------------*/
96
97static TIMER_CALLBACK( cdp1864_int_tick )
98{
99   const device_config *device = ptr;
100   cdp1864_t *cdp1864 = get_safe_token(device);
101
102   int scanline = video_screen_get_vpos(cdp1864->screen);
103
104   if (scanline == CDP1864_SCANLINE_INT_START)
105   {
106      if (cdp1864->disp)
107      {
108         devcb_call_write_line(&cdp1864->out_int_func, ASSERT_LINE);
109      }
110
111      timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_END, 0), 0);
112   }
113   else
114   {
115      if (cdp1864->disp)
116      {
117         devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
118      }
119
120      timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_START, 0), 0);
121   }
122}
123
124/*-------------------------------------------------
125    TIMER_CALLBACK( cdp1864_efx_tick )
126-------------------------------------------------*/
127
128static TIMER_CALLBACK( cdp1864_efx_tick )
129{
130   const device_config *device = ptr;
131   cdp1864_t *cdp1864 = get_safe_token(device);
132
133   int scanline = video_screen_get_vpos(cdp1864->screen);
134
135   switch (scanline)
136   {
137   case CDP1864_SCANLINE_EFX_TOP_START:
138      devcb_call_write_line(&cdp1864->out_efx_func, ASSERT_LINE);
139      timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_END, 0), 0);
140      break;
141
142   case CDP1864_SCANLINE_EFX_TOP_END:
143      devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
144      timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_BOTTOM_START, 0), 0);
145      break;
146
147   case CDP1864_SCANLINE_EFX_BOTTOM_START:
148      devcb_call_write_line(&cdp1864->out_efx_func, ASSERT_LINE);
149      timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_BOTTOM_END, 0), 0);
150      break;
151
152   case CDP1864_SCANLINE_EFX_BOTTOM_END:
153      devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
154      timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0);
155      break;
156   }
157}
158
159/*-------------------------------------------------
160    TIMER_CALLBACK( cdp1864_dma_tick )
161-------------------------------------------------*/
162
163static TIMER_CALLBACK( cdp1864_dma_tick )
164{
165   const device_config *device = ptr;
166   cdp1864_t *cdp1864 = get_safe_token(device);
167
168   int scanline = video_screen_get_vpos(cdp1864->screen);
169
170   if (cdp1864->dmaout)
171   {
172      if (cdp1864->disp)
173      {
174         if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END)
175         {
176            devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
177         }
178      }
179
180      timer_adjust_oneshot(cdp1864->dma_timer, cpu_clocks_to_attotime(machine->firstcpu, CDP1864_CYCLES_DMA_WAIT), 0);
181
182      cdp1864->dmaout = 0;
183   }
184   else
185   {
186      if (cdp1864->disp)
187      {
188         if (scanline >= CDP1864_SCANLINE_DISPLAY_START && scanline < CDP1864_SCANLINE_DISPLAY_END)
189         {
190            devcb_call_write_line(&cdp1864->out_dmao_func, ASSERT_LINE);
191         }
192      }
193
194      timer_adjust_oneshot(cdp1864->dma_timer, cpu_clocks_to_attotime(machine->firstcpu, CDP1864_CYCLES_DMA_ACTIVE), 0);
195
196      cdp1864->dmaout = 1;
197   }
198}
199
200/*-------------------------------------------------
201    cdp1864_init_palette - initialize palette
202-------------------------------------------------*/
203
204static void cdp1864_init_palette(const device_config *device, const cdp1864_interface *intf)
205{
206   int i;
207
208   double res_total = intf->res_r + intf->res_g + intf->res_b + intf->res_bkg;
209
210   int weight_r = (intf->res_r / res_total) * 100;
211   int weight_g = (intf->res_g / res_total) * 100;
212   int weight_b = (intf->res_b / res_total) * 100;
213   int weight_bkg = (intf->res_bkg / res_total) * 100;
214
215   for (i = 0; i < 16; i++)
216   {
217      int r, g, b, luma = 0;
218
219      luma += (i & 4) ? weight_r : 0;
220      luma += (i & 1) ? weight_g : 0;
221      luma += (i & 2) ? weight_b : 0;
222      luma += (i & 8) ? 0 : weight_bkg;
223
224      luma = (luma * 0xff) / 100;
225
226      r = (i & 4) ? luma : 0;
227      g = (i & 1) ? luma : 0;
228      b = (i & 2) ? luma : 0;
229
230      palette_set_color_rgb( device->machine, i, r, g, b );
231   }
232}
233
234/*-------------------------------------------------
235    cdp1864_aoe_w - audio output enable
236-------------------------------------------------*/
237
238void cdp1864_aoe_w(const device_config *device, int level)
239{
240   cdp1864_t *cdp1864 = get_safe_token(device);
241   const device_config *speaker = devtag_get_device(device->machine, "beep");
242
243   if (!level)
244   {
245      cdp1864->latch = CDP1864_DEFAULT_LATCH;
246   }
247
248   cdp1864->audio = level;
249
250   beep_set_state(speaker, level); // TODO: remove this
251}
252
253/*-------------------------------------------------
254    cdp1864_dispon_r - turn display on
255-------------------------------------------------*/
256
257READ8_DEVICE_HANDLER( cdp1864_dispon_r )
258{
259   cdp1864_t *cdp1864 = get_safe_token(device);
260
261   cdp1864->disp = 1;
262
263   return 0xff;
264}
265
266/*-------------------------------------------------
267    cdp1864_dispoff_r - turn display off
268-------------------------------------------------*/
269
270READ8_DEVICE_HANDLER( cdp1864_dispoff_r )
271{
272   cdp1864_t *cdp1864 = get_safe_token(device);
273
274   cdp1864->disp = 0;
275
276   devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
277   devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
278
279   return 0xff;
280}
281
282/*-------------------------------------------------
283    cdp1864_step_bgcolor_w - step background color
284-------------------------------------------------*/
285
286WRITE8_DEVICE_HANDLER( cdp1864_step_bgcolor_w )
287{
288   cdp1864_t *cdp1864 = get_safe_token(device);
289
290   cdp1864->disp = 1;
291
292   if (++cdp1864->bgcolor > 3) cdp1864->bgcolor = 0;
293}
294
295/*-------------------------------------------------
296    cdp1864_tone_latch_w - load tone latch
297-------------------------------------------------*/
298
299WRITE8_DEVICE_HANDLER( cdp1864_tone_latch_w )
300{
301   cdp1864_t *cdp1864 = get_safe_token(device);
302   const device_config *speaker = devtag_get_device(device->machine, "beep");
303
304   cdp1864->latch = data;
305   beep_set_frequency(speaker, CDP1864_CLOCK / 8 / 4 / (data + 1) / 2); // TODO: remove this
306}
307
308/*-------------------------------------------------
309    cdp1864_dma_w - write DMA byte
310-------------------------------------------------*/
311
312void cdp1864_dma_w(const device_config *device, UINT8 data, int color_on, int rdata, int gdata, int bdata)
313{
314   cdp1864_t *cdp1864 = get_safe_token(device);
315
316   int sx = video_screen_get_hpos(cdp1864->screen) + 4;
317   int y = video_screen_get_vpos(cdp1864->screen);
318   int x;
319
320   if (color_on == CLEAR_LINE)
321   {
322      rdata = 1;
323      gdata = 1;
324      bdata = 1;
325   }
326
327   for (x = 0; x < 8; x++)
328   {
329      int color = CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8;
330
331      if (BIT(data, 7))
332      {
333         color = (gdata << 2) | (bdata << 1) | rdata;
334      }
335
336      *BITMAP_ADDR16(cdp1864->bitmap, y, sx + x) = color;
337
338      data <<= 1;
339   }
340}
341
342/*-------------------------------------------------
343    cdp1864_sound_update - update sound
344-------------------------------------------------*/
345
346#ifdef UNUSED_FUNCTION
347static void cdp1864_sound_update(const device_config *device, stream_sample_t **inputs, stream_sample_t **_buffer, int length)
348{
349   cdp1864_t *cdp1864 = get_safe_token(device);
350
351   INT16 signal = cdp1864->signal;
352   stream_sample_t *buffer = _buffer[0];
353
354   memset(buffer, 0, length * sizeof(*buffer));
355
356   if (cdp1864->audio)
357   {
358      double frequency = cdp1864->intf->clock / 8 / 4 / (cdp1864->latch + 1) / 2;
359
360      int rate = device->machine->sample_rate / 2;
361
362      /* get progress through wave */
363      int incr = cdp1864->incr;
364
365      if (signal < 0)
366      {
367         signal = -0x7fff;
368      }
369      else
370      {
371         signal = 0x7fff;
372      }
373
374      while( length-- > 0 )
375      {
376         *buffer++ = signal;
377         incr -= frequency;
378         while( incr < 0 )
379         {
380            incr += rate;
381            signal = -signal;
382         }
383      }
384
385      /* store progress through wave */
386      cdp1864->incr = incr;
387      cdp1864->signal = signal;
388   }
389}
390#endif
391
392/*-------------------------------------------------
393    cdp1864_update - update screen
394-------------------------------------------------*/
395
396void cdp1864_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
397{
398   cdp1864_t *cdp1864 = get_safe_token(device);
399
400   if (cdp1864->disp)
401   {
402      copybitmap(bitmap, cdp1864->bitmap, 0, 0, 0, 0, cliprect);
403      bitmap_fill(cdp1864->bitmap, cliprect, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8);
404   }
405   else
406   {
407      bitmap_fill(bitmap, cliprect, get_black_pen(device->machine));
408   }
409}
410
411/*-------------------------------------------------
412    DEVICE_START( cdp1864 )
413-------------------------------------------------*/
414
415static DEVICE_START( cdp1864 )
416{
417   cdp1864_t *cdp1864 = get_safe_token(device);
418   const cdp1864_interface *intf = get_interface(device);
419
420   /* resolve callbacks */
421   devcb_resolve_write_line(&cdp1864->out_int_func, &intf->out_int_func, device);
422   devcb_resolve_write_line(&cdp1864->out_dmao_func, &intf->out_dmao_func, device);
423   devcb_resolve_write_line(&cdp1864->out_efx_func, &intf->out_efx_func, device);
424
425   /* get the cpu */
426   cdp1864->cpu = cputag_get_cpu(device->machine, intf->cpu_tag);
427
428   /* get the screen device */
429   cdp1864->screen = devtag_get_device(device->machine, intf->screen_tag);
430   assert(cdp1864->screen != NULL);
431
432   /* allocate the temporary bitmap */
433   cdp1864->bitmap = auto_bitmap_alloc(device->machine, video_screen_get_width(cdp1864->screen), video_screen_get_height(cdp1864->screen), video_screen_get_format(cdp1864->screen));
434   bitmap_fill(cdp1864->bitmap, 0, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8);
435
436   /* initialize the palette */
437   cdp1864_init_palette(device, intf);
438
439   /* create the timers */
440   cdp1864->int_timer = timer_alloc(device->machine, cdp1864_int_tick, (void *)device);
441   cdp1864->efx_timer = timer_alloc(device->machine, cdp1864_efx_tick, (void *)device);
442   cdp1864->dma_timer = timer_alloc(device->machine, cdp1864_dma_tick, (void *)device);
443
444   /* register for state saving */
445   state_save_register_device_item(device, 0, cdp1864->disp);
446   state_save_register_device_item(device, 0, cdp1864->dmaout);
447   state_save_register_device_item(device, 0, cdp1864->bgcolor);
448
449   state_save_register_device_item(device, 0, cdp1864->audio);
450   state_save_register_device_item(device, 0, cdp1864->latch);
451   state_save_register_device_item(device, 0, cdp1864->signal);
452   state_save_register_device_item(device, 0, cdp1864->incr);
453
454   state_save_register_bitmap(device->machine, "cdp1864", device->tag, 0, "cdp1864->bitmap", cdp1864->bitmap);
455}
456
457/*-------------------------------------------------
458    DEVICE_RESET( cdp1861 )
459-------------------------------------------------*/
460
461static DEVICE_RESET( cdp1864 )
462{
463   cdp1864_t *cdp1864 = get_safe_token(device);
464
465   timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_START, 0), 0);
466   timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0);
467   timer_adjust_oneshot(cdp1864->dma_timer, cpu_clocks_to_attotime(device->machine->firstcpu, CDP1864_CYCLES_DMA_START), 0);
468
469   cdp1864->disp = 0;
470   cdp1864->dmaout = 0;
471   cdp1864->bgcolor = 0;
472
473   devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE);
474   devcb_call_write_line(&cdp1864->out_dmao_func, CLEAR_LINE);
475   devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE);
476
477   cdp1864_aoe_w(device, 0);
478}
479
480/*-------------------------------------------------
481    DEVICE_GET_INFO( cdp1861 )
482-------------------------------------------------*/
483
484DEVICE_GET_INFO( cdp1864 )
485{
486   switch (state)
487   {
488      /* --- the following bits of info are returned as 64-bit signed integers --- */
489      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cdp1864_t);                  break;
490      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                              break;
491      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;               break;
492
493      /* --- the following bits of info are returned as pointers to data or functions --- */
494      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cdp1864);         break;
495      case DEVINFO_FCT_STOP:                     /* Nothing */                              break;
496      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(cdp1864);         break;
497
498      /* --- the following bits of info are returned as NULL-terminated strings --- */
499      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA CDP1864");                  break;
500      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA CDP1800");                  break;
501      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                        break;
502      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
503      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");            break;
504   }
505}
src/mess/video/cdp1864.h
r5705r5706
1/*
2
3             CDP1864C COS/MOS PAL Compatible Color TV Interface
4
5                        ________________
6            INLACE    1   ---|      \/      |---  40  Vdd
7            CLK IN_    2   ---|            |---  39  AUD
8           CLR OUT_    3   ---|            |---  38  CLR IN_
9               AOE    4   ---|            |---  37  DMA0_
10               SC1    5   ---|            |---  36  INT_
11               SC0    6   ---|            |---  35  TPA
12              MRD_    7   ---|            |---  34  TPB
13             BUS 7    8   ---|            |---  33  EVS
14             BUS 6    9   ---|            |---  32  V SYNC
15             BUS 5   10   ---|   CDP1864C    |---  31  H SYNC
16             BUS 4   11   ---|   top view   |---  30  C SYNC_
17             BUS 3   12   ---|            |---  29  RED
18             BUS 2   13   ---|            |---  28  BLUE
19             BUS 1   14   ---|            |---  27  GREEN
20             BUS 0   15   ---|            |---  26  BCK GND_
21              CON_   16   ---|            |---  25  BURST
22               N2   17   ---|            |---  24  ALT
23               EF_   18   ---|            |---  23  R DATA
24               N0   19   ---|            |---  22  G DATA
25               Vss   20   ---|________________|---  21  B DATA
26
27
28            http://homepage.mac.com/ruske/cosmacelf/cdp1864.pdf
29
30*/
31
32#ifndef __CDP1864__
33#define __CDP1864__
34
35#include "devcb.h"
36
37/***************************************************************************
38    PARAMETERS
39***************************************************************************/
40
41#define CDP1864_CLOCK   XTAL_1_75MHz
42
43#define CDP1864_VISIBLE_COLUMNS   64
44#define CDP1864_VISIBLE_LINES   192
45
46#define CDP1864_HBLANK_END       1 * 8
47#define CDP1864_HBLANK_START   13 * 8
48#define CDP1864_HSYNC_START       0 * 8
49#define CDP1864_HSYNC_END       1 * 8
50#define CDP1864_SCREEN_START    4 * 8
51#define CDP1864_SCREEN_END      12 * 8
52#define CDP1864_SCREEN_WIDTH   14 * 8
53
54#define CDP1864_TOTAL_SCANLINES            312
55
56#define CDP1864_SCANLINE_VBLANK_START      CDP1864_TOTAL_SCANLINES - 4
57#define CDP1864_SCANLINE_VBLANK_END         20
58#define CDP1864_SCANLINE_VSYNC_START      0
59#define CDP1864_SCANLINE_VSYNC_END         4
60#define CDP1864_SCANLINE_DISPLAY_START      60 // ???
61#define CDP1864_SCANLINE_DISPLAY_END      CDP1864_SCANLINE_DISPLAY_START + CDP1864_VISIBLE_LINES
62#define CDP1864_SCANLINE_INT_START         CDP1864_SCANLINE_DISPLAY_START - 2
63#define CDP1864_SCANLINE_INT_END         CDP1864_SCANLINE_DISPLAY_START
64#define CDP1864_SCANLINE_EFX_TOP_START      CDP1864_SCANLINE_DISPLAY_START - 4
65#define CDP1864_SCANLINE_EFX_TOP_END      CDP1864_SCANLINE_DISPLAY_START
66#define CDP1864_SCANLINE_EFX_BOTTOM_START   CDP1864_SCANLINE_DISPLAY_END - 4
67#define CDP1864_SCANLINE_EFX_BOTTOM_END      CDP1864_SCANLINE_DISPLAY_END
68
69/***************************************************************************
70    MACROS / CONSTANTS
71***************************************************************************/
72
73#define CDP1864      DEVICE_GET_INFO_NAME(cdp1864)
74
75#define MDRV_CDP1864_ADD(_tag, _clock, _config) \
76   MDRV_DEVICE_ADD(_tag, CDP1864, _clock) \
77   MDRV_DEVICE_CONFIG(_config)
78
79#define CDP1864_INTERFACE(name) const cdp1864_interface (name)=
80
81/***************************************************************************
82    TYPE DEFINITIONS
83***************************************************************************/
84
85typedef enum _cdp1864_format cdp1864_format;
86enum _cdp1864_format {
87   CDP1864_NON_INTERLACED = 0,
88   CDP1864_INTERLACED
89};
90
91typedef struct _cdp1864_interface cdp1864_interface;
92struct _cdp1864_interface
93{
94   const char *cpu_tag;      /* cpu we are working with */
95   const char *screen_tag;      /* screen we are acting on */
96
97   cdp1864_format interlace;   /* interlace */
98
99   /* this gets called for every change of the INT pin (pin 36) */
100   devcb_write_line      out_int_func;
101
102   /* this gets called for every change of the DMAO pin (pin 37) */
103   devcb_write_line      out_dmao_func;
104
105   /* this gets called for every change of the EFX pin (pin 18) */
106   devcb_write_line      out_efx_func;
107
108   double res_r;            /* red output resistor value */
109   double res_g;            /* green output resistor value */
110   double res_b;            /* blue output resistor value */
111   double res_bkg;            /* background output resistor value */
112};
113
114/***************************************************************************
115    PROTOTYPES
116***************************************************************************/
117
118/* device interface */
119DEVICE_GET_INFO( cdp1864 );
120
121/* display on (0x69) */
122READ8_DEVICE_HANDLER( cdp1864_dispon_r );
123
124/* display off (0x6c) */
125READ8_DEVICE_HANDLER( cdp1864_dispoff_r );
126
127/* step background color (0x61) */
128WRITE8_DEVICE_HANDLER( cdp1864_step_bgcolor_w );
129
130/* load tone latch (0x64) */
131WRITE8_DEVICE_HANDLER( cdp1864_tone_latch_w );
132
133/* audio output enable */
134void cdp1864_aoe_w(const device_config *device, int level);
135
136/* DMA write */
137void cdp1864_dma_w(const device_config *device, UINT8 data, int color_on, int rdata, int gdata, int bdata);
138
139/* screen update */
140void cdp1864_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
141
142#endif
src/mess/video/cdp1862.c
r5705r5706
1212    TODO:
1313
1414   - calculate colors from luminance/chrominance resistors
15   - refactor DMA write to WRITE8_DEVICE_HANDLER and add callbacks for RD/BD/GD
1615
1716*/
1817
r5705r5706
3231typedef struct _cdp1862_t cdp1862_t;
3332struct _cdp1862_t
3433{
34   devcb_resolved_read_line      in_rd_func;
35   devcb_resolved_read_line      in_bd_func;
36   devcb_resolved_read_line      in_gd_func;
37
3538   const device_config *screen;   /* screen */
3639   bitmap_t *bitmap;            /* bitmap */
3740
r5705r5706
105108    cdp1862_dma_w - DMA byte write
106109-------------------------------------------------*/
107110
108void cdp1862_dma_w(const device_config *device, UINT8 data, int rd, int bd, int gd)
111WRITE8_DEVICE_HANDLER( cdp1862_dma_w )
109112{
110113   cdp1862_t *cdp1862 = get_safe_token(device);
111114
115   int rd = 1, bd = 1, gd = 1;
112116   int sx = video_screen_get_hpos(cdp1862->screen) + 4;
113117   int y = video_screen_get_vpos(cdp1862->screen);
114118   int x;
115119
116   if (cdp1862->con)
120   if (!cdp1862->con)
117121   {
118      /* latch white dot color */
119      rd = 1;
120      gd = 1;
121      bd = 1;
122      rd = devcb_call_read_line(&cdp1862->in_rd_func);
123      bd = devcb_call_read_line(&cdp1862->in_bd_func);
124      gd = devcb_call_read_line(&cdp1862->in_gd_func);
122125   }
123126
124127   for (x = 0; x < 8; x++)
r5705r5706
171174   cdp1862_t *cdp1862 = get_safe_token(device);
172175   const cdp1862_interface *intf = device->static_config;
173176
177   /* resolve callbacks */
178   devcb_resolve_read_line(&cdp1862->in_rd_func, &intf->in_rd_func, device);
179   devcb_resolve_read_line(&cdp1862->in_bd_func, &intf->in_bd_func, device);
180   devcb_resolve_read_line(&cdp1862->in_gd_func, &intf->in_gd_func, device);
181
174182   /* get the screen device */
175183   cdp1862->screen = devtag_get_device(device->machine, intf->screen_tag);
176184   assert(cdp1862->screen != NULL);
src/mess/video/cdp1862.h
r5705r5706
4343   MDRV_DEVICE_CONFIG(_config)
4444
4545#define CDP1862_INTERFACE(name) \
46   const cdp1862_interface (name)=
46   const cdp1862_interface (name) =
4747
4848/***************************************************************************
4949    TYPE DEFINITIONS
r5705r5706
5454{
5555   const char *screen_tag;      /* screen we are acting on */
5656
57   devcb_read_line            in_rd_func;
58   devcb_read_line            in_bd_func;
59   devcb_read_line            in_gd_func;
60
5761   double lum_r;            /* red luminance resistor value */
5862   double lum_b;            /* blue luminance resistor value */
5963   double lum_g;            /* green luminance resistor value */
r5705r5706
7377DEVICE_GET_INFO( cdp1862 );
7478
7579/* step background color */
76WRITE8_DEVICE_HANDLER( cdp1862_bkg_w );
80WRITE8_DEVICE_HANDLER( cdp1862_bkg_w ) ATTR_NONNULL(1);
7781
7882/* color on */
79WRITE_LINE_DEVICE_HANDLER( cdp1862_con_w );
83WRITE_LINE_DEVICE_HANDLER( cdp1862_con_w ) ATTR_NONNULL(1);
8084
8185/* DMA write */
82void cdp1862_dma_w(const device_config *device, UINT8 data, int rd, int bd, int gd) ATTR_NONNULL(1);
86WRITE8_DEVICE_HANDLER( cdp1862_dma_w ) ATTR_NONNULL(1);
8387
8488/* screen update */
8589void cdp1862_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) ATTR_NONNULL(1) ATTR_NONNULL(2) ATTR_NONNULL(3);
src/mess/video/tmc1800.c
r5705r5706
22#include "includes/tmc1800.h"
33#include "cpu/cdp1802/cdp1802.h"
44#include "video/cdp1861.h"
5#include "video/cdp1864.h"
5#include "sound/cdp1864.h"
66#include "machine/rescap.h"
77
88/* Telmac 1800 */
r5705r5706
3434
3535/* Telmac 2000 */
3636
37static READ_LINE_DEVICE_HANDLER( rdata_r )
38{
39   tmc2000_state *state = device->machine->driver_data;
40
41   return BIT(state->color, 2);
42}
43
44static READ_LINE_DEVICE_HANDLER( bdata_r )
45{
46   tmc2000_state *state = device->machine->driver_data;
47
48   return BIT(state->color, 1);
49}
50
51static READ_LINE_DEVICE_HANDLER( gdata_r )
52{
53   tmc2000_state *state = device->machine->driver_data;
54
55   return BIT(state->color, 0);
56}
57
3758static WRITE_LINE_DEVICE_HANDLER( tmc2000_efx_w )
3859{
3960   tmc2000_state *driver_state = device->machine->driver_data;
r5705r5706
4667   CDP1802_TAG,
4768   SCREEN_TAG,
4869   CDP1864_INTERLACED,
70   DEVCB_LINE(rdata_r),
71   DEVCB_LINE(bdata_r),
72   DEVCB_LINE(gdata_r),
4973   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_INT),
5074   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_DMAOUT),
5175   DEVCB_LINE(tmc2000_efx_w),
r5705r5706
78102   CDP1802_TAG,
79103   SCREEN_TAG,
80104   CDP1864_INTERLACED,
105   DEVCB_LINE_VCC,
106   DEVCB_LINE_VCC,
107   DEVCB_LINE_VCC,
81108   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_INT),
82109   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_DMAOUT),
83110   DEVCB_LINE(oscnano_efx_w),
r5705r5706
142169   MDRV_PALETTE_LENGTH(8+8)
143170   MDRV_VIDEO_UPDATE(tmc2000)
144171
172   MDRV_SPEAKER_STANDARD_MONO("mono")
145173   MDRV_CDP1864_ADD(CDP1864_TAG, XTAL_1_75MHz, tmc2000_cdp1864_intf)
174   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
146175MACHINE_DRIVER_END
147176
148177MACHINE_DRIVER_START( oscnano_video )
r5705r5706
153182   MDRV_PALETTE_LENGTH(8+8)
154183   MDRV_VIDEO_UPDATE(oscnano)
155184
185   MDRV_SPEAKER_STANDARD_MONO("mono")
156186   MDRV_CDP1864_ADD(CDP1864_TAG, XTAL_1_75MHz, oscnano_cdp1864_intf)
187   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
157188MACHINE_DRIVER_END
src/mess/video/cdp1861.c
r5705r5706
1/**********************************************************************
2
3    RCA CDP1861 Video Display Controller emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
110#include "driver.h"
211#include "cdp1861.h"
312
r5705r5706
4453{
4554   assert(device != NULL);
4655   assert(device->token != NULL);
47
56   assert(device->type == CDP1861);
4857   return (cdp1861_t *)device->token;
4958}
5059
r5705r5706
199208    cdp1861_dma_w - write DMA byte
200209-------------------------------------------------*/
201210
202void cdp1861_dma_w(const device_config *device, UINT8 data)
211WRITE8_DEVICE_HANDLER( cdp1861_dma_w )
203212{
204213   cdp1861_t *cdp1861 = get_safe_token(device);
205214
src/mess/video/cdp1861.h
r5705r5706
1/*
1/**********************************************************************
22
3                 RCA CDP1861 Video Display Controller
3    RCA CDP1861 Video Display Controller emulation
44
5                        _______  _______
6              CLK_    1   ---|      \/      |---  24  Vdd
7              DMAO_    2   ---|            |---  23  CLEAR_
8               INT_    3   ---|            |---  22  SC1
9               TPA    4   ---|            |---  21  SC0
10               TPB    5   ---|            |---  20  DI7
11         COMP SYNC_    6   ---|   CDP1861C   |---  19  DI6
12             VIDEO    7   ---|   top view   |---  18  DI5
13            RESET_    8   ---|            |---  17  DI4
14              EFX_    9   ---|            |---  16  DI3
15            DISP ON   10   ---|             |---  15  DI2
16           DISP OFF   11   ---|            |---  14  DI1
17               Vss   12   ---|________________|---  13  DI0
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
187
8**********************************************************************
9                     _______  _______
10           CLK_    1   ---|      \/      |---  24  Vdd
11           DMAO_    2   ---|            |---  23  CLEAR_
12            INT_    3   ---|            |---  22  SC1
13            TPA    4   ---|            |---  21  SC0
14            TPB    5   ---|            |---  20  DI7
15      COMP SYNC_    6   ---|   CDP1861C   |---  19  DI6
16          VIDEO    7   ---|   top view   |---  18  DI5
17         RESET_    8   ---|            |---  17  DI4
18           EFX_    9   ---|            |---  16  DI3
19         DISP ON   10   ---|             |---  15  DI2
20        DISP OFF   11   ---|            |---  14  DI1
21            Vss   12   ---|________________|---  13  DI0
1922
20            http://homepage.mac.com/ruske/cosmacelf/cdp1861.pdf
2123
22*/
24         http://homepage.mac.com/ruske/cosmacelf/cdp1861.pdf
2325
26**********************************************************************/
27
2428#ifndef __CDP1861__
2529#define __CDP1861__
2630
r5705r5706
6468   MDRV_DEVICE_ADD(_tag, CDP1861, _clock) \
6569   MDRV_DEVICE_CONFIG(_config)
6670
67#define CDP1861_INTERFACE(name) const cdp1861_interface (name)=
71#define CDP1861_INTERFACE(name) \
72   const cdp1861_interface (name) =
6873
6974/***************************************************************************
7075    TYPE DEFINITIONS
r5705r5706
9499DEVICE_GET_INFO( cdp1861 );
95100
96101/* display on */
97WRITE_LINE_DEVICE_HANDLER( cdp1861_dispon_w );
102WRITE_LINE_DEVICE_HANDLER( cdp1861_dispon_w ) ATTR_NONNULL(1);
98103
99104/* display off */
100WRITE_LINE_DEVICE_HANDLER( cdp1861_dispoff_w );
105WRITE_LINE_DEVICE_HANDLER( cdp1861_dispoff_w ) ATTR_NONNULL(1);
101106
102107/* DMA write */
103void cdp1861_dma_w(const device_config *device, UINT8 data);
108WRITE8_DEVICE_HANDLER( cdp1861_dma_w ) ATTR_NONNULL(1);
104109
105110/* screen update */
106void cdp1861_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
111void cdp1861_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) ATTR_NONNULL(1) ATTR_NONNULL(2) ATTR_NONNULL(3);
107112
108113#endif
src/mess/includes/vip.h
r5705r5706
1010
1111#define VP590_COLOR_RAM_SIZE   0x100
1212
13#define VIP_BANK_RAM      0
14#define VIP_BANK_ROM      1
13#define VIP_BANK_RAM         0
14#define VIP_BANK_ROM         1
1515
16#define VIP_VIDEO_CDP1861   0
17#define VIP_VIDEO_CDP1862   1
16#define VIP_VIDEO_CDP1861      0
17#define VIP_VIDEO_CDP1862      1
1818
19#define VIP_SOUND_SPEAKER   0
20#define VIP_SOUND_VP595      1
21#define VIP_SOUND_VP550      2
22#define VIP_SOUND_VP551      3
19#define VIP_SOUND_SPEAKER      0
20#define VIP_SOUND_VP595         1
21#define VIP_SOUND_VP550         2
22#define VIP_SOUND_VP551         3
2323
2424#define VIP_KEYBOARD_KEYPAD      0
2525#define VIP_KEYBOARD_VP580      1
r5705r5706
2727#define VIP_KEYBOARD_VP601      3
2828#define VIP_KEYBOARD_VP611      4
2929
30#define VIP_LED_POWER      0
31#define VIP_LED_Q         1
32#define VIP_LED_TAPE      2
30#define VIP_LED_POWER         0
31#define VIP_LED_Q            1
32#define VIP_LED_TAPE         2
3333
3434typedef struct _vip_state vip_state;
3535struct _vip_state
r5705r5706
4141   int cdp1861_efx;            /* EFx */
4242   int a12;                  /* latched address line 12 */
4343   UINT8 *colorram;            /* CDP1862 color RAM */
44   UINT8 color;               /* color RAM data */
4445
45   /* sound state */
46
4746   /* keyboard state */
4847   int keylatch;               /* key latch */
4948
src/mess/includes/studio2.h
r5705r5706
2323   int cdp1861_efx;
2424   int cdp1864_efx;
2525   UINT8 *color_ram;
26   UINT8 color;
2627
2728   /* devices */
2829   const device_config *cdp1861;
src/mess/includes/tmc2000e.h
r5705r5706
1313{
1414   /* video state */
1515   int cdp1864_efx;      /* EFx */
16
1716   UINT8 *colorram;      /* color memory */
17   UINT8 color;
1818
1919   /* keyboard state */
2020   int keylatch;         /* key latch */
src/mess/includes/tmc1800.h
r5705r5706
4545   int reset;            /* reset activated */
4646
4747   UINT8 *colorram;      /* color memory */
48   UINT8 color;
4849
4950   /* keyboard state */
5051   int keylatch;         /* key latch */
src/mess/mess.mak
r5705r5706
231231#SOUNDS += TMS5100
232232#SOUNDS += TMS5110A
233233SOUNDS += CDP1863
234SOUNDS += CDP1864
234235
235236
236237#-------------------------------------------------
r5705r5706
461462   $(MESS_MACHINE)/z80sti.o   \
462463   $(MESS_VIDEO)/cdp1861.o      \
463464   $(MESS_VIDEO)/cdp1862.o      \
464   $(MESS_VIDEO)/cdp1864.o      \
465465   $(MESS_VIDEO)/crtc6845.o   \
466466   $(MESS_VIDEO)/dl1416.o      \
467467   $(MESS_VIDEO)/dm9368.o      \
src/mess/drivers/vip.c
r5705r5706
396396   DEVCB_LINE(vip_efx_w)
397397};
398398
399static READ_LINE_DEVICE_HANDLER( rd_r )
400{
401   vip_state *state = device->machine->driver_data;
402
403   return BIT(state->color, 1);
404}
405
406static READ_LINE_DEVICE_HANDLER( bd_r )
407{
408   vip_state *state = device->machine->driver_data;
409
410   return BIT(state->color, 2);
411}
412
413static READ_LINE_DEVICE_HANDLER( gd_r )
414{
415   vip_state *state = device->machine->driver_data;
416
417   return BIT(state->color, 3);
418}
419
399420static CDP1862_INTERFACE( vip_cdp1862_intf )
400421{
401422   SCREEN_TAG,
423   DEVCB_LINE(rd_r),
424   DEVCB_LINE(bd_r),
425   DEVCB_LINE(gd_r),
402426   510,         /* R3 */
403427   360,         /* R4 */
404428   RES_K(1),      /* R5 */
r5705r5706
551575   switch (input_port_read(device->machine, "VIDEO"))
552576   {
553577   case VIP_VIDEO_CDP1861:
554      cdp1861_dma_w(state->cdp1861, data);
578      cdp1861_dma_w(state->cdp1861, offset, data);
555579      break;
556580
557581   case VIP_VIDEO_CDP1862:
558582      {
559583         UINT8 mask = 0xff;
560         UINT8 color;
561         int rd, bd, gd;
562584
563         if (!state->a12)
585         if (!state->a12)
564586         {
565587            /* mask out A4 and A3 */
566588            mask = 0xe7;
567589         }
568590
569         color = state->colorram[offset & mask];
591         state->color = state->colorram[offset & mask];
570592         
571         rd = BIT(color, 1);
572         bd = BIT(color, 2);
573         gd = BIT(color, 3);
574
575         cdp1862_dma_w(state->cdp1862, data, rd, bd, gd);
593         cdp1862_dma_w(state->cdp1862, offset, data);
576594      }
577595      break;
578596   }
r5705r5706
631649   vp550_q_w(state->vp550, 0);
632650
633651   /* register for state saving */
652   state_save_register_global(machine, state->reset);
634653   state_save_register_global_pointer(machine, state->colorram, VP590_COLOR_RAM_SIZE);
635
636   state_save_register_global(machine, state->reset);
637654   state_save_register_global(machine, state->cdp1861_efx);
655   state_save_register_global(machine, state->color);
638656   state_save_register_global(machine, state->keylatch);
639657}
640658
src/mess/drivers/elf.c
r5705r5706
199199   return state->data;
200200}
201201
202static WRITE8_DEVICE_HANDLER( elf2_dma_w )
203{
204   elf2_state *state = device->machine->driver_data;
205
206   cdp1861_dma_w(state->cdp1861, data);
207}
208
209202static CDP1802_INTERFACE( elf2_config )
210203{
211204   elf2_mode_r,
r5705r5706
213206   elf2_sc_w,
214207   DEVCB_LINE(elf2_q_w),
215208   DEVCB_HANDLER(elf2_dma_r),
216   DEVCB_HANDLER(elf2_dma_w)
209   DEVCB_DEVICE_HANDLER(CDP1861_TAG, cdp1861_dma_w)
217210};
218211
219212/* MM74C923 Interface */
src/mess/drivers/studio2.c
r5705r5706
198198#include "includes/studio2.h"
199199#include "cpu/cdp1802/cdp1802.h"
200200#include "video/cdp1861.h"
201#include "video/cdp1864.h"
201#include "sound/cdp1864.h"
202202#include "devices/cartslot.h"
203203#include "sound/beep.h"
204204#include "sound/discrete.h"
r5705r5706
331331   CDP1802_TAG,
332332   SCREEN_TAG,
333333   CDP1864_INTERLACED,
334   DEVCB_LINE_VCC, // ?
335   DEVCB_LINE_VCC, // ?
336   DEVCB_LINE_VCC, // ?
334337   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_INT),
335338   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_DMAOUT),
336339   DEVCB_LINE(mpt02_efx_w),
r5705r5706
378381   beep_set_state(speaker, state);
379382}
380383
381static WRITE8_DEVICE_HANDLER( studio2_dma_w )
382{
383   studio2_state *state = device->machine->driver_data;
384
385   cdp1861_dma_w(state->cdp1861, data);
386}
387
388384static CDP1802_INTERFACE( studio2_config )
389385{
390386   studio2_mode_r,
r5705r5706
392388   NULL,
393389   DEVCB_LINE(studio2_q_w),
394390   DEVCB_NULL,
395   DEVCB_HANDLER(studio2_dma_w)
391   DEVCB_DEVICE_HANDLER(CDP1861_TAG, cdp1861_dma_w)
396392};
397393
398394static CDP1802_EF_READ( mpt02_ef_r )
r5705r5706
413409{
414410   studio2_state *state = device->machine->driver_data;
415411
416   UINT8 color = state->color_ram[offset / 4]; // 0x04 = R, 0x02 = B, 0x01 = G
412   state->color = state->color_ram[offset / 4];
417413
418   int rdata = BIT(color, 2);
419   int gdata = BIT(color, 0);
420   int bdata = BIT(color, 1);
421
422   cdp1864_dma_w(state->cdp1864, data, ASSERT_LINE, rdata, gdata, bdata);
414   cdp1864_con_w(state->cdp1864, 0); // HACK
415   cdp1864_dma_w(state->cdp1864, offset, data);
423416}
424417
425418static CDP1802_INTERFACE( mpt02_config )
r5705r5706
543536   MDRV_DRIVER_DATA(studio2_state)
544537
545538   // basic machine hardware
546
547539   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, 3579545/2) // the real clock is derived from an oscillator circuit
548540   MDRV_CPU_PROGRAM_MAP(studio2_map)
549541   MDRV_CPU_IO_MAP(studio2_io_map)
r5705r5706
553545   MDRV_MACHINE_RESET(studio2)
554546
555547    // video hardware
556
557548   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
558549   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
559550   MDRV_SCREEN_RAW_PARAMS(3579545/2, CDP1861_SCREEN_WIDTH, CDP1861_HBLANK_END, CDP1861_HBLANK_START, CDP1861_TOTAL_SCANLINES, CDP1861_SCANLINE_VBLANK_END, CDP1861_SCANLINE_VBLANK_START)
r5705r5706
562553   MDRV_PALETTE_INIT(black_and_white)
563554   MDRV_VIDEO_UPDATE(studio2)
564555
565   MDRV_CDP1861_ADD(CDP1861_TAG, XTAL_3_52128MHz, studio2_cdp1861_intf)
556   MDRV_CDP1861_ADD(CDP1861_TAG, 3579545/2, studio2_cdp1861_intf)
566557
567558   // sound hardware
568
569559   MDRV_SPEAKER_STANDARD_MONO("mono")
570560   MDRV_SOUND_ADD("beep", BEEP, 0)
571561   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
r5705r5706
577567   MDRV_DRIVER_DATA(studio2_state)
578568
579569   // basic machine hardware
580
581570   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_3_579545MHz/2)
582571   MDRV_CPU_PROGRAM_MAP(visicom_map)
583572   MDRV_CPU_IO_MAP(visicom_io_map)
r5705r5706
587576   MDRV_MACHINE_RESET(studio2)
588577
589578    // video hardware
590
591579   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
592580   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
593581   MDRV_SCREEN_RAW_PARAMS(XTAL_3_579545MHz/2, CDP1861_SCREEN_WIDTH, CDP1861_HBLANK_END, CDP1861_HBLANK_START, CDP1861_TOTAL_SCANLINES, CDP1861_SCANLINE_VBLANK_END, CDP1861_SCANLINE_VBLANK_START)
r5705r5706
599587   MDRV_CDP1861_ADD(CDP1861_TAG, XTAL_3_579545MHz/2/8, studio2_cdp1861_intf)
600588
601589   // sound hardware
602
603590   MDRV_SPEAKER_STANDARD_MONO("mono")
604591   MDRV_SOUND_ADD("beep", BEEP, 0)
605592   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
r5705r5706
611598   MDRV_DRIVER_DATA(studio2_state)
612599
613600   // basic machine hardware
614
615601   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, CDP1864_CLOCK)
616602   MDRV_CPU_PROGRAM_MAP(mpt02_map)
617603   MDRV_CPU_IO_MAP(mpt02_io_map)
r5705r5706
621607   MDRV_MACHINE_RESET(mpt02)
622608
623609    // video hardware
624
625610   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
626611   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
627612   MDRV_SCREEN_RAW_PARAMS(CDP1864_CLOCK, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START)
r5705r5706
629614   MDRV_PALETTE_LENGTH(8+8)
630615   MDRV_VIDEO_UPDATE(mpt02)
631616
632   MDRV_CDP1864_ADD(CDP1864_TAG, CDP1864_CLOCK, mpt02_cdp1864_intf)
633
634617   // sound hardware
635
636618   MDRV_SPEAKER_STANDARD_MONO("mono")
637   MDRV_SOUND_ADD("beep", BEEP, 0)
638   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
619   MDRV_CDP1864_ADD(CDP1864_TAG, CDP1864_CLOCK, mpt02_cdp1864_intf)
620   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
639621   
640622   MDRV_IMPORT_FROM( studio2_cartslot )
641623MACHINE_DRIVER_END
src/mess/drivers/tmc1800.c
r5705r5706
115115#include "includes/tmc1800.h"
116116#include "cpu/cdp1802/cdp1802.h"
117117#include "video/cdp1861.h"
118#include "video/cdp1864.h"
118#include "sound/cdp1864.h"
119119#include "devices/cassette.h"
120120#include "devices/snapquik.h"
121121#include "machine/rescap.h"
r5705r5706
493493   cassette_output(driver_state->cassette, state ? 1.0 : -1.0);
494494}
495495
496static WRITE8_DEVICE_HANDLER( tmc1800_dma_w )
497{
498   tmc1800_state *state = device->machine->driver_data;
499
500   cdp1861_dma_w(state->cdp1861, data);
501}
502
503496static CDP1802_INTERFACE( tmc1800_config )
504497{
505498   tmc1800_mode_r,
r5705r5706
507500   NULL,
508501   DEVCB_LINE(tmc1800_q_w),
509502   DEVCB_NULL,
510   DEVCB_HANDLER(tmc1800_dma_w)
503   DEVCB_DEVICE_HANDLER(CDP1861_TAG, cdp1861_dma_w)
511504};
512505
513506static CDP1802_INTERFACE( osc1000b_config )
r5705r5706
590583{
591584   tmc2000_state *state = device->machine->driver_data;
592585
593   UINT8 color = ~(state->colorram[offset & 0x1ff]) & 0x07;
594   
595   int rdata = BIT(color, 2);
596   int gdata = BIT(color, 0);
597   int bdata = BIT(color, 1);
586   state->color = ~(state->colorram[offset & 0x1ff]) & 0x07;
598587
599   cdp1864_dma_w(state->cdp1864, data, ASSERT_LINE, rdata, gdata, bdata);
588   cdp1864_con_w(state->cdp1864, 0); // HACK
589   cdp1864_dma_w(state->cdp1864, offset, data);
600590}
601591
602592static CDP1802_INTERFACE( tmc2000_config )
r5705r5706
702692   cassette_output(driver_state->cassette, state ? 1.0 : -1.0);
703693}
704694
705static WRITE8_DEVICE_HANDLER( oscnano_dma_w )
706{
707   oscnano_state *state = device->machine->driver_data;
708
709   cdp1864_dma_w(state->cdp1864, data, CLEAR_LINE, 1, 1, 1);
710}
711
712695static CDP1802_INTERFACE( oscnano_config )
713696{
714697   oscnano_mode_r,
r5705r5706
716699   NULL,
717700   DEVCB_LINE(oscnano_q_w),
718701   DEVCB_NULL,
719   DEVCB_HANDLER(oscnano_dma_w)
702   DEVCB_DEVICE_HANDLER(CDP1864_TAG, cdp1864_dma_w)
720703};
721704
722705/* Machine Initialization */
r5705r5706
741724{
742725   tmc1800_state *state = machine->driver_data;
743726
744   /* reset CDP1864 */
727   /* reset CDP1861 */
745728   device_reset(state->cdp1861);
746729}
747730
r5705r5706
864847   MDRV_DRIVER_DATA(tmc1800_state)
865848
866849   // basic system hardware
867
868850   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_1_75MHz)
869851   MDRV_CPU_PROGRAM_MAP(tmc1800_map)
870852   MDRV_CPU_IO_MAP(tmc1800_io_map)
r5705r5706
874856   MDRV_MACHINE_RESET(tmc1800)
875857
876858   // video hardware
877
878859   MDRV_IMPORT_FROM(tmc1800_video)
879860
880861   // sound hardware
881
882862   MDRV_SPEAKER_STANDARD_MONO("mono")
883863
884864   MDRV_SOUND_ADD("beep", BEEP, 0)
885865   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
886866
887   // quickload
888
867   // devices
889868   MDRV_QUICKLOAD_ADD("quickload", tmc1800, "bin", 0)
890
891869   MDRV_CASSETTE_ADD( "cassette", tmc1800_cassette_config )
892870MACHINE_DRIVER_END
893871
r5705r5706
895873   MDRV_DRIVER_DATA(osc1000b_state)
896874
897875   // basic system hardware
898
899876   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_1_75MHz)
900877   MDRV_CPU_PROGRAM_MAP(osc1000b_map)
901878   MDRV_CPU_IO_MAP(osc1000b_io_map)
r5705r5706
905882   MDRV_MACHINE_RESET(osc1000b)
906883
907884   // video hardware
908
909885   MDRV_IMPORT_FROM(osc1000b_video)
910886
911887   // sound hardware
912
913888   MDRV_SPEAKER_STANDARD_MONO("mono")
914889
915890   MDRV_SOUND_ADD("beep", BEEP, 0)
916891   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
917892
918   // quickload
919
893   // devices
920894   MDRV_QUICKLOAD_ADD("quickload", tmc1800, "bin", 0)
921
922895   MDRV_CASSETTE_ADD( "cassette", tmc1800_cassette_config )
923896MACHINE_DRIVER_END
924897
r5705r5706
926899   MDRV_DRIVER_DATA(tmc2000_state)
927900
928901   // basic system hardware
929
930902   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_1_75MHz)
931903   MDRV_CPU_PROGRAM_MAP(tmc2000_map)
932904   MDRV_CPU_IO_MAP(tmc2000_io_map)
r5705r5706
936908   MDRV_MACHINE_RESET(tmc2000)
937909
938910   // video hardware
939
940911   MDRV_IMPORT_FROM(tmc2000_video)
941912
942   // sound hardware
943
944   MDRV_SPEAKER_STANDARD_MONO("mono")
945
946   MDRV_SOUND_ADD("beep", BEEP, 0)
947   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
948
949   // quickload
950
913   // devices
951914   MDRV_QUICKLOAD_ADD("quickload", tmc1800, "bin", 0)
952
953915   MDRV_CASSETTE_ADD( "cassette", tmc1800_cassette_config )
954916MACHINE_DRIVER_END
955917
r5705r5706
957919   MDRV_DRIVER_DATA(oscnano_state)
958920
959921   // basic system hardware
960
961922   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_1_75MHz)
962923   MDRV_CPU_PROGRAM_MAP(oscnano_map)
963924   MDRV_CPU_IO_MAP(oscnano_io_map)
r5705r5706
967928   MDRV_MACHINE_RESET(oscnano)
968929
969930   // video hardware
970
971931   MDRV_IMPORT_FROM(oscnano_video)
972932
973   // sound hardware
974
975   MDRV_SPEAKER_STANDARD_MONO("mono")
976
977   MDRV_SOUND_ADD("beep", BEEP, 0)
978   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
979
980   // quickload
981
933   // devices
982934   MDRV_QUICKLOAD_ADD("quickload", tmc1800, "bin", 0)
983
984935   MDRV_CASSETTE_ADD( "cassette", tmc1800_cassette_config )
985936MACHINE_DRIVER_END
986937
r5705r5706
10711022/*    YEAR  NAME        PARENT  COMPAT  MACHINE     INPUT       INIT        CONFIG      COMPANY         FULLNAME        FLAGS */
10721023COMP( 1977, tmc1800,    0,      0,      tmc1800,    tmc1800,    tmc1800,    tmc1800,    "Telercas Oy",  "Telmac 1800",  GAME_NOT_WORKING )
10731024COMP( 1977, osc1000b,   tmc1800,0,      osc1000b,   tmc1800,    tmc1800,    osc1000b,   "OSCOM Oy",      "OSCOM 1000B",  GAME_NOT_WORKING )
1074COMP( 1980, tmc2000,    0,      0,      tmc2000,    tmc2000,    tmc1800,    tmc2000,    "Telercas Oy",  "Telmac 2000",  GAME_SUPPORTS_SAVE )
1075COMP( 1980, oscnano,   tmc2000,0,      oscnano,   oscnano,   tmc1800,   oscnano,   "OSCOM Oy",      "OSCOM Nano",   GAME_SUPPORTS_SAVE )
1025COMP( 1980, tmc2000,    0,      0,      tmc2000,    tmc2000,    0,          tmc2000,    "Telercas Oy",  "Telmac 2000",  GAME_SUPPORTS_SAVE )
1026COMP( 1980, oscnano,   tmc2000,0,      oscnano,   oscnano,   0,         oscnano,   "OSCOM Oy",      "OSCOM Nano",   GAME_SUPPORTS_SAVE )
src/mess/drivers/tmc2000e.c
r5705r5706
3636#include "devices/flopdrv.h"
3737#include "formats/basicdsk.h"
3838#include "devices/cassette.h"
39#include "video/cdp1864.h"
40#include "sound/beep.h"
39#include "sound/cdp1864.h"
4140#include "machine/rescap.h"
4241
4342/* Read/Write Handlers */
r5705r5706
126125
127126/* Video */
128127
128static READ_LINE_DEVICE_HANDLER( rdata_r )
129{
130   tmc2000e_state *state = device->machine->driver_data;
131
132   return BIT(state->color, 2);
133}
134
135static READ_LINE_DEVICE_HANDLER( bdata_r )
136{
137   tmc2000e_state *state = device->machine->driver_data;
138
139   return BIT(state->color, 1);
140}
141
142static READ_LINE_DEVICE_HANDLER( gdata_r )
143{
144   tmc2000e_state *state = device->machine->driver_data;
145
146   return BIT(state->color, 0);
147}
148
129149static WRITE_LINE_DEVICE_HANDLER( tmc2000e_efx_w )
130150{
131151   tmc2000e_state *driver_state = device->machine->driver_data;
r5705r5706
138158   CDP1802_TAG,
139159   SCREEN_TAG,
140160   CDP1864_INTERLACED,
161   DEVCB_LINE(rdata_r),
162   DEVCB_LINE(bdata_r),
163   DEVCB_LINE(gdata_r),
141164   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_INT),
142165   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_DMAOUT),
143166   DEVCB_LINE(tmc2000e_efx_w),
r5705r5706
222245{
223246   tmc2000e_state *state = device->machine->driver_data;
224247
225   UINT8 color = (state->colorram[offset & 0x3ff]) & 0x07; // 0x04 = R, 0x02 = B, 0x01 = G
226   
227   int rdata = BIT(color, 2);
228   int gdata = BIT(color, 0);
229   int bdata = BIT(color, 1);
248   state->color = (state->colorram[offset & 0x3ff]) & 0x07; // 0x04 = R, 0x02 = B, 0x01 = G
230249
231   cdp1864_dma_w(state->cdp1864, data, ASSERT_LINE, rdata, gdata, bdata);
250   cdp1864_con_w(state->cdp1864, 0); // HACK
251   cdp1864_dma_w(state->cdp1864, offset, data);
232252}
233253
234254static CDP1802_INTERFACE( tmc2000e_config )
r5705r5706
284304   MDRV_DRIVER_DATA(tmc2000e_state)
285305
286306   // basic system hardware
287
288307   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_1_75MHz)
289308   MDRV_CPU_PROGRAM_MAP(tmc2000e_map)
290309   MDRV_CPU_IO_MAP(tmc2000e_io_map)
r5705r5706
294313   MDRV_MACHINE_RESET(tmc2000e)
295314
296315   // video hardware
297
298316   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
299317   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
300318   MDRV_SCREEN_RAW_PARAMS(XTAL_1_75MHz, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START)
r5705r5706
302320   MDRV_PALETTE_LENGTH(8)
303321   MDRV_VIDEO_UPDATE(tmc2000e)
304322
305   MDRV_CDP1864_ADD(CDP1864_TAG, XTAL_1_75MHz, tmc2000e_cdp1864_intf)
306
307323   // sound hardware
308
309324   MDRV_SPEAKER_STANDARD_MONO("mono")
310   MDRV_SOUND_ADD("beep", BEEP, 0)
325   MDRV_CDP1864_ADD(CDP1864_TAG, XTAL_1_75MHz, tmc2000e_cdp1864_intf)
311326   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
312327
313   /* printer */
328   /* devices */
314329   MDRV_PRINTER_ADD("printer")
315
316330   MDRV_CASSETTE_ADD("cassette", tmc2000_cassette_config)
317331MACHINE_DRIVER_END
318332
r5705r5706
352366   CONFIG_DEVICE(tmc2000e_floppy_getinfo)
353367SYSTEM_CONFIG_END
354368
355/* Driver Initialization */
356
357static TIMER_CALLBACK(setup_beep)
358{
359   const device_config *speaker = devtag_get_device(machine, "beep");
360   beep_set_state(speaker, 0);
361   beep_set_frequency( speaker, 0 );
362}
363
364static DRIVER_INIT( tmc2000e )
365{
366   // enable power led
367   set_led_status(2, 1);
368
369   timer_set(machine, attotime_zero, NULL, 0, setup_beep);
370}
371
372//    YEAR  NAME      PARENT   COMPAT   MACHINE   INPUT     INIT        CONFIG    COMPANY        FULLNAME
373COMP( 1980, tmc2000e, 0,       0,       tmc2000e, tmc2000e, tmc2000e,   tmc2000e, "Telercas Oy", "Telmac 2000E", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
369//    YEAR  NAME      PARENT   COMPAT   MACHINE   INPUT     INIT    CONFIG    COMPANY        FULLNAME
370COMP( 1980, tmc2000e, 0,       0,       tmc2000e, tmc2000e, 0,      tmc2000e, "Telercas Oy", "Telmac 2000E", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team