home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / FGIN131.ZIP / SOURCE.ZIP / DEFINE.C next >
C/C++ Source or Header  |  1994-02-11  |  3KB  |  167 lines

  1. /****************************************************************************\
  2.  
  3. \****************************************************************************/
  4. #include "fginput.h"
  5. #include "internal.h"
  6. #include <dos.h>
  7.  
  8. int  _VMode;                    //Video mode specific
  9. int  _VType;                    //Video mode type
  10. int  _VLines;                    //Number of text rows using
  11. int  _Defined;                    //Has define_parameters() been called?
  12.  
  13. int  BorderLcolor;
  14. int  BorderRcolor;
  15. int  BorderTcolor;
  16. int  BorderBcolor;
  17. int  Backcolor;
  18. int  BackHighlightcolor;
  19. int  TextNormalcolor;
  20. int  TextHighlightcolor;
  21. int  Cursorcolor;
  22.  
  23. int  Polled_Mode;
  24. int  TextSize=8;
  25.  
  26. void (*_print)(char*,int);    //Points to fg_text() or fg_print()
  27.  
  28. /****************************************************************************\
  29.  
  30.     int restore_default_colors(void)
  31.  
  32. \****************************************************************************/
  33. int restore_default_colors(void)
  34. {
  35.  
  36.     if (!_Defined) return(IN_NOT_DEFINED);
  37.     if (_VMode==NOTSUPPORTED) return(IN_NOT_SUPPORTED);
  38.  
  39.     BorderLcolor       =
  40.     BorderBcolor       = 0;
  41.  
  42.     switch (_VMode) {
  43.  
  44.         case TEXTC:
  45.         case COLOR16:
  46.         case COLOR16b:
  47.             BorderRcolor       =
  48.             BorderTcolor       = WHITE;
  49.             BorderBcolor       =
  50.             BorderLcolor       = DARKGRAY;
  51.             Backcolor          = BLACK;
  52.             BackHighlightcolor =
  53.             TextNormalcolor    = LIGHTGRAY;
  54.             TextHighlightcolor = WHITE;
  55.             Cursorcolor        = RED;
  56.             break;
  57.  
  58.         case TEXTBW:
  59.         case COLOR2:
  60.             BorderRcolor       =
  61.             BorderTcolor       =
  62.             Backcolor          =
  63.             TextHighlightcolor = 0;
  64.             Cursorcolor        =
  65.             BackHighlightcolor =
  66.             TextNormalcolor    = 1;
  67.             break;
  68.  
  69.         case COLOR4:
  70.             BackHighlightcolor =
  71.             BorderLcolor       =
  72.             BorderBcolor       =
  73.             BorderRcolor       =
  74.             BorderTcolor       = 1;
  75.             Backcolor          = 0;
  76.             TextNormalcolor    =
  77.             TextHighlightcolor = 3;
  78.             Cursorcolor        = 2;
  79.             break;
  80.  
  81.     }//Switch (mode)
  82.  
  83.     return(IN_SUCCESS);
  84.  
  85. }
  86.  
  87. /****************************************************************************\
  88.  
  89.     int define_parameters(void)
  90.  
  91. \****************************************************************************/
  92. int define_parameters(void)
  93. {
  94.  
  95.     int far *ptr;
  96.     int current_mode=fg_getmode();
  97.  
  98.     switch (current_mode) {
  99.  
  100.         case 0:
  101.         case 1:
  102.         case 2:
  103.         case 3:
  104.         case -125:
  105.             _VMode=TEXTC;
  106.             break;
  107.  
  108.         case 7:
  109.             _VMode=TEXTBW;
  110.             break;
  111.  
  112.         case 9:
  113.         case 11:
  114.         case 12:
  115.         case 15:
  116.             _VMode=NOTSUPPORTED;
  117.             break;
  118.  
  119.         case 6:
  120.         case 17:
  121.             _VMode=COLOR2;
  122.             break;
  123.  
  124.         case 4:
  125.         case 5:
  126.             _VMode=COLOR4;
  127.             break;
  128.  
  129.         case 16:
  130.             TextSize=14;
  131.             _VMode=COLOR16b;
  132.             break;
  133.  
  134.         default:
  135.             if (current_mode>=17&¤t_mode<=29)
  136.                 _VMode=COLOR16;
  137.             else if (current_mode==13||current_mode==14)
  138.                 _VMode=COLOR16;
  139.             else
  140.                 _VMode=NOTSUPPORTED;
  141.             break;
  142.  
  143.     }
  144.  
  145.     if (_VMode==TEXTC||_VMode==TEXTBW) {
  146.         _VType=TEXT;
  147.         _print=fg_text;
  148.     }
  149.     else {
  150.         _VType=GRAPHICS;
  151.         _print=fg_print;
  152.     }
  153.  
  154.     _Defined=1;
  155.     restore_default_colors();
  156.  
  157.     if (_VMode==NOTSUPPORTED) return(IN_NOT_SUPPORTED);
  158.  
  159.     /* Get number of text lines */
  160.     ptr=MK_FP(0x40,0x84);   //BIOS data area 0x00484 stores number of lines
  161.     _VLines=(*ptr)+1;       //Pointer is used for memory model compatibility
  162.  
  163.     return(IN_SUCCESS);
  164.  
  165. }
  166.  
  167.