home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / grafik / mcgatpu / apfemcga.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-05-25  |  4.3 KB  |  199 lines

  1. program apfel;
  2.        {Apelmänchen Routine für TURBO PASCAL
  3.     Aus:
  4.          CHIP MAGAZIN 1990 (Monat unbekannt )
  5.  
  6.          Modified by:
  7.  
  8.          STEVEN OF OZ
  9.          DISASTER BBS  0211/683207   GERMANY GILBNET
  10.  
  11.              Hardware required: MCGA / VGA - COLOR
  12.          }
  13.  
  14.  
  15. uses dos,crt,mcga;
  16.  
  17. const     stname='FRACTAL.GRA';
  18.       name='ZOOMFRAC.GRA';
  19.       cr=#13#10;
  20.  
  21. var
  22.       xmax,xmin,ymax,ymin :real;
  23.       xmaxt,xmint,ymaxt,ymint:real;
  24.       xmaxtl,xmintl,ymaxtl,ymintl:real;
  25.       tmax,yp,xp,x,y :integer;
  26.       schritte,hg:byte;
  27.       dx,dy,cy,cx,temp:real;
  28.       ywa,yqa,yw,xw,xq,yq:real;
  29.       regs:registers;
  30.       xk,yk:Integer;
  31.          ch:char;
  32.         num:byte;
  33.         newname,tempname:string;
  34.  
  35. procedure wait;
  36. begin
  37.  
  38.  ch:=readkey;
  39.  while keypressed do ch:=readkey
  40. end;
  41.  
  42. procedure reset(ite:boolean);
  43. begin
  44.        tempname:=stname;
  45.        xmax:= 2.0;  {Standart param.}
  46.        xmin:=-1.5;
  47.        ymax:= 2.1;
  48.        ymin:=-2.1;
  49.        if ite then tmax:=16;   {Iterationdepth}
  50.        hg:=8       {Background color}
  51. end;
  52.  
  53. procedure create;
  54. label raus;
  55. begin
  56.       xk:=320;    {Video size of MCGA}
  57.       yk:=200;
  58.  
  59.       dx:=(xmax-xmin)/xk;
  60.       dy:=(ymax-ymin)/yk;
  61.       cy:=ymax;
  62.  
  63.       for yp:=0 to yk do begin
  64.        cx:=xmin;
  65.        ywa:=0-cy;
  66.        yqa:=ywa*ywa;
  67.        for xp:=0 to xk do begin
  68.     xw:=0-cx;
  69.     yw:=ywa;
  70.     xq:=xw*xw;
  71.     yq:=yqa;
  72.      for schritte:=1 to tmax do begin
  73.       yw:=(yw+yw)*xw-cy;
  74.       xw:=xq-yq-cx;
  75.       xq:=xw*xw;
  76.       yq:=yw*yw;
  77.       if xq+yq>=8 then goto raus
  78.      end;
  79.      schritte:=hg;
  80.   raus:  PrintPixelAt(Schritte,xp,yp);
  81.      cx:=cx+dx
  82.     end;
  83.     if keypressed then begin
  84.          setmode(text);
  85.            xmax:=xmaxtl;
  86.            xmin:=xmintl;
  87.            ymax:=ymaxtl;
  88.            ymin:=ymintl;
  89.           exit end;
  90.     cy:=cy-dy
  91.        end
  92. end;
  93.  
  94. begin
  95.       clrscr;
  96.       Reset(true);      {standart param}
  97.       tempname:=stname;
  98.  
  99.   repeat
  100.       Gotoxy(1,1);
  101.       Writeln('Written by STEVEN OF OZ',cr,
  102.           'Revised Version V1.2',cr,
  103.           'DISASTER BBS 0211/686331 GILBNET GERMANY',cr,cr,
  104.           '1. Load last fractal',cr,
  105.           '2. ZOOM and SAVE',cr,
  106.           '3. Iterationdepth/ Num of colors and repaint',cr,
  107.           '4. RESET',cr,
  108.           '5. Last data',cr,
  109.           'e. Exit',cr,cr,
  110.           'MEM : ',memavail,' required 128k ',cr,cr,
  111.           'Current Data:',cr,
  112.           'XMax: ',xmax:2:4,cr,
  113.           'YMax: ',ymax:2:4,cr,
  114.           'XMin: ',xmin:2:4,cr,
  115.           'YMin: ',ymin:2:4,cr,
  116.           'TMax: ',tmax,'            Iterationdepth/ Num of colors');
  117.       Wait;
  118.  
  119.        case ch of
  120.     '1': begin setmode(mcgam); load(name) ;wait;setmode(text) end;
  121.     '2': begin
  122.            num:=0;
  123.  
  124.            xmaxtl:=xmax;  {Merker}
  125.            xmintl:=xmin;
  126.            ymaxtl:=ymax;
  127.            ymintl:=ymin;
  128.  
  129.            setmode(mcgam); {Grafikmodus setzen}
  130.            load(tempname);
  131.            
  132.            GraphMouse;     {Mousepointer MCGA on}
  133.            repeat
  134.              Getmousepos(x,y,button);
  135.                      dec(y,2);
  136.              case button of
  137.              left: begin    {Obere linke Ecke holen}
  138.                  sound(440);
  139.                  delay(100);
  140.                  nosound;
  141.  
  142.                                   xmaxt:=xmin+((xmax-xmin)/639)*x;
  143.                                   ymint:=ymin+((ymax-ymin)/199)*y
  144.                 end;
  145.             right: begin    {Untere rechte Ecke holen}
  146.                  sound(1000);
  147.                  delay(100);
  148.                  nosound;
  149.  
  150.                                   xmint:=xmin+((xmax-xmin)/639)*x;
  151.                                   ymaxt:=ymin+((ymax-ymin)/199)*y
  152.                 end
  153.            end;
  154.                    if keypressed then ch:=readkey;
  155.  
  156.            until  ch=#27;
  157.  
  158.            xmax:=xmint;
  159.            xmin:=xmaxt;
  160.            ymax:=ymint;
  161.            ymin:=ymaxt;
  162.  
  163.            HideMouse;
  164.            create;
  165.            if not(keypressed) then begin
  166.                     save(name);
  167.             wait;
  168.             setmode(text);
  169.                      if tempname<>name then tempname:=name
  170.            end
  171.                     else
  172.                       if tempname=stname then reset(true)
  173.          end;
  174.     '3': begin
  175.           clrscr;
  176.           Write('Iterationstiefe/ Anzahl der Farben (16-255) : ');
  177.           Readln(tmax);
  178.           if (tmax>255) or (tmax<-1) then tmax:=16;
  179.           clrscr;
  180.           Setmode(mcgam);
  181.           create;
  182.           if not(keypressed) then begin
  183.            save(name);
  184.            wait;
  185.            Setmode(text)
  186.           end
  187.          end;
  188.     '4': reset(true);
  189.         '5': begin
  190.            xmax:=xmaxtl;
  191.            xmin:=xmintl;
  192.            ymax:=ymaxtl;
  193.            ymin:=ymintl
  194.          end
  195.        end
  196.    until ch ='e'
  197. end.
  198.  
  199.