#include "classes.h" // 008c9530 void Menu_ControllerSelect::Update() { uint64_t qVar1; char cVar2; uint32_t uVar3; uint8_t *buffer; int iVar4; int *in_ECX; int *extraout_ECX; int *piVar5; uint8_t *pbVar6; uint64_t *allocCounter; void *historyEnd; uint8_t *newEntry; int deviceId; int *device; int *deviceRefCount; uint32_t local_18; uint32_t local_14; void *local_10; uint8_t *puStack_c; uint32_t local_8; uint8_t ch; uint32_t *entriesEnd; MenuManager *menuManager; int *selection; local_8 = 0xffffffff; puStack_c = &LAB_00b05835; local_10 = ExceptionList; uVar3 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 4U; ExceptionList = &local_10; piVar5 = in_ECX; if (*GHIDRA_CAST((GHIDRA_CAST(in_ECX) + 0x119)) != '\0') { (GHIDRA_CAST((GHIDRA_CAST((in_ECX + 0x10)))))->AnimationState::Update(); (GHIDRA_CAST((GHIDRA_CAST((in_ECX + 0x18)))))->AnimationState::Update(); piVar5 = extraout_ECX; } FUN_008ca0a0(piVar5,uVar3); in_ECX[0x4a] = in_ECX[0x49]; (**(code **)(PTR_vftable_00c57b2c + 0xc))(0xffffffff); uVar3 = DAT_00c57b24 - _DAT_00c57b20 >> 3; local_8 = 0; local_18 = uVar3; (**(code **)(PTR_vftable_00c57b2c + 0x10))(); local_14 = 0; if (uVar3 != 0) { do { local_8 = 0xffffffff; (GHIDRA_CAST((GHIDRA_CAST(&PTR_vftable_00c57b18))))->KAGE::Input::Manager::get_device(&device,local_14); local_8 = 1; if (device == GHIDRA_CAST(0x0)) { local_8 = 2; if (((deviceRefCount != GHIDRA_CAST(0x0)) && (cVar2 = (**(code **)(*deviceRefCount + 0xc))(), cVar2 != '\0')) && (g_inputDeviceRelease != (void *)0x0)) { (*g_inputDeviceRelease)(&device); } } else { buffer = operator_new_tracked(0x40); deviceId = 0; *buffer = 0; local_8 = CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),3); newEntry = buffer; (**(code **)(*device + 0xc))(); sprintf_s(buffer,0x40,&DAT_00b62fdc); pbVar6 = buffer; do { ch = *pbVar6; pbVar6 = pbVar6 + 1; } while (ch != 0); if (0x12 < GHIDRA_UINT((GHIDRA_INT(pbVar6) - GHIDRA_INT((buffer + 1))))) { buffer[0x10] = 0x2e; buffer[0x11] = 0x2e; buffer[0x12] = 0; } entriesEnd = GHIDRA_CAST(in_ECX[0x4a]); deviceId = device[3]; if (entriesEnd == GHIDRA_CAST(in_ECX[0x4b])) { FUN_008c9e90(entriesEnd,&newEntry); iVar4 = in_ECX[0x4a]; buffer = newEntry; } else { entriesEnd[1] = deviceId; pbVar6 = operator_new_tracked(0x40); *entriesEnd = pbVar6; sprintf_s(pbVar6,0x40,&DAT_00b62fdc); in_ECX[0x4a] = in_ECX[0x4a] + 8; iVar4 = in_ECX[0x4a]; } if (5 < GHIDRA_UINT((iVar4 - in_ECX[0x49] >> 3))) { if (g_mainHeap == (void *)0x0) { allocCounter = &g_allocatedBytesNoHeap; } else { allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if (buffer != GHIDRA_CAST(0x0)) { uVar3 = *GHIDRA_CAST((buffer + -4)); qVar1 = *allocCounter; *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar3; *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar3)); free(buffer + -4); } local_8 = 5; if (((deviceRefCount != GHIDRA_CAST(0x0)) && (cVar2 = (**(code **)(*deviceRefCount + 0xc))(), cVar2 != '\0')) && (g_inputDeviceRelease != (void *)0x0)) { (*g_inputDeviceRelease)(&device); } break; } if (g_mainHeap == (void *)0x0) { allocCounter = &g_allocatedBytesNoHeap; } else { allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); } if (buffer != GHIDRA_CAST(0x0)) { uVar3 = *GHIDRA_CAST((buffer + -4)); qVar1 = *allocCounter; *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar3; *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar3)); free(buffer + -4); } local_8 = 7; if (((deviceRefCount != GHIDRA_CAST(0x0)) && (cVar2 = (**(code **)(*deviceRefCount + 0xc))(), cVar2 != '\0')) && (g_inputDeviceRelease != (void *)0x0)) { (*g_inputDeviceRelease)(&device); } uVar3 = local_18; } local_14 = local_14 + 1; } while (local_14 < uVar3); } local_8 = 0xffffffff; piVar5 = in_ECX + 0x49; uVar3 = in_ECX[0x4a] - *piVar5 >> 3; if (uVar3 <= GHIDRA_UINT(in_ECX[1])) { in_ECX[1] = uVar3 - 1; } local_18 = 0xe; cVar2 = (**(code **)(PTR_vftable_00c57b18 + 0x74))(0xffffffff,FUN_00a209e0,&local_18,0,0); if (cVar2 == '\0') { local_18 = 0xf; cVar2 = (**(code **)(PTR_vftable_00c57b18 + 0x74))(0xffffffff,FUN_00a209e0,&local_18,0,0); menuManager = g_menuManager; if (cVar2 == '\0') { local_18 = 0x17; cVar2 = (**(code **)(PTR_vftable_00c57b18 + 0x74))(0xffffffff,FUN_00a20940,&local_18,0,0); if (cVar2 == '\0') { local_18 = 0x16; cVar2 = (**(code **)(PTR_vftable_00c57b18 + 0x74))(0xffffffff,FUN_00a20940,&local_18,0,0); if ((cVar2 != '\0') && ((iVar4 = *in_ECX, iVar4 == 0 || ((0x31 < iVar4 && (iVar4 % 10 == 0)))))) { selection = in_ECX + 1; *selection = *selection + -1; if (*selection < 0) { in_ECX[1] = (in_ECX[0x4a] - *piVar5 >> 3) + -1; } } } else { iVar4 = *in_ECX; if (((iVar4 == 0) || ((0x31 < iVar4 && (iVar4 % 10 == 0)))) && (in_ECX[1] = in_ECX[1] + 1, in_ECX[0x4a] - *piVar5 >> 3 <= in_ECX[1])) { in_ECX[1] = 0; } } } else { historyEnd = (g_menuManager->_menuStateHistory)._end; if (1 < GHIDRA_UINT((GHIDRA_INT(historyEnd) - GHIDRA_INT((g_menuManager->_menuStateHistory)._begin) >> 2))) { historyEnd = (void *)(GHIDRA_INT(historyEnd) + -4); (g_menuManager->_menuStateHistory)._end = historyEnd; } (GHIDRA_CAST((menuManager)))->MenuManager::SetState(*GHIDRA_CAST((GHIDRA_CAST(historyEnd) + -4)),0); } } else { g_menuControllerIndex = *GHIDRA_CAST((*piVar5 + 4 + in_ECX[1] * 8)); MenuManager::push_menu(0xc,in_ECX[1]); g_manager->_isHotkeysEnabled = 0; } local_18 = 0x16; cVar2 = (**(code **)(PTR_vftable_00c57b18 + 0x74))(0xffffffff,FUN_00a20940,&local_18,0,0); if (cVar2 == '\0') { local_14 = 0x17; cVar2 = (**(code **)(PTR_vftable_00c57b18 + 0x74))(0xffffffff,FUN_00a20940,&local_14,0,0); if (cVar2 == '\0') { *in_ECX = 0; ExceptionList = local_10; return; } } *in_ECX = *in_ECX + 1; ExceptionList = local_10; return; } // 008c99b0 void Menu_ControllerSelect::Render() { uint8_t *text; KColor color; LayerState *cursorLayer; void *pvVar1; void *layerFrames; AnimationState *secondAnimState; int iVar2; uint8_t *textEnd; uint32_t row; Font *font; uint8_t glyphRun [16]; uint32_t fontParams; uint32_t local_144; uint32_t local_140; uint32_t local_13c; uint32_t local_138; uint32_t local_134; uint32_t local_130; float textX; float textY; float listY; float listX; Vector renderPos; uint8_t nameText [256]; uint32_t local_14; void *local_10; uint8_t *puStack_c; uint32_t local_8; ANM2 *animation; uint8_t ch; local_8 = 0xffffffff; puStack_c = &LAB_00b0587b; local_10 = ExceptionList; local_14 = __security_cookie ^ GHIDRA_UINT((nameText + 0x110)); ExceptionList = &local_10; cursorLayer = (GHIDRA_CAST((&this->ControllerSelectSprite)))->ANM2::GetLayer(GHIDRA_CAST(0x2)); cursorLayer->_visible = 0; renderPos.x = (g_menuManager->_ViewPosition).x + this->PositionX; renderPos.y = (g_menuManager->_ViewPosition).y + this->PositionY; if ((this->ControllerSelectSprite)._loaded != 0) { if ((this->ControllerSelectSprite)._overlayRenderFirst == 0) { AnimationState::Render (&(this->ControllerSelectSprite)._animState,&renderPos,&g_vectorZero,&g_vectorZero); secondAnimState = &(this->ControllerSelectSprite)._overlayAnimState; } else { AnimationState::Render (&(this->ControllerSelectSprite)._overlayAnimState,&renderPos,&g_vectorZero, &g_vectorZero); secondAnimState = &(this->ControllerSelectSprite)._animState; } AnimationState::Render(secondAnimState,&renderPos,&g_vectorZero,&g_vectorZero); } row = 0; iVar2 = this[1].HoldInputTimer; if (this[1].SelectedElement - iVar2 >> 3 != 0) { listX = (g_menuManager->_ViewPosition).x + this->PositionX + 265.0; listY = (g_menuManager->_ViewPosition).y + this->PositionY + 60.0; do { text = *GHIDRA_CAST((iVar2 + row * 8)); if (text == GHIDRA_CAST(0x0)) { iVar2 = 0; } else { textEnd = text; do { ch = *textEnd; textEnd = textEnd + 1; } while (ch != 0); iVar2 = GHIDRA_INT(textEnd) - GHIDRA_INT((text + 1)); } text_convert_encoding(text,iVar2,0,nameText,0x80,1); font = &g_manager->_font2_TeamMeatEx12; if (*GHIDRA_CAST(&g_manager->_stringTable) == 0) { font = &g_manager->_font1_TeamMeatEx10; } fontParams = 0; local_144 = 0xffff; local_140 = 0; local_13c = 0x3f800000; local_138 = 0xffffffff; local_134 = 0; local_130 = 0; local_8 = 0; textY = (float)((double)GHIDRA_INT(row) + __uint_to_double_fixup[-(GHIDRA_INT(row) >> 0x1f)]) * 20.0 + listY ; textX = listX - (float)((double)GHIDRA_INT(row) + __uint_to_double_fixup[-(GHIDRA_INT(row) >> 0x1f)]) * 4.0; pvVar1 = (GHIDRA_CAST((font)))->Font::layout_glyphs(glyphRun,nameText,&fontParams,&g_vectorOne); local_8 = CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),1); color._blue = 0.1764706; color._red = 0.21176471; color._green = 0.18431373; color._alpha = 1.0; color._unk = 0; Font::draw_glyph_run(font,textX,textY,pvVar1,1.0,1.0,color,&fontParams); msvc::vector<12byte>::clear(); msvc::vector<12byte>::_Tidy(); local_8 = 0xffffffff; row = row + 1; iVar2 = this[1].HoldInputTimer; } while (row < GHIDRA_UINT((this[1].SelectedElement - iVar2 >> 3))); } cursorLayer = (GHIDRA_CAST((&this->ControllerSelectSprite)))->ANM2::GetLayer(GHIDRA_CAST(0x2)); cursorLayer->_visible = 1; renderPos.x = ((g_menuManager->_ViewPosition).x + this->PositionX) - (float)this->SelectedElement * 4.0; renderPos.y = (g_menuManager->_ViewPosition).y + this->PositionY + (float)this->SelectedElement * 20.0; if ((this->ControllerSelectSprite)._loaded != 0) { if ((this->ControllerSelectSprite)._overlayRenderFirst == 0) { pvVar1 = (this->ControllerSelectSprite)._animState._animData; if (((pvVar1 != (void *)0x0) && (animation = (this->ControllerSelectSprite)._animState._animation, 2 < animation->_layerCount)) && (iVar2 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x40)), -1 < iVar2)) { AnimationLayer::RenderFrame (GHIDRA_CAST((iVar2 * 0x10 + *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x18)))),&renderPos, *GHIDRA_CAST((GHIDRA_INT((this->ControllerSelectSprite)._animState._layerFrames) + iVar2 * 4)) ,&g_vectorZero,&g_vectorZero,animation); } pvVar1 = (this->ControllerSelectSprite)._overlayAnimState._animData; if (pvVar1 == (void *)0x0) { ExceptionList = local_10; return; } animation = (this->ControllerSelectSprite)._overlayAnimState._animation; if (animation->_layerCount < 3) { ExceptionList = local_10; return; } iVar2 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x40)); if (iVar2 < 0) { ExceptionList = local_10; return; } layerFrames = (this->ControllerSelectSprite)._overlayAnimState._layerFrames; } else { pvVar1 = (this->ControllerSelectSprite)._overlayAnimState._animData; if (((pvVar1 != (void *)0x0) && (animation = (this->ControllerSelectSprite)._overlayAnimState._animation, 2 < animation->_layerCount)) && (iVar2 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x40)), -1 < iVar2)) { AnimationLayer::RenderFrame (GHIDRA_CAST((iVar2 * 0x10 + *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x18)))),&renderPos, *GHIDRA_CAST((GHIDRA_INT((this->ControllerSelectSprite)._overlayAnimState._layerFrames) + iVar2 * 4)),&g_vectorZero,&g_vectorZero,animation); } pvVar1 = (this->ControllerSelectSprite)._animState._animData; if (pvVar1 == (void *)0x0) { ExceptionList = local_10; return; } animation = (this->ControllerSelectSprite)._animState._animation; if (animation->_layerCount < 3) { ExceptionList = local_10; return; } iVar2 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x40)); if (iVar2 < 0) { ExceptionList = local_10; return; } layerFrames = (this->ControllerSelectSprite)._animState._layerFrames; } AnimationLayer::RenderFrame (GHIDRA_CAST((iVar2 * 0x10 + *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x18)))),&renderPos, *GHIDRA_CAST((GHIDRA_CAST(layerFrames) + iVar2 * 4)),&g_vectorZero,&g_vectorZero,animation); } ExceptionList = local_10; return; }