Skip to content

Instantly share code, notes, and snippets.

@tuttlem
Created November 29, 2012 22:14
Show Gist options
  • Save tuttlem/4172261 to your computer and use it in GitHub Desktop.
Save tuttlem/4172261 to your computer and use it in GitHub Desktop.
plasmas - generate costab
#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