Decompile 5 functions in Source/Resource/Bitmap/BitmapImage.cpp, Source/Resource/Bitmap/BitmapImage.h, ...

Batch #1026 by ragnarok-clanker: 0 byte-identical, 5 confirmed by peer review.

- fn_07866 BitmapImage::CreateAuxiliary: logic confirmed by peer review
- fn_07867 BitmapImage::Pixel: logic confirmed by peer review
- fn_07874 BitmapImage::ClearAuxiliary: logic confirmed by peer review
- fn_09684 SkinPaletteColor: logic confirmed by peer review
- fn_09685 SkinPaletteChannels: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
Adds to the build: Source/Resource/SkinPalette.cpp
This commit is contained in:
ragnarok-clanker 2026-10-27 10:04:56 +00:00
commit d22c6b96a6
5 changed files with 106 additions and 0 deletions

View file

@ -57,6 +57,62 @@ void BitmapImage::Clear() {
this->auxiliary = nullptr;
}
// OFFSET: 0x0074A680
// FUNCTION: fn_07866
bool BitmapImage::CreateAuxiliary(int mode) {
if (!this->pixels || this->auxiliary) {
return false;
}
this->auxiliary = std::malloc(PixelBytes(this->width, this->height));
std::memset(this->auxiliary, 255, 4u * this->width * this->height);
auto* output = static_cast<std::uint32_t*>(this->auxiliary);
for (int y = 0; y < this->height; ++y) {
for (int x = 0; x < this->width; ++x) {
const int index = x + y * this->width;
const std::uint32_t value = this->pixels[index];
unsigned red = (value >> 16) & 255;
unsigned green = (value >> 8) & 255;
unsigned blue = value & 255;
if (red != 255 || blue != 255 || green != 0) {
unsigned intensity = (red + green + blue) / 3;
const unsigned minimum = mode == 1 ? 120 : 100;
if (intensity < minimum) {
intensity = minimum;
}
red = green = blue = intensity;
if (mode == 2) {
red = 200;
} else if (mode == 3) {
green = 200;
} else if (mode == 4) {
blue = 200;
}
}
output[index] = (value & 0xFF000000u) | (red << 16) | (green << 8) | blue;
}
}
return true;
}
// OFFSET: 0x0074A7F0
// FUNCTION: fn_07867
std::uint32_t BitmapImage::Pixel(int x, int y) const {
if (x < 0 || x >= this->width || y < 0 || y >= this->height) {
return 0x00FF0000;
}
return this->pixels[x + y * this->width];
}
// OFFSET: 0x0074C540
// FUNCTION: fn_07874
void BitmapImage::ClearAuxiliary() {
if (this->auxiliary) {
std::free(this->auxiliary);
this->auxiliary = nullptr;
}
}
// OFFSET: 0x0074AB00
// FUNCTION: fn_07869
bool BitmapImage::DecodeBitmap(const void* input, int, bool iconOnly) {

View file

@ -14,6 +14,9 @@ struct BitmapImage {
BitmapImage();
void Clear();
bool CreateAuxiliary(int mode);
std::uint32_t Pixel(int x, int y) const;
void ClearAuxiliary();
bool DecodeBitmap(const void* data, int bytes, bool iconOnly);
bool DecodeTga(const void* data, int bytes);
bool DecodePng(const void* data, int bytes, const char* name);

View file

@ -0,0 +1,29 @@
#include "Resource/SkinPalette.h"
#include "Resource/Bitmap/BitmapResource.h"
#include "Resource/ResourceMgr.h"
#include "Resource/TextureNames.h"
// OFFSET: 0x007E0F40
// FUNCTION: fn_09684
std::uint32_t SkinPaletteColor(ResourceMgr& resources, TextureNames& names, const SkinPaletteCell& cell, bool resolveSkin) {
const char* filename = "유저인터페이스\\colorchip.bmp";
if (resolveSkin) {
filename = names.Resolve(filename);
}
auto* bitmap = static_cast<CBitmapRes*>(resources.Load(filename));
if (!bitmap) {
return 0;
}
const std::uint32_t color = bitmap->image.Pixel(4 * cell.column + 2, 4 * cell.row + 2);
return ((color & 255) << 16) | (color & 0xFF00) | ((color >> 16) & 255);
}
// OFFSET: 0x007E0FC0
// FUNCTION: fn_09685
void SkinPaletteChannels(ResourceMgr& resources, TextureNames& names, int x, int y, unsigned& red, unsigned& green, unsigned& blue) {
auto* bitmap = static_cast<CBitmapRes*>(resources.Load(names.Resolve("유저인터페이스\\colorchip.bmp")));
const std::uint32_t color = bitmap->image.Pixel(x, y);
red = (color >> 16) & 255;
green = (color >> 8) & 255;
blue = color & 255;
}

View file

@ -0,0 +1,17 @@
#ifndef RAGNAROK_SOURCE_RESOURCE_SKINPALETTE_H
#define RAGNAROK_SOURCE_RESOURCE_SKINPALETTE_H
#include <cstdint>
class ResourceMgr;
struct TextureNames;
struct SkinPaletteCell {
/* 0000 */ int column;
/* 0004 */ int row;
};
std::uint32_t SkinPaletteColor(ResourceMgr& resources, TextureNames& names, const SkinPaletteCell& cell, bool resolveSkin);
void SkinPaletteChannels(ResourceMgr& resources, TextureNames& names, int x, int y, unsigned& red, unsigned& green, unsigned& blue);
#endif

View file

@ -513,6 +513,7 @@
"Source/Resource/ResourceFailures.cpp": 3,
"Source/Resource/ResourceMgr.cpp": 3,
"Source/Resource/ResourceTransient.cpp": 3,
"Source/Resource/SkinPalette.cpp": 3,
"Source/Resource/Sprites/ActionResource.cpp": 3,
"Source/Resource/Sprites/SpriteEncoding.cpp": 3,
"Source/Resource/Sprites/SpriteResource.cpp": 3,