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

+896
View File
@@ -0,0 +1,896 @@
#include "classes.h"
// 00840670
HUD_Message::~HUD_Message()
{
HUD_Message *sprite = this;
HUD_Message *glyphTree;
char isRenderTargetValid;
undefined4 extraout_ECX;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
ANM2 *sprite;
local_8 = 0xffffffff;
puStack_c = &LAB_00b02a60;
local_10 = ExceptionList;
ExceptionList = &local_10;
free_text_buffers(sprite);
sprite = GHIDRA_CAST<ANM2 *>((sprite + 8));
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Reset();
KAGE::SmartPointer<RenderTargetBase>::reset(extraout_ECX);
*GHIDRA_CAST<undefined1 *>((sprite + 2)) = 0;
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((sprite + 0x6a)))))->Font::Unload();
glyphTree = sprite + 0x7a;
FID_conflict__Erase_tree<fuzzer::fuzzer_allocator<std::_Tree_node<fuzzer::TracePC::PCTableEntry_const*,void*>_>_>
(glyphTree,(fuzzer_allocator<std::_Tree_node<unsigned_int,void*>_> *)glyphTree,
*(_Tree_node<unsigned_int,void*> **)(GHIDRA_INT(sprite[0x7a]) + 4));
operator_delete((void *)*glyphTree,0x18);
FUN_004b3950();
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((sprite + 0x57)))))->Font::Unload();
glyphTree = sprite + 0x67;
FID_conflict__Erase_tree<fuzzer::fuzzer_allocator<std::_Tree_node<fuzzer::TracePC::PCTableEntry_const*,void*>_>_>
(glyphTree,(fuzzer_allocator<std::_Tree_node<unsigned_int,void*>_> *)glyphTree,
*(_Tree_node<unsigned_int,void*> **)(GHIDRA_INT(sprite[0x67]) + 4));
operator_delete((void *)*glyphTree,0x18);
FUN_004b3950();
local_8 = 0;
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Reset();
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((sprite + 0x1c)))))->AnimationState::~AnimationState();
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((sprite + 0x14)))))->AnimationState::~AnimationState();
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>((sprite + 0xe)))))->std::string::_Tidy_deallocate();
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(sprite))))->std::string::_Tidy_deallocate();
local_8 = 1;
if (sprite[7] != (HUD_Message)0x0) {
isRenderTargetValid = (**(code **)(*GHIDRA_CAST<int *>(sprite[7]) + 0xc))();
if ((isRenderTargetValid != '\0') && (g_renderTargetReleaseFn != (void *)0x0)) {
(*g_renderTargetReleaseFn)(sprite + 6);
}
}
ExceptionList = local_10;
return;
}
// 008407a0
void HUD_Message::load_graphics()
{
char isLastRef;
void *renderTarget;
byte *extraout_EAX;
byte *extraout_EAX_00;
byte *fontPath;
HUD_Message *in_ECX;
KColor *clearColor;
char *freeBlock;
uint freeSize;
undefined1 tmpRenderTarget [4];
int *renderTargetRefCount;
char *krFontPath [4];
uint krFontPathSize;
uint krFontPathCapacity;
char *local_54 [4];
uint local_44;
uint local_40;
undefined1 local_3c [16];
uint local_2c;
uint local_28;
uint securityCookie;
undefined1 *puStack_20;
void *local_1c;
undefined1 *puStack_18;
undefined4 local_14;
Manager *manager;
puStack_20 = local_3c + 0x38;
local_14 = 0xffffffff;
puStack_18 = &LAB_00b02ab5;
local_1c = ExceptionList;
securityCookie = __security_cookie ^ GHIDRA_UINT((local_3c + 0x2c));
ExceptionList = &local_1c;
local_2c = 0;
local_28 = 0xf;
local_3c[0] = '\0';
local_3c[1] = '\0';
local_3c[2] = '\0';
local_3c[3] = '\0';
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_3c)) + 0x0))) = std::_Allocate(0x20);
local_2c = 0x15;
local_28 = 0x1f;
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_3c))) + 0x0))),"gfx/ui/ui_streak.anm2",0x16);
local_14 = 0;
(GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((in_ECX + 8)))))->ANM2::Load(GHIDRA_CAST<std_string *>(local_3c),1);
local_14 = 0xffffffff;
if (0xf < local_28) {
freeSize = local_28 + 1;
freeBlock = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_3c))) + 0x0)));
if (0xfff < freeSize) {
freeBlock = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_3c)) + 0x0))) + -4));
freeSize = local_28 + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_3c)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(freeBlock,freeSize);
}
(GHIDRA_CAST<KColor *>((GHIDRA_CAST<KColor *>((local_3c + 4)))))->KColor::SetFromARGB(0);
renderTarget = KAGE_Graphics::create_render_target
(tmpRenderTarget,400,0x80,GHIDRA_CAST<byte *>("HUD_Message Text Surface"),clearColor);
local_14 = 1;
(GHIDRA_CAST<shared_ptr *>((in_ECX + 6)))->shared_ptr::operator_assign(renderTarget);
local_14 = 2;
if (renderTargetRefCount != GHIDRA_CAST<int *>(0x0)) {
isLastRef = (**(code **)(*renderTargetRefCount + 0xc))();
if ((isLastRef != '\0') && (g_renderTargetReleaseFn != (void *)0x0)) {
(*g_renderTargetReleaseFn)(tmpRenderTarget);
}
}
manager = g_manager;
local_14 = 0xffffffff;
local_54[0] = std::_Allocate(0x20);
local_44 = 0x12;
local_40 = 0x1f;
builtin_strncpy(local_54[0],"font/MPlus_12b.fnt",0x13);
local_14 = 3;
(GHIDRA_CAST<ModManager *>((&manager->_modManager)))->ModManager::TryRedirectPath(GHIDRA_CAST<std_string *>(local_3c),GHIDRA_CAST<std_string *>(local_54));
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 4;
fontPath = extraout_EAX;
if (0xf < *GHIDRA_CAST<uint *>((extraout_EAX + 0x14))) {
fontPath = *GHIDRA_CAST<byte **>(extraout_EAX);
}
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((in_ECX + 0x57)))))->Font::Load(fontPath,0);
local_14 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))),3);
if (0xf < local_28) {
freeSize = local_28 + 1;
freeBlock = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_3c))) + 0x0)));
if (0xfff < freeSize) {
freeBlock = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_3c)) + 0x0))) + -4));
freeSize = local_28 + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_3c)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) goto LAB_008409ce;
}
operator_delete(freeBlock,freeSize);
}
local_14 = 0xffffffff;
local_2c = 0;
local_28 = 0xf;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_3c)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_3c)) + 0x0))) & 0xffffff00;
if (0xf < local_40) {
freeSize = local_40 + 1;
freeBlock = local_54[0];
if (0xfff < freeSize) {
freeBlock = *GHIDRA_CAST<char **>((local_54[0] + -4));
freeSize = local_40 + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < local_54[0] + (-4 - GHIDRA_INT(freeBlock))) {
LAB_008409ce:
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(freeBlock,freeSize);
}
manager = g_manager;
krFontPath[0] = std::_Allocate(0x20);
krFontPathSize = 0x12;
krFontPathCapacity = 0x1f;
builtin_strncpy(krFontPath[0],"font/KR_Font14.fnt",0x13);
local_14 = 5;
(GHIDRA_CAST<ModManager *>((&manager->_modManager)))->ModManager::TryRedirectPath(GHIDRA_CAST<std_string *>(local_54),GHIDRA_CAST<std_string *>(krFontPath))
;
local_14 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))),6);
fontPath = extraout_EAX_00;
if (0xf < *GHIDRA_CAST<uint *>((extraout_EAX_00 + 0x14))) {
fontPath = *GHIDRA_CAST<byte **>(extraout_EAX_00);
}
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((in_ECX + 0x6a)))))->Font::Load(fontPath,0);
if (0xf < local_40) {
freeSize = local_40 + 1;
freeBlock = local_54[0];
if (0xfff < freeSize) {
freeBlock = *GHIDRA_CAST<char **>((local_54[0] + -4));
freeSize = local_40 + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < local_54[0] + (-4 - GHIDRA_INT(freeBlock))) goto LAB_00840ab4;
}
operator_delete(freeBlock,freeSize);
}
local_44 = 0;
local_40 = 0xf;
local_54[0] = GHIDRA_CAST<char *>((GHIDRA_UINT(local_54[0]) & 0xffffff00));
if (0xf < krFontPathCapacity) {
freeSize = krFontPathCapacity + 1;
freeBlock = krFontPath[0];
if (0xfff < freeSize) {
freeBlock = *GHIDRA_CAST<char **>((krFontPath[0] + -4));
freeSize = krFontPathCapacity + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < krFontPath[0] + (-4 - GHIDRA_INT(freeBlock))) {
LAB_00840ab4:
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(freeBlock,freeSize);
}
in_ECX[3] = (HUD_Message)0x0;
in_ECX[4] = (HUD_Message)0x0;
in_ECX[5] = (HUD_Message)0x3f800000;
free_text_buffers(in_ECX);
ExceptionList = local_1c;
return;
}
// 00840b00
void HUD_Message::Show(byte *title, byte *subtitle, byte autoHide, byte isCurseDisplay)
{
byte bVar1;
short *text;
char *anim;
LayerState *curseLayer;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
local_8 = 0xffffffff;
puStack_c = &LAB_00b02ae0;
local_10 = ExceptionList;
ExceptionList = &local_10;
if (title == GHIDRA_CAST<byte *>(0x0)) {
KAGE_LogMessage(8,(byte *)
"(GHIDRA_CAST<HUD_Message *>(()))->HUD_Message::Show() recieved NULL messageText (This will have no effect) \n")
;
ExceptionList = local_10;
return;
}
text = utf8_to_utf16_alloc(title);
if (subtitle == GHIDRA_CAST<byte *>(0x0)) {
title = GHIDRA_CAST<byte *>(0x0);
}
else {
title = GHIDRA_CAST<byte *>(utf8_to_utf16_alloc(subtitle));
}
if (text == GHIDRA_CAST<short *>(0x0)) {
KAGE_LogMessage(8,(byte *)
"(GHIDRA_CAST<HUD_Message *>(()))->HUD_Message::Show() recieved NULL messageText (This will have no effect) \n")
;
}
else {
text_out(this);
set_text_line(this,text,0);
if (title != GHIDRA_CAST<byte *>(0x0)) {
set_text_line(this,GHIDRA_CAST<short *>(title),1);
}
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this[2])) + 0x2))) = isCurseDisplay;
anim = &DAT_00b1c208;
if (autoHide == 0) {
anim = "TextIn";
}
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this[2])) + 0x1))) = autoHide;
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((this + 8)))))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(anim),1);
if (bVar1 != 0) {
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((this + 0x14)))))->AnimationState::Rewind();
*GHIDRA_CAST<undefined1 *>((this + 0x19)) = 1;
}
bVar1 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this[2])) + 0x2)));
curseLayer = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((this + 8)))))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x1));
curseLayer->_visible = bVar1;
UpdateTextImage(this);
*GHIDRA_CAST<undefined1 *>((this + 2)) = 1;
}
local_8 = 0;
tracked_alloc(1,text,0);
local_8 = 1;
tracked_alloc(1,title,0);
ExceptionList = local_10;
return;
}
// 00840c60
void HUD_Message::text_out()
{
byte bVar1;
byte *animNameCursor;
uint cmpResult;
char *targetNameCursor;
bool isLess;
if (*GHIDRA_CAST<char *>((this + 2)) != '\0') {
if ((this[0x15] != (HUD_Message)0x0) && (*GHIDRA_CAST<char *>((this + 0x19)) != '\0')) {
animNameCursor = *GHIDRA_CAST<byte **>((this + 0x15));
if ((HUD_Message)animNameCursor == (HUD_Message)0x0) {
animNameCursor = &s_empty;
}
else if (0xf < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(animNameCursor) + 0x14))) {
animNameCursor = *GHIDRA_CAST<byte **>(animNameCursor);
}
targetNameCursor = "TextOut";
do {
bVar1 = *animNameCursor;
isLess = bVar1 < (byte)*targetNameCursor;
if (bVar1 != *targetNameCursor) {
LAB_00840cb0:
cmpResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_00840cb5;
}
if (bVar1 == 0) break;
bVar1 = *GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(animNameCursor) + 1));
isLess = bVar1 < (byte)targetNameCursor[1];
if (bVar1 != targetNameCursor[1]) goto LAB_00840cb0;
animNameCursor = GHIDRA_CAST<byte *>((GHIDRA_INT(animNameCursor) + 2));
targetNameCursor = targetNameCursor + 2;
} while (bVar1 != 0);
cmpResult = 0;
LAB_00840cb5:
if (cmpResult == 0) {
return;
}
}
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((this + 8)))))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("TextOut"),1);
if (bVar1 != 0) {
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((this + 0x14)))))->AnimationState::Rewind();
*GHIDRA_CAST<undefined1 *>((this + 0x19)) = 1;
}
}
return;
}
// 00840f70
void HUD_Message::free_text_buffers()
{
qword *allocCounter;
int bufferIdx;
void *local_10;
undefined1 *puStack_c;
undefined4 uStack_8;
qword allocatedBytes;
uint blockSize;
HUD_Message buffer;
uStack_8 = 0xffffffff;
puStack_c = &LAB_00af12f0;
local_10 = ExceptionList;
ExceptionList = &local_10;
bufferIdx = 0;
do {
buffer = this[bufferIdx];
if (buffer != (HUD_Message)0x0) {
if (g_mainHeap == (void *)0x0) {
allocCounter = &g_allocatedBytesNoHeap;
}
else {
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
blockSize = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(buffer) + -4));
allocatedBytes = *allocCounter;
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - blockSize;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < blockSize));
free((void *)(GHIDRA_INT(buffer) + -4));
this[bufferIdx] = (HUD_Message)0x0;
}
bufferIdx = bufferIdx + 1;
} while (bufferIdx < 2);
ExceptionList = local_10;
return;
}
// 00841000
void HUD_Message::set_text_line(short *text, int lineIndex)
{
short *textEnd;
HUD_Message textCopy;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
longlong byteSize;
short ch;
uint charCount;
puStack_c = &LAB_00b02b00;
local_10 = ExceptionList;
ExceptionList = &local_10;
if (this[lineIndex] != (HUD_Message)0x0) {
local_8 = 0;
tracked_alloc(1,(void *)this[lineIndex],0);
this[lineIndex] = (HUD_Message)0x0;
}
local_8 = 0xffffffff;
textEnd = text;
do {
ch = *textEnd;
textEnd = textEnd + 1;
} while (ch != 0);
charCount = (GHIDRA_INT(textEnd) - GHIDRA_INT((text + 1)) >> 1) + 1;
byteSize = (ulonglong)charCount * 2;
textCopy = (HUD_Message)
tracked_alloc(0,(void *)0x0,
(ulonglong)
(-GHIDRA_UINT((GHIDRA_INT(((ulonglong)byteSize >> 0x20)) != 0)) | GHIDRA_UINT(byteSize)));
this[lineIndex] = textCopy;
memcpy((void *)textCopy,text,charCount * 2);
ExceptionList = local_10;
return;
}
// 008410c0
void HUD_Message::UpdateTextImage()
{
char cVar1;
undefined4 *targetStackEntry;
uint uVar2;
int unused;
int unused_00;
float fVar3;
float textY;
undefined4 drawSettings;
undefined4 local_48;
undefined4 local_44;
undefined4 local_40;
undefined4 local_3c;
undefined4 local_38;
undefined4 local_34;
KColor textColor;
undefined8 local_1c;
Font *subtitleFont;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
HUD_Message text;
Font *titleFont;
local_8 = 0xffffffff;
puStack_c = &LAB_00b02b35;
local_10 = ExceptionList;
ExceptionList = &local_10;
titleFont = &g_manager->_font7_Upheaval;
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this[2])) + 0x2))) == '\0') {
subtitleFont = &g_manager->_font9_PFTempestaSevenCondensedAgain;
}
else {
subtitleFont = &g_manager->_font1_TeamMeatEx10;
}
local_1c = 0;
std::vector::resize(&local_1c);
targetStackEntry = std::deque::back();
if (GHIDRA_CAST<byte *>((targetStackEntry + 1)) != GHIDRA_CAST<byte *>(0x0)) {
*GHIDRA_CAST<byte *>((targetStackEntry + 1)) = (byte)(g_graphicsManager_flags >> 5) & 1;
}
*targetStackEntry = g_graphicsManager_renderTarget;
(GHIDRA_CAST<KAGE_Graphics *>((&DAT_00c798e0)))->KAGE_Graphics::SetRenderTarget((void *)this[6],0);
(GHIDRA_CAST<RenderTarget *>((&DAT_00c798e0)))->RenderTarget::Clear();
g_graphicsManager_blendMode[0] = 0;
g_graphicsManager_blendMode[1] = 1;
g_graphicsManager_blendMode[2] = 7;
g_graphicsManager_blendMode[3] = 1;
g_graphicsManager_blendMode[4] = 7;
text = *this;
fVar3 = (float)(*GHIDRA_CAST<uint *>((GHIDRA_INT(this[6]) + 0x10)) >> 1) + 0.0;
local_1c = CONCAT44(fVar3,(undefined4)local_1c);
if (text != (HUD_Message)0x0) {
if (*GHIDRA_CAST<short *>(text) == 1) {
(GHIDRA_CAST<KColor *>((&textColor)))->KColor::SetFromARGB(0xffffffff);
if ((*GHIDRA_CAST<char *>((this + 0x57)) == '\0') && (*GHIDRA_CAST<char *>((this + 0x6a)) == '\0')) {
textY = 0.0;
}
else {
textY = 2.0;
}
render_text_image(titleFont,GHIDRA_CAST<short *>((GHIDRA_INT(text) + 2)),fVar3,textY,&textColor,unused);
}
else {
uVar2 = (GHIDRA_CAST<Font *>((titleFont)))->Font::get_string_width_utf16(GHIDRA_CAST<short *>(text),-1);
drawSettings = 0;
local_48 = 0xffff;
local_44 = 0;
local_40 = 0x3f800000;
local_3c = 0xffffffff;
local_38 = 0;
local_34 = 0;
fVar3 = fVar3 - ((float)(uVar2 >> 1) + 0.0);
local_8 = 0;
(GHIDRA_CAST<KColor *>((&textColor)))->KColor::SetFromARGB(0xffffffff);
if ((*GHIDRA_CAST<char *>((this + 0x57)) == '\0') && (*GHIDRA_CAST<char *>((this + 0x6a)) == '\0')) {
textY = 0.0;
}
else {
textY = 2.0;
}
(GHIDRA_CAST<Font *>((titleFont)))->Font::draw_string_wide_unscaled(GHIDRA_CAST<short *>(*this),fVar3,textY,&textColor,&drawSettings)
;
local_8 = 0xffffffff;
}
fVar3 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_1c)) + 0x4)));
}
text = this[1];
if (text != (HUD_Message)0x0) {
cVar1 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this[2])) + 0x2)));
uVar2 = 0xffffffff;
if (cVar1 != '\0') {
uVar2 = 0xff000000;
}
(GHIDRA_CAST<KColor *>((&textColor)))->KColor::SetFromARGB(uVar2);
textY = 18.0;
if (cVar1 != '\0') {
textY = 26.0;
}
if (*GHIDRA_CAST<short *>(text) == 1) {
render_text_image(subtitleFont,GHIDRA_CAST<short *>((GHIDRA_INT(text) + 2)),fVar3,textY,&textColor,unused_00);
}
else {
uVar2 = (GHIDRA_CAST<Font *>((subtitleFont)))->Font::get_string_width_utf16(GHIDRA_CAST<short *>(text),-1);
drawSettings = 0;
local_48 = 0xffff;
local_44 = 0;
local_40 = 0x3f800000;
local_3c = 0xffffffff;
local_38 = 0;
local_34 = 0;
local_8 = 1;
Font::draw_string_wide_unscaled
(subtitleFont,GHIDRA_CAST<short *>(this[1]),fVar3 - ((float)(uVar2 >> 1) + 0.0),textY,&textColor,
&drawSettings);
local_8 = 0xffffffff;
}
}
_glfw_context_reset(1);
pop_render_target();
ExceptionList = local_10;
return;
}
// 008413a0
void HUD_Message::render_text_image(Font *font, short *text, float x, float y, KColor *color, int unused)
{
byte isFontLoaded;
char cVar1;
int iVar2;
void *pvVar3;
uint uVar4;
LayerState *pLVar5;
undefined *shader;
ushort ch;
int unused_00;
int unused_01;
uint hashMix;
double advance;
int *image;
int *imageRefCount;
undefined1 auStack_182 [2];
undefined1 quad [44];
float local_14c;
float local_138;
float local_124;
float local_110;
void *charNode;
undefined1 glyphLayout [16];
float uvX0;
float uvY0;
float uvX1;
float uvY1;
float uvX2;
float uvY2;
float uvX3;
float uvY3;
undefined1 local_cc;
Vector quadSize;
undefined1 statsTexture [4];
int *statsTextureRef;
undefined1 cardsPillsTexture [4];
int *cardsPillsTextureRef;
undefined1 pickupTexture [4];
int *pickupTextureRef;
undefined1 chargeBarTexture [4];
int *chargeBarTextureRef;
undefined1 heartsTexture [4];
int *heartsTextureRef;
Vector local_94;
undefined1 defaultTexture [4];
int *defaultTextureRef;
undefined1 roomTargetB [4];
int *roomTargetBRef;
undefined1 roomTargetA [4];
int *roomTargetARef;
ushort *charPtr;
int *charBuf;
int *local_6c;
int *local_64;
int *textureRef;
int *local_5c;
ushort *local_58;
int *local_54;
undefined1 colorScratch [28];
float fStack_34;
float fStack_30;
float fStack_2c;
float local_28;
uint stackCookie;
undefined1 *puStack_20;
void *savedExceptionList;
undefined1 *puStack_18;
undefined4 ehState;
puStack_20 = colorScratch + 0x4c;
ehState = 0xffffffff;
puStack_18 = &LAB_00b02bcf;
savedExceptionList = ExceptionList;
stackCookie = __security_cookie ^ GHIDRA_UINT((colorScratch + 0x40));
ExceptionList = &savedExceptionList;
charPtr = GHIDRA_CAST<ushort *>(text);
local_54 = GHIDRA_CAST<int *>(0x0);
charBuf = GHIDRA_CAST<int *>(GHIDRA_UINT((ushort)*text));
if (*text != 0) {
isFontLoaded = font->_isLoaded;
local_58 = GHIDRA_CAST<ushort *>(text);
local_5c = charBuf;
do {
if (isFontLoaded == 0) {
LAB_00841470:
iVar2 = 8;
}
else {
local_6c = charBuf;
_Find_lower_bound<>();
if ((*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(local_94.y) + 0xd)) != '\0') ||
(pvVar3 = (void *)local_94.y,
(GHIDRA_UINT(charBuf) & 0xffff) < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(local_94.y) + 0x10)))) {
pvVar3 = (font->_charsBlock)._head;
}
if (pvVar3 == (font->_charsBlock)._head) {
iVar2 = font->_missingCharacter;
}
else {
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar3) + 0x14));
}
if ((iVar2 == -1) ||
(iVar2 = GHIDRA_INT(*GHIDRA_CAST<short *>((GHIDRA_CAST<char *>(font->_chars) + iVar2 * 0x14 + 0x10))), iVar2 == 0))
goto LAB_00841470;
}
local_58 = local_58 + 1;
local_54 = GHIDRA_CAST<int *>((GHIDRA_INT(local_54) + iVar2));
charBuf = GHIDRA_CAST<int *>(GHIDRA_UINT(*local_58));
isFontLoaded = font->_isLoaded;
} while (*local_58 != 0);
local_6c = GHIDRA_CAST<int *>((GHIDRA_UINT(local_5c) & 0xffff));
local_58 = GHIDRA_CAST<ushort *>((x - ((float)(GHIDRA_UINT(local_54) >> 1) + 0.0)));
charBuf = GHIDRA_CAST<int *>(0x0);
do {
if (font->_isLoaded == 0) {
LAB_008415fb:
ch = *charPtr;
LAB_00841601:
local_6c = GHIDRA_CAST<int *>(0x8);
local_64 = GHIDRA_CAST<int *>(0x0);
textureRef = GHIDRA_CAST<int *>(0x0);
uVar4 = ch + 1;
ehState = 0;
hashMix = uVar4 >> 5 ^ uVar4;
local_5c = GHIDRA_CAST<int *>(((uVar4 >> 0xc ^ hashMix) & 7));
local_54 = GHIDRA_CAST<int *>(((hashMix >> 8 ^ hashMix) & 0xffff));
switch(local_5c) {
case GHIDRA_CAST<int *>(0x0):
pLVar5 = (GHIDRA_CAST<ANM2 *>((&(g_game->_hud)._heartsSprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
pvVar3 = (GHIDRA_CAST<LayerState *>((pLVar5)))->LayerState::GetTexture(heartsTexture);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 1;
(GHIDRA_CAST<KAGE::SmartPointer *>((&local_64)))->KAGE::SmartPointer::operator_assign(pvVar3);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 2;
if (heartsTextureRef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*heartsTextureRef + 0xc))();
pvVar3 = g_imageReleaseFn;
joined_r0x00841934:
if ((cVar1 != '\0') && (pvVar3 != (code *)0x0)) {
(*pvVar3)();
}
}
break;
case GHIDRA_CAST<int *>(0x1):
pLVar5 = (GHIDRA_CAST<ANM2 *>((&(g_game->_hud)._chargeBarSprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
pvVar3 = (GHIDRA_CAST<LayerState *>((pLVar5)))->LayerState::GetTexture(chargeBarTexture);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 3;
(GHIDRA_CAST<KAGE::SmartPointer *>((&local_64)))->KAGE::SmartPointer::operator_assign(pvVar3);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 4;
if (chargeBarTextureRef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*chargeBarTextureRef + 0xc))();
pvVar3 = g_imageReleaseFn;
goto joined_r0x00841934;
}
break;
case GHIDRA_CAST<int *>(0x2):
pLVar5 = (GHIDRA_CAST<ANM2 *>((&(g_game->_hud)._pickupHUDSprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
pvVar3 = (GHIDRA_CAST<LayerState *>((pLVar5)))->LayerState::GetTexture(pickupTexture);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 5;
(GHIDRA_CAST<KAGE::SmartPointer *>((&local_64)))->KAGE::SmartPointer::operator_assign(pvVar3);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 6;
if (pickupTextureRef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*pickupTextureRef + 0xc))();
pvVar3 = g_imageReleaseFn;
goto joined_r0x00841934;
}
break;
case GHIDRA_CAST<int *>(0x3):
pLVar5 = (GHIDRA_CAST<ANM2 *>((&(g_game->_hud)._cardsPillsSprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
pvVar3 = (GHIDRA_CAST<LayerState *>((pLVar5)))->LayerState::GetTexture(cardsPillsTexture);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 7;
(GHIDRA_CAST<KAGE::SmartPointer *>((&local_64)))->KAGE::SmartPointer::operator_assign(pvVar3);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 8;
if (cardsPillsTextureRef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*cardsPillsTextureRef + 0xc))();
pvVar3 = g_imageReleaseFn;
goto joined_r0x00841934;
}
break;
case GHIDRA_CAST<int *>(0x4):
(GHIDRA_CAST<shared_ptr *>((roomTargetA)))->shared_ptr::assign((void *)(GHIDRA_INT(g_game->_room) + 0x1bc8));
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 9;
(GHIDRA_CAST<KAGE::SmartPointer *>((&local_64)))->KAGE::SmartPointer::operator_assign(roomTargetA);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 10;
if (roomTargetARef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*roomTargetARef + 0xc))();
pvVar3 = g_renderTargetReleaseFn;
goto joined_r0x00841934;
}
break;
case GHIDRA_CAST<int *>(0x5):
(GHIDRA_CAST<shared_ptr *>((roomTargetB)))->shared_ptr::assign((void *)(GHIDRA_INT(g_game->_room) + 0x1bd0));
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 0xb;
(GHIDRA_CAST<KAGE::SmartPointer *>((&local_64)))->KAGE::SmartPointer::operator_assign(roomTargetB);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 0xc;
if (roomTargetBRef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*roomTargetBRef + 0xc))();
pvVar3 = g_renderTargetReleaseFn;
goto joined_r0x00841934;
}
break;
case GHIDRA_CAST<int *>(0x6):
pLVar5 = (GHIDRA_CAST<ANM2 *>((&(g_game->_hud)._statsSprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
pvVar3 = (GHIDRA_CAST<LayerState *>((pLVar5)))->LayerState::GetTexture(statsTexture);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 0xd;
(GHIDRA_CAST<KAGE::SmartPointer *>((&local_64)))->KAGE::SmartPointer::operator_assign(pvVar3);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 0xe;
if (statsTextureRef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*statsTextureRef + 0xc))();
pvVar3 = g_imageReleaseFn;
goto joined_r0x00841934;
}
break;
case GHIDRA_CAST<int *>(0x7):
(GHIDRA_CAST<KAGE::SmartPointer *>((defaultTexture)))->KAGE::SmartPointer::operator_assign(&DAT_00c798a8);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 0xf;
(GHIDRA_CAST<KAGE::SmartPointer *>((&local_64)))->KAGE::SmartPointer::operator_assign(defaultTexture);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x0))) = 0x10;
if (defaultTextureRef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*defaultTextureRef + 0xc))();
pvVar3 = g_imageReleaseFn;
goto joined_r0x00841934;
}
}
ehState = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(ehState))) + 0x1))) << 8;
if (local_64 != GHIDRA_CAST<int *>(0x0)) {
uVar4 = GHIDRA_UINT(local_64[4]) >> 3;
local_cc = 1;
local_28 = 0.0;
quadSize.x = 8.0;
quadSize.y = 16.0;
iVar2 = GHIDRA_INT(local_54) % GHIDRA_INT(((GHIDRA_UINT(local_64[5]) >> 4) * uVar4));
local_94.x = (float)local_58;
uvY0 = (float)(iVar2 / GHIDRA_INT(uVar4)) * 16.0;
uvY2 = uvY0 + 16.0;
uvX0 = (float)(iVar2 % GHIDRA_INT(uVar4)) * 8.0;
uvX1 = uvX0 + 8.0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x18))) = 1.0;
fStack_34 = 1.0;
fStack_30 = 1.0;
fStack_2c = 1.0;
local_94.y = y;
uvY1 = uvY0;
uvX2 = uvX0;
uvX3 = uvX1;
uvY3 = uvY2;
render_quad_set_rect(quad,&local_94,&quadSize,GHIDRA_CAST<KColor *>((colorScratch + 0x18)));
if (local_5c == GHIDRA_CAST<int *>(&DAT_00000007)) {
if ((g_manager->_optionsConfig)._enableColorCorrection == 0) {
if ((local_14c + local_138 + local_124 + local_110) * 0.25 != 0.0) {
shader_push(GHIDRA_CAST<byte *>("KAGE_ColorShader"));
FUN_00a11080();
pvVar3 = kage_graphics_flush((void *)0x0);
render_quad_draw(pvVar3,colorScratch + 8,quad,1,unused_01);
FUN_00a14200();
}
goto LAB_00841bda;
}
local_5c = GHIDRA_CAST<int *>(0x3f800000);
shader = &DAT_00c79398;
if ((DAT_00c7939c & 1) == 0) {
shader = g_currentShader;
}
local_54 = GHIDRA_CAST<int *>(0x3f800000);
g_currentShader = shader;
(GHIDRA_CAST<Shader *>((shader)))->Shader::set_uniform(GHIDRA_CAST<byte *>("Exposure"),8,&local_5c,GHIDRA_INT(shader));
(GHIDRA_CAST<Shader *>((g_currentShader)))->Shader::set_uniform(GHIDRA_CAST<byte *>("Gamma"),8,&local_54,unused_00);
}
else {
shader = &g_shaders;
if ((DAT_00c7911c & 1) == 0) {
shader = g_currentShader;
}
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x0))) = 1.0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x4))) = 1.0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x8))) = 1.0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0xc))) = 1.0;
fStack_30 = 0.0;
fStack_2c = 0.0;
image = GHIDRA_CAST<int *>(0x0);
imageRefCount = GHIDRA_CAST<int *>(0x0);
local_28 = 0.0;
local_5c = textureRef;
local_54 = local_64;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x10))) = 0.0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x14))) = 0.0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x18))) = 0.0;
fStack_34 = 0.0;
g_currentShader = shader;
if (textureRef != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*textureRef + 4))();
if (cVar1 != '\0') {
if (((imageRefCount != GHIDRA_CAST<int *>(0x0)) &&
(cVar1 = (**(code **)(*imageRefCount + 0xc))(), cVar1 != '\0')) &&
(g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)(auStack_182 + -10);
}
image = local_54;
imageRefCount = local_5c;
}
}
apply_sprite_shader_params(GHIDRA_CAST<ColorMod *>(colorScratch),1,image,imageRefCount);
}
(**(code **)(*local_64 + 0x14))(&uvX0);
}
LAB_00841bda:
ehState = 0x11;
if (((textureRef != GHIDRA_CAST<int *>(0x0)) &&
(cVar1 = (**(code **)(*textureRef + 0xc))(), cVar1 != '\0')) &&
(g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)();
}
}
else {
local_5c = local_6c;
_Find_lower_bound<>();
if ((*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(charNode) + 0xd)) != '\0') ||
(pvVar3 = charNode, (GHIDRA_UINT(local_6c) & 0xffff) < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(charNode) + 0x10)))) {
pvVar3 = (font->_charsBlock)._head;
}
if (pvVar3 == (font->_charsBlock)._head) {
iVar2 = font->_missingCharacter;
}
else {
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar3) + 0x14));
}
if (iVar2 == -1) goto LAB_008415fb;
local_6c = GHIDRA_CAST<int *>(GHIDRA_INT(*GHIDRA_CAST<short *>((GHIDRA_CAST<char *>(font->_chars) + iVar2 * 0x14 + 0x10))));
ch = *charPtr;
if (local_6c == GHIDRA_CAST<int *>(0x0)) goto LAB_00841601;
charBuf = GHIDRA_CAST<int *>(GHIDRA_UINT(ch));
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x10))) = 0.0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x14))) = 9.18341e-41;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(colorScratch)) + 0x18))) = 0.0;
fStack_34 = 1.0;
fStack_30 = -NAN;
fStack_2c = 0.0;
local_28 = 0.0;
ehState = 0x12;
pvVar3 = (GHIDRA_CAST<Font *>((font)))->Font::layout_glyphs(glyphLayout,GHIDRA_CAST<byte *>(&charBuf),colorScratch + 0x10,
&g_vectorOne);
ehState = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(ehState)) + 0x1))),0x13);
Font::draw_glyph_run(font,(float)local_58,y,pvVar3,1.0,1.0,*color,colorScratch + 0x10);
std::vector<12byte>::clear();
std::vector<12byte>::_Tidy();
}
ehState = 0xffffffff;
iVar2 = GHIDRA_INT(local_6c) >> 0x1f;
advance = (double)GHIDRA_INT(local_6c);
charPtr = charPtr + 1;
local_6c = GHIDRA_CAST<int *>(GHIDRA_UINT(*charPtr));
local_58 = GHIDRA_CAST<ushort *>(((float)(advance + __uint_to_double_fixup[-iVar2]) + (float)local_58));
} while (*charPtr != 0);
}
ExceptionList = savedExceptionList;
return;
}