Advertisement
Guest User

Untitled

a guest
Jun 18th, 2013
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. FILE *o;
  2.  
  3. double a;
  4. double b;
  5. double fr;
  6. double pclk;
  7.  
  8. a = pow(2.0, (1.0 / 12.0));
  9. pclk = (1.0 / (4433618.75 * 1.6)) * 2.0;
  10.  
  11. o = fopen("mt_PeriodTable.h", "w");
  12. fprintf(o, "const short mt_PeriodTable[%d] =\n{\n%c", 16 * 37, 0x09);
  13.  
  14. for (i = 0; i < 16; ++i)
  15. {
  16.     b = pow(a, ((double)i / 8.0));
  17.     fr = 258.9731 * b;
  18.  
  19.     for (j = 0; j < 36; ++j)
  20.     {
  21.         mt_PeriodTable[(i * 37) + j] = (int)((1.0 / fr / pclk) / 16.0);
  22.  
  23.         fr *= a;
  24.  
  25.         fprintf(o, "%d,",  mt_PeriodTable[(i * 37) + j]);
  26.         if (j == 35)
  27.             fprintf(o, "0,\n%c",  0x09);
  28.         else if ((j % 12) == 11)
  29.             fprintf(o, "\n%c",  0x09);
  30.     }
  31.  
  32.     mt_PeriodTable[(i * 37) + j] = 0;  
  33. }
  34.  
  35. fseek(o, -4, SEEK_CUR);
  36. fprintf(o, "\n};\n");
  37.  
  38. fclose(o);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement