src/emu/video/mc6845.c
| r3476 | r3477 | |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | |
| 47 | /* mode control bits */ |
| 48 | |
| 49 | #define MODE_INTERLACED 0x01 /* not supported */ |
| 50 | #define MODE_VIDEO 0x02 /* not supported */ |
| 51 | #define MODE_ROW_COLUMN_ADDRESSING 0x04 /* not supported */ |
| 52 | #define MODE_TRANSPARENT_ADDRESSING 0x08 /* not supported */ |
| 53 | #define MODE_DISPLAY_ENABLE_SKEW 0x10 |
| 54 | #define MODE_CURSOR_SKEW 0x20 |
| 55 | #define MODE_RA4_IS_UPDATE_STROBE 0x40 /* not supported */ |
| 56 | #define MODE_INTERLEAVED_UPDATES 0x80 /* not supported */ |
| 57 | |
| 58 | |
| 47 | 59 | /* tags for state saving */ |
| 48 | 60 | static const char * const device_tags[NUM_TYPES] = { "mc6845", "mc6845-1", "c6545-1", "r6545-1", "h46505", "hd6845", "sy6545-1" }; |
| 49 | 61 | |
| r3476 | r3477 | |
| 52 | 64 | static const int supports_vert_sync_width[NUM_TYPES] = { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE }; |
| 53 | 65 | static const int supports_status_reg_d5[NUM_TYPES] = { FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE }; |
| 54 | 66 | static const int supports_status_reg_d6[NUM_TYPES] = { FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE }; |
| 67 | static const int supports_status_reg_d7[NUM_TYPES] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE }; |
| 55 | 68 | |
| 56 | 69 | |
| 57 | 70 | typedef struct _mc6845_t mc6845_t; |
| r3476 | r3477 | |
| 77 | 90 | UINT16 disp_start_addr; /* 0x0c/0x0d */ |
| 78 | 91 | UINT16 cursor_addr; /* 0x0e/0x0f */ |
| 79 | 92 | UINT16 light_pen_addr; /* 0x10/0x11 */ |
| 93 | UINT16 update_addr; /* 0x12/0x13 */ |
| 80 | 94 | |
| 81 | 95 | /* other internal state */ |
| 82 | 96 | UINT64 clock; |
| r3476 | r3477 | |
| 104 | 118 | UINT16 vsync_off_pos; |
| 105 | 119 | UINT16 current_disp_addr; /* the display address currently drawn */ |
| 106 | 120 | UINT8 light_pen_latched; |
| 121 | int update_ready; |
| 107 | 122 | int has_valid_parameters; |
| 108 | 123 | }; |
| 109 | 124 | |
| r3476 | r3477 | |
| 159 | 174 | if (supports_status_reg_d6[mc6845->device_type] && mc6845->light_pen_latched) |
| 160 | 175 | ret = ret | 0x40; |
| 161 | 176 | |
| 177 | /* update ready */ |
| 178 | if (supports_status_reg_d7[mc6845->device_type] && mc6845->update_ready) |
| 179 | ret = ret | 0x80; |
| 180 | |
| 162 | 181 | return ret; |
| 163 | 182 | } |
| 164 | 183 | |
| r3476 | r3477 | |
| 176 | 195 | case 0x0f: ret = (mc6845->cursor_addr >> 0) & 0xff; break; |
| 177 | 196 | case 0x10: ret = (mc6845->light_pen_addr >> 8) & 0xff; mc6845->light_pen_latched = FALSE; break; |
| 178 | 197 | case 0x11: ret = (mc6845->light_pen_addr >> 0) & 0xff; mc6845->light_pen_latched = FALSE; break; |
| 198 | case 0x1f: mc6845->update_ready = 0; mc6845->update_addr = (mc6845->update_addr + 1) & 0x3fff; break; |
| 179 | 199 | |
| 180 | 200 | /* all other registers are write only and return 0 */ |
| 181 | 201 | default: break; |
| r3476 | r3477 | |
| 211 | 231 | case 0x0f: mc6845->cursor_addr = ((data & 0xff) << 0) | (mc6845->cursor_addr & 0xff00); break; |
| 212 | 232 | case 0x10: /* read-only */ break; |
| 213 | 233 | case 0x11: /* read-only */ break; |
| 234 | case 0x12: mc6845->update_addr = ((data & 0x3f) << 8) | (mc6845->update_addr & 0x00ff); break; |
| 235 | case 0x13: mc6845->update_addr = ((data & 0xff) << 0) | (mc6845->update_addr & 0xff00); break; |
| 236 | case 0x1f: mc6845->update_ready = 0; mc6845->update_addr = (mc6845->update_addr + 1) & 0x3fff; break; |
| 214 | 237 | default: break; |
| 215 | 238 | } |
| 216 | 239 | |
| 217 | | /* display message if the Mode Control register is not zero */ |
| 218 | | if ((mc6845->register_address_latch == 0x08) && (mc6845->mode_control != 0)) |
| 240 | /* display message if the Mode Control register has unsupported bits active */ |
| 241 | if ((mc6845->register_address_latch == 0x08) && (mc6845->mode_control & ~(MODE_DISPLAY_ENABLE_SKEW | MODE_CURSOR_SKEW))) |
| 219 | 242 | popmessage("Mode Control %02X is not supported!!!", mc6845->mode_control); |
| 220 | 243 | |
| 221 | 244 | recompute_parameters(mc6845, FALSE); |
| r3476 | r3477 | |
| 354 | 377 | next_y = 0; |
| 355 | 378 | } |
| 356 | 379 | |
| 380 | /* delay display enable for 1 character time if skew is enabled */ |
| 381 | if (mc6845->mode_control & MODE_DISPLAY_ENABLE_SKEW) |
| 382 | next_x++; |
| 383 | |
| 357 | 384 | if (next_y != -1) |
| 358 | 385 | duration = video_screen_get_time_until_pos(mc6845->screen, next_y, next_x); |
| 359 | 386 | else |
| r3476 | r3477 | |
| 378 | 405 | else |
| 379 | 406 | next_y = (video_screen_get_vpos(mc6845->screen) + 1) % mc6845->vert_pix_total; |
| 380 | 407 | |
| 381 | | /* if the next line is not in the visible region, go to the beginning of the screen */ |
| 382 | | if (next_y > mc6845->max_visible_y) |
| 383 | | next_y = 0; |
| 384 | | |
| 385 | 408 | timer_adjust_oneshot(mc6845->hsync_on_timer, video_screen_get_time_until_pos(mc6845->screen, next_y, mc6845->hsync_on_pos) , 0); |
| 386 | 409 | timer_adjust_oneshot(mc6845->hsync_off_timer, video_screen_get_time_until_pos(mc6845->screen, next_y, mc6845->hsync_off_pos), 0); |
| 387 | 410 | } |
| r3476 | r3477 | |
| 655 | 678 | /* compute the cursor X position, or -1 if not visible */ |
| 656 | 679 | INT8 cursor_x = cursor_visible ? (mc6845->cursor_addr - mc6845->current_disp_addr) : -1; |
| 657 | 680 | |
| 681 | /* delay cursor for 1 character time if skew is enabled */ |
| 682 | if (mc6845->mode_control & MODE_CURSOR_SKEW) |
| 683 | cursor_x++; |
| 684 | |
| 658 | 685 | /* call the external system to draw it */ |
| 659 | 686 | mc6845->intf->update_row(device, bitmap, cliprect, mc6845->current_disp_addr, ra, y, mc6845->horiz_disp, cursor_x, param); |
| 660 | 687 | |
| r3476 | r3477 | |
| 746 | 773 | state_save_register_item(unique_tag, 0, mc6845->light_pen_latched); |
| 747 | 774 | state_save_register_item(unique_tag, 0, mc6845->cursor_state); |
| 748 | 775 | state_save_register_item(unique_tag, 0, mc6845->cursor_blink_count); |
| 776 | state_save_register_item(unique_tag, 0, mc6845->update_addr); |
| 777 | state_save_register_item(unique_tag, 0, mc6845->update_ready); |
| 749 | 778 | |
| 750 | 779 | return DEVICE_START_OK; |
| 751 | 780 | } |