src/mess/video/isa_ega.c
| r15430 | r15431 | |
| 773 | 773 | static CRTC_EGA_UPDATE_ROW( pc_ega_graphics ) |
| 774 | 774 | { |
| 775 | 775 | isa8_ega_device *ega = dynamic_cast<isa8_ega_device*>(device->owner()); |
| 776 | | // UINT16 *p = &bitmap.pix16(y); |
| 777 | | int i; |
| 776 | UINT16 *p = &bitmap.pix16(y); |
| 778 | 777 | |
| 779 | 778 | // logerror( "pc_ega_graphics: y = %d, x_count = %d, ma = %d, ra = %d\n", y, x_count, ma, ra ); |
| 780 | 779 | |
| 781 | | switch ( ega->m_attribute.data[ 0x12 ] & 0x0f ) |
| 780 | if ( ega->m_graphics_controller.data[5] & 0x10 ) |
| 782 | 781 | { |
| 783 | | case 0x03: |
| 784 | | for ( i = 0; i < x_count; i++ ) |
| 782 | // Odd/Even mode (CGA compatible) |
| 783 | |
| 784 | for ( int i = 0; i < x_count; i++ ) |
| 785 | 785 | { |
| 786 | | // UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( y & 1 ) << 13 ); |
| 787 | | // UINT8 data = ega->m_videoram[ offset ]; |
| 788 | | // |
| 789 | | // *p = ega->m_attribute.data[ ( data >> 6 ) ]; p++; |
| 790 | | // *p = ega->m_attribute.data[ ( data >> 4 ) & 0x03 ]; p++; |
| 791 | | // *p = ega->m_attribute.data[ ( data >> 2 ) & 0x03 ]; p++; |
| 792 | | // *p = ega->m_attribute.data[ data & 0x03 ]; p++; |
| 793 | | // |
| 794 | | // data = ega->m_videoram[ offset + 1 ]; |
| 795 | | // |
| 796 | | // *p = ega->m_attribute.data[ ( data >> 6 ) ]; p++; |
| 797 | | // *p = ega->m_attribute.data[ ( data >> 4 ) & 0x03 ]; p++; |
| 798 | | // *p = ega->m_attribute.data[ ( data >> 2 ) & 0x03 ]; p++; |
| 799 | | // *p = ega->m_attribute.data[ data & 0x03 ]; p++; |
| 786 | UINT16 offset = ( ( ma + i ) & 0x1fff ) | ( ( y & 1 ) << 12 ); |
| 787 | UINT8 data = ega->m_plane[0][offset]; |
| 788 | |
| 789 | *p = ega->m_attribute.data[ ( data >> 6 ) ]; p++; |
| 790 | *p = ega->m_attribute.data[ ( data >> 4 ) & 0x03 ]; p++; |
| 791 | *p = ega->m_attribute.data[ ( data >> 2 ) & 0x03 ]; p++; |
| 792 | *p = ega->m_attribute.data[ data & 0x03 ]; p++; |
| 793 | |
| 794 | data = ega->m_plane[1][offset]; |
| 795 | |
| 796 | *p = ega->m_attribute.data[ ( data >> 6 ) ]; p++; |
| 797 | *p = ega->m_attribute.data[ ( data >> 4 ) & 0x03 ]; p++; |
| 798 | *p = ega->m_attribute.data[ ( data >> 2 ) & 0x03 ]; p++; |
| 799 | *p = ega->m_attribute.data[ data & 0x03 ]; p++; |
| 800 | 800 | } |
| 801 | | break; |
| 802 | | case 0x0f: |
| 803 | | for ( i = 0; i < x_count; i++ ) |
| 801 | } |
| 802 | else |
| 803 | { |
| 804 | // EGA mode |
| 805 | |
| 806 | // UINT8 mask = ega->m_attribute.data[0x12] & 0x0f; |
| 807 | |
| 808 | for ( int i = 0; i < x_count; i++ ) |
| 804 | 809 | { |
| 805 | | // UINT16 offset = ma + i; |
| 806 | | // UINT8 data0 = ega->m_plane[0][ offset ]; |
| 807 | | // UINT8 data1 = ega->m_plane[1][ offset ]; |
| 808 | | // UINT8 data2 = ega->m_plane[2][ offset ]; |
| 809 | | // UINT8 data3 = ega->m_plane[3][ offset ]; |
| 810 | | // |
| 811 | | // for ( int j = 0; j < 8; j++ ) |
| 812 | | // { |
| 813 | | // UINT16 col = ( ( data0 >> 7 ) & 0x01 ) | ( ( data1 >> 6 ) & 0x02 ) | ( ( data2 >> 5 ) & 0x04 ); |
| 814 | | // if ( data3 & 0x80 ) |
| 815 | | // { |
| 816 | | // col += 0x38; |
| 817 | | // } |
| 818 | | // |
| 819 | | // *p = col; |
| 820 | | // p++; |
| 821 | | // data0 <<= 1; |
| 822 | | // data1 <<= 1; |
| 823 | | // data2 <<= 1; |
| 824 | | // data3 <<= 1; |
| 825 | | // } |
| 810 | UINT16 offset = ma + i; |
| 811 | UINT16 data0 = ega->m_plane[0][offset]; |
| 812 | UINT16 data1 = ega->m_plane[1][offset] << 1; |
| 813 | UINT16 data2 = ega->m_plane[2][offset] << 2; |
| 814 | UINT16 data3 = ega->m_plane[3][offset] << 3; |
| 815 | |
| 816 | for ( int j = 7; j >= 0; j-- ) |
| 817 | { |
| 818 | UINT16 col = ( data0 & 0x01 ) | ( data1 & 0x02 ) | ( data2 & 0x04 ) | ( data3 & 0x08 ); |
| 819 | |
| 820 | // col &= mask; |
| 821 | |
| 822 | p[j] = ega->m_attribute.data[col]; |
| 823 | |
| 824 | data0 >>= 1; |
| 825 | data1 >>= 1; |
| 826 | data2 >>= 1; |
| 827 | data3 >>= 1; |
| 828 | } |
| 829 | p += 8; |
| 826 | 830 | } |
| 827 | | break; |
| 828 | | default: |
| 829 | | if (y==0) |
| 830 | | printf("unhandled %02x\n", ega->m_attribute.data[ 0x12 ] & 0x0f); |
| 831 | | break; |
| 832 | 831 | } |
| 833 | 832 | } |
| 834 | 833 | |
| r15430 | r15431 | |
| 930 | 929 | } |
| 931 | 930 | else |
| 932 | 931 | { |
| 933 | | m_charA = m_plane[2] + 0x10000; |
| 934 | | m_charB = m_plane[2] + 0x10000; |
| 932 | m_charA = m_plane[2]; |
| 933 | m_charB = m_plane[2]; |
| 935 | 934 | } |
| 936 | 935 | } |
| 937 | 936 | |
| r15430 | r15431 | |
| 991 | 990 | WRITE8_MEMBER( isa8_ega_device::write ) |
| 992 | 991 | { |
| 993 | 992 | UINT8 alu[4]; |
| 993 | UINT8 target_mask = m_graphics_controller.data[8]; |
| 994 | |
| 994 | 995 | alu[0] =alu[1] = alu[2] = alu[3] = 0; |
| 995 | 996 | |
| 996 | 997 | switch( m_graphics_controller.data[5] & 0x03 ) |
| r15430 | r15431 | |
| 1030 | 1031 | alu[3] = m_read_latch[3] ^ data; |
| 1031 | 1032 | break; |
| 1032 | 1033 | } |
| 1034 | break; |
| 1033 | 1035 | |
| 1034 | | offset &= 0xffff; |
| 1036 | case 1: // Write mode 1 |
| 1037 | alu[0] = m_read_latch[0]; |
| 1038 | alu[1] = m_read_latch[1]; |
| 1039 | alu[2] = m_read_latch[2]; |
| 1040 | alu[3] = m_read_latch[3]; |
| 1041 | target_mask = 0xff; |
| 1042 | return; |
| 1035 | 1043 | |
| 1036 | | // |
| 1037 | | // Plane selection |
| 1038 | | // TODO: Get this logic clearer. The documentation is unclear on the exact magic combination of bits. |
| 1039 | | // |
| 1040 | | if ( m_sequencer.data[4] & 0x04 ) |
| 1044 | case 2: // Write mode 2 |
| 1045 | alu[0] = ( data & 0x01 ) ? 0xff : 0x00; |
| 1046 | alu[1] = ( data & 0x02 ) ? 0xff : 0x00; |
| 1047 | alu[2] = ( data & 0x04 ) ? 0xff : 0x00; |
| 1048 | alu[3] = ( data & 0x08 ) ? 0xff : 0x00; |
| 1049 | break; |
| 1050 | |
| 1051 | case 3: // Write mode 3 |
| 1052 | popmessage("EGA: Write mode 3 not supported!"); |
| 1053 | return; |
| 1054 | } |
| 1055 | |
| 1056 | offset &= 0xffff; |
| 1057 | |
| 1058 | // |
| 1059 | // Plane selection |
| 1060 | // TODO: Get this logic clearer. The documentation is unclear on the exact magic combination of bits. |
| 1061 | // |
| 1062 | if ( m_sequencer.data[4] & 0x04 ) |
| 1063 | { |
| 1064 | // Sequential addressing mode |
| 1065 | if ( m_sequencer.data[2] & 0x01 ) |
| 1041 | 1066 | { |
| 1042 | | // Sequential addressing mode |
| 1043 | | if ( m_attribute.data[0x12] & 0x01 ) |
| 1067 | // Plane 0 |
| 1068 | // Bit selection |
| 1069 | m_plane[0][offset] = ( m_plane[0][offset] & ~ target_mask ) | ( alu[0] & target_mask ); |
| 1070 | } |
| 1071 | if ( m_sequencer.data[2] & 0x02 ) |
| 1072 | { |
| 1073 | // Plane 1 |
| 1074 | // Bit selection |
| 1075 | m_plane[1][offset] = ( m_plane[1][offset] & ~ target_mask ) | ( alu[1] & target_mask ); |
| 1076 | } |
| 1077 | if ( m_sequencer.data[2] & 0x04 ) |
| 1078 | { |
| 1079 | // Plane 2 |
| 1080 | // Bit selection |
| 1081 | m_plane[2][offset] = ( m_plane[2][offset] & ~ target_mask ) | ( alu[2] & target_mask ); |
| 1082 | } |
| 1083 | if ( m_sequencer.data[2] & 0x08 ) |
| 1084 | { |
| 1085 | // Plane 3 |
| 1086 | // Bit selection |
| 1087 | m_plane[3][offset] = ( m_plane[3][offset] & ~ target_mask ) | ( alu[3] & target_mask ); |
| 1088 | } |
| 1089 | } |
| 1090 | else |
| 1091 | { |
| 1092 | // Odd/Even addressing mode |
| 1093 | if ( offset & 1 ) |
| 1094 | { |
| 1095 | // Odd addresses go to planes 1 and 3 |
| 1096 | |
| 1097 | offset >>= 1; |
| 1098 | |
| 1099 | if ( m_sequencer.data[2] & 0x02 ) |
| 1044 | 1100 | { |
| 1045 | | // Plane 0 |
| 1046 | | // Bit selection |
| 1047 | | m_plane[0][offset] = ( m_plane[0][offset] & ~ m_graphics_controller.data[8] ) | ( alu[0] & m_graphics_controller.data[8] ); |
| 1048 | | } |
| 1049 | | if ( m_attribute.data[0x12] & 0x02 ) |
| 1050 | | { |
| 1051 | 1101 | // Plane 1 |
| 1052 | 1102 | // Bit selection |
| 1053 | | m_plane[1][offset] = ( m_plane[1][offset] & ~ m_graphics_controller.data[8] ) | ( alu[1] & m_graphics_controller.data[8] ); |
| 1103 | m_plane[1][offset] = ( m_plane[1][offset] & ~ target_mask ) | ( alu[1] & target_mask ); |
| 1054 | 1104 | } |
| 1055 | | if ( m_attribute.data[0x12] & 0x04 ) |
| 1105 | if ( ( m_sequencer.data[2] & 0x08 ) && ! ( m_sequencer.data[4] & 0x01 ) ) |
| 1056 | 1106 | { |
| 1057 | | // Plane 2 |
| 1058 | | // Bit selection |
| 1059 | | m_plane[2][offset] = ( m_plane[2][offset] & ~ m_graphics_controller.data[8] ) | ( alu[2] & m_graphics_controller.data[8] ); |
| 1060 | | } |
| 1061 | | if ( m_attribute.data[0x12] & 0x08 ) |
| 1062 | | { |
| 1063 | 1107 | // Plane 3 |
| 1064 | 1108 | // Bit selection |
| 1065 | | m_plane[3][offset] = ( m_plane[3][offset] & ~ m_graphics_controller.data[8] ) | ( alu[3] & m_graphics_controller.data[8] ); |
| 1109 | m_plane[3][offset] = ( m_plane[3][offset] & ~ target_mask ) | ( alu[3] & target_mask ); |
| 1066 | 1110 | } |
| 1067 | 1111 | } |
| 1068 | 1112 | else |
| 1069 | 1113 | { |
| 1070 | | // Odd/Even addressing mode |
| 1071 | | if ( offset & 1 ) |
| 1072 | | { |
| 1073 | | // Odd addresses go to planes 1 and 3 |
| 1114 | // Even addresses go to planes 0 and 2 |
| 1074 | 1115 | |
| 1075 | | offset >>= 1; |
| 1116 | offset >>= 1; |
| 1076 | 1117 | |
| 1077 | | if ( m_attribute.data[0x12] & 0x02 ) |
| 1078 | | { |
| 1079 | | // Plane 1 |
| 1080 | | // Bit selection |
| 1081 | | m_plane[1][offset] = ( m_plane[1][offset] & ~ m_graphics_controller.data[8] ) | ( alu[1] & m_graphics_controller.data[8] ); |
| 1082 | | } |
| 1083 | | if ( ( m_attribute.data[0x12] & 0x08 ) && ! ( m_sequencer.data[4] & 0x01 ) ) |
| 1084 | | { |
| 1085 | | // Plane 3 |
| 1086 | | // Bit selection |
| 1087 | | m_plane[3][offset] = ( m_plane[3][offset] & ~ m_graphics_controller.data[8] ) | ( alu[3] & m_graphics_controller.data[8] ); |
| 1088 | | } |
| 1118 | if ( m_sequencer.data[2] & 0x01 ) |
| 1119 | { |
| 1120 | // Plane 0 |
| 1121 | // Bit selection |
| 1122 | m_plane[0][offset] = ( m_plane[0][offset] & ~ target_mask ) | ( alu[0] & target_mask ); |
| 1089 | 1123 | } |
| 1090 | | else |
| 1124 | if ( ( m_sequencer.data[2] & 0x04 ) && ! ( m_sequencer.data[4] & 0x01 ) ) |
| 1091 | 1125 | { |
| 1092 | | // Even addresses go to planes 0 and 2 |
| 1093 | | |
| 1094 | | offset >>= 1; |
| 1095 | | |
| 1096 | | if ( m_attribute.data[0x12] & 0x01 ) |
| 1097 | | { |
| 1098 | | // Plane 0 |
| 1099 | | // Bit selection |
| 1100 | | m_plane[0][offset] = ( m_plane[0][offset] & ~ m_graphics_controller.data[8] ) | ( alu[0] & m_graphics_controller.data[8] ); |
| 1101 | | } |
| 1102 | | if ( ( m_attribute.data[0x12] & 0x04 ) && ! ( m_sequencer.data[4] & 0x01 ) ) |
| 1103 | | { |
| 1104 | | // Plane 2 |
| 1105 | | // Bit selection |
| 1106 | | m_plane[2][offset] = ( m_plane[2][offset] & ~ m_graphics_controller.data[8] ) | ( alu[2] & m_graphics_controller.data[8] ); |
| 1107 | | } |
| 1126 | // Plane 2 |
| 1127 | // Bit selection |
| 1128 | m_plane[2][offset] = ( m_plane[2][offset] & ~ target_mask ) | ( alu[2] & target_mask ); |
| 1108 | 1129 | } |
| 1109 | 1130 | } |
| 1110 | | |
| 1111 | | break; |
| 1112 | | |
| 1113 | | case 1: // Write mode 1 |
| 1114 | | popmessage("EGA: Write mode 1 not supported!"); |
| 1115 | | break; |
| 1116 | | |
| 1117 | | case 2: // Write mode 2 |
| 1118 | | popmessage("EGA: Write mode 2 not supported!"); |
| 1119 | | break; |
| 1120 | | |
| 1121 | | case 3: // Write mode 3 |
| 1122 | | popmessage("EGA: Write mode 3 not supported!"); |
| 1123 | | break; |
| 1124 | 1131 | } |
| 1125 | 1132 | } |
| 1126 | 1133 | |