Previous 15994 Revisions Next

r2078 Sunday 23rd March, 2008 at 17:12:42 UTC by Nathan Woods
Another mc6845 update by Zsolt
[src/emu/video]mc6845.c mc6845.h

src/emu/video/mc6845.c
r2077r2078
4545
4646
4747/* tags for state saving */
48const char * const device_tags[NUM_TYPES] = {           "mc6845", "mc6845-1", "c6545-1", "r6545-1", "h46505", "hd6845", "sy6545-1" };
48static const char * const device_tags[NUM_TYPES] = {     "mc6845", "mc6845-1", "c6545-1", "r6545-1", "h46505", "hd6845", "sy6545-1" };
4949
5050/* capabilities */
5151static const int supports_disp_start_addr_r[NUM_TYPES] = {  TRUE,       TRUE,     FALSE,     FALSE,    FALSE,    FALSE,      FALSE };
r2077r2078
8181   /* other internal state */
8282   UINT64   clock;
8383   UINT8   register_address_latch;
84   UINT8   hpixels_per_column;
8485   UINT8   cursor_state;   /* 0 = off, 1 = on */
8586   UINT8   cursor_blink_count;
8687
r2077r2078
228229      UINT16 hsync_on_pos, hsync_off_pos, vsync_on_pos, vsync_off_pos;
229230
230231      /* compute the screen sizes */
231      UINT16 horiz_pix_total = (mc6845->horiz_char_total + 1) * mc6845->intf->hpixels_per_column;
232      UINT16 horiz_pix_total = (mc6845->horiz_char_total + 1) * mc6845->hpixels_per_column;
232233      UINT16 vert_pix_total = (mc6845->vert_char_total + 1) * (mc6845->max_ras_addr + 1) + mc6845->vert_total_adj;
233234
234235      /* determine the visible area, avoid division by 0 */
235      UINT16 max_visible_x = mc6845->horiz_disp * mc6845->intf->hpixels_per_column - 1;
236      UINT16 max_visible_x = mc6845->horiz_disp * mc6845->hpixels_per_column - 1;
236237      UINT16 max_visible_y = mc6845->vert_disp * (mc6845->max_ras_addr + 1) - 1;
237238
238239      /* determine the syncing positions */
r2077r2078
245246      if (vert_sync_pix_width == 0)
246247         vert_sync_pix_width = 0x10;
247248
248      hsync_on_pos = mc6845->horiz_sync_pos * mc6845->intf->hpixels_per_column;
249      hsync_off_pos = hsync_on_pos + (horiz_sync_char_width * mc6845->intf->hpixels_per_column);
249      hsync_on_pos = mc6845->horiz_sync_pos * mc6845->hpixels_per_column;
250      hsync_off_pos = hsync_on_pos + (horiz_sync_char_width * mc6845->hpixels_per_column);
250251      vsync_on_pos = mc6845->vert_sync_pos * (mc6845->max_ras_addr + 1);
251252      vsync_off_pos = vsync_on_pos + vert_sync_pix_width;
252253
r2077r2078
475476
476477      ret = (mc6845->disp_start_addr +
477478           (y / (mc6845->max_ras_addr + 1)) * mc6845->horiz_disp +
478           (x / mc6845->intf->hpixels_per_column)) & 0x3fff;
479           (x / mc6845->hpixels_per_column)) & 0x3fff;
479480   }
480481   else
481482      ret = 0;
r2077r2078
530531      x = video_screen_get_hpos(mc6845->screen);
531532
532533      /* compute the pixel coordinate of the NEXT character -- this is when the light pen latches */
533      char_x = x / mc6845->intf->hpixels_per_column;
534      x = (char_x + 1) * mc6845->intf->hpixels_per_column;
534      char_x = x / mc6845->hpixels_per_column;
535      x = (char_x + 1) * mc6845->hpixels_per_column;
535536
536537      /* adjust if we are passed the boundaries of the screen */
537538      if (x == mc6845->horiz_pix_total)
r2077r2078
564565}
565566
566567
568void mc6845_set_hpixels_per_column(const device_config *device, int hpixels_per_column)
569{
570   mc6845_t *mc6845 = get_safe_token(device);
571
572   /* validate arguments */
573   assert(hpixels_per_column > 0);
574
575   if (hpixels_per_column != mc6845->hpixels_per_column)
576   {
577      mc6845->hpixels_per_column = hpixels_per_column;
578      recompute_parameters(mc6845, FALSE);
579   }
580}
581
582
567583static void update_cursor_state(mc6845_t *mc6845)
568584{
569585   /* save and increment cursor counter */
r2077r2078
677693      assert(mc6845->intf->clock > 0);
678694      assert(mc6845->intf->hpixels_per_column > 0);
679695
680      /* copy the initial clock */
696      /* copy the initial parameters */
681697      mc6845->clock = mc6845->intf->clock;
698      mc6845->hpixels_per_column = mc6845->intf->hpixels_per_column;
682699
683700      /* get the screen device */
684701      mc6845->screen = device_list_find_by_tag(device->machine->config->devicelist, VIDEO_SCREEN, mc6845->intf->screen_tag);
r2077r2078
709726   state_save_register_func_postload_ptr(mc6845_state_save_postload, mc6845);
710727
711728   state_save_register_item(unique_tag, 0, mc6845->clock);
729   state_save_register_item(unique_tag, 0, mc6845->hpixels_per_column);
712730   state_save_register_item(unique_tag, 0, mc6845->register_address_latch);
713731   state_save_register_item(unique_tag, 0, mc6845->horiz_char_total);
714732   state_save_register_item(unique_tag, 0, mc6845->horiz_disp);
src/emu/video/mc6845.h
r2077r2078
110110/* set the clock (pin 21) of the chip */
111111void mc6845_set_clock(const device_config *device, int clock);
112112
113/* set number of pixels per video memory address */
114void mc6845_set_hpixels_per_column(const device_config *device, int hpixels_per_column);
115
113116/* updates the screen -- this will call begin_update(),
114117   followed by update_row() reapeatedly and after all row
115118   updating is complete, end_update() */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team