Files
isaac-port/generated-src/generic_prompt.cpp
T
shweetandClaude Opus 5.5 780767f5e1 Curation round 2, wave A: anm2 (Anm2Ed JSON), text, config as idiomatic classes; SDL3 platform opens a window
- anm2.h/.cpp take over ANM2, AnimationState, LayerState, AnmCache and the frame data. They read Anm2Ed's JSON documents
  with simdjson and play them as the game does (interpolation baked at load). src/anm2/ and msvc.h are retired.
- font, formatted_text, string_table and rich_text take over the text classes. FormattedText::parse is still bit-exact
  against its assembly.
- options_config and challenge_params take over OptionsConfig, ChallengeParams and the .ini helpers. The tests include
  Save's exact bytes.
- platform.h/.cpp and main.cpp run IsaacMain on SDL3: the window and GL context open, and the run stops at the first
  built-in shader (FUN_00a13fa0).
- source_tree.py: a taken-over parent stays bytes, taken-over methods are not re-emitted as a namespace, and every
  address in a (a, b, c to d) list on a comment counts as taken over.
- log.h: reconstruction_missing() for a taken-over class's methods that are not written yet.
206 functions taken over, boot path 89/615. The full build waits for wave B: item_config, entity_config and mod_manager
still use the old APIs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 23:04:54 -05:00

496 lines
18 KiB
C++

