/* the exponential variation of the uncovered
	area in the return-map test */


#include <dos.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>


void plot(int x, int y, int color);
void setmode (int mode);
void cls(int color);


int xres=640;
int yres=480;

float lambdar, lambdai;

int A[102][102];

main()
{ float x,y;
  long int i,s;
  long int R;
  int is, js;
  s=0;
  R=100*100;
  y=(float)(rand())/(RAND_MAX+1.0);

  for(is=1; is<=100; is++)
	for(js=1; js<=100; js++) A[is][js]=0;

  setmode(18);
  cls(7);

  for(s=1; s<=1000000; s++)
  {x=(float)(rand())/(RAND_MAX+1.0);
	is=(int)(y*100)+1;
	js=(int)(x*100)+1;
	y=x;
	if (A[is][js]==0) {A[is][js]=1; R--;
							 if (R>0) plot(s/100,480-(int)(40*log((double)(R))),12);}
  }



getchar();
}



void setmode(int mode)
{
  union REGS reg;
  reg.x.ax=mode;
  int86 (0x10,&reg,&reg);
}



void cls(int color)
{
    union REGS reg;

    reg.x.ax=0x0600;
    reg.x.cx=0;
    reg.x.dx=0x1E4F;
    reg.h.bh=color;
    int86(0x10,&reg,&reg);
}

void plot(int x, int y , int color)
{

   #define graph_out(index,val) {outp(0x3CE,index); outp(0x3CF,val);}
   int dummy,mask;
   char far * address;
   address = (char far *) 0xA0000000L+(long)y*xres/8L+((long)x/8L);
   mask=0x80 >> (x%8);
   graph_out(8,mask);
   graph_out(5,2);
   dummy= *address;
   *address=color;
   graph_out(5,0);
   graph_out(8,0xFF);
 }





