#include "classes.h" // 00407a60 LayerState::~LayerState() { char isLastRef; int in_ECX; void *local_10; uint8_t *puStack_c; uint32_t local_8; puStack_c = &LAB_00af09f0; local_10 = ExceptionList; ExceptionList = &local_10; local_8 = 0; if (*GHIDRA_CAST((in_ECX + 0x9c)) != GHIDRA_CAST(0x0)) { isLastRef = (**(code **)(**GHIDRA_CAST((in_ECX + 0x9c)) + 0xc)) (__security_cookie ^ GHIDRA_INT(register0x00000010) - 4U); if ((isLastRef != '\0') && (g_imageReleaseFn != (void *)0x0)) { (*g_imageReleaseFn)(in_ECX + 0x98); } } (GHIDRA_CAST((GHIDRA_CAST((in_ECX + 8)))))->msvc::string::_Tidy_deallocate(); ExceptionList = local_10; return; } // 004081d0 LayerState::LayerState() { uint32_t graphicsFlag4; int blendFactor; void *local_10; uint8_t *puStack_c; uint32_t local_8; puStack_c = &LAB_00af0a8e; local_10 = ExceptionList; ExceptionList = &local_10; (this->_spriteSheetPath)._buf[0] = '\0'; (this->_spriteSheetPath)._buf[1] = '\0'; (this->_spriteSheetPath)._buf[2] = '\0'; (this->_spriteSheetPath)._buf[3] = '\0'; (this->_spriteSheetPath)._size = 0; (this->_spriteSheetPath)._capacity = 0xf; (this->_spriteSheetPath)._buf[0] = '\0'; (this->_size).y = 0.0; (this->_size).x = 0.0; (this->_pos).y = 0.0; (this->_pos).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; graphicsFlag4 = g_graphicsManager_flags & 4; this->_blendMode[0] = 0; blendFactor = 1; this->_blendMode[2] = 7; this->_blendMode[3] = 1; if (graphicsFlag4 == 0) { blendFactor = 6; } this->_blendMode[1] = blendFactor; this->_blendMode[4] = 7; (this->_cropOffset).y = 0.0; (this->_cropOffset).x = 0.0; this->_spriteSheet = 0; this[1]._layerData = (void *)0x0; local_8 = 1; Init(this,0); ExceptionList = local_10; return this; } // 00408310 void LayerState::Init(void *param_2) { void **text; int blendMode1; void *allocBlock; uint32_t uVar1; bool isNoData; void *layerPath [4]; uint32_t layerPathSize; uint32_t layerPathCapacity; void *emptyPath [4]; uint32_t emptyPathSize; uint32_t emptyPathCapacity; uint32_t local_18; void *local_10; uint8_t *puStack_c; void *local_8; void **textSize; local_8 = (void *)0xffffffff; puStack_c = &LAB_00af0ae7; local_10 = ExceptionList; local_18 = __security_cookie ^ GHIDRA_UINT((emptyPath + 0xb)); ExceptionList = &local_10; this->_layerData = param_2; isNoData = param_2 == (void *)0x0; if (isNoData) { emptyPathCapacity = 0xf; emptyPathSize = 0; emptyPath[0] = (void *)0x0; text = emptyPath; local_8 = (void *)0x1; } else { text = (GHIDRA_CAST((GHIDRA_CAST(layerPath))))->msvc::string::string((void *)(GHIDRA_INT(param_2) + 0x20)); local_8 = (void *)0x0; } local_8 = (void *)GHIDRA_UINT(isNoData); if (&this->_spriteSheetPath != GHIDRA_CAST(text)) { textSize = text + 4; if ((void *)0xf < text[5]) { text = *text; } (GHIDRA_CAST(((this->_spriteSheetPath)._buf)))->msvc::string::assign(GHIDRA_CAST(text),GHIDRA_UINT(*textSize)); } local_8 = (void *)0x0; if ((isNoData) && (0xf < emptyPathCapacity)) { uVar1 = emptyPathCapacity + 1; allocBlock = emptyPath[0]; if (0xfff < uVar1) { allocBlock = *(void **)(GHIDRA_INT(emptyPath[0]) + -4); uVar1 = emptyPathCapacity + 0x24; if (0x1f < GHIDRA_UINT((GHIDRA_INT(emptyPath[0]) + (-4 - GHIDRA_INT(allocBlock))))) goto LAB_00408423; } operator_delete(allocBlock,uVar1); } local_8 = (void *)0xffffffff; if (!isNoData) { if (0xf < layerPathCapacity) { uVar1 = layerPathCapacity + 1; allocBlock = layerPath[0]; if (0xfff < uVar1) { allocBlock = *(void **)(GHIDRA_INT(layerPath[0]) + -4); uVar1 = layerPathCapacity + 0x24; if (0x1f < GHIDRA_UINT((GHIDRA_INT(layerPath[0]) + (-4 - GHIDRA_INT(allocBlock))))) { LAB_00408423: /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(allocBlock,uVar1); } layerPathSize = 0; layerPathCapacity = 0xf; layerPath[0] = (void *)(GHIDRA_UINT(layerPath[0]) & 0xffffff00); } (GHIDRA_CAST((&this->_spriteSheet)))->KAGE::SmartPointer::reset((void *)0x0); this->_spriteSheetLoaded = 0; (*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x31))) = 0; this->_flipX = 0; this->_flipY = 0; (this->_size).x = g_vectorOne.x; (this->_size).y = g_vectorOne.y; this->_rotation = 0.0; (this->_pos).x = g_vectorZero.x; (this->_pos).y = g_vectorZero.y; (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->_visible = 1; uVar1 = g_graphicsManager_flags & 4; this->_blendMode[0] = 0; this->_blendMode[2] = 7; blendMode1 = 1; if (uVar1 == 0) { blendMode1 = 6; } this->_blendMode[3] = 1; this->_blendMode[1] = blendMode1; this->_blendMode[4] = 7; this->_minFilterMode = DAT_00c3799c; this->_magFilterMode = DAT_00c379a0; this->_wrapSMode = DAT_00c379a4; this->_wrapTMode = DAT_00c379a8; this->_bitflags = 0; (this->_cropOffset).x = g_vectorZero.x; (this->_cropOffset).y = g_vectorZero.y; ExceptionList = local_10; return; } // 00408590 void * LayerState::GetTexture(void *outTexture) { int iVar1; int iVar2; int *texture; texture = GHIDRA_CAST(this->_spriteSheet); if (texture != GHIDRA_CAST(0x0)) { iVar1 = this->_minFilterMode; if (((texture[0xc] != iVar1) || (texture[0xd] != this->_magFilterMode)) && ((iVar2 = this->_magFilterMode, iVar1 != texture[0xc] || (iVar2 != texture[0xd])))) { (**(code **)(*texture + 0x44))(iVar1,iVar2); texture[0xc] = iVar1; texture[0xd] = iVar2; texture = GHIDRA_CAST(this->_spriteSheet); } iVar1 = this->_wrapSMode; if (((texture[0xe] != iVar1) || (texture[0xf] != this->_wrapTMode)) && ((iVar2 = this->_wrapTMode, iVar1 != texture[0xe] || (iVar2 != texture[0xf])))) { (**(code **)(*texture + 0x48))(iVar1,iVar2); texture[0xe] = iVar1; texture[0xf] = iVar2; } } (GHIDRA_CAST((outTexture)))->KAGE::SmartPointer::operator_assign(&this->_spriteSheet); return outTexture; } // 00408640 void LayerState::SetTexture(void *texture, void *textureRefCount) { char isLastRef; uint32_t uVar1; void *local_10; uint8_t *puStack_c; uint32_t local_8; puStack_c = &LAB_00af0b1d; local_10 = ExceptionList; uVar1 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U; ExceptionList = &local_10; local_8 = 0; if (texture != (void *)0x0) { this->_minFilterMode = *GHIDRA_CAST((GHIDRA_CAST(texture) + 0x30)); this->_magFilterMode = *GHIDRA_CAST((GHIDRA_CAST(texture) + 0x34)); this->_wrapSMode = *GHIDRA_CAST((GHIDRA_CAST(texture) + 0x38)); this->_wrapTMode = *GHIDRA_CAST((GHIDRA_CAST(texture) + 0x3c)); } (GHIDRA_CAST((&this->_spriteSheet)))->KAGE::SmartPointer::operator_assign(&texture); local_8 = 1; if (textureRefCount != (void *)0x0) { isLastRef = (**(code **)(*GHIDRA_CAST(textureRefCount) + 0xc))(uVar1); if ((isLastRef != '\0') && (g_imageReleaseFn != (void *)0x0)) { (*g_imageReleaseFn)(&texture); } } ExceptionList = local_10; return; }