From 7b35a18c93511482b644e6a0ed1dbd9de11eff07 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 31 Jan 2021 22:33:48 -0500 Subject: Progress on map dumper, now renders images with holes in them --- tools/sprite_dumper/common.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tools/sprite_dumper/common.h') diff --git a/tools/sprite_dumper/common.h b/tools/sprite_dumper/common.h index dca5de9..2aca4fa 100644 --- a/tools/sprite_dumper/common.h +++ b/tools/sprite_dumper/common.h @@ -136,4 +136,25 @@ private: std::vector data_; }; +class Palette { +public: + + Palette() = default; + + Palette(BufferView m3, const int addr) { + for (int i=0; i<16; i++) { + unsigned short ch = m3.ReadTwoBytes(addr + (i << 1)); + int r = (ch & 0x1F); + int g = ((ch >> 5) & 0x1F); + int b = ((ch >> 10) & 0x1F); + colors_.push_back(Magick::ColorRGB((r << 3)/256.0, (g << 3)/256.0, (b << 3)/256.0)); + } + } + + const std::vector& Colors() const { return colors_; } + +private: + std::vector colors_; +}; + #endif /* end of include guard: COMMON_H_04DD2B2A */ -- cgit 1.4.1