Previous 15994 Revisions Next

r1813 Saturday 1st March, 2008 at 03:31:04 UTC by Nathan Woods
mc6845 sync with MAME
[src/emu/video]mc6845.c mc6845.h

src/emu/video/mc6845.c
r1812r1813
2626#include "mc6845.h"
2727
2828
29#define LOG      (0)
29#define LOG      (1)
3030
3131
32/* device types */
33enum
34{
35   TYPE_MC6845,
36   TYPE_R6545
37};
38
39
3240struct _mc6845_t
3341{
42   int device_type;
3443   running_machine *machine;
3544   const mc6845_interface *intf;
3645
3746   /* internal registers */
3847   UINT8   address_latch;
39   UINT8   horiz_total;
48   UINT8   horiz_char_total;
4049   UINT8   horiz_disp;
4150   UINT8   horiz_sync_pos;
42   UINT8   horiz_sync_width;
43   UINT8   vert_total;
51   UINT8   sync_width;
52   UINT8   vert_char_total;
4453   UINT8   vert_total_adj;
4554   UINT8   vert_disp;
4655   UINT8   vert_sync_pos;
r1812r1813
5261   UINT16   cursor_addr;
5362   UINT16   light_pen_addr;
5463
64   /* other internal state */
65   UINT8   cursor_state;   /* 0 = off, 1 = on */
66   UINT8   cursor_blink_count;
67
68   /* timers */
5569   emu_timer *de_changed_timer;
5670   emu_timer *hsync_on_timer;
5771   emu_timer *hsync_off_timer;
5872   emu_timer *vsync_on_timer;
5973   emu_timer *vsync_off_timer;
60   UINT8   cursor_state;   /* 0 = off, 1 = on */
61   UINT8   cursor_blink_count;
74   emu_timer *light_pen_latch_timer;
6275
63   /* saved screen parameters so we don't call
64       video_screen_configure() unneccessarily.
65       Do NOT state save these! */
66   UINT16   last_horiz_total;
67   UINT16   last_vert_total;
68   UINT16   last_max_x;
69   UINT16   last_max_y;
70   UINT16   last_hsync_on_pos;
71   UINT16   last_hsync_off_pos;
72   UINT16   last_vsync_on_pos;
73   UINT16   last_vsync_off_pos;
76   /* computed values - do NOT state save these! */
77   UINT16   horiz_pix_total;
78   UINT16   vert_pix_total;
79   UINT16   max_visible_x;
80   UINT16   max_visible_y;
81   UINT16   hsync_on_pos;
82   UINT16   hsync_off_pos;
83   UINT16   vsync_on_pos;
84   UINT16   vsync_off_pos;
7485   UINT16  current_ma;      /* the MA address currently drawn */
7586   int      has_valid_parameters;
7687};
r1812r1813
8192static void update_de_changed_timer(mc6845_t *mc6845);
8293static void update_hsync_changed_timers(mc6845_t *mc6845);
8394static void update_vsync_changed_timers(mc6845_t *mc6845);
84static TIMER_CALLBACK( de_changed_timer_cb );
85static TIMER_CALLBACK( vsync_on_timer_cb );
86static TIMER_CALLBACK( vsync_off_timer_cb );
87static TIMER_CALLBACK( hsync_on_timer_cb );
88static TIMER_CALLBACK( hsync_off_timer_cb );
8995
9096
9197static void mc6845_state_save_postload(void *param)
9298{
93   mc6845_t *mc6845 = (mc6845_t *)param;
94
95   configure_screen(mc6845, TRUE);
99   configure_screen(param, TRUE);
96100}
97101
98102
r1812r1813
136140
137141   switch (mc6845->address_latch)
138142   {
139      case 0x00:  mc6845->horiz_total      =   data & 0xff; break;
143      case 0x00:  mc6845->horiz_char_total =   data & 0xff; break;
140144      case 0x01:  mc6845->horiz_disp       =   data & 0xff; break;
141145      case 0x02:  mc6845->horiz_sync_pos   =   data & 0xff; break;
142      case 0x03:  mc6845->horiz_sync_width =   data & 0x0f; break;
143      case 0x04:  mc6845->vert_total       =   data & 0x7f; break;
146      case 0x03:  mc6845->sync_width       =   data & 0xff; break;
147      case 0x04:  mc6845->vert_char_total  =   data & 0x7f; break;
144148      case 0x05:  mc6845->vert_total_adj   =   data & 0x1f; break;
145149      case 0x06:  mc6845->vert_disp        =   data & 0x7f; break;
146150      case 0x07:  mc6845->vert_sync_pos    =   data & 0x7f; break;
r1812r1813
165169{
166170   if (mc6845->intf)
167171   {
172      UINT16 hsync_on_pos, hsync_off_pos, vsync_on_pos, vsync_off_pos;
173
168174      /* compute the screen sizes */
169      UINT16 horiz_total = (mc6845->horiz_total + 1) * mc6845->intf->hpixels_per_column;
170      UINT16 vert_total = (mc6845->vert_total + 1) * (mc6845->max_ras_addr + 1) + mc6845->vert_total_adj;
175      UINT16 horiz_pix_total = (mc6845->horiz_char_total + 1) * mc6845->intf->hpixels_per_column;
176      UINT16 vert_pix_total = (mc6845->vert_char_total + 1) * (mc6845->max_ras_addr + 1) + mc6845->vert_total_adj;
171177
172178      /* determine the visible area, avoid division by 0 */
173      UINT16 max_x = mc6845->horiz_disp * mc6845->intf->hpixels_per_column - 1;
174      UINT16 max_y = mc6845->vert_disp * (mc6845->max_ras_addr + 1) - 1;
179      UINT16 max_visible_x = mc6845->horiz_disp * mc6845->intf->hpixels_per_column - 1;
180      UINT16 max_visible_y = mc6845->vert_disp * (mc6845->max_ras_addr + 1) - 1;
175181
176182      /* determine the syncing positions */
177      UINT16 hsync_on_pos = mc6845->horiz_sync_pos * mc6845->intf->hpixels_per_column;
178      UINT16 hsync_off_pos = hsync_on_pos + (mc6845->horiz_sync_width * mc6845->intf->hpixels_per_column);
179      UINT16 vsync_on_pos = mc6845->vert_sync_pos * (mc6845->max_ras_addr + 1);
180      UINT16 vsync_off_pos = vsync_on_pos + 0x10;   /* this is a constant -- non-programmable */
183      UINT8 horiz_sync_char_width = mc6845->sync_width & 0x0f;
184      UINT8 vert_sync_pix_height = (mc6845->device_type == TYPE_MC6845) ? 0x10 : (mc6845->sync_width >> 4) & 0x0f;
181185
186      if (horiz_sync_char_width == 0)
187         horiz_sync_char_width = 0x10;
188
189      if (vert_sync_pix_height == 0)
190         vert_sync_pix_height = 0x10;
191
192      hsync_on_pos = mc6845->horiz_sync_pos * mc6845->intf->hpixels_per_column;
193      hsync_off_pos = hsync_on_pos + (horiz_sync_char_width * mc6845->intf->hpixels_per_column);
194      vsync_on_pos = mc6845->vert_sync_pos * (mc6845->max_ras_addr + 1);
195      vsync_off_pos = vsync_on_pos + vert_sync_pix_height;
196
197      /* the Commodore 40xx series computers program a horizontal synch pulse that extends
198           past the scanline width.  I am assume that the real device will clamp it */
199      if (hsync_off_pos > horiz_pix_total)
200         hsync_off_pos = horiz_pix_total;
201
202      if (vsync_off_pos > vert_pix_total)
203         vsync_off_pos = vert_pix_total;
204
182205      /* update only if screen parameters changed, unless we are coming here after loading the saved state */
183206      if (postload ||
184          (horiz_total != mc6845->last_horiz_total) || (vert_total != mc6845->last_vert_total) ||
185         (max_x != mc6845->last_max_x) || (max_y != mc6845->last_max_y) ||
186         (hsync_on_pos != mc6845->last_hsync_on_pos) || (vsync_on_pos != mc6845->last_vsync_on_pos) ||
187         (hsync_off_pos != mc6845->last_hsync_off_pos) || (vsync_off_pos != mc6845->last_vsync_off_pos))
207          (horiz_pix_total != mc6845->horiz_pix_total) || (vert_pix_total != mc6845->vert_pix_total) ||
208         (max_visible_x != mc6845->max_visible_x) || (max_visible_y != mc6845->max_visible_y) ||
209         (hsync_on_pos != mc6845->hsync_on_pos) || (vsync_on_pos != mc6845->vsync_on_pos) ||
210         (hsync_off_pos != mc6845->hsync_off_pos) || (vsync_off_pos != mc6845->vsync_off_pos))
188211      {
189212         /* update the screen if we have valid data */
190         if ((horiz_total > 0) && (max_x < horiz_total) &&
191            (vert_total > 0) && (max_y < vert_total) &&
192            (hsync_off_pos <= horiz_total) && (vsync_off_pos <= vert_total) &&
213         if ((horiz_pix_total > 0) && (max_visible_x < horiz_pix_total) &&
214            (vert_pix_total > 0) && (max_visible_y < vert_pix_total) &&
215            (hsync_on_pos <= horiz_pix_total) && (vsync_on_pos <= vert_pix_total) &&
193216            (hsync_on_pos != hsync_off_pos))
194217         {
195218            rectangle visarea;
196219
197            attoseconds_t refresh = HZ_TO_ATTOSECONDS(mc6845->intf->clock) * (mc6845->horiz_total + 1) * vert_total;
220            attoseconds_t refresh = HZ_TO_ATTOSECONDS(mc6845->intf->clock) * (mc6845->horiz_char_total + 1) * vert_pix_total;
198221
199222            visarea.min_x = 0;
200223            visarea.min_y = 0;
201            visarea.max_x = max_x;
202            visarea.max_y = max_y;
224            visarea.max_x = max_visible_x;
225            visarea.max_y = max_visible_y;
203226
204227            if (LOG) logerror("M6845 config screen: HTOTAL: 0x%x  VTOTAL: 0x%x  MAX_X: 0x%x  MAX_Y: 0x%x  HSYNC: 0x%x-0x%x  VSYNC: 0x%x-0x%x  Freq: %ffps\n",
205                          horiz_total, vert_total, max_x, max_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
228                          horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
206229
207            video_screen_configure(mc6845->intf->scrnum, horiz_total, vert_total, &visarea, refresh);
230            video_screen_configure(mc6845->intf->scrnum, horiz_pix_total, vert_pix_total, &visarea, refresh);
208231
209232            mc6845->has_valid_parameters = TRUE;
210233         }
211234         else
212235            mc6845->has_valid_parameters = FALSE;
213236
214         mc6845->last_horiz_total = horiz_total;
215         mc6845->last_vert_total = vert_total;
216         mc6845->last_max_x = max_x;
217         mc6845->last_max_y = max_y;
218         mc6845->last_hsync_on_pos = hsync_on_pos;
219         mc6845->last_hsync_off_pos = hsync_off_pos;
220         mc6845->last_vsync_on_pos = vsync_on_pos;
221         mc6845->last_vsync_off_pos = vsync_off_pos;
237         mc6845->horiz_pix_total = horiz_pix_total;
238         mc6845->vert_pix_total = vert_pix_total;
239         mc6845->max_visible_x = max_visible_x;
240         mc6845->max_visible_y = max_visible_y;
241         mc6845->hsync_on_pos = hsync_on_pos;
242         mc6845->hsync_off_pos = hsync_off_pos;
243         mc6845->vsync_on_pos = vsync_on_pos;
244         mc6845->vsync_off_pos = vsync_off_pos;
222245
223246         update_de_changed_timer(mc6845);
224247         update_hsync_changed_timers(mc6845);
r1812r1813
233256   UINT16 y = video_screen_get_vpos(mc6845->intf->scrnum);
234257   UINT16 x = video_screen_get_hpos(mc6845->intf->scrnum);
235258
236   return (y <= mc6845->last_max_y) && (x <= mc6845->last_max_x);
259   return (y <= mc6845->max_visible_y) && (x <= mc6845->max_visible_x);
237260}
238261
239262
r1812r1813
250273      {
251274         /* normally, it's at end the current raster line */
252275         next_y = video_screen_get_vpos(mc6845->intf->scrnum);
253         next_x = mc6845->last_max_x + 1;
276         next_x = mc6845->max_visible_x + 1;
254277
255         /* but if visible width = horiz_total, then we need
278         /* but if visible width = horiz_pix_total, then we need
256279               to go to the beginning of VBLANK */
257         if (next_x == mc6845->last_horiz_total)
280         if (next_x == mc6845->horiz_pix_total)
258281         {
259            next_y = mc6845->last_max_y + 1;
282            next_y = mc6845->max_visible_y + 1;
260283            next_x = 0;
261284
262285            /* abnormal case, no vertical blanking, either */
263            if (next_y == mc6845->last_vert_total)
286            if (next_y == mc6845->vert_pix_total)
264287               next_y = -1;
265288         }
266289      }
r1812r1813
269292      else
270293      {
271294         next_x = 0;
272         next_y = (video_screen_get_vpos(mc6845->intf->scrnum) + 1) % mc6845->last_vert_total;
295         next_y = (video_screen_get_vpos(mc6845->intf->scrnum) + 1) % mc6845->vert_pix_total;
273296
274297         /* if we would now fall in the vertical blanking, we need
275298               to go to the top of the screen */
276         if (next_y > mc6845->last_max_y)
299         if (next_y > mc6845->max_visible_y)
277300            next_y = 0;
278301      }
279302
r1812r1813
294317      UINT16 next_y;
295318
296319      /* we are before the HSYNC position, we trigger on the current line */
297      if (video_screen_get_hpos(mc6845->intf->scrnum) < mc6845->last_hsync_on_pos)
320      if (video_screen_get_hpos(mc6845->intf->scrnum) < mc6845->hsync_on_pos)
298321         next_y = video_screen_get_vpos(mc6845->intf->scrnum);
299322
300323      /* trigger on the next line */
301324      else
302         next_y = (video_screen_get_vpos(mc6845->intf->scrnum) + 1) % mc6845->last_vert_total;
325         next_y = (video_screen_get_vpos(mc6845->intf->scrnum) + 1) % mc6845->vert_pix_total;
303326
304327      /* if the next line is not in the visible region, go to the beginning of the screen */
305      if (next_y > mc6845->last_max_y)
328      if (next_y > mc6845->max_visible_y)
306329         next_y = 0;
307330
308      timer_adjust_oneshot(mc6845->hsync_on_timer,  video_screen_get_time_until_pos(mc6845->intf->scrnum, next_y, mc6845->last_hsync_on_pos) , 0);
309      timer_adjust_oneshot(mc6845->hsync_off_timer, video_screen_get_time_until_pos(mc6845->intf->scrnum, next_y, mc6845->last_hsync_off_pos), 0);
331      timer_adjust_oneshot(mc6845->hsync_on_timer,  video_screen_get_time_until_pos(mc6845->intf->scrnum, next_y, mc6845->hsync_on_pos) , 0);
332      timer_adjust_oneshot(mc6845->hsync_off_timer, video_screen_get_time_until_pos(mc6845->intf->scrnum, next_y, mc6845->hsync_off_pos), 0);
310333   }
311334}
312335
r1812r1813
315338{
316339   if (mc6845->has_valid_parameters && (mc6845->vsync_on_timer != NULL))
317340   {
318      timer_adjust_oneshot(mc6845->vsync_on_timer,  video_screen_get_time_until_pos(mc6845->intf->scrnum, mc6845->last_vsync_on_pos,  0), 0);
319      timer_adjust_oneshot(mc6845->vsync_off_timer, video_screen_get_time_until_pos(mc6845->intf->scrnum, mc6845->last_vsync_off_pos, 0), 0);
341      timer_adjust_oneshot(mc6845->vsync_on_timer,  video_screen_get_time_until_pos(mc6845->intf->scrnum, mc6845->vsync_on_pos,  0), 0);
342      timer_adjust_oneshot(mc6845->vsync_off_timer, video_screen_get_time_until_pos(mc6845->intf->scrnum, mc6845->vsync_off_pos, 0), 0);
320343   }
321344}
322345
r1812r1813
373396
374397
375398
376static UINT16 get_ma_for_yx(mc6845_t *mc6845, int y, int x)
399UINT16 mc6845_get_ma(mc6845_t *mc6845)
377400{
378401   UINT16 ret;
379402
403   assert(mc6845 != NULL);
404
380405   if (mc6845->has_valid_parameters)
381406   {
382407      /* clamp Y/X to the visible region */
408      int y = video_screen_get_vpos(mc6845->intf->scrnum);
409      int x = video_screen_get_hpos(mc6845->intf->scrnum);
383410
384411      /* since the MA counter stops in the blanking regions, if we are in a
385412           VBLANK, both X and Y are at their max */
386      if ((y > mc6845->last_max_y) || (x > mc6845->last_max_x))
387         x = mc6845->last_max_x;
413      if ((y > mc6845->max_visible_y) || (x > mc6845->max_visible_x))
414         x = mc6845->max_visible_x;
388415
389      if (y > mc6845->last_max_y)
390         y = mc6845->last_max_y;
416      if (y > mc6845->max_visible_y)
417         y = mc6845->max_visible_y;
391418
392419      ret = (mc6845->start_addr +
393420           (y / (mc6845->max_ras_addr + 1)) * mc6845->horiz_disp +
r1812r1813
400427}
401428
402429
403UINT16 mc6845_get_ma(mc6845_t *mc6845)
404{
405   UINT16 ret;
406
407   assert(mc6845 != NULL);
408
409   if (mc6845->has_valid_parameters)
410   {
411      int y = video_screen_get_vpos(mc6845->intf->scrnum);
412      int x = video_screen_get_hpos(mc6845->intf->scrnum);
413
414      ret = get_ma_for_yx(mc6845, y, x);
415   }
416   else
417      ret = 0;
418
419   return ret;
420}
421
422
423430UINT8 mc6845_get_ra(mc6845_t *mc6845)
424431{
425432   UINT8 ret;
r1812r1813
431438      /* get the current vertical raster position and clamp it to the visible region */
432439      int y = video_screen_get_vpos(mc6845->intf->scrnum);
433440
434      if (y > mc6845->last_max_y)
435         y = mc6845->last_max_y;
441      if (y > mc6845->max_visible_y)
442         y = mc6845->max_visible_y;
436443
437444      ret = y % (mc6845->max_ras_addr + 1);
438445   }
r1812r1813
443450}
444451
445452
453static TIMER_CALLBACK( light_pen_latch_timer_cb )
454{
455   mc6845_t *mc6845 = ptr;
456
457   mc6845->light_pen_addr = mc6845_get_ma(mc6845);
458}
459
460
446461void mc6845_assert_light_pen_input(mc6845_t *mc6845)
447462{
448463   int y, x;
464   int char_x;
449465
450466   assert(mc6845 != NULL);
451467
452   /* the light pen address register gets latched on the NEXT display address change */
453   y = video_screen_get_vpos(mc6845->intf->scrnum);
454   x = video_screen_get_hpos(mc6845->intf->scrnum) + mc6845->intf->hpixels_per_column;
468   if (mc6845->has_valid_parameters)
469   {
470      /* get the current pixel coordinates */
471      y = video_screen_get_vpos(mc6845->intf->scrnum);
472      x = video_screen_get_hpos(mc6845->intf->scrnum);
455473
456   mc6845->light_pen_addr = get_ma_for_yx(mc6845, y, x);
474      /* compute the pixel coordinate of the NEXT character -- this is when the light pen latches */
475      char_x = x / mc6845->intf->hpixels_per_column;
476      x = (char_x + 1) * mc6845->intf->hpixels_per_column;
477
478      /* adjust if we are passed the boundaries of the screen */
479      if (x == mc6845->horiz_pix_total)
480      {
481         y = y + 1;
482         x = 0;
483
484         if (y == mc6845->vert_pix_total)
485            y = 0;
486      }
487
488      /* set the timer that will latch the display address into the light pen registers */
489      timer_adjust_oneshot(mc6845->light_pen_latch_timer, video_screen_get_time_until_pos(mc6845->intf->scrnum, y, x), 0);
490   }
457491}
458492
459493
r1812r1813
488522}
489523
490524
491void mc6845_update(mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect)
525void mc6845_update(mc6845_t *mc6845, bitmap_t *bitmap, const rectangle *cliprect)
492526{
527   assert(mc6845 != NULL);
528   assert(bitmap != NULL);
529   assert(cliprect != NULL);
530
493531   if (mc6845->has_valid_parameters)
494532   {
495533      UINT16 y;
496534
497      /* call the set up function if any */
498535      void *param = NULL;
499536
500      if (mc6845->intf->begin_update)
537      assert(mc6845->intf != NULL);
538      assert(mc6845->intf->update_row != NULL);
539
540      /* call the set up function if any */
541      if (mc6845->intf->begin_update != NULL)
501542         param = mc6845->intf->begin_update(mc6845->machine, mc6845, bitmap, cliprect);
502543
503544      if (cliprect->min_y == 0)
r1812r1813
534575      }
535576
536577      /* call the tear down function if any */
537      if (mc6845->intf->end_update)
578      if (mc6845->intf->end_update != NULL)
538579         mc6845->intf->end_update(mc6845->machine, mc6845, bitmap, cliprect, param);
539580
540581      popmessage(NULL);
541582   }
542583   else
543      popmessage("Invalid MC6845 screen parameters - display disabed!!!");
584      popmessage("Invalid MC6845 screen parameters - display disabled!!!");
544585}
545586
546587
547588/* device interface */
548static void *mc6845_start(running_machine *machine, const char *tag, const void *static_config, const void *inline_config)
589static void *common_start(running_machine *machine, const char *tag, const void *static_config, const void *inline_config, int device_type)
549590{
550591   mc6845_t *mc6845;
551592   char unique_tag[30];
r1812r1813
559600   mc6845 = auto_malloc(sizeof(*mc6845));
560601   memset(mc6845, 0, sizeof(*mc6845));
561602
603   mc6845->device_type = device_type;
562604   mc6845->machine = machine;
563605   mc6845->intf = static_config;
564606
565607   /* create the timers for the various pin notifications */
566   if (mc6845->intf)
608   if (mc6845->intf != NULL)
567609   {
568      if (mc6845->intf->on_de_changed)
610      if (mc6845->intf->on_de_changed != NULL)
569611         mc6845->de_changed_timer = timer_alloc(de_changed_timer_cb, mc6845);
570612
571      if (mc6845->intf->on_hsync_changed)
613      if (mc6845->intf->on_hsync_changed != NULL)
572614      {
573615         mc6845->hsync_on_timer = timer_alloc(hsync_on_timer_cb, mc6845);
574616         mc6845->hsync_off_timer = timer_alloc(hsync_off_timer_cb, mc6845);
575617      }
576618
577      if (mc6845->intf->on_vsync_changed)
619      if (mc6845->intf->on_vsync_changed != NULL)
578620      {
579621         mc6845->vsync_on_timer = timer_alloc(vsync_on_timer_cb, mc6845);
580622         mc6845->vsync_off_timer = timer_alloc(vsync_off_timer_cb, mc6845);
581623      }
582624   }
583625
626   mc6845->light_pen_latch_timer = timer_alloc(light_pen_latch_timer_cb, mc6845);
627
584628   /* register for state saving */
585   state_save_combine_module_and_tag(unique_tag, "mc6845", tag);
629   switch (device_type)
630   {
631   case TYPE_MC6845:
632   default:
633      state_save_combine_module_and_tag(unique_tag, "mc6845", tag);
634      break;
586635
636   case TYPE_R6545:
637      state_save_combine_module_and_tag(unique_tag, "r6545", tag);
638      break;
639   }
640
587641   state_save_register_func_postload_ptr(mc6845_state_save_postload, mc6845);
588642
589643   state_save_register_item(unique_tag, 0, mc6845->address_latch);
590   state_save_register_item(unique_tag, 0, mc6845->horiz_total);
644   state_save_register_item(unique_tag, 0, mc6845->horiz_char_total);
591645   state_save_register_item(unique_tag, 0, mc6845->horiz_disp);
592646   state_save_register_item(unique_tag, 0, mc6845->horiz_sync_pos);
593   state_save_register_item(unique_tag, 0, mc6845->horiz_sync_width);
594   state_save_register_item(unique_tag, 0, mc6845->vert_total);
647   state_save_register_item(unique_tag, 0, mc6845->sync_width);
648   state_save_register_item(unique_tag, 0, mc6845->vert_char_total);
595649   state_save_register_item(unique_tag, 0, mc6845->vert_total_adj);
596650   state_save_register_item(unique_tag, 0, mc6845->vert_disp);
597651   state_save_register_item(unique_tag, 0, mc6845->vert_sync_pos);
r1812r1813
608662   return mc6845;
609663}
610664
665static void *mc6845_start(running_machine *machine, const char *tag, const void *static_config, const void *inline_config)
666{
667   return common_start(machine, tag, static_config, inline_config, TYPE_MC6845);
668}
611669
670static void *r6545_start(running_machine *machine, const char *tag, const void *static_config, const void *inline_config)
671{
672   return common_start(machine, tag, static_config, inline_config, TYPE_R6545);
673}
674
675
676static void mc6845_reset(running_machine *machine, void *token)
677{
678   mc6845_t *mc6845 = token;
679
680   /* internal registers remain unchanged, all outputs go low */
681   if (mc6845->intf != NULL)
682   {
683      if (mc6845->intf->on_de_changed != NULL)
684         mc6845->intf->on_de_changed(machine, mc6845, FALSE);
685
686      if (mc6845->intf->on_hsync_changed != NULL)
687         mc6845->intf->on_hsync_changed(machine, mc6845, FALSE);
688
689      if (mc6845->intf->on_vsync_changed != NULL)
690         mc6845->intf->on_vsync_changed(machine, mc6845, FALSE);
691   }
692}
693
694
612695static void mc6845_set_info(running_machine *machine, void *token, UINT32 state, const deviceinfo *info)
613696{
614697   switch (state)
r1812r1813
629712      case DEVINFO_FCT_SET_INFO:                  info->set_info = mc6845_set_info;      break;
630713      case DEVINFO_FCT_START:                     info->start = mc6845_start;            break;
631714      case DEVINFO_FCT_STOP:                     /* Nothing */                     break;
632      case DEVINFO_FCT_RESET:                     /* Nothing */                     break;
715      case DEVINFO_FCT_RESET:                     info->reset = mc6845_reset;            break;
633716
634717      /* --- the following bits of info are returned as NULL-terminated strings --- */
635718      case DEVINFO_STR_NAME:                     info->s = "MC6845";                  break;
636719      case DEVINFO_STR_FAMILY:                  info->s = "MC6845 CRTC";            break;
637      case DEVINFO_STR_VERSION:                  info->s = "1.5";                  break;
720      case DEVINFO_STR_VERSION:                  info->s = "1.6";                  break;
638721      case DEVINFO_STR_SOURCE_FILE:               info->s = __FILE__;                  break;
639722      case DEVINFO_STR_CREDITS:                  info->s = "Copyright Nicola Salmoria and the MAME Team"; break;
640723   }
r1812r1813
647730   {
648731      /* --- the following bits of info are returned as NULL-terminated strings --- */
649732      case DEVINFO_STR_NAME:                     info->s = "R6545";                  break;
733
734      /* --- the following bits of info are returned as pointers to data or functions --- */
735      case DEVINFO_FCT_START:                     info->start = r6545_start;            break;
736
650737      default: mc6845_get_info(machine, token, state, info);                           break;
651738   }
652739}
src/emu/video/mc6845.h
r1812r1813
1919
2020
2121/* callback definitions */
22typedef void * (*mc6845_begin_update_func)(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect);
23#define MC6845_BEGIN_UPDATE(name)   void *name(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect)
22typedef void * (*mc6845_begin_update_func)(running_machine *machine, mc6845_t *mc6845, bitmap_t *bitmap, const rectangle *cliprect);
23#define MC6845_BEGIN_UPDATE(name)   void *name(running_machine *machine, mc6845_t *mc6845, bitmap_t *bitmap, const rectangle *cliprect)
2424
25typedef void (*mc6845_update_row_func)(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap,
25typedef void (*mc6845_update_row_func)(running_machine *machine, mc6845_t *mc6845, bitmap_t *bitmap,
2626                                 const rectangle *cliprect, UINT16 ma, UINT8 ra,
2727                                 UINT16 y, UINT8 x_count, INT8 cursor_x, void *param);
28#define MC6845_UPDATE_ROW(name)      void name(running_machine *machine, mc6845_t *mc6845, mame_bitmap *bitmap,   \
28#define MC6845_UPDATE_ROW(name)      void name(running_machine *machine, mc6845_t *mc6845, bitmap_t *bitmap,   \
2929                                      const rectangle *cliprect, UINT16 ma, UINT8 ra,               \
3030                                      UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
3131
3232typedef void (*mc6845_end_update_func)(running_machine *machine, mc6845_t *mc6845,
33                                 mame_bitmap *bitmap, const rectangle *cliprect, void *param);
33                                 bitmap_t *bitmap, const rectangle *cliprect, void *param);
3434#define MC6845_END_UPDATE(name)      void name(running_machine *machine, mc6845_t *mc6845,                  \
35                                      mame_bitmap *bitmap, const rectangle *cliprect, void *param)
35                                      bitmap_t *bitmap, const rectangle *cliprect, void *param)
3636
3737typedef void (*mc6845_on_de_changed_func)(running_machine *machine, mc6845_t *mc6845, int display_enabled);
3838#define MC6845_ON_DE_CHANGED(name)   void name(running_machine *machine, mc6845_t *mc6845, int display_enabled)
r1812r1813
101101/* updates the screen -- this will call begin_update(),
102102   followed by update_row() reapeatedly and after all row
103103   updating is complete, end_update() */
104void mc6845_update(mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *cliprect);
104void mc6845_update(mc6845_t *mc6845, bitmap_t *bitmap, const rectangle *cliprect);
105105
106106
107107#endif

Previous 15994 Revisions Next


© 1998-2018 The MESS Team