3d cube and dirty drawing
[dos_low3d] / tools / genlut.c
1 #include <stdio.h>
2 #include <math.h>
3
4 #define SINTAB_SIZE             512
5 #define SINTAB_SCALE    8192
6
7 int main(void)
8 {
9         int i, len;
10
11         printf("\tbits 32\n");
12         printf("\tsection .rodata\n\n");
13
14         printf("\tglobal _sintab\n");
15         printf("_sintab:\n");
16
17         fputs("\tdw", stdout);
18         len = 10;
19         for(i=0; i<SINTAB_SIZE; i++) {
20                 double theta = (double)i / (double)SINTAB_SIZE * 6.28318530718;
21                 double sf = sin(theta);
22                 int sx = (int)(sf * SINTAB_SCALE);
23                 len += printf(" %d", sx);
24                 if(len >= 72) {
25                         putchar('\n');
26                         if(i < SINTAB_SIZE - 1) {
27                                 fputs("\tdw", stdout);
28                                 len = 10;
29                         }
30                 } else {
31                         putchar(',');
32                         len++;
33                 }
34         }
35         printf("\n\n; vi:ft=nasm ts=8 sts=8 sw=8:\n");
36         return 0;
37 }