#include "classes.h" // 009f24b0 void RichTextIcon::render(Vector *pos, int iconType, int iconId, float alpha) { void *imageMap = this; float r; Vector *pVVar1; int *imageSlot; uint8_t *shader; ColorMod *color; uint32_t *imagePtr; ColorMod *color_00; LayerState *layer; int layerId; uint32_t size; float fVar2; float in_XMM2_Da; uint8_t auStackY_1a8 [128]; void *pvVar3; Vector *image; void *imageRefCount; uint8_t quad [112]; Color local_a0; KColor tintColor; Vector local_60; void *savedImageMap; Vector *local_54; uint8_t local_50 [40]; float local_28; uint32_t local_24; uint8_t *puStack_20; void *local_1c; uint8_t *puStack_18; uint32_t local_14; void *imageMap; puStack_20 = local_50 + 0x4c; local_14 = 0xffffffff; puStack_18 = &LAB_00b100ed; local_1c = ExceptionList; local_24 = __security_cookie ^ GHIDRA_UINT((local_50 + 0x40)); ExceptionList = &local_1c; local_54 = pos; set_icon(); if (iconType == 2) { imageMap = (void *)(GHIDRA_INT(imageMap) + 0x120); pvVar3 = (void *)0x9f2522; savedImageMap = imageMap; imageSlot = map_int_ImagePtr_subscript(imageMap,&iconId); if (*imageSlot != 0) { shader = &g_shaders; if ((DAT_00c7911c & 1) == 0) { shader = g_currentShader; } g_currentShader = shader; if (0.0 < *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0x114))) { pvVar3 = (void *)0x9f2563; imageSlot = map_int_ImagePtr_subscript(imageMap,&iconId); fVar2 = (float)((double)*GHIDRA_CAST((*imageSlot + 0x14)) + __uint_to_double_fixup[-(*GHIDRA_CAST((*imageSlot + 0x14)) >> 0x1f)]); if (*GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0x114)) <= fVar2 && fVar2 != *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0x114))) { imageSlot = map_int_ImagePtr_subscript(imageMap,&iconId); local_60.y = (*GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0x114)) / (float)((double)*GHIDRA_CAST((*imageSlot + 0x14)) + __uint_to_double_fixup[-(*GHIDRA_CAST((*imageSlot + 0x14)) >> 0x1f)])) * 1.5 ; (GHIDRA_CAST((&tintColor)))->KColor::SetFromARGB(0xffffffff); imageSlot = map_int_ImagePtr_subscript(imageMap,&iconId); pVVar1 = local_54; local_54 = (Vector *) ((float)((double)*GHIDRA_CAST((*imageSlot + 0x14)) + __uint_to_double_fixup[-(*GHIDRA_CAST((*imageSlot + 0x14)) >> 0x1f)]) * local_60.y + local_54->y); imageSlot = map_int_ImagePtr_subscript(imageMap,&iconId); fVar2 = pVVar1->x; image = local_54; render_quad_set_uniform_color (quad,fVar2,pVVar1->y, (float)((double)*GHIDRA_CAST((*imageSlot + 0x10)) + __uint_to_double_fixup[-(*GHIDRA_CAST((*imageSlot + 0x10)) >> 0x1f)]) * local_60.y + fVar2,(float)local_54,&tintColor); pvVar3 = (void *)0x9f266e; (GHIDRA_CAST((GHIDRA_CAST(local_50))))->Color::Color(); imageMap = map_int_ImagePtr_subscript(savedImageMap,&iconId); (GHIDRA_CAST((auStackY_1a8 + 0x84)))->KAGE::SmartPointer::operator_assign(imageMap); apply_sprite_shader_params(color,1,image,pvVar3); imagePtr = map_int_ImagePtr_subscript(savedImageMap,&iconId); tintColor._unk = 0; tintColor._red = 1.0; tintColor._green = 1.0; tintColor._blue = 1.0; tintColor._alpha = alpha; (**(code **)(*GHIDRA_CAST(*imagePtr) + 0x1c))(); ExceptionList = local_1c; return; } } imageRefCount = (void *)0x9f26e3; (GHIDRA_CAST((GHIDRA_CAST(local_50))))->Color::Color(); imageMap = map_int_ImagePtr_subscript(savedImageMap,&iconId); (GHIDRA_CAST((auStackY_1a8 + 0x84)))->KAGE::SmartPointer::operator_assign(imageMap); apply_sprite_shader_params(color_00,1,pvVar3,imageRefCount); imagePtr = map_int_ImagePtr_subscript(savedImageMap,&iconId); tintColor._unk = 0; tintColor._red = 1.0; tintColor._green = 1.0; tintColor._blue = 1.0; tintColor._alpha = alpha; (**(code **)(*GHIDRA_CAST(*imagePtr) + 0x20))(); } } else { get_animation_name(GHIDRA_CAST((local_50 + 0x14)),iconType); local_14 = 0; layer = (GHIDRA_CAST((imageMap)))->ANM2::get_layer_by_string(GHIDRA_CAST((local_50 + 0x14))); if (layer != GHIDRA_CAST(0x0)) { if (layer->_layerData == GHIDRA_CAST(0x0)) { layerId = -1; } else { layerId = *GHIDRA_CAST(layer->_layerData); } imageMap = (GHIDRA_CAST((GHIDRA_CAST((GHIDRA_INT(imageMap) + 0x30)))))->AnimationState::GetLayerFrame(layerId); fVar2 = *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0x114)); local_60.y = 0.0; r = *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xc)); if ((0.0 < fVar2) && (fVar2 < r)) { *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0x9c)) = fVar2 / r; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xa0)) = fVar2 / r; } tintColor._unk = 0; tintColor._red = 1.0; tintColor._green = 1.0; tintColor._blue = 1.0; tintColor._alpha = alpha; (GHIDRA_CAST((&local_a0)))->Color::Color(r,in_XMM2_Da,0.0,(float)&tintColor); if (GHIDRA_CAST((GHIDRA_INT(imageMap) + 0xa8)) != &local_a0) { (GHIDRA_CAST((GHIDRA_INT(imageMap) + 0xa8)))->_tint[0] = local_a0._tint[0]; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xac)) = local_a0._tint[1]; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xb0)) = local_a0._tint[2]; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xb4)) = local_a0._tint[3]; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xb8)) = local_a0._colorize[0]; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xbc)) = local_a0._colorize[1]; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xc0)) = local_a0._colorize[2]; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xc4)) = local_a0._colorize[3]; *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 200)) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_a0._offset)) + 0x0))); *GHIDRA_CAST((GHIDRA_CAST(imageMap) + 0xd0)) = local_a0._offset[2]; } local_60.x = local_54->x + local_60.y; local_60.y = local_54->y + local_60.y; (GHIDRA_CAST((imageMap)))->ANM2::Render(&local_60,&g_vectorZero,&g_vectorZero); } if (0xf < GHIDRA_UINT(local_28)) { size = GHIDRA_INT(local_28) + 1; imageMap = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)local_50)) + 0x14))); if (0xfff < size) { imageMap = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(local_50)) + 0x14))) + -4); size = GHIDRA_INT(local_28) + 0x24; if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(local_50)) + 0x14))) + (-4 - GHIDRA_INT(imageMap))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(imageMap,size); } } ExceptionList = local_1c; return; } // 009f28b0 Vector * RichTextIcon::get_size(Vector *outSize) { int *piVar1; int *piVar2; LayerState *layer; int iVar3; void *pvVar4; uint32_t size; float fVar5; float scaledHeight; std_string animName; uint32_t local_18; void *local_10; uint8_t *puStack_c; uint32_t local_8; float frameHeight; double heightFixup; float maxHeight; local_8 = 0xffffffff; puStack_c = &LAB_00af85cd; local_10 = ExceptionList; local_18 = __security_cookie ^ GHIDRA_INT(&animName) + 0x2cU; ExceptionList = &local_10; outSize->y = 0.0; outSize->x = 0.0; if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x118)) == 2) { piVar2 = GHIDRA_CAST((GHIDRA_INT(this) + 0x11c)); piVar1 = map_int_ImagePtr_subscript((void *)(GHIDRA_INT(this) + 0x120),piVar2); if (*piVar1 == 0) { ExceptionList = local_10; return outSize; } piVar1 = map_int_ImagePtr_subscript((void *)(GHIDRA_INT(this) + 0x120),piVar2); iVar3 = *GHIDRA_CAST((*piVar1 + 0x14)); heightFixup = __uint_to_double_fixup[-(iVar3 >> 0x1f)]; piVar1 = map_int_ImagePtr_subscript((void *)(GHIDRA_INT(this) + 0x120),piVar2); outSize->x = (float)((double)*GHIDRA_CAST((*piVar1 + 0x10)) + __uint_to_double_fixup[-(*GHIDRA_CAST((*piVar1 + 0x10)) >> 0x1f)]); outSize->y = (float)((double)iVar3 + heightFixup); if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x114)) <= 0.0) { ExceptionList = local_10; return outSize; } piVar1 = map_int_ImagePtr_subscript((void *)(GHIDRA_INT(this) + 0x120),piVar2); fVar5 = (float)((double)*GHIDRA_CAST((*piVar1 + 0x14)) + __uint_to_double_fixup[-(*GHIDRA_CAST((*piVar1 + 0x14)) >> 0x1f)]); if (fVar5 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0x114)) || fVar5 == *GHIDRA_CAST((GHIDRA_CAST(this) + 0x114))) { ExceptionList = local_10; return outSize; } piVar2 = map_int_ImagePtr_subscript((void *)(GHIDRA_INT(this) + 0x120),piVar2); fVar5 = (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x114)) / (float)((double)*GHIDRA_CAST((*piVar2 + 0x14)) + __uint_to_double_fixup[-(*GHIDRA_CAST((*piVar2 + 0x14)) >> 0x1f)])) * 1.5; scaledHeight = fVar5 * outSize->y; outSize->x = fVar5 * outSize->x; } else { if (*(void **)(GHIDRA_CAST(this) + 0x34) == (void *)0x0) { animName._capacity = 0xf; animName._size = 0; (*GHIDRA_CAST((GHIDRA_CAST(&(animName._buf)) + 0x0))) = (void *)0x0; } else { (GHIDRA_CAST((animName._buf)))->msvc::string::string(*(void **)(GHIDRA_CAST(this) + 0x34)); } local_8 = 0; layer = this->ANM2::get_layer_by_string(&animName); local_8 = 0xffffffff; if (0xf < animName._capacity) { size = animName._capacity + 1; pvVar4 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)animName._buf)) + 0x0))); if (0xfff < size) { pvVar4 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(animName._buf)) + 0x0))) + -4); size = animName._capacity + 0x24; if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(animName._buf)) + 0x0))) + (-4 - GHIDRA_INT(pvVar4))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(pvVar4,size); } if (layer == GHIDRA_CAST(0x0)) { ExceptionList = local_10; return outSize; } if (layer->_layerData == GHIDRA_CAST(0x0)) { iVar3 = -1; } else { iVar3 = *GHIDRA_CAST(layer->_layerData); } pvVar4 = (GHIDRA_CAST((GHIDRA_CAST((GHIDRA_INT(this) + 0x30)))))->AnimationState::GetLayerFrame(iVar3); fVar5 = *GHIDRA_CAST((GHIDRA_CAST(pvVar4) + 8)); outSize->x = fVar5; frameHeight = *GHIDRA_CAST((GHIDRA_CAST(pvVar4) + 0xc)); outSize->y = frameHeight; maxHeight = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x114)); if (maxHeight <= 0.0) { ExceptionList = local_10; return outSize; } if (frameHeight <= maxHeight) { ExceptionList = local_10; return outSize; } scaledHeight = frameHeight * (maxHeight / frameHeight); outSize->x = fVar5 * (maxHeight / frameHeight); } outSize->y = scaledHeight; ExceptionList = local_10; return outSize; } // 009f2b10 std_string * RichTextIcon::get_animation_name(std_string *outName, int iconType) { if (iconType == 0) { 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 = 7; memmove(outName,"players",7); outName->_buf[7] = '\0'; return outName; } if (iconType == 1) { 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 = 7; memmove(outName,"pickups",7); outName->_buf[7] = '\0'; return outName; } if (iconType == 3) { 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 = 5; memmove(outName,"rooms",5); outName->_buf[5] = '\0'; return outName; } KAGE_LogMessage(8,GHIDRA_CAST("Invalid icon type (%d) for get_animation_name() \n")); 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; } // 009f2c10 void RichTextIcon::set_icon(int param_1, int param_2) { uint8_t bVar1; char isLastRef; std_string *psVar2; uint8_t *currentAnimChar; uint32_t uVar3; ItemConfig_Item *pIVar4; int *imageSlot; void *pvVar5; void *imageSlotRef; ANM2 *in_ECX; std_string *newAnimChar; int iVar6; bool isLess; uint8_t loadedImage [4]; int *loadedImageRef; void *animName [5]; uint32_t animNameCapacity; uint32_t local_14; void *local_10; uint8_t *puStack_c; void *local_8; uint8_t *animData; ANM2 *iconData; Manager *manager; iVar6 = param_2; manager = g_manager; local_8 = (void *)0xffffffff; puStack_c = &LAB_00b10135; local_10 = ExceptionList; local_14 = __security_cookie ^ GHIDRA_UINT((animName + 10)); ExceptionList = &local_10; if (param_1 == 2) { iconData = in_ECX + 1; (iconData->_filename)._buf[4] = '\x02'; (iconData->_filename)._buf[5] = '\0'; (iconData->_filename)._buf[6] = '\0'; (iconData->_filename)._buf[7] = '\0'; pIVar4 = (GHIDRA_CAST((&manager->_itemConfig)))->ItemConfig::GetCollectible(param_2); if (pIVar4 != GHIDRA_CAST(0x0)) { imageSlot = map_int_ImagePtr_subscript(in_ECX[1]._filename._buf + 0xc,¶m_2); if (*imageSlot == 0) { psVar2 = &pIVar4->gfxFilename; if (0xf < (pIVar4->gfxFilename)._capacity) { psVar2 = *GHIDRA_CAST(psVar2->_buf); } pvVar5 = Manager::LoadImage(loadedImage,GHIDRA_CAST(psVar2)); local_8 = (void *)0x1; imageSlotRef = map_int_ImagePtr_subscript(in_ECX[1]._filename._buf + 0xc,¶m_2); (GHIDRA_CAST((imageSlotRef)))->KAGE::SmartPointer::operator_assign(pvVar5); local_8 = (void *)0x2; if (loadedImageRef != GHIDRA_CAST(0x0)) { isLastRef = (**(code **)(*loadedImageRef + 0xc))(); if ((isLastRef != '\0') && (g_imageReleaseFn != (void *)0x0)) { (*g_imageReleaseFn)(loadedImage); } } } LAB_009f2dec: iVar6 = param_2; } LAB_009f2def: *GHIDRA_CAST((in_ECX[1]._filename._buf + 8)) = iVar6; } else { psVar2 = get_animation_name(GHIDRA_CAST(animName),param_1); local_8 = (void *)0x0; if (0xf < psVar2->_capacity) { psVar2 = *GHIDRA_CAST(psVar2->_buf); } animData = (in_ECX->_animState)._animData; if (animData == GHIDRA_CAST(0x0)) { LAB_009f2caa: bVar1 = (GHIDRA_CAST((in_ECX)))->ANM2::SetAnimation(GHIDRA_CAST(psVar2),1); if (bVar1 != 0) { (GHIDRA_CAST((&in_ECX->_animState)))->AnimationState::Rewind(); (in_ECX->_animState)._isPlaying = 1; } } else { currentAnimChar = animData; if (0xf < *GHIDRA_CAST((animData + 0x14))) { currentAnimChar = *GHIDRA_CAST(animData); } newAnimChar = psVar2; do { bVar1 = *currentAnimChar; isLess = bVar1 < (uint8_t)newAnimChar->_buf[0]; if (bVar1 != newAnimChar->_buf[0]) { LAB_009f2c97: uVar3 = -GHIDRA_UINT(isLess) | 1; goto LAB_009f2c9c; } if (bVar1 == 0) break; bVar1 = currentAnimChar[1]; isLess = bVar1 < (uint8_t)newAnimChar->_buf[1]; if (bVar1 != newAnimChar->_buf[1]) goto LAB_009f2c97; currentAnimChar = currentAnimChar + 2; newAnimChar = GHIDRA_CAST((newAnimChar->_buf + 2)); } while (bVar1 != 0); uVar3 = 0; LAB_009f2c9c: if ((uVar3 != 0) || ((animData[0x34] != 0 && ((in_ECX->_animState)._isPlaying == 0)))) goto LAB_009f2caa; } local_8 = (void *)0xffffffff; if (0xf < animNameCapacity) { uVar3 = animNameCapacity + 1; pvVar5 = animName[0]; if (0xfff < uVar3) { pvVar5 = *(void **)(GHIDRA_INT(animName[0]) + -4); uVar3 = animNameCapacity + 0x24; if (0x1f < GHIDRA_UINT((GHIDRA_INT(animName[0]) + (-4 - GHIDRA_INT(pvVar5))))) { /* WARNING: Subroutine does not return */ _invalid_parameter_noinfo_noreturn(); } } operator_delete(pvVar5,uVar3); } *GHIDRA_CAST((in_ECX[1]._filename._buf + 4)) = param_1; if (-1 < param_2) { pvVar5 = (in_ECX->_animState)._animData; if (pvVar5 == (void *)0x0) { iVar6 = 0; } else { iVar6 = *GHIDRA_CAST((GHIDRA_CAST(pvVar5) + 0x30)); } if (param_2 <= iVar6) { iVar6 = param_2; if (pvVar5 != (void *)0x0) { (GHIDRA_CAST((&in_ECX->_animState)))->AnimationState::SetFrameFloat((float)param_2); goto LAB_009f2dec; } goto LAB_009f2def; } } KAGE_LogMessage(8,GHIDRA_CAST("Invalid icon id (%d) for Icon Type %d \n")); } ExceptionList = local_10; return; }