program pal_relax;

{ palette relaxation v1.1 by Crush,D UNT }

uses crt,crush13h;        { crt for keypressed }
                          { crush13h for color stuff and mode 13h }
var r,g,b:integer;
    x,y,z:byte;
    m,n,o:integer;

begin

     writeln ('Crush,D UNT back in the mix...');
     writeln ('        Palette relaxation');
     writeln ('                !!! EPILEPSY WARNING !!!');
     writeln ('                Watch out for your eyes...');
     writeln ('');
     writeln ('Press a key...');
     readkey;

     video_mode ( $13);                 { mode 13h}

     setcolor (4,32,32,32);             { initial color }

     cls (4,vga);                       { clear screen }
     randomize;

     repeat
                                        { NOTE: random means 0<=x<range }
     r:=random(3)-1;                    { random numbers for r,g,b }
     g:=random(3)-1;                    { between -1 and 1... }
     b:=random(3)-1;                    { random (3) means 0,1 or 2 :) }

     {normal relaxation is random(3)-1}
     {for real psycho journey write random(a)-a/2-1 beeing a>64 and pair}

     getcolor (4,x,y,z);                { get color settings }
                                        { check bounds }
     {if x+r > 63 then r:=0;
     if y+g > 63 then g:=0;
     if z+b > 63 then b:=0;

     if x+r < 0 then r:=63;
     if y+g < 0 then g:=63;
     if z+b < 0 then b:=63;}

     setcolor (4,x+r,y+g,z+b);          { new color settings }
     waitvbl;                           { wait for vertical retrace}

     until keypressed;
     readkey;                           { exit }

     video_mode ( 03);                  { normal mode }

end.