/* * fredygames.com: regenerates Brogue CE's assets/tiles.bin for the redrawn tiles.png. * * tiles.bin holds the sub-pixel alignments that tiles.c finds by brute force for every tile and * size (optimizeTiles); the game computes it when the file is missing, which takes minutes and * opens a progress window. Since make-tiles.py redraws the text glyphs, the file is recomputed here, * once, at build time: this program compiles tiles.c as is, with its window calls replaced by stubs * (the optimizer only uses software surfaces), and runs under Node (-sNODERAWFS) on the build tree. * * tiles-bin (reads /assets/tiles.png, writes /assets/tiles.bin) * * Part of the source of the build served at fredygames.com (AGPL-3.0-or-later, like Brogue CE). */ #include #include #include #include static SDL_Surface *previewSurface; static SDL_Window *stubCreateWindow(void) { return NULL; } static SDL_Surface *stubGetWindowSurface(void) { if (!previewSurface) { previewSurface = SDL_CreateRGBSurfaceWithFormat(0, 128, 232, 32, SDL_PIXELFORMAT_ARGB8888); } return previewSurface; } #define SDL_CreateWindow(...) stubCreateWindow() #define SDL_SetWindowTitle(...) ((void)0) #define SDL_GetWindowSurface(...) stubGetWindowSurface() #define SDL_UpdateWindowSurface(...) 0 #define SDL_PollEvent(...) 0 #define SDL_DestroyWindow(...) ((void)0) #include "tiles.c" /* Symbols tiles.c uses from the rest of the game; only the optimizer runs here. */ char dataDirectory[BROGUE_FILENAME_MAX]; boolean fileExists(const char *pathname) { FILE *f = fopen(pathname, "rb"); if (f) fclose(f); return f != NULL; } int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "usage: tiles-bin \n"); return 1; } strcpy(dataDirectory, argv[1]); if (!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)) return 1; initTiles(); /* no tiles.bin yet: optimizes every tile and writes it */ return 0; }