www.pudn.com > virtual_gameboy-0.8.8.zip > FMFREQS.C
/* FmFreqs.c
This file is part of the VGB-DOS project
Copyright (C) Marcel de Kogel (m.dekogel@student.utwente.nl), 1996
Markus F.X.J. Oberhumer (markus.oberhumer@jk.uni-linz.ac.at), 1996
You may not use this file for commercial purposes
Please notify me if you make any changes to this file */
#include
#include
int main (void)
{
int i;
int b, bestb;
double v, minv;
int f, bestf;
double realfreq, adlibfreq;
FILE *file;
file = stdout;
for (i = 2048; i >= 1; i--)
{
minv = 10000; bestb = 0; bestf = 0;
realfreq = 4194304.0 / (32*i);
for (b = 0; b < 8; b++)
{
f = floor (realfreq / (50000.0 * pow(2,b-20)) + 0.5);
if (f > 1023)
continue;
adlibfreq = 50000.0 * f * pow(2,b-20);
v = fabs(realfreq - adlibfreq);
if (v < minv)
{
minv = v;
bestb = b;
bestf = f;
}
}
fprintf(file,"%1d, %4d, /* %8.2f */\n",
bestb, bestf, minv);
}
return 0;
}