Change colour palette in text mode, pascal source

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category:

Program: Farbydos.pas
File exe: Farbydos.exe

It changes the colour palette directly in the text mode of DOS withoutswitching to the graphics. The text is first demonstrated in black and then displayed. Really clever, e.g. if you don't want a user to see all the commands which your program gives and of which the display can't be prevented. For example, if you send a command to DOS which can display the well-known "Bad command or file name".
{ FARBYDOS.PAS              Copyright (c) TrSek alias Zdeno Sekerak }
{ Program vie zmenit graficku paletu v DOSe - textovom rezime.      }
{ Demonstruje to tak ze zhasne text a potom ho rozsvieti.           }
{                                                                   }
{ Datum:01.02.1999                             http://www.trsek.com }
 
program zmena_farieb_dos;
uses crt;
const time=50;
Type paleta=array[1..768] of byte;
var pal:Paleta;
      i:integer;
 
procedure jas ( n:integer; var p:paleta);
var i:integer;
begin
 Port[$3c8]:=0;
 for i:=1 to 768 do port[$3c9]:=p[i]*n div 63;
end;
 
procedure zp ( var p:paleta );
var i:integer;
begin
 Port[$3c7]:=0;
 for i:=1 to 768 do p[i]:=Port[$3c9];
end;
 
procedure Zasviet ( var p:paleta);
var n:integer;
begin
 for n:=0 to 63 do begin
   Jas(n,p);
   Delay(time);
   end;
end;
 
procedure Stmavenie ( var p:paleta);
var n:integer;
begin
 for n:=63 downto 0 do begin
   Jas(n,p);
   delay(time);
   end;
end;
 
begin
 ClrScr;
 for i:=1 to 25 do begin
    GotoXY(1,i);
    TextColor(i);
    Write('Zmena farieb v DOSe. Zhasam a rozsviecujem farby.             Software by TrSek.');
    end;
 zp(pal);
 Stmavenie(pal);
 Zasviet(pal);
 end.