Reconstruction layout: generated-src/ (generated) and src/ (curated), CMake, the first takeover: RNG
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>
This commit is contained in:
1 parent
2ff2d5d87f
commit
3ce74c6e2d
331 files changed
+485
-7835
No files matched your search
@@ -0,0 +1,159 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 00a149a0
|
||||
void KAGE::Graphics::ShaderBase::free_uniforms()
|
||||
{
|
||||
int iVar1;
|
||||
qword *allocatedBytes;
|
||||
uint uVar2;
|
||||
uint uVar3;
|
||||
int iVar4;
|
||||
int *bufferSlot;
|
||||
code *freeFn;
|
||||
int iVar5;
|
||||
int uniformOffset;
|
||||
uint uniformIndex;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 uStack_8;
|
||||
uint blockSize;
|
||||
qword previousAllocatedBytes;
|
||||
|
||||
uStack_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b10d90;
|
||||
local_10 = ExceptionList;
|
||||
ExceptionList = &local_10;
|
||||
uVar2 = 0;
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x10)) != 0) {
|
||||
do {
|
||||
iVar5 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc)) + uVar2 * 8));
|
||||
if (iVar5 != 0) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocatedBytes = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
uVar3 = *GHIDRA_CAST<uint *>((iVar5 + -4));
|
||||
previousAllocatedBytes = *allocatedBytes;
|
||||
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar3;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(previousAllocatedBytes) < uVar3));
|
||||
free((void *)(iVar5 + -4));
|
||||
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc)) + uVar2 * 8)) = 0;
|
||||
}
|
||||
uVar2 = uVar2 + 1;
|
||||
} while (uVar2 < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x10)));
|
||||
}
|
||||
iVar5 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x38));
|
||||
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x34));
|
||||
uniformIndex = 0;
|
||||
iVar1 = iVar5 - iVar4 >> 0x1f;
|
||||
if ((iVar5 - iVar4) / 0x18 + iVar1 != iVar1) {
|
||||
uniformOffset = 0;
|
||||
do {
|
||||
iVar5 = uniformOffset + iVar4;
|
||||
iVar1 = *GHIDRA_CAST<int *>((iVar5 + 0xc));
|
||||
uVar3 = 0;
|
||||
uVar2 = *GHIDRA_CAST<int *>((uniformOffset + 0x10 + iVar4)) - iVar1 >> 2;
|
||||
if (uVar2 != 0) {
|
||||
do {
|
||||
if ((7 < *GHIDRA_CAST<int *>((iVar5 + 8))) &&
|
||||
(iVar4 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((iVar5 + 0xc)) + uVar3 * 4)), iVar4 != 0)) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocatedBytes = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
blockSize = *GHIDRA_CAST<uint *>((iVar4 + -4));
|
||||
previousAllocatedBytes = *allocatedBytes;
|
||||
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - blockSize;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) -
|
||||
GHIDRA_UINT((GHIDRA_UINT(previousAllocatedBytes) < blockSize));
|
||||
free((void *)(iVar4 + -4));
|
||||
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((iVar5 + 0xc)) + uVar3 * 4)) = 0;
|
||||
}
|
||||
uVar3 = uVar3 + 1;
|
||||
} while (uVar3 < uVar2);
|
||||
iVar1 = *GHIDRA_CAST<int *>((iVar5 + 0xc));
|
||||
}
|
||||
uniformIndex = uniformIndex + 1;
|
||||
uniformOffset = uniformOffset + 0x18;
|
||||
*GHIDRA_CAST<int *>((iVar5 + 0x10)) = iVar1;
|
||||
iVar5 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x38));
|
||||
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x34));
|
||||
} while (uniformIndex < GHIDRA_UINT(((iVar5 - iVar4) / 0x18)));
|
||||
}
|
||||
if (iVar4 != iVar5) {
|
||||
do {
|
||||
FID_conflict__Tidy((void *)(iVar4 + 0xc));
|
||||
iVar4 = iVar4 + 0x18;
|
||||
} while (iVar4 != iVar5);
|
||||
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x34));
|
||||
}
|
||||
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x38)) = iVar4;
|
||||
iVar5 = 8;
|
||||
bufferSlot = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0x14));
|
||||
do {
|
||||
iVar4 = *bufferSlot;
|
||||
if (iVar4 != 0) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocatedBytes = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
uVar2 = *GHIDRA_CAST<uint *>((iVar4 + -4));
|
||||
previousAllocatedBytes = *allocatedBytes;
|
||||
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar2;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(previousAllocatedBytes) < uVar2));
|
||||
free((void *)(iVar4 + -4));
|
||||
*bufferSlot = 0;
|
||||
}
|
||||
bufferSlot = bufferSlot + 1;
|
||||
iVar5 = iVar5 + -1;
|
||||
} while (iVar5 != 0);
|
||||
iVar5 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 8));
|
||||
if (iVar5 == 0) {
|
||||
freeFn = free_exref;
|
||||
}
|
||||
else {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocatedBytes = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
uVar2 = *GHIDRA_CAST<uint *>((iVar5 + -4));
|
||||
previousAllocatedBytes = *allocatedBytes;
|
||||
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar2;
|
||||
freeFn = free_exref;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(previousAllocatedBytes) < uVar2));
|
||||
free((void *)(iVar5 + -4));
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 8)) = 0;
|
||||
}
|
||||
iVar5 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc));
|
||||
if (iVar5 != 0) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocatedBytes = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
uVar2 = *GHIDRA_CAST<uint *>((iVar5 + -4));
|
||||
previousAllocatedBytes = *allocatedBytes;
|
||||
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar2;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(previousAllocatedBytes) < uVar2));
|
||||
(*freeFn)(iVar5 + -4);
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0;
|
||||
}
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 4)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 4)) & 0xfffffffe;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0;
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
Reference in new issue
Block a user