src/mess/video/crtc_ega.c
| r3849 | r3850 | |
| 81 | 81 | emu_timer *hsync_off_timer; |
| 82 | 82 | emu_timer *vsync_on_timer; |
| 83 | 83 | emu_timer *vsync_off_timer; |
| 84 | emu_timer *vblank_on_timer; |
| 85 | emu_timer *vblank_off_timer; |
| 84 | 86 | emu_timer *light_pen_latch_timer; |
| 85 | 87 | |
| 86 | 88 | /* computed values - do NOT state save these! */ |
| r3849 | r3850 | |
| 104 | 106 | static void update_de_changed_timer(crtc_ega_t *crtc_ega); |
| 105 | 107 | static void update_hsync_changed_timers(crtc_ega_t *crtc_ega); |
| 106 | 108 | static void update_vsync_changed_timers(crtc_ega_t *crtc_ega); |
| 109 | static void update_vblank_changed_timers(crtc_ega_t *crtc_ega); |
| 107 | 110 | |
| 108 | 111 | |
| 109 | 112 | /* makes sure that the passed in device is the right type */ |
| r3849 | r3850 | |
| 306 | 309 | update_de_changed_timer(crtc_ega); |
| 307 | 310 | update_hsync_changed_timers(crtc_ega); |
| 308 | 311 | update_vsync_changed_timers(crtc_ega); |
| 312 | update_vblank_changed_timers(crtc_ega); |
| 309 | 313 | } |
| 310 | 314 | } |
| 311 | 315 | } |
| r3849 | r3850 | |
| 401 | 405 | } |
| 402 | 406 | |
| 403 | 407 | |
| 408 | static void update_vblank_changed_timers(crtc_ega_t *crtc_ega) |
| 409 | { |
| 410 | if (crtc_ega->has_valid_parameters && (crtc_ega->vblank_on_timer != NULL)) |
| 411 | { |
| 412 | timer_adjust_oneshot(crtc_ega->vblank_on_timer, video_screen_get_time_until_pos(crtc_ega->screen, crtc_ega->vert_disp_end, crtc_ega->hsync_on_pos), 0); |
| 413 | timer_adjust_oneshot(crtc_ega->vblank_off_timer, video_screen_get_time_until_pos(crtc_ega->screen, 0, crtc_ega->hsync_off_pos), 0); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | |
| 404 | 418 | static TIMER_CALLBACK( de_changed_timer_cb ) |
| 405 | 419 | { |
| 406 | 420 | const device_config *device = ptr; |
| r3849 | r3850 | |
| 457 | 471 | } |
| 458 | 472 | |
| 459 | 473 | |
| 474 | static TIMER_CALLBACK( vblank_on_timer_cb ) |
| 475 | { |
| 476 | const device_config *device = ptr; |
| 477 | crtc_ega_t *crtc_ega = get_safe_token(device); |
| 460 | 478 | |
| 479 | /* call the callback function -- we know it exists */ |
| 480 | crtc_ega->intf->on_vblank_changed(device, TRUE); |
| 481 | |
| 482 | update_vblank_changed_timers(crtc_ega); |
| 483 | } |
| 484 | |
| 485 | |
| 486 | static TIMER_CALLBACK( vblank_off_timer_cb ) |
| 487 | { |
| 488 | const device_config *device = ptr; |
| 489 | crtc_ega_t *crtc_ega = get_safe_token(device); |
| 490 | |
| 491 | /* call the callback function -- we know it exists */ |
| 492 | crtc_ega->intf->on_vblank_changed(device, FALSE); |
| 493 | |
| 494 | update_vblank_changed_timers(crtc_ega); |
| 495 | } |
| 496 | |
| 497 | |
| 498 | |
| 461 | 499 | UINT16 crtc_ega_get_ma(const device_config *device) |
| 462 | 500 | { |
| 463 | 501 | UINT16 ret; |
| r3849 | r3850 | |
| 718 | 756 | crtc_ega->vsync_on_timer = timer_alloc(device->machine, vsync_on_timer_cb, (void *)device); |
| 719 | 757 | crtc_ega->vsync_off_timer = timer_alloc(device->machine, vsync_off_timer_cb, (void *)device); |
| 720 | 758 | } |
| 759 | |
| 760 | if (crtc_ega->intf->on_vblank_changed != NULL) |
| 761 | { |
| 762 | crtc_ega->vblank_on_timer = timer_alloc(device->machine, vblank_on_timer_cb, (void *)device); |
| 763 | crtc_ega->vblank_off_timer = timer_alloc(device->machine, vblank_off_timer_cb, (void *)device); |
| 764 | } |
| 721 | 765 | } |
| 722 | 766 | |
| 723 | 767 | crtc_ega->light_pen_latch_timer = timer_alloc(device->machine, light_pen_latch_timer_cb, (void *)device); |
src/mess/video/crtc_ega.h
| r3849 | r3850 | |
| 34 | 34 | typedef void (*crtc_ega_on_vsync_changed_func)(const device_config *device, int vsync); |
| 35 | 35 | #define CRTC_EGA_ON_VSYNC_CHANGED(name) void name(const device_config *device, int vsync) |
| 36 | 36 | |
| 37 | typedef void (*crtc_ega_on_vblank_changed_func)(const device_config *device, int vblank); |
| 38 | #define CRTC_EGA_ON_VBLANK_CHANGED(name) void name(const device_config *device, int vblank) |
| 37 | 39 | |
| 40 | |
| 38 | 41 | /* interface */ |
| 39 | 42 | typedef struct _crtc_ega_interface crtc_ega_interface; |
| 40 | 43 | struct _crtc_ega_interface |
| 41 | 44 | { |
| 42 | 45 | const char *screen_tag; /* screen we are acting on */ |
| 43 | | int clock; /* the clock (pin 21) of the chip */ |
| 46 | int clock; /* the clock of the chip */ |
| 44 | 47 | int hpixels_per_column; /* number of pixels per video memory address */ |
| 45 | 48 | |
| 46 | 49 | /* if specified, this gets called before any pixel update, |
| r3849 | r3850 | |
| 57 | 60 | /* if specified, this gets called after all row updating is complete */ |
| 58 | 61 | crtc_ega_end_update_func end_update; |
| 59 | 62 | |
| 60 | | /* if specified, this gets called for every change of the disply enable pin (pin 18) */ |
| 63 | /* if specified, this gets called for every change of the disply enable signal */ |
| 61 | 64 | crtc_ega_on_de_changed_func on_de_changed; |
| 62 | 65 | |
| 63 | | /* if specified, this gets called for every change of the HSYNC pin (pin 39) */ |
| 66 | /* if specified, this gets called for every change of the HSYNC signal */ |
| 64 | 67 | crtc_ega_on_hsync_changed_func on_hsync_changed; |
| 65 | 68 | |
| 66 | | /* if specified, this gets called for every change of the VSYNC pin (pin 40) */ |
| 69 | /* if specified, this gets called for every change of the VSYNC signal */ |
| 67 | 70 | crtc_ega_on_vsync_changed_func on_vsync_changed; |
| 71 | |
| 72 | /* if specificed, this gets called for every change of the VBLANK signal */ |
| 73 | crtc_ega_on_vblank_changed_func on_vblank_changed; |
| 68 | 74 | }; |
| 69 | 75 | |
| 70 | 76 | |
src/mess/video/pc_ega.c
| r3849 | r3850 | |
| 55 | 55 | 1 = video is being displayed |
| 56 | 56 | |
| 57 | 57 | |
| 58 | Configuration switches |
| 59 | SW1 SW2 SW3 SW4 |
| 60 | OFF OFF OFF ON - EGA, Color 80x25 (5153) |
| 61 | - EGA (primary) + MDA, Color 80x25 + Monochrome |
| 62 | OFF OFF ON OFF - EGA, Monochrome (5151) |
| 63 | - EGA (primary) + CGA, Monochrome + Color 80x25 |
| 64 | OFF OFF ON ON - EGA + MDA (primary), 5154 + Enhanced Monochrome |
| 65 | OFF ON OFF ON - EGA + CGA (primary), Monochrome + Color 80x25 |
| 66 | OFF ON ON OFF - EGA, Enhanced Color - Enhanced Mode (5154) |
| 67 | - EGA (primary) + MDA, 5154 monitor + Enhanced Monochrome |
| 68 | OFF ON ON ON - EGA + MDA (primary), Color 80x25 + Monochrome |
| 69 | ON OFF OFF ON - EGA, Color 40x25 (5153) |
| 70 | - EGA (primary) + MDA, Color 40x25 + Monochrome |
| 71 | ON OFF ON OFF - EGA (primary) + CGA, Monochrome + Color 40x25 |
| 72 | ON OFF ON ON - EGA + MDA (primary), 5154 + Normal Monochrome |
| 73 | ON ON OFF ON - EGA + CGA (primary), Monochrome + Color 40x25 |
| 74 | ON ON ON OFF - EGA, Enhanced Color - Enhanced Mode (5154) |
| 75 | - EGA (primary) + MDA, 5154 monitor + Normal Monochrome |
| 76 | ON ON ON ON - EGA + MDA (primary), Color 40x25 + Monochrome |
| 77 | |
| 78 | |
| 58 | 79 | 3XA - 7 6 5 4 3 2 1 0 - Feature Control Register - Write Only |
| 59 | 80 | | | | | | | | | |
| 60 | 81 | | | | | | | | +-- output to FEAT0 of the feature connector |
| r3849 | r3850 | |
| 77 | 98 | | | | | | +------ light pen switch |
| 78 | 99 | | | | | | 0 = switch is closed |
| 79 | 100 | | | | | | 1 = switch is open |
| 80 | | | | | | +-------- vertical retrace |
| 101 | | | | | +-------- vertical blank |
| 81 | 102 | | | | | 0 = video information is being displayed |
| 82 | | | | | | 1 = CRT is in vertical retrace |
| 103 | | | | | 1 = CRT is in vertical blank |
| 83 | 104 | | | | +---------- diagnostic usage |
| 84 | 105 | | | +------------ diagnostic usage |
| 85 | 106 | | +-------------- reserved/unused |
| 86 | 107 | +---------------- reserved/unused |
| 87 | 108 | |
| 109 | We think bits 4 and 5 of the status register contain some information about the |
| 110 | current pixel that is being drawn. Those bits do not seem to be documented. |
| 88 | 111 | |
| 112 | |
| 89 | 113 | The EGA graphics card introduces a lot of new indexed registers to handle the |
| 90 | 114 | enhanced graphics. These new indexed registers can be divided into three |
| 91 | 115 | groups: |
| r3849 | r3850 | |
| 461 | 485 | |
| 462 | 486 | UINT8 frame_cnt; |
| 463 | 487 | UINT8 vsync; |
| 488 | UINT8 vblank; |
| 464 | 489 | UINT8 display_enable; |
| 465 | 490 | } ega; |
| 466 | 491 | |
| r3849 | r3850 | |
| 474 | 499 | static CRTC_EGA_UPDATE_ROW( ega_update_row ); |
| 475 | 500 | static CRTC_EGA_ON_DE_CHANGED( ega_de_changed ); |
| 476 | 501 | static CRTC_EGA_ON_VSYNC_CHANGED( ega_vsync_changed ); |
| 502 | static CRTC_EGA_ON_VBLANK_CHANGED( ega_vblank_changed ); |
| 477 | 503 | static READ8_HANDLER( pc_ega8_3b0_r ); |
| 478 | 504 | static WRITE8_HANDLER( pc_ega8_3b0_w ); |
| 479 | 505 | static READ16_HANDLER( pc_ega16le_3b0_r ); |
| r3849 | r3850 | |
| 507 | 533 | NULL, /* end_update */ |
| 508 | 534 | ega_de_changed, /* on_de_chaged */ |
| 509 | 535 | NULL, /* on_hsync_changed */ |
| 510 | | ega_vsync_changed /* on_vsync_changed */ |
| 536 | ega_vsync_changed, /* on_vsync_changed */ |
| 537 | ega_vblank_changed /* on_vblank_changed */ |
| 511 | 538 | }; |
| 512 | 539 | |
| 513 | 540 | |
| r3849 | r3850 | |
| 694 | 721 | } |
| 695 | 722 | |
| 696 | 723 | |
| 724 | static CRTC_EGA_ON_VBLANK_CHANGED( ega_vblank_changed ) |
| 725 | { |
| 726 | ega.vblank = vblank ? 8 : 0; |
| 727 | } |
| 728 | |
| 729 | |
| 697 | 730 | static CRTC_EGA_UPDATE_ROW( pc_ega_graphics ) |
| 698 | 731 | { |
| 699 | 732 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 700 | 733 | int i; |
| 701 | 734 | |
| 735 | // logerror( "pc_ega_graphics: y = %d, x_count = %d, ma = %d, ra = %d\n", y, x_count, ma, ra ); |
| 736 | |
| 702 | 737 | for ( i = 0; i < x_count; i++ ) |
| 703 | 738 | { |
| 704 | 739 | *p = 0; |
| r3849 | r3850 | |
| 788 | 823 | } |
| 789 | 824 | crtc_ega_set_clock( device, clock / pixels ); |
| 790 | 825 | crtc_ega_set_hpixels_per_column( device, pixels ); |
| 826 | |
| 827 | if ( ! ega.update_row ) |
| 828 | logerror("unknown video mode\n"); |
| 791 | 829 | } |
| 792 | 830 | |
| 793 | 831 | |
| r3849 | r3850 | |
| 814 | 852 | |
| 815 | 853 | /* Input Status Register 1 */ |
| 816 | 854 | case 10: |
| 817 | | data = ega.vsync | ega.display_enable; |
| 855 | data = ega.vblank | ega.display_enable; |
| 818 | 856 | |
| 857 | if ( ega.display_enable ) |
| 858 | { |
| 859 | /* For the moment i'm putting in some bogus data */ |
| 860 | static int pixel_data; |
| 861 | |
| 862 | pixel_data = ( pixel_data + 1 ) & 0x03; |
| 863 | data |= ( pixel_data << 4 ); |
| 864 | } |
| 865 | |
| 819 | 866 | /* Reset the attirubte writing flip flop to let the next write go to the index reigster */ |
| 820 | 867 | ega.attribute.index_write = 1; |
| 821 | 868 | break; |
| r3849 | r3850 | |
| 892 | 939 | |
| 893 | 940 | static READ8_HANDLER( pc_ega8_3c0_r ) |
| 894 | 941 | { |
| 942 | UINT8 dips = 0x08; /* 0x01 - EGA only, 80x25 color(?) */ |
| 943 | /* |
| 944 | 0000 - 40x25 |
| 945 | 0001 - no display (text at a0000) and writes to 0c00xx (?), seems to be a graphics mode |
| 946 | 0010 - 40x25 |
| 947 | 0011 - no display |
| 948 | 0100 - 40x25 |
| 949 | 0101 - no display |
| 950 | 0110 - 40x25 |
| 951 | 0111 - no display |
| 952 | 1000 - 40x25 |
| 953 | 1001 - no diplsay (text at a0000) |
| 954 | 1010 - 40x25 |
| 955 | 1100 - 40x25 |
| 956 | 1110 - 40x25 |
| 957 | */ |
| 895 | 958 | int data = 0xff; |
| 896 | 959 | |
| 897 | 960 | if ( VERBOSE_EGA ) |
| r3849 | r3850 | |
| 907 | 970 | |
| 908 | 971 | /* Feature Read */ |
| 909 | 972 | case 2: |
| 910 | | data = ( data & 0x0F ); |
| 973 | data = ( data & 0x0f ); |
| 911 | 974 | data |= ( ( ega.feature_control & 0x03 ) << 5 ); |
| 912 | 975 | data |= ( ega.vsync ? 0x00 : 0x80 ); |
| 976 | data |= ( ( ( dips >> ( ( ( ega.misc_output & 0xc0 ) >> 6 ) ) ) & 0x01 ) << 4 ); |
| 913 | 977 | break; |
| 914 | 978 | |
| 915 | 979 | /* Sequencer */ |