Previous 15994 Revisions Next

r2219 Wednesday 2nd April, 2008 at 15:36:11 UTC by Curt Coder
[TMC600] Refactored to use new CDP1869 from MAME.
[src/emu/video]cdp1869.c cdp1869.h
[src/mess/drivers]tmc600.c

src/emu/video/cdp1869.c
r2218r2219
11#include "driver.h"
2#include "deprecat.h"
2#include "sndintrf.h"
3#include "streams.h"
34#include "cpu/cdp1802/cdp1802.h"
45#include "video/cdp1869.h"
56#include "sound/cdp1869.h"
r2218r2219
89
910    TODO:
1011
11    - convert CDP1869 into a device with video/sound
12    - add predisplay/display timers
12    - connect to sound system when possible
13   - white noise
14   - scanline based update
15   - fix flashing spaceship in destryer/altair
16   - fix flashing player in draco
1317
1418*/
1519
16typedef struct
20#define CDP1869_WEIGHT_RED      30 /* % of max luminance */
21#define CDP1869_WEIGHT_GREEN   59
22#define CDP1869_WEIGHT_BLUE      11
23
24#define CDP1869_COLUMNS_HALF   20
25#define CDP1869_COLUMNS_FULL   40
26#define CDP1869_ROWS_HALF      12
27#define CDP1869_ROWS_FULL_PAL   25
28#define CDP1869_ROWS_FULL_NTSC   24
29
30enum
1731{
18   int ntsc_pal;
19   int dispoff;
20   int fresvert, freshorz;
21   int dblpage, line16, line9, cmem, cfc;
22   UINT8 col, bkg;
23   UINT16 pma, hma;
24   UINT8 cram[CDP1869_CHARRAM_SIZE];
25   UINT8 pram[CDP1869_PAGERAM_SIZE];
26   int cramsize, pramsize;
27   UINT8 (*color_callback)(UINT8 cramdata, UINT16 cramaddr, UINT16 pramaddr);
28} CDP1869_VIDEO_CONFIG;
32   CDB0 = 0,
33   CDB1,
34   CDB2,
35   CDB3,
36   CDB4,
37   CDB5,
38   CCB0,
39   CCB1
40};
2941
30static CDP1869_VIDEO_CONFIG cdp1869;
42typedef struct _cdp1869_t cdp1869_t;
43struct _cdp1869_t
44{
45   const cdp1869_interface *intf;   /* interface */
46   const device_config *screen;   /* screen */
47   sound_stream *stream;         /* sound output */
3148
49   /* video state */
50   int dispoff;               /* display off */
51   int fresvert;               /* full resolution vertical */
52   int freshorz;               /* full resolution horizontal */
53   int cmem;                  /* character memory access mode */
54   int dblpage;               /* double page mode */
55   int line16;                  /* 16-line hi-res mode */
56   int line9;                  /* 9 line mode */
57   int cfc;                  /* color format control */
58   UINT8 col;                  /* character color control */
59   UINT8 bkg;                  /* background color */
60   UINT16 pma;                  /* page memory address */
61   UINT16 hma;                  /* home memory address */
62
63   /* video timer */
64   emu_timer *prd_changed_timer;   /* predisplay changed timer */
65
66   /* sound state */
67   INT16 signal;               /* current signal */
68   int incr;                  /* initial wave state */
69   int toneoff;               /* tone off */
70   int wnoff;                  /* white noise off */
71   UINT8 tonediv;               /* tone divisor */
72   UINT8 tonefreq;               /* tone range select */
73   UINT8 toneamp;               /* tone output amplitude */
74   UINT8 wnfreq;               /* white noise range select */
75   UINT8 wnamp;               /* white noise output amplitude */
76};
77
78INLINE cdp1869_t *get_safe_token(const device_config *device)
79{
80   assert(device != NULL);
81   assert(device->token != NULL);
82
83   return (cdp1869_t *)device->token;
84}
85
86/* Predisplay Timer */
87
88static void update_prd_changed_timer(cdp1869_t *cdp1869)
89{
90   if (cdp1869->prd_changed_timer != NULL)
91   {
92      attotime duration;
93      int start, end, level;
94      int scanline = video_screen_get_vpos(cdp1869->screen);
95      int next_scanline;
96
97      if (cdp1869->intf->pal_ntsc == CDP1869_NTSC)
98      {
99         start = CDP1869_SCANLINE_PREDISPLAY_START_NTSC;
100         end = CDP1869_SCANLINE_PREDISPLAY_END_NTSC;
101      }
102      else
103      {
104         start = CDP1869_SCANLINE_PREDISPLAY_START_PAL;
105         end = CDP1869_SCANLINE_PREDISPLAY_END_PAL;
106      }
107
108      if (scanline < start)
109      {
110         next_scanline = start;
111         level = 0;
112      }
113      else if (scanline < end)
114      {
115         next_scanline = end;
116         level = 1;
117      }
118      else
119      {
120         next_scanline = start;
121         level = 0;
122      }
123
124      if (cdp1869->dispoff)
125      {
126         level = 1;
127      }
128
129      duration = video_screen_get_time_until_pos(cdp1869->screen, next_scanline, 0);
130      timer_adjust_oneshot(cdp1869->prd_changed_timer, duration, level);
131   }
132}
133
134static TIMER_CALLBACK( prd_changed_tick )
135{
136   const device_config *device = ptr;
137   cdp1869_t *cdp1869 = get_safe_token(device);
138
139   /* call the callback function -- we know it exists */
140   cdp1869->intf->on_prd_changed(device, param);
141
142   update_prd_changed_timer(cdp1869);
143}
144
145/* State Save Postload */
146
147static void cdp1869_state_save_postload(void *param)
148{
149   update_prd_changed_timer(param);
150}
151
152/* CDP1802 X Register */
153
32154static UINT16 cdp1802_get_r_x(void)
33155{
34156   return activecpu_get_reg(CDP1802_R0 + activecpu_get_reg(CDP1802_X));
35157}
36158
37WRITE8_HANDLER ( cdp1869_out3_w )
159/* Palette Initialization */
160
161static rgb_t cdp1869_get_rgb(int i, int c, int l)
38162{
163   int luma = 0, r, g, b;
164
165   luma += (l & 4) ? CDP1869_WEIGHT_RED : 0;
166   luma += (l & 1) ? CDP1869_WEIGHT_GREEN : 0;
167   luma += (l & 2) ? CDP1869_WEIGHT_BLUE : 0;
168
169   luma = (luma * 0xff) / 100;
170
171   r = (c & 4) ? luma : 0;
172   g = (c & 1) ? luma : 0;
173   b = (c & 2) ? luma : 0;
174
175   return MAKE_RGB(r, g, b);
176}
177
178/* Screen Update */
179
180static int cdp1869_get_lines(const device_config *device)
181{
182   cdp1869_t *cdp1869 = get_safe_token(device);
183
184   if (cdp1869->line16 && !cdp1869->dblpage)
185   {
186      return 16;
187   }
188   else if (!cdp1869->line9)
189   {
190      return 9;
191   }
192   else
193   {
194      return 8;
195   }
196}
197
198static UINT16 cdp1869_get_pmemsize(const device_config *device, int cols, int rows)
199{
200   cdp1869_t *cdp1869 = get_safe_token(device);
201
202   int pmemsize = cols * rows;
203
204   if (cdp1869->dblpage) pmemsize *= 2;
205   if (cdp1869->line16) pmemsize *= 2;
206
207   return pmemsize;
208}
209
210static UINT16 cdp1869_get_pma(const device_config *device)
211{
212   cdp1869_t *cdp1869 = get_safe_token(device);
213
214   if (cdp1869->dblpage)
215   {
216      return cdp1869->pma;
217   }
218   else
219   {
220      return cdp1869->pma & 0x3ff;
221   }
222}
223
224static int cdp1869_get_pen(const device_config *device, int ccb0, int ccb1, int pcb)
225{
226   cdp1869_t *cdp1869 = get_safe_token(device);
227
228   int r = 0, g = 0, b = 0, color;
229
230   switch (cdp1869->col)
231   {
232   case 0:
233      r = ccb0;
234      b = ccb1;
235      g = pcb;
236      break;
237
238   case 1:
239      r = ccb0;
240      b = pcb;
241      g = ccb1;
242      break;
243
244   case 2:
245   case 3:
246      r = pcb;
247      b = ccb0;
248      g = ccb1;
249      break;
250   }
251
252   color = (r << 2) + (b << 1) + g;
253
254   if (cdp1869->cfc)
255   {
256      return color + ((cdp1869->bkg + 1) * 8);
257   }
258   else
259   {
260      return color;
261   }
262}
263
264static void cdp1869_draw_line(const device_config *device, bitmap_t *bitmap, int x, int y, int data, int color)
265{
266   cdp1869_t *cdp1869 = get_safe_token(device);
267
268   int i;
269
270   data <<= 2;
271
272   for (i = 0; i < CDP1869_CHAR_WIDTH; i++)
273   {
274      if (data & 0x80)
275      {
276         *BITMAP_ADDR16(bitmap, y, x) = color;
277
278         if (!cdp1869->fresvert)
279         {
280            *BITMAP_ADDR16(bitmap, y + 1, x) = color;
281         }
282
283         if (!cdp1869->freshorz)
284         {
285            *BITMAP_ADDR16(bitmap, y, x + 1) = color;
286
287            if (!cdp1869->fresvert)
288            {
289               *BITMAP_ADDR16(bitmap, y + 1, x + 1) = color;
290            }
291         }
292      }
293
294      if (!cdp1869->freshorz)
295      {
296         x++;
297      }
298
299      x++;
300
301      data <<= 1;
302   }
303}
304
305static void cdp1869_draw_char(const device_config *device, bitmap_t *bitmap, int x, int y, UINT16 pma, const rectangle *screenrect)
306{
307   cdp1869_t *cdp1869 = get_safe_token(device);
308
309   UINT8 cma = 0;
310
311   int pcb = cdp1869->intf->pcb_r(device, pma, cma);
312
313   for (cma = 0; cma < cdp1869_get_lines(device); cma++)
314   {
315      UINT8 data = cdp1869->intf->char_ram_r(device, pma, cma);
316
317      int ccb0 = BIT(data, CCB0);
318      int ccb1 = BIT(data, CCB1);
319
320      int color = cdp1869_get_pen(device, ccb0, ccb1, pcb);
321
322      cdp1869_draw_line(device, bitmap, screenrect->min_x + x, screenrect->min_y + y, data, color);
323
324      y++;
325
326      if (!cdp1869->fresvert)
327      {
328         y++;
329      }
330   }
331}
332
333/* Palette Initialization */
334
335PALETTE_INIT( cdp1869 )
336{
337   int i, c, l;
338
339   // color-on-color display (CFC=0)
340
341   for (i = 0; i < 8; i++)
342   {
343      palette_set_color(machine, i, cdp1869_get_rgb(i, i, 15));
344   }
345
346   // tone-on-tone display (CFC=1)
347
348   for (c = 0; c < 8; c++)
349   {
350      for (l = 0; l < 8; l++)
351      {
352         palette_set_color(machine, i, cdp1869_get_rgb(i, c, l));
353         i++;
354      }
355   }
356}
357
358/* Register Access */
359
360WRITE8_DEVICE_HANDLER( cdp1869_out3_w )
361{
362   cdp1869_t *cdp1869 = get_safe_token(device);
363
39364   /*
40365      bit   description
41366
r2218r2219
49374        7   fres horz
50375    */
51376
52   cdp1869.bkg = (data & 0x07);
53   cdp1869.cfc = (data & 0x08) >> 3;
54   cdp1869.dispoff = (data & 0x10) >> 4;
55   cdp1869.col = (data & 0x60) >> 5;
56   cdp1869.freshorz = (data & 0x80) >> 7;
377   cdp1869->bkg = data & 0x07;
378   cdp1869->cfc = BIT(data, 3);
379   cdp1869->dispoff = BIT(data, 4);
380   cdp1869->col = (data & 0x60) >> 5;
381   cdp1869->freshorz = BIT(data, 7);
57382}
58383
59WRITE8_HANDLER ( cdp1869_out4_w )
384WRITE8_DEVICE_HANDLER( cdp1869_out4_w )
60385{
386   cdp1869_t *cdp1869 = get_safe_token(device);
387
61388   UINT16 word = cdp1802_get_r_x();
62389
63390   /*
r2218r2219
81408       15   always 0
82409    */
83410
84   cdp1869_set_toneamp(0, word & 0x0f);
85   cdp1869_set_tonefreq(0, (word & 0x70) >> 4);
86   cdp1869_set_toneoff(0, (word & 0x80) >> 7);
87   cdp1869_set_tonediv(0, (word & 0x7f00) >> 8);
411   cdp1869->toneamp = word & 0x0f;
412   cdp1869->tonefreq = (word & 0x70) >> 4;
413   cdp1869->toneoff = BIT(word, 7);
414   cdp1869->tonediv = (word & 0x7f00) >> 8;
415
416   // fork out to CDP1869 sound core
417   cdp1869_set_toneamp(0, cdp1869->toneamp);
418   cdp1869_set_tonefreq(0, cdp1869->tonefreq);
419   cdp1869_set_toneoff(0, cdp1869->toneoff);
420   cdp1869_set_tonediv(0, cdp1869->tonediv);
88421}
89422
90WRITE8_HANDLER ( cdp1869_out5_w )
423WRITE8_DEVICE_HANDLER( cdp1869_out5_w )
91424{
425   cdp1869_t *cdp1869 = get_safe_token(device);
426
92427   UINT16 word = cdp1802_get_r_x();
93428
94429   /*
r2218r2219
112447       15   wn off
113448    */
114449
115   cdp1869.cmem = (word & 0x01);
116   cdp1869.line9 = (word & 0x08) >> 3;
117   cdp1869.line16 = (word & 0x20) >> 5;
118   cdp1869.dblpage = (word & 0x40) >> 6;
119   cdp1869.fresvert = (word & 0x80) >> 7;
450   cdp1869->cmem = BIT(word, 0);
451   cdp1869->line9 = BIT(word, 3);
120452
121   cdp1869_set_wnamp(0, (word & 0x0f00) >> 8);
122   cdp1869_set_wnfreq(0, (word & 0x7000) >> 12);
123   cdp1869_set_wnoff(0, (word & 0x8000) >> 15);
453   if (cdp1869->intf->pal_ntsc == CDP1869_NTSC)
454   {
455      cdp1869->line16 = BIT(word, 5);
456   }
457
458   cdp1869->dblpage = BIT(word, 6);
459   cdp1869->fresvert = BIT(word, 7);
460
461   cdp1869->wnamp = (word & 0x0f00) >> 8;
462   cdp1869->wnfreq = (word & 0x7000) >> 12;
463   cdp1869->wnoff = BIT(word, 15);
464
465   // fork out to CDP1869 sound core
466   cdp1869_set_wnamp(0, cdp1869->wnamp);
467   cdp1869_set_wnfreq(0, cdp1869->wnfreq);
468   cdp1869_set_wnoff(0, cdp1869->wnoff);
469
470   if (cdp1869->cmem)
471   {
472      cdp1869->pma = word;
473   }
474   else
475   {
476      cdp1869->pma = 0;
477   }
124478}
125479
126WRITE8_HANDLER ( cdp1869_out6_w )
480WRITE8_DEVICE_HANDLER( cdp1869_out6_w )
127481{
482   cdp1869_t *cdp1869 = get_safe_token(device);
483
128484   UINT16 word = cdp1802_get_r_x();
129485
130486   /*
r2218r2219
148504       15   x
149505    */
150506
151   cdp1869.pma = word & 0x7ff;
507   cdp1869->pma = word & 0x7ff;
152508}
153509
154WRITE8_HANDLER ( cdp1869_out7_w )
510WRITE8_DEVICE_HANDLER( cdp1869_out7_w )
155511{
512   cdp1869_t *cdp1869 = get_safe_token(device);
513
156514   UINT16 word = cdp1802_get_r_x();
157515
158516   /*
r2218r2219
176534       15   x
177535    */
178536
179   cdp1869.hma = word & 0x7fc;
537   cdp1869->hma = word & 0x7fc;
180538}
181539
182static void cdp1869_set_color(int i, int c, int l)
183{
184   int luma = 0, r, g, b;
540/* Page RAM Access */
185541
186   luma += (l & 4) ? CDP1869_WEIGHT_RED : 0;
187   luma += (l & 1) ? CDP1869_WEIGHT_GREEN : 0;
188   luma += (l & 2) ? CDP1869_WEIGHT_BLUE : 0;
189
190   luma = (luma * 0xff) / 100;
191
192   r = (c & 4) ? luma : 0;
193   g = (c & 1) ? luma : 0;
194   b = (c & 2) ? luma : 0;
195
196   palette_set_color( Machine, i, MAKE_RGB(r, g, b) );
197}
198
199PALETTE_INIT( cdp1869 )
542READ8_DEVICE_HANDLER( cdp1869_pageram_r )
200543{
201   int i, c, l;
544   cdp1869_t *cdp1869 = get_safe_token(device);
202545
203   // color-on-color display (CFC=0)
546   UINT16 pma;
204547
205   for (i = 0; i < 8; i++)
548   if (cdp1869->cmem)
206549   {
207      cdp1869_set_color(i, i, 15);
550      pma = cdp1869_get_pma(device);
208551   }
209
210   // tone-on-tone display (CFC=1)
211
212   for (c = 0; c < 8; c++)
552   else
213553   {
214      for (l = 0; l < 8; l++)
215      {
216         cdp1869_set_color(i, c, l);
217         i++;
218      }
554      pma = offset;
219555   }
220}
221556
222static int cdp1869_get_lines(void)
223{
224   if (cdp1869.line16 && !cdp1869.dblpage)
225   {
226      return 16;
227   }
228   else if (!cdp1869.line9)
229   {
230      return 9;
231   }
232   else
233   {
234      return 8;
235   }
557   return cdp1869->intf->page_ram_r(device, pma);
236558}
237559
238static UINT16 cdp1869_get_pmemsize(int cols, int rows)
560WRITE8_DEVICE_HANDLER( cdp1869_pageram_w )
239561{
240   int pmemsize = cols * rows;
562   cdp1869_t *cdp1869 = get_safe_token(device);
241563
242   if (cdp1869.dblpage) pmemsize *= 2;
243   if (cdp1869.line16) pmemsize *= 2;
564   UINT16 pma;
244565
245   return pmemsize;
246}
247
248static UINT16 cdp1869_get_pma(void)
249{
250   if (cdp1869.dblpage)
566   if (cdp1869->cmem)
251567   {
252      return cdp1869.pma;
568      pma = cdp1869_get_pma(device);
253569   }
254570   else
255571   {
256      return cdp1869.pma & 0x3ff;
572      pma = offset;
257573   }
574
575   cdp1869->intf->page_ram_w(device, pma, data);
258576}
259577
260UINT16 cdp1869_get_cma(UINT16 offset)
578/* Character RAM Access */
579
580READ8_DEVICE_HANDLER( cdp1869_charram_r )
261581{
262   int column = cdp1869.pram[cdp1869_get_pma()];
263   int row = offset & 0x07;
582   cdp1869_t *cdp1869 = get_safe_token(device);
264583
265   int addr = (column << 3) + row;
266
267   if ((offset & 0x08) && (cdp1869_get_lines() > 8))
584   if (cdp1869->cmem)
268585   {
269      addr += (CDP1869_CHARRAM_SIZE / 2);
270   }
586      UINT16 pma = cdp1869_get_pma(device);
587      UINT8 cma = offset & 0x0f;
271588
272   return addr;
273}
589      if (cdp1869_get_lines(device) == 8)
590      {
591         cma &= 0x07;
592      }
274593
275static UINT8 cdp1869_read_pageram(UINT16 addr)
276{
277   if (addr >= cdp1869.pramsize)
278   {
279      return 0xff;
594      return cdp1869->intf->char_ram_r(device, pma, cma);
280595   }
281596   else
282597   {
283      return cdp1869.pram[addr];
284   }
285}
286
287#ifdef UNUSED_FUNCTION
288UINT8 cdp1869_read_charram(UINT16 addr)
289{
290   if (addr >= cdp1869.cramsize)
291   {
292598      return 0xff;
293599   }
294   else
295   {
296      return cdp1869.cram[addr];
297   }
298600}
299#endif
300601
301WRITE8_HANDLER ( cdp1869_charram_w )
602WRITE8_DEVICE_HANDLER( cdp1869_charram_w )
302603{
303   if (cdp1869.cmem)
304   {
305      UINT16 addr = cdp1869_get_cma(offset);
306      cdp1869.cram[addr] = data;
307   }
308}
604   cdp1869_t *cdp1869 = get_safe_token(device);
309605
310READ8_HANDLER ( cdp1869_charram_r )
311{
312   if (cdp1869.cmem)
606   if (cdp1869->cmem)
313607   {
314      UINT16 addr = cdp1869_get_cma(offset);
315      return cdp1869.cram[addr];
316   }
317   else
318   {
319      return 0xff;
320   }
321}
608      UINT16 pma = cdp1869_get_pma(device);
609      UINT8 cma = offset & 0x0f;
322610
323WRITE8_HANDLER ( cdp1869_pageram_w )
324{
325   UINT16 addr;
611      if (cdp1869_get_lines(device) == 8)
612      {
613         cma &= 0x07;
614      }
326615
327   if (cdp1869.cmem)
328   {
329      addr = cdp1869_get_pma();
616      cdp1869->intf->char_ram_w(device, pma, cma, data);
330617   }
331   else
332   {
333      addr = offset;
334   }
335
336   cdp1869.pram[addr] = data;
337618}
338619
339READ8_HANDLER ( cdp1869_pageram_r )
620/* Screen Update */
621
622void cdp1869_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect)
340623{
341   UINT16 addr;
624   cdp1869_t *cdp1869 = get_safe_token(device);
342625
343   if (cdp1869.cmem)
344   {
345      addr = cdp1869_get_pma();
346   }
347   else
348   {
349      addr = offset;
350   }
626   rectangle screen_rect, outer;
351627
352   return cdp1869.pram[addr];
353}
354
355static int cdp1869_get_color(int ccb0, int ccb1, int pcb)
356{
357   int r = 0, g = 0, b = 0, color;
358
359   switch (cdp1869.col)
628   switch (cdp1869->intf->pal_ntsc)
360629   {
361   case 0:
362      r = ccb0;
363      g = pcb;
364      b = ccb1;
630   case CDP1869_NTSC:
631      outer.min_x = CDP1869_HBLANK_END;
632      outer.max_x = CDP1869_HBLANK_START - 1;
633      outer.min_y = CDP1869_SCANLINE_VBLANK_END_NTSC;
634      outer.max_y = CDP1869_SCANLINE_VBLANK_START_NTSC - 1;
635      screen_rect.min_x = CDP1869_SCREEN_START_NTSC;
636      screen_rect.max_x = CDP1869_SCREEN_END - 1;
637      screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_NTSC;
638      screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_NTSC - 1;
365639      break;
366640
367   case 1:
368      r = ccb0;
369      g = ccb1;
370      b = pcb;
641   default:
642   case CDP1869_PAL:
643      outer.min_x = CDP1869_HBLANK_END;
644      outer.max_x = CDP1869_HBLANK_START - 1;
645      outer.min_y = CDP1869_SCANLINE_VBLANK_END_PAL;
646      outer.max_y = CDP1869_SCANLINE_VBLANK_START_PAL - 1;
647      screen_rect.min_x = CDP1869_SCREEN_START_PAL;
648      screen_rect.max_x = CDP1869_SCREEN_END - 1;
649      screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_PAL;
650      screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_PAL - 1;
371651      break;
372
373   case 2:
374   case 3:
375      r = pcb;
376      g = ccb1;
377      b = ccb0;
378      break;
379652   }
380653
381   color = (r << 2) + (b << 1) + g;
654   sect_rect(&outer, cliprect);
655   fillbitmap(bitmap, device->machine->pens[cdp1869->bkg], &outer);
382656
383   if (cdp1869.cfc)
657   if (!cdp1869->dispoff)
384658   {
385      return color + ((cdp1869.bkg + 1) * 8);
386   }
387   else
388   {
389      return color;
390   }
391}
659      int sx, sy, rows, cols, width, height;
660      UINT16 addr, pmemsize;
392661
393static void cdp1869_draw_line(running_machine *machine, bitmap_t *bitmap, int x, int y, int data, int color)
394{
395   int i;
662      width = CDP1869_CHAR_WIDTH;
663      height = cdp1869_get_lines(device);
396664
397   data <<= 2;
665      if (!cdp1869->freshorz)
666      {
667         width *= 2;
668      }
398669
399   for (i = 0; i < CDP1869_CHAR_WIDTH; i++)
400   {
401      if (data & 0x80)
670      if (!cdp1869->fresvert)
402671      {
403         *BITMAP_ADDR16(bitmap, y, x) = machine->pens[color];
672         height *= 2;
673      }
404674
405         if (!cdp1869.fresvert)
406         {
407            *BITMAP_ADDR16(bitmap, y + 1, x) = machine->pens[color];
408         }
675      cols = cdp1869->freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF;
676      rows = (screen_rect.max_y - screen_rect.min_y + 1) / height;
409677
410         if (!cdp1869.freshorz)
411         {
412            *BITMAP_ADDR16(bitmap, y, x + 1) = machine->pens[color];
678      pmemsize = cdp1869_get_pmemsize(device, cols, rows);
413679
414            if (!cdp1869.fresvert)
415            {
416               *BITMAP_ADDR16(bitmap, y + 1, x + 1) = machine->pens[color];
417            }
418         }
419      }
680      addr = cdp1869->hma;
420681
421      if (!cdp1869.freshorz)
682      for (sy = 0; sy < rows; sy++)
422683      {
423         x++;
424      }
684         for (sx = 0; sx < cols; sx++)
685         {
686            int x = sx * width;
687            int y = sy * height;
425688
426      x++;
689            cdp1869_draw_char(device, bitmap, x, y, addr, &screen_rect);
427690
428      data <<= 1;
691            addr++;
692
693            if (addr == pmemsize) addr = 0;
694         }
695      }
429696   }
430697}
431698
432static void cdp1869_draw_char(running_machine *machine, bitmap_t *bitmap, int x, int y, UINT16 pramaddr, const rectangle *screenrect)
699/* Sound Update */
700
701#ifdef UNUSED_FUNCTION
702static void cdp1869_sum_square_wave(stream_sample_t *buffer, double frequency, double amplitude)
433703{
434   int i;
435   UINT8 code = cdp1869_read_pageram(pramaddr);
436   UINT16 addr = code * 8;
437   UINT16 addr2 = addr + (CDP1869_CHARRAM_SIZE / 2);
704   // do a fast fourier transform on all the waves in the white noise range
705}
438706
439   for (i = 0; i < cdp1869_get_lines(); i++)
440   {
441      UINT8 data = cdp1869.cram[addr];
707static void cdp1869_sound_update(const device_config *device, stream_sample_t **inputs, stream_sample_t **_buffer, int length)
708{
709   cdp1869_t *cdp1869 = get_safe_token(device);
442710
443      UINT8 colorbits = cdp1869.color_callback(data, addr, pramaddr);
711   INT16 signal = cdp1869->signal;
712   stream_sample_t *buffer = _buffer[0];
444713
445      int pcb = colorbits & 0x01;
446      int ccb1 = (colorbits & 0x02) >> 1;
447      int ccb0 = (colorbits & 0x04) >> 2;
714   memset(buffer, 0, length * sizeof(*buffer));
448715
449      int color = cdp1869_get_color(ccb0, ccb1, pcb);
716   if (!cdp1869->toneoff && cdp1869->toneamp)
717   {
718      double frequency = (cdp1869->intf->pixel_clock / 2) / (512 >> cdp1869->tonefreq) / (cdp1869->tonediv + 1);
450719
451      cdp1869_draw_line(machine, bitmap, screenrect->min_x + x, screenrect->min_y + y, data, color);
720      int rate = device->machine->sample_rate / 2;
452721
453      addr++;
454      y++;
722      /* get progress through wave */
723      int incr = cdp1869->incr;
455724
456      if (!cdp1869.fresvert)
725      if (signal < 0)
457726      {
458         y++;
727         signal = -(cdp1869->toneamp * (0x07fff / 15));
459728      }
729      else
730      {
731         signal = cdp1869->toneamp * (0x07fff / 15);
732      }
460733
461      if (i == 7)
734      while( length-- > 0 )
462735      {
463         addr = addr2;
736         *buffer++ = signal;
737         incr -= frequency;
738         while( incr < 0 )
739         {
740            incr += rate;
741            signal = -signal;
742         }
464743      }
744
745      /* store progress through wave */
746      cdp1869->incr = incr;
747      cdp1869->signal = signal;
465748   }
466}
467749
468VIDEO_START( cdp1869 )
469{
470   state_save_register_item("cdp1869", 0, cdp1869.ntsc_pal);
471   state_save_register_item("cdp1869", 0, cdp1869.dispoff);
472   state_save_register_item("cdp1869", 0, cdp1869.fresvert);
473   state_save_register_item("cdp1869", 0, cdp1869.freshorz);
474   state_save_register_item("cdp1869", 0, cdp1869.dblpage);
475   state_save_register_item("cdp1869", 0, cdp1869.line16);
476   state_save_register_item("cdp1869", 0, cdp1869.line9);
477   state_save_register_item("cdp1869", 0, cdp1869.cmem);
478   state_save_register_item("cdp1869", 0, cdp1869.cfc);
479   state_save_register_item("cdp1869", 0, cdp1869.col);
480   state_save_register_item("cdp1869", 0, cdp1869.bkg);
481   state_save_register_item("cdp1869", 0, cdp1869.pma);
482   state_save_register_item("cdp1869", 0, cdp1869.hma);
483   state_save_register_item_array("cdp1869", 0, cdp1869.cram);
484   state_save_register_item_array("cdp1869", 0, cdp1869.pram);
485   state_save_register_item("cdp1869", 0, cdp1869.cramsize);
486   state_save_register_item("cdp1869", 0, cdp1869.pramsize);
750    if (!cdp1869->wnoff)
751    {
752      int wndiv;
753        double amplitude = cdp1869->wnamp * ((0.78*5) / 15);
754
755        for (wndiv = 0; wndiv < 128; wndiv++)
756        {
757            double frequency = (cdp1869->intf->pixel_clock / 2) / (4096 >> cdp1869->wnfreq) / (wndiv + 1);
758
759            cdp1869_sum_square_wave(buffer, frequency, amplitude);
760        }
761    }
487762}
763#endif
488764
489VIDEO_UPDATE( cdp1869 )
765/* Device Interface */
766
767static DEVICE_START( cdp1869 )
490768{
491   fillbitmap(bitmap, get_black_pen(screen->machine), cliprect);
769   cdp1869_t *cdp1869 = get_safe_token(device);
770   char unique_tag[30];
492771
493   if (!cdp1869.dispoff)
494   {
495      int sx, sy, rows, cols, width, height;
496      UINT16 addr, pmemsize;
497      rectangle screen_rect, outer;
772   // validate arguments
498773
499      switch (cdp1869.ntsc_pal)
500      {
501      case CDP1869_NTSC:
502         outer.min_x = CDP1869_HBLANK_END;
503         outer.max_x = CDP1869_HBLANK_START - 1;
504         outer.min_y = CDP1869_SCANLINE_VBLANK_END_NTSC;
505         outer.max_y = CDP1869_SCANLINE_VBLANK_START_NTSC - 1;
506         screen_rect.min_x = CDP1869_SCREEN_START_NTSC;
507         screen_rect.max_x = CDP1869_SCREEN_END - 1;
508         screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_NTSC;
509         screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_NTSC - 1;
510         break;
774   assert(device != NULL);
775   assert(device->tag != NULL);
776   assert(strlen(device->tag) < 20);
777   assert(device->static_config != NULL);
511778
512      default:
513      case CDP1869_PAL:
514         outer.min_x = CDP1869_HBLANK_END;
515         outer.max_x = CDP1869_HBLANK_START - 1;
516         outer.min_y = CDP1869_SCANLINE_VBLANK_END_PAL;
517         outer.max_y = CDP1869_SCANLINE_VBLANK_START_PAL - 1;
518         screen_rect.min_x = CDP1869_SCREEN_START_PAL;
519         screen_rect.max_x = CDP1869_SCREEN_END - 1;
520         screen_rect.min_y = CDP1869_SCANLINE_DISPLAY_START_PAL;
521         screen_rect.max_y = CDP1869_SCANLINE_DISPLAY_END_PAL - 1;
522         break;
523      }
779   cdp1869->intf = device->static_config;
524780
525      sect_rect(&outer, cliprect);
526      fillbitmap(bitmap, screen->machine->pens[cdp1869.bkg], &outer);
781   assert(cdp1869->intf->page_ram_r != NULL);
782   assert(cdp1869->intf->page_ram_w != NULL);
783   assert(cdp1869->intf->pcb_r != NULL);
784   assert(cdp1869->intf->char_ram_r != NULL);
785   assert(cdp1869->intf->char_ram_w != NULL);
527786
528      width = CDP1869_CHAR_WIDTH;
529      height = cdp1869_get_lines();
787   // set initial values
530788
531      if (!cdp1869.freshorz)
532      {
533         width *= 2;
534      }
789   cdp1869->toneoff = 1;
790   cdp1869->wnoff = 1;
535791
536      if (!cdp1869.fresvert)
537      {
538         height *= 2;
539      }
792   // get the screen device
540793
541      cols = cdp1869.freshorz ? CDP1869_COLUMNS_FULL : CDP1869_COLUMNS_HALF;
542      rows = (screen_rect.max_y - screen_rect.min_y + 1) / height;
794   cdp1869->screen = device_list_find_by_tag(device->machine->config->devicelist, VIDEO_SCREEN, cdp1869->intf->screen_tag);
795   assert(cdp1869->screen != NULL);
543796
544      pmemsize = cdp1869_get_pmemsize(cols, rows);
797   // allocate timers
545798
546      addr = cdp1869.hma;
799   if (cdp1869->intf->on_prd_changed != NULL)
800   {
801      cdp1869->prd_changed_timer = timer_alloc(prd_changed_tick, (void *)device);
802      update_prd_changed_timer(cdp1869);
803   }
547804
548      for (sy = 0; sy < rows; sy++)
549      {
550         for (sx = 0; sx < cols; sx++)
551         {
552            int x = sx * width;
553            int y = sy * height;
805   // register for state saving
554806
555            cdp1869_draw_char(screen->machine, bitmap, x, y, addr, &screen_rect);
807   state_save_combine_module_and_tag(unique_tag, "CDP1869", device->tag);
808   state_save_register_func_postload_ptr(cdp1869_state_save_postload, cdp1869);
556809
557            addr++;
810   state_save_register_item(unique_tag, 0, cdp1869->dispoff);
811   state_save_register_item(unique_tag, 0, cdp1869->fresvert);
812   state_save_register_item(unique_tag, 0, cdp1869->freshorz);
813   state_save_register_item(unique_tag, 0, cdp1869->cmem);
814   state_save_register_item(unique_tag, 0, cdp1869->dblpage);
815   state_save_register_item(unique_tag, 0, cdp1869->line16);
816   state_save_register_item(unique_tag, 0, cdp1869->line9);
817   state_save_register_item(unique_tag, 0, cdp1869->cfc);
818   state_save_register_item(unique_tag, 0, cdp1869->col);
819   state_save_register_item(unique_tag, 0, cdp1869->bkg);
820   state_save_register_item(unique_tag, 0, cdp1869->pma);
821   state_save_register_item(unique_tag, 0, cdp1869->hma);
558822
559            if (addr == pmemsize) addr = 0;
560         }
561      }
823   state_save_register_item(unique_tag, 0, cdp1869->signal);
824   state_save_register_item(unique_tag, 0, cdp1869->incr);
825   state_save_register_item(unique_tag, 0, cdp1869->toneoff);
826   state_save_register_item(unique_tag, 0, cdp1869->wnoff);
827   state_save_register_item(unique_tag, 0, cdp1869->tonediv);
828   state_save_register_item(unique_tag, 0, cdp1869->tonefreq);
829   state_save_register_item(unique_tag, 0, cdp1869->toneamp);
830   state_save_register_item(unique_tag, 0, cdp1869->wnfreq);
831   state_save_register_item(unique_tag, 0, cdp1869->wnamp);
832}
833
834static DEVICE_SET_INFO( cdp1869 )
835{
836   switch (state)
837   {
838      /* no parameters to set */
562839   }
563
564   return 0;
565840}
566841
567void cdp1869_configure(const CDP1869_interface *intf)
842DEVICE_GET_INFO( cdp1869_video )
568843{
569   if (intf->charrom_region != REGION_INVALID)
844   switch (state)
570845   {
571      UINT8 *memory = memory_region(intf->charrom_region);
572      memcpy(cdp1869.cram, memory, intf->charram_size);
846      /* --- the following bits of info are returned as 64-bit signed integers --- */
847      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cdp1869_t);            break;
848      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
849      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
850
851      /* --- the following bits of info are returned as pointers to data or functions --- */
852      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(cdp1869); break;
853      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cdp1869);   break;
854      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
855      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
856
857      /* --- the following bits of info are returned as NULL-terminated strings --- */
858      case DEVINFO_STR_NAME:                     info->s = "RCA CDP1869";               break;
859      case DEVINFO_STR_FAMILY:                  info->s = "RCA CDP1869";               break;
860      case DEVINFO_STR_VERSION:                  info->s = "1.0";                     break;
861      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                     break;
862      case DEVINFO_STR_CREDITS:                  info->s = "Copyright Nicola Salmoria and the MAME Team"; break;
573863   }
574
575   cdp1869.ntsc_pal = intf->video_format;
576   cdp1869.cramsize = intf->charram_size;
577   cdp1869.pramsize = intf->pageram_size;
578   cdp1869.color_callback = intf->get_color_bits;
579864}
src/emu/video/cdp1869.h
r2218r2219
3434#ifndef __CDP1869_VIDEO__
3535#define __CDP1869_VIDEO__
3636
37typedef enum _cdp1869_video_format cdp1869_video_format;
38
39enum _cdp1869_video_format {
40   CDP1869_NTSC,
41   CDP1869_PAL
42};
43
4437#define CDP1869_DOT_CLK_PAL         5626000.0
4538#define CDP1869_DOT_CLK_NTSC      5670000.0
4639#define CDP1869_COLOR_CLK_PAL      8867236.0
r2218r2219
5447#define CDP1869_HSYNC_START         (56 * CDP1869_CHAR_WIDTH)
5548#define CDP1869_HSYNC_END         (60 * CDP1869_CHAR_WIDTH)
5649#define CDP1869_HBLANK_START      (54 * CDP1869_CHAR_WIDTH)
57#define CDP1869_HBLANK_END         (5 * CDP1869_CHAR_WIDTH)
58#define CDP1869_SCREEN_START_PAL   (9 * CDP1869_CHAR_WIDTH)
50#define CDP1869_HBLANK_END         ( 5 * CDP1869_CHAR_WIDTH)
51#define CDP1869_SCREEN_START_PAL   ( 9 * CDP1869_CHAR_WIDTH)
5952#define CDP1869_SCREEN_START_NTSC   (10 * CDP1869_CHAR_WIDTH)
6053#define CDP1869_SCREEN_START      (10 * CDP1869_CHAR_WIDTH)
6154#define CDP1869_SCREEN_END         (50 * CDP1869_CHAR_WIDTH)
r2218r2219
8376#define CDP1869_SCANLINE_PREDISPLAY_END_NTSC   228
8477#define CDP1869_VISIBLE_SCANLINES_NTSC         (CDP1869_SCANLINE_DISPLAY_END_NTSC - CDP1869_SCANLINE_DISPLAY_START_NTSC)
8578
86#define CDP1869_FPS_PAL            CDP1869_DOT_CLK_PAL / CDP1869_SCREEN_WIDTH / CDP1869_TOTAL_SCANLINES_PAL
87#define CDP1869_FPS_NTSC         CDP1869_DOT_CLK_NTSC / CDP1869_SCREEN_WIDTH / CDP1869_TOTAL_SCANLINES_NTSC
79#define   CDP1869_PALETTE_LENGTH   8+64
8880
89#define CDP1869_WEIGHT_RED      30 // % of max luminance
90#define CDP1869_WEIGHT_GREEN   59
91#define CDP1869_WEIGHT_BLUE      11
81#define CDP1869_VIDEO      DEVICE_GET_INFO_NAME(cdp1869_video)
9282
93#define CDP1869_CHARRAM_SIZE   0x1000
94#define CDP1869_PAGERAM_SIZE   0x800
83typedef UINT8 (*cdp1869_char_ram_read_func)(const device_config *device, UINT16 pma, UINT8 cma);
84#define CDP1869_CHAR_RAM_READ(name) UINT8 name(const device_config *device, UINT16 pma, UINT8 cma)
9585
96#define CDP1869_COLUMNS_HALF   20
97#define CDP1869_COLUMNS_FULL   40
98#define CDP1869_ROWS_HALF      12
99#define CDP1869_ROWS_FULL_PAL   25
100#define CDP1869_ROWS_FULL_NTSC   24
86typedef void (*cdp1869_char_ram_write_func)(const device_config *device, UINT16 pma, UINT8 cma, UINT8 data);
87#define CDP1869_CHAR_RAM_WRITE(name) void name(const device_config *device, UINT16 pma, UINT8 cma, UINT8 data)
10188
102typedef struct CDP1869_interface
89typedef UINT8 (*cdp1869_page_ram_read_func)(const device_config *device, UINT16 pma);
90#define CDP1869_PAGE_RAM_READ(name) UINT8 name(const device_config *device, UINT16 pma)
91
92typedef void (*cdp1869_page_ram_write_func)(const device_config *device, UINT16 pma, UINT8 data);
93#define CDP1869_PAGE_RAM_WRITE(name) void name(const device_config *device, UINT16 pma, UINT8 data)
94
95typedef int (*cdp1869_pcb_read_func)(const device_config *device, UINT16 pma, UINT8 cma);
96#define CDP1869_PCB_READ(name) int name(const device_config *device, UINT16 pma, UINT8 cma)
97
98typedef void (*cdp1869_on_prd_changed_func) (const device_config *device, int prd);
99#define CDP1869_ON_PRD_CHANGED(name) void name(const device_config *device, int prd)
100
101typedef enum _cdp1869_format cdp1869_format;
102enum _cdp1869_format {
103   CDP1869_NTSC = 0,
104   CDP1869_PAL
105};
106
107/* interface */
108typedef struct _cdp1869_interface cdp1869_interface;
109struct _cdp1869_interface
103110{
104   cdp1869_video_format video_format;   // display format (NTSC/PAL)
105   int charrom_region;               // memory region to load CHARRAM from
106   UINT16 charram_size;            // CHARRAM size
107   UINT16 pageram_size;            // PAGERAM size
108   UINT8 (*get_color_bits)(UINT8 cramdata, UINT16 cramaddr, UINT16 pramaddr); // 0x01 = PCB, 0x02 = CCB0, 0x04 = CCB1
109} CDP1869_interface;
111   const char *screen_tag;      /* screen we are acting on */
112   int pixel_clock;         /* the dot clock of the chip */
113   int color_clock;         /* the chroma clock of the chip */
110114
111WRITE8_HANDLER ( cdp1869_out3_w );
112WRITE8_HANDLER ( cdp1869_out4_w );
113WRITE8_HANDLER ( cdp1869_out5_w );
114WRITE8_HANDLER ( cdp1869_out6_w );
115WRITE8_HANDLER ( cdp1869_out7_w );
115   cdp1869_format pal_ntsc;   /* screen format */
116116
117   /* page memory read function */
118   cdp1869_page_ram_read_func      page_ram_r;
119
120   /* page memory write function */
121   cdp1869_page_ram_write_func      page_ram_w;
122
123   /* page memory color bit read function */
124   cdp1869_pcb_read_func         pcb_r;
125
126   /* character memory read function */
127   cdp1869_char_ram_read_func      char_ram_r;
128
129   /* character memory write function */
130   cdp1869_char_ram_write_func      char_ram_w;
131
132   /* if specified, this gets called for every change of the predisplay pin (CDP1870/76 pin 1) */
133   cdp1869_on_prd_changed_func      on_prd_changed;
134};
135
136/* device interface */
137DEVICE_GET_INFO( cdp1869_video );
138
139/* palette initialization */
117140PALETTE_INIT( cdp1869 );
118VIDEO_START( cdp1869 );
119VIDEO_UPDATE( cdp1869 );
120141
121READ8_HANDLER ( cdp1869_charram_r );
122READ8_HANDLER ( cdp1869_pageram_r );
123WRITE8_HANDLER ( cdp1869_charram_w );
124WRITE8_HANDLER ( cdp1869_pageram_w );
142/* io port access */
143WRITE8_DEVICE_HANDLER( cdp1869_out3_w );
144WRITE8_DEVICE_HANDLER( cdp1869_out4_w );
145WRITE8_DEVICE_HANDLER( cdp1869_out5_w );
146WRITE8_DEVICE_HANDLER( cdp1869_out6_w );
147WRITE8_DEVICE_HANDLER( cdp1869_out7_w );
125148
126void cdp1869_configure(const CDP1869_interface *intf);
149/* character memory access */
150READ8_DEVICE_HANDLER ( cdp1869_charram_r );
151WRITE8_DEVICE_HANDLER ( cdp1869_charram_w );
127152
128UINT16 cdp1869_get_cma(UINT16 offset);
153/* page memory access */
154READ8_DEVICE_HANDLER ( cdp1869_pageram_r );
155WRITE8_DEVICE_HANDLER ( cdp1869_pageram_w );
129156
157/* updates the screen */
158void cdp1869_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
159
130160#endif
src/mess/drivers/tmc600.c
r2218r2219
8989#include "cpu/cdp1802/cdp1802.h"
9090#include "video/cdp1869.h"
9191
92#define SCREEN_TAG   "main"
93#define CDP1869_TAG   "cdp1869"
94
95#define TMC600_PAGERAM_SIZE   0x400
96#define TMC600_PAGERAM_MASK   0x3ff
97
9298/* Read/Write Handlers */
9399
94100static int vismac_reg_latch;
95101static int vismac_color_latch;
96102static int vismac_bkg_latch;
97103static int vismac_blink;
98static UINT8 vismac_colorram[0x400]; // 1024x4 bit color ram (0x08 = blink)
104static UINT8 *pageram, *vismac_colorram;
99105
100106static WRITE8_HANDLER( vismac_register_w )
101107{
102108   vismac_reg_latch = data;
103109}
104110
105static WRITE8_HANDLER( vismac_data_w )
111static WRITE8_DEVICE_HANDLER( vismac_data_w )
106112{
107113   switch (vismac_reg_latch)
108114   {
r2218r2219
114120   case 0x30:
115121      // write cdp1869 command on the data bus
116122      vismac_bkg_latch = data & 0x07;
117      cdp1869_out3_w(machine, 0, data);
123      cdp1869_out3_w(device, 0, data);
118124      break;
119125
120126   case 0x40:
121      cdp1869_out4_w(machine, 0, data);
127      cdp1869_out4_w(device, 0, data);
122128      break;
123129
124130   case 0x50:
125      cdp1869_out5_w(machine, 0, data);
131      cdp1869_out5_w(device, 0, data);
126132      break;
127133
128134   case 0x60:
129      cdp1869_out6_w(machine, 0, data);
135      cdp1869_out6_w(device, 0, data);
130136      break;
131137
132138   case 0x70:
133      cdp1869_out7_w(machine, 0, data);
139      cdp1869_out7_w(device, 0, data);
134140      break;
135141   }
136142}
137143
138static WRITE8_HANDLER( vismac_pageram_w )
139{
140   cdp1869_pageram_w( machine, offset, data );
141   vismac_colorram[offset] = vismac_color_latch;
142}
143
144144static int keylatch;
145145
146146static WRITE8_HANDLER( keyboard_latch_w )
r2218r2219
158158static ADDRESS_MAP_START( tmc600_map, ADDRESS_SPACE_PROGRAM, 8 )
159159   AM_RANGE(0x0000, 0x4fff) AM_ROM
160160   AM_RANGE(0x6000, 0x7fff) AM_RAM
161   AM_RANGE(0xf400, 0xf7ff) AM_READWRITE(cdp1869_charram_r, cdp1869_charram_w)
162   AM_RANGE(0xf800, 0xffff) AM_READWRITE(cdp1869_pageram_r, vismac_pageram_w)
161   AM_RANGE(0xf400, 0xf7ff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_charram_r, cdp1869_charram_w)
162   AM_RANGE(0xf800, 0xffff) AM_DEVREADWRITE(CDP1869_VIDEO, CDP1869_TAG, cdp1869_pageram_r, cdp1869_pageram_w)
163163ADDRESS_MAP_END
164164
165165static ADDRESS_MAP_START( tmc600_io_map, ADDRESS_SPACE_IO, 8 )
166166   AM_RANGE(0x03, 0x03) AM_WRITE(keyboard_latch_w)
167167   AM_RANGE(0x04, 0x04) AM_WRITE(printer_w)
168   AM_RANGE(0x05, 0x05) AM_WRITE(vismac_data_w)
168   AM_RANGE(0x05, 0x05) AM_DEVWRITE(CDP1869_VIDEO, CDP1869_TAG, vismac_data_w)
169169//  AM_RANGE(0x06, 0x06) AM_WRITE(floppy_w)
170170   AM_RANGE(0x07, 0x07) AM_WRITE(vismac_register_w)
171171ADDRESS_MAP_END
r2218r2219
309309   NULL
310310};
311311
312/* Video */
313
312314static INTERRUPT_GEN( vismac_blink_int )
313315{
314316   vismac_blink = !vismac_blink;
315317}
316318
319static UINT8 tmc600_get_color(UINT16 pma)
320{
321   UINT8 color = vismac_colorram[pma];
322
323   if (BIT(color, 3) && vismac_blink)
324   {
325      return vismac_bkg_latch;
326   }
327   else
328   {
329      return color;
330   }
331}
332
333static CDP1869_PAGE_RAM_READ(tmc600_pageram_r)
334{
335   UINT16 addr = pma & TMC600_PAGERAM_MASK;
336
337   return pageram[addr];
338}
339
340static CDP1869_PAGE_RAM_WRITE(tmc600_pageram_w)
341{
342   UINT16 addr = pma & TMC600_PAGERAM_MASK;
343
344   pageram[addr] = data;
345   vismac_colorram[addr] = vismac_color_latch;
346}
347
348static CDP1869_CHAR_RAM_READ(tmc600_charram_r)
349{
350   UINT16 pageaddr = pma & TMC600_PAGERAM_MASK;
351   UINT8 column = pageram[pageaddr];
352   UINT8 color = tmc600_get_color(pageaddr);
353   UINT16 charaddr = (column << 3) | (cma & 0x07);
354   UINT8 *charrom = memory_region(REGION_GFX1);
355   UINT8 cdb = charrom[charaddr] & 0x3f;
356
357   int ccb0 = BIT(color, 2);
358   int ccb1 = BIT(color, 1);
359
360   if (BIT(cma, 3))
361   {
362      charaddr += 0x800;
363   }
364
365   return (ccb1 << 7) | (ccb0 << 6) | cdb;
366}
367
368static CDP1869_CHAR_RAM_WRITE(tmc600_charram_w)
369{
370   // character ROM cannot be written to
371}
372
373static CDP1869_PCB_READ(tmc600_pcb_r)
374{
375   UINT16 pageaddr = pma & TMC600_PAGERAM_MASK;
376   UINT8 color = tmc600_get_color(pageaddr);
377
378   int pcb = BIT(color, 0);
379
380   return pcb;
381}
382
383static const cdp1869_interface tmc600_cdp1869_intf =
384{
385   SCREEN_TAG,
386   CDP1869_DOT_CLK_PAL,
387   CDP1869_COLOR_CLK_PAL,
388   CDP1869_PAL,
389   tmc600_pageram_r,
390   tmc600_pageram_w,
391   tmc600_pcb_r,
392   tmc600_charram_r,
393   tmc600_charram_w,
394   NULL
395};
396
397static VIDEO_START( tmc600 )
398{
399   // allocate memory
400
401   pageram = auto_malloc(TMC600_PAGERAM_SIZE);
402   vismac_colorram = auto_malloc(TMC600_PAGERAM_SIZE);
403
404   // register for save state
405
406   state_save_register_global_pointer(pageram, TMC600_PAGERAM_SIZE);
407   state_save_register_global_pointer(vismac_colorram, TMC600_PAGERAM_SIZE);
408}
409
410static VIDEO_UPDATE( tmc600 )
411{
412   const device_config *cdp1869 = device_list_find_by_tag(screen->machine->config->devicelist, CDP1869_VIDEO, CDP1869_TAG);
413
414   cdp1869_update(cdp1869, bitmap, cliprect);
415
416   return 0;
417}
418
317419/* Machine Initialization */
318420
319421static MACHINE_START( tmc600 )
r2218r2219
322424   state_save_register_global(vismac_color_latch);
323425   state_save_register_global(vismac_bkg_latch);
324426   state_save_register_global(vismac_blink);
325   state_save_register_global_array(vismac_colorram);
326427   state_save_register_global(keylatch);
327428}
328429
r2218r2219
348449
349450   // video hardware
350451
351   MDRV_SCREEN_ADD("main", RASTER)
452   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
352453   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
353454   MDRV_PALETTE_LENGTH(8+64)
354455   MDRV_PALETTE_INIT(cdp1869)
355   MDRV_VIDEO_START(cdp1869)
356   MDRV_VIDEO_UPDATE(cdp1869)
456   MDRV_VIDEO_START(tmc600)
457   MDRV_VIDEO_UPDATE(tmc600)
357458   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)
358459
460   MDRV_DEVICE_ADD(CDP1869_TAG, CDP1869_VIDEO)
461   MDRV_DEVICE_CONFIG(tmc600_cdp1869_intf)
462
359463   // sound hardware
360464
361465   MDRV_SPEAKER_STANDARD_MONO("mono")
r2218r2219
374478   ROM_LOAD( "sb23",      0x3000, 0x1000, NO_DUMP )
375479   ROM_LOAD( "190482_2",   0x4000, 0x1000, NO_DUMP )
376480
377   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
481   ROM_REGION( 0x1000, REGION_GFX1, 0 )
378482   ROM_LOAD( "chargen",   0x0000, 0x1000, NO_DUMP )
379483ROM_END
380484
r2218r2219
386490   ROM_LOAD( "sb33",      0x3000, 0x1000, CRC(b7d241fa) SHA1(6f3eadf86c4e3aaf93d123e302a18dc4d9db964b) )
387491   ROM_LOAD( "151182",      0x4000, 0x1000, CRC(c1a8d9d8) SHA1(4552e1f06d0e338ba7b0f1c3a20b8a51c27dafde) )
388492
389   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
493   ROM_REGION( 0x1000, REGION_GFX1, 0 )
390494   ROM_LOAD( "chargen",   0x0000, 0x1000, CRC(93f92cbf) SHA1(371156fb38fa5319c6fde537ccf14eed94e7adfb) )
391495ROM_END
392496
r2218r2219
466570   CONFIG_DEVICE(tmc600_quickload_getinfo)
467571SYSTEM_CONFIG_END
468572
469static UINT8 tmc600_get_color_bits(UINT8 cramdata, UINT16 cramaddr, UINT16 pramaddr)
470{
471   UINT8 color = vismac_colorram[pramaddr];
472
473   if ((color & 0x08) && vismac_blink)
474   {
475      return vismac_bkg_latch;
476   }
477   else
478   {
479      return color;
480   }
481}
482
483static const CDP1869_interface tmc600_CDP1869_interface =
484{
485   CDP1869_PAL,
486   REGION_GFX1,
487   0x1000,               // charrom size
488   0x400,               // pageram size
489   tmc600_get_color_bits   // color bit callback
490};
491
492static DRIVER_INIT( tmc600 )
493{
494   cdp1869_configure(&tmc600_CDP1869_interface);
495}
496
497573/* System Drivers */
498574
499575//    YEAR  NAME      PARENT    COMPAT   MACHINE   INPUT     INIT    CONFIG    COMPANY        FULLNAME
500COMP( 1982, tmc600s1, 0,      0,        tmc600,   tmc600,   tmc600, tmc600,   "Telercas Oy", "Telmac TMC-600 (Sarja I)",  GAME_NOT_WORKING )
501COMP( 1982, tmc600s2, 0,      0,        tmc600,   tmc600,   tmc600, tmc600,   "Telercas Oy", "Telmac TMC-600 (Sarja II)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
576COMP( 1982, tmc600s1, 0,      0,        tmc600,   tmc600,   0,    tmc600,   "Telercas Oy", "Telmac TMC-600 (Sarja I)",  GAME_NOT_WORKING )
577COMP( 1982, tmc600s2, 0,      0,        tmc600,   tmc600,   0,    tmc600,   "Telercas Oy", "Telmac TMC-600 (Sarja II)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team