Previous 15994 Revisions Next

r9413 Tuesday 19th October, 2010 at 11:49:27 UTC by Curt Coder
Refactored the CDP1869 chip into a C++ device.
Removed the old CDP1802 CPU.
[src/emu/cpu]cdp1802
[src/emu/cpu/cosmac]cosmac.c cosmac.h
[src/emu/drivers]xtal.h
[src/emu/sound]cdp1869.c cdp1869.h
[src/mess]mess.mak
[src/mess/drivers]comx35.c cosmicos.c pecom.c tmc600.c
[src/mess/includes]comx35.h cosmicos.h pecom.h tmc600.h
[src/mess/machine]comx35.c pecom.c
[src/mess/video]comx35.c pecom.c tmc600.c

src/emu/cpu/cosmac/cosmac.c
r9412r9413
555555//**************************************************************************
556556
557557//-------------------------------------------------
558//  get_memory_address - get current memory address
559//-------------------------------------------------
560
561offs_t cosmac_device::get_memory_address()
562{
563   // this is valid for INP/OUT opcodes
564   return R[X];
565}
566
567//-------------------------------------------------
558568//  execute_set_input -
559569//-------------------------------------------------
560570
src/emu/cpu/cosmac/cosmac.h
r9412r9413
189189
190190public:
191191   // public interfaces
192   offs_t get_memory_address();
192193
193194protected:
194195   // device-level overrides
src/emu/sound/cdp1869.c
r9412r9413
1#include "emu.h"
2#include "streams.h"
3#include "cpu/cosmac/cosmac.h"
4#include "sound/cdp1869.h"
1/**********************************************************************
52
3   RCA CDP1869/1870/1876 Video Interface System (VIS) emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
610/*
711
812    TODO:
913
10    - remove CDP1802 dependency
11    - sound base frequencies are TPA/TPB
1214    - white noise
1315    - scanline based update
1416    - CMSEL output
1517
1618*/
1719
18/***************************************************************************
19    PARAMETERS
20***************************************************************************/
20#include "emu.h"
21#include "cdp1869.h"
2122
22#define CDP1869_WEIGHT_RED      30 /* % of max luminance */
23
24
25//**************************************************************************
26//   MACROS / CONSTANTS
27//**************************************************************************
28
29#define LOG 0
30
31#define CDP1869_WEIGHT_RED      30 // % of max luminance
2332#define CDP1869_WEIGHT_GREEN   59
2433#define CDP1869_WEIGHT_BLUE      11
2534
r9412r9413
2938#define CDP1869_ROWS_FULL_PAL   25
3039#define CDP1869_ROWS_FULL_NTSC   24
3140
32/***************************************************************************
33    TYPE DEFINITIONS
34***************************************************************************/
35
3641enum
3742{
3843   CDB0 = 0,
r9412r9413
4550   CCB1
4651};
4752
48typedef struct _cdp1869_t cdp1869_t;
49struct _cdp1869_t
53
54
55//**************************************************************************
56//  GLOBAL VARIABLES
57//**************************************************************************
58
59// devices
60const device_type CDP1869 = cdp1869_device_config::static_alloc_device_config;
61
62
63// default address map
64static ADDRESS_MAP_START( cdp1869, 0, 8 )
65   AM_RANGE(0x000, 0x7ff) AM_RAM
66ADDRESS_MAP_END
67
68
69
70//**************************************************************************
71//  DEVICE CONFIGURATION
72//**************************************************************************
73
74//-------------------------------------------------
75//  cdp1869_device_config - constructor
76//-------------------------------------------------
77
78cdp1869_device_config::cdp1869_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
79   : device_config(mconfig, static_alloc_device_config, "RCA CDP1869", tag, owner, clock),
80     device_config_sound_interface(mconfig, *this),
81     device_config_memory_interface(mconfig, *this),
82     m_space_config("pageram", ENDIANNESS_LITTLE, 8, 11, 0, NULL, *ADDRESS_MAP_NAME(cdp1869))
5083{
51   devcb_resolved_read8      in_page_ram_func;
52   devcb_resolved_write8      out_page_ram_func;
53   devcb_resolved_write_line   out_prd_func;
54   devcb_resolved_read_line   in_pal_ntsc_func;
84}
5585
56   running_device *device;
57   const cdp1869_interface *intf;   /* interface */
58   screen_device *screen;   /* screen */
59   running_device *cpu;      /* CPU */
60   sound_stream *stream;         /* sound output */
61   int color_clock;
6286
63   /* video state */
64   int prd;                  /* predisplay */
65   int dispoff;               /* display off */
66   int fresvert;               /* full resolution vertical */
67   int freshorz;               /* full resolution horizontal */
68   int cmem;                  /* character memory access mode */
69   int dblpage;               /* double page mode */
70   int line16;                  /* 16-line hi-res mode */
71   int line9;                  /* 9 line mode */
72   int cfc;                  /* color format control */
73   UINT8 col;                  /* character color control */
74   UINT8 bkg;                  /* background color */
75   UINT16 pma;                  /* page memory address */
76   UINT16 hma;                  /* home memory address */
87//-------------------------------------------------
88//  static_alloc_device_config - allocate a new
89//  configuration object
90//-------------------------------------------------
7791
78   /* video timer */
79   emu_timer *prd_changed_timer;   /* predisplay changed timer */
92device_config *cdp1869_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
93{
94   return global_alloc(cdp1869_device_config(mconfig, tag, owner, clock));
95}
8096
81   /* sound state */
82   INT16 signal;               /* current signal */
83   int incr;                  /* initial wave state */
84   int toneoff;               /* tone off */
85   int wnoff;                  /* white noise off */
86   UINT8 tonediv;               /* tone divisor */
87   UINT8 tonefreq;               /* tone range select */
88   UINT8 toneamp;               /* tone output amplitude */
89   UINT8 wnfreq;               /* white noise range select */
90   UINT8 wnamp;               /* white noise output amplitude */
91};
9297
93/***************************************************************************
94    INLINE FUNCTIONS
95***************************************************************************/
98//-------------------------------------------------
99//  alloc_device - allocate a new device object
100//-------------------------------------------------
96101
97INLINE cdp1869_t *get_safe_token(running_device *device)
102device_t *cdp1869_device_config::alloc_device(running_machine &machine) const
98103{
99   assert(device != NULL);
100   return (cdp1869_t *)downcast<legacy_device_base *>(device)->token();
104   return auto_alloc(&machine, cdp1869_device(machine, *this));
101105}
102106
103/***************************************************************************
104    IMPLEMENTATION
105***************************************************************************/
106107
107#define CDP1869_IS_NTSC \
108   (!devcb_call_read_line(&cdp1869->in_pal_ntsc_func))
108//-------------------------------------------------
109//  memory_space_config - return a description of
110//  any address spaces owned by this device
111//-------------------------------------------------
109112
110/*-------------------------------------------------
111    update_prd_changed_timer - update predisplay
112    changed timer
113-------------------------------------------------*/
113const address_space_config *cdp1869_device_config::memory_space_config(int spacenum) const
114{
115   return (spacenum == 0) ? &m_space_config : NULL;
116}
114117
115static void update_prd_changed_timer(cdp1869_t *cdp1869)
118
119//-------------------------------------------------
120//  device_config_complete - perform any
121//  operations now that the configuration is
122//  complete
123//-------------------------------------------------
124
125void cdp1869_device_config::device_config_complete()
116126{
117   if (cdp1869->prd_changed_timer != NULL)
127   // inherit a copy of the static data
128   const cdp1869_interface *intf = reinterpret_cast<const cdp1869_interface *>(static_config());
129   if (intf != NULL)
130      *static_cast<cdp1869_interface *>(this) = *intf;
131
132   // or initialize to defaults if none provided
133   else
118134   {
119      attotime duration;
120      int start, end, level;
121      int scanline = cdp1869->screen->vpos();
122      int next_scanline;
135      memset(&in_pal_ntsc_func, 0, sizeof(in_pal_ntsc_func));
136      memset(&out_prd_func, 0, sizeof(out_prd_func));
137      in_pcb_func = NULL;
138      in_char_ram_func = NULL;
139      out_char_ram_func = NULL;
140   }
141}
123142
124      if (CDP1869_IS_NTSC)
125      {
126         start = CDP1869_SCANLINE_PREDISPLAY_START_NTSC;
127         end = CDP1869_SCANLINE_PREDISPLAY_END_NTSC;
128      }
129      else
130      {
131         start = CDP1869_SCANLINE_PREDISPLAY_START_PAL;
132         end = CDP1869_SCANLINE_PREDISPLAY_END_PAL;
133      }
134143
135      if (scanline < start)
136      {
137         next_scanline = start;
138         level = ASSERT_LINE;
139      }
140      else if (scanline < end)
141      {
142         next_scanline = end;
143         level = CLEAR_LINE;
144      }
145      else
146      {
147         next_scanline = start;
148         level = ASSERT_LINE;
149      }
150144
151      if (cdp1869->dispoff)
152      {
153         level = CLEAR_LINE;
154      }
145//**************************************************************************
146//  INLINE HELPERS
147//**************************************************************************
155148
156      duration = cdp1869->screen->time_until_pos(next_scanline);
157      timer_adjust_oneshot(cdp1869->prd_changed_timer, duration, level);
158   }
149//-------------------------------------------------
150//  is_ntsc - is device in NTSC mode
151//-------------------------------------------------
152
153inline bool cdp1869_device::is_ntsc()
154{
155   return devcb_call_read_line(&m_in_pal_ntsc_func) ? false : true;
159156}
160157
161/*-------------------------------------------------
162    TIMER_CALLBACK( prd_changed_tick )
163-------------------------------------------------*/
164158
165static TIMER_CALLBACK( prd_changed_tick )
159//-------------------------------------------------
160//  read_page_ram_byte - read a page RAM byte at
161//  the given address
162//-------------------------------------------------
163
164inline UINT8 cdp1869_device::read_page_ram_byte(offs_t pma)
166165{
167   running_device *device = (running_device *)ptr;
168   cdp1869_t *cdp1869 = get_safe_token(device);
166   return space()->read_byte(pma);
167}
169168
170   devcb_call_write_line(&cdp1869->out_prd_func, param);
171   cdp1869->prd = param;
172169
173   update_prd_changed_timer(cdp1869);
170//-------------------------------------------------
171//  write_page_ram_byte - write a page RAM byte at
172//  the given address
173//-------------------------------------------------
174
175inline void cdp1869_device::write_page_ram_byte(offs_t pma, UINT8 data)
176{
177   space()->write_byte(pma, data);
174178}
175179
176/*-------------------------------------------------
177    STATE_POSTLOAD( cdp1869_state_save_postload )
178-------------------------------------------------*/
179180
180static STATE_POSTLOAD( cdp1869_state_save_postload )
181//-------------------------------------------------
182//  read_char_ram_byte - read a char RAM byte at
183//  the given address
184//-------------------------------------------------
185
186inline UINT8 cdp1869_device::read_char_ram_byte(offs_t pma, offs_t cma, UINT8 pmd)
181187{
182   update_prd_changed_timer((cdp1869_t *)param);
188   UINT8 data = 0;
189
190   if (m_in_char_ram_func != NULL)
191   {
192      data = m_in_char_ram_func(this, pma, cma, pmd);
193   }
194
195   return data;
183196}
184197
185/*-------------------------------------------------
186    cdp1802_get_r_x - get CDP1802 R(X) value
187-------------------------------------------------*/
188198
189static UINT16 cdp1802_get_r_x(cdp1869_t *cdp1869)
199//-------------------------------------------------
200//  write_char_ram_byte - write a char RAM byte at
201//  the given address
202//-------------------------------------------------
203
204inline void cdp1869_device::write_char_ram_byte(offs_t pma, offs_t cma, UINT8 pmd, UINT8 data)
190205{
191   return cpu_get_reg(cdp1869->cpu, COSMAC_R0 + cpu_get_reg(cdp1869->cpu, COSMAC_X));
206   if (m_out_char_ram_func != NULL)
207   {
208      m_out_char_ram_func(this, pma, cma, pmd, data);
209   }
192210}
193211
194/*-------------------------------------------------
195    get_rgb - get RGB value
196-------------------------------------------------*/
197212
198static rgb_t get_rgb(int i, int c, int l)
213//-------------------------------------------------
214//  read_pcb - read page control bit
215//-------------------------------------------------
216
217inline int cdp1869_device::read_pcb(offs_t pma, offs_t cma, UINT8 pmd)
199218{
219   int pcb = 0;
220
221   if (m_in_pcb_func != NULL)
222   {
223      pcb = m_in_pcb_func(this, pma, cma, pmd);
224   }
225
226   return pcb;
227}
228
229
230//-------------------------------------------------
231//  update_prd_changed_timer -
232//-------------------------------------------------
233
234inline void cdp1869_device::update_prd_changed_timer()
235{
236   int start = CDP1869_SCANLINE_PREDISPLAY_START_PAL;
237   int end = CDP1869_SCANLINE_PREDISPLAY_END_PAL;
238   int next_state;
239   int scanline = m_screen->vpos();
240   int next_scanline;
241
242   if (is_ntsc())
243   {
244      start = CDP1869_SCANLINE_PREDISPLAY_START_NTSC;
245      end = CDP1869_SCANLINE_PREDISPLAY_END_NTSC;
246   }
247
248   if (scanline < start)
249   {
250      next_scanline = start;
251      next_state = ASSERT_LINE;
252   }
253   else if (scanline < end)
254   {
255      next_scanline = end;
256      next_state = CLEAR_LINE;
257   }
258   else
259   {
260      next_scanline = start;
261      next_state = ASSERT_LINE;
262   }
263
264   if (m_dispoff)
265   {
266      next_state = CLEAR_LINE;
267   }
268
269   attotime duration = m_screen->time_until_pos(next_scanline);
270   timer_adjust_oneshot(m_prd_timer, duration, next_state);
271}
272
273
274//-------------------------------------------------
275//  get_rgb - get RGB value
276//-------------------------------------------------
277
278inline rgb_t cdp1869_device::get_rgb(int i, int c, int l)
279{
200280   int luma = 0, r, g, b;
201281
202282   luma += (l & 4) ? CDP1869_WEIGHT_RED : 0;
r9412r9413
212292   return MAKE_RGB(r, g, b);
213293}
214294
215/*-------------------------------------------------
216    get_lines - get number of character lines
217-------------------------------------------------*/
218295
219static int get_lines(running_device *device)
296//-------------------------------------------------
297//   get_lines - get number of character lines
298//-------------------------------------------------
299
300inline int cdp1869_device::get_lines()
220301{
221   cdp1869_t *cdp1869 = get_safe_token(device);
222
223   if (cdp1869->line16 && !cdp1869->dblpage)
302   if (m_line16 && !m_dblpage)
224303   {
225304      return 16;
226305   }
227   else if (!cdp1869->line9)
306   else if (!m_line9)
228307   {
229308      return 9;
230309   }
r9412r9413
234313   }
235314}
236315
237/*-------------------------------------------------
238    get_pmemsize - get page memory size
239-------------------------------------------------*/
240316
241static UINT16 get_pmemsize(running_device *device, int cols, int rows)
317//-------------------------------------------------
318//   get_pmemsize - get page memory size
319//-------------------------------------------------
320
321inline UINT16 cdp1869_device::get_pmemsize(int cols, int rows)
242322{
243   cdp1869_t *cdp1869 = get_safe_token(device);
244
245323   int pmemsize = cols * rows;
246324
247   if (cdp1869->dblpage) pmemsize *= 2;
248   if (cdp1869->line16) pmemsize *= 2;
325   if (m_dblpage) pmemsize *= 2;
326   if (m_line16) pmemsize *= 2;
249327
250328   return pmemsize;
251329}
252330
253/*-------------------------------------------------
254    get_pma - get page memory address
255-------------------------------------------------*/
256331
257static UINT16 get_pma(running_device *device)
332//-------------------------------------------------
333//   get_pma - get page memory address
334//-------------------------------------------------
335
336inline UINT16 cdp1869_device::get_pma()
258337{
259   cdp1869_t *cdp1869 = get_safe_token(device);
260
261   if (cdp1869->dblpage)
338   if (m_dblpage)
262339   {
263      return cdp1869->pma;
340      return m_pma;
264341   }
265342   else
266343   {
267      return cdp1869->pma & 0x3ff;
344      return m_pma & 0x3ff;
268345   }
269346}
270347
271/*-------------------------------------------------
272    get_pen - get pen for color bits
273-------------------------------------------------*/
274348
275static int get_pen(running_device *device, int ccb0, int ccb1, int pcb)
349//-------------------------------------------------
350//   get_pen - get pen for color bits
351//-------------------------------------------------
352
353inline int cdp1869_device::get_pen(int ccb0, int ccb1, int pcb)
276354{
277   cdp1869_t *cdp1869 = get_safe_token(device);
355   int r = 0, g = 0, b = 0;
278356
279   int r = 0, g = 0, b = 0, color;
280
281   switch (cdp1869->col)
357   switch (m_col)
282358   {
283359   case 0:
284360      r = ccb0;
r9412r9413
300376      break;
301377   }
302378
303   color = (r << 2) + (b << 1) + g;
379   int color = (r << 2) + (b << 1) + g;
304380
305   if (cdp1869->cfc)
381   if (m_cfc)
306382   {
307      return color + ((cdp1869->bkg + 1) * 8);
383      return color + ((m_bkg + 1) * 8);
308384   }
309385   else
310386   {
r9412r9413
312388   }
313389}
314390
315/*-------------------------------------------------
316    draw_line - draw character line
317-------------------------------------------------*/
318391
319static void draw_line(running_device *device, bitmap_t *bitmap, int x, int y, int data, int color)
392
393//**************************************************************************
394//  LIVE DEVICE
395//**************************************************************************
396
397//-------------------------------------------------
398//  cdp1869_device - constructor
399//-------------------------------------------------
400
401cdp1869_device::cdp1869_device(running_machine &_machine, const cdp1869_device_config &config)
402    : device_t(_machine, config),
403     device_sound_interface(_machine, config, *this),
404     device_memory_interface(_machine, config, *this),
405     m_stream(NULL),
406      m_config(config)
320407{
321   cdp1869_t *cdp1869 = get_safe_token(device);
322408
409}
410
411
412//-------------------------------------------------
413//  device_start - device-specific startup
414//-------------------------------------------------
415
416void cdp1869_device::device_start()
417{
418   // get the screen device
419   m_screen = m_machine.device<screen_device>(m_config.screen_tag);
420   assert(m_screen != NULL);
421
422   // resolve callbacks
423   devcb_resolve_read_line(&m_in_pal_ntsc_func, &m_config.in_pal_ntsc_func, this);
424   devcb_resolve_write_line(&m_out_prd_func, &m_config.out_prd_func, this);
425   m_in_pcb_func = m_config.in_pcb_func;
426   m_in_char_ram_func = m_config.in_char_ram_func;
427   m_out_char_ram_func = m_config.out_char_ram_func;
428
429   // allocate timers
430   m_prd_timer = device_timer_alloc(*this);
431   update_prd_changed_timer();
432
433   // initialize palette
434   initialize_palette();
435
436   // create sound stream
437   m_stream = stream_create(this, 0, 1, m_machine.sample_rate, this, static_stream_generate);
438
439   // register for state saving
440   state_save_register_device_item(this, 0, m_prd);
441   state_save_register_device_item(this, 0, m_dispoff);
442   state_save_register_device_item(this, 0, m_fresvert);
443   state_save_register_device_item(this, 0, m_freshorz);
444   state_save_register_device_item(this, 0, m_cmem);
445   state_save_register_device_item(this, 0, m_dblpage);
446   state_save_register_device_item(this, 0, m_line16);
447   state_save_register_device_item(this, 0, m_line9);
448   state_save_register_device_item(this, 0, m_cfc);
449   state_save_register_device_item(this, 0, m_col);
450   state_save_register_device_item(this, 0, m_bkg);
451   state_save_register_device_item(this, 0, m_pma);
452   state_save_register_device_item(this, 0, m_hma);
453   state_save_register_device_item(this, 0, m_signal);
454   state_save_register_device_item(this, 0, m_incr);
455   state_save_register_device_item(this, 0, m_toneoff);
456   state_save_register_device_item(this, 0, m_wnoff);
457   state_save_register_device_item(this, 0, m_tonediv);
458   state_save_register_device_item(this, 0, m_tonefreq);
459   state_save_register_device_item(this, 0, m_toneamp);
460   state_save_register_device_item(this, 0, m_wnfreq);
461   state_save_register_device_item(this, 0, m_wnamp);
462}
463
464
465//-------------------------------------------------
466//  device_post_load - device-specific post-load
467//-------------------------------------------------
468
469void cdp1869_device::device_post_load()
470{
471   update_prd_changed_timer();
472}
473
474
475//-------------------------------------------------
476//  device_timer - handler timer events
477//-------------------------------------------------
478
479void cdp1869_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
480{
481   devcb_call_write_line(&m_out_prd_func, param);
482   m_prd = param;
483
484   update_prd_changed_timer();
485}
486
487
488//-------------------------------------------------
489//  initialize_palette - initialize palette
490//-------------------------------------------------
491
492void cdp1869_device::initialize_palette()
493{
494   // color-on-color display (CFC=0)
323495   int i;
324496
497   for (i = 0; i < 8; i++)
498   {
499      palette_set_color(machine, i, get_rgb(i, i, 15));
500   }
501
502   // tone-on-tone display (CFC=1)
503   for (int c = 0; c < 8; c++)
504   {
505      for (int l = 0; l < 8; l++)
506      {
507         palette_set_color(machine, i, get_rgb(i, c, l));
508         i++;
509      }
510   }
511}
512
513
514//-------------------------------------------------
515//  stream_generate - handle update requests for
516//  our sound stream
517//-------------------------------------------------
518
519STREAM_UPDATE( cdp1869_device::static_stream_generate )
520{
521   reinterpret_cast<cdp1869_device *>(param)->stream_generate(inputs, outputs, samples);
522}
523
524void cdp1869_device::stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples)
525{
526   // reset the output stream
527   memset(outputs[0], 0, samples * sizeof(*outputs[0]));
528
529   INT16 signal = m_signal;
530   stream_sample_t *buffer = outputs[0];
531
532   if (!m_toneoff && m_toneamp)
533   {
534      double frequency = (clock() / 2) / (512 >> m_tonefreq) / (m_tonediv + 1);
535//      double amplitude = m_toneamp * ((0.78*5) / 15);
536
537      int rate = m_machine.sample_rate / 2;
538
539      /* get progress through wave */
540      int incr = m_incr;
541
542      if (signal < 0)
543      {
544         signal = -(m_toneamp * (0x07fff / 15));
545      }
546      else
547      {
548         signal = m_toneamp * (0x07fff / 15);
549      }
550
551      while( samples-- > 0 )
552      {
553         *buffer++ = signal;
554         incr -= frequency;
555         while( incr < 0 )
556         {
557            incr += rate;
558            signal = -signal;
559         }
560      }
561
562      /* store progress through wave */
563      m_incr = incr;
564      m_signal = signal;
565   }
566/*
567    if (!m_wnoff)
568    {
569        double amplitude = m_wnamp * ((0.78*5) / 15);
570
571        for (int wndiv = 0; wndiv < 128; wndiv++)
572        {
573            double frequency = (clock() / 2) / (4096 >> m_wnfreq) / (wndiv + 1):
574
575            sum_square_wave(buffer, frequency, amplitude);
576        }
577    }
578*/
579
580}
581
582
583//-------------------------------------------------
584//   draw_line - draw character line
585//-------------------------------------------------
586
587void cdp1869_device::draw_line(bitmap_t *bitmap, const rectangle *rect, int x, int y, UINT8 data, int color)
588{
589   int i;
590
325591   data <<= 2;
326592
327593   for (i = 0; i < CDP1869_CHAR_WIDTH; i++)
r9412r9413
330596      {
331597         *BITMAP_ADDR16(bitmap, y, x) = color;
332598
333         if (!cdp1869->fresvert)
599         if (!m_fresvert)
334600         {
335601            *BITMAP_ADDR16(bitmap, y + 1, x) = color;
336602         }
337603
338         if (!cdp1869->freshorz)
604         if (!m_freshorz)
339605         {
340606            *BITMAP_ADDR16(bitmap, y, x + 1) = color;
341607
342            if (!cdp1869->fresvert)
608            if (!m_fresvert)
343609            {
344610               *BITMAP_ADDR16(bitmap, y + 1, x + 1) = color;
345611            }
346612         }
347613      }
348614
349      if (!cdp1869->freshorz)
615      if (!m_freshorz)
350616      {
351617         x++;
352618      }
r9412r9413
357623   }
358624}
359625
360/*-------------------------------------------------
361    draw_char - draw character
362-------------------------------------------------*/
363626
364static void draw_char(running_device *device, bitmap_t *bitmap, int x, int y, UINT16 pma, const rectangle *screenrect)
627//-------------------------------------------------
628//   draw_char - draw character
629//-------------------------------------------------
630
631void cdp1869_device::draw_char(bitmap_t *bitmap, const rectangle *rect, int x, int y, UINT16 pma)
365632{
366   cdp1869_t *cdp1869 = get_safe_token(device);
633   UINT8 pmd = read_page_ram_byte(pma);
367634
368   UINT8 cma = 0;
369
370   for (cma = 0; cma < get_lines(device); cma++)
635   for (UINT8 cma = 0; cma < get_lines(); cma++)
371636   {
372      UINT8 data = cdp1869->intf->char_ram_r(device, pma, cma);
637      UINT8 data = read_char_ram_byte(pma, cma, pmd);
373638
374639      int ccb0 = BIT(data, CCB0);
375640      int ccb1 = BIT(data, CCB1);
376      int pcb = BIT(cdp1869->intf->pcb_r(device, pma, cma), 0);
641      int pcb = read_pcb(pma, cma, pmd);
377642
378      int color = get_pen(device, ccb0, ccb1, pcb);
643      int color = get_pen(ccb0, ccb1, pcb);
379644
380      draw_line(device, bitmap, screenrect->min_x + x, screenrect->min_y + y, data, color);
645      draw_line(bitmap, rect, rect->min_x + x, rect->min_y + y, data, color);
381646
382647      y++;
383648
384      if (!cdp1869->fresvert)
649      if (!m_fresvert)
385650      {
386651         y++;
387652      }
388653   }
389654}
390655
391/*-------------------------------------------------
392    PALETTE_INIT( cdp1869 )
393-------------------------------------------------*/
394656
395PALETTE_INIT( cdp1869 )
396{
397   int i, c, l;
657//-------------------------------------------------
658//  out3_w - register 3 write
659//-------------------------------------------------
398660
399   /* color-on-color display (CFC=0) */
400   for (i = 0; i < 8; i++)
401   {
402      palette_set_color(machine, i, get_rgb(i, i, 15));
403   }
404
405   /* tone-on-tone display (CFC=1) */
406   for (c = 0; c < 8; c++)
407   {
408      for (l = 0; l < 8; l++)
409      {
410         palette_set_color(machine, i, get_rgb(i, c, l));
411         i++;
412      }
413   }
414}
415
416/*-------------------------------------------------
417    cdp1869_out3_w - register 3 write
418-------------------------------------------------*/
419
420WRITE8_DEVICE_HANDLER( cdp1869_out3_w )
661WRITE8_MEMBER( cdp1869_device::out3_w )
421662{
422663   /*
423664      bit   description
r9412r9413
432673        7   fres horz
433674    */
434675
435   cdp1869_t *cdp1869 = get_safe_token(device);
436
437   cdp1869->bkg = data & 0x07;
438   cdp1869->cfc = BIT(data, 3);
439   cdp1869->dispoff = BIT(data, 4);
440   cdp1869->col = (data & 0x60) >> 5;
441   cdp1869->freshorz = BIT(data, 7);
676   m_bkg = data & 0x07;
677   m_cfc = BIT(data, 3);
678   m_dispoff = BIT(data, 4);
679   m_col = (data & 0x60) >> 5;
680   m_freshorz = BIT(data, 7);
442681}
443682
444/*-------------------------------------------------
445    cdp1869_out4_w - register 4 write
446-------------------------------------------------*/
447683
448WRITE8_DEVICE_HANDLER( cdp1869_out4_w )
684//-------------------------------------------------
685//  out4_w - register 4 write
686//-------------------------------------------------
687
688WRITE8_MEMBER( cdp1869_device::out4_w )
449689{
450690   /*
451691      bit   description
r9412r9413
468708       15   always 0
469709    */
470710
471   cdp1869_t *cdp1869 = get_safe_token(device);
472   UINT16 word = cdp1802_get_r_x(cdp1869);
711   m_toneamp = offset & 0x0f;
712   m_tonefreq = (offset & 0x70) >> 4;
713   m_toneoff = BIT(offset, 7);
714   m_tonediv = (offset & 0x7f00) >> 8;
473715
474   cdp1869->toneamp = word & 0x0f;
475   cdp1869->tonefreq = (word & 0x70) >> 4;
476   cdp1869->toneoff = BIT(word, 7);
477   cdp1869->tonediv = (word & 0x7f00) >> 8;
716   stream_update(m_stream);
478717}
479718
480/*-------------------------------------------------
481    cdp1869_out5_w - register 5 write
482-------------------------------------------------*/
483719
484WRITE8_DEVICE_HANDLER( cdp1869_out5_w )
720//-------------------------------------------------
721//  out5_w - register 5 write
722//-------------------------------------------------
723
724WRITE8_MEMBER( cdp1869_device::out5_w )
485725{
486726   /*
487727      bit   description
r9412r9413
504744       15   wn off
505745    */
506746
507   cdp1869_t *cdp1869 = get_safe_token(device);
508   UINT16 word = cdp1802_get_r_x(cdp1869);
747   m_cmem = BIT(offset, 0);
748   m_line9 = BIT(offset, 3);
749   m_line16 = BIT(offset, 5);
750   m_dblpage = BIT(offset, 6);
751   m_fresvert = BIT(offset, 7);
752   m_wnamp = (offset & 0x0f00) >> 8;
753   m_wnfreq = (offset & 0x7000) >> 12;
754   m_wnoff = BIT(offset, 15);
509755
510   cdp1869->cmem = BIT(word, 0);
511   cdp1869->line9 = BIT(word, 3);
756   stream_update(m_stream);
512757
513   if (CDP1869_IS_NTSC)
758   if (m_cmem)
514759   {
515      cdp1869->line16 = BIT(word, 5);
760      m_pma = offset;
516761   }
517
518   cdp1869->dblpage = BIT(word, 6);
519   cdp1869->fresvert = BIT(word, 7);
520
521   cdp1869->wnamp = (word & 0x0f00) >> 8;
522   cdp1869->wnfreq = (word & 0x7000) >> 12;
523   cdp1869->wnoff = BIT(word, 15);
524
525   if (cdp1869->cmem)
526   {
527      cdp1869->pma = word;
528   }
529762   else
530763   {
531      cdp1869->pma = 0;
764      m_pma = 0;
532765   }
533766}
534767
535/*-------------------------------------------------
536    cdp1869_out6_w - register 6 write
537-------------------------------------------------*/
538768
539WRITE8_DEVICE_HANDLER( cdp1869_out6_w )
769//-------------------------------------------------
770//  out6_w - register 6 write
771//-------------------------------------------------
772
773WRITE8_MEMBER( cdp1869_device::out6_w )
540774{
541775   /*
542776      bit   description
r9412r9413
559793       15   x
560794    */
561795
562   cdp1869_t *cdp1869 = get_safe_token(device);
563   UINT16 word = cdp1802_get_r_x(cdp1869);
564
565   cdp1869->pma = word & 0x7ff;
796   m_pma = offset & 0x7ff;
566797}
567798
568/*-------------------------------------------------
569    cdp1869_out7_w - register 7 write
570-------------------------------------------------*/
571799
572WRITE8_DEVICE_HANDLER( cdp1869_out7_w )
800//-------------------------------------------------
801//  out7_w - register 7 write
802//-------------------------------------------------
803
804WRITE8_MEMBER( cdp1869_device::out7_w )
573805{
574806   /*
575807      bit   description
r9412r9413
592824       15   x
593825    */
594826
595   cdp1869_t *cdp1869 = get_safe_token(device);
596   UINT16 word = cdp1802_get_r_x(cdp1869);
597
598   cdp1869->hma = word & 0x7fc;
827   m_hma = offset & 0x7fc;
599828}
600829
601/*-------------------------------------------------
602    cdp1869_pageram_r - page memory read
603-------------------------------------------------*/
604830
605READ8_DEVICE_HANDLER( cdp1869_pageram_r )
831//-------------------------------------------------
832//  char_ram_r - character RAM read
833//-------------------------------------------------
834
835READ8_MEMBER( cdp1869_device::char_ram_r )
606836{
607   cdp1869_t *cdp1869 = get_safe_token(device);
608
837   UINT8 cma = offset & 0x0f;
609838   UINT16 pma;
610839
611   if (cdp1869->cmem)
840   if (m_cmem)
612841   {
613      pma = get_pma(device);
842      pma = get_pma();
614843   }
615844   else
616845   {
617846      pma = offset;
618847   }
619848
620   return devcb_call_read8(&cdp1869->in_page_ram_func, pma);
849   if (m_dblpage)
850   {
851      cma &= 0x07;
852   }
853
854   UINT8 pmd = read_page_ram_byte(pma);
855
856   return read_char_ram_byte(pma, cma, pmd);
621857}
622858
623/*-------------------------------------------------
624    cdp1869_pageram_w - page memory write
625-------------------------------------------------*/
626859
627WRITE8_DEVICE_HANDLER( cdp1869_pageram_w )
860//-------------------------------------------------
861//  char_ram_w - character RAM write
862//-------------------------------------------------
863
864WRITE8_MEMBER( cdp1869_device::char_ram_w )
628865{
629   cdp1869_t *cdp1869 = get_safe_token(device);
630
866   UINT8 cma = offset & 0x0f;
631867   UINT16 pma;
632868
633   if (cdp1869->cmem)
869   if (m_cmem)
634870   {
635      pma = get_pma(device);
871      pma = get_pma();
636872   }
637873   else
638874   {
639875      pma = offset;
640876   }
641877
642   devcb_call_write8(&cdp1869->out_page_ram_func, pma, data);
878   if (m_dblpage)
879   {
880      cma &= 0x07;
881   }
882
883   UINT8 pmd = read_page_ram_byte(pma);
884
885   write_char_ram_byte(pma, cma, pmd, data);
643886}
644887
645/*-------------------------------------------------
646    cdp1869_charram_r - character memory read
647-------------------------------------------------*/
648888
649READ8_DEVICE_HANDLER( cdp1869_charram_r )
889//-------------------------------------------------
890//  page_ram_r - page RAM read
891//-------------------------------------------------
892
893READ8_MEMBER( cdp1869_device::page_ram_r )
650894{
651   cdp1869_t *cdp1869 = get_safe_token(device);
652
653   UINT8 cma = offset & 0x0f;
654895   UINT16 pma;
655896
656   if (cdp1869->cmem)
897   if (m_cmem)
657898   {
658      pma = get_pma(device);
899      pma = get_pma();
659900   }
660901   else
661902   {
662903      pma = offset;
663904   }
664905
665   if (cdp1869->dblpage)
666   {
667      cma &= 0x07;
668   }
669
670   return cdp1869->intf->char_ram_r(device, pma, cma);
906   return read_page_ram_byte(pma);
671907}
672908
673/*-------------------------------------------------
674    cdp1869_charram_w - character memory write
675-------------------------------------------------*/
676909
677WRITE8_DEVICE_HANDLER( cdp1869_charram_w )
910//-------------------------------------------------
911//  page_ram_w - page RAM write
912//-------------------------------------------------
913
914WRITE8_MEMBER( cdp1869_device::page_ram_w )
678915{
679   cdp1869_t *cdp1869 = get_safe_token(device);
680
681   UINT8 cma = offset & 0x0f;
682916   UINT16 pma;
683917
684   if (cdp1869->cmem)
918   if (m_cmem)
685919   {
686      pma = get_pma(device);
920      pma = get_pma();
687921   }
688922   else
689923   {
690924      pma = offset;
691925   }
692926
693   if (cdp1869->dblpage)
694   {
695      cma &= 0x07;
696   }
697
698   if (cdp1869->intf->char_ram_w)
699   {
700      cdp1869->intf->char_ram_w(device, pma, cma, data);
701   }
927   write_page_ram_byte(pma, data);
702928}
703929
704/*-------------------------------------------------
705    cdp1869_predisplay_r - predisplay read
706-------------------------------------------------*/
707930
708READ_LINE_DEVICE_HANDLER( cdp1869_predisplay_r )
931//-------------------------------------------------
932//  page_ram_w - predisplay
933//-------------------------------------------------
934
935READ_LINE_MEMBER( cdp1869_device::predisplay_r )
709936{
710   cdp1869_t *cdp1869 = get_safe_token(device);
711
712   return cdp1869->prd;
937   return m_prd;
713938}
714939
715/*-------------------------------------------------
716    cdp1869_pal_ntsc_r - PAL/NTSC read
717-------------------------------------------------*/
718940
719READ_LINE_DEVICE_HANDLER( cdp1869_pal_ntsc_r )
941//-------------------------------------------------
942//  pal_ntsc_r - PAL/NTSC
943//-------------------------------------------------
944
945READ_LINE_MEMBER( cdp1869_device::pal_ntsc_r )
720946{
721   cdp1869_t *cdp1869 = get_safe_token(device);
722
723   return devcb_call_read_line(&cdp1869->in_pal_ntsc_func);
947   return devcb_call_read_line(&m_in_pal_ntsc_func);
724948}
725949
726/*-------------------------------------------------
727    cdp1869_update - screen update
728-------------------------------------------------*/
729950
730void cdp1869_update(running_device *device, bitmap_t *bitmap, const rectangle *cliprect)
951//-------------------------------------------------
952//  update_screen - update screen
953//-------------------------------------------------
954
955void cdp1869_device::update_screen(bitmap_t *bitmap, const rectangle *cliprect)
731956{
732   cdp1869_t *cdp1869 = get_safe_token(device);
733
734957   rectangle screen_rect, outer;
735958
736   if (CDP1869_IS_NTSC)
959   if (is_ntsc())
737960   {
738961      outer.min_x = CDP1869_HBLANK_END;
739962      outer.max_x = CDP1869_HBLANK_START - 1;
r9412r9413
757980   }
758981
759982   sect_rect(&outer, cliprect);
760   bitmap_fill(bitmap, &outer, device->machine->pens[cdp1869->bkg]);
983   bitmap_fill(bitmap, &outer, m_bkg);
761984
762   if (!cdp1869->dispoff)
985   if (!m_dispoff)
763986   {
764      int sx, sy, rows, cols, width, height;
765      UINT16 addr, pmemsize;
987      int width = CDP1869_CHAR_WIDTH;
988      int height = get_lines();
766989
767      width = CDP1869_CHAR_WIDTH;
768      height = get_lines(device);
769
770      if (!cdp1869->freshorz)
990      if (!m_freshorz)
771991      {
772992         width *= 2;
773993      }
774994
775      if (!cdp1869->fresvert)
995      if (!m_fresvert)
776996      {
777997         height *= 2;
778998      }
779999
780      cols = cdp1869->freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF;
781      rows = (screen_rect.max_y - screen_rect.min_y + 1) / height;
1000      int cols = m_freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF;
1001      int rows = (screen_rect.max_y - screen_rect.min_y + 1) / height;
7821002
783      pmemsize = get_pmemsize(device, cols, rows);
1003      UINT16 pmemsize = get_pmemsize(cols, rows);
1004      UINT16 addr = m_hma;
7841005
785      addr = cdp1869->hma;
786
787      for (sy = 0; sy < rows; sy++)
1006      for (int sy = 0; sy < rows; sy++)
7881007      {
789         for (sx = 0; sx < cols; sx++)
1008         for (int sx = 0; sx < cols; sx++)
7901009         {
7911010            int x = sx * width;
7921011            int y = sy * height;
7931012
794            draw_char(device, bitmap, x, y, addr, &screen_rect);
795
1013            draw_char(bitmap, &screen_rect, x, y, addr);
1014           
7961015            addr++;
7971016
7981017            if (addr == pmemsize) addr = 0;
r9412r9413
8001019      }
8011020   }
8021021}
803
804/*-------------------------------------------------
805    STREAM_UPDATE( cdp1869_stream_update )
806-------------------------------------------------*/
807
808static STREAM_UPDATE( cdp1869_stream_update )
809{
810   cdp1869_t *cdp1869 = (cdp1869_t *)param;
811   INT16 signal = cdp1869->signal;
812   stream_sample_t *buffer = outputs[0];
813
814   memset( buffer, 0, samples * sizeof(*buffer) );
815
816   if (!cdp1869->toneoff && cdp1869->toneamp)
817   {
818      double frequency = (cdp1869->device->clock() / 2) / (512 >> cdp1869->tonefreq) / (cdp1869->tonediv + 1);
819//      double amplitude = cdp1869->toneamp * ((0.78*5) / 15);
820
821      int rate = cdp1869->device->machine->sample_rate / 2;
822
823      /* get progress through wave */
824      int incr = cdp1869->incr;
825
826      if (signal < 0)
827      {
828         signal = -(cdp1869->toneamp * (0x07fff / 15));
829      }
830      else
831      {
832         signal = cdp1869->toneamp * (0x07fff / 15);
833      }
834
835      while( samples-- > 0 )
836      {
837         *buffer++ = signal;
838         incr -= frequency;
839         while( incr < 0 )
840         {
841            incr += rate;
842            signal = -signal;
843         }
844      }
845
846      /* store progress through wave */
847      cdp1869->incr = incr;
848      cdp1869->signal = signal;
849   }
850/*
851    if (!cdp1869->wnoff)
852    {
853        double amplitude = cdp1869->wnamp * ((0.78*5) / 15);
854
855        for (int wndiv = 0; wndiv < 128; wndiv++)
856        {
857            double frequency = (cdp1869->clock / 2) / (4096 >> cdp1869->wnfreq) / (wndiv + 1):
858
859            sum_square_wave(buffer, frequency, amplitude);
860        }
861    }
862*/
863}
864
865/*-------------------------------------------------
866    DEVICE_START( cdp1869 )
867-------------------------------------------------*/
868
869static DEVICE_START( cdp1869 )
870{
871   cdp1869_t *cdp1869 = get_safe_token(device);
872
873   /* validate arguments */
874   cdp1869->intf = (const cdp1869_interface *)device->baseconfig().static_config();
875
876   assert(cdp1869->intf->pcb_r != NULL);
877   assert(cdp1869->intf->char_ram_r != NULL);
878
879   /* resolve callbacks */
880   devcb_resolve_read8(&cdp1869->in_page_ram_func, &cdp1869->intf->in_page_ram_func, device);
881   devcb_resolve_write8(&cdp1869->out_page_ram_func, &cdp1869->intf->out_page_ram_func, device);
882   devcb_resolve_write_line(&cdp1869->out_prd_func, &cdp1869->intf->out_prd_func, device);
883   devcb_resolve_read_line(&cdp1869->in_pal_ntsc_func, &cdp1869->intf->in_pal_ntsc_func, device);
884
885   /* set initial values */
886   cdp1869->device = device;
887   cdp1869->stream = stream_create(device, 0, 1, device->machine->sample_rate, cdp1869, cdp1869_stream_update);
888   cdp1869->incr = 0;
889   cdp1869->signal = 0x07fff;
890   cdp1869->toneoff = 1;
891   cdp1869->wnoff = 1;
892
893   /* get the screen device */
894   cdp1869->screen = downcast<screen_device *>(device->machine->device(cdp1869->intf->screen_tag));
895   assert(cdp1869->screen != NULL);
896
897   /* get the CPU device */
898   cdp1869->cpu = device->machine->device(cdp1869->intf->cpu_tag);
899   assert(cdp1869->cpu != NULL);
900
901   /* allocate predisplay timer */
902   cdp1869->prd_changed_timer = timer_alloc(device->machine, prd_changed_tick, (void *)device);
903   update_prd_changed_timer(cdp1869);
904
905   /* register for state saving */
906   state_save_register_postload(device->machine, cdp1869_state_save_postload, cdp1869);
907
908   state_save_register_device_item(device, 0, cdp1869->prd);
909   state_save_register_device_item(device, 0, cdp1869->dispoff);
910   state_save_register_device_item(device, 0, cdp1869->fresvert);
911   state_save_register_device_item(device, 0, cdp1869->freshorz);
912   state_save_register_device_item(device, 0, cdp1869->cmem);
913   state_save_register_device_item(device, 0, cdp1869->dblpage);
914   state_save_register_device_item(device, 0, cdp1869->line16);
915   state_save_register_device_item(device, 0, cdp1869->line9);
916   state_save_register_device_item(device, 0, cdp1869->cfc);
917   state_save_register_device_item(device, 0, cdp1869->col);
918   state_save_register_device_item(device, 0, cdp1869->bkg);
919   state_save_register_device_item(device, 0, cdp1869->pma);
920   state_save_register_device_item(device, 0, cdp1869->hma);
921
922   state_save_register_device_item(device, 0, cdp1869->signal);
923   state_save_register_device_item(device, 0, cdp1869->incr);
924   state_save_register_device_item(device, 0, cdp1869->toneoff);
925   state_save_register_device_item(device, 0, cdp1869->wnoff);
926   state_save_register_device_item(device, 0, cdp1869->tonediv);
927   state_save_register_device_item(device, 0, cdp1869->tonefreq);
928   state_save_register_device_item(device, 0, cdp1869->toneamp);
929   state_save_register_device_item(device, 0, cdp1869->wnfreq);
930   state_save_register_device_item(device, 0, cdp1869->wnamp);
931}
932
933/*-------------------------------------------------
934    DEVICE_GET_INFO( cdp1869 )
935-------------------------------------------------*/
936
937DEVICE_GET_INFO( cdp1869 )
938{
939   switch (state)
940   {
941      /* --- the following bits of info are returned as 64-bit signed integers --- */
942      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cdp1869_t);            break;
943
944      /* --- the following bits of info are returned as pointers to data or functions --- */
945      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cdp1869);   break;
946      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
947      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
948
949      /* --- the following bits of info are returned as NULL-terminated strings --- */
950      case DEVINFO_STR_NAME:                     strcpy(info->s, "RCA CDP1869");            break;
951      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "RCA CDP1800");            break;
952      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
953      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
954      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
955   }
956}
957
958
959DEFINE_LEGACY_SOUND_DEVICE(CDP1869, cdp1869);
src/emu/sound/cdp1869.h
r9412r9413
1/*
1/**********************************************************************
22
3    RCA CDP1869/70/76 Video Interface System (VIS)
3   RCA CDP1869/1870/1876 Video Interface System (VIS) emulation
44
5    http://homepage.mac.com/ruske/cosmacelf/cdp1869.pdf
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
67
7                        ________________                                            ________________
8           TPA   1  ---|       \/       |---  40  Vdd          PREDISPLAY_   1  ---|       \/       |---  40  Vdd
9           TPB   2  ---|                |---  39  PMSEL          *DISPLAY_   2  ---|                |---  39  PAL/NTSC_
10          MRD_   3  ---|                |---  38  PMWR_                PCB   3  ---|                |---  38  CPUCLK
11          MWR_   4  ---|                |---  37  *CMSEL              CCB1   4  ---|                |---  37  XTAL (DOT)
12         MA0/8   5  ---|                |---  36  CMWR_               BUS7   5  ---|                |---  36  XTAL (DOT)_
13         MA1/9   6  ---|                |---  35  PMA0                CCB0   6  ---|                |---  35  *ADDRSTB_
14        MA2/10   7  ---|                |---  34  PMA1                BUS6   7  ---|                |---  34  MRD_
15        MA3/11   8  ---|                |---  33  PMA2                CDB5   8  ---|                |---  33  TPB
16        MA4/12   9  ---|                |---  32  PMA3                BUS5   9  ---|                |---  32  *CMSEL
17        MA5/13  10  ---|    CDP1869C    |---  31  PMA4                CDB4  10  ---|  CDP1870/76C   |---  31  BURST
18        MA6/14  11  ---|    top view    |---  30  PMA5                BUS4  11  ---|    top view    |---  30  *H SYNC_
19        MA7/15  12  ---|                |---  29  PMA6                CDB3  12  ---|                |---  29  COMPSYNC_
20            N0  13  ---|                |---  28  PMA7                BUS3  13  ---|                |---  28  LUM / (RED)^
21            N1  14  ---|                |---  27  PMA8                CDB2  14  ---|                |---  27  PAL CHROM / (BLUE)^
22            N2  15  ---|                |---  26  PMA9                BUS2  15  ---|                |---  26  NTSC CHROM / (GREEN)^
23      *H SYNC_  16  ---|                |---  25  CMA3/PMA10          CDB1  16  ---|                |---  25  XTAL_ (CHROM)
24     *DISPLAY_  17  ---|                |---  24  CMA2                BUS1  17  ---|                |---  24  XTAL (CHROM)
25     *ADDRSTB_  18  ---|                |---  23  CMA1                CDB0  18  ---|                |---  23  EMS_
26         SOUND  19  ---|                |---  22  CMA0                BUS0  19  ---|                |---  22  EVS_
27           VSS  20  ---|________________|---  21  *N=3_                Vss  20  ---|________________|---  21  *N=3_
8**********************************************************************
9                            _____   _____
10                   TPA   1 |*    \_/     | 40  Vdd
11                   TPB   2 |             | 39  PMSEL
12                  _MRD   3 |             | 38  _PMWR
13                  _MWR   4 |             | 37  CMSEL
14                 MA0/8   5 |             | 36  _CMWR
15                 MA1/9   6 |             | 35  PMA0
16                MA2/10   7 |             | 34  PMA1
17                MA3/11   8 |             | 33  PMA2
18                MA4/12   9 |             | 32  PMA3
19                MA5/13  10 |             | 31  PMA4
20                MA6/14  11 |   CDP1869   | 30  PMA5
21                MA7/15  12 |             | 29  PMA6
22                    N0  13 |             | 28  PMA7
23                    N1  14 |             | 27  PMA8
24                    N2  15 |             | 26  PMA9
25               _H SYNC  16 |             | 25  CMA3/PMA10
26              _DISPLAY  17 |             | 24  CMA2
27              _ADDRSTB  18 |             | 23  CMA1
28                 SOUND  19 |             | 22  CMA0
29                   Vss  20 |_____________| 21  _N=3
2830
31                            _____   _____
32           _PREDISPLAY   1 |*    \_/     | 40  Vdd
33              _DISPLAY   2 |             | 39  PAL/_NTSC
34                   PCB   3 |             | 38  CPUCLK
35                  CCB1   4 |             | 37  XTAL (DOT)
36                  BUS7   5 |             | 36  _XTAL (DOT)
37                  CCB0   6 |             | 35  _ADDRSTB
38                  BUS6   7 |             | 34  _MRD
39                  CDB5   8 |             | 33  TPB
40                  BUS5   9 |             | 32  CMSEL
41                  CDB4  10 |             | 31  BURST
42                  BUS4  11 |   CDP1870   | 30  _H SYNC
43                  CDB3  12 |             | 29  _COMPSYNC
44                  BUS3  13 |             | 28  LUM
45                  CDB2  14 |             | 27  PAL CHROM
46                  BUS2  15 |             | 26  NTSC CHROM
47                  CDB1  16 |             | 25  _XTAL (CHROM)
48                  BUS1  17 |             | 24  XTAL (CHROM)
49                  CDB0  18 |             | 23  _EMS
50                  BUS0  19 |             | 22  _EVS
51                   Vss  20 |_____________| 21  _N=3
2952
30                 * = INTERCHIP CONNECTIONS      ^ = FOR THE RGB BOND-OUT OPTION (CDP1876C)      _ = ACTIVE LOW
53                            _____   _____
54           _PREDISPLAY   1 |*    \_/     | 40  Vdd
55              _DISPLAY   2 |             | 39  PAL/_NTSC
56                   PCB   3 |             | 38  CPUCLK
57                  CCB1   4 |             | 37  XTAL (DOT)
58                  BUS7   5 |             | 36  _XTAL (DOT)
59                  CCB0   6 |             | 35  _ADDRSTB
60                  BUS6   7 |             | 34  _MRD
61                  CDB5   8 |             | 33  TPB
62                  BUS5   9 |             | 32  CMSEL
63                  CDB4  10 |             | 31  BURST
64                  BUS4  11 |   CDP1876   | 30  _H SYNC
65                  CDB3  12 |             | 29  _COMPSYNC
66                  BUS3  13 |             | 28  RED
67                  CDB2  14 |             | 27  BLUE
68                  BUS2  15 |             | 26  GREEN
69                  CDB1  16 |             | 25  _XTAL (CHROM)
70                  BUS1  17 |             | 24  XTAL (CHROM)
71                  CDB0  18 |             | 23  _EMS
72                  BUS0  19 |             | 22  _EVS
73                   Vss  20 |_____________| 21  _N=3
3174
32*/
75**********************************************************************/
3376
77#pragma once
78
3479#ifndef __CDP1869__
3580#define __CDP1869__
3681
37#include "devlegcy.h"
82#include "emu.h"
3883
3984
40/***************************************************************************
41    MACROS / CONSTANTS
42***************************************************************************/
4385
44#define CDP1869_DOT_CLK_PAL         5626000.0
45#define CDP1869_DOT_CLK_NTSC      5670000.0
46#define CDP1869_COLOR_CLK_PAL      8867236.0
47#define CDP1869_COLOR_CLK_NTSC      7159090.0
86//**************************************************************************
87//   MACROS / CONSTANTS
88//**************************************************************************
4889
90#define CDP1869_DOT_CLK_PAL         (float)XTAL_5_626MHz
91#define CDP1869_DOT_CLK_NTSC      (float)XTAL_5_67MHz
92#define CDP1869_COLOR_CLK_PAL      (float)XTAL_8_867236MHz
93#define CDP1869_COLOR_CLK_NTSC      (float)XTAL_7_15909MHz
94
4995#define CDP1869_CPU_CLK_PAL         (CDP1869_DOT_CLK_PAL / 2)
5096#define CDP1869_CPU_CLK_NTSC      (CDP1869_DOT_CLK_NTSC / 2)
5197
r9412r9413
85131
86132#define   CDP1869_PALETTE_LENGTH   8+64
87133
88DECLARE_LEGACY_SOUND_DEVICE(CDP1869, cdp1869);
89134
90#define MDRV_CDP1869_ADD(_tag, _pixclock, _config) \
135
136//**************************************************************************
137//  INTERFACE CONFIGURATION MACROS
138//**************************************************************************
139
140#define MDRV_CDP1869_ADD(_tag, _pixclock, _config, _map) \
91141   MDRV_DEVICE_ADD(_tag, CDP1869, _pixclock) \
92   MDRV_DEVICE_CONFIG(_config)
142   MDRV_DEVICE_CONFIG(_config) \
143   MDRV_DEVICE_ADDRESS_MAP(0, _map)
93144
94145#define MDRV_CDP1869_SCREEN_PAL_ADD(_tag, _clock) \
95146   MDRV_SCREEN_ADD(_tag, RASTER) \
96147   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) \
97148   MDRV_SCREEN_RAW_PARAMS(_clock, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL) \
98   MDRV_PALETTE_LENGTH(8+64) \
99   MDRV_PALETTE_INIT(cdp1869)
149   MDRV_PALETTE_LENGTH(8+64)
100150
101151#define MDRV_CDP1869_SCREEN_NTSC_ADD(_tag, _clock) \
102152   MDRV_SCREEN_ADD(_tag, RASTER) \
103153   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) \
104154   MDRV_SCREEN_RAW_PARAMS(_clock, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_NTSC, CDP1869_SCANLINE_VBLANK_END_NTSC, CDP1869_SCANLINE_VBLANK_START_NTSC) \
105   MDRV_PALETTE_LENGTH(8+64) \
106   MDRV_PALETTE_INIT(cdp1869)
155   MDRV_PALETTE_LENGTH(8+64)
107156
108157#define CDP1869_INTERFACE(_name) \
109158   const cdp1869_interface (_name) =
110159
111#define CDP1869_CHAR_RAM_READ(name) UINT8 name(running_device *device, UINT16 pma, UINT8 cma)
112#define CDP1869_CHAR_RAM_WRITE(name) void name(running_device *device, UINT16 pma, UINT8 cma, UINT8 data)
113#define CDP1869_PCB_READ(name) int name(running_device *device, UINT16 pma, UINT8 cma)
160#define CDP1869_CHAR_RAM_READ(name) UINT8 name(running_device *device, UINT16 pma, UINT8 cma, UINT8 pmd)
161#define CDP1869_CHAR_RAM_WRITE(name) void name(running_device *device, UINT16 pma, UINT8 cma, UINT8 pmd, UINT8 data)
162#define CDP1869_PCB_READ(name) int name(running_device *device, UINT16 pma, UINT8 cma, UINT8 pmd)
114163
115164#define CDP1869_PAL \
116165   DEVCB_LINE_VCC
r9412r9413
118167#define CDP1869_NTSC \
119168   DEVCB_LINE_GND
120169
121/***************************************************************************
122    TYPE DEFINITIONS
123***************************************************************************/
124170
125typedef UINT8 (*cdp1869_char_ram_read_func)(running_device *device, UINT16 pma, UINT8 cma);
126typedef void (*cdp1869_char_ram_write_func)(running_device *device, UINT16 pma, UINT8 cma, UINT8 data);
127typedef int (*cdp1869_pcb_read_func)(running_device *device, UINT16 pma, UINT8 cma);
128171
129/* interface */
130typedef struct _cdp1869_interface cdp1869_interface;
131struct _cdp1869_interface
172//**************************************************************************
173//   TYPE DEFINITIONS
174//**************************************************************************
175
176typedef UINT8 (*cdp1869_char_ram_read_func)(running_device *device, UINT16 pma, UINT8 cma, UINT8 pmd);
177typedef void (*cdp1869_char_ram_write_func)(running_device *device, UINT16 pma, UINT8 cma, UINT8 pmd, UINT8 data);
178typedef int (*cdp1869_pcb_read_func)(running_device *device, UINT16 pma, UINT8 cma, UINT8 pmd);
179
180
181// ======================> cdp1869_interface
182
183struct cdp1869_interface
132184{
133   const char *cpu_tag;      /* CPU we work together with */
134   const char *screen_tag;      /* screen we are acting on */
185   const char *screen_tag;      // screen we are acting on
135186
136   /* pixel clock of the chip is the device clock */
137   int color_clock;         /* the chroma clock of the chip */
187   // pixel clock of the chip is the device clock
188   int color_clock;         // the chroma clock of the chip
138189
139   /* screen format */
190   // screen format
140191   devcb_read_line               in_pal_ntsc_func;
141192
142   /* page memory read function */
143   devcb_read8                  in_page_ram_func;
193   // page memory color bit read function
194   cdp1869_pcb_read_func         in_pcb_func;
144195
145   /* page memory write function */
146   devcb_write8               out_page_ram_func;
196   // character memory read function
197   cdp1869_char_ram_read_func      in_char_ram_func;
147198
148   /* page memory color bit read function */
149   cdp1869_pcb_read_func         pcb_r;
199   // character memory write function
200   cdp1869_char_ram_write_func      out_char_ram_func;
150201
151   /* character memory read function */
152   cdp1869_char_ram_read_func      char_ram_r;
202   // if specified, this gets called for every change of the predisplay pin (CDP1870/76 pin 1)
203   devcb_write_line            out_prd_func;
204};
153205
154   /* character memory write function */
155   cdp1869_char_ram_write_func      char_ram_w;
156206
157   /* if specified, this gets called for every change of the predisplay pin (CDP1870/76 pin 1) */
158   devcb_write_line            out_prd_func;
207
208// ======================> cdp1869_device_config
209
210class cdp1869_device_config :   public device_config,
211                        public device_config_sound_interface,
212                        public device_config_memory_interface,
213                                public cdp1869_interface
214{
215    friend class cdp1869_device;
216
217    // construction/destruction
218    cdp1869_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
219
220public:
221    // allocators
222    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
223    virtual device_t *alloc_device(running_machine &machine) const;
224
225protected:
226   // device_config overrides
227   virtual void device_config_complete();
228
229   // device_config_memory_interface overrides
230   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
231
232    // address space configurations
233   const address_space_config      m_space_config;
159234};
160235
161/***************************************************************************
162    PROTOTYPES
163***************************************************************************/
164236
165/* palette initialization */
166PALETTE_INIT( cdp1869 );
167237
168/* register access */
169WRITE8_DEVICE_HANDLER( cdp1869_out3_w );
170WRITE8_DEVICE_HANDLER( cdp1869_out4_w );
171WRITE8_DEVICE_HANDLER( cdp1869_out5_w );
172WRITE8_DEVICE_HANDLER( cdp1869_out6_w );
173WRITE8_DEVICE_HANDLER( cdp1869_out7_w );
238// ======================> cdp1869_device
174239
175/* character memory access */
176READ8_DEVICE_HANDLER ( cdp1869_charram_r );
177WRITE8_DEVICE_HANDLER ( cdp1869_charram_w );
240class cdp1869_device :   public device_t,
241                  public device_sound_interface,
242                  public device_memory_interface
243{
244    friend class cdp1869_device_config;
178245
179/* page memory access */
180READ8_DEVICE_HANDLER ( cdp1869_pageram_r );
181WRITE8_DEVICE_HANDLER ( cdp1869_pageram_w );
246    // construction/destruction
247    cdp1869_device(running_machine &_machine, const cdp1869_device_config &_config);
182248
183/* predisplay */
184READ_LINE_DEVICE_HANDLER( cdp1869_predisplay_r );
249public:
250   DECLARE_WRITE8_MEMBER( out3_w );
251    DECLARE_WRITE8_MEMBER( out4_w );
252    DECLARE_WRITE8_MEMBER( out5_w );
253    DECLARE_WRITE8_MEMBER( out6_w );
254    DECLARE_WRITE8_MEMBER( out7_w );
185255
186/* PAL/NTSC */
187READ_LINE_DEVICE_HANDLER( cdp1869_pal_ntsc_r );
256   DECLARE_READ8_MEMBER( char_ram_r );
257    DECLARE_WRITE8_MEMBER( char_ram_w );
188258
189/* screen update */
190void cdp1869_update(running_device *device, bitmap_t *bitmap, const rectangle *cliprect);
259   DECLARE_READ8_MEMBER( page_ram_r );
260    DECLARE_WRITE8_MEMBER( page_ram_w );
191261
262   DECLARE_READ_LINE_MEMBER( predisplay_r );
263   DECLARE_READ_LINE_MEMBER( pal_ntsc_r );
264
265   void update_screen(bitmap_t *bitmap, const rectangle *cliprect);
266
267protected:
268    // device-level overrides
269    virtual void device_start();
270   virtual void device_post_load();
271   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
272
273   // internal callbacks
274   static STREAM_UPDATE( static_stream_generate );
275   virtual void stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples);
276
277   inline bool is_ntsc();
278   inline UINT8 read_page_ram_byte(offs_t address);
279   inline void write_page_ram_byte(offs_t address, UINT8 data);
280   inline UINT8 read_char_ram_byte(offs_t pma, offs_t cma, UINT8 pmd);
281   inline void write_char_ram_byte(offs_t pma, offs_t cma, UINT8 pmd, UINT8 data);
282   inline int read_pcb(offs_t pma, offs_t cma, UINT8 pmd);
283   inline void update_prd_changed_timer();
284   inline rgb_t get_rgb(int i, int c, int l);
285   inline int get_lines();
286   inline UINT16 get_pmemsize(int cols, int rows);
287   inline UINT16 get_pma();
288   inline int get_pen(int ccb0, int ccb1, int pcb);
289
290   void initialize_palette();
291   void draw_line(bitmap_t *bitmap, const rectangle *rect, int x, int y, UINT8 data, int color);
292   void draw_char(bitmap_t *bitmap, const rectangle *rect, int x, int y, UINT16 pma);
293
294private:
295   devcb_resolved_read_line      m_in_pal_ntsc_func;
296   devcb_resolved_write_line      m_out_prd_func;
297   cdp1869_pcb_read_func         m_in_pcb_func;
298   cdp1869_char_ram_read_func      m_in_char_ram_func;
299   cdp1869_char_ram_write_func      m_out_char_ram_func;
300
301   screen_device *m_screen;
302   address_space *m_page_ram;
303   emu_timer *m_prd_timer;
304   sound_stream *m_stream;
305
306   // video state
307   int m_prd;                  // predisplay
308   int m_dispoff;               // display off
309   int m_fresvert;               // full resolution vertical
310   int m_freshorz;               // full resolution horizontal
311   int m_cmem;                  // character memory access mode
312   int m_dblpage;               // double page mode
313   int m_line16;               // 16-line hi-res mode
314   int m_line9;               // 9 line mode
315   int m_cfc;                  // color format control
316   UINT8 m_col;               // character color control
317   UINT8 m_bkg;               // background color
318   UINT16 m_pma;               // page memory address
319   UINT16 m_hma;               // home memory address
320
321   // sound state
322   INT16 m_signal;               // current signal
323   int m_incr;                  // initial wave state
324   int m_toneoff;               // tone off
325   int m_wnoff;               // white noise off
326   UINT8 m_tonediv;            // tone divisor
327   UINT8 m_tonefreq;            // tone range select
328   UINT8 m_toneamp;            // tone output amplitude
329   UINT8 m_wnfreq;               // white noise range select
330   UINT8 m_wnamp;               // white noise output amplitude
331
332   const cdp1869_device_config &m_config;
333};
334
335
336// device type definition
337extern const device_type CDP1869;
338
339
340
192341#endif
src/emu/drivers/xtal.h
r9412r9413
6262   XTAL_4_9152MHz     = 4915200,
6363   XTAL_5MHz         = 5000000,      /* Mutant Night */
6464   XTAL_5_0688MHz      = 5068800,      /* Xerox 820, DEC VK100 */
65   XTAL_5_626MHz      = 5626000,      /* RCA CDP1869 PAL dot clock */
66   XTAL_5_67MHz      = 5670000,      /* RCA CDP1869 NTSC dot clock */
6567   XTAL_5_7143MHz      = 5714300,      /* Cidelsa Destroyer */
6668   XTAL_5_9904MHz      = 5990400,      /* Luxor ABC 800 keyboard */
6769   XTAL_6MHz         = 6000000,      /* American Poker II */
r9412r9413
7476   XTAL_8_2MHz         = 8200000,      /* Universal Mr. Do - Model 8021 PCB */
7577   XTAL_8_4672MHz      = 8467200,      /* Subsino's Ying Hua Lian */
7678   XTAL_8_664MHz      = 8664000,      /* Touchmaster */
79   XTAL_8_867236MHz   = 8867236,      /* RCA CDP1869 PAL color clock */
7780   XTAL_8_867238MHz   = 8867238,      /* ETI-660 */
7881   XTAL_8_945MHz      = 8945000,      /* Hit Me */
7982   XTAL_9_828MHz      = 9828000,      /* Universal PCBs */
src/mess/machine/comx35.c
r9412r9413
240240
241241      if (!m_fdc_drq_enable)
242242      {
243         m_cdp1802_ef4 = 1;
243         m_cdp1802_ef4 = CLEAR_LINE;
244244      }
245245
246246      wd17xx_set_side(m_fdc, BIT(data, 5));
r9412r9413
589589      memory_unmap_readwrite(program, 0xe000, 0xefff, 0, 0);
590590      memory_set_bank(machine, "bank2", 0);
591591   }
592
592   
593593   /* card slot banking */
594594   memory_configure_bank(machine, "bank1", 0, 1, memory_region(&m_machine, CDP1802_TAG) + 0xc000, 0);
595595   memory_configure_bank(machine, "bank1", BANK_FLOPPY, 1, memory_region(&m_machine, "fdc"), 0);
r9412r9413
632632
633633   m_reset = 0;
634634   m_iden = 1;
635   m_cdp1802_ef4 = 1;
635   m_cdp1802_ef4 = CLEAR_LINE;
636636
637637   timer_adjust_oneshot(m_reset_timer, ATTOTIME_IN_MSEC(t), 0);
638638}
src/mess/machine/pecom.c
r9412r9413
2828
2929MACHINE_RESET( pecom )
3030{
31   UINT8 *rom = memory_region(machine, "maincpu");
32   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
31   UINT8 *rom = memory_region(machine, CDP1802_TAG);
32   address_space *space = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM);
3333
3434   pecom_state *state = machine->driver_data<pecom_state>();
3535
r9412r9413
4949   timer_adjust_oneshot(state->reset_timer, ATTOTIME_IN_MSEC(5), 0);
5050}
5151
52static READ8_HANDLER( pecom_cdp1869_charram_r )
53{
54   pecom_state *state = space->machine->driver_data<pecom_state>();
55   return state->cdp1869->char_ram_r(*space, offset);
56}
57
58static WRITE8_HANDLER( pecom_cdp1869_charram_w )
59{
60   pecom_state *state = space->machine->driver_data<pecom_state>();
61   return state->cdp1869->char_ram_w(*space, offset, data);
62}
63
64static READ8_HANDLER( pecom_cdp1869_pageram_r )
65{
66   pecom_state *state = space->machine->driver_data<pecom_state>();
67   return state->cdp1869->page_ram_r(*space, offset);
68}
69
70static WRITE8_HANDLER( pecom_cdp1869_pageram_w )
71{
72   pecom_state *state = space->machine->driver_data<pecom_state>();
73   return state->cdp1869->page_ram_w(*space, offset, data);
74}
75
5276WRITE8_HANDLER( pecom_bank_w )
5377{
54   running_device *cdp1869 = space->machine->device(CDP1869_TAG);
55   address_space *space2 = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
56   UINT8 *rom = memory_region(space->machine, "maincpu");
57   memory_install_write_bank(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, "bank1");
78//   pecom_state *state = space->machine->driver_data<pecom_state>();
79   address_space *space2 = cputag_get_address_space(space->machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM);
80   UINT8 *rom = memory_region(space->machine, CDP1802_TAG);
81   memory_install_write_bank(cputag_get_address_space(space->machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, "bank1");
5882   memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")) + 0x0000);
5983
6084   if (data==2)
6185   {
62      memory_install_read8_device_handler (space2, cdp1869, 0xf000, 0xf7ff, 0, 0, cdp1869_charram_r);
63      memory_install_write8_device_handler(space2, cdp1869, 0xf000, 0xf7ff, 0, 0, cdp1869_charram_w);
64      memory_install_read8_device_handler (space2, cdp1869, 0xf800, 0xffff, 0, 0, cdp1869_pageram_r);
65      memory_install_write8_device_handler(space2, cdp1869, 0xf800, 0xffff, 0, 0, cdp1869_pageram_w);
66   }
86      memory_install_read8_handler (space2, 0xf000, 0xf7ff, 0, 0, pecom_cdp1869_charram_r);
87      memory_install_write8_handler(space2, 0xf000, 0xf7ff, 0, 0, pecom_cdp1869_charram_w);
88      memory_install_read8_handler (space2, 0xf800, 0xffff, 0, 0, pecom_cdp1869_pageram_r);
89      memory_install_write8_handler(space2, 0xf800, 0xffff, 0, 0, pecom_cdp1869_pageram_w);
90   }
6791   else
6892   {
6993      memory_unmap_write(space2, 0xf000, 0xf7ff, 0, 0);
r9412r9413
88112       Address is available on address bus during reading of value from port, and that is
89113       used to determine keyboard line reading
90114    */
91   UINT16 addr = cpu_get_reg(space->machine->device("maincpu"), COSMAC_R0 + cpu_get_reg(space->machine->device("maincpu"), COSMAC_X));
115   UINT16 addr = cpu_get_reg(space->machine->device(CDP1802_TAG), COSMAC_R0 + cpu_get_reg(space->machine->device(CDP1802_TAG), COSMAC_X));
92116   /* just in case somone is reading non existing ports */
93117   if (addr<0x7cca || addr>0x7ce3) return 0;
94118   return input_port_read(space->machine, keynames[addr - 0x7cca]) & 0x03;
r9412r9413
151175
152176   case COSMAC_STATE_CODE_S2_DMA:
153177      // DMA acknowledge clears the DMAOUT request
154      cputag_set_input_line(device->machine, "maincpu", COSMAC_INPUT_LINE_DMAOUT, CLEAR_LINE);
178      cputag_set_input_line(device->machine, CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT, CLEAR_LINE);
155179      break;
156180   case COSMAC_STATE_CODE_S3_INTERRUPT:
157181      break;
src/mess/video/tmc600.c
r9412r9413
1#define ADDRESS_MAP_MODERN
2
13#include "emu.h"
24#include "sound/cdp1869.h"
35#include "includes/tmc600.h"
r9412r9413
911
1012WRITE8_MEMBER( tmc600_state::vismac_data_w )
1113{
14   UINT16 ma = m_maincpu->get_memory_address();
15
1216   switch (m_vismac_reg_latch)
1317   {
1418   case 0x20:
15      // set character color
19      // character color latch
1620      m_vismac_color_latch = data;
1721      break;
1822
1923   case 0x30:
20      // write cdp1869 command on the data bus
24      // background color latch
2125      m_vismac_bkg_latch = data & 0x07;
22      cdp1869_out3_w(m_vis, 0, data);
26
27      m_vis->out3_w(space, ma, data);
2328      break;
2429
2530   case 0x40:
26      cdp1869_out4_w(m_vis, 0, data);
31      m_vis->out4_w(space, ma, data);
2732      break;
2833
2934   case 0x50:
30      cdp1869_out5_w(m_vis, 0, data);
35      m_vis->out5_w(space, ma, data);
3136      break;
3237
3338   case 0x60:
34      cdp1869_out6_w(m_vis, 0, data);
39      m_vis->out6_w(space, ma, data);
3540      break;
3641
3742   case 0x70:
38      cdp1869_out7_w(m_vis, 0, data);
43      m_vis->out7_w(space, ma, data);
3944      break;
4045   }
4146}
r9412r9413
6065   return color;
6166}
6267
63static READ8_DEVICE_HANDLER( tmc600_page_ram_r )
68WRITE8_MEMBER( tmc600_state::page_ram_w )
6469{
65   tmc600_state *state = device->machine->driver_data<tmc600_state>();
66
67   UINT16 addr = offset & TMC600_PAGE_RAM_MASK;
68
69   return state->m_page_ram[addr];
70   m_page_ram[offset] = data;
71   m_color_ram[offset] = m_vismac_color_latch;
7072}
7173
72static WRITE8_DEVICE_HANDLER( tmc600_page_ram_w )
73{
74   tmc600_state *state = device->machine->driver_data<tmc600_state>();
74static ADDRESS_MAP_START( cdp1869_page_ram, 0, 8, tmc600_state )
75   AM_RANGE(0x000, 0x3ff) AM_MIRROR(0x400) AM_RAM AM_BASE(m_page_ram) AM_WRITE(page_ram_w)
76ADDRESS_MAP_END
7577
76   UINT16 addr = offset & TMC600_PAGE_RAM_MASK;
77
78   state->m_page_ram[addr] = data;
79   state->m_color_ram[addr] = state->m_vismac_color_latch;
80}
81
8278static CDP1869_CHAR_RAM_READ( tmc600_char_ram_r )
8379{
8480   tmc600_state *state = device->machine->driver_data<tmc600_state>();
8581
8682   UINT16 pageaddr = pma & TMC600_PAGE_RAM_MASK;
87   UINT8 column = state->m_page_ram[pageaddr];
8883   UINT8 color = state->get_color(pageaddr);
89   UINT16 charaddr = ((cma & 0x08) << 8) | (column << 3) | (cma & 0x07);
84   UINT16 charaddr = ((cma & 0x08) << 8) | (pmd << 3) | (cma & 0x07);
9085   UINT8 cdb = state->m_char_rom[charaddr] & 0x3f;
9186
9287   int ccb0 = BIT(color, 2);
r9412r9413
105100   return BIT(color, 0);
106101}
107102
108static CDP1869_INTERFACE( tmc600_cdp1869_intf )
103static CDP1869_INTERFACE( vis_intf )
109104{
110   CDP1802_TAG,
111105   SCREEN_TAG,
112106   CDP1869_COLOR_CLK_PAL,
113107   CDP1869_PAL,
114   DEVCB_HANDLER(tmc600_page_ram_r),
115   DEVCB_HANDLER(tmc600_page_ram_w),
116108   tmc600_pcb_r,
117109   tmc600_char_ram_r,
118110   NULL,
119   DEVCB_NULL
111   DEVCB_NULL // ?
120112};
121113
122114void tmc600_state::video_start()
123115{
124   /* allocate memory */
125   m_page_ram = auto_alloc_array(machine, UINT8, TMC600_PAGE_RAM_SIZE);
116   // allocate memory
126117   m_color_ram = auto_alloc_array(machine, UINT8, TMC600_PAGE_RAM_SIZE);
127118
128   /* find memory regions */
119   // find memory regions
129120   m_char_rom = memory_region(machine, "chargen");
130121
131   /* register for state saving */
132   state_save_register_global_pointer(machine, m_page_ram, TMC600_PAGE_RAM_SIZE);
122   // register for state saving
133123   state_save_register_global_pointer(machine, m_color_ram, TMC600_PAGE_RAM_SIZE);
134124
135125   state_save_register_global(machine, m_vismac_reg_latch);
r9412r9413
138128   state_save_register_global(machine, m_blink);
139129}
140130
141bool tmc600_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
131static const gfx_layout tmc600_charlayout =
142132{
143   cdp1869_update(m_vis, &bitmap, &cliprect);
133   6, 9,               // 6 x 9 characters
134   256,               // 256 characters
135   1,                  // 1 bits per pixel
136   { 0 },               // no bitplanes
137   // x offsets
138   { 2, 3, 4, 5, 6, 7 },
139   // y offsets
140   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 2048*8 },
141   8*8                  // every char takes 8 x 8 bytes
142};
144143
145   return 0;
146}
144static GFXDECODE_START( tmc600 )
145   GFXDECODE_ENTRY( "chargen", 0x0000, tmc600_charlayout, 0, 36 )
146GFXDECODE_END
147147
148148MACHINE_CONFIG_FRAGMENT( tmc600_video )
149   // video hardware
150   MDRV_CDP1869_SCREEN_PAL_ADD(SCREEN_TAG, CDP1869_DOT_CLK_PAL)
149151   MDRV_TIMER_ADD_PERIODIC("blink", blink_tick, HZ(2))
152   MDRV_GFXDECODE(tmc600)
150153
151   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
152   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
153   MDRV_PALETTE_LENGTH(8+64)
154   MDRV_PALETTE_INIT(cdp1869)
155   MDRV_SCREEN_RAW_PARAMS(CDP1869_DOT_CLK_PAL, CDP1869_SCREEN_WIDTH, CDP1869_HBLANK_END, CDP1869_HBLANK_START, CDP1869_TOTAL_SCANLINES_PAL, CDP1869_SCANLINE_VBLANK_END_PAL, CDP1869_SCANLINE_VBLANK_START_PAL)
156
154   // sound hardware
157155   MDRV_SPEAKER_STANDARD_MONO("mono")
158   MDRV_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, tmc600_cdp1869_intf)
156   MDRV_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, vis_intf, cdp1869_page_ram)
159157   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
160158MACHINE_CONFIG_END
src/mess/video/comx35.c
r9412r9413
66#include "sound/wave.h"
77#include "video/mc6845.h"
88
9/* CDP1869 */
10
11static READ8_DEVICE_HANDLER( comx35_pageram_r )
9WRITE8_MEMBER( comx35_state::cdp1869_w )
1210{
13   comx35_state *state = device->machine->driver_data<comx35_state>();
11   UINT16 ma = m_maincpu->get_memory_address();
1412
15   UINT16 addr = offset & COMX35_PAGERAM_MASK;
13   switch (offset + 3)
14   {
15   case 3:
16      m_vis->out3_w(space, ma, data);
17      break;
1618
17   return state->m_pageram[addr];
19   case 4:
20      m_vis->out4_w(space, ma, data);
21      break;
22     
23   case 5:
24      m_vis->out5_w(space, ma, data);
25      break;
26
27   case 6:
28      m_vis->out6_w(space, ma, data);
29      break;
30
31   case 7:
32      m_vis->out7_w(space, ma, data);
33      break;
34   }
1835}
1936
20static WRITE8_DEVICE_HANDLER( comx35_pageram_w )
21{
22   comx35_state *state = device->machine->driver_data<comx35_state>();
37/* CDP1869 */
2338
24   UINT16 addr = offset & COMX35_PAGERAM_MASK;
39static ADDRESS_MAP_START( cdp1869_page_ram, 0, 8 )
40   AM_RANGE(0x000, 0x3ff) AM_MIRROR(0x400) AM_RAM
41ADDRESS_MAP_END
2542
26   state->m_pageram[addr] = data;
27}
28
2943static CDP1869_CHAR_RAM_READ( comx35_charram_r )
3044{
3145   comx35_state *state = device->machine->driver_data<comx35_state>();
3246
33   UINT16 pageaddr = pma & COMX35_PAGERAM_MASK;
34   UINT8 column = state->m_pageram[pageaddr] & 0x7f;
47   UINT8 column = pmd & 0x7f;
3548   UINT16 charaddr = (column << 4) | cma;
3649
3750   return state->m_charram[charaddr];
r9412r9413
4154{
4255   comx35_state *state = device->machine->driver_data<comx35_state>();
4356
44   UINT16 pageaddr = pma & COMX35_PAGERAM_MASK;
45   UINT8 column = state->m_pageram[pageaddr] & 0x7f;
57   UINT8 column = pmd & 0x7f;
4658   UINT16 charaddr = (column << 4) | cma;
4759
4860   state->m_charram[charaddr] = data;
r9412r9413
5062
5163static CDP1869_PCB_READ( comx35_pcb_r )
5264{
53   comx35_state *state = device->machine->driver_data<comx35_state>();
54
55   UINT16 pageaddr = pma & COMX35_PAGERAM_MASK;
56
57   return BIT(state->m_pageram[pageaddr], 7);
65   return BIT(pmd, 7);
5866}
5967
6068static WRITE_LINE_DEVICE_HANDLER( comx35_prd_w )
r9412r9413
7179
7280static CDP1869_INTERFACE( pal_cdp1869_intf )
7381{
74   CDP1802_TAG,
7582   SCREEN_TAG,
7683   CDP1869_COLOR_CLK_PAL,
7784   CDP1869_PAL,
78   DEVCB_HANDLER(comx35_pageram_r),
79   DEVCB_HANDLER(comx35_pageram_w),
8085   comx35_pcb_r,
8186   comx35_charram_r,
8287   comx35_charram_w,
r9412r9413
8590
8691static CDP1869_INTERFACE( ntsc_cdp1869_intf )
8792{
88   CDP1802_TAG,
8993   SCREEN_TAG,
9094   CDP1869_COLOR_CLK_NTSC,
9195   CDP1869_NTSC,
92   DEVCB_HANDLER(comx35_pageram_r),
93   DEVCB_HANDLER(comx35_pageram_w),
9496   comx35_pcb_r,
9597   comx35_charram_r,
9698   comx35_charram_w,
r9412r9413
100102void comx35_state::video_start()
101103{
102104   // allocate memory
103   m_pageram = auto_alloc_array(machine, UINT8, COMX35_PAGERAM_SIZE);
104105   m_charram = auto_alloc_array(machine, UINT8, COMX35_CHARRAM_SIZE);
105106   m_videoram = auto_alloc_array(machine, UINT8, COMX35_VIDEORAM_SIZE);
106107
107108   // register for save state
108   state_save_register_global_pointer(machine, m_pageram, COMX35_PAGERAM_SIZE);
109109   state_save_register_global_pointer(machine, m_charram, COMX35_CHARRAM_SIZE);
110110   state_save_register_global_pointer(machine, m_videoram, COMX35_VIDEORAM_SIZE);
111111}
r9412r9413
114114{
115115   if (screen.width() == CDP1869_SCREEN_WIDTH)
116116   {
117      cdp1869_update(m_vis, &bitmap, &cliprect);
117      m_vis->update_screen(&bitmap, &cliprect);
118118   }
119119   else
120120   {
121121      mc6845_update(m_crtc, &bitmap, &cliprect);
122122   }
123123
124   return 0;
124   return false;
125125}
126126
127127/* MC6845 */
r9412r9413
219219   /* sound hardware */
220220   MDRV_SPEAKER_STANDARD_MONO("mono")
221221
222   MDRV_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, pal_cdp1869_intf)
222   MDRV_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, pal_cdp1869_intf, cdp1869_page_ram)
223223   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
224224
225225   MDRV_SOUND_WAVE_ADD("wave", "cassette")
r9412r9413
238238   /* sound hardware */
239239   MDRV_SPEAKER_STANDARD_MONO("mono")
240240
241   MDRV_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_NTSC, ntsc_cdp1869_intf)
241   MDRV_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_NTSC, ntsc_cdp1869_intf, cdp1869_page_ram)
242242   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
243243
244244   MDRV_SOUND_WAVE_ADD("wave", "cassette")
src/mess/video/pecom.c
r9412r9413
1212#include "cpu/cosmac/cosmac.h"
1313#include "includes/pecom.h"
1414
15static READ8_DEVICE_HANDLER( pecom_page_ram_r )
15WRITE8_HANDLER( pecom_cdp1869_w )
1616{
17   pecom_state *state = device->machine->driver_data<pecom_state>();
17   pecom_state *state = space->machine->driver_data<pecom_state>();
18   
19   UINT16 ma = state->cdp1802->get_memory_address();
20   
21   switch (offset + 3)
22   {
23   case 3:
24      state->cdp1869->out3_w(*space, ma, data);
25      break;
1826
19   UINT16 addr = offset & PECOM_PAGE_RAM_MASK;
27   case 4:
28      state->cdp1869->out4_w(*space, ma, data);
29      break;
30     
31   case 5:
32      state->cdp1869->out5_w(*space, ma, data);
33      break;
2034
21   return state->page_ram[addr];
22}
35   case 6:
36      state->cdp1869->out6_w(*space, ma, data);
37      break;
2338
24static WRITE8_DEVICE_HANDLER( pecom_page_ram_w )
25{
26   pecom_state *state = device->machine->driver_data<pecom_state>();
27
28   UINT16 addr = offset & PECOM_PAGE_RAM_MASK;
29
30   state->page_ram[addr] = data;
39   case 7:
40      state->cdp1869->out7_w(*space, ma, data);
41      break;
42   }
3143}
3244
45static ADDRESS_MAP_START( cdp1869_page_ram, 0, 8 )
46   AM_RANGE(0x000, 0x3ff) AM_MIRROR(0x400) AM_RAM
47ADDRESS_MAP_END
3348
3449static CDP1869_CHAR_RAM_READ( pecom_char_ram_r )
3550{
3651   pecom_state *state = device->machine->driver_data<pecom_state>();
3752
38   UINT16 pageaddr = pma & PECOM_PAGE_RAM_MASK;
39   UINT8 column = state->page_ram[pageaddr] & 0x7f;
53   UINT8 column = pmd & 0x7f;
4054   UINT16 charaddr = (column << 4) | cma;
4155
4256   return state->charram[charaddr];
r9412r9413
4660{
4761   pecom_state *state = device->machine->driver_data<pecom_state>();
4862
49   UINT16 pageaddr = pma & PECOM_PAGE_RAM_MASK;
50   UINT8 column = state->page_ram[pageaddr] & 0x7f;
63   UINT8 column = pmd & 0x7f;
5164   UINT16 charaddr = (column << 4) | cma;
5265
5366   state->charram[charaddr] = data;
r9412r9413
5568
5669static CDP1869_PCB_READ( pecom_pcb_r )
5770{
58   pecom_state *state = device->machine->driver_data<pecom_state>();
59
60   UINT16 pageaddr = pma & PECOM_PAGE_RAM_MASK;
61
62   return BIT(state->page_ram[pageaddr], 7);
71   return BIT(pmd, 7);
6372}
6473
65
6674static WRITE_LINE_DEVICE_HANDLER( pecom_prd_w )
6775{
6876   pecom_state *driver_state = device->machine->driver_data<pecom_state>();
77
6978   // every other PRD triggers a DMAOUT request
7079   if (driver_state->dma)
7180   {
72      driver_state->dma = 0;
73
74      cputag_set_input_line(device->machine, "maincpu", COSMAC_INPUT_LINE_DMAOUT, HOLD_LINE);
81      cputag_set_input_line(device->machine, CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT, HOLD_LINE);
7582   }
76   else
77   {
78      driver_state->dma = 1;
79   }
83
84   driver_state->dma = !driver_state->dma;
8085}
8186
8287static CDP1869_INTERFACE( pecom_cdp1869_intf )
8388{
84   "maincpu",
8589   SCREEN_TAG,
8690   CDP1869_COLOR_CLK_PAL,
8791   CDP1869_PAL,
88   DEVCB_HANDLER(pecom_page_ram_r),
89   DEVCB_HANDLER(pecom_page_ram_w),
9092   pecom_pcb_r,
9193   pecom_char_ram_r,
9294   pecom_char_ram_w,
9395   DEVCB_LINE(pecom_prd_w)
9496};
9597
96
97
9898static VIDEO_START( pecom )
9999{
100100   pecom_state *state = machine->driver_data<pecom_state>();
101101
102102   /* allocate memory */
103   state->charram = auto_alloc_array(machine, UINT8, PECOM_CHAR_RAM_SIZE);
103104
104   state->page_ram = auto_alloc_array(machine, UINT8, PECOM_PAGE_RAM_SIZE);
105   state->charram = auto_alloc_array(machine, UINT8, 0x800);
106
107   /* find devices */
108
109   state->cdp1869 = machine->device(CDP1869_TAG);
110
111105   /* register for state saving */
112106   state_save_register_global(machine, state->reset);
113107   state_save_register_global(machine, state->dma);
114   state_save_register_global_pointer(machine, state->page_ram, PECOM_PAGE_RAM_SIZE);
108   state_save_register_global_pointer(machine, state->charram, PECOM_CHAR_RAM_SIZE);
115109}
116110
117111static VIDEO_UPDATE( pecom )
118112{
119113   pecom_state *state = screen->machine->driver_data<pecom_state>();
120114
121   cdp1869_update(state->cdp1869, bitmap, cliprect);
115   state->cdp1869->update_screen(bitmap, cliprect);
122116
123117   return 0;
124118}
r9412r9413
131125
132126   MDRV_SPEAKER_STANDARD_MONO("mono")
133127
134   MDRV_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, pecom_cdp1869_intf)
128   MDRV_CDP1869_ADD(CDP1869_TAG, CDP1869_DOT_CLK_PAL, pecom_cdp1869_intf, cdp1869_page_ram)
135129   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
136130   MDRV_SOUND_WAVE_ADD("wave", "cassette")
137131   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
src/mess/includes/tmc600.h
r9412r9413
2626    { }
2727
2828   required_device<cosmac_device> m_maincpu;
29   required_device<running_device> m_vis;
29   required_device<cdp1869_device> m_vis;
3030   required_device<running_device> m_cassette;
3131   required_device<running_device> m_ram;
3232
3333   virtual void machine_start();
34   virtual void machine_reset();
3534
3635   virtual void video_start();
37   virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
36   bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect) { m_vis->update_screen(&bitmap, &cliprect); return false; }
3837
3938   DECLARE_WRITE8_MEMBER(keyboard_latch_w);
4039   DECLARE_WRITE8_MEMBER(vismac_register_w);
4140   DECLARE_WRITE8_MEMBER(vismac_data_w);
41   DECLARE_WRITE8_MEMBER(page_ram_w);
4242
4343   UINT8 get_color(UINT16 pma);
4444
45   /* video state */
46   int m_vismac_reg_latch;   /* video register latch */
47   int m_vismac_color_latch;   /* color latch */
48   int m_vismac_bkg_latch;   /* background color latch */
49   int m_blink;            /* cursor blink */
45   // video state
46   int m_vismac_reg_latch;      // video register latch
47   int m_vismac_color_latch;   // color latch
48   int m_vismac_bkg_latch;      // background color latch
49   int m_blink;            // cursor blink
5050
51   UINT8 *m_page_ram;      /* page memory */
52   UINT8 *m_color_ram;      /* color memory */
53   UINT8 *m_char_rom;      /* character generator ROM */
51   UINT8 *m_page_ram;         // page memory
52   UINT8 *m_color_ram;         // color memory
53   UINT8 *m_char_rom;         // character generator ROM
5454
55   /* keyboard state */
56   int m_keylatch;         /* key latch */
55   // keyboard state
56   int m_keylatch;            // key latch
5757};
5858
59/* ---------- defined in video/tmc600.c ---------- */
59// ---------- defined in video/tmc600.c ----------
6060
6161MACHINE_CONFIG_EXTERN( tmc600_video );
6262
src/mess/includes/comx35.h
r9412r9413
22#define __COMX35__
33
44#include "cpu/cosmac/cosmac.h"
5#include "sound/cdp1869.h"
56#include "devices/snapquik.h"
67#include "machine/wd17xx.h"
78
r9412r9413
1718
1819#define CASSETTE_TAG      "cassette"
1920
20#define COMX35_PAGERAM_SIZE 0x400
2121#define COMX35_CHARRAM_SIZE 0x800
2222#define COMX35_VIDEORAM_SIZE 0x800
2323
24#define COMX35_PAGERAM_MASK 0x3ff
2524#define COMX35_CHARRAM_MASK 0x7ff
2625#define COMX35_VIDEORAM_MASK 0x7ff
2726
r9412r9413
5352   { }
5453
5554   required_device<cosmac_device> m_maincpu;
56   required_device<running_device> m_vis;
55   required_device<cdp1869_device> m_vis;
5756   required_device<running_device> m_crtc;
5857   required_device<running_device> m_fdc;
5958   required_device<running_device> m_kbe;
r9412r9413
6665   virtual void video_start();
6766   virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
6867
68   DECLARE_WRITE8_MEMBER(cdp1869_w);
6969   DECLARE_READ8_MEMBER(io_r);
7070   DECLARE_READ8_MEMBER(io2_r);
71
7271   DECLARE_WRITE8_MEMBER(bank_select_w);
7372   DECLARE_WRITE8_MEMBER(io_w);
73   DECLARE_READ_LINE_MEMBER(clear_r);
74   DECLARE_READ_LINE_MEMBER(ef2_r);
75   DECLARE_READ_LINE_MEMBER(ef4_r);
76   DECLARE_WRITE_LINE_MEMBER(comx35_q_w);
77   DECLARE_READ_LINE_MEMBER(comx35_shift_r);
78   DECLARE_READ_LINE_MEMBER(comx35_control_r);
7479
7580   UINT8 read_expansion();
7681   bool is_expansion_box_installed();
r9412r9413
8287   void get_active_bank(UINT8 data);
8388   void set_active_bank();
8489
85   /* processor state */
86   int m_reset;            /* CPU mode */
87   int m_cdp1802_q;         /* Q flag */
88   int m_cdp1802_ef4;         /* EF4 flag */
89   int m_iden;               /* interrupt/DMA enable */
90   int m_slot;               /* selected slot */
91   int m_bank;               /* selected device bank */
92   int m_rambank;            /* selected RAM bank */
93   int m_dma;               /* memory refresh DMA */
90   // processor state
91   int m_reset;            // CPU mode
92   int m_cdp1802_q;         // Q flag
93   int m_cdp1802_ef4;         // EF4 flag
94   int m_iden;               // interrupt/DMA enable
95   int m_slot;               // selected slot
96   int m_bank;               // selected device bank
97   int m_rambank;            // selected RAM bank
98   int m_dma;               // memory refresh DMA
9499
95   UINT8 *m_pageram;         /* page memory */
96   UINT8 *m_charram;         /* character memory */
97   UINT8 *m_videoram;         /* 80 column video memory */
100   // video state
101   UINT8 *m_charram;         // character memory
102   UINT8 *m_videoram;         // 80 column video memory
98103
99   /* floppy state */
100   int m_fdc_addr;            /* FDC address */
101   int m_fdc_irq;            /* interrupt request */
102   int m_fdc_drq_enable;      /* EF4 enabled */
104   // floppy state
105   int m_fdc_addr;            // FDC address
106   int m_fdc_irq;            // interrupt request
107   int m_fdc_drq_enable;      // EF4 enabled
103108
104   /* timers */
105   emu_timer *m_reset_timer;   /* power on reset timer */
109   // timers
110   emu_timer *m_reset_timer;   // power on reset timer
106111};
107112
108/* ---------- defined in machine/comx35.c ---------- */
113// ---------- defined in machine/comx35.c ----------
114
109115extern const wd17xx_interface comx35_wd17xx_interface;
110116
111117INPUT_CHANGED( comx35_reset );
112118
113/* ---------- defined in video/comx35.c ---------- */
119// ---------- defined in video/comx35.c ----------
120
114121MACHINE_CONFIG_EXTERN( comx35_pal_video );
115122MACHINE_CONFIG_EXTERN( comx35_ntsc_video );
116123
src/mess/includes/pecom.h
r9412r9413
44#include "cpu/cosmac/cosmac.h"
55
66#define SCREEN_TAG   "screen"
7#define CDP1802_TAG   "cdp1802"
78#define CDP1869_TAG   "cdp1869"
89
9#define PECOM_PAGE_RAM_SIZE   0x400
10#define PECOM_PAGE_RAM_MASK   0x3ff
10#define PECOM_CHAR_RAM_SIZE   0x800
1111
1212class pecom_state : public driver_device
1313{
1414public:
1515   pecom_state(running_machine &machine, const driver_device_config_base &config)
16      : driver_device(machine, config) { }
16      : driver_device(machine, config),
17        cdp1802(*this, CDP1802_TAG),
18        cdp1869(*this, CDP1869_TAG)
19   { }
1720
18   UINT8 *page_ram;      /* page memory */
21   required_device<cosmac_device> cdp1802;
22   required_device<cdp1869_device> cdp1869;
23
1924   UINT8 *charram;         /* character generator ROM */
2025   int reset;            /* CPU mode */
2126   int dma;            /* memory refresh DMA */
22   running_device *cdp1869;
2327
2428   /* timers */
2529   emu_timer *reset_timer;   /* power on reset timer */
r9412r9413
3741
3842/* ---------- defined in video/pecom.c ---------- */
3943
44WRITE8_HANDLER( pecom_cdp1869_w );
4045MACHINE_CONFIG_EXTERN( pecom_video );
4146
4247#endif
src/mess/includes/cosmicos.h
r9412r9413
11#ifndef __COSMICOS__
22#define __COSMICOS__
33
4#include "cpu/cdp1802/cdp1802.h"
4#include "cpu/cosmac/cosmac.h"
55
66#define CDP1802_TAG      "ic19"
77#define CDP1864_TAG      "ic3"
r9412r9413
3232{
3333public:
3434   cosmicos_state(running_machine &machine, const driver_device_config_base &config)
35      : driver_device(machine, config) { }
35      : driver_device(machine, config),
36        m_maincpu(*this, CDP1802_TAG)
37   { }
3638
39   required_device<cosmac_device> m_maincpu;
40
3741   /* CPU state */
38   cdp1802_control_mode cdp1802_mode;
42   int wait;
43   int clear;
3944   int sc1;
4045
4146   /* memory state */
src/mess/mess.mak
r9412r9413
103103CPUS += DSP56156
104104CPUS += RSP
105105CPUS += ALPHA8201
106CPUS += CDP1802
107106CPUS += COP400
108107CPUS += TLCS90
109108CPUS += TLCS900
src/mess/drivers/tmc600.c
r9412r9413
104104static ADDRESS_MAP_START( tmc600_map, ADDRESS_SPACE_PROGRAM, 8, tmc600_state )
105105   AM_RANGE(0x0000, 0x4fff) AM_ROM
106106   AM_RANGE(0x6000, 0xbfff) AM_RAM
107   AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE_LEGACY(CDP1869_TAG, cdp1869_charram_r, cdp1869_charram_w)
108   AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE_LEGACY(CDP1869_TAG, cdp1869_pageram_r, cdp1869_pageram_w)
107   AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE(CDP1869_TAG, cdp1869_device, char_ram_r, char_ram_w)
108   AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE(CDP1869_TAG, cdp1869_device, page_ram_r, page_ram_w)
109109ADDRESS_MAP_END
110110
111111static ADDRESS_MAP_START( tmc600_io_map, ADDRESS_SPACE_IO, 8, tmc600_state )
r9412r9413
199199   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x93") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
200200   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
201201
202   PORT_START("EF")
203   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SPECIAL ) //
204   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL ) // tape in
205   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) // keyboard
206   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SPECIAL ) //
207
208202   PORT_START("RUN")
209   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Run/Stop") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) PORT_TOGGLE
203   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Run/Stop") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) PORT_TOGGLE
210204INPUT_PORTS_END
211205
212206/* CDP1802 Interface */
r9412r9413
230224   return BIT(data, state->m_keylatch % 8);
231225}
232226
233static WRITE_LINE_DEVICE_HANDLER( tmc600_q_w )
227static WRITE_LINE_DEVICE_HANDLER( q_w )
234228{
235   tmc600_state *driver_state = device->machine->driver_data<tmc600_state>();
236
237   cassette_output(driver_state->m_cassette, state ? +1.0 : -1.0);
229   cassette_output(device, state ? +1.0 : -1.0);
238230}
239231
240232static COSMAC_INTERFACE( cosmac_intf )
r9412r9413
245237   DEVCB_DEVICE_LINE(CASSETTE_TAG, ef2_r),
246238   DEVCB_LINE(ef3_r),
247239   DEVCB_NULL,
248   DEVCB_LINE(tmc600_q_w),
240   DEVCB_DEVICE_LINE(CASSETTE_TAG, q_w),
249241   DEVCB_NULL,
250242   DEVCB_NULL,
251243   NULL,
r9412r9413
275267   state_save_register_global(machine, m_keylatch);
276268}
277269
278void tmc600_state::machine_reset()
279{
280   cputag_set_input_line(machine, CDP1802_TAG, INPUT_LINE_RESET, PULSE_LINE);
281}
282
283270/* Machine Drivers */
284271
285272static const cassette_config tmc600_cassette_config =
r9412r9413
297284   DEVCB_NULL,
298285   DEVCB_NULL,
299286   DEVCB_NULL,
300   FLOPPY_STANDARD_5_25_DSHD,
287   FLOPPY_STANDARD_5_25_DSDD,
301288   FLOPPY_OPTIONS_NAME(default),
302289   NULL
303290};
304291
305/* F4 Character Displayer */
306static const gfx_layout tmc600_charlayout =
307{
308   6, 9,               /* 6 x 9 characters */
309   256,               /* 256 characters */
310   1,               /* 1 bits per pixel */
311   { 0 },               /* no bitplanes */
312   /* x offsets */
313   { 2, 3, 4, 5, 6, 7 },
314   /* y offsets */
315   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 2048*8 },
316   8*8               /* every char takes 2 x 8 bytes */
317};
318
319static GFXDECODE_START( tmc600 )
320   GFXDECODE_ENTRY( "chargen", 0x0000, tmc600_charlayout, 0, 36 )
321GFXDECODE_END
322
323292static MACHINE_CONFIG_START( tmc600, tmc600_state )
324293   // basic system hardware
325294   MDRV_CPU_ADD(CDP1802_TAG, COSMAC, 3579545)   // ???
r9412r9413
329298
330299   // sound and video hardware
331300   MDRV_FRAGMENT_ADD(tmc600_video)
332   MDRV_GFXDECODE(tmc600)
333301
334302   /* devices */
335303   MDRV_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
src/mess/drivers/comx35.c
r9412r9413
3838   AM_RANGE(0x4000, 0xbfff) AM_RAM
3939   AM_RANGE(0xc000, 0xdfff) AM_RAMBANK("bank1")
4040   AM_RANGE(0xe000, 0xefff) AM_ROMBANK("bank3")
41   AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE_LEGACY(CDP1869_TAG, cdp1869_charram_r, cdp1869_charram_w)
42   AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE_LEGACY(CDP1869_TAG, cdp1869_pageram_r, cdp1869_pageram_w)
41   AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE(CDP1869_TAG, cdp1869_device, char_ram_r, char_ram_w)
42   AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE(CDP1869_TAG, cdp1869_device, page_ram_r, page_ram_w)
4343ADDRESS_MAP_END
4444
4545static ADDRESS_MAP_START( comx35_io_map, ADDRESS_SPACE_IO, 8, comx35_state )
4646   ADDRESS_MAP_UNMAP_HIGH
4747   AM_RANGE(0x01, 0x01) AM_WRITE(bank_select_w)
4848   AM_RANGE(0x02, 0x02) AM_READWRITE(io_r, io_w)
49   AM_RANGE(0x03, 0x03) AM_DEVREAD_LEGACY(CDP1871_TAG, cdp1871_data_r) AM_DEVWRITE_LEGACY(CDP1869_TAG, cdp1869_out3_w)
50   AM_RANGE(0x04, 0x04) AM_READ(io2_r) AM_DEVWRITE_LEGACY(CDP1869_TAG, cdp1869_out4_w)
51   AM_RANGE(0x05, 0x05) AM_DEVWRITE_LEGACY(CDP1869_TAG, cdp1869_out5_w)
52   AM_RANGE(0x06, 0x06) AM_DEVWRITE_LEGACY(CDP1869_TAG, cdp1869_out6_w)
53   AM_RANGE(0x07, 0x07) AM_DEVWRITE_LEGACY(CDP1869_TAG, cdp1869_out7_w)
49   AM_RANGE(0x03, 0x03) AM_DEVREAD_LEGACY(CDP1871_TAG, cdp1871_data_r)
50   AM_RANGE(0x03, 0x07) AM_WRITE(cdp1869_w)
5451ADDRESS_MAP_END
5552
5653/* Input Ports */
r9412r9413
217214   if (state->m_iden)
218215   {
219216      // interrupts disabled: PAL/NTSC
220      return cdp1869_pal_ntsc_r(state->m_vis);
217      return state->m_vis->pal_ntsc_r();
221218   }
222219   else
223220   {
src/mess/drivers/pecom.c
r9412r9413
2626
2727static ADDRESS_MAP_START( pecom64_io, ADDRESS_SPACE_IO, 8 )
2828   AM_RANGE(0x01, 0x01) AM_WRITE(pecom_bank_w)
29   AM_RANGE(0x03, 0x03) AM_READ(pecom_keyboard_r) AM_DEVWRITE(CDP1869_TAG, cdp1869_out3_w)
30   AM_RANGE(0x04, 0x04) AM_DEVWRITE(CDP1869_TAG, cdp1869_out4_w)
31   AM_RANGE(0x05, 0x05) AM_DEVWRITE(CDP1869_TAG, cdp1869_out5_w)
32   AM_RANGE(0x06, 0x06) AM_DEVWRITE(CDP1869_TAG, cdp1869_out6_w)
33   AM_RANGE(0x07, 0x07) AM_DEVWRITE(CDP1869_TAG, cdp1869_out7_w)
29   AM_RANGE(0x03, 0x03) AM_READ(pecom_keyboard_r)
30   AM_RANGE(0x03, 0x07) AM_WRITE(pecom_cdp1869_w)
3431ADDRESS_MAP_END
3532
3633/* Input ports */
r9412r9413
5350
5451static INPUT_CHANGED( ef_w )
5552{
56   cputag_set_input_line(field->port->machine, "maincpu", (int)(FPTR)param, newval);
53   cputag_set_input_line(field->port->machine, CDP1802_TAG, (int)(FPTR)param, newval);
5754}
5855
5956static INPUT_PORTS_START( pecom )
r9412r9413
180177static MACHINE_CONFIG_START( pecom64, pecom_state )
181178
182179    /* basic machine hardware */
183   MDRV_CPU_ADD("maincpu", COSMAC, CDP1869_DOT_CLK_PAL/3)
180   MDRV_CPU_ADD(CDP1802_TAG, COSMAC, CDP1869_DOT_CLK_PAL/3)
184181   MDRV_CPU_PROGRAM_MAP(pecom64_mem)
185182   MDRV_CPU_IO_MAP(pecom64_io)
186183   MDRV_CPU_CONFIG(pecom64_cdp1802_config)
r9412r9413
202199
203200/* ROM definition */
204201ROM_START( pecom64 )
205     ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
202     ROM_REGION( 0x10000, CDP1802_TAG, ROMREGION_ERASEFF )
206203     ROM_SYSTEM_BIOS(0, "ver4", "version 4")
207204     ROMX_LOAD( "pecom64-1.bin", 0x8000, 0x4000, CRC(9a433b47) SHA1(dadb8c399e0a25a2693e10e42a2d7fc2ea9ad427), ROM_BIOS(1) )
208205     ROMX_LOAD( "pecom64-2.bin", 0xc000, 0x4000, CRC(2116cadc) SHA1(03f11055cd221d438a40a41874af8fba0fa116d9), ROM_BIOS(1) )
src/mess/drivers/cosmicos.c
r9412r9413
3434
3535#include "emu.h"
3636#include "includes/cosmicos.h"
37#include "cpu/cdp1802/cdp1802.h"
37#include "cpu/cosmac/cosmac.h"
3838#include "devices/cassette.h"
3939#include "devices/messram.h"
4040#include "devices/snapquik.h"
r9412r9413
4444#include "video/dm9368.h"
4545#include "cosmicos.lh"
4646
47enum
48{
49   MODE_RUN,
50   MODE_LOAD,
51   MODE_PAUSE,
52   MODE_RESET
53};
54
4755/* Read/Write Handlers */
4856
4957static READ8_DEVICE_HANDLER( video_off_r )
r9412r9413
193201{
194202   cosmicos_state *state = field->port->machine->driver_data<cosmicos_state>();
195203
196   if (!newval && (state->cdp1802_mode == CDP1802_MODE_LOAD))
204   if (!newval && !state->wait && !state->clear)
197205   {
198      cputag_set_input_line(field->port->machine, CDP1802_TAG, CDP1802_INPUT_LINE_DMAIN, ASSERT_LINE);
206      cputag_set_input_line(field->port->machine, CDP1802_TAG, COSMAC_INPUT_LINE_DMAIN, ASSERT_LINE);
199207   }
200208}
201209
r9412r9413
204212   // if in PAUSE mode, set RUN mode until TPB=active
205213}
206214
207static void set_cdp1802_mode(running_machine *machine, cdp1802_control_mode mode)
215static void set_cdp1802_mode(running_machine *machine, int mode)
208216{
209217   cosmicos_state *state = machine->driver_data<cosmicos_state>();
210218
211   state->cdp1802_mode = mode;
212
213219   output_set_led_value(LED_RUN, 0);
214220   output_set_led_value(LED_LOAD, 0);
215221   output_set_led_value(LED_PAUSE, 0);
r9412r9413
217223
218224   switch (mode)
219225   {
220   case CDP1802_MODE_RUN:
226   case MODE_RUN:
221227      output_set_led_value(LED_RUN, 1);
228
229      state->wait = 1;
230      state->clear = 1;
222231      break;
223232
224   case CDP1802_MODE_LOAD:
233   case MODE_LOAD:
225234      output_set_led_value(LED_LOAD, 1);
235
236      state->wait = 0;
237      state->clear = 0;
226238      break;
227239
228   case CDP1802_MODE_PAUSE:
240   case MODE_PAUSE:
229241      output_set_led_value(LED_PAUSE, 1);
242
243      state->wait = 1;
244      state->clear = 0;
230245      break;
231246
232   case CDP1802_MODE_RESET:
233      cputag_set_input_line(machine, CDP1802_TAG, CDP1802_INPUT_LINE_INT, CLEAR_LINE);
234      cputag_set_input_line(machine, CDP1802_TAG, CDP1802_INPUT_LINE_DMAIN, CLEAR_LINE);
247   case MODE_RESET:
248      cputag_set_input_line(machine, CDP1802_TAG, COSMAC_INPUT_LINE_INT, CLEAR_LINE);
249      cputag_set_input_line(machine, CDP1802_TAG, COSMAC_INPUT_LINE_DMAIN, CLEAR_LINE);
235250
251      state->wait = 1;
252      state->clear = 0;
236253      state->boot = 1;
237254
238255      output_set_led_value(LED_RESET, 1);
r9412r9413
240257   }
241258}
242259
243static INPUT_CHANGED( run )   { if (!newval) set_cdp1802_mode(field->port->machine, CDP1802_MODE_RUN); }
244static INPUT_CHANGED( load )  { if (!newval) set_cdp1802_mode(field->port->machine, CDP1802_MODE_LOAD); }
245static INPUT_CHANGED( cosmicos_pause ) {   if (!newval) set_cdp1802_mode(field->port->machine, CDP1802_MODE_PAUSE); }
246static INPUT_CHANGED( reset ) {   if (!newval) set_cdp1802_mode(field->port->machine, CDP1802_MODE_RESET); }
260static INPUT_CHANGED( run )            { if (!newval) set_cdp1802_mode(field->port->machine, MODE_RUN); }
261static INPUT_CHANGED( load )         { if (!newval) set_cdp1802_mode(field->port->machine, MODE_LOAD); }
262static INPUT_CHANGED( cosmicos_pause )   { if (!newval) set_cdp1802_mode(field->port->machine, MODE_PAUSE); }
263static INPUT_CHANGED( reset )         { if (!newval) set_cdp1802_mode(field->port->machine, MODE_RESET); }
247264
248265static void clear_input_data(running_machine *machine)
249266{
r9412r9413
351368   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
352369
353370   PORT_START("SPECIAL")
354   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RET") PORT_CODE(KEYCODE_F1)
355   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("DEC") PORT_CODE(KEYCODE_F2)
356   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("REQ") PORT_CODE(KEYCODE_F3)
357   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("SEQ") PORT_CODE(KEYCODE_F4)
371   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RET") PORT_CODE(KEYCODE_F1)
372   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("DEC") PORT_CODE(KEYCODE_F2)
373   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("REQ") PORT_CODE(KEYCODE_F3)
374   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SEQ") PORT_CODE(KEYCODE_F4)
358375INPUT_PORTS_END
359376
360377/* Video */
r9412r9413
370387
371388static TIMER_DEVICE_CALLBACK( int_tick )
372389{
373   cputag_set_input_line(timer.machine, CDP1802_TAG, CDP1802_INPUT_LINE_INT, ASSERT_LINE);
390   cputag_set_input_line(timer.machine, CDP1802_TAG, COSMAC_INPUT_LINE_INT, ASSERT_LINE);
374391}
375392
376393static WRITE_LINE_DEVICE_HANDLER( cosmicos_dmaout_w )
r9412r9413
395412   DEVCB_LINE_VCC,
396413   DEVCB_LINE_VCC,
397414   DEVCB_LINE_VCC,
398   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_INT),
415   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
399416   DEVCB_LINE(cosmicos_dmaout_w),
400417   DEVCB_LINE(cosmicos_efx_w),
401418   RES_K(2), // R2
r9412r9413
415432
416433/* CDP1802 Configuration */
417434
418static CDP1802_MODE_READ( cosmicos_mode_r )
435static READ_LINE_DEVICE_HANDLER( wait_r )
419436{
420437   cosmicos_state *state = device->machine->driver_data<cosmicos_state>();
421438
422   return state->cdp1802_mode;
439   return state->wait;
423440}
424441
425static CDP1802_EF_READ( cosmicos_ef_r )
442static READ_LINE_DEVICE_HANDLER( clear_r )
426443{
427   /*
428        EF1
429        EF2     cassette input
430        EF3
431        EF4     ENTER
432    */
444   cosmicos_state *state = device->machine->driver_data<cosmicos_state>();
433445
434   cosmicos_state *state = device->machine->driver_data<cosmicos_state>();
446   return state->clear;
447}
448
449static READ_LINE_DEVICE_HANDLER( ef1_r )
450{
435451   UINT8 special = input_port_read(device->machine, "SPECIAL");
436   UINT8 flags = 0x0f;
437452
438   /* cassette input */
439   if (cassette_input(state->cassette) < 0.0)
440   {
441      output_set_led_value(LED_CASSETTE, 1);
442      flags &= ~EF2;
443   }
444   else
445   {
446      output_set_led_value(LED_CASSETTE, 0);
447   }
453   return BIT(special, 0);
454}
448455
449   /* ENTER */
450   if (!BIT(input_port_read(device->machine, "BUTTONS"), 0)) flags &= ~EF4;
456static READ_LINE_DEVICE_HANDLER( ef2_r )
457{
458   UINT8 special = input_port_read(device->machine, "SPECIAL");
459   int casin = cassette_input(device) < 0.0;
460   
461   output_set_led_value(LED_CASSETTE, casin);
451462
452   /* hexadecimal keypad */
453   if (!BIT(special, 0)) flags &= ~EF1;
454   if (!BIT(special, 1)) flags &= ~EF2;
455   if (!BIT(special, 2)) flags &= ~EF3;
456   if (!BIT(special, 3)) flags &= ~(EF2 | EF3);
463   return BIT(special, 1) | BIT(special, 3) | casin;
464}
457465
458   return flags;
466static READ_LINE_DEVICE_HANDLER( ef3_r )
467{
468   UINT8 special = input_port_read(device->machine, "SPECIAL");
469
470   return BIT(special, 2) | BIT(special, 3);
459471}
460472
461static CDP1802_SC_WRITE( cosmicos_sc_w )
473static READ_LINE_DEVICE_HANDLER( ef4_r )
462474{
475   return BIT(input_port_read(device->machine, "BUTTONS"), 0);
476}
477
478static COSMAC_SC_WRITE( cosmicos_sc_w )
479{
463480   cosmicos_state *driver_state = device->machine->driver_data<cosmicos_state>();
464481
482   int sc1 = BIT(sc, 1);
483
465484   if (driver_state->sc1 && !sc1)
466485   {
467486      clear_input_data(device->machine);
r9412r9413
469488
470489   if (sc1)
471490   {
472      cpu_set_input_line(device, CDP1802_INPUT_LINE_INT, CLEAR_LINE);
473      cpu_set_input_line(device, CDP1802_INPUT_LINE_DMAIN, CLEAR_LINE);
491      cpu_set_input_line(device, COSMAC_INPUT_LINE_INT, CLEAR_LINE);
492      cpu_set_input_line(device, COSMAC_INPUT_LINE_DMAIN, CLEAR_LINE);
474493   }
475494
476495   driver_state->sc1 = sc1;
r9412r9413
499518   return state->data;
500519}
501520
502static CDP1802_INTERFACE( cosmicos_config )
521static COSMAC_INTERFACE( cosmicos_config )
503522{
504   cosmicos_mode_r,
505   cosmicos_ef_r,
506   cosmicos_sc_w,
523   DEVCB_LINE(wait_r),
524   DEVCB_LINE(clear_r),
525   DEVCB_LINE(ef1_r),
526   DEVCB_DEVICE_LINE(CASSETTE_TAG, ef2_r),
527   DEVCB_LINE(ef3_r),
528   DEVCB_LINE(ef4_r),
507529   DEVCB_LINE(cosmicos_q_w),
508530   DEVCB_HANDLER(cosmicos_dma_r),
531   DEVCB_NULL,
532   cosmicos_sc_w,
533   DEVCB_NULL,
509534   DEVCB_NULL
510535};
511536
537
512538/* Machine Initialization */
513539
514540static MACHINE_START( cosmicos )
r9412r9413
540566   set_ram_mode(machine);
541567
542568   /* register for state saving */
543   state_save_register_global(machine, state->cdp1802_mode);
569   state_save_register_global(machine, state->wait);
570   state_save_register_global(machine, state->clear);
544571   state_save_register_global(machine, state->sc1);
545572   state_save_register_global(machine, state->data);
546573   state_save_register_global(machine, state->boot);
r9412r9413
558585
559586static MACHINE_RESET( cosmicos )
560587{
561   set_cdp1802_mode(machine, CDP1802_MODE_RESET);
588   set_cdp1802_mode(machine, MODE_RESET);
562589}
563590
564591/* Quickload */
r9412r9413
585612};
586613
587614static MACHINE_CONFIG_START( cosmicos, cosmicos_state )
588
589615   /* basic machine hardware */
590    MDRV_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_1_75MHz)
616    MDRV_CPU_ADD(CDP1802_TAG, COSMAC, XTAL_1_75MHz)
591617    MDRV_CPU_PROGRAM_MAP(cosmicos_mem)
592618    MDRV_CPU_IO_MAP(cosmicos_io)
593619   MDRV_CPU_CONFIG(cosmicos_config)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team