
/*  ZXrand_c    April 26, 1991 11am
*        Using QL Small-C to
*     Generate Random Numbers insame way as ZX-81 & TS 2068
*/

#include <stdio_h>


int a[3], b[3], m[3], d[3];
int seed[3], random[3], i;
char c, strg[6], *ow; 

main()   {
   initz();
   printf("Choose an integer seed in the range from 0 to 65535 \n");
   gets(strg);
   *seed = atof(strg);
   printf("The seed will be %s\n",ftoa(seed,strg));
   printf("touch [SPACE BAR] to begin, q to quit\n");
   while((getc(c)) != 'q')   {
      rand();
      printf("%6s",ftoa(seed,strg));
   }
   printf("\nPress any key to exit\n");
   beep(10,1);
   for(i=0; i<20480; i++) {
      ;
   }
   beep(10,2);
   getc();
 }

initz()  {
   *a = atof("65536");
   *b = atof("65537");   
   *m = atof("75");
   *d = atof("74");
}

rand()  {
   *random = fmult(m,seed);
   *random = fadd(random,d);
   *random = fmod();
   fmove(seed,random);
   }

fmod()   {
   while(fcmp(random,b) >0 ) {
      *random = fsub(random,b);
   }
return (*random);
}

_console() {
  mode(4);
  fopen(ow,"con","w");
  window(ow,512,256,0,0);
  paper(ow,0);
  ink(ow,4);
  border(ow,7,2);
  cls(ow);
}
 
/*  End of ZXrand_c Apr 26, 1991 noon **  */ 
