/* the return-map test for the simple floa
	random number generator on the [0.1) interval */

#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;

long int A[102];

main()
{ float x,y;
  int is,js;
  long int i;
  setmode(18);
  cls(7);
  y=(float)(rand())/(RAND_MAX+1.0);
  for(i=1; i<=1000000; i++)
  {x=(float)(rand())/(RAND_MAX+1.0);
	is=(int)(400*y);
	js=(int)(400*x);
	y=x;
	plot(is, js, 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);
 }





