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,55 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 008fd3c0
|
||||
void MTRNG::Init(uint seed)
|
||||
{
|
||||
MTRNG index;
|
||||
|
||||
*this = (MTRNG)seed;
|
||||
this[0x270] = (MTRNG)0x1;
|
||||
do {
|
||||
index = this[0x270];
|
||||
this[GHIDRA_INT(index)] =
|
||||
(MTRNG)((GHIDRA_UINT(this[GHIDRA_INT(index) + -1]) >> 0x1e ^ GHIDRA_UINT(this[GHIDRA_INT(index) + -1])) * 0x6c078965 +
|
||||
GHIDRA_INT(index));
|
||||
this[0x270] = (MTRNG)(GHIDRA_INT(this[0x270]) + 1);
|
||||
} while (GHIDRA_INT(this[0x270]) < 0x270);
|
||||
return;
|
||||
}
|
||||
|
||||
// 008fd410
|
||||
uint MTRNG::Next()
|
||||
{
|
||||
MTRNG index;
|
||||
uint y;
|
||||
int kk;
|
||||
MTRNG word;
|
||||
|
||||
index = this[0x270];
|
||||
if (0x26f < GHIDRA_INT(index)) {
|
||||
if (index == (MTRNG)0x271) {
|
||||
Init(this,0x1571);
|
||||
}
|
||||
kk = 0;
|
||||
do {
|
||||
y = (GHIDRA_UINT(this[kk + 1]) ^ GHIDRA_UINT(this[kk])) & 0x7fffffff ^ GHIDRA_UINT(this[kk]);
|
||||
this[kk] = (MTRNG)(y >> 1 ^ GHIDRA_UINT((&PTR_00b67f8c)[y & 1]) ^ GHIDRA_UINT(this[kk + 0x18d]));
|
||||
kk = kk + 1;
|
||||
} while (kk < 0xe3);
|
||||
do {
|
||||
y = (GHIDRA_UINT(this[kk + 1]) ^ GHIDRA_UINT(this[kk])) & 0x7fffffff ^ GHIDRA_UINT(this[kk]);
|
||||
this[kk] = (MTRNG)(y >> 1 ^ GHIDRA_UINT((&PTR_00b67f8c)[y & 1]) ^ GHIDRA_UINT(this[kk + -0xe3]));
|
||||
kk = kk + 1;
|
||||
} while (kk < 0x26f);
|
||||
y = (GHIDRA_UINT(*this) ^ GHIDRA_UINT(this[0x26f])) & 0x7fffffff ^ GHIDRA_UINT(this[0x26f]);
|
||||
this[0x26f] = (MTRNG)(GHIDRA_UINT((&PTR_00b67f8c)[y & 1]) ^ GHIDRA_UINT(this[0x18c]) ^ y >> 1);
|
||||
index = (MTRNG)0x0;
|
||||
this[0x270] = (MTRNG)0x0;
|
||||
}
|
||||
word = this[GHIDRA_INT(index)];
|
||||
this[0x270] = (MTRNG)(GHIDRA_INT(index) + 1);
|
||||
y = GHIDRA_UINT(word) ^ GHIDRA_UINT(word) >> 0xb;
|
||||
y = y ^ (y & 0xff3a58ad) << 7;
|
||||
y = y ^ (y & 0xffffdf8c) << 0xf;
|
||||
return y >> 0x12 ^ y;
|
||||
}
|
||||
Reference in new issue
Block a user