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:
shweetandClaude Opus 5.5 committed 2026-11-19 21:10:23 -05:00
1 parent 2ff2d5d87f
commit 3ce74c6e2d
331 files changed
+485 -7835

No files matched your search

@@ -0,0 +1,147 @@
#include "classes.h"
// 00a22940
void KAGE::Input::InputDeviceGamepad::vfunc_30()
{
ushort uVar1;
uint local_EAX_6;
int boundButton;
uint local_ECX_26;
uint *bindingCursor;
int *axisBindingCursor;
uint maskHigh;
int *piVar2;
float axisValue;
uint axisButton;
uint axisHalf;
int *savedDevice;
uint isPassUnbound;
byte isNegativeHalf;
float axisRest;
local_EAX_6 = 0;
local_ECX_26 = DAT_00c79bf0 - GHIDRA_INT(g_gamepadDevices) >> 2;
if (local_ECX_26 != 0) {
do {
piVar2 = g_gamepadDevices[local_EAX_6];
if (*piVar2 == *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x370))) {
if (piVar2 == GHIDRA_CAST<int *>(0x0)) {
return 0;
}
local_EAX_6 = 0;
uVar1 = *GHIDRA_CAST<ushort *>((GHIDRA_CAST<char *>(this) + 8)) & 0x20;
isPassUnbound = GHIDRA_UINT(uVar1);
if (piVar2[5] != 0) goto LAB_00a229a0;
goto LAB_00a22a04;
}
local_EAX_6 = local_EAX_6 + 1;
} while (local_EAX_6 < local_ECX_26);
}
return 0;
LAB_00a229a0:
do {
if (0x1f < local_EAX_6) break;
local_ECX_26 = 0;
bindingCursor = GHIDRA_CAST<uint *>((GHIDRA_INT(this) + 0x38c));
do {
if (*bindingCursor == local_EAX_6) {
boundButton = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + local_ECX_26 * 8 + 0x388));
goto LAB_00a229c9;
}
local_ECX_26 = local_ECX_26 + 1;
bindingCursor = bindingCursor + 2;
} while (local_ECX_26 < 0x1d);
boundButton = -1;
LAB_00a229c9:
if (((uVar1 != 0) || (boundButton != -1)) && (*GHIDRA_CAST<char *>((local_EAX_6 + piVar2[7])) != '\0')) {
local_ECX_26 = 1 << (local_EAX_6 & 0x1f);
maskHigh = 0;
if (0x1f < local_EAX_6) {
maskHigh = local_ECX_26;
}
local_ECX_26 = local_ECX_26 ^ maskHigh;
if (0x3f < local_EAX_6) {
maskHigh = local_ECX_26;
}
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x20)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x20)) | local_ECX_26;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x24)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x24)) | maskHigh;
}
local_EAX_6 = local_EAX_6 + 1;
} while (local_EAX_6 < GHIDRA_UINT(piVar2[5]));
LAB_00a22a04:
axisHalf = 0;
savedDevice = piVar2;
if ((piVar2[4] & 0x7fffffffU) != 0) {
do {
if (0x1f < axisHalf) break;
if ((*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(this) + 8)) & 0x40) == 0) {
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + axisHalf * 4 + 0x470)) =
*GHIDRA_CAST<undefined4 *>((piVar2[6] + (axisHalf >> 1) * 4));
}
else {
axisRest = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + axisHalf * 4 + 0x470));
isNegativeHalf = ~(byte)axisHalf & 1;
axisValue = *GHIDRA_CAST<float *>((piVar2[6] + (axisHalf >> 1) * 4)) - axisRest;
if (axisRest < 0.0) {
axisValue = axisValue / (1.0 - axisRest);
}
axisButton = 0xffffffff;
if ((short)isPassUnbound == 0) {
local_EAX_6 = 0;
axisBindingCursor = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0x38c));
do {
piVar2 = savedDevice;
if (*axisBindingCursor == axisHalf + 0xabab) {
axisButton = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + local_EAX_6 * 8 + 0x388));
goto LAB_00a22ac5;
}
local_EAX_6 = local_EAX_6 + 1;
axisBindingCursor = axisBindingCursor + 2;
} while (local_EAX_6 < 0x1d);
axisButton = 0xffffffff;
}
LAB_00a22ac5:
if (isNegativeHalf == 0) {
if (*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0xd4)) < axisValue) goto LAB_00a22ae2;
LAB_00a22b4a:
if (axisValue <= 0.0) {
axisValue = 0.0;
}
}
else {
if (axisValue < -*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0xd4))) {
LAB_00a22ae2:
if (((short)isPassUnbound != 0) || (axisButton != 0xffffffff)) {
this->FUN_00a1f910(&axisButton);
if (axisButton == 0xffffffff) {
axisButton = axisHalf;
}
local_EAX_6 = 1 << (axisButton & 0x1f);
local_ECX_26 = 0;
if (0x1f < axisButton) {
local_ECX_26 = local_EAX_6;
}
local_EAX_6 = local_EAX_6 ^ local_ECX_26;
if (0x3f < axisButton) {
local_ECX_26 = local_EAX_6;
}
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x30)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x30)) | local_EAX_6;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x34)) = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x34)) | local_ECX_26;
}
if (isNegativeHalf == 0) goto LAB_00a22b4a;
}
if (0.0 <= axisValue) {
axisValue = 0.0;
}
else {
axisValue = -axisValue;
}
}
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + axisHalf * 4 + 0x40)) = axisValue;
}
axisHalf = axisHalf + 1;
} while (axisHalf < GHIDRA_UINT((piVar2[4] * 2)));
}
*GHIDRA_CAST<ushort *>((GHIDRA_CAST<char *>(this) + 8)) = *GHIDRA_CAST<ushort *>((GHIDRA_CAST<char *>(this) + 8)) | 0x40;
return 1;
}