From 6ebf73c48a8a1cd90234593e5e4d38fc46909d3f Mon Sep 17 00:00:00 2001 From: rofl0r Date: Sat, 2 Nov 2019 18:41:10 +0000 Subject: [PATCH] 2palpic: whitespace cleanup --- utils/2palpic.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/utils/2palpic.c b/utils/2palpic.c index ca6ac65..5b36008 100644 --- a/utils/2palpic.c +++ b/utils/2palpic.c @@ -44,7 +44,7 @@ int main(int argc, char** argv) { int w, h; struct palpic pp = palpic_empty; prgb pal[256]; - + struct Pix* infile; struct Pix* pix32; @@ -59,9 +59,9 @@ int main(int argc, char** argv) { } if(startarg == 2 && argv[1][0] == '-' && argv[1][1] == 't' && argv[1][2] == 0) pp.flags |= PPF_TRANSPARENT; - + startarg++; - + char *in_filename = argv[startarg]; if(access(in_filename, R_OK) == -1) { perror(in_filename); @@ -80,12 +80,12 @@ int main(int argc, char** argv) { size_t l = snprintf(struct_name, sizeof struct_name, "%s", st_start); struct_name[l-2] = 0; } - - + + infile = pixRead(in_filename); pixGetDimensions(infile, &w, &h, NULL); - + if(startarg > 1) { char* str_w = argv[startarg -1] + LIT_SIZE("-sprite="); char* str_h = strchr(str_w, 'x'); @@ -108,16 +108,16 @@ int main(int argc, char** argv) { sprite_h = h; sprite_count = 1; } - + unsigned sprites_per_row = w / sprite_w; - + /* we always align sprites vertically */ pp.height = sprite_h * sprite_count; pp.width = sprite_w; - + pix32 = pixConvertTo32(infile); prgb* bufptr = (prgb*) pix32->data; - + unsigned x, y = 0, p; for(y = 0; y < (unsigned) h; y++) { for(x = 0; x < (unsigned) w; x++) { @@ -129,21 +129,21 @@ int main(int argc, char** argv) { bufptr++; } } - + FILE* outfile = fopen(out_filename, "w"); - + unsigned sprite; if(!to_c) { palpic_fileformat(&pp); fwrite(&pp, sizeof(pp), 1, outfile); fwrite(pal, sizeof(prgb) * pp.palcount, 1, outfile); - + for(sprite = 0; sprite < sprite_count; sprite++) { for(y = 0; y < sprite_h; y++) { unsigned sprite_start_y = get_sprite_start(sprite, y, sprite_w, sprite_h, sprites_per_row); bufptr = &((prgb*) pix32->data)[sprite_start_y]; - + for(x = 0; x < sprite_w; x++) { for(p = 0; p < pp.palcount; p++) if(pal[p].val == bufptr->val) { @@ -160,7 +160,7 @@ int main(int argc, char** argv) { } } else { char buf[1024]; - snprintf(buf, sizeof(buf), + snprintf(buf, sizeof(buf), "#include \"palpic.h\"\n" "#define PAL_COUNT %d\n" "#define SPRITE_COUNT %d\n" @@ -177,24 +177,24 @@ int main(int argc, char** argv) { "\t{ {'p', 'P', 'i', 'C', }, 1, PAL_COUNT, SPRITE_COUNT, WIDTH, HEIGHT, %s, 0 },\n" "\t{\n\t\t", (int) pp.palcount, - (int) sprite_count, - (int) pp.width, + (int) sprite_count, + (int) pp.width, (int) pp.height, struct_name, (pp.flags & PPF_TRANSPARENT ? "PPF_TRANSPARENT" : "0") ); fwrite(buf, strlen(buf), 1, outfile); - + for(p = 0; p < pp.palcount; p++) { if(p == 0 && pp.flags & PPF_TRANSPARENT) snprintf(buf, sizeof(buf), "PRGB(%3u, %3u, %3u), ", (unsigned) 0,(unsigned) 0, (unsigned) 0); - else + else snprintf(buf, sizeof(buf), "PRGB(%3u, %3u, %3u), ", (unsigned) pal[p].colors.r,(unsigned) pal[p].colors.g, (unsigned) pal[p].colors.b); fwrite(buf, strlen(buf), 1, outfile); - //if(p % 8 == 7) + //if(p % 8 == 7) fwrite(STRSZ("\n\t\t"), 1, outfile); } - + snprintf(buf, sizeof(buf), "\n\t},\n\t{\n\t\t"); fwrite(buf, strlen(buf), 1, outfile); unsigned counter = 0; @@ -207,7 +207,7 @@ int main(int argc, char** argv) { unsigned sprite_start_y = get_sprite_start(sprite, y, sprite_w, sprite_h, sprites_per_row); assert(sprite_start_y + sprite_w <= h * w); bufptr = &((prgb*) pix32->data)[sprite_start_y]; - + for(x = 0; x < sprite_w; x++) { for(p = 0; p < pp.palcount; p++) { if(pal[p].val == bufptr->val) { @@ -232,7 +232,7 @@ int main(int argc, char** argv) { fwrite(STRSZ("\n\t},\n"), 1, outfile); - snprintf(buf, sizeof(buf), + snprintf(buf, sizeof(buf), "};\n\n" "#undef o\n" "#undef PAL_COUNT\n" @@ -241,7 +241,7 @@ int main(int argc, char** argv) { "#undef HEIGHT\n" "#undef STRUCT_NAME\n\n"); fwrite(buf, strlen(buf), 1, outfile); - + } fclose(outfile); pixDestroy(&pix32); -- 2.11.4.GIT