home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-ASM_VI.ARJ / PROGC.ZIP / PROGC002.C < prev    next >
Text File  |  1988-05-25  |  4KB  |  80 lines

  1.  
  2. /************************************************************************/
  3. /* Load all control registers using a table                             */
  4. /* First we determine type of display attached and then load register   */
  5. /* with values for mode 3 (if Color display) or mode 7 (if Mono display)*/
  6. /************************************************************************/
  7.  
  8. select_mode_x()
  9.         {
  10.         #define MONO    5
  11.         #define VMONO   7
  12.         #define VCOLOR  8
  13.  
  14.         static  char    mode_0[] = {
  15.                 0xD4,                           /* CRTC Address         */
  16.                 0x23,                           /* Miscellaneous Regs   */
  17.                 0x0B,0x03,0x00,0x03,            /* Sequencer            */
  18.                                                 /* CRT Controller       */
  19.                 0x37,0x27,0x2D,0x37, 0x31,0x15,0x04,0x11,
  20.                 0x00,0x07,0x06,0x07, 0x00,0x00,0x00,0x00,
  21.                 0xE1,0x24,0xC7,0x14, 0x08,0xE0,0xF0,0xA3, 0xFF,
  22.                                                 /* Graphics Controller  */
  23.                 0x00,0x00,0x00,0x00, 0x00,0x10,0x0E,0x00, 0xFF,
  24.                                                 /* Attribute Controller */
  25.                 0x00,0x01,0x02,0x03, 0x04,0x05,0x14,0x07,
  26.                 0x38,0x39,0x3A,0x3B, 0x3C,0x3D,0x3E,0x3F,
  27.                 0x08,0x00,0x0F,0x00};
  28.  
  29.         static  char    mode_3[] = {
  30.                 0xD4,                           /* CRTC Address         */
  31.                 0xA7,                           /* Miscellaneous Regs   */
  32.                 0x01,0x03,0x00,0x03,            /* Sequencer            */
  33.                                                 /* CRT Controller       */
  34.                 0x5B,0x4F,0x53,0x37, 0x51,0x5B,0x6C,0x1F,
  35.                 0x00,0x0D,0x0B,0x0C, 0x00,0x00,0x00,0x00,
  36.                 0x5E,0x2B,0x5D,0x28, 0x0F,0x5E,0x0A,0xA3, 0xFF,
  37.                                                 /* Graphics Controller  */
  38.                 0x00,0x00,0x00,0x00, 0x00,0x10,0x0E,0x00, 0xFF,
  39.                                                 /* Attribute Controller */
  40.                 0x00,0x01,0x02,0x03, 0x04,0x05,0x14,0x07,
  41.                 0x38,0x39,0x3A,0x3B, 0x3C,0x3D,0x3E,0x3F,
  42.                 0x08,0x00,0x0F,0x00};
  43.  
  44.         static  char    mode_7[] = {
  45.                 0xB4,                           /* CRTC Address         */
  46.                 0xA6,                           /* Miscellaneous Regs   */
  47.                 0x00,0x03,0x00,0x03,            /* Sequencer            */
  48.                                                 /* CRT Controller       */
  49.                 0x60,0x4F,0x56,0x3A, 0x51,0x60,0x70,0x1F,
  50.                 0x00,0x0D,0x0B,0x0C, 0x00,0x00,0x00,0x00,
  51.  
  52.                 0x5E,0x2E,0x5D,0x28, 0x0D,0x5E,0x6E,0xA3, 0xFF,
  53.                                                 /* Graphics Controller  */
  54.                 0x00,0x00,0x00,0x00, 0x00,0x10,0x0A,0x00, 0xFF,
  55.                                                 /* Attribute Controller */
  56.                 0x00,0x08,0x08,0x08, 0x08,0x08,0x08,0x08,
  57.                 0x10,0x18,0x18,0x18, 0x18,0x18,0x18,0x18,
  58.                 0x0E,0x00,0x0F,0x08};
  59.  
  60.         if (get_display_type() == VCOLOR)
  61.                 {
  62.                 write_register_set(mode_3);     /* Set VGA into mode 3   */
  63.                 getchar();
  64.                 set_mode(3);
  65.                 }
  66.  
  67.         else if (get_display_type() == MONO || get_display_type() == VMONO)
  68.                 {
  69.                 write_register_set(mode_7);     /* Set EGA into mode 7   */
  70.                 getchar();
  71.                 set_mode(7);
  72.                 }
  73.         else
  74.                 {
  75.                 write_register_set(mode_0);     /* Set EGA into mode 0   */
  76.                 getchar();
  77.                 set_mode(3);
  78.                 }
  79.         }
  80.