home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / bix / twoscrn.pas < prev    next >
Pascal/Delphi Source File  |  1986-08-04  |  2KB  |  75 lines

  1. {switching between mono & color}
  2. program twoscrn;
  3. {demonstration of two screen operation}
  4. {(c) 1985 by nathan liskov, waltham mass}
  5. {free to use but not to sell}
  6. var
  7.   n:integer;
  8.   mpos:array [0..31] of array [0..1] of integer;
  9.  
  10. procedure saveparam(imode:integer);     {save screen state}
  11. var
  12.   n:integer;
  13. begin
  14.   for n:=0 to 29 do
  15.   mpos[n,imode]:=mem[0:1097+n];
  16.   mpos[30,imode]:=wherey;
  17.   mpos[31,imode]:=wherex;
  18. end;
  19.  
  20. procedure restoreparam(imode:integer);     {restore screen state}
  21. var
  22.   n:integer;
  23. begin
  24.   for n:=0 to 29 do
  25.   mem[0:1097+n]:=mpos[n,imode];
  26.   gotoxy(mpos[31,imode],mpos[30,imode]);
  27. end;
  28.  
  29. procedure tocolor;     {to color monitor}
  30. begin
  31.   saveparam(0);        {save mono screen state}
  32.   mem[0:1040]:=(mem[0:1040] and 207) or 32;    {to color monitor}
  33.   restoreparam(1);     {restore previous color screen state}
  34. end;
  35.  
  36. procedure tomono;     {to mono monitor}
  37. begin
  38.   saveparam(1);       {save color screen state}
  39.   mem[0:1040]:=(mem[0:1040] and 207) or 48;      {to mono monitor}
  40.   restoreparam(0);    {restore previous mono screen state}
  41. end;
  42.  
  43. procedure setupscreens;     {save mono and color screen states}
  44. begin                       {ends up on mono monitor}
  45.  if (mem[0:1040] and 207)=207 then  {if current monitor is mono then...}
  46.  begin
  47.   saveparam(0);      {save mono screen state}
  48.   mem[0:1040]:=(mem[0:1040] and 207) or 32; {to color screen}
  49.  end else
  50.  begin
  51.   saveparam(1)       {save color screen state}
  52.  end;
  53.  textmode(0);
  54.  textbackground(1);
  55.  mem[0:1040]:=(mem[0:1040] and 207) or 48;  {to mono screen}
  56.  textmode;
  57. end;
  58.  
  59. begin
  60.  setupscreens;
  61.  tocolor;
  62.  graphcolormode;
  63.  graphbackground(1);
  64.  for n:=1 to 20 do
  65.  begin
  66.   tomono;
  67.   writeln('here i am! ',n);
  68.   tocolor;
  69.   draw(0,0,32*n,2*n*n,1);
  70. {  gotoxy(1+n,2*n-1);}
  71.   writeln('no here i am! ',n);
  72.  end;
  73.  tomono;
  74. end.
  75.