From the Archives: Screen Capture in DOS

I was moving some files into Dropbox for archiving and was poking through some files and found my old screen dump program in Turbo Pascal. It dumps a raw $10 VGA mode file.

BTW, if you haven’t tried out dropbox, do so. It’s pretty fantastic. Use this link and I will get some bonus space for the referral: https://www.dropbox.com/referrals/NTMyODY2MTg5

program Screen_Dump;
{$M 1024, 0, 0}
{$R-,S-,I-,D+,F+,V-,B-,N-,L+}
uses CRT, Dos;

Type
    PalType = Record
         Red : Byte;
         Green : Byte ;
         Blue : Byte;
    end;
var
   OldPrtScrVec: pointer;
   MyFile : File;
   x : word;
   PalArray: Array [0..255] of PalType;
   PalFile : File of Byte;
   C : byte;

procedure STI;
Inline($FB);

procedure CallOldInt(Sub : Pointer);
begin
     inline($9C/$FF/$5E/$06);
end;

procedure MyInt5(Flags, CS, IP, AX, BX, CX, DX,
                        SI, DI, DS, ES, BP: word); interrupt;

begin
   if AX = 14254 then
   begin
      Assign(MyFile, 'DUMPED.RAW');
      Rewrite(MyFile, 1);
      BlockWrite(MyFile, Mem[$A000 : 0], 64000);
      close(MyFile);

      Assign(PalFile, 'DUMPED.PAL');
      Rewrite(PalFile);
      for C := 0 to 255 do
      begin
	 with PalArray do
	 begin
	    Port[$3C7] := c;
	    red := Port[$3C9];
	    green := Port[$3C9];
	    blue := Port[$3C9];
	    write (PalFile, PalArray.red);
	    write (PalFile, PalArray.green);
	    write (PalFile, PalArray.blue);
	 end;
      end;
      sound(1000);
      delay(500);
      nosound;
   end
   else
      CallOldInt(OldPrtScrVec);

   STI;
end;

begin
   GetintVec($05, OldPrtScrVec);
   SetIntVec($05, @MyInt5);
   writeln('Screen Dump is Memory Resident');
   keep(0);
end.

Leave a Reply

Your email address will not be published. Required fields are marked *