Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738// dump_sprite.cpp — decode a raw sprite by id from the asset banks and write it to a BMP,// UNFLIPPED and with no projection. Isolates the sprite decoder's handedness for comparison// against real-game reference pixels. Usage: dump_sprite ID [ID ...]#include <cstdio>#include <cstdlib>#include <string>#include "sc2k/render/asset_loader.hpp"#include "sc2k/render/framebuffer.hpp"
using namespace sc2k::render;
int main(int argc, char** argv) { if (argc < 2) { std::fprintf(stderr, "usage: dump_sprite ID [ID ...]\n"); return 2; } Assets a = load_assets(); const Rgba bg{255, 0, 255, 255}; // magenta = transparent, so handedness is unambiguous for (int i = 1; i < argc; ++i) { const int id = std::atoi(argv[i]); const Sprite* s = a.bank.get(id); if (!s) { std::fprintf(stderr, "id %d: no sprite\n", id); continue; } Framebuffer fb(s->width, s->height); for (int y = 0; y < s->height; ++y) for (int x = 0; x < s->width; ++x) fb.set(x, y, bg); // blit unflipped at 0,0 (blit_sprite signature: sprite, x, y, palette, flip, ...) fb.blit_sprite(*s, 0, 0, /*flip=*/false, a.palette.colors.data()); char path[64]; std::snprintf(path, sizeof path, "sprite_%d.bmp", id); fb.write_bmp(path); std::printf("id %d: %dx%d -> %s\n", id, s->width, s->height, path); } return 0;}