home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / MATRIX.ZIP / SOURCE.ZIP / CREATANG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-13  |  1.1 KB  |  57 lines

  1. /*
  2.  *
  3.  *  CREATANG.C
  4.  *
  5.  *  (Simon Hern, 1994)
  6.  *
  7.  *  Create table of sines of angles for use in MATRIX program
  8.  *  Table outputted to file ANGSINES.ASM in assembler format
  9.  *
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <math.h>
  14.  
  15.  
  16. #define PI 3.1415926536
  17. #define FILE_NAME "ANGSINES.ASM"
  18. #define ANGLES 1024
  19.  
  20.  
  21. #define WORDS_PER_LINE 8
  22. void dump_word(FILE * f, int w) {
  23.     static int mmm = 0;
  24.     if ( mmm == 0 ) fprintf(f, "\n    dw  0%04xh", w);
  25.     else fprintf(f, ", 0%04xh", w);
  26.     if ( ++mmm == WORDS_PER_LINE ) mmm = 0;
  27. }
  28.  
  29.  
  30. int main() {
  31.  
  32.     FILE * file;
  33.     int i;
  34.     int sval;
  35.  
  36.     file = fopen(FILE_NAME, "wt");
  37.     if ( file == NULL ) {
  38.         printf("Error: Cannot open %s for output\n", FILE_NAME);
  39.         return 1;
  40.     }
  41.  
  42.     fprintf(file, "\n_Data SEGMENT WORD PUBLIC \'Data\'\n\n");
  43.     fprintf(file, "_AngleSines:\n");
  44.  
  45.     for ( i = 0 ; i < ANGLES ; i++ ) {
  46.         sval = 32767.0 * sin(2*PI * (double)i/ANGLES);
  47.         dump_word(file, sval);
  48.     }
  49.  
  50.     fprintf(file, "\n\n_Data ENDS\n\n");
  51.  
  52.     fclose(file);
  53.     return 0;
  54. }
  55.  
  56.  
  57.