src/emu/video/mc6845.c
| r3518 | r3519 | |
| 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 | | |
| 59 | 47 | /* tags for state saving */ |
| 60 | 48 | static const char * const device_tags[NUM_TYPES] = { "mc6845", "mc6845-1", "c6545-1", "r6545-1", "h46505", "hd6845", "sy6545-1" }; |
| 61 | 49 | |
| r3518 | r3519 | |
| 64 | 52 | static const int supports_vert_sync_width[NUM_TYPES] = { FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE }; |
| 65 | 53 | static const int supports_status_reg_d5[NUM_TYPES] = { FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE }; |
| 66 | 54 | 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 }; |
| 68 | 55 | |
| 69 | 56 | |
| 70 | 57 | typedef struct _mc6845_t mc6845_t; |
| r3518 | r3519 | |
| 90 | 77 | UINT16 disp_start_addr; /* 0x0c/0x0d */ |
| 91 | 78 | UINT16 cursor_addr; /* 0x0e/0x0f */ |
| 92 | 79 | UINT16 light_pen_addr; /* 0x10/0x11 */ |
| 93 | | UINT16 update_addr; /* 0x12/0x13 */ |
| 94 | 80 | |
| 95 | 81 | /* other internal state */ |
| 96 | 82 | UINT64 clock; |
| r3518 | r3519 | |
| 118 | 104 | UINT16 vsync_off_pos; |
| 119 | 105 | UINT16 current_disp_addr; /* the display address currently drawn */ |
| 120 | 106 | UINT8 light_pen_latched; |
| 121 | | int update_ready; |
| 122 | 107 | int has_valid_parameters; |
| 123 | 108 | }; |
| 124 | 109 | |
| r3518 | r3519 | |
| 174 | 159 | if (supports_status_reg_d6[mc6845->device_type] && mc6845->light_pen_latched) |
| 175 | 160 | ret = ret | 0x40; |
| 176 | 161 | |
| 177 | | /* update ready */ |
| 178 | | if (supports_status_reg_d7[mc6845->device_type] && mc6845->update_ready) |
| 179 | | ret = ret | 0x80; |
| 180 | | |
| 181 | 162 | return ret; |
| 182 | 163 | } |
| 183 | 164 | |
| r3518 | r3519 | |
| 195 | 176 | case 0x0f: ret = (mc6845->cursor_addr >> 0) & 0xff; break; |
| 196 | 177 | case 0x10: ret = (mc6845->light_pen_addr >> 8) & 0xff; mc6845->light_pen_latched = FALSE; break; |
| 197 | 178 | 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; |
| 199 | 179 | |
| 200 | 180 | /* all other registers are write only and return 0 */ |
| 201 | 181 | default: break; |
| r3518 | r3519 | |
| 231 | 211 | case 0x0f: mc6845->cursor_addr = ((data & 0xff) << 0) | (mc6845->cursor_addr & 0xff00); break; |
| 232 | 212 | case 0x10: /* read-only */ break; |
| 233 | 213 | 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; |
| 237 | 214 | default: break; |
| 238 | 215 | } |
| 239 | 216 | |
| 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))) |
| 217 | /* display message if the Mode Control register is not zero */ |
| 218 | if ((mc6845->register_address_latch == 0x08) && (mc6845->mode_control != 0)) |
| 242 | 219 | popmessage("Mode Control %02X is not supported!!!", mc6845->mode_control); |
| 243 | 220 | |
| 244 | 221 | recompute_parameters(mc6845, FALSE); |
| r3518 | r3519 | |
| 301 | 278 | |
| 302 | 279 | visarea.min_x = 0; |
| 303 | 280 | visarea.min_y = 0; |
| 304 | | visarea.max_x = hsync_on_pos - 1; |
| 305 | | visarea.max_y = vsync_on_pos - 1; |
| 281 | visarea.max_x = max_visible_x; |
| 282 | visarea.max_y = max_visible_y; |
| 306 | 283 | |
| 307 | 284 | 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", |
| 308 | 285 | 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)); |
| r3518 | r3519 | |
| 333 | 310 | |
| 334 | 311 | INLINE int is_display_enabled(mc6845_t *mc6845) |
| 335 | 312 | { |
| 336 | | int x = video_screen_get_hpos(mc6845->screen); |
| 337 | | int x0 = 0; |
| 338 | | int x1 = mc6845->max_visible_x; |
| 339 | | int y = video_screen_get_vpos(mc6845->screen); |
| 340 | | |
| 341 | | if (mc6845->mode_control & MODE_DISPLAY_ENABLE_SKEW) |
| 342 | | { |
| 343 | | x0 += mc6845->hpixels_per_column; |
| 344 | | x1 += mc6845->hpixels_per_column; |
| 345 | | } |
| 346 | | |
| 347 | | return (x >= x0) && (x <= x1) && (y <= mc6845->max_visible_y); |
| 313 | return !video_screen_get_vblank(mc6845->screen) && !video_screen_get_hblank(mc6845->screen); |
| 348 | 314 | } |
| 349 | 315 | |
| 350 | 316 | |
| r3518 | r3519 | |
| 388 | 354 | next_y = 0; |
| 389 | 355 | } |
| 390 | 356 | |
| 391 | | /* delay display enable for 1 character time if skew is enabled */ |
| 392 | | if (mc6845->mode_control & MODE_DISPLAY_ENABLE_SKEW) |
| 393 | | next_x += mc6845->hpixels_per_column; |
| 394 | | |
| 395 | 357 | if (next_y != -1) |
| 396 | 358 | duration = video_screen_get_time_until_pos(mc6845->screen, next_y, next_x); |
| 397 | 359 | else |
| r3518 | r3519 | |
| 674 | 636 | } |
| 675 | 637 | |
| 676 | 638 | /* for each row in the visible region */ |
| 677 | | for (y = cliprect->min_y; y <= MIN(cliprect->max_y, mc6845->max_visible_y); y++) |
| 639 | for (y = cliprect->min_y; y <= cliprect->max_y; y++) |
| 678 | 640 | { |
| 679 | 641 | /* compute the current raster line */ |
| 680 | 642 | UINT8 ra = y % (mc6845->max_ras_addr + 1); |
| r3518 | r3519 | |
| 689 | 651 | /* compute the cursor X position, or -1 if not visible */ |
| 690 | 652 | INT8 cursor_x = cursor_visible ? (mc6845->cursor_addr - mc6845->current_disp_addr) : -1; |
| 691 | 653 | |
| 692 | | /* delay cursor for 1 character time if skew is enabled */ |
| 693 | | if (mc6845->mode_control & MODE_CURSOR_SKEW) |
| 694 | | cursor_x += mc6845->hpixels_per_column; |
| 695 | | |
| 696 | 654 | /* call the external system to draw it */ |
| 697 | 655 | mc6845->intf->update_row(device, bitmap, cliprect, mc6845->current_disp_addr, ra, y, mc6845->horiz_disp, cursor_x, param); |
| 698 | 656 | |
| r3518 | r3519 | |
| 784 | 742 | state_save_register_item(unique_tag, 0, mc6845->light_pen_latched); |
| 785 | 743 | state_save_register_item(unique_tag, 0, mc6845->cursor_state); |
| 786 | 744 | state_save_register_item(unique_tag, 0, mc6845->cursor_blink_count); |
| 787 | | state_save_register_item(unique_tag, 0, mc6845->update_addr); |
| 788 | | state_save_register_item(unique_tag, 0, mc6845->update_ready); |
| 789 | 745 | |
| 790 | 746 | return DEVICE_START_OK; |
| 791 | 747 | } |
src/mess/video/abc802.c
| r3518 | r3519 | |
| 80 | 80 | |
| 81 | 81 | int column;
|
| 82 | 82 | int rf = 0, rc = 0, rg = 0;
|
| 83 |
|
| 84 | /* prevent wraparound */
|
| 85 | if (y >= 240) return;
|
| 86 |
|
| 87 | y += 29;
|
| 83 | 88 | |
| 84 | 89 | for (column = 0; column < x_count; column++)
|
| 85 | 90 | {
|
| r3518 | r3519 | |
| 144 | 149 | {
|
| 145 | 150 | for (bit = 0; bit < ABC800_CHAR_WIDTH; bit++)
|
| 146 | 151 | {
|
| 147 | | int x = ((column + 3) * ABC800_CHAR_WIDTH) + bit; // DEN+3
|
| 152 | int x = 121 + ((column + 3) * ABC800_CHAR_WIDTH) + bit;
|
| 148 | 153 | int color = BIT(data, 7) ^ ri;
|
| 149 | 154 | |
| 150 | 155 | *BITMAP_ADDR16(bitmap, y, x) = color;
|
| r3518 | r3519 | |
| 156 | 161 | {
|
| 157 | 162 | for (bit = 0; bit < ABC800_CHAR_WIDTH; bit++)
|
| 158 | 163 | {
|
| 159 | | int x = ((column + 3) * ABC800_CHAR_WIDTH) + (bit << 1); // DEN+3
|
| 164 | int x = 121 + ((column + 3) * ABC800_CHAR_WIDTH) + (bit << 1);
|
| 160 | 165 | int color = BIT(data, 7) ^ ri;
|
| 161 | 166 | |
| 162 | 167 | *BITMAP_ADDR16(bitmap, y, x) = color;
|
| r3518 | r3519 | |
| 240 | 245 | {
|
| 241 | 246 | abc802_state *state = screen->machine->driver_data;
|
| 242 | 247 |
|
| 248 | /* expand visible area to workaround MC6845 */
|
| 249 | video_screen_set_visarea(screen, 0, 767, 0, 311);
|
| 250 | |
| 251 | /* draw text */
|
| 243 | 252 | mc6845_update(state->mc6845, bitmap, cliprect);
|
| 244 | 253 |
|
| 245 | 254 | return 0;
|
src/mess/video/abc806.c
| r3518 | r3519 | |
| 221 | 221 | int e6 = state->_40; |
| 222 | 222 | int th = 0; |
| 223 | 223 | |
| 224 | | y += state->sync; |
| 224 | /* prevent wraparound */ |
| 225 | if (y >= 240) return; |
| 225 | 226 | |
| 227 | y += state->sync + 27; |
| 228 | |
| 226 | 229 | for (column = 0; column < x_count; column++) |
| 227 | 230 | { |
| 228 | 231 | UINT8 data = state->charram[(ma + column) & 0x7ff]; |
| r3518 | r3519 | |
| 294 | 297 | |
| 295 | 298 | chargen_addr = (th << 12) | (data << 4) | rad_data; |
| 296 | 299 | chargen_data = state->char_rom[chargen_addr & 0xfff] << 2; |
| 297 | | x = (column + 4) * ABC800_CHAR_WIDTH; |
| 300 | x = 109 + (column + 4) * ABC800_CHAR_WIDTH; |
| 298 | 301 | |
| 299 | 302 | for (bit = 0; bit < ABC800_CHAR_WIDTH; bit++) |
| 300 | 303 | { |
| r3518 | r3519 | |
| 394 | 397 | UINT32 addr = (state->hrs & 0x0f) << 15; |
| 395 | 398 | int sx, y, pixel; |
| 396 | 399 | |
| 397 | | for (y = state->sync; y < MIN(cliprect->max_y + 1, state->sync + 240); y++) |
| 400 | for (y = state->sync + 27; y < MIN(cliprect->max_y + 1, state->sync + 27 + 240); y++) |
| 398 | 401 | { |
| 399 | 402 | for (sx = 0; sx < 128; sx++) |
| 400 | 403 | { |
| r3518 | r3519 | |
| 403 | 406 | |
| 404 | 407 | for (pixel = 0; pixel < 4; pixel++) |
| 405 | 408 | { |
| 406 | | int x = (ABC800_CHAR_WIDTH * 4) - 16 + (sx * 4) + pixel; |
| 409 | int x = 109 + (ABC800_CHAR_WIDTH * 4) - 16 + (sx * 4) + pixel; |
| 407 | 410 | |
| 408 | 411 | if (BIT(dot, 15) || *BITMAP_ADDR16(bitmap, y, x) == 0) |
| 409 | 412 | { |
| r3518 | r3519 | |
| 477 | 480 | static VIDEO_UPDATE( abc806 ) |
| 478 | 481 | { |
| 479 | 482 | abc806_state *state = screen->machine->driver_data; |
| 480 | | |
| 483 | |
| 484 | /* expand visible area to workaround MC6845 */ |
| 485 | video_screen_set_visarea(screen, 0, 767, 0, 311); |
| 486 | |
| 481 | 487 | /* clear screen */ |
| 482 | 488 | fillbitmap(bitmap, 0, cliprect); |
| 483 | 489 | |