home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST1015.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-31  |  3.1 KB  |  84 lines

  1. Program TestBIOSInterfaceRoutines;
  2. {--------------------------------------------------------------}
  3. { This program is a test the collection of routines presented  }
  4. { earlier that interface the BGI with the BIOS.  The routines  }
  5. { can be found in listing 10.12, 10.13, and 10.14.             }
  6. {--------------------------------------------------------------}
  7.  
  8. Uses Crt, Dos, Graph;    { Link in necessary library units     }
  9.  
  10. Const
  11.   PathToDrivers = '';    { Location of support file for BGI    }
  12.   DAC = 14;              { DAC to get the RGB values from      }
  13.  
  14. Var
  15.   GraphDriver,
  16.   GraphMode : Integer;   { Variables for graphics mode         }
  17.   Ch : Char;             { Character to use for pausing        }
  18.   RedVal,
  19.   GreenVal,
  20.   BlueVal : Integer;     { Values of each color in a DAC       }
  21.   VideoMode : Byte;      { Value of active video mode          }
  22.   OutString : String;    { String used to OutText Info         }
  23.  
  24. {$I GETMODE.INC}         { Include routine from list 10.12     }
  25. {$I GETRGBP.INC}         { Include routine from list 10.13     }
  26. {$I GRASCALE.INC}        { Include routine from list 10.14     }
  27.  
  28. Procedure ShowGrayScale;
  29. { This procedure will display a sequence of bars on the screen }
  30. { using the first 16 palette registers.                        }
  31.  
  32. Var
  33.   MaxX, MaxY : Word;
  34.   Y1,Y2,YInc : Word;         { Variables used to create bars   }
  35.   I : Word;                  { Loop counter variable           }
  36.   P : PaletteType;           { Variable for original palette   }
  37.  
  38. Begin
  39.   GetPalette( P );           { Save the original palette       }
  40.   For I := 0 to 15 Do        { Reset palette to 1st 16 colors  }
  41.     SetPalette( I,I );
  42.   MaxY := GetMaxY;           { Create 16 bars on the screen    }
  43.   MaxX := GetMaxX;
  44.   YInc := MaxY Div 16;
  45.   Y1 := 0;
  46.   Y2 := YInc;
  47.   For I := 0 to 15 do
  48.   Begin
  49.     SetFillStyle( SolidFill, I );
  50.     Bar( 0,Y1,MaxX,Y2 );
  51.     Inc( Y1, YInc );
  52.     Inc( Y2, YInc );
  53.   End;
  54.   Ch := Readkey;             { Pause for Screen viewing        }
  55.   SetAllPalette( P );        { Restore original palette set    }
  56. End;
  57.  
  58. Begin
  59.   GraphDriver := VGA;   { Initialize graphics mode to VGA      }
  60.   GraphMode := VGAHi;
  61.   InitGraph( GraphDriver, GraphMode, PathToDrivers );
  62.   GetRGBPalette( DAC, RedVal, GreenVal, BlueVal );
  63.   Str( RedVal, OutString );  { Convert result for displaying   }
  64.   MoveTo( 10,10 );           { Reposition Current Pointer      }
  65.   OutText( 'Red = ' + OutString );
  66.   Str( GreenVal, OutString );
  67.   OutText( ' Green = ' + OutString );
  68.   Str( BlueVal, OutString );
  69.   OutText( ' Blue = ' + OutString );
  70.   Ch := Readkey;             { Pause for screen viewing        }
  71.   ClearViewPort;             { Clear the screen for next demo  }
  72.   CreateGrayScale( 0,16 );   { Create and display a gray scale }
  73.   ShowGrayScale;
  74.   ClearViewPort;             { Clear the screen for next demo  }
  75.   VideoMode := GetVideoMode;
  76.   Str( VideoMode, OutString );
  77.   OutTextXY( 10,10, OutString );
  78.   Ch := Readkey;             { Pause for screen viewing        }
  79.   CloseGraph;                { Shut down graphics system       }
  80.   GotoXY( 10,10 );
  81.   Write( GetVideoMode );
  82.   Ch := Readkey;
  83. End.
  84.