src/emu/video/mc6845.c
| r2077 | r2078 | |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | /* tags for state saving */ |
| 48 | | const char * const device_tags[NUM_TYPES] = { "mc6845", "mc6845-1", "c6545-1", "r6545-1", "h46505", "hd6845", "sy6545-1" }; |
| 48 | static const char * const device_tags[NUM_TYPES] = { "mc6845", "mc6845-1", "c6545-1", "r6545-1", "h46505", "hd6845", "sy6545-1" }; |
| 49 | 49 | |
| 50 | 50 | /* capabilities */ |
| 51 | 51 | static const int supports_disp_start_addr_r[NUM_TYPES] = { TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE }; |
| r2077 | r2078 | |
| 81 | 81 | /* other internal state */ |
| 82 | 82 | UINT64 clock; |
| 83 | 83 | UINT8 register_address_latch; |
| 84 | UINT8 hpixels_per_column; |
| 84 | 85 | UINT8 cursor_state; /* 0 = off, 1 = on */ |
| 85 | 86 | UINT8 cursor_blink_count; |
| 86 | 87 | |
| r2077 | r2078 | |
| 228 | 229 | UINT16 hsync_on_pos, hsync_off_pos, vsync_on_pos, vsync_off_pos; |
| 229 | 230 | |
| 230 | 231 | /* 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; |
| 232 | 233 | UINT16 vert_pix_total = (mc6845->vert_char_total + 1) * (mc6845->max_ras_addr + 1) + mc6845->vert_total_adj; |
| 233 | 234 | |
| 234 | 235 | /* 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; |
| 236 | 237 | UINT16 max_visible_y = mc6845->vert_disp * (mc6845->max_ras_addr + 1) - 1; |
| 237 | 238 | |
| 238 | 239 | /* determine the syncing positions */ |
| r2077 | r2078 | |
| 245 | 246 | if (vert_sync_pix_width == 0) |
| 246 | 247 | vert_sync_pix_width = 0x10; |
| 247 | 248 | |
| 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); |
| 250 | 251 | vsync_on_pos = mc6845->vert_sync_pos * (mc6845->max_ras_addr + 1); |
| 251 | 252 | vsync_off_pos = vsync_on_pos + vert_sync_pix_width; |
| 252 | 253 | |
| r2077 | r2078 | |
| 475 | 476 | |
| 476 | 477 | ret = (mc6845->disp_start_addr + |
| 477 | 478 | (y / (mc6845->max_ras_addr + 1)) * mc6845->horiz_disp + |
| 478 | | (x / mc6845->intf->hpixels_per_column)) & 0x3fff; |
| 479 | (x / mc6845->hpixels_per_column)) & 0x3fff; |
| 479 | 480 | } |
| 480 | 481 | else |
| 481 | 482 | ret = 0; |
| r2077 | r2078 | |
| 530 | 531 | x = video_screen_get_hpos(mc6845->screen); |
| 531 | 532 | |
| 532 | 533 | /* 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; |
| 535 | 536 | |
| 536 | 537 | /* adjust if we are passed the boundaries of the screen */ |
| 537 | 538 | if (x == mc6845->horiz_pix_total) |
| r2077 | r2078 | |
| 564 | 565 | } |
| 565 | 566 | |
| 566 | 567 | |
| 568 | void 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 | |
| 567 | 583 | static void update_cursor_state(mc6845_t *mc6845) |
| 568 | 584 | { |
| 569 | 585 | /* save and increment cursor counter */ |
| r2077 | r2078 | |
| 677 | 693 | assert(mc6845->intf->clock > 0); |
| 678 | 694 | assert(mc6845->intf->hpixels_per_column > 0); |
| 679 | 695 | |
| 680 | | /* copy the initial clock */ |
| 696 | /* copy the initial parameters */ |
| 681 | 697 | mc6845->clock = mc6845->intf->clock; |
| 698 | mc6845->hpixels_per_column = mc6845->intf->hpixels_per_column; |
| 682 | 699 | |
| 683 | 700 | /* get the screen device */ |
| 684 | 701 | mc6845->screen = device_list_find_by_tag(device->machine->config->devicelist, VIDEO_SCREEN, mc6845->intf->screen_tag); |
| r2077 | r2078 | |
| 709 | 726 | state_save_register_func_postload_ptr(mc6845_state_save_postload, mc6845); |
| 710 | 727 | |
| 711 | 728 | state_save_register_item(unique_tag, 0, mc6845->clock); |
| 729 | state_save_register_item(unique_tag, 0, mc6845->hpixels_per_column); |
| 712 | 730 | state_save_register_item(unique_tag, 0, mc6845->register_address_latch); |
| 713 | 731 | state_save_register_item(unique_tag, 0, mc6845->horiz_char_total); |
| 714 | 732 | state_save_register_item(unique_tag, 0, mc6845->horiz_disp); |