#include "classes.h"
// 008378e0
void GenericPrompt::Initialize(uint8_t SmallPrompt)
{
char *ptr;
uint32_t size;
std_string anm2Path;
std_string smallAnm2Path;
uint32_t local_24;
uint8_t *puStack_20;
void *local_1c;
uint8_t *puStack_18;
uint32_t local_14;
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
local_14 = 0xffffffff;
puStack_18 = &LAB_00b02515;
local_1c = ExceptionList;
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
ExceptionList = &local_1c;
if (SmallPrompt == 0) {
anm2Path._size = 0;
anm2Path._capacity = 0xf;
anm2Path._buf[0] = '\0';
anm2Path._buf[1] = '\0';
anm2Path._buf[2] = '\0';
anm2Path._buf[3] = '\0';
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20);
anm2Path._size = 0x18;
anm2Path._capacity = 0x1f;
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0))),"gfx/ui/Prompt_YesNo.anm2",0x19);
local_14 = 1;
ANM2::Load(&this->_sprite,&anm2Path,1);
if (anm2Path._capacity < 0x10) goto LAB_00837a6d;
size = anm2Path._capacity + 1;
ptr = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0)));
if (0xfff < size) {
ptr = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4));
size = anm2Path._capacity + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
}
else {
smallAnm2Path._size = 0;
smallAnm2Path._capacity = 0xf;
smallAnm2Path._buf[0] = '\0';
smallAnm2Path._buf[1] = '\0';
smallAnm2Path._buf[2] = '\0';
smallAnm2Path._buf[3] = '\0';
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(smallAnm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20);
smallAnm2Path._size = 0x1e;
smallAnm2Path._capacity = 0x1f;
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(smallAnm2Path._buf))) + 0x0))),"gfx/ui/Prompt_YesNo_Small.anm2",0x1f);
local_14 = 0;
ANM2::Load(&this->_sprite,&smallAnm2Path,1);
if (smallAnm2Path._capacity < 0x10) goto LAB_00837a6d;
size = smallAnm2Path._capacity + 1;
ptr = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(smallAnm2Path._buf))) + 0x0)));
if (0xfff < size) {
ptr = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(smallAnm2Path._buf)) + 0x0))) + -4));
size = smallAnm2Path._capacity + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(smallAnm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
}
operator_delete(ptr,size);
LAB_00837a6d:
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x12c)))) = 0;
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x128)))) = 0;
this->_isOnlineVote = 0;
ExceptionList = local_1c;
return;
}
// 00837ab0
void GenericPrompt::Update(uint8_t processInput)
{
int layerId;
uint8_t bVar1;
uint8_t *currentAnimChar;
uint32_t compareResult;
char *appearChar;
uint8_t *idleChar;
bool isLess;
uint8_t *animData;
void *currentAnimData;
int selectedOption;
if (processInput != 0) {
handle_input(this);
}
if ((this->_sprite)._loaded != 0) {
AnimationState::Update(&(this->_sprite)._animState);
AnimationState::Update(&(this->_sprite)._overlayAnimState);
}
animData = (this->_sprite)._animState._animData;
if ((animData != GHIDRA_CAST<uint8_t *>(0x0)) && ((this->_sprite)._animState._isPlaying == 0)) {
currentAnimChar = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
currentAnimChar = *GHIDRA_CAST<uint8_t **>(animData);
}
appearChar = "Appear";
do {
bVar1 = *currentAnimChar;
isLess = bVar1 < (uint8_t)*appearChar;
if (bVar1 != *appearChar) {
LAB_00837b22:
compareResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_00837b27;
}
if (bVar1 == 0) break;
bVar1 = currentAnimChar[1];
isLess = bVar1 < (uint8_t)appearChar[1];
if (bVar1 != appearChar[1]) goto LAB_00837b22;
currentAnimChar = currentAnimChar + 2;
appearChar = appearChar + 2;
} while (bVar1 != 0);
compareResult = 0;
LAB_00837b27:
if (compareResult == 0) {
currentAnimChar = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
currentAnimChar = *GHIDRA_CAST<uint8_t **>(animData);
}
idleChar = s_Idle;
do {
bVar1 = *currentAnimChar;
isLess = bVar1 < *idleChar;
if (bVar1 != *idleChar) {
LAB_00837b60:
compareResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_00837b65;
}
if (bVar1 == 0) break;
bVar1 = currentAnimChar[1];
isLess = bVar1 < idleChar[1];
if (bVar1 != idleChar[1]) goto LAB_00837b60;
currentAnimChar = currentAnimChar + 2;
idleChar = idleChar + 2;
} while (bVar1 != 0);
compareResult = 0;
LAB_00837b65:
if (((compareResult != 0) || (animData[0x34] != 0)) &&
(bVar1 = ANM2::SetAnimation(&this->_sprite,s_Idle,1), bVar1 != 0)) {
AnimationState::Rewind(&(this->_sprite)._animState);
(this->_sprite)._animState._isPlaying = 1;
}
}
}
selectedOption = *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x128))));
if ((this->_sprite)._animState._animData != (void *)0x0) {
if ((*GHIDRA_CAST<int *>((GHIDRA_INT((this->_sprite)._animState._animation) + 0x80)) < 2) &&
(KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("LayerId out of bounds\n")),
*GHIDRA_CAST<int *>((GHIDRA_INT((this->_sprite)._animState._animation) + 0x80)) < 2)) {
return;
}
currentAnimData = (this->_sprite)._animState._animData;
layerId = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(currentAnimData) + 0x3c));
if (((currentAnimData == (void *)0x0) || (layerId < 0)) ||
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(currentAnimData) + 0x1c)) <= layerId)) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("id out of bounds\n"));
}
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT((this->_sprite)._animState._layerFrames) + layerId * 4)) = 0;
AnimationState::AdvanceLayerPosition(&(this->_sprite)._animState,layerId,(float)selectedOption);
}
return;
}
// 00837c10
void GenericPrompt::Render()
{
KColor color;
float *textTopFrame;
int iVar1;
int bodyLineWidth;
void *glyphRun;
AnimationState *secondAnimState;
uint32_t *lineText;
float fVar2;
float fVar3;
float textScaleY;
float fVar4;
float fVar5;
float fVar6;
uint32_t fontSettings;
uint32_t local_78;
uint32_t local_74;
uint32_t local_70;
uint32_t local_6c;
uint32_t local_68;
uint32_t local_64;
KColor textColor;
uint8_t glyphRunBuf [16];
Vector layoutScale;
Vector screenCenter;
float bodyLineX;
GenericPrompt *local_28;
float textX;
float local_20;
float lineY;
Font *local_18;
Font *bodyFont;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
Font *titleFont;
local_8 = 0xffffffff;
puStack_c = &LAB_00b0255d;
local_10 = ExceptionList;
ExceptionList = &local_10;
if (((this->_sprite)._animState._animData != (void *)0x0) &&
((this->_sprite)._animState._isPlaying != 0)) {
screenCenter.x = g_screenWidth * 0.5;
local_18 = &g_manager->_font3_TeamMeatEx16;
bodyFont = &g_manager->_font2_TeamMeatEx12;
screenCenter.y = g_screenHeight * 0.5;
local_28 = this;
if ((this->_sprite)._loaded != 0) {
if ((this->_sprite)._overlayRenderFirst == 0) {
AnimationState::Render
(&(this->_sprite)._animState,&screenCenter,&g_vectorZero,&g_vectorZero);
secondAnimState = &(this->_sprite)._overlayAnimState;
}
else {
AnimationState::Render
(&(this->_sprite)._overlayAnimState,&screenCenter,&g_vectorZero,&g_vectorZero);
secondAnimState = &(this->_sprite)._animState;
}
AnimationState::Render(secondAnimState,&screenCenter,&g_vectorZero,&g_vectorZero);
}
if ((this->_sprite)._animState._animData != (void *)0x0) {
textTopFrame = AnimationState::GetNullFrame(&(this->_sprite)._animState,GHIDRA_CAST<uint8_t *>("TextTop"));
if (textTopFrame != GHIDRA_CAST<float *>(0x0)) {
(GHIDRA_CAST<KColor *>((&textColor)))->KColor::SetFromARGB(0xff362f2d);
titleFont = local_18;
fVar6 = *textTopFrame;
lineText = GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x114))));
fVar3 = textTopFrame[1];
local_20 = 2.8026e-45;
textX = fVar6;
lineY = fVar3;
do {
if (GHIDRA_CAST<short *>(*lineText) == GHIDRA_CAST<short *>(0x0)) {
textScaleY = textTopFrame[5];
}
else {
fontSettings = 0;
local_78 = 0xffff;
local_74 = 0;
local_70 = 0x3f800000;
local_6c = 0xffffffff;
local_68 = 0;
local_64 = 0;
local_8 = 0;
fVar5 = 0.5;
fVar2 = textTopFrame[5];
fVar4 = textTopFrame[4];
fVar3 = g_screenHeight * 0.5 + fVar3;
iVar1 = Font::get_string_width_utf16(titleFont,GHIDRA_CAST<short *>(*lineText),-1);
Font::draw_string_wide
(titleFont,GHIDRA_CAST<short *>(*lineText),
(g_screenWidth * fVar5 + fVar6) -
(float)((double)iVar1 + __uint_to_double_fixup[-(iVar1 >> 0x1f)]) * fVar5 *
textTopFrame[4],fVar3,fVar4,fVar2,&textColor,&fontSettings);
textScaleY = textTopFrame[5];
fVar3 = lineY + textScaleY * 17.0;
fVar6 = textX;
lineY = fVar3;
}
lineText = lineText + 1;
local_20 = (float)(GHIDRA_INT(local_20) + -1);
local_18 = GHIDRA_CAST<Font *>(textScaleY);
} while (local_20 != 0.0);
lineText = GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((local_28)) + 0x11c))));
iVar1 = 3;
fVar3 = textScaleY * 12.0 + fVar3;
local_20 = fVar3;
do {
if (GHIDRA_CAST<short *>(*lineText) != GHIDRA_CAST<short *>(0x0)) {
fontSettings = 0;
local_78 = 0xffff;
local_74 = 0;
local_70 = 0x3f800000;
local_6c = 0xffffffff;
local_68 = 0;
local_64 = 0;
local_8 = 1;
fVar4 = 0.5;
fVar2 = textTopFrame[4];
lineY = g_screenHeight * 0.5 + fVar3;
local_28 = GHIDRA_CAST<GenericPrompt *>(fVar2);
bodyLineWidth = Font::get_string_width_utf16(bodyFont,GHIDRA_CAST<short *>(*lineText),-1);
bodyLineX = (g_screenWidth * fVar4 + fVar6) -
(float)((double)bodyLineWidth +
__uint_to_double_fixup[-(bodyLineWidth >> 0x1f)]) * fVar4 *
textTopFrame[4];
layoutScale.x = fVar2;
layoutScale.y = textScaleY;
glyphRun = Font::layout_glyphs(bodyFont,glyphRunBuf,GHIDRA_CAST<uint8_t *>(*lineText),&fontSettings,
&layoutScale);
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),2);
color._green = textColor._green;
color._red = textColor._red;
color._blue = textColor._blue;
color._alpha = textColor._alpha;
color._unk = textColor._unk;
Font::draw_glyph_run
(bodyFont,bodyLineX,lineY,glyphRun,(float)local_28,(float)local_18,color,
&fontSettings);
msvc::vector<12byte>::clear();
msvc::vector<12byte>::_Tidy();
textScaleY = textTopFrame[5];
fVar3 = local_20 + textScaleY * 13.0;
local_20 = fVar3;
local_18 = GHIDRA_CAST<Font *>(textScaleY);
}
lineText = lineText + 1;
iVar1 = iVar1 + -1;
fVar6 = textX;
} while (iVar1 != 0);
}
}
}
ExceptionList = local_10;
return;
}
// 00837fe0
void GenericPrompt::handle_input()
{
uint8_t bVar1;
int localEntry;
uint8_t *animName;
uint32_t uVar2;
uint8_t *idleCursor;
int controllerId;
bool isLess;
controllerId = -1;
if (g_manager->_netplayManager != *GHIDRA_CAST<int *>((g_manager + 1))) {
localEntry = FUN_0090b070();
if ((localEntry != 0) && (*GHIDRA_CAST<int *>((localEntry + 0x378)) != 0)) {
controllerId = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((localEntry + 0x378)) + 0xc));
}
}
bVar1 = input_is_action_triggered(g_manager,0x14,controllerId,GHIDRA_CAST<Entity *>(0x0),0);
if (bVar1 == 0) {
bVar1 = input_is_action_triggered(g_manager,0x15,controllerId,GHIDRA_CAST<Entity *>(0x0),0);
if (bVar1 == 0) goto LAB_0083804d;
}
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x128)))) = *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x128)))) - 1U & 1;
LAB_0083804d:
bVar1 = input_is_action_triggered(g_manager,0xe,controllerId,GHIDRA_CAST<Entity *>(0x0),0);
if (((bVar1 != 0) && (animName = (this->_sprite)._animState._animData, animName != GHIDRA_CAST<uint8_t *>(0x0)))
&& ((this->_sprite)._animState._isPlaying != 0)) {
if (0xf < *GHIDRA_CAST<uint32_t *>((animName + 0x14))) {
animName = *GHIDRA_CAST<uint8_t **>(animName);
}
idleCursor = s_Idle;
do {
bVar1 = *animName;
isLess = bVar1 < *idleCursor;
if (bVar1 != *idleCursor) {
LAB_008380a0:
uVar2 = -GHIDRA_UINT(isLess) | 1;
goto LAB_008380a5;
}
if (bVar1 == 0) break;
bVar1 = animName[1];
isLess = bVar1 < idleCursor[1];
if (bVar1 != idleCursor[1]) goto LAB_008380a0;
animName = animName + 2;
idleCursor = idleCursor + 2;
} while (bVar1 != 0);
uVar2 = 0;
LAB_008380a5:
if (uVar2 == 0) {
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x12c)))) = 2 - GHIDRA_UINT((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x128)))) != 0));
if (this->_isOnlineVote != 0) {
online_vote_send(GHIDRA_UINT((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x128)))) == 0)));
return;
}
Disappear(&this->_sprite);
}
}
return;
}
// 008380f0
void GenericPrompt::Show(uint8_t UNK)
{
uint8_t bVar1;
uint8_t *animName;
uint32_t cmpResult;
char *appearName;
bool isLess;
uint8_t *animData;
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x12c)))) = 0;
*GHIDRA_CAST<uint32_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x128)))) = 0;
animData = (this->_sprite)._animState._animData;
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
animName = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
animName = *GHIDRA_CAST<uint8_t **>(animData);
}
appearName = "Appear";
do {
bVar1 = *animName;
isLess = bVar1 < (uint8_t)*appearName;
if (bVar1 != *appearName) {
LAB_00838142:
cmpResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_00838147;
}
if (bVar1 == 0) break;
bVar1 = animName[1];
isLess = bVar1 < (uint8_t)appearName[1];
if (bVar1 != appearName[1]) goto LAB_00838142;
animName = animName + 2;
appearName = appearName + 2;
} while (bVar1 != 0);
cmpResult = 0;
LAB_00838147:
if ((cmpResult == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0))))
goto LAB_00838173;
}
bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST<uint8_t *>("Appear"),1);
if (bVar1 != 0) {
AnimationState::Rewind(&(this->_sprite)._animState);
(this->_sprite)._animState._isPlaying = 1;
}
LAB_00838173:
this->_isOnlineVote = UNK;
return;
}
// 00838190
void GenericPrompt::Disappear(ANM2 *anm2)
{
uint8_t bVar1;
uint8_t *animName;
uint32_t compareResult;
char *targetName;
bool isLess;
uint8_t *animData;
animData = (anm2->_animState)._animData;
if (animData != GHIDRA_CAST<uint8_t *>(0x0)) {
animName = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
animName = *GHIDRA_CAST<uint8_t **>(animData);
}
targetName = "Dissappear";
do {
bVar1 = *animName;
isLess = bVar1 < (uint8_t)*targetName;
if (bVar1 != *targetName) {
LAB_008381d0:
compareResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_008381d5;
}
if (bVar1 == 0) break;
bVar1 = animName[1];
isLess = bVar1 < (uint8_t)targetName[1];
if (bVar1 != targetName[1]) goto LAB_008381d0;
animName = animName + 2;
targetName = targetName + 2;
} while (bVar1 != 0);
compareResult = 0;
LAB_008381d5:
if (compareResult == 0) {
if (animData[0x34] == 0) {
return;
}
if ((anm2->_animState)._isPlaying != 0) {
return;
}
}
}
bVar1 = ANM2::SetAnimation(anm2,GHIDRA_CAST<uint8_t *>("Dissappear"),1);
if (bVar1 != 0) {
AnimationState::Rewind(&anm2->_animState);
(anm2->_animState)._isPlaying = 1;
}
return;
}