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>
196 lines
7.5 KiB
C++
196 lines
7.5 KiB
C++
#include "classes.h"
|
|
|
|
// 00a66e30
|
|
void RenderBatch::set_state(int param_1)
|
|
{
|
|
void *pvVar1;
|
|
char cVar2;
|
|
byte batchFlags;
|
|
ReferenceCountBase *newRefCount;
|
|
undefined4 *other;
|
|
int in_ECX;
|
|
undefined4 foundImage;
|
|
int *foundImageRefCount;
|
|
undefined4 emptyImage;
|
|
ReferenceCountBase *emptyImageRefCount;
|
|
ReferenceCountBase *local_2c;
|
|
size_t local_28;
|
|
void *local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
uint local_14;
|
|
int *shaderUniforms;
|
|
int *uniforms;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00b13216;
|
|
local_1c = ExceptionList;
|
|
ExceptionList = &local_1c;
|
|
local_24 = (void *)0x0;
|
|
if (param_1 == 0) {
|
|
emptyImage = 0;
|
|
emptyImageRefCount = GHIDRA_CAST<ReferenceCountBase *>(0x0);
|
|
newRefCount = operator_new(0x18);
|
|
local_14 = 1;
|
|
local_2c = newRefCount;
|
|
if (newRefCount == GHIDRA_CAST<ReferenceCountBase *>(0x0)) {
|
|
newRefCount = GHIDRA_CAST<ReferenceCountBase *>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<ReferenceCountBase *>((newRefCount)))->ReferenceCountBase::ReferenceCountBase();
|
|
*GHIDRA_CAST<undefined ***>(newRefCount) = ReferenceCount<KAGE::Graphics::ImageBase>::vftable;
|
|
*GHIDRA_CAST<undefined4 *>((newRefCount + 0x14)) = 0;
|
|
}
|
|
local_14 = local_14 & 0xffffff00;
|
|
if (((emptyImageRefCount != GHIDRA_CAST<ReferenceCountBase *>(0x0)) &&
|
|
(cVar2 = emptyImageRefCount->vfunc_3(), cVar2 != '\0')) &&
|
|
(g_imageReleaseFn != (void *)0x0)) {
|
|
(*g_imageReleaseFn)(&emptyImage);
|
|
}
|
|
emptyImage = 0;
|
|
local_14 = 2;
|
|
other = &emptyImage;
|
|
local_24 = (void *)0x2;
|
|
emptyImageRefCount = newRefCount;
|
|
}
|
|
else {
|
|
local_28 = *GHIDRA_CAST<size_t *>((param_1 + 0x48));
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
FUN_00a12280(&local_24,&local_28);
|
|
if (local_24 != DAT_00c37988) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_24) + 0x14)) + 0x48)) != *GHIDRA_CAST<int *>((param_1 + 0x48))) break;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_24) + 0x14)) == param_1) {
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((&foundImage)))->KAGE::SmartPointer::operator_assign((void *)(GHIDRA_INT(local_24) + 0x14));
|
|
goto LAB_00a66ecc;
|
|
}
|
|
std::
|
|
_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tree_simple_types<unsigned_int>_>,std::_Iterator_base0>
|
|
::operator++((_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tree_simple_types<unsigned_int>_>,std::_Iterator_base0>
|
|
*)&local_24);
|
|
} while (local_24 != DAT_00c37988);
|
|
}
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((&foundImage)))->KAGE::SmartPointer::SmartPointer((void *)0x0);
|
|
LAB_00a66ecc:
|
|
local_14 = 0;
|
|
other = &foundImage;
|
|
local_24 = (void *)0x5;
|
|
}
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>(((void *)(in_ECX + 8))))->KAGE::SmartPointer::operator_assign(other);
|
|
if ((GHIDRA_UINT(local_24) & 2) != 0) {
|
|
local_24 = (void *)(GHIDRA_UINT(local_24) & 0xfffffffd);
|
|
local_14 = 3;
|
|
if (((emptyImageRefCount != GHIDRA_CAST<ReferenceCountBase *>(0x0)) &&
|
|
(cVar2 = emptyImageRefCount->vfunc_3(), cVar2 != '\0')) &&
|
|
(g_imageReleaseFn != (void *)0x0)) {
|
|
(*g_imageReleaseFn)(&emptyImage);
|
|
}
|
|
}
|
|
if ((((GHIDRA_UINT(local_24) & 1) != 0) && (local_14 = 4, foundImageRefCount != GHIDRA_CAST<int *>(0x0))) &&
|
|
((cVar2 = (**(code **)(*foundImageRefCount + 0xc))(), cVar2 != '\0' &&
|
|
(g_imageReleaseFn != (void *)0x0)))) {
|
|
(*g_imageReleaseFn)(&foundImage);
|
|
}
|
|
local_14 = 0xffffffff;
|
|
uniforms = GHIDRA_CAST<int *>((in_ECX + 0x28));
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x10)) = g_graphicsManager_blendMode[0];
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x14)) = g_graphicsManager_blendMode[1];
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x18)) = g_graphicsManager_blendMode[2];
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x1c)) = g_graphicsManager_blendMode[3];
|
|
*GHIDRA_CAST<int *>((in_ECX + 0x20)) = g_graphicsManager_blendMode[4];
|
|
pvVar1 = g_currentShader;
|
|
*(void **)(in_ECX + 0x24) = g_currentShader;
|
|
shaderUniforms = GHIDRA_CAST<int *>((GHIDRA_INT(pvVar1) + 0x40));
|
|
if (uniforms != shaderUniforms) {
|
|
local_2c = GHIDRA_CAST<ReferenceCountBase *>(*shaderUniforms);
|
|
local_28 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x44)) - GHIDRA_INT(local_2c);
|
|
local_24 = (void *)*uniforms;
|
|
if (GHIDRA_UINT((*GHIDRA_CAST<int *>((in_ECX + 0x30)) - GHIDRA_INT(local_24) >> 2)) < GHIDRA_UINT((GHIDRA_INT(local_28) >> 2))) {
|
|
std::vector<int>::reserve_clear(GHIDRA_INT(local_28) >> 2);
|
|
local_24 = (void *)*uniforms;
|
|
}
|
|
memmove(local_24,local_2c,local_28);
|
|
*GHIDRA_CAST<size_t *>((in_ECX + 0x2c)) = GHIDRA_INT(local_24) + local_28;
|
|
}
|
|
if ((((*GHIDRA_CAST<int *>((in_ECX + 0x10)) == 0) && (*GHIDRA_CAST<int *>((in_ECX + 0x14)) == 1)) &&
|
|
(*GHIDRA_CAST<int *>((in_ECX + 0x18)) == 0)) &&
|
|
((*GHIDRA_CAST<int *>((in_ECX + 0x1c)) == 1 && (*GHIDRA_CAST<int *>((in_ECX + 0x20)) == 0)))) {
|
|
batchFlags = *GHIDRA_CAST<byte *>((in_ECX + 4)) | 1;
|
|
}
|
|
else {
|
|
batchFlags = *GHIDRA_CAST<byte *>((in_ECX + 4)) & 0xfe;
|
|
}
|
|
*GHIDRA_CAST<byte *>((in_ECX + 4)) = batchFlags;
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 00a670c0
|
|
byte RenderBatch::is_state_equal(void *texture)
|
|
{
|
|
void *pvVar1;
|
|
bool bVar2;
|
|
uint uVar3;
|
|
int *batchUniform;
|
|
int *shaderUniform;
|
|
int uniformCount;
|
|
uint bytesLeft;
|
|
|
|
if (*(void **)(GHIDRA_CAST<char *>(this) + 8) != texture) {
|
|
return 0;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x10)) != g_graphicsManager_blendMode[0]) {
|
|
return 0;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x14)) != g_graphicsManager_blendMode[1]) {
|
|
return 0;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x18)) != g_graphicsManager_blendMode[2]) {
|
|
return 0;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x1c)) != g_graphicsManager_blendMode[3]) {
|
|
return 0;
|
|
}
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20)) != g_graphicsManager_blendMode[4]) {
|
|
return 0;
|
|
}
|
|
pvVar1 = *(void **)(GHIDRA_CAST<char *>(this) + 0x24);
|
|
if (pvVar1 != g_currentShader) {
|
|
return 0;
|
|
}
|
|
shaderUniform = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(pvVar1) + 0x40));
|
|
batchUniform = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x28));
|
|
uniformCount = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x2c)) - GHIDRA_INT(batchUniform) >> 2;
|
|
if (uniformCount != *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x44)) - GHIDRA_INT(shaderUniform) >> 2) {
|
|
return 0;
|
|
}
|
|
bytesLeft = uniformCount * 4;
|
|
while (uVar3 = bytesLeft - 4, 3 < bytesLeft) {
|
|
if (*batchUniform != *shaderUniform) goto LAB_00a67166;
|
|
batchUniform = batchUniform + 1;
|
|
shaderUniform = shaderUniform + 1;
|
|
bytesLeft = uVar3;
|
|
}
|
|
if (uVar3 != 0xfffffffc) {
|
|
LAB_00a67166:
|
|
if (((char)*batchUniform != (char)*shaderUniform) ||
|
|
((uVar3 != 0xfffffffd &&
|
|
((*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(batchUniform) + 1)) != *GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(shaderUniform) + 1)) ||
|
|
((uVar3 != 0xfffffffe &&
|
|
((*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(batchUniform) + 2)) != *GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(shaderUniform) + 2)) ||
|
|
((uVar3 != 0xffffffff &&
|
|
(*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(batchUniform) + 3)) != *GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(shaderUniform) + 3)))))))))))))) {
|
|
bVar2 = false;
|
|
goto LAB_00a67199;
|
|
}
|
|
}
|
|
bVar2 = true;
|
|
LAB_00a67199:
|
|
if (bVar2) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|