src/emu/video/pc_vga.c
| r14083 | r14084 | |
| 71 | 71 | UINT8 index; |
| 72 | 72 | UINT8 *data; |
| 73 | 73 | } sequencer; |
| 74 | |
| 75 | /* An empty comment at the start of the line indicates that register is currently unused */ |
| 74 | 76 | struct |
| 75 | 77 | { |
| 76 | 78 | UINT8 index; |
| 77 | 79 | UINT8 *data; |
| 80 | /**/ UINT16 horz_total; |
| 81 | /**/ UINT16 horz_disp_end; |
| 82 | /**/ UINT8 horz_blank_start; |
| 83 | /**/ UINT8 horz_blank_end; |
| 84 | /**/ UINT8 disp_enable_skew; |
| 85 | /**/ UINT8 evra; |
| 86 | /**/ UINT16 vert_total; |
| 87 | /**/ UINT16 vert_retrace_start; |
| 88 | /**/ UINT8 vert_retrace_end; |
| 89 | /**/ UINT16 vert_disp_end; |
| 90 | /**/ UINT16 line_compare; |
| 91 | /**/ UINT16 vert_blank_start; |
| 92 | /**/ UINT8 horz_retrace_start; |
| 93 | /**/ UINT8 horz_retrace_skew; |
| 94 | /**/ UINT8 horz_retrace_end; |
| 95 | /**/ UINT16 cursor_addr; |
| 96 | /**/ UINT8 byte_panning; |
| 97 | /**/ UINT8 preset_row_scan; |
| 98 | /**/ UINT8 scan_doubling; |
| 99 | /**/ UINT8 maximum_scan_line; |
| 100 | /**/ UINT8 cursor_enable; |
| 101 | /**/ UINT8 cursor_scan_start; |
| 102 | /**/ UINT8 cursor_skew; |
| 103 | /**/ UINT8 cursor_scan_end; |
| 104 | /**/ UINT16 start_addr; |
| 105 | /**/ UINT8 protect_enable; |
| 106 | /**/ UINT8 bandwidth; |
| 107 | /**/ UINT8 offset; |
| 108 | /**/ UINT8 word_mode; |
| 109 | /**/ UINT8 dw; |
| 110 | /**/ UINT8 div4; |
| 111 | /**/ UINT8 underline_loc; |
| 112 | /**/ UINT8 vert_blank_end; |
| 113 | UINT8 sync_en; |
| 114 | /**/ UINT8 aw; |
| 115 | /**/ UINT8 div2; |
| 116 | /**/ UINT8 sldiv; |
| 117 | /**/ UINT8 map14; |
| 118 | /**/ UINT8 map13; |
| 78 | 119 | } crtc; |
| 120 | |
| 79 | 121 | struct |
| 80 | 122 | { |
| 81 | 123 | UINT8 index; |
| r14083 | r14084 | |
| 132 | 174 | #define MAX_SCAN_LINES ((vga.crtc.data[9]&0x1f)+1) |
| 133 | 175 | #define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0) |
| 134 | 176 | |
| 135 | | #define CRTC_ON (vga.crtc.data[0x17]&0x80) |
| 136 | | |
| 137 | 177 | #define LINES_HELPER ( (vga.crtc.data[0x12] \ |
| 138 | 178 | |((vga.crtc.data[7]&2)<<7) \ |
| 139 | 179 | |((vga.crtc.data[7]&0x40)<<3))+1 ) |
| r14083 | r14084 | |
| 373 | 413 | { |
| 374 | 414 | int i; |
| 375 | 415 | |
| 376 | | if (CRTC_ON) |
| 416 | if (vga.crtc.sync_en) |
| 377 | 417 | { |
| 378 | 418 | if (vga.dac.dirty) |
| 379 | 419 | { |
| r14083 | r14084 | |
| 503 | 543 | |
| 504 | 544 | static int vga_get_crtc_columns(void) /* in clocks! */ |
| 505 | 545 | { |
| 506 | | int columns=vga.crtc.data[0]+5; |
| 546 | int columns=vga.crtc.data[0]+5; // htotal |
| 507 | 547 | |
| 508 | 548 | if (!GRAPHIC_MODE) |
| 509 | 549 | columns *= CHAR_WIDTH; |
| r14083 | r14084 | |
| 742 | 782 | } |
| 743 | 783 | } |
| 744 | 784 | |
| 785 | #if 0 |
| 786 | static UINT8 crtc_reg_read(UINT8 index) |
| 787 | { |
| 788 | UINT8 res; |
| 789 | |
| 790 | res = 0xff; |
| 791 | |
| 792 | switch(index) |
| 793 | { |
| 794 | default: |
| 795 | printf("Unhandled CRTC reg r %02x\n",index); |
| 796 | } |
| 797 | |
| 798 | return res; |
| 799 | } |
| 800 | #endif |
| 801 | |
| 802 | static void crtc_reg_write(UINT8 index, UINT8 data) |
| 803 | { |
| 804 | switch(index) |
| 805 | { |
| 806 | case 0x00: vga.crtc.horz_total = (data & 0xff) + 5; break; |
| 807 | case 0x01: vga.crtc.horz_disp_end = (data & 0xff) + 1; break; |
| 808 | case 0x02: vga.crtc.horz_blank_start = (data & 0xff); break; |
| 809 | case 0x03: |
| 810 | vga.crtc.horz_blank_end &= ~0x1f; |
| 811 | vga.crtc.horz_blank_end |= data & 0x1f; |
| 812 | vga.crtc.disp_enable_skew = (data & 0x60) >> 5; |
| 813 | vga.crtc.evra = (data & 0x80) >> 7; |
| 814 | break; |
| 815 | case 0x04: |
| 816 | vga.crtc.horz_retrace_start = data & 0xff; |
| 817 | break; |
| 818 | case 0x05: |
| 819 | vga.crtc.horz_blank_end &= ~0x20; |
| 820 | vga.crtc.horz_blank_end |= ((data & 0x80) >> 2); |
| 821 | vga.crtc.horz_retrace_skew = ((data & 0x60) >> 5); |
| 822 | vga.crtc.horz_retrace_end = data & 0x1f; |
| 823 | break; |
| 824 | case 0x06: |
| 825 | vga.crtc.vert_total &= ~0xff; |
| 826 | vga.crtc.vert_total |= data & 0xff; |
| 827 | break; |
| 828 | case 0x07: // Overflow Register |
| 829 | vga.crtc.vert_total &= ~0x300; |
| 830 | vga.crtc.vert_retrace_start &= ~0x300; |
| 831 | vga.crtc.vert_disp_end &= ~0x300; |
| 832 | vga.crtc.line_compare &= ~0x100; |
| 833 | vga.crtc.vert_blank_start &= ~0x100; |
| 834 | vga.crtc.vert_retrace_start |= ((data & 0x80) << (9-7)); |
| 835 | vga.crtc.vert_disp_end |= ((data & 0x40) << (9-6)); |
| 836 | vga.crtc.vert_total |= ((data & 0x20) << (9-5)); |
| 837 | vga.crtc.line_compare |= ((data & 0x10) << (8-4)); |
| 838 | vga.crtc.vert_blank_start |= ((data & 0x08) << (8-3)); |
| 839 | vga.crtc.vert_retrace_start |= ((data & 0x04) << (8-2)); |
| 840 | vga.crtc.vert_disp_end |= ((data & 0x02) << (8-1)); |
| 841 | vga.crtc.vert_total |= ((data & 0x01) << (8-0)); |
| 842 | break; |
| 843 | case 0x08: // Preset Row Scan Register |
| 844 | vga.crtc.byte_panning = (data & 0x60) >> 5; |
| 845 | vga.crtc.preset_row_scan = (data & 0x1f); |
| 846 | break; |
| 847 | case 0x09: // Maximum Scan Line Register |
| 848 | vga.crtc.line_compare &= ~0x200; |
| 849 | vga.crtc.vert_blank_start &= ~0x200; |
| 850 | vga.crtc.scan_doubling = ((data & 0x80) >> 7) + 1; |
| 851 | vga.crtc.line_compare |= ((data & 0x40) << (9-6)); |
| 852 | vga.crtc.vert_blank_start |= ((data & 0x20) << (9-5)); |
| 853 | vga.crtc.maximum_scan_line = (data & 0x1f) + 1; |
| 854 | break; |
| 855 | case 0x0a: |
| 856 | vga.crtc.cursor_enable = ((data & 0x20) ^ 0x20) >> 5; |
| 857 | vga.crtc.cursor_scan_start = data & 0x1f; |
| 858 | break; |
| 859 | case 0x0b: |
| 860 | vga.crtc.cursor_skew = (data & 0x60) >> 5; |
| 861 | vga.crtc.cursor_scan_end = data & 0x1f; |
| 862 | break; |
| 863 | case 0x0c: |
| 864 | case 0x0d: |
| 865 | vga.crtc.start_addr &= ~(0xff << (((index & 1)^1) * 8)); |
| 866 | vga.crtc.start_addr |= (data << (((index & 1)^1) * 8)); |
| 867 | break; |
| 868 | case 0x0e: |
| 869 | case 0x0f: |
| 870 | vga.crtc.cursor_addr &= ~(0xff << (((index & 1)^1) * 8)); |
| 871 | vga.crtc.cursor_addr |= (data << (((index & 1)^1) * 8)); |
| 872 | break; |
| 873 | case 0x10: |
| 874 | vga.crtc.vert_retrace_start &= ~0xff; |
| 875 | vga.crtc.vert_retrace_start |= data & 0xff; |
| 876 | break; |
| 877 | case 0x11: |
| 878 | vga.crtc.protect_enable = (data & 0x80) >> 7; |
| 879 | vga.crtc.bandwidth = (data & 0x40) >> 6; |
| 880 | vga.crtc.vert_retrace_end = data & 0x0f; |
| 881 | break; |
| 882 | case 0x12: |
| 883 | vga.crtc.vert_disp_end &= ~0xff; |
| 884 | vga.crtc.vert_disp_end |= data & 0xff; |
| 885 | break; |
| 886 | case 0x13: |
| 887 | vga.crtc.offset = data & 0xff; |
| 888 | break; |
| 889 | case 0x14: |
| 890 | vga.crtc.dw = (data & 0x40) >> 6; |
| 891 | vga.crtc.div4 = (data & 0x20) >> 5; |
| 892 | vga.crtc.underline_loc = (data & 0x1f); |
| 893 | break; |
| 894 | case 0x15: |
| 895 | vga.crtc.vert_blank_start &= ~0xff; |
| 896 | vga.crtc.vert_blank_start |= data & 0xff; |
| 897 | break; |
| 898 | case 0x16: |
| 899 | vga.crtc.vert_blank_end = data & 0x7f; |
| 900 | break; |
| 901 | case 0x17: |
| 902 | vga.crtc.sync_en = (data & 0x80) >> 7; |
| 903 | vga.crtc.word_mode = (data & 0x40) >> 6; |
| 904 | vga.crtc.aw = (data & 0x20) >> 5; |
| 905 | vga.crtc.div2 = (data & 0x08) >> 3; |
| 906 | vga.crtc.sldiv = (data & 0x04) >> 2; |
| 907 | vga.crtc.map14 = (data & 0x02) >> 1; |
| 908 | vga.crtc.map13 = (data & 0x01) >> 0; |
| 909 | break; |
| 910 | case 0x18: |
| 911 | vga.crtc.line_compare &= ~0xff; |
| 912 | vga.crtc.line_compare |= data & 0xff; |
| 913 | break; |
| 914 | default: |
| 915 | printf("Unhandled CRTC reg w %02x %02x\n",index,data); |
| 916 | } |
| 917 | } |
| 918 | |
| 745 | 919 | static READ8_HANDLER(vga_crtc_r) |
| 746 | 920 | { |
| 747 | 921 | UINT8 data = 0xff; |
| r14083 | r14084 | |
| 818 | 992 | if (vga.crtc.index < vga.svga_intf.crtc_regcount) |
| 819 | 993 | vga.crtc.data[vga.crtc.index] = data; |
| 820 | 994 | |
| 995 | crtc_reg_write(vga.crtc.index,data); |
| 821 | 996 | //space->machine().primary_screen->update_partial(space->machine().primary_screen->vpos()); |
| 822 | 997 | //printf("%02x %02x %d\n",vga.crtc.index,data,space->machine().primary_screen->vpos()); |
| 823 | 998 | break; |