Created
November 29, 2012 22:14
-
-
Save tuttlem/4172261 to your computer and use it in GitHub Desktop.
plasmas - generate costab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
#define PI_BY_2 (3.14159f * 2) | |
int main(int argc, char *argv[]) { | |
int theta = 0, count = 0, count2 = 0; | |
unsigned char values[256]; | |
for (theta = 0; theta <= 255; theta ++) { | |
float angle = ((float)theta / 256.0f) * PI_BY_2; | |
values[theta] = (unsigned char)((cosf(angle) * 127.0f) + 127.0f); | |
} | |
printf("costab DB "); | |
for (count = 0; count < 32; count ++) { | |
for (count2 = 0; count2 < 8; count2 ++) { | |
printf("%03xh, ", values[(count << 3) + count2]); | |
} | |
printf("\n DB "); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment