Previous 15994 Revisions Next

r15431 Saturday 9th June, 2012 at 19:47:56 UTC by Wilbert Pol
isa_ega.c: Started rewriting some of the graphics modes. (nw)
[src/mess/video]isa_ega.c isa_ega.h

src/mess/video/isa_ega.c
r15430r15431
773773static CRTC_EGA_UPDATE_ROW( pc_ega_graphics )
774774{
775775   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);
778777
779778//  logerror( "pc_ega_graphics: y = %d, x_count = %d, ma = %d, ra = %d\n", y, x_count, ma, ra );
780779
781   switch ( ega->m_attribute.data[ 0x12 ] & 0x0f )
780   if ( ega->m_graphics_controller.data[5] & 0x10 )
782781   {
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++ )
785785      {
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++;
800800      }
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++ )
804809      {
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;
826830      }
827      break;
828   default:
829      if (y==0)
830         printf("unhandled %02x\n", ega->m_attribute.data[ 0x12 ] & 0x0f);
831      break;
832831   }
833832}
834833
r15430r15431
930929      }
931930      else
932931      {
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];
935934      }
936935   }
937936
r15430r15431
991990WRITE8_MEMBER( isa8_ega_device::write )
992991{
993992   UINT8 alu[4];
993   UINT8 target_mask = m_graphics_controller.data[8];
994
994995   alu[0] =alu[1] = alu[2] = alu[3] = 0;
995996
996997   switch( m_graphics_controller.data[5] & 0x03 )
r15430r15431
10301031         alu[3] = m_read_latch[3] ^ data;
10311032         break;
10321033      }
1034      break;
10331035
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;
10351043
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 )
10411066      {
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 )
10441100         {
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         {
10511101            // Plane 1
10521102            // 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 );
10541104         }
1055         if ( m_attribute.data[0x12] & 0x04 )
1105         if ( ( m_sequencer.data[2] & 0x08 ) && ! ( m_sequencer.data[4] & 0x01 ) )
10561106         {
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         {
10631107            // Plane 3
10641108            // 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 );
10661110         }
10671111      }
10681112      else
10691113      {
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
10741115
1075            offset >>= 1;
1116         offset >>= 1;
10761117
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 );
10891123         }
1090         else
1124         if ( ( m_sequencer.data[2] & 0x04 ) && ! ( m_sequencer.data[4] & 0x01 ) )
10911125         {
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 );
11081129         }
11091130      }
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;
11241131   }
11251132}
11261133
src/mess/video/isa_ega.h
r15430r15431
5555      UINT8   *m_plane[4];
5656      UINT8   m_read_latch[4];
5757      UINT8   *m_videoram;
58      UINT8   *m_videoram_a0000;
59      UINT8   *m_videoram_b0000;
60      UINT8   *m_videoram_b8000;
6158      UINT8   *m_charA;
6259      UINT8   *m_charB;
6360

Previous 15994 Revisions Next


© 1998-2018 The MESS Team