Decompile 5 functions in Source/Resource/Sprites/SpriteEncoding.cpp, Source/Resource/Sprites/SpriteResource.cpp, ...
Batch #11640 by cremane: 0 byte-identical, 5 confirmed by peer review. - fn_02405 ConvertSpritePalette: logic confirmed by peer review - fn_08062 CSprRes::ReduceSprite: logic confirmed by peer review - fn_08063 CSprRes::EncodeSpriteRuns: logic confirmed by peer review - fn_08054 CSprRes::Load: logic confirmed by peer review - fn_08055 CSprRes::Unload: logic confirmed by peer review Peer-reviewed-by: Yommy, KWDev Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
2a811bedf3
commit
19413f2872
3 changed files with 61 additions and 63 deletions
|
|
@ -4,34 +4,33 @@
|
|||
|
||||
// OFFSET: 0x00761070
|
||||
// FUNCTION: fn_08063
|
||||
std::uint8_t* EncodeSpriteRuns(const std::uint8_t* pixels, int width, int height, std::uint16_t& bytes) {
|
||||
std::uint8_t* CSprRes::EncodeSpriteRuns(const std::uint8_t* pixels, int width, int height, std::uint16_t& bytes) {
|
||||
std::vector<std::uint8_t> encoded;
|
||||
unsigned zeroCount = 0;
|
||||
bool zeroRun = false;
|
||||
std::uint32_t index = 0;
|
||||
std::uint16_t zeroCount = 0;
|
||||
int zeroRun = 0;
|
||||
std::uint16_t index = 0;
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x, ++index) {
|
||||
const std::uint8_t pixel = pixels[static_cast<std::uint16_t>(index)];
|
||||
|
||||
if (pixel == 0) {
|
||||
if (!zeroRun) {
|
||||
if (pixels[index] == 0) {
|
||||
if (zeroRun) {
|
||||
if (++zeroCount >= 255) {
|
||||
encoded.push_back(static_cast<std::uint8_t>(zeroCount));
|
||||
zeroRun = 0;
|
||||
zeroCount = 0;
|
||||
}
|
||||
} else {
|
||||
encoded.push_back(0);
|
||||
zeroRun = true;
|
||||
}
|
||||
|
||||
if (++zeroCount >= 255) {
|
||||
encoded.push_back(static_cast<std::uint8_t>(zeroCount));
|
||||
zeroRun = false;
|
||||
zeroCount = 0;
|
||||
zeroRun = 1;
|
||||
++zeroCount;
|
||||
}
|
||||
} else {
|
||||
if (zeroRun) {
|
||||
encoded.push_back(static_cast<std::uint8_t>(zeroCount));
|
||||
}
|
||||
|
||||
encoded.push_back(pixel);
|
||||
zeroRun = false;
|
||||
encoded.push_back(pixels[index]);
|
||||
zeroRun = 0;
|
||||
zeroCount = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -42,9 +41,9 @@ std::uint8_t* EncodeSpriteRuns(const std::uint8_t* pixels, int width, int height
|
|||
}
|
||||
|
||||
bytes = static_cast<std::uint16_t>(encoded.size());
|
||||
auto* result = static_cast<std::uint8_t*>(::operator new(bytes));
|
||||
auto* result = new std::uint8_t[bytes];
|
||||
|
||||
for (unsigned index = 0; index < bytes; ++index) {
|
||||
for (std::uint16_t index = 0; index < bytes; ++index) {
|
||||
result[index] = encoded[index];
|
||||
}
|
||||
|
||||
|
|
@ -53,10 +52,10 @@ std::uint8_t* EncodeSpriteRuns(const std::uint8_t* pixels, int width, int height
|
|||
|
||||
// OFFSET: 0x00760FE0
|
||||
// FUNCTION: fn_08062
|
||||
std::uint8_t* ReduceSprite(const std::uint8_t* pixels, int width, int height, int halfWidth, int halfHeight) {
|
||||
std::uint8_t* CSprRes::ReduceSprite(const std::uint8_t* pixels, int width, int height, int halfWidth, int halfHeight) {
|
||||
const int outputWidth = halfWidth != 0 ? width / 2 : width;
|
||||
const int outputHeight = halfHeight != 0 ? height / 2 : height;
|
||||
auto* output = static_cast<std::uint8_t*>(::operator new(static_cast<std::size_t>(outputWidth) * outputHeight));
|
||||
auto* output = new std::uint8_t[outputWidth * outputHeight];
|
||||
|
||||
for (int y = 0; y < outputHeight; ++y) {
|
||||
const auto* source = pixels + width * y * (halfHeight + 1);
|
||||
|
|
@ -73,9 +72,9 @@ std::uint8_t* ReduceSprite(const std::uint8_t* pixels, int width, int height, in
|
|||
// FUNCTION: fn_02405
|
||||
void ConvertSpritePalette(std::uint32_t* output, const std::uint8_t* input, int count) {
|
||||
for (int index = 0; index < count; ++index) {
|
||||
const unsigned red = input[index * 4];
|
||||
const unsigned green = input[index * 4 + 1];
|
||||
const unsigned blue = input[index * 4 + 2];
|
||||
const std::uint8_t red = input[index * 4];
|
||||
const std::uint8_t green = input[index * 4 + 1];
|
||||
const std::uint8_t blue = input[index * 4 + 2];
|
||||
output[index] = red >= 254 && green < 4 && blue >= 254 ? 1057u : ((blue | 0x40000u) >> 3) | (4 * ((green & 0xF8u) | (32 * (red & 0xF8u))));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue