Files
isaac-port/generated-src/anm2.cpp
T
shweetandClaude Opus 5.5 9d4d4f5c64 Build 29: zero-length placeholder structs, generated-src with standard types
--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:41:34 -05:00

1986 lines
71 KiB
C++

#include "classes.h"
// 004074c0
void ANM2::constructor()
{
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
puStack_c = &LAB_00af094e;
local_10 = ExceptionList;
ExceptionList = &local_10;
(this->_filename)._buf[0] = '\0';
(this->_filename)._buf[1] = '\0';
(this->_filename)._buf[2] = '\0';
(this->_filename)._buf[3] = '\0';
(this->_filename)._size = 0;
(this->_filename)._capacity = 0xf;
(this->_filename)._buf[0] = '\0';
(this->_animDefaultName)._buf[0] = '\0';
(this->_animDefaultName)._buf[1] = '\0';
(this->_animDefaultName)._buf[2] = '\0';
(this->_animDefaultName)._buf[3] = '\0';
(this->_animDefaultName)._size = 0;
(this->_animDefaultName)._capacity = 0xf;
(this->_animDefaultName)._buf[0] = '\0';
local_8 = 1;
(this->_animState)._animation = this;
(this->_animState)._layerFrames = (void *)0x0;
(this->_animState)._nullLayerFrames = (void *)0x0;
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::SetAnimationData((void *)0x0);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 2;
(this->_overlayAnimState)._animation = this;
(this->_overlayAnimState)._layerFrames = (void *)0x0;
(this->_overlayAnimState)._nullLayerFrames = (void *)0x0;
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::SetAnimationData((void *)0x0);
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),3);
(this->_offset).y = 0.0;
(this->_offset).x = 0.0;
(this->_scale).y = 0.0;
(this->_scale).x = 0.0;
(this->_color)._tint[0] = 1.0;
(this->_color)._tint[1] = 1.0;
(this->_color)._tint[2] = 1.0;
(this->_color)._tint[3] = 1.0;
(this->_color)._colorize[0] = 0.0;
(this->_color)._colorize[1] = 0.0;
(this->_color)._colorize[2] = 0.0;
(this->_color)._colorize[3] = 0.0;
(this->_color)._offset[0] = 0.0;
(this->_color)._offset[1] = 0.0;
(this->_color)._offset[2] = 0.0;
(this->_championColor)._tint[0] = 1.0;
(this->_championColor)._tint[1] = 1.0;
(this->_championColor)._tint[2] = 1.0;
(this->_championColor)._tint[3] = 1.0;
(this->_championColor)._colorize[0] = 0.0;
(this->_championColor)._colorize[1] = 0.0;
(this->_championColor)._colorize[2] = 0.0;
(this->_championColor)._colorize[3] = 0.0;
this->_layerState = (void *)0x0;
(this->_championColor)._offset[0] = 0.0;
(this->_championColor)._offset[1] = 0.0;
(this->_championColor)._offset[2] = 0.0;
Reset(this);
ExceptionList = local_10;
return;
}
// 00407690
ANM2::ANM2(ANM2 *other)
{
float fVar1;
float fVar2;
float fVar3;
char isLastRef;
std_string *text;
void *textureRef;
uint32_t allocSize;
LayerState *srcLayer;
uint32_t *dstLayer;
uint8_t tmpTexture [4];
uint32_t *local_34;
uint32_t layerCount;
ANM2 *self;
uint32_t *local_28;
uint32_t local_24;
uint8_t *puStack_20;
void *local_1c;
uint8_t *puStack_18;
uint32_t local_14;
uint8_t isLoaded;
puStack_20 = tmpTexture + 0x34;
local_14 = 0xffffffff;
puStack_18 = &LAB_00af09d3;
local_1c = ExceptionList;
ExceptionList = &local_1c;
self = this;
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(this))))->msvc::string::string(other);
local_14 = 0;
(GHIDRA_CAST<msvc::string *>(((this->_animDefaultName)._buf)))->msvc::string::string(&other->_animDefaultName);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 1;
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::AnimationState(this,&other->_animState);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 2;
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::AnimationState(this,&other->_overlayAnimState);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 3;
this->_overlayRenderFirst = other->_overlayRenderFirst;
this->_animData = other->_animData;
this->_animCount = other->_animCount;
this->_layerState = (void *)0x0;
this->_layerCount = other->_layerCount;
this->_nullLayerNames = other->_nullLayerNames;
this->_numNullLayers = other->_numNullLayers;
this->_eventNames = other->_eventNames;
this->_numEvents = other->_numEvents;
(this->_offset).y = 0.0;
(this->_offset).x = 0.0;
fVar1 = (other->_scale).y;
(this->_scale).x = (other->_scale).x;
(this->_scale).y = fVar1;
this->_rotation = other->_rotation;
fVar1 = (other->_color)._tint[1];
fVar2 = (other->_color)._tint[2];
fVar3 = (other->_color)._tint[3];
(this->_color)._tint[0] = (other->_color)._tint[0];
(this->_color)._tint[1] = fVar1;
(this->_color)._tint[2] = fVar2;
(this->_color)._tint[3] = fVar3;
fVar1 = (other->_color)._colorize[1];
fVar2 = (other->_color)._colorize[2];
fVar3 = (other->_color)._colorize[3];
(this->_color)._colorize[0] = (other->_color)._colorize[0];
(this->_color)._colorize[1] = fVar1;
(this->_color)._colorize[2] = fVar2;
(this->_color)._colorize[3] = fVar3;
*GHIDRA_CAST<uint64_t *>((this->_color)._offset) = *GHIDRA_CAST<uint64_t *>((other->_color)._offset);
(this->_color)._offset[2] = (other->_color)._offset[2];
fVar1 = (other->_championColor)._tint[1];
fVar2 = (other->_championColor)._tint[2];
fVar3 = (other->_championColor)._tint[3];
(this->_championColor)._tint[0] = (other->_championColor)._tint[0];
(this->_championColor)._tint[1] = fVar1;
(this->_championColor)._tint[2] = fVar2;
(this->_championColor)._tint[3] = fVar3;
fVar1 = (other->_championColor)._colorize[1];
fVar2 = (other->_championColor)._colorize[2];
fVar3 = (other->_championColor)._colorize[3];
(this->_championColor)._colorize[0] = (other->_championColor)._colorize[0];
(this->_championColor)._colorize[1] = fVar1;
(this->_championColor)._colorize[2] = fVar2;
(this->_championColor)._colorize[3] = fVar3;
fVar1 = (other->_championColor)._offset[1];
(this->_championColor)._offset[0] = (other->_championColor)._offset[0];
(this->_championColor)._offset[1] = fVar1;
(this->_championColor)._offset[2] = (other->_championColor)._offset[2];
this->_flipX = other->_flipX;
this->_flipY = other->_flipY;
this->_playbackSpeed = other->_playbackSpeed;
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x108))) = (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((other)) + 0x108)));
isLoaded = other->_loaded;
this->_loaded = isLoaded;
this->_shadowLayerIndex = other->_shadowLayerIndex;
this->_bitflags = 0;
if (isLoaded != 0) {
AnmCache::AddRef(&this->_filename);
}
layerCount = other->_layerCount;
local_28 = GHIDRA_CAST<uint32_t *>(0x0);
allocSize = -GHIDRA_UINT((GHIDRA_INT(((uint64_t)layerCount * 0xa0 >> 0x20)) != 0)) |
GHIDRA_UINT(((uint64_t)layerCount * 0xa0));
local_24 = layerCount;
local_34 = operator_new_tracked(-GHIDRA_UINT((0xfffffffb < allocSize)) | allocSize + 4);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 4;
if (local_34 == GHIDRA_CAST<uint32_t *>(0x0)) {
local_28 = GHIDRA_CAST<uint32_t *>(0x0);
}
else {
*local_34 = local_24;
local_28 = local_34 + 1;
_eh_vector_constructor_iterator_
(local_28,0xa0,local_24,LayerState::LayerState,LayerState::~LayerState);
}
this->_layerState = local_28;
local_24 = 0;
if (other->_layerCount != 0) {
local_28 = GHIDRA_CAST<uint32_t *>(0x0);
do {
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 3;
srcLayer = GHIDRA_CAST<LayerState *>((GHIDRA_INT(other->_layerState) + GHIDRA_INT(local_28)));
dstLayer = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(this->_layerState) + GHIDRA_INT(local_28)));
*dstLayer = srcLayer->_layerData;
text = &srcLayer->_spriteSheetPath;
if (GHIDRA_CAST<std_string *>((dstLayer + 2)) != text) {
if (0xf < (srcLayer->_spriteSheetPath)._capacity) {
text = *GHIDRA_CAST<std_string **>(text->_buf);
}
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>((dstLayer + 2)))))->msvc::string::assign(GHIDRA_CAST<uint8_t *>(text),(srcLayer->_spriteSheetPath)._size);
}
textureRef = (GHIDRA_CAST<LayerState *>((srcLayer)))->LayerState::GetTexture(tmpTexture);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 5;
(GHIDRA_CAST<KAGE::SmartPointer *>((dstLayer + 0x26)))->KAGE::SmartPointer::operator_assign(textureRef);
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 6;
if (local_34 != GHIDRA_CAST<uint32_t *>(0x0)) {
isLastRef = (**(code **)(*local_34 + 0xc))();
if ((isLastRef != '\0') && (g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)(tmpTexture);
}
}
*GHIDRA_CAST<uint8_t *>((dstLayer + 0xc)) = srcLayer->_spriteSheetLoaded;
*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(dstLayer) + 0x31)) = (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((srcLayer)) + 0x31)));
*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(dstLayer) + 0x32)) = srcLayer->_flipX;
*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(dstLayer) + 0x33)) = srcLayer->_flipY;
dstLayer[0xd] = (srcLayer->_size).x;
dstLayer[0xe] = (srcLayer->_size).y;
dstLayer[0xf] = srcLayer->_rotation;
dstLayer[0x10] = (srcLayer->_pos).x;
dstLayer[0x11] = (srcLayer->_pos).y;
if (GHIDRA_CAST<ColorMod *>((dstLayer + 0x12)) != &srcLayer->_color) {
fVar1 = (srcLayer->_color)._tint[1];
fVar2 = (srcLayer->_color)._tint[2];
fVar3 = (srcLayer->_color)._tint[3];
dstLayer[0x12] = (srcLayer->_color)._tint[0];
dstLayer[0x13] = fVar1;
dstLayer[0x14] = fVar2;
dstLayer[0x15] = fVar3;
fVar1 = (srcLayer->_color)._colorize[1];
fVar2 = (srcLayer->_color)._colorize[2];
fVar3 = (srcLayer->_color)._colorize[3];
dstLayer[0x16] = (srcLayer->_color)._colorize[0];
dstLayer[0x17] = fVar1;
dstLayer[0x18] = fVar2;
dstLayer[0x19] = fVar3;
fVar1 = (srcLayer->_color)._offset[1];
dstLayer[0x1a] = (srcLayer->_color)._offset[0];
dstLayer[0x1b] = fVar1;
dstLayer[0x1c] = (srcLayer->_color)._offset[2];
}
*GHIDRA_CAST<uint8_t *>((dstLayer + 0x1d)) = srcLayer->_visible;
dstLayer[0x1e] = srcLayer->_blendMode[0];
dstLayer[0x1f] = srcLayer->_blendMode[1];
local_24 = local_24 + 1;
dstLayer[0x20] = srcLayer->_blendMode[2];
dstLayer[0x21] = srcLayer->_blendMode[3];
dstLayer[0x22] = srcLayer->_blendMode[4];
dstLayer[0x23] = srcLayer->_bitflags;
dstLayer[0x24] = (srcLayer->_cropOffset).x;
dstLayer[0x25] = (srcLayer->_cropOffset).y;
*GHIDRA_CAST<ANM2 **>((GHIDRA_CAST<char *>(local_28) + 4 + GHIDRA_INT(self->_layerState))) = self;
local_28 = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(local_28) + 0xa0));
this = self;
} while (local_24 < GHIDRA_UINT(other->_layerCount));
}
ExceptionList = local_1c;
return this;
}
// 00407e90
ANM2 * ANM2::operator_assign(ANM2 other)
{
ANM2 *this_00;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
local_8 = 0xffffffff;
puStack_c = &LAB_00af0a10;
local_10 = ExceptionList;
ExceptionList = &local_10;
Isaac::SwapANM2(this,&other);
local_8 = 0;
Reset(this_00);
(GHIDRA_CAST<AnimationState *>((&other._overlayAnimState)))->AnimationState::~AnimationState();
(GHIDRA_CAST<AnimationState *>((&other._animState)))->AnimationState::~AnimationState();
(GHIDRA_CAST<msvc::string *>((other._animDefaultName._buf)))->msvc::string::_Tidy_deallocate();
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(&other))))->msvc::string::_Tidy_deallocate();
ExceptionList = local_10;
return this;
}
// 00407f10
void ANM2::Reset()
{
uint32_t *ptr;
ANM2 *filenameBuf;
std_string *defaultNameBuf;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
void *layerStates;
local_8 = 0xffffffff;
puStack_c = &LAB_00af0a30;
local_10 = ExceptionList;
ExceptionList = &local_10;
if ((this->_filename)._size != 0) {
AnmCache::RemoveRef(&this->_filename);
}
filenameBuf = this;
if (0xf < (this->_filename)._capacity) {
filenameBuf = *GHIDRA_CAST<ANM2 **>((this->_filename)._buf);
}
(this->_filename)._size = 0;
(filenameBuf->_filename)._buf[0] = '\0';
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::SetAnimationData((void *)0x0);
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::SetAnimationData((void *)0x0);
defaultNameBuf = &this->_animDefaultName;
if (0xf < (this->_animDefaultName)._capacity) {
defaultNameBuf = *GHIDRA_CAST<std_string **>((this->_animDefaultName)._buf);
}
(this->_animDefaultName)._size = 0;
defaultNameBuf->_buf[0] = '\0';
layerStates = this->_layerState;
this->_animData = (void *)0x0;
this->_animCount = 0;
if (layerStates != (void *)0x0) {
ptr = GHIDRA_CAST<uint32_t *>((GHIDRA_INT(layerStates) + -4));
local_8 = 0;
_eh_vector_destructor_iterator_(layerStates,0xa0,*ptr,LayerState::~LayerState);
operator_delete(ptr,*ptr * 0xa0 + 4);
}
this->_layerState = (void *)0x0;
this->_layerCount = 0;
this->_nullLayerNames = (void *)0x0;
this->_numNullLayers = 0;
this->_eventNames = (void *)0x0;
this->_numEvents = 0;
(this->_offset).x = g_vectorZero.x;
(this->_offset).y = g_vectorZero.y;
(this->_scale).x = g_vectorOne.x;
(this->_scale).y = g_vectorOne.y;
this->_rotation = 0.0;
(this->_color)._tint[0] = 1.0;
(this->_color)._tint[1] = 1.0;
(this->_color)._tint[2] = 1.0;
(this->_color)._tint[3] = 1.0;
(this->_color)._colorize[0] = 0.0;
(this->_color)._colorize[1] = 0.0;
(this->_color)._colorize[2] = 0.0;
(this->_color)._colorize[3] = 0.0;
(this->_color)._offset[0] = 0.0;
(this->_color)._offset[1] = 0.0;
(this->_color)._offset[2] = 0.0;
(this->_championColor)._colorize[0] = 0.0;
(this->_championColor)._colorize[1] = 0.0;
(this->_championColor)._colorize[2] = 0.0;
(this->_championColor)._colorize[3] = 0.0;
(this->_championColor)._offset[0] = 0.0;
(this->_championColor)._offset[1] = 0.0;
(this->_championColor)._offset[2] = 0.0;
(this->_championColor)._tint[0] = 1.0;
(this->_championColor)._tint[1] = 1.0;
(this->_championColor)._tint[2] = 1.0;
(this->_championColor)._tint[3] = 0.0;
this->_flipX = 0;
this->_flipY = 0;
this->_playbackSpeed = 1.0;
*GHIDRA_CAST<uint16_t *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x108)))) = 0;
this->_overlayRenderFirst = 0;
this->_shadowLayerIndex = -1;
this->_bitflags = 0;
ExceptionList = local_10;
return;
}
// 00408170
ANM2::~ANM2()
{
void *local_10;
uint8_t *puStack_c;
uint32_t uStack_8;
uStack_8 = 0xffffffff;
puStack_c = &LAB_00af0a50;
local_10 = ExceptionList;
ExceptionList = &local_10;
Reset(this);
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::~AnimationState();
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::~AnimationState();
(GHIDRA_CAST<msvc::string *>(((this->_animDefaultName)._buf)))->msvc::string::_Tidy_deallocate();
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(this))))->msvc::string::_Tidy_deallocate();
ExceptionList = local_10;
return;
}
// 00409100
void ANM2::Update()
{
if (this->_loaded == 0) {
return;
}
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::Update();
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::Update();
return;
}
// 0040a0d0
void ANM2::Render(Vector *position, Vector *topleftclamp, Vector *bottomrightclamp)
{
if (this->_loaded != 0) {
if (this->_overlayRenderFirst != 0) {
AnimationState::Render(&this->_overlayAnimState,position,topleftclamp,bottomrightclamp);
AnimationState::Render(&this->_animState,position,topleftclamp,bottomrightclamp);
return;
}
AnimationState::Render(&this->_animState,position,topleftclamp,bottomrightclamp);
AnimationState::Render(&this->_overlayAnimState,position,topleftclamp,bottomrightclamp);
}
return;
}
// 0040a380
void ANM2::Play(uint8_t *anim, uint8_t reset)
{
uint8_t bVar1;
uint8_t *currentName;
uint32_t compareResult;
uint8_t *wantedName;
bool isLess;
uint8_t *animData;
if ((reset == 0) && (animData = (this->_animState)._animData, animData != GHIDRA_CAST<uint8_t *>(0x0))) {
currentName = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
currentName = *GHIDRA_CAST<uint8_t **>(animData);
}
wantedName = anim;
do {
bVar1 = *currentName;
isLess = bVar1 < *wantedName;
if (bVar1 != *wantedName) {
LAB_0040a3c1:
compareResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_0040a3c6;
}
if (bVar1 == 0) break;
bVar1 = currentName[1];
isLess = bVar1 < wantedName[1];
if (bVar1 != wantedName[1]) goto LAB_0040a3c1;
currentName = currentName + 2;
wantedName = wantedName + 2;
} while (bVar1 != 0);
compareResult = 0;
LAB_0040a3c6:
if (compareResult == 0) {
if (animData[0x34] == 0) {
return;
}
if ((this->_animState)._isPlaying != 0) {
return;
}
}
}
bVar1 = SetAnimation(this,anim,1);
if (bVar1 != 0) {
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::Rewind();
(this->_animState)._isPlaying = 1;
}
return;
}
// 0040a4d0
uint8_t ANM2::IsPlaying(uint8_t *name)
{
uint8_t *animName;
uint32_t compareResult;
bool isLess;
uint8_t nameChar;
animName = (this->_animState)._animData;
if ((animName == GHIDRA_CAST<uint8_t *>(0x0)) || ((this->_animState)._isPlaying == 0)) {
return 0;
}
if (*name != 0) {
if (0xf < *GHIDRA_CAST<uint32_t *>((animName + 0x14))) {
animName = *GHIDRA_CAST<uint8_t **>(animName);
}
do {
nameChar = *animName;
isLess = nameChar < *name;
if (nameChar != *name) {
LAB_0040a510:
compareResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_0040a515;
}
if (nameChar == 0) break;
nameChar = animName[1];
isLess = nameChar < name[1];
if (nameChar != name[1]) goto LAB_0040a510;
animName = animName + 2;
name = name + 2;
} while (nameChar != 0);
compareResult = 0;
LAB_0040a515:
if (compareResult != 0) {
return 0;
}
}
return 1;
}
// 0040a550
uint8_t ANM2::IsFinishedImpl(uint8_t *animName)
{
uint8_t *currentAnimName;
uint32_t compareResult;
bool nameChar;
uint8_t nameChar;
currentAnimName = (this->_animState)._animData;
if (currentAnimName == GHIDRA_CAST<uint8_t *>(0x0)) {
nameChar = *animName == 0;
}
else {
if ((this->_animState)._isPlaying != 0) {
return 0;
}
if (*animName == 0) {
return 1;
}
if (0xf < *GHIDRA_CAST<uint32_t *>((currentAnimName + 0x14))) {
currentAnimName = *GHIDRA_CAST<uint8_t **>(currentAnimName);
}
do {
nameChar = *currentAnimName;
nameChar = nameChar < *animName;
if (nameChar != *animName) {
LAB_0040a598:
compareResult = -GHIDRA_UINT(nameChar) | 1;
goto LAB_0040a59d;
}
if (nameChar == 0) break;
nameChar = currentAnimName[1];
nameChar = nameChar < animName[1];
if (nameChar != animName[1]) goto LAB_0040a598;
currentAnimName = currentAnimName + 2;
animName = animName + 2;
} while (nameChar != 0);
compareResult = 0;
LAB_0040a59d:
nameChar = compareResult == 0;
}
if (nameChar) {
return 1;
}
return 0;
}
// 0040a5d0
uint8_t ANM2::SetAnimation(uint8_t *anim, uint8_t reset)
{
uint8_t *entryNameCursor;
uint32_t compareResult;
uint8_t *queryNameCursor;
uint8_t *animEntry;
uint32_t animIndex;
bool isBelow;
uint8_t nameChar;
animIndex = 0;
if (this->_animCount != 0) {
animEntry = this->_animData;
do {
entryNameCursor = animEntry;
queryNameCursor = anim;
if (0xf < *GHIDRA_CAST<uint32_t *>((animEntry + 0x14))) {
entryNameCursor = *GHIDRA_CAST<uint8_t **>(animEntry);
}
do {
nameChar = *entryNameCursor;
isBelow = nameChar < *queryNameCursor;
if (nameChar != *queryNameCursor) {
LAB_0040a620:
compareResult = -GHIDRA_UINT(isBelow) | 1;
goto LAB_0040a625;
}
if (nameChar == 0) break;
nameChar = entryNameCursor[1];
isBelow = nameChar < queryNameCursor[1];
if (nameChar != queryNameCursor[1]) goto LAB_0040a620;
entryNameCursor = entryNameCursor + 2;
queryNameCursor = queryNameCursor + 2;
} while (nameChar != 0);
compareResult = 0;
LAB_0040a625:
if (compareResult == 0) {
animEntry = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(this->_animData) + animIndex * 0x13c));
if (reset == 0) {
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::ChangeAnimationKeepFrame(animEntry);
return 1;
}
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::SetAnimationData(animEntry);
return 1;
}
animIndex = animIndex + 1;
animEntry = animEntry + 0x13c;
} while (animIndex < GHIDRA_UINT(this->_animCount));
}
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("[warn] no animation named %s\n"));
return 0;
}
// 0040a690
void ANM2::SetFrame(std_string *anim, int frame)
{
uint8_t isAnimationSet;
if (0xf < anim->_capacity) {
anim = *GHIDRA_CAST<std_string **>(anim->_buf);
}
isAnimationSet = SetAnimation(this,GHIDRA_CAST<uint8_t *>(anim),1);
if ((isAnimationSet != 0) && ((this->_animState)._animData != (void *)0x0)) {
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::SetFrameFloat((float)frame);
if ((this->_animState)._animData != (void *)0x0) {
(this->_animState)._isPlaying = 0;
}
}
return;
}
// 0040a780
int ANM2::GetFrame()
{
double frame;
if ((this->_animState)._animData == (void *)0x0) {
return -1;
}
frame = floor((double)(this->_animState)._animFrame);
return GHIDRA_INT(frame);
}
// 0040a7e0
void ANM2::SetLayerFrame(int layerid, int frame)
{
int layerId;
void *animData;
AnimationState *animState;
if ((this->_animState)._animData != (void *)0x0) {
animState = &this->_animState;
if (((layerid < 0) || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animState->_animation) + 0x80)) <= layerid)) &&
(KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("LayerId out of bounds\n")), layerid < 0)) {
return;
}
if (layerid < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animState->_animation) + 0x80))) {
animData = (this->_animState)._animData;
layerId = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + layerid * 4 + 0x38));
if (((animData == (void *)0x0) || (layerId < 0)) ||
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animData) + 0x1c)) <= layerId)) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("id out of bounds\n"));
}
*GHIDRA_CAST<uint32_t *>((GHIDRA_INT((this->_animState)._layerFrames) + layerId * 4)) = 0;
(GHIDRA_CAST<AnimationState *>((animState)))->AnimationState::AdvanceLayerPosition(layerId,(float)frame);
}
}
return;
}
// 0040a940
void ANM2::PlayOverlay(uint8_t *animName, uint8_t isForce)
{
uint8_t bVar1;
uint8_t *curNameCursor;
uint32_t cmpResult;
uint8_t *targetNameCursor;
bool isLess;
uint8_t *overlayAnimData;
if ((isForce == 0) &&
(overlayAnimData = (this->_overlayAnimState)._animData, overlayAnimData != GHIDRA_CAST<uint8_t *>(0x0))) {
curNameCursor = overlayAnimData;
if (0xf < *GHIDRA_CAST<uint32_t *>((overlayAnimData + 0x14))) {
curNameCursor = *GHIDRA_CAST<uint8_t **>(overlayAnimData);
}
targetNameCursor = animName;
do {
bVar1 = *curNameCursor;
isLess = bVar1 < *targetNameCursor;
if (bVar1 != *targetNameCursor) {
LAB_0040a981:
cmpResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_0040a986;
}
if (bVar1 == 0) break;
bVar1 = curNameCursor[1];
isLess = bVar1 < targetNameCursor[1];
if (bVar1 != targetNameCursor[1]) goto LAB_0040a981;
curNameCursor = curNameCursor + 2;
targetNameCursor = targetNameCursor + 2;
} while (bVar1 != 0);
cmpResult = 0;
LAB_0040a986:
if (cmpResult == 0) {
if (overlayAnimData[0x34] == 0) {
return;
}
if ((this->_overlayAnimState)._isPlaying != 0) {
return;
}
}
}
bVar1 = SetOverlayAnimation(this,animName,1);
if (bVar1 != 0) {
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::Rewind();
(this->_overlayAnimState)._isPlaying = 1;
}
return;
}
// 0040aaf0
uint8_t ANM2::SetOverlayAnimation(uint8_t *anim, uint8_t reset)
{
uint8_t *entryNameCursor;
uint32_t nameCompare;
uint8_t *wantedNameCursor;
uint8_t *pbVar1;
uint32_t animIndex;
bool isNameLess;
uint8_t nameChar;
animIndex = 0;
if (this->_animCount != 0) {
pbVar1 = this->_animData;
do {
entryNameCursor = pbVar1;
wantedNameCursor = anim;
if (0xf < *GHIDRA_CAST<uint32_t *>((pbVar1 + 0x14))) {
entryNameCursor = *GHIDRA_CAST<uint8_t **>(pbVar1);
}
do {
nameChar = *entryNameCursor;
isNameLess = nameChar < *wantedNameCursor;
if (nameChar != *wantedNameCursor) {
LAB_0040ab40:
nameCompare = -GHIDRA_UINT(isNameLess) | 1;
goto LAB_0040ab45;
}
if (nameChar == 0) break;
nameChar = entryNameCursor[1];
isNameLess = nameChar < wantedNameCursor[1];
if (nameChar != wantedNameCursor[1]) goto LAB_0040ab40;
entryNameCursor = entryNameCursor + 2;
wantedNameCursor = wantedNameCursor + 2;
} while (nameChar != 0);
nameCompare = 0;
LAB_0040ab45:
if (nameCompare == 0) {
pbVar1 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(this->_animData) + animIndex * 0x13c));
if (reset == 0) {
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::ChangeAnimationKeepFrame(pbVar1);
return 1;
}
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::SetAnimationData(pbVar1);
return 1;
}
animIndex = animIndex + 1;
pbVar1 = pbVar1 + 0x13c;
} while (animIndex < GHIDRA_UINT(this->_animCount));
}
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("[warn] no animation named %s\n"));
return 0;
}
// 0040abf0
void ANM2::SetOverlayFrame(uint8_t *anim, int frame)
{
uint8_t isAnimationSet;
isAnimationSet = SetOverlayAnimation(this,anim,1);
if ((isAnimationSet != 0) && ((this->_overlayAnimState)._animData != (void *)0x0)) {
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::SetFrameFloat((float)frame);
}
return;
}
// 0040ac30
void ANM2::SetOverlayFrame(int frame)
{
if ((this->_overlayAnimState)._animData != (void *)0x0) {
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::SetFrameFloat((float)frame);
}
return;
}
// 0040b090
uint8_t ANM2::WasEventTriggered(uint8_t *eventName)
{
uint8_t isTriggered;
if ((this->_animState)._animData == (void *)0x0) {
return 0;
}
isTriggered = (GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::WasEventTriggered(eventName);
return isTriggered;
}
// 0040b0c0
void * ANM2::GetNullFrame(uint8_t *animName, uint8_t *nullLayerName, int frame)
{
void *animData;
uint8_t *layerNameChar;
uint32_t nullLayerIdx;
uint8_t *nullNameChar;
uint32_t compareResult;
uint32_t *nullAnim;
uint32_t foundIdx;
uint32_t i;
bool isLess;
uint8_t currentChar;
animData = GetAnimationData(this,animName);
if (animData != (void *)0x0) {
i = 0;
if (this->_numNullLayers != 0) {
foundIdx = 0xffffffff;
do {
layerNameChar = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(this->_nullLayerNames) + i * 0x18));
if (0xf < *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this->_nullLayerNames) + i * 0x18 + 0x14))) {
layerNameChar = *GHIDRA_CAST<uint8_t **>(layerNameChar);
}
nullNameChar = nullLayerName;
do {
currentChar = *layerNameChar;
isLess = currentChar < *nullNameChar;
if (currentChar != *nullNameChar) {
LAB_0040b132:
compareResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_0040b137;
}
if (currentChar == 0) break;
currentChar = layerNameChar[1];
isLess = currentChar < nullNameChar[1];
if (currentChar != nullNameChar[1]) goto LAB_0040b132;
layerNameChar = layerNameChar + 2;
nullNameChar = nullNameChar + 2;
} while (currentChar != 0);
compareResult = 0;
LAB_0040b137:
nullLayerIdx = i;
if (compareResult != 0) {
nullLayerIdx = foundIdx;
}
i = i + 1;
foundIdx = nullLayerIdx;
} while (i < GHIDRA_UINT(this->_numNullLayers));
if (-1 < GHIDRA_INT(nullLayerIdx)) {
i = 0;
if (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(animData) + 0x24)) != 0) {
nullAnim = *GHIDRA_CAST<uint32_t **>((GHIDRA_CAST<char *>(animData) + 0x20));
do {
if (((*nullAnim == nullLayerIdx) && (-1 < frame)) && (frame < GHIDRA_INT(nullAnim[3]))) {
return (void *)(frame * 0x54 + nullAnim[2]);
}
i = i + 1;
nullAnim = nullAnim + 4;
} while (i < *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(animData) + 0x24)));
}
KAGE_LogMessage(1,GHIDRA_CAST<uint8_t *>("[warn] ANM2::GetNullFrame frame number %d out of bounds.\n"));
}
}
}
return (void *)0x0;
}
// 0040b1a0
void * ANM2::GetLayerFrame(int nullLayerId)
{
void *nullFrame;
if ((this->_animState)._animData == (void *)0x0) {
return (void *)0x0;
}
nullFrame = (GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::GetNullFrameById(nullLayerId);
return nullFrame;
}
// 0040b220
LayerState * ANM2::GetLayer(uint8_t *layerName)
{
uint32_t stackCookie;
void *local_10;
uint8_t *puStack_c;
uint32_t uStack_8;
uStack_8 = 0xffffffff;
puStack_c = &LAB_00af0c31;
local_10 = ExceptionList;
stackCookie = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U;
ExceptionList = &local_10;
if (((-1 < GHIDRA_INT(layerName)) && (GHIDRA_INT(layerName) < this->_layerCount)) ||
((KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("%s: No layer with Id %d\n")), -1 < GHIDRA_INT(layerName) &&
(GHIDRA_INT(layerName) < this->_layerCount)))) {
ExceptionList = local_10;
return GHIDRA_CAST<LayerState *>((GHIDRA_INT(layerName) * 0xa0 + GHIDRA_INT(this->_layerState)));
}
if ((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>(ThreadLocalStoragePointer) + 0xc)) < _DAT_00c7f628) &&
(_Init_thread_header(&DAT_00c7f628,stackCookie), _DAT_00c7f628 == -1)) {
uStack_8 = 0;
(GHIDRA_CAST<LayerState *>((GHIDRA_CAST<LayerState *>(0xc7f630))))->LayerState::LayerState();
_atexit(FUN_00b15190);
_Init_thread_footer(&DAT_00c7f628);
}
ExceptionList = local_10;
return GHIDRA_CAST<LayerState *>(0xc7f630);
}
// 0040b310
LayerState * ANM2::get_layer_by_string(std_string *name)
{
uint8_t isMatch;
std_string *wantedText;
uint8_t ****ppppbVar1;
uint32_t layerIdx;
uint32_t size;
int layerOffset;
uint8_t ****layerName [4];
uint32_t layerNameSize;
uint32_t layerNameCapacity;
uint32_t local_c;
uint8_t auStack_8 [4];
int layerData;
uint8_t ****layerNameBuffer;
uint32_t savedCapacity;
local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4));
layerIdx = 0;
if (this->_layerCount != 0) {
layerOffset = 0;
do {
layerData = *GHIDRA_CAST<int *>((layerOffset + GHIDRA_INT(this->_layerState)));
if (layerData == 0) {
layerName[0] = GHIDRA_CAST<uint8_t ****>(0x0);
layerNameCapacity = 0xf;
layerNameSize = 0;
}
else {
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(layerName))))->msvc::string::string((void *)(layerData + 8));
}
savedCapacity = layerNameCapacity;
layerNameBuffer = layerName[0];
wantedText = name;
if (0xf < name->_capacity) {
wantedText = *GHIDRA_CAST<std_string **>(name->_buf);
}
ppppbVar1 = GHIDRA_CAST<uint8_t ****>(layerName);
if (0xf < layerNameCapacity) {
ppppbVar1 = layerName[0];
}
isMatch = str_eq(GHIDRA_CAST<uint8_t *>(ppppbVar1),layerNameSize,GHIDRA_CAST<uint8_t *>(wantedText),name->_size);
if (0xf < savedCapacity) {
size = savedCapacity + 1;
ppppbVar1 = layerNameBuffer;
if (0xfff < size) {
ppppbVar1 = GHIDRA_CAST<uint8_t ****>(layerNameBuffer[-1]);
size = savedCapacity + 0x24;
if (GHIDRA_CAST<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>((GHIDRA_INT(layerNameBuffer) + (-4 - GHIDRA_INT(ppppbVar1))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(ppppbVar1,size);
}
if (isMatch != 0) {
return GHIDRA_CAST<LayerState *>((layerIdx * 0xa0 + GHIDRA_INT(this->_layerState)));
}
layerIdx = layerIdx + 1;
layerOffset = layerOffset + 0xa0;
} while (layerIdx < GHIDRA_UINT(this->_layerCount));
}
return GHIDRA_CAST<LayerState *>(0x0);
}
// 0040b600
KColor * ANM2::GetTexel(AnimationState *anim, KColor *outColor, int layerId, Vector samplePos, Vector renderPos, float alphaThreshold)
{
uint8_t *layerName;
AnimationState *pAVar1;
char isLastRef;
LayerState *layerState;
float *textureRef;
uint32_t *sampleTextureRef;
void *extraout_ECX;
void *extraout_ECX_00;
void *pvVar2;
KColor *extraout_ECX_01;
float fVar3;
float scaleY;
float spriteScaleY;
float fVar4;
float scaleX;
Color layerColor;
uint32_t uStack_1bc;
SourceQuad screenQuad;
float local_120;
float local_11c;
SourceQuad sourceQuad;
KColor texel;
uint8_t sampleTexture [4];
int *sampleTextureRefCount;
uint8_t texture [4];
int *textureRefCount;
float quadMaxX;
float local_cc;
float local_c8;
float local_c4;
float local_c0;
KColor *outColorLocal;
uint32_t layerIdx;
float alphaThresholdLocal;
int layerOffset;
float local_a8;
AnimationState *animState;
float local_a0;
float local_9c;
AnimationFrame frame;
uint32_t stackCookie;
uint8_t *puStack_20;
void *savedExceptionList;
uint8_t *puStack_18;
uint32_t ehState;
int layerAnim;
puStack_20 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
ehState = 0xffffffff;
puStack_18 = &LAB_00af0c80;
savedExceptionList = ExceptionList;
stackCookie = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
ExceptionList = &savedExceptionList;
outColorLocal = outColor;
alphaThresholdLocal = alphaThreshold;
animState = anim;
(GHIDRA_CAST<KColor *>((&texel)))->KColor::SetFromARGB(0);
pvVar2 = animState->_animData;
if ((pvVar2 != (void *)0x0) && (layerIdx = 0, *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0x1c)) != 0)) {
layerOffset = 0;
do {
layerAnim = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0x18)) + 4 + layerOffset));
if ((layerAnim != 0) &&
((layerName = *GHIDRA_CAST<uint8_t **>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar2) + 0x18)) + layerOffset)), layerId < 0 ||
(layerName == GHIDRA_CAST<uint8_t *>(layerId))))) {
AnimationState::copy_assign
(GHIDRA_CAST<AnimationState *>(&frame),
(AnimationState *)
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(animState->_layerFrames) + layerIdx * 4)) * 0x6c + layerAnim));
pAVar1 = animState;
layerState = GetLayer(animState->_animation,layerName);
if ((frame.visible != 0) && (layerState->_visible != 0)) {
textureRef = (GHIDRA_CAST<LayerState *>((layerState)))->LayerState::GetTexture(texture);
local_a8 = *textureRef;
ehState = 0;
pvVar2 = (void *)0x0;
if (textureRefCount != GHIDRA_CAST<int *>(0x0)) {
isLastRef = (**(code **)(*textureRefCount + 0xc))();
pvVar2 = extraout_ECX;
if ((isLastRef != '\0') && (g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)();
pvVar2 = extraout_ECX_00;
}
}
ehState = 0xffffffff;
if (local_a8 != 0.0) {
uStack_1bc = 0x40b768;
AnimationLayer::GetSourceQuad
(&sourceQuad,pvVar2,&frame,layerState,&g_vectorZero,&g_vectorZero,
pAVar1->_animation);
uStack_1bc = 0x40b78c;
render_build_sprite_quad
(&screenQuad,&renderPos,&frame,layerState,&g_vectorZero,&g_vectorZero,
pAVar1->_animation);
pvVar2 = pAVar1->_animation;
fVar3 = frame.rotation + layerState->_rotation;
fVar4 = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(pvVar2) + 0xa4));
if ((fVar4 != 0.0) || (fVar3 != 0.0)) {
scaleX = frame.scale.x * (layerState->_size).x;
spriteScaleY = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(pvVar2) + 0xa0));
scaleY = frame.scale.y * (layerState->_size).y;
if (*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(pvVar2) + 0x9c)) < 0.0 != scaleX < 0.0) {
if (*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(pvVar2) + 0x9c)) < 0.0) {
fVar3 = -fVar3;
fVar4 = -fVar4;
}
if (scaleX < 0.0) {
fVar3 = -fVar3;
}
}
if (layerState->_flipY != 0) {
scaleY = -scaleY;
}
if (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(pvVar2) + 0x101)) != '\0') {
spriteScaleY = -spriteScaleY;
}
if (spriteScaleY < 0.0 != scaleY < 0.0) {
if (spriteScaleY < 0.0) {
fVar3 = -fVar3;
fVar4 = -fVar4;
}
if (scaleY < 0.0) {
fVar3 = -fVar3;
}
}
local_a0 = -(fVar3 + fVar4) * 0.017453292;
(GHIDRA_CAST<Quad *>((&screenQuad)))->Quad::rotate(&g_vectorZero,local_a0);
local_9c = cos(local_a0);
fVar4 = sin(local_a0);
fVar3 = fVar4 * samplePos.x;
samplePos.x = local_9c * samplePos.x - fVar4 * samplePos.y;
samplePos.y = local_9c * samplePos.y + fVar3;
}
local_a0 = samplePos.x;
local_9c = samplePos.y;
if ((((screenQuad._topLeft.x < samplePos.x) &&
(quadMaxX = screenQuad._bottomRight.x, samplePos.x < screenQuad._bottomRight.x)) &&
(screenQuad._topLeft.y < samplePos.y)) &&
(local_a8 = screenQuad._bottomRight.y, samplePos.y < screenQuad._bottomRight.y)) {
if (screenQuad._topLeft.x == screenQuad._bottomRight.x) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Start and End parameters cannot be the same!"));
local_9c = samplePos.y;
}
fVar4 = (local_a0 - screenQuad._topLeft.x) / (quadMaxX - screenQuad._topLeft.x);
if (fVar4 <= 0.0) {
fVar4 = 0.0;
}
if (1.0 <= fVar4) {
fVar4 = 1.0;
}
samplePos.x = (sourceQuad._bottomRight.x - sourceQuad._topLeft.x) * fVar4 +
sourceQuad._topLeft.x;
if (screenQuad._topLeft.y == local_a8) {
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Start and End parameters cannot be the same!"));
}
fVar4 = (local_9c - screenQuad._topLeft.y) / (local_a8 - screenQuad._topLeft.y);
if (fVar4 <= 0.0) {
fVar4 = 0.0;
}
if (1.0 <= fVar4) {
fVar4 = 1.0;
}
samplePos.y = (sourceQuad._bottomRight.y - sourceQuad._topLeft.y) * fVar4 +
sourceQuad._topLeft.y;
sampleTextureRef = (GHIDRA_CAST<LayerState *>((layerState)))->LayerState::GetTexture(sampleTexture);
ehState = 1;
(**(code **)(*GHIDRA_CAST<int *>(*sampleTextureRef) + 0x2c))();
ehState = 2;
if (((sampleTextureRefCount != GHIDRA_CAST<int *>(0x0)) &&
(isLastRef = (**(code **)(*sampleTextureRefCount + 0xc))(), isLastRef != '\0')) &&
(g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)();
}
ehState = 0xffffffff;
if (alphaThresholdLocal <= local_c0) {
(GHIDRA_CAST<Color *>((&layerColor)))->Color::operator_assign(GHIDRA_CAST<ColorMod *>((GHIDRA_INT(animState->_animation) + 0xa8)));
FUN_004072e0();
layerColor._offset[2] = 5.944584e-39;
FUN_004072e0();
local_cc = local_120 * local_cc + sourceQuad._bottomRight.x;
local_c8 = local_11c * local_c8 + sourceQuad._bottomRight.y;
local_c4 = sourceQuad._topLeft.x * local_c4 + (float)sourceQuad._coordinateSpace;
local_c0 = sourceQuad._topLeft.y * local_c0;
FUN_00a0f720();
ExceptionList = savedExceptionList;
return extraout_ECX_01;
}
}
}
}
}
layerOffset = layerOffset + 0x10;
layerIdx = layerIdx + 1;
pvVar2 = animState->_animData;
} while (layerIdx < *GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(pvVar2) + 0x1c)));
outColor = outColorLocal;
}
outColor->_unk = texel._unk;
outColor->_red = texel._red;
outColor->_green = texel._green;
outColor->_blue = texel._blue;
outColor->_alpha = texel._alpha;
ExceptionList = savedExceptionList;
return outColor;
}
// 0040bcd0
void * ANM2::GetAnimationData(uint8_t *name)
{
uint8_t bVar1;
uint8_t *animNameCursor;
uint32_t cmpResult;
uint8_t *targetNameCursor;
uint8_t *animEntry;
uint32_t animIdx;
bool isLess;
animIdx = 0;
if (this->_animCount != 0) {
animEntry = this->_animData;
do {
animNameCursor = animEntry;
if (0xf < *GHIDRA_CAST<uint32_t *>((animEntry + 0x14))) {
animNameCursor = *GHIDRA_CAST<uint8_t **>(animEntry);
}
targetNameCursor = name;
do {
bVar1 = *animNameCursor;
isLess = bVar1 < *targetNameCursor;
if (bVar1 != *targetNameCursor) {
LAB_0040bd15:
cmpResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_0040bd1a;
}
if (bVar1 == 0) break;
bVar1 = animNameCursor[1];
isLess = bVar1 < targetNameCursor[1];
if (bVar1 != targetNameCursor[1]) goto LAB_0040bd15;
animNameCursor = animNameCursor + 2;
targetNameCursor = targetNameCursor + 2;
} while (bVar1 != 0);
cmpResult = 0;
LAB_0040bd1a:
if (cmpResult == 0) {
return GHIDRA_CAST<uint8_t *>((GHIDRA_INT(this->_animData) + animIdx * 0x13c));
}
animIdx = animIdx + 1;
animEntry = animEntry + 0x13c;
} while (animIdx < GHIDRA_UINT(this->_animCount));
}
return (void *)0x0;
}
// 0040bd50
void ANM2::Load(std_string *ANM2Path, uint8_t loadgraphics)
{
uint8_t bVar1;
std_string *pathText;
int *layerState;
uint8_t *nameCursor;
uint32_t compareResult;
uint8_t unk;
char *pcVar2;
char *nullLayerName;
int iVar3;
uint32_t layerIdx;
uint8_t *layerName;
bool bVar4;
uint32_t *layerFlags;
if ((this->_filename)._size != 0) {
AnmCache::RemoveRef(&this->_filename);
}
if (this != GHIDRA_CAST<ANM2 *>(ANM2Path)) {
pathText = ANM2Path;
if (0xf < ANM2Path->_capacity) {
pathText = *GHIDRA_CAST<std_string **>(ANM2Path->_buf);
}
(GHIDRA_CAST<msvc::string *>((GHIDRA_CAST<char *>(this))))->msvc::string::assign(GHIDRA_CAST<uint8_t *>(pathText),ANM2Path->_size);
}
AnmCache::Load(ANM2Path,this);
AnmCache::AddRef(ANM2Path);
if (loadgraphics != 0) {
LoadGraphics(this,unk);
}
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::SetAnimationData((void *)0x0);
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::SetAnimationData((void *)0x0);
layerIdx = 0;
this->_loaded = 1;
this->_shadowLayerIndex = -1;
if (this->_layerCount != 0) {
_loadgraphics = 0;
do {
layerState = GHIDRA_CAST<int *>((GHIDRA_INT(this->_layerState) + _loadgraphics));
iVar3 = *layerState;
if (iVar3 == 0) {
layerName = &s_empty;
}
else {
layerName = GHIDRA_CAST<uint8_t *>((iVar3 + 8));
if (0xf < *GHIDRA_CAST<uint32_t *>((iVar3 + 0x1c))) {
layerName = *GHIDRA_CAST<uint8_t **>(layerName);
}
}
pcVar2 = "shadow";
nameCursor = layerName;
do {
bVar1 = *nameCursor;
bVar4 = bVar1 < (uint8_t)*pcVar2;
if (bVar1 != *pcVar2) {
LAB_0040be20:
compareResult = -GHIDRA_UINT(bVar4) | 1;
goto LAB_0040be25;
}
if (bVar1 == 0) break;
bVar1 = nameCursor[1];
bVar4 = bVar1 < (uint8_t)pcVar2[1];
if (bVar1 != pcVar2[1]) goto LAB_0040be20;
nameCursor = nameCursor + 2;
pcVar2 = pcVar2 + 2;
} while (bVar1 != 0);
compareResult = 0;
LAB_0040be25:
if (compareResult == 0) {
this->_shadowLayerIndex = layerIdx;
}
else if (*layerName == 0x2a) {
layerFlags = GHIDRA_CAST<uint32_t *>((layerState + 0x23));
*layerFlags = *layerFlags | 5;
this->_bitflags = this->_bitflags | 0x400;
}
layerIdx = layerIdx + 1;
_loadgraphics = _loadgraphics + 0xa0;
} while (layerIdx < GHIDRA_UINT(this->_layerCount));
}
iVar3 = this->_numNullLayers;
if (iVar3 != 0) {
pcVar2 = this->_nullLayerNames;
do {
nullLayerName = pcVar2;
if (0xf < *GHIDRA_CAST<uint32_t *>((pcVar2 + 0x14))) {
nullLayerName = *GHIDRA_CAST<char **>(pcVar2);
}
if (*nullLayerName == '*') {
this->_bitflags = this->_bitflags | 0x800;
}
pcVar2 = pcVar2 + 0x18;
iVar3 = iVar3 + -1;
} while (iVar3 != 0);
}
return;
}
// 0040bea0
void ANM2::Reload()
{
uint8_t unk;
if ((this->_filename)._size != 0) {
AnmCache::Load(this,this);
AnmCache::AddRef(&this->_filename);
LoadGraphics(this,unk);
}
return;
}
// 0040c000
void ANM2::LoadGraphics(uint8_t unk)
{
char cVar1;
uint8_t *pbVar2;
int layerOffset;
uint8_t auStackY_dc [128];
uint32_t **outImage;
uint32_t *texture;
void *pvVar3;
int *piVar4;
int oldTexture;
int *oldTextureRefCount;
uint32_t *image;
int *imageRefCount;
LayerState *layerState;
uint32_t *imageCopy;
int *imageRefCountCopy;
ANM2 *savedThis;
uint32_t layerIdx;
uint8_t isLoaded;
void *local_10;
uint8_t *puStack_c;
uint32_t local_8;
void *layerStates;
puStack_c = &LAB_00af0cc5;
local_10 = ExceptionList;
ExceptionList = &local_10;
layerIdx = 0;
if (this->_layerCount != 0) {
layerOffset = 0;
savedThis = this;
do {
local_8 = 0xffffffff;
if (*GHIDRA_CAST<char *>((layerOffset + 0x30 + GHIDRA_INT(this->_layerState))) == '\0') {
pbVar2 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(this->_layerState) + layerOffset + 8));
if (0xf < *GHIDRA_CAST<uint32_t *>((pbVar2 + 0x14))) {
pbVar2 = *GHIDRA_CAST<uint8_t **>(pbVar2);
}
outImage = &image;
Manager::LoadImage(outImage,pbVar2);
local_8 = 0;
if (image == GHIDRA_CAST<uint32_t *>(0x0)) {
LAB_0040c096:
isLoaded = 0;
}
else {
pvVar3 = (void *)0x40c079;
cVar1 = (**(code **)*image)();
if (cVar1 == '\0') goto LAB_0040c096;
isLoaded = 1;
(GHIDRA_CAST<KAGE::SmartPointer *>((auStackY_dc + 0x84)))->KAGE::SmartPointer::operator_assign(&image);
TextureCache::Add(outImage,pvVar3);
}
piVar4 = &oldTexture;
pvVar3 = (void *)0x40c0a8;
(GHIDRA_CAST<LayerState *>((GHIDRA_CAST<LayerState *>((GHIDRA_INT(this->_layerState) + layerOffset)))))->LayerState::GetTexture(piVar4);
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1);
if (oldTexture != 0) {
layerStates = this->_layerState;
pbVar2 = *GHIDRA_CAST<uint8_t **>((oldTexture + 0x44));
(GHIDRA_CAST<KAGE::SmartPointer *>((auStackY_dc + 0x84)))->KAGE::SmartPointer::SmartPointer((void *)0x0);
(GHIDRA_CAST<LayerState *>((GHIDRA_CAST<LayerState *>((GHIDRA_INT(layerStates) + layerOffset)))))->LayerState::SetTexture(pvVar3,piVar4);
TextureCache::Release(pbVar2);
this = savedThis;
}
layerState = GHIDRA_CAST<LayerState *>((GHIDRA_INT(this->_layerState) + layerOffset));
texture = GHIDRA_CAST<uint32_t *>(0x0);
piVar4 = GHIDRA_CAST<int *>(0x0);
imageRefCountCopy = imageRefCount;
imageCopy = image;
if (imageRefCount != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*imageRefCount + 4))();
if (cVar1 != '\0') {
if (((piVar4 != GHIDRA_CAST<int *>(0x0)) && (cVar1 = (**(code **)(*piVar4 + 0xc))(), cVar1 != '\0'))
&& (g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)(auStackY_dc + 0x84);
}
texture = imageCopy;
piVar4 = imageRefCountCopy;
}
}
(GHIDRA_CAST<LayerState *>((layerState)))->LayerState::SetTexture(texture,piVar4);
*GHIDRA_CAST<uint8_t *>((layerOffset + 0x30 + GHIDRA_INT(this->_layerState))) = isLoaded;
*GHIDRA_CAST<uint8_t *>((layerOffset + 0x31 + GHIDRA_INT(this->_layerState))) = 0;
local_8 = CONCAT31((*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),2);
if (((oldTextureRefCount != GHIDRA_CAST<int *>(0x0)) &&
(cVar1 = (**(code **)(*oldTextureRefCount + 0xc))(), cVar1 != '\0')) &&
(g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)();
}
local_8 = 3;
if (((imageRefCount != GHIDRA_CAST<int *>(0x0)) &&
(cVar1 = (**(code **)(*imageRefCount + 0xc))(), cVar1 != '\0')) &&
(g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)();
}
}
layerIdx = layerIdx + 1;
layerOffset = layerOffset + 0xa0;
} while (layerIdx < GHIDRA_UINT(this->_layerCount));
}
ExceptionList = local_10;
return;
}
// 00452bf0
std_string * ANM2::GetAnimation(std_string *outName)
{
void *animData;
animData = *(void **)((this->_filename)._buf + 4);
if (animData == (void *)0x0) {
outName->_buf[0] = '\0';
outName->_buf[1] = '\0';
outName->_buf[2] = '\0';
outName->_buf[3] = '\0';
outName->_size = 0;
outName->_capacity = 0xf;
outName->_buf[0] = '\0';
outName->_size = 0;
outName->_buf[0] = '\0';
return outName;
}
(GHIDRA_CAST<msvc::string *>((outName->_buf)))->msvc::string::string(animData);
return outName;
}
// 004a5d10
void ANM2::LoadDeliriumForm(ANM2 *sprite, int type, int variant, uint8_t isReloadAnm2)
{
char *_Dst;
uint32_t uVar1;
uint32_t uVar2;
uint8_t *puVar3;
EntityConfig_Entity *entityConfig;
LayerState *pLVar4;
int iVar5;
std_string *psVar6;
uint8_t *pbVar7;
uint8_t extraout_CL;
uint8_t extraout_CL_00;
uint8_t extraout_CL_01;
uint8_t extraout_CL_02;
uint8_t extraout_CL_03;
uint8_t extraout_CL_04;
ANM2 *extraout_ECX;
ANM2 *extraout_ECX_00;
ANM2 *pAVar8;
uint32_t uVar9;
char *_Src;
uint32_t uVar10;
size_t tailLen;
std_string *ptr;
uint32_t uVar11;
uint32_t replacedLen;
uint32_t newCapacity;
uint8_t bVar12;
uint8_t *layerIdx;
std_string sheetPath;
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_00af305d;
local_1c = ExceptionList;
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
ExceptionList = &local_1c;
pAVar8 = sprite;
puVar3 = GHIDRA_CAST<uint8_t *>((GHIDRA_INT(register0x00000010) + -4));
if (isReloadAnm2 != 0) {
entityConfig = (GHIDRA_CAST<EntityConfig *>((&g_manager->_entityConfig)))->EntityConfig::GetEntity(type,variant,0);
pAVar8 = extraout_ECX;
puVar3 = puStack_20;
if (entityConfig != GHIDRA_CAST<EntityConfig_Entity *>(0x0)) {
Load(sprite,&entityConfig->anm2Path,0);
pAVar8 = extraout_ECX_00;
puVar3 = puStack_20;
}
}
puStack_20 = puVar3;
bVar12 = (uint8_t)pAVar8;
layerIdx = GHIDRA_CAST<uint8_t *>(0x0);
if (sprite->_layerCount != 0) {
do {
pLVar4 = GetLayer(sprite,layerIdx);
sheetPath._buf[0] = '\0';
sheetPath._buf[1] = '\0';
sheetPath._buf[2] = '\0';
sheetPath._buf[3] = '\0';
sheetPath._size = 0;
sheetPath._capacity = 0;
psVar6 = &pLVar4->_spriteSheetPath;
uVar11 = (pLVar4->_spriteSheetPath)._size;
if (0xf < (pLVar4->_spriteSheetPath)._capacity) {
psVar6 = *GHIDRA_CAST<std_string **>(psVar6->_buf);
}
if (uVar11 < 0x10) {
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x0))) = *GHIDRA_CAST<uint32_t *>(psVar6->_buf);
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x4))) = *GHIDRA_CAST<uint32_t *>((psVar6->_buf + 4));
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x8))) = *GHIDRA_CAST<uint32_t *>((psVar6->_buf + 8));
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0xc))) = *GHIDRA_CAST<uint32_t *>((psVar6->_buf + 0xc));
uVar10 = 0xf;
bVar12 = extraout_CL;
}
else {
uVar10 = uVar11 | 0xf;
if (0x7fffffff < uVar10) {
uVar10 = 0x7fffffff;
}
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x0))) = msvc::_Allocate(uVar10 + 1);
memcpy((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&((void *)sheetPath._buf)) + 0x0))),psVar6,uVar11 + 1);
bVar12 = extraout_CL_00;
}
local_14 = 0;
sheetPath._size = uVar11;
sheetPath._capacity = uVar10;
if (type != 0x19c) {
psVar6 = &sheetPath;
if (0xf < uVar10) {
psVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(sheetPath._buf))) + 0x0)));
}
iVar5 = _strnicmp(psVar6->_buf + 4,"bosses",6);
uVar10 = sheetPath._capacity;
uVar11 = sheetPath._size;
if (iVar5 == 0) {
if (sheetPath._size < 4) {
/* WARNING: Subroutine does not return */
FUN_00499950();
}
replacedLen = 6;
if (sheetPath._size - 4 < 6) {
replacedLen = sheetPath._size - 4;
}
if (replacedLen == 0x23) {
psVar6 = &sheetPath;
if (0xf < sheetPath._capacity) {
psVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(sheetPath._buf))) + 0x0)));
}
memmove(psVar6->_buf + 4,"Bosses/AfterbirthPlus/DeliriumForms",0x23);
LAB_004a609a:
}
else {
tailLen = (sheetPath._size - replacedLen) - 3;
if (0x23 < replacedLen) {
sheetPath._size = (sheetPath._size - replacedLen) + 0x23;
psVar6 = &sheetPath;
if (0xf < sheetPath._capacity) {
psVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(sheetPath._buf))) + 0x0)));
}
memmove(psVar6->_buf + 4,"Bosses/AfterbirthPlus/DeliriumForms",0x23);
memmove(psVar6[1]._buf + 0xf,psVar6->_buf + 4 + replacedLen,tailLen);
goto LAB_004a609a;
}
uVar9 = -replacedLen + 0x23;
if (uVar9 <= sheetPath._capacity - sheetPath._size) {
psVar6 = &sheetPath;
if (0xf < sheetPath._capacity) {
psVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(sheetPath._buf))) + 0x0)));
}
_Src = psVar6->_buf + replacedLen + 4;
_Dst = psVar6->_buf + 4;
if ((GHIDRA_CAST<uint8_t *>(0xb1e25e) < _Dst) ||
(psVar6->_buf + sheetPath._size < "Bosses/AfterbirthPlus/DeliriumForms")) {
pbVar7 = &DAT_00000023;
}
else if ("Bosses/AfterbirthPlus/DeliriumForms" < _Src) {
pbVar7 = GHIDRA_CAST<uint8_t *>((_Src + -0xb1e23c));
}
else {
pbVar7 = GHIDRA_CAST<uint8_t *>(0x0);
}
sheetPath._size = sheetPath._size + uVar9;
memmove(_Src + uVar9,_Src,tailLen);
memmove(_Dst,"Bosses/AfterbirthPlus/DeliriumForms",(size_t)pbVar7);
memcpy(pbVar7 + GHIDRA_INT(_Dst),
pbVar7 + GHIDRA_INT(("Bosses/AfterbirthPlus/DeliriumForms" + -replacedLen + 0x23)),
0x23 - GHIDRA_INT(pbVar7));
goto LAB_004a609a;
}
if (0x7fffffff - sheetPath._size < uVar9) {
/* WARNING: Subroutine does not return */
msvc::string::_Xlen();
}
uVar9 = uVar9 + sheetPath._size;
newCapacity = uVar9 | 0xf;
if (newCapacity < 0x80000000) {
if (0x7fffffff - (sheetPath._capacity >> 1) < sheetPath._capacity) {
newCapacity = 0x7fffffff;
}
else {
uVar1 = sheetPath._capacity + (sheetPath._capacity >> 1);
if (newCapacity < uVar1) {
newCapacity = uVar1;
}
}
}
else {
newCapacity = 0x7fffffff;
}
psVar6 = msvc::_Allocate(newCapacity + 1);
uVar2 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x0)));
tailLen = (uVar11 - replacedLen) - 3;
sheetPath._size = uVar9;
sheetPath._capacity = newCapacity;
if (uVar10 < 0x10) {
*GHIDRA_CAST<uint32_t *>(psVar6->_buf) = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x0)));
psVar6->_buf[4] = 'B';
psVar6->_buf[5] = 'o';
psVar6->_buf[6] = 's';
psVar6->_buf[7] = 's';
psVar6->_buf[8] = 'e';
psVar6->_buf[9] = 's';
psVar6->_buf[10] = '/';
psVar6->_buf[0xb] = 'A';
psVar6->_buf[0xc] = 'f';
psVar6->_buf[0xd] = 't';
psVar6->_buf[0xe] = 'e';
psVar6->_buf[0xf] = 'r';
psVar6->_size = 0x74726962;
psVar6->_capacity = 0x756c5068;
builtin_strncpy(psVar6[1]._buf,"s/DeliriumForms",0xf);
memcpy(psVar6[1]._buf + 0xf,sheetPath._buf + replacedLen + 4,tailLen);
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x0))) = psVar6;
goto LAB_004a609a;
}
*GHIDRA_CAST<uint32_t *>(psVar6->_buf) = *(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<uint32_t *>(GHIDRA_CAST<char *>(sheetPath._buf)))) + 0x0)));
psVar6->_buf[4] = 'B';
psVar6->_buf[5] = 'o';
psVar6->_buf[6] = 's';
psVar6->_buf[7] = 's';
psVar6->_buf[8] = 'e';
psVar6->_buf[9] = 's';
psVar6->_buf[10] = '/';
psVar6->_buf[0xb] = 'A';
psVar6->_buf[0xc] = 'f';
psVar6->_buf[0xd] = 't';
psVar6->_buf[0xe] = 'e';
psVar6->_buf[0xf] = 'r';
psVar6->_size = 0x74726962;
psVar6->_capacity = 0x756c5068;
builtin_strncpy(psVar6[1]._buf,"s/DeliriumForms",0xf);
memcpy(psVar6[1]._buf + 0xf,(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(sheetPath._buf))) + 0x0))) + replacedLen + 4,tailLen);
uVar11 = uVar10 + 1;
ptr = GHIDRA_CAST<std_string *>(uVar2);
if (0xfff < uVar11) {
ptr = GHIDRA_CAST<std_string *>((GHIDRA_CAST<std_string *>((uVar2 + -0x18)))->_capacity);
uVar11 = uVar10 + 0x24;
if (GHIDRA_CAST<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>((uVar2 + (-4 - GHIDRA_INT(ptr))))) goto LAB_004a622d;
}
operator_delete(ptr,uVar11);
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x0))) = psVar6;
}
psVar6 = &sheetPath;
if (0xf < sheetPath._capacity) {
psVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(sheetPath._buf))) + 0x0)));
}
pbVar7 = FileSystem::ResolvePath(GHIDRA_CAST<uint8_t *>(psVar6));
bVar12 = pbVar7 != GHIDRA_CAST<uint8_t *>(0x0);
if (pbVar7 != GHIDRA_CAST<uint8_t *>(0x0)) {
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 1;
tracked_alloc(1,pbVar7,0);
local_14 = (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_14))) + 0x1))) << 8;
(GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>(sprite))))->Sprite::ReplaceSpritesheet(GHIDRA_INT(layerIdx),&sheetPath);
bVar12 = extraout_CL_01;
}
}
else {
psVar6 = &sheetPath;
if (0xf < sheetPath._capacity) {
psVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(sheetPath._buf))) + 0x0)));
}
iVar5 = _strnicmp(psVar6->_buf + 4,"monsters",8);
bVar12 = extraout_CL_02;
if (iVar5 == 0) {
msvc::string::replace
(sheetPath._buf,4,8,GHIDRA_CAST<uint8_t *>("Bosses/AfterbirthPlus/DeliriumForms"),0x23);
psVar6 = &sheetPath;
if (0xf < sheetPath._capacity) {
psVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(sheetPath._buf))) + 0x0)));
}
pbVar7 = FileSystem::ResolvePath(GHIDRA_CAST<uint8_t *>(psVar6));
bVar12 = pbVar7 != GHIDRA_CAST<uint8_t *>(0x0);
if (pbVar7 != GHIDRA_CAST<uint8_t *>(0x0)) {
(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 2;
tracked_alloc(1,pbVar7,0);
local_14 = (*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_14))) + 0x1))) << 8;
(GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>(sprite))))->Sprite::ReplaceSpritesheet(GHIDRA_INT(layerIdx),&sheetPath);
bVar12 = extraout_CL_03;
}
}
}
}
local_14 = 0xffffffff;
if (0xf < sheetPath._capacity) {
uVar11 = sheetPath._capacity + 1;
psVar6 = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(sheetPath._buf))) + 0x0)));
if (0xfff < uVar11) {
psVar6 = GHIDRA_CAST<std_string *>((GHIDRA_CAST<std_string *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x0))) + -0x18)))->_capacity);
uVar11 = sheetPath._capacity + 0x24;
if (GHIDRA_CAST<uint8_t *>(0x1f) < GHIDRA_CAST<uint8_t *>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(sheetPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(psVar6))))) {
LAB_004a622d:
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(psVar6,uVar11);
bVar12 = extraout_CL_04;
}
layerIdx = layerIdx + 1;
} while (layerIdx < GHIDRA_CAST<uint8_t *>(sprite->_layerCount));
}
LoadGraphics(sprite,bVar12);
psVar6 = &sprite->_animDefaultName;
if (0xf < (sprite->_animDefaultName)._capacity) {
psVar6 = *GHIDRA_CAST<std_string **>(psVar6->_buf);
}
bVar12 = SetAnimation(sprite,GHIDRA_CAST<uint8_t *>(psVar6),1);
if (((bVar12 != 0) && ((sprite->_animState)._animData != (void *)0x0)) &&
((GHIDRA_CAST<AnimationState *>((&sprite->_animState)))->AnimationState::SetFrameFloat(0.0),
(sprite->_animState)._animData != (void *)0x0)) {
(sprite->_animState)._isPlaying = 0;
}
ExceptionList = local_1c;
return;
}
// 0078b3b0
void ANM2::copy_animation_to(ANM2 *source, ANM2 *dest)
{
uint8_t isAnimSet;
std_string *animName;
int frame;
void *allocBlock;
uint32_t allocSize;
void *overlayNameBuf [5];
uint32_t overlayNameCapacity;
void *animNameBuf [5];
uint32_t animNameCapacity;
uint32_t local_14;
void *local_10;
uint8_t *puStack_c;
void *local_8;
float overlayFrame;
local_8 = (void *)0xffffffff;
puStack_c = &LAB_00aff585;
local_10 = ExceptionList;
local_14 = __security_cookie ^ GHIDRA_UINT((animNameBuf + 10));
ExceptionList = &local_10;
if ((source->_loaded != 0) && (dest->_loaded != 0)) {
if (((source->_animState)._animData == (void *)0x0) || ((source->_animState)._isPlaying == 0)) {
frame = GetFrame(source);
animName = GetAnimation(GHIDRA_CAST<ANM2 *>(&source->_animState),GHIDRA_CAST<std_string *>(animNameBuf));
local_8 = (void *)0x1;
SetFrame(dest,animName,frame);
local_8 = (void *)0xffffffff;
if (0xf < animNameCapacity) {
allocSize = animNameCapacity + 1;
allocBlock = animNameBuf[0];
if (0xfff < allocSize) {
allocBlock = *(void **)(GHIDRA_INT(animNameBuf[0]) + -4);
allocSize = animNameCapacity + 0x24;
if (0x1f < GHIDRA_UINT((GHIDRA_INT(animNameBuf[0]) + (-4 - GHIDRA_INT(allocBlock))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(allocBlock,allocSize);
}
}
else {
animName = GetAnimation(GHIDRA_CAST<ANM2 *>(&source->_animState),GHIDRA_CAST<std_string *>(animNameBuf));
local_8 = (void *)0x0;
if (0xf < animName->_capacity) {
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
}
isAnimSet = SetAnimation(dest,GHIDRA_CAST<uint8_t *>(animName),1);
if (isAnimSet != 0) {
(GHIDRA_CAST<AnimationState *>((&dest->_animState)))->AnimationState::Rewind();
(dest->_animState)._isPlaying = 1;
}
local_8 = (void *)0xffffffff;
if (0xf < animNameCapacity) {
allocSize = animNameCapacity + 1;
allocBlock = animNameBuf[0];
if (0xfff < allocSize) {
allocBlock = *(void **)(GHIDRA_INT(animNameBuf[0]) + -4);
allocSize = animNameCapacity + 0x24;
if (0x1f < GHIDRA_UINT((GHIDRA_INT(animNameBuf[0]) + (-4 - GHIDRA_INT(allocBlock))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(allocBlock,allocSize);
}
frame = GetFrame(source);
if ((dest->_animState)._animData != (void *)0x0) {
(GHIDRA_CAST<AnimationState *>((&dest->_animState)))->AnimationState::SetFrameFloat((float)frame);
}
}
if ((source->_overlayAnimState)._animData == (void *)0x0) {
if ((dest->_overlayAnimState)._animData != (void *)0x0) {
(GHIDRA_CAST<AnimationState *>((&dest->_overlayAnimState)))->AnimationState::SetAnimationData((void *)0x0);
}
}
else if ((source->_overlayAnimState)._isPlaying == 0) {
overlayFrame = (source->_overlayAnimState)._animFrame;
animName = GetAnimation(GHIDRA_CAST<ANM2 *>(&source->_overlayAnimState),GHIDRA_CAST<std_string *>(overlayNameBuf));
local_8 = (void *)0x3;
(GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>(dest))))->Sprite::SetOverlayFrame(animName,GHIDRA_INT(overlayFrame));
if (0xf < overlayNameCapacity) {
allocSize = overlayNameCapacity + 1;
allocBlock = overlayNameBuf[0];
if (0xfff < allocSize) {
allocBlock = *(void **)(GHIDRA_INT(overlayNameBuf[0]) + -4);
allocSize = overlayNameCapacity + 0x24;
if (0x1f < GHIDRA_UINT((GHIDRA_INT(overlayNameBuf[0]) + (-4 - GHIDRA_INT(allocBlock))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(allocBlock,allocSize);
}
}
else {
animName = GetAnimation(GHIDRA_CAST<ANM2 *>(&source->_overlayAnimState),GHIDRA_CAST<std_string *>(animNameBuf));
local_8 = (void *)0x2;
if (0xf < animName->_capacity) {
animName = *GHIDRA_CAST<std_string **>(animName->_buf);
}
isAnimSet = SetOverlayAnimation(dest,GHIDRA_CAST<uint8_t *>(animName),1);
if (isAnimSet != 0) {
(GHIDRA_CAST<AnimationState *>((&dest->_overlayAnimState)))->AnimationState::Rewind();
(dest->_overlayAnimState)._isPlaying = 1;
}
local_8 = (void *)0xffffffff;
if (0xf < animNameCapacity) {
allocSize = animNameCapacity + 1;
allocBlock = animNameBuf[0];
if (0xfff < allocSize) {
allocBlock = *(void **)(GHIDRA_INT(animNameBuf[0]) + -4);
allocSize = animNameCapacity + 0x24;
if (0x1f < GHIDRA_UINT((GHIDRA_INT(animNameBuf[0]) + (-4 - GHIDRA_INT(allocBlock))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(allocBlock,allocSize);
}
if ((source->_overlayAnimState)._animData == (void *)0x0) {
frame = -1;
}
else {
frame = GHIDRA_INT((source->_overlayAnimState)._animFrame);
}
if ((dest->_overlayAnimState)._animData != (void *)0x0) {
(GHIDRA_CAST<AnimationState *>((&dest->_overlayAnimState)))->AnimationState::SetFrameFloat((float)frame);
}
}
}
ExceptionList = local_10;
return;
}
// 00837210
void ANM2::update_appear_then_idle()
{
uint8_t nameChar;
uint8_t *animName;
uint32_t compareResult;
char *appearName;
uint8_t *idleName;
bool isLess;
uint8_t *animData;
if (this->_loaded != 0) {
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::Update();
(GHIDRA_CAST<AnimationState *>((&this->_overlayAnimState)))->AnimationState::Update();
}
animData = (this->_animState)._animData;
if ((animData != GHIDRA_CAST<uint8_t *>(0x0)) && ((this->_animState)._isPlaying == 0)) {
animName = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
animName = *GHIDRA_CAST<uint8_t **>(animData);
}
appearName = "Appear";
do {
nameChar = *animName;
isLess = nameChar < (uint8_t)*appearName;
if (nameChar != *appearName) {
LAB_00837272:
compareResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_00837277;
}
if (nameChar == 0) break;
nameChar = animName[1];
isLess = nameChar < (uint8_t)appearName[1];
if (nameChar != appearName[1]) goto LAB_00837272;
animName = animName + 2;
appearName = appearName + 2;
} while (nameChar != 0);
compareResult = 0;
LAB_00837277:
if (compareResult == 0) {
animName = animData;
if (0xf < *GHIDRA_CAST<uint32_t *>((animData + 0x14))) {
animName = *GHIDRA_CAST<uint8_t **>(animData);
}
idleName = s_Idle;
do {
nameChar = *animName;
isLess = nameChar < *idleName;
if (nameChar != *idleName) {
LAB_008372b0:
compareResult = -GHIDRA_UINT(isLess) | 1;
goto LAB_008372b5;
}
if (nameChar == 0) break;
nameChar = animName[1];
isLess = nameChar < idleName[1];
if (nameChar != idleName[1]) goto LAB_008372b0;
animName = animName + 2;
idleName = idleName + 2;
} while (nameChar != 0);
compareResult = 0;
LAB_008372b5:
if ((compareResult != 0) || (animData[0x34] != 0)) {
nameChar = SetAnimation(this,s_Idle,1);
if (nameChar != 0) {
(GHIDRA_CAST<AnimationState *>((&this->_animState)))->AnimationState::Rewind();
(this->_animState)._isPlaying = 1;
}
}
}
}
return;
}