unit farbwahl;

interface

uses crt, graph;

type colortyp = record
         rott, gruent, blaut : integer;
       end;

const rosa : colortyp = (rott: 250; gruent: 225; blaut: 225);
      holz : colortyp = (rott: 175; gruent: 100; blaut: 30);

procedure setpalettecolor(colornum: integer; farbkonst: colortyp);

procedure resetcolor(colornum: integer);

procedure zufallfarbe(colornum : integer);

implementation

const EGAColors : array[0..15] of colortyp = (
        ( rott:$00; gruent:$00; blaut:$00 ),          {0}
        ( rott:$00; gruent:$00; blaut:$70 ),          {1}
        ( rott:$00; gruent:$70; blaut:$00 ),          {2}
        ( rott:$00; gruent:$70; blaut:$70 ),          {3}
        ( rott:$70; gruent:$00; blaut:$00 ),          {4}
        ( rott:$6a; gruent:$00; blaut:$6a ),          {5}
        ( rott:175; gruent:85; blaut:$00 ),           {6}
        ( rott:105; gruent:105; blaut:105 ),          {7}
        ( rott:$15; gruent:$15; blaut:$15 ),          {8}
        ( rott:$15; gruent:$15; blaut:$fc ),          {9}
        ( rott:$15; gruent:$fc; blaut:$15 ),          {10}
        ( rott:$00; gruent:$fc; blaut:$fc ),          {11}
        ( rott:$fc; gruent:$15; blaut:$15 ),          {12}
        ( rott:$fc; gruent:$00; blaut:$fc ),          {13}
        ( rott:$fc; gruent:$fc; blaut:$00 ),          {14}
        ( rott:$fc; gruent:$fc; blaut:$fc ));         {15}
      gd : integer = 9;
      gm : integer = 2;

var i : integer;
    istr : string;

procedure setpalettecolor(colornum: integer; farbkonst : colortyp);

  begin
    with farbkonst do
      begin
        if colornum=6 then colornum:=20;
        if (colornum>=8) and (colornum<=15) then colornum:=colornum+48;
        setrgbpalette(colornum, rott, gruent, blaut);
      end;
  end;

procedure zufallfarbe(colornum: integer);
  begin
    if colornum=6 then colornum:=20;
    if (colornum>=8) and (colornum<=15) then colornum:=colornum+48;
    setrgbpalette(colornum, random(255), random(255), random(255));
  end;

procedure resetcolor(colornum : integer);

  var colornum2 : integer;

  begin
    case colornum of
        6       : colornum2:=20;
        8..15   : colornum2:=colornum+48;
        0..5, 7 : colornum2:=colornum;
      end;
    with egacolors[colornum] do
      setrgbpalette(colornum2, rott, gruent, blaut);
  end;

end.