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

+190
View File
@@ -0,0 +1,190 @@
#include "classes.h"
// 005ccd80
void Entity_Text::Update()
{
int iVar1;
uint timer;
undefined4 uVar2;
float fVar3;
float velY;
Game *game;
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x2c));
if (iVar1 == 0) {
fVar3 = 1.0 - (float)*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x410)) / (float)*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x414));
fVar3 = fVar3 * fVar3;
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x524)) = fVar3;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x34c)) = 0;
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x350)) = (1.0 - fVar3) * -50.0;
}
else if (iVar1 == 1) {
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x410));
if (iVar1 == 0) {
sprintf_s(GHIDRA_CAST<byte *>((GHIDRA_INT(this) + 0x418)),0x100,&DAT_00b62fe0);
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x410));
}
game = g_game;
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x414)) - iVar1;
if (10 < iVar1) {
iVar1 = 10;
}
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x524)) = (float)iVar1 / 10.0;
fVar3 = sin((float)(game->_frameCount - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x328))) * 0.2);
if ((*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(this) + 0x20)) & 1) == 0) {
fVar3 = fVar3 * 15.0;
}
else {
fVar3 = fVar3 * -15.0;
}
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x34c)) = fVar3;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x350)) = 0;
}
else if (iVar1 == 2) {
timer = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x410));
if (timer == 0) {
sprintf_s(GHIDRA_CAST<byte *>((GHIDRA_INT(this) + 0x418)),0x100,s__d);
timer = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x410));
}
uVar2 = 0x3f800000;
if ((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x414)) + -0xf <= GHIDRA_INT(timer)) && ((timer & 1) != 0)) {
uVar2 = 0;
}
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x518)) = 0x3f800000;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x51c)) = 0x3f800000;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x520)) = 0x3f800000;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x524)) = uVar2;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x528)) = 0;
}
fVar3 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x36c)) * *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x360));
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x410)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x410)) + 1;
velY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x36c)) * *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x364));
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x36c)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x368));
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x360)) = fVar3;
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x364)) = velY;
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x33c)) = fVar3 + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x33c));
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x340)) = velY + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x340));
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x414)) < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x410))) {
this->Remove();
}
return;
}
// 005ccfc0
void Entity_Text::Render(Vector *offset)
{
void *font = this;
byte *str;
Vector pos;
Vector scale;
byte isPaused;
uint flickerPhase;
Font *font;
float fVar1;
double dVar2;
FontSettings fontSettings;
undefined4 local_3c;
undefined4 local_38;
undefined4 local_34;
undefined4 local_30;
undefined4 local_2c;
undefined4 local_28;
float screenY;
float worldY;
int textWidth;
float pixelScale;
float screenX;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
local_8 = 0xffffffff;
puStack_c = &LAB_00af5fe5;
local_10 = ExceptionList;
ExceptionList = &local_10;
if (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(font) + 0x172)) != '\0') {
str = GHIDRA_CAST<byte *>((GHIDRA_INT(font) + 0x418));
font = &g_manager->_font6_PFTempestaSevenCondensed;
textWidth = (GHIDRA_CAST<Font *>((font)))->Font::get_string_width_n(str,-1);
worldY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(font) + 0x340)) + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(font) + 0x350));
screenY = (g_screenHeight - 182.0) * 0.5;
pixelScale = g_displayPixelRatio * g_screenPointScale;
screenX = (((*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(font) + 0x34c)) + *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(font) + 0x33c))) - 60.0) * 0.65 +
(g_screenWidth - 338.0) * 0.5) * pixelScale + 0.5;
dVar2 = floor((double)screenX);
screenX = (float)dVar2 / pixelScale;
screenY = ((worldY - 140.0) * 0.65 + screenY) * pixelScale + 0.5;
dVar2 = floor((double)screenY);
screenY = (float)dVar2;
screenX = screenX + offset->x;
fVar1 = offset->y;
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(font) + 0x1a4)) = screenX;
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(font) + 0x1a8)) = screenY / pixelScale + fVar1;
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(font) + 0x2c)) == 2) {
isPaused = (GHIDRA_CAST<Game *>((g_game)))->Game::IsPaused();
if (isPaused == 0) {
flickerPhase = g_manager->_framecount + 1U & 0x80000001;
if (GHIDRA_INT(flickerPhase) < 0) {
flickerPhase = (flickerPhase - 1 | 0xfffffffe) + 1;
}
}
else {
flickerPhase = 0;
}
fontSettings = (FontSettings)0x0;
local_3c = 0xffff;
local_38 = 0;
local_34 = 0x3f800000;
local_30 = 0xffffffff;
local_2c = 0;
local_28 = 0;
fVar1 = ((float)GHIDRA_INT((flickerPhase + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(font) + 0x410)) * 2)) * 0.5 - 0.0) * 0.25;
if (fVar1 <= 0.0) {
fVar1 = 0.0;
}
if (1.0 <= fVar1) {
fVar1 = 1.0;
}
fVar1 = 4.0 - fVar1 * 2.5;
local_8 = 0;
pos.y = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(font) + 0x1a8)) - fVar1 * 4.0;
pos.x = screenX - (float)textWidth * 0.5 * fVar1;
scale.y = fVar1;
scale.x = fVar1;
(GHIDRA_CAST<Font *>((font)))->Font::DrawString(str,pos,scale,GHIDRA_CAST<KColor *>((GHIDRA_INT(font) + 0x518)),&fontSettings);
ExceptionList = local_10;
return;
}
fontSettings = (FontSettings)0x0;
local_3c = 0xffff;
local_38 = 0;
local_34 = 0x3f800000;
local_30 = 0xffffffff;
local_2c = 0;
local_28 = 0;
local_8 = 1;
(GHIDRA_CAST<Font *>((font)))->Font::DrawString(str,GHIDRA_CAST<KColor *>((GHIDRA_INT(font) + 0x518)),&fontSettings,
screenX - (float)textWidth * 0.5,*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(font) + 0x1a8)));
}
ExceptionList = local_10;
return;
}
// 005cd2e0
void Entity_Text::Interpolate()
{
float wobble;
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x2c)) == 1) {
wobble = sin(((float)(g_game->_frameCount - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x328))) + 0.5) * 0.2);
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x350)) = 0;
if ((*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(this) + 0x20)) & 1) == 0) {
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x34c)) = wobble * 15.0;
this->Entity::Interpolate();
return;
}
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x34c)) = wobble * -15.0;
}
this->Entity::Interpolate();
return;
}