The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body. src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT, from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra). structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
262 lines
8.0 KiB
C++
262 lines
8.0 KiB
C++
#include "classes.h"
|
|
|
|
// 00407a60
|
|
LayerState::~LayerState()
|
|
{
|
|
char isLastRef;
|
|
int in_ECX;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
|
|
puStack_c = &LAB_00af09f0;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
local_8 = 0;
|
|
if (*GHIDRA_CAST<int **>((in_ECX + 0x9c)) != GHIDRA_CAST<int *>(0x0)) {
|
|
isLastRef = (**(code **)(**GHIDRA_CAST<int **>((in_ECX + 0x9c)) + 0xc))
|
|
(__security_cookie ^ GHIDRA_INT(register0x00000010) - 4U);
|
|
if ((isLastRef != '\0') && (g_imageReleaseFn != (void *)0x0)) {
|
|
(*g_imageReleaseFn)(in_ECX + 0x98);
|
|
}
|
|
}
|
|
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>((in_ECX + 8)))))->std::string::_Tidy_deallocate();
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 004081d0
|
|
LayerState::LayerState()
|
|
{
|
|
uint graphicsFlag4;
|
|
int blendFactor;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
|
|
puStack_c = &LAB_00af0a8e;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
(this->_spriteSheetPath)._buf[0] = '\0';
|
|
(this->_spriteSheetPath)._buf[1] = '\0';
|
|
(this->_spriteSheetPath)._buf[2] = '\0';
|
|
(this->_spriteSheetPath)._buf[3] = '\0';
|
|
(this->_spriteSheetPath)._size = 0;
|
|
(this->_spriteSheetPath)._capacity = 0xf;
|
|
(this->_spriteSheetPath)._buf[0] = '\0';
|
|
(this->_size).y = 0.0;
|
|
(this->_size).x = 0.0;
|
|
(this->_pos).y = 0.0;
|
|
(this->_pos).x = 0.0;
|
|
(this->_color)._tint[0] = 1.0;
|
|
(this->_color)._tint[1] = 1.0;
|
|
(this->_color)._tint[2] = 1.0;
|
|
(this->_color)._tint[3] = 1.0;
|
|
(this->_color)._colorize[0] = 0.0;
|
|
(this->_color)._colorize[1] = 0.0;
|
|
(this->_color)._colorize[2] = 0.0;
|
|
(this->_color)._colorize[3] = 0.0;
|
|
(this->_color)._offset[0] = 0.0;
|
|
(this->_color)._offset[1] = 0.0;
|
|
(this->_color)._offset[2] = 0.0;
|
|
graphicsFlag4 = g_graphicsManager_flags & 4;
|
|
this->_blendMode[0] = 0;
|
|
blendFactor = 1;
|
|
this->_blendMode[2] = 7;
|
|
this->_blendMode[3] = 1;
|
|
if (graphicsFlag4 == 0) {
|
|
blendFactor = 6;
|
|
}
|
|
this->_blendMode[1] = blendFactor;
|
|
this->_blendMode[4] = 7;
|
|
(this->_cropOffset).y = 0.0;
|
|
(this->_cropOffset).x = 0.0;
|
|
this->_spriteSheet = 0;
|
|
this[1]._layerData = (void *)0x0;
|
|
local_8 = 1;
|
|
Init(this,0);
|
|
ExceptionList = local_10;
|
|
return this;
|
|
}
|
|
|
|
// 00408310
|
|
void LayerState::Init(void *param_2)
|
|
{
|
|
void **text;
|
|
int blendMode1;
|
|
void *allocBlock;
|
|
uint uVar1;
|
|
bool isNoData;
|
|
void *layerPath [4];
|
|
undefined4 layerPathSize;
|
|
uint layerPathCapacity;
|
|
void *emptyPath [4];
|
|
undefined4 emptyPathSize;
|
|
uint emptyPathCapacity;
|
|
uint local_18;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
void *local_8;
|
|
void **textSize;
|
|
|
|
local_8 = (void *)0xffffffff;
|
|
puStack_c = &LAB_00af0ae7;
|
|
local_10 = ExceptionList;
|
|
local_18 = __security_cookie ^ GHIDRA_UINT((emptyPath + 0xb));
|
|
ExceptionList = &local_10;
|
|
this->_layerData = param_2;
|
|
isNoData = param_2 == (void *)0x0;
|
|
if (isNoData) {
|
|
emptyPathCapacity = 0xf;
|
|
emptyPathSize = 0;
|
|
emptyPath[0] = (void *)0x0;
|
|
text = emptyPath;
|
|
local_8 = (void *)0x1;
|
|
}
|
|
else {
|
|
text = (GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(layerPath))))->std::string::string((void *)(GHIDRA_INT(param_2) + 0x20));
|
|
local_8 = (void *)0x0;
|
|
}
|
|
local_8 = (void *)GHIDRA_UINT(isNoData);
|
|
if (&this->_spriteSheetPath != GHIDRA_CAST<std_string *>(text)) {
|
|
textSize = text + 4;
|
|
if ((void *)0xf < text[5]) {
|
|
text = *text;
|
|
}
|
|
(GHIDRA_CAST<std::string *>(((this->_spriteSheetPath)._buf)))->std::string::assign(GHIDRA_CAST<byte *>(text),GHIDRA_UINT(*textSize));
|
|
}
|
|
local_8 = (void *)0x0;
|
|
if ((isNoData) && (0xf < emptyPathCapacity)) {
|
|
uVar1 = emptyPathCapacity + 1;
|
|
allocBlock = emptyPath[0];
|
|
if (0xfff < uVar1) {
|
|
allocBlock = *(void **)(GHIDRA_INT(emptyPath[0]) + -4);
|
|
uVar1 = emptyPathCapacity + 0x24;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(emptyPath[0]) + (-4 - GHIDRA_INT(allocBlock))))) goto LAB_00408423;
|
|
}
|
|
operator_delete(allocBlock,uVar1);
|
|
}
|
|
local_8 = (void *)0xffffffff;
|
|
if (!isNoData) {
|
|
if (0xf < layerPathCapacity) {
|
|
uVar1 = layerPathCapacity + 1;
|
|
allocBlock = layerPath[0];
|
|
if (0xfff < uVar1) {
|
|
allocBlock = *(void **)(GHIDRA_INT(layerPath[0]) + -4);
|
|
uVar1 = layerPathCapacity + 0x24;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(layerPath[0]) + (-4 - GHIDRA_INT(allocBlock))))) {
|
|
LAB_00408423:
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(allocBlock,uVar1);
|
|
}
|
|
layerPathSize = 0;
|
|
layerPathCapacity = 0xf;
|
|
layerPath[0] = (void *)(GHIDRA_UINT(layerPath[0]) & 0xffffff00);
|
|
}
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((&this->_spriteSheet)))->KAGE::SmartPointer::reset((void *)0x0);
|
|
this->_spriteSheetLoaded = 0;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x31))) = 0;
|
|
this->_flipX = 0;
|
|
this->_flipY = 0;
|
|
(this->_size).x = g_vectorOne.x;
|
|
(this->_size).y = g_vectorOne.y;
|
|
this->_rotation = 0.0;
|
|
(this->_pos).x = g_vectorZero.x;
|
|
(this->_pos).y = g_vectorZero.y;
|
|
(this->_color)._tint[0] = 1.0;
|
|
(this->_color)._tint[1] = 1.0;
|
|
(this->_color)._tint[2] = 1.0;
|
|
(this->_color)._tint[3] = 1.0;
|
|
(this->_color)._colorize[0] = 0.0;
|
|
(this->_color)._colorize[1] = 0.0;
|
|
(this->_color)._colorize[2] = 0.0;
|
|
(this->_color)._colorize[3] = 0.0;
|
|
(this->_color)._offset[0] = 0.0;
|
|
(this->_color)._offset[1] = 0.0;
|
|
(this->_color)._offset[2] = 0.0;
|
|
this->_visible = 1;
|
|
uVar1 = g_graphicsManager_flags & 4;
|
|
this->_blendMode[0] = 0;
|
|
this->_blendMode[2] = 7;
|
|
blendMode1 = 1;
|
|
if (uVar1 == 0) {
|
|
blendMode1 = 6;
|
|
}
|
|
this->_blendMode[3] = 1;
|
|
this->_blendMode[1] = blendMode1;
|
|
this->_blendMode[4] = 7;
|
|
this->_minFilterMode = DAT_00c3799c;
|
|
this->_magFilterMode = DAT_00c379a0;
|
|
this->_wrapSMode = DAT_00c379a4;
|
|
this->_wrapTMode = DAT_00c379a8;
|
|
this->_bitflags = 0;
|
|
(this->_cropOffset).x = g_vectorZero.x;
|
|
(this->_cropOffset).y = g_vectorZero.y;
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 00408590
|
|
void * LayerState::GetTexture(void *outTexture)
|
|
{
|
|
int iVar1;
|
|
int iVar2;
|
|
int *texture;
|
|
|
|
texture = GHIDRA_CAST<int *>(this->_spriteSheet);
|
|
if (texture != GHIDRA_CAST<int *>(0x0)) {
|
|
iVar1 = this->_minFilterMode;
|
|
if (((texture[0xc] != iVar1) || (texture[0xd] != this->_magFilterMode)) &&
|
|
((iVar2 = this->_magFilterMode, iVar1 != texture[0xc] || (iVar2 != texture[0xd])))) {
|
|
(**(code **)(*texture + 0x44))(iVar1,iVar2);
|
|
texture[0xc] = iVar1;
|
|
texture[0xd] = iVar2;
|
|
texture = GHIDRA_CAST<int *>(this->_spriteSheet);
|
|
}
|
|
iVar1 = this->_wrapSMode;
|
|
if (((texture[0xe] != iVar1) || (texture[0xf] != this->_wrapTMode)) &&
|
|
((iVar2 = this->_wrapTMode, iVar1 != texture[0xe] || (iVar2 != texture[0xf])))) {
|
|
(**(code **)(*texture + 0x48))(iVar1,iVar2);
|
|
texture[0xe] = iVar1;
|
|
texture[0xf] = iVar2;
|
|
}
|
|
}
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((outTexture)))->KAGE::SmartPointer::operator_assign(&this->_spriteSheet);
|
|
return outTexture;
|
|
}
|
|
|
|
// 00408640
|
|
void LayerState::SetTexture(void *texture, void *textureRefCount)
|
|
{
|
|
char isLastRef;
|
|
uint uVar1;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
|
|
puStack_c = &LAB_00af0b1d;
|
|
local_10 = ExceptionList;
|
|
uVar1 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
|
|
ExceptionList = &local_10;
|
|
local_8 = 0;
|
|
if (texture != (void *)0x0) {
|
|
this->_minFilterMode = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(texture) + 0x30));
|
|
this->_magFilterMode = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(texture) + 0x34));
|
|
this->_wrapSMode = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(texture) + 0x38));
|
|
this->_wrapTMode = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(texture) + 0x3c));
|
|
}
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((&this->_spriteSheet)))->KAGE::SmartPointer::operator_assign(&texture);
|
|
local_8 = 1;
|
|
if (textureRefCount != (void *)0x0) {
|
|
isLastRef = (**(code **)(*GHIDRA_CAST<int *>(textureRefCount) + 0xc))(uVar1);
|
|
if ((isLastRef != '\0') && (g_imageReleaseFn != (void *)0x0)) {
|
|
(*g_imageReleaseFn)(&texture);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|