home *** CD-ROM | disk | FTP | other *** search
- Program VGALoad;
-
- Uses Crt,
- Graph,
- Dos;
-
- CONST A_VGA_Driver = 9;
- MaxX = 320;
- MaxY = 200;
-
- Type InBufPtr = ^BufArray;
- BufArray = Array[1..65535] of Byte;
-
- Var InFile : File;
- FileName : String;
- CH : Char;
- Width,
- Height : Word;
- InBuf : Pointer;
- Vertical,
- Horizon,
- ArrayIndex,
- MemIndex,
- BlockCount,
- MaxBytes,
- BufSize : Longint;
- OrigMode : Integer;
- Pal : Array[1..768] of Byte;
-
- {************************************************************************
- * *
- * Sets video display to VGA 320x200x256 mode after first checking *
- * to see if the monitor supports that mode. *
- * *
- ************************************************************************}
-
- Function SetVideoMode : Boolean;
-
- Var Regs : Registers;
- Driver,
- Mode : Integer;
-
- Begin
-
- DetectGraph(Driver, Mode); {* Detects VGA Monitor *}
-
- If Driver = A_VGA_Driver Then
- Begin
-
- Regs.AH := $00;
- Regs.AL := $13; {* 320x200x256 VGA Mode *}
- Intr($10, Regs);
- SetVideoMode := TRUE;
-
- End
- Else SetVideoMode := FALSE;
-
- End;
-
- {***********************************************************************
- * *
- * Sets the diplay palette to the current image palette before *
- * displaying that image. *
- * *
- ***********************************************************************}
-
- Procedure SetPalette;
-
- Var Regs : Registers;
-
- Begin
-
- Regs.AH := $10;
- Regs.AL := $12;
- Regs.BX := 0; {* Starting Color Location *}
- Regs.CX := 256; {* Number of Colors *}
- Regs.ES := Seg(Pal); {* Array of RGB values for *}
- Regs.DX := Ofs(Pal); {* each palette color *}
- Intr($10, Regs);
-
- End;
-
- {***********************************************************************
- * *
- * VGALoad first reads the image file from the command line and *
- * determines if it is a valid bitmap. It then reads and sets the *
- * palette from the image. The buffer is filled and written to *
- * video memory, which starts at [$A000:0000], until the file is *
- * empty. The image can be repostioned on the screen by adjusting *
- * the MemIndex value. *
- * *
- ***********************************************************************}
-
- Begin
-
- If ParamCount = 1 Then
- Begin
-
- FileName := ParamStr(1);
- Assign(InFile,FileName);
- Reset(InFile,1);
-
- If (IOResult = 0) Then
- Begin
-
- OrigMode := LastMode;
- BufSize := MaxAvail; {* Get Maximum Memory for Buffer *}
- If BufSize > MaxInt Then
- BufSize := MaxInt;
-
- GetMem(InBuf, BufSize);
-
- If SetVideoMode Then
- Begin
-
- BlockRead(Infile, Width, 2); {* Read Off Width *}
- BlockRead(Infile, Height, 2); {* Read Off Height *}
-
- If (Width < MaxX) and (Height < MaxY) Then
- Begin
-
- BlockRead(InFile, Pal, 768); {* Read Palette Values *}
-
- SetPalette;
-
- MaxBytes := (MaxX * (Height + 1));
- BlockCount := 1;
- ArrayIndex := 1;
- MemIndex := 0;
-
- BlockRead(InFile, InBuf^, BufSize); {* Read BitMap *}
-
- For Vertical := 1 to Height do
- For Horizon := 1 to MaxX do
- Begin
-
- If Horizon <= Width Then
- Begin
- {* Place BitMap Buffer Into Video Memory *}
- Mem[$A000:MemIndex] := InBufPtr(InBuf)^[ArrayIndex];
- If ArrayIndex >= BufSize Then
- Begin
-
- BlockRead(InFile, InBuf^, BufSize);
- ArrayIndex := 0;
-
- End;
- Inc(ArrayIndex);
-
- End;
- MemIndex := MemIndex + 1;
-
- End;
- End;
- End;
-
- CH := ReadKey;
-
- FreeMem(InBuf,BufSize);
- Close(InFile);
-
- TextMode(OrigMode);
-
- End;
- End;
-
- End.
-
-