convertPieces.c 515 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. Script for converting the piece graphic to C data.
  3. CC0
  4. */
  5. #include <stdio.h>
  6. #include <stdint.h>
  7. int main(void)
  8. {
  9. FILE *f = fopen("pieces.ppm","rb");
  10. uint8_t b[256];
  11. fread(b,1,0x3A,f);
  12. int counter = 0;
  13. uint8_t byte = 0;
  14. while (fread(b,1,3,f) == 3)
  15. {
  16. byte = (byte << 1) | (b[0] != 0);
  17. counter++;
  18. if (counter % 8 == 0)
  19. {
  20. printf("0x%x,",byte);
  21. if ((counter % (8 * 12)) == 0)
  22. putchar('\n');
  23. byte = 0;
  24. }
  25. }
  26. fclose(f);
  27. return 0;
  28. }