#include "classes.h" // 004073b0 uint8_t AnimationState::IsLoopingAnimation() { if (this->_animData == (void *)0x0) { return 0; } return *GHIDRA_CAST((GHIDRA_CAST(this->_animData) + 0x34)); } // 004086e0 AnimationState::AnimationState(void *owner, AnimationState *other) { void *animData; int64_t allocBytes; this->_animation = owner; animData = other->_animData; this->_animData = animData; if ((animData == (void *)0x0) || (*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x1c)) == 0)) { this->_layerFrames = (void *)0x0; } else { allocBytes = (uint64_t)*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x1c)) * 4; animData = operator_new_tracked (-GHIDRA_UINT((GHIDRA_INT(((uint64_t)allocBytes >> 0x20)) != 0)) | GHIDRA_UINT(allocBytes)); this->_layerFrames = animData; memcpy(animData,other->_layerFrames,*GHIDRA_CAST((GHIDRA_CAST(this->_animData) + 0x1c)) << 2); animData = this->_animData; } if ((animData == (void *)0x0) || (*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x24)) == 0)) { this->_nullLayerFrames = (void *)0x0; } else { allocBytes = (uint64_t)*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x24)) * 4; animData = operator_new_tracked (-GHIDRA_UINT((GHIDRA_INT(((uint64_t)allocBytes >> 0x20)) != 0)) | GHIDRA_UINT(allocBytes)); this->_nullLayerFrames = animData; memcpy(animData,other->_nullLayerFrames,*GHIDRA_CAST((GHIDRA_CAST(this->_animData) + 0x24)) << 2); } this->_animFrame = other->_animFrame; this->_isPlaying = other->_isPlaying; this->_currentlyTriggeredEvents = other->_currentlyTriggeredEvents; this->_previouslyTriggeredEvents = other->_previouslyTriggeredEvents; return; } // 00408ef0 void AnimationState::SetLayerFrame(int layerID, int frame) { void *animData; int dataLayerId; if (((layerID < 0) || (*GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x80)) <= layerID)) && (KAGE_LogMessage(0x10,GHIDRA_CAST("LayerId out of bounds\n")), layerID < 0)) { return; } if (layerID < *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x80))) { animData = this->_animData; dataLayerId = *GHIDRA_CAST((GHIDRA_CAST(animData) + layerID * 4 + 0x38)); if (((animData == (void *)0x0) || (dataLayerId < 0)) || (*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x1c)) <= dataLayerId)) { KAGE_LogMessage(0x10,GHIDRA_CAST("id out of bounds\n")); } *GHIDRA_CAST((GHIDRA_CAST(this->_layerFrames) + dataLayerId * 4)) = 0; AdvanceLayerPosition(this,dataLayerId,(float)frame); } return; } // 00408f70 int AnimationState::GetLayerFrameIdx(int layerId) { if (((layerId < 0) || (*GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x80)) <= layerId)) && (KAGE_LogMessage(0x10,GHIDRA_CAST("LayerId out of bounds\n")), layerId < 0)) { return 0; } if (layerId < *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x80))) { return *GHIDRA_CAST((GHIDRA_INT(this->_layerFrames) + *GHIDRA_CAST((GHIDRA_CAST(this->_animData) + layerId * 4 + 0x38)) * 4)); } return 0; } // 00408fc0 void AnimationState::SetNullLayerFrame(int nullLayerId, int frame) { if ((nullLayerId < 0) || (*GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x88)) <= nullLayerId)) { KAGE_LogMessage(0x10,GHIDRA_CAST("layerId out of bounds\n")); } if (((this->_animData == (void *)0x0) || (nullLayerId < 0)) || (*GHIDRA_CAST((GHIDRA_CAST(this->_animData) + 0x24)) <= nullLayerId)) { KAGE_LogMessage(0x10,GHIDRA_CAST("id out of bounds\n")); } *GHIDRA_CAST((GHIDRA_CAST(this->_nullLayerFrames) + nullLayerId * 4)) = 0; AdvanceNullLayerPosition(this,nullLayerId,(float)frame); return; } // 0040ac70 void * AnimationState::GetNullFrameById(int nullLayerId) { void *animData; int *nullLayer; uint32_t layerIdx; int *layerFrameIt; int frameIndex; animData = this->_animData; if (animData == (void *)0x0) { KAGE_LogMessage(0x10,GHIDRA_CAST("AnimationData is NULL\n")); animData = this->_animData; } layerIdx = 0; if (*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x24)) != 0) { layerFrameIt = this->_nullLayerFrames; nullLayer = *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x20)); do { if (((*nullLayer == nullLayerId) && (frameIndex = *layerFrameIt, -1 < frameIndex)) && (frameIndex < nullLayer[3])) { return (void *)(frameIndex * 0x54 + nullLayer[2]); } layerIdx = layerIdx + 1; nullLayer = nullLayer + 4; layerFrameIt = layerFrameIt + 1; } while (layerIdx < *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x24))); } return (void *)0x0; } // 0040ace0 void * AnimationState::GetNullFrame(uint8_t *nullLayerName) { uint8_t *layerNameCursor; uint32_t cmpResult; void *animData; uint32_t *nullTrack; uint8_t *nameCursor; uint32_t uVar1; uint32_t nullLayerIdx; uint8_t *nullLayerEntry; int *frameIdxPtr; bool isLess; uint8_t ch; int frameIdx; if (this->_animData == (void *)0x0) { KAGE_LogMessage(0x10,GHIDRA_CAST("AnimationData is NULL\n")); } nullLayerIdx = 0; uVar1 = *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x88)); if (uVar1 != 0) { nullLayerEntry = *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x84)); do { layerNameCursor = nullLayerEntry; if (0xf < *GHIDRA_CAST((nullLayerEntry + 0x14))) { layerNameCursor = *GHIDRA_CAST(nullLayerEntry); } nameCursor = nullLayerName; do { ch = *layerNameCursor; isLess = ch < *nameCursor; if (ch != *nameCursor) { LAB_0040ad50: cmpResult = -GHIDRA_UINT(isLess) | 1; goto LAB_0040ad55; } if (ch == 0) break; ch = layerNameCursor[1]; isLess = ch < nameCursor[1]; if (ch != nameCursor[1]) goto LAB_0040ad50; layerNameCursor = layerNameCursor + 2; nameCursor = nameCursor + 2; } while (ch != 0); cmpResult = 0; LAB_0040ad55: if (cmpResult == 0) { animData = this->_animData; if (animData == (void *)0x0) { KAGE_LogMessage(0x10,GHIDRA_CAST("AnimationData is NULL\n")); animData = this->_animData; } uVar1 = 0; if (*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x24)) != 0) { nullTrack = *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x20)); frameIdxPtr = this->_nullLayerFrames; do { if (((*nullTrack == nullLayerIdx) && (frameIdx = *frameIdxPtr, -1 < frameIdx)) && (frameIdx < GHIDRA_INT(nullTrack[3]))) { return (void *)(frameIdx * 0x54 + nullTrack[2]); } uVar1 = uVar1 + 1; nullTrack = nullTrack + 4; frameIdxPtr = frameIdxPtr + 1; } while (uVar1 < *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x24))); } return (void *)0x0; } nullLayerIdx = nullLayerIdx + 1; nullLayerEntry = nullLayerEntry + 0x18; } while (nullLayerIdx < uVar1); } return (void *)0x0; } // 0040add0 uint8_t AnimationState::IsEventTriggered(uint8_t *eventName) { uint8_t *eventNameChar; uint32_t compareResult; uint8_t *queryChar; uint8_t *eventEntry; uint32_t eventIndex; bool isLess; uint8_t ch; uint32_t eventCount; if (this->_animData == (void *)0x0) { KAGE_LogMessage(0x10,GHIDRA_CAST("AnimationData is NULL\n")); } eventIndex = 0; eventCount = *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x90)); if (eventCount != 0) { eventEntry = *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x8c)); do { eventNameChar = eventEntry; if (0xf < *GHIDRA_CAST((eventEntry + 0x14))) { eventNameChar = *GHIDRA_CAST(eventEntry); } queryChar = eventName; do { ch = *eventNameChar; isLess = ch < *queryChar; if (ch != *queryChar) { LAB_0040ae32: compareResult = -GHIDRA_UINT(isLess) | 1; goto LAB_0040ae37; } if (ch == 0) break; ch = eventNameChar[1]; isLess = ch < queryChar[1]; if (ch != queryChar[1]) goto LAB_0040ae32; eventNameChar = eventNameChar + 2; queryChar = queryChar + 2; } while (ch != 0); compareResult = 0; LAB_0040ae37: if (compareResult == 0) { if (GHIDRA_INT(eventIndex) < 0) { return 0; } return (this->_currentlyTriggeredEvents & 1 << ((uint8_t)eventIndex & 0x1f)) != 0; } eventIndex = eventIndex + 1; eventEntry = eventEntry + 0x18; } while (eventIndex < eventCount); } return 0; } // 0040ae70 uint8_t AnimationState::WasEventTriggered(uint8_t *eventName) { uint8_t *entryNameCursor; uint32_t compareResult; uint8_t *wantedName; uint8_t *eventEntry; uint32_t eventIdx; bool isLess; uint32_t eventCount; uint8_t nameChar; if (this->_animData == (void *)0x0) { KAGE_LogMessage(0x10,GHIDRA_CAST("AnimationData is NULL\n")); } eventIdx = 0; eventCount = *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x90)); if (eventCount != 0) { eventEntry = *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x8c)); do { entryNameCursor = eventEntry; if (0xf < *GHIDRA_CAST((eventEntry + 0x14))) { entryNameCursor = *GHIDRA_CAST(eventEntry); } wantedName = eventName; do { nameChar = *entryNameCursor; isLess = nameChar < *wantedName; if (nameChar != *wantedName) { LAB_0040aed2: compareResult = -GHIDRA_UINT(isLess) | 1; goto LAB_0040aed7; } if (nameChar == 0) break; nameChar = entryNameCursor[1]; isLess = nameChar < wantedName[1]; if (nameChar != wantedName[1]) goto LAB_0040aed2; entryNameCursor = entryNameCursor + 2; wantedName = wantedName + 2; } while (nameChar != 0); compareResult = 0; LAB_0040aed7: if (compareResult == 0) { if (GHIDRA_INT(eventIdx) < 0) { return 0; } return (this->_previouslyTriggeredEvents & 1 << ((uint8_t)eventIdx & 0x1f)) != 0; } eventIdx = eventIdx + 1; eventEntry = eventEntry + 0x18; } while (eventIdx < eventCount); } return 0; } // 0040af10 int AnimationState::NextEventTrigger(uint8_t *eventName) { uint8_t *triggerName; uint32_t compareResult; uint8_t *wantedName; uint32_t uVar1; int framesUntil; uint32_t eventIndex; uint8_t *eventNameEntry; int nearestDelta; int nextFrame; bool isLess; int bestFrame; void *animData; uint8_t ch; int eventFrame; if (this->_animData == (void *)0x0) { KAGE_LogMessage(0x10,GHIDRA_CAST("AnimationData is NULL\n")); } eventIndex = 0; uVar1 = *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x90)); if (uVar1 != 0) { eventNameEntry = *GHIDRA_CAST((GHIDRA_CAST(this->_animation) + 0x8c)); do { triggerName = eventNameEntry; if (0xf < *GHIDRA_CAST((eventNameEntry + 0x14))) { triggerName = *GHIDRA_CAST(eventNameEntry); } wantedName = eventName; do { ch = *triggerName; isLess = ch < *wantedName; if (ch != *wantedName) { LAB_0040af74: compareResult = -GHIDRA_UINT(isLess) | 1; goto LAB_0040af79; } if (ch == 0) break; ch = triggerName[1]; isLess = ch < wantedName[1]; if (ch != wantedName[1]) goto LAB_0040af74; triggerName = triggerName + 2; wantedName = wantedName + 2; } while (ch != 0); compareResult = 0; LAB_0040af79: if (compareResult == 0) { if (GHIDRA_INT(eventIndex) < 0) { return -1; } nextFrame = -1; uVar1 = 0; bestFrame = -1; nearestDelta = -1; animData = this->_animData; if (*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x2c)) != 0) { do { if (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x28)) + uVar1 * 8)) == eventIndex) { eventFrame = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x28)) + 4 + uVar1 * 8)); framesUntil = eventFrame - GHIDRA_INT(this->_animFrame); nextFrame = bestFrame; if ((0 < framesUntil) && ((nearestDelta < 0 || (framesUntil < nearestDelta)))) { nearestDelta = framesUntil; nextFrame = eventFrame; bestFrame = eventFrame; } } uVar1 = uVar1 + 1; } while (uVar1 < *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x2c))); } return nextFrame; } eventIndex = eventIndex + 1; eventNameEntry = eventNameEntry + 0x18; } while (eventIndex < uVar1); } return -1; } // 0040bbf0 AnimationState * AnimationState::copy_assign(AnimationState *other) { void *pvVar1; int iVar2; int iVar3; void *pvVar4; void *pvVar5; undefined3 uVar6; uint8_t isPlaying; pvVar1 = other->_animData; this->_animation = other->_animation; this->_animData = pvVar1; pvVar1 = other->_nullLayerFrames; this->_layerFrames = other->_layerFrames; this->_nullLayerFrames = pvVar1; isPlaying = other->_isPlaying; uVar6 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((other)) + 0x15)))); this->_animFrame = other->_animFrame; this->_isPlaying = isPlaying; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x15)))) = uVar6; iVar2 = other->_previouslyTriggeredEvents; this->_currentlyTriggeredEvents = other->_currentlyTriggeredEvents; this->_previouslyTriggeredEvents = iVar2; pvVar1 = other[1]._animData; this[1]._animation = other[1]._animation; this[1]._animData = pvVar1; this[1]._layerFrames = other[1]._layerFrames; *GHIDRA_CAST(&this[1]._nullLayerFrames) = *GHIDRA_CAST(&other[1]._nullLayerFrames); isPlaying = other[1]._isPlaying; uVar6 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(other[1])) + 0x15)))); iVar2 = other[1]._currentlyTriggeredEvents; iVar3 = other[1]._previouslyTriggeredEvents; this[1]._animFrame = other[1]._animFrame; this[1]._isPlaying = isPlaying; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x15)))) = uVar6; this[1]._currentlyTriggeredEvents = iVar2; this[1]._previouslyTriggeredEvents = iVar3; pvVar1 = other[2]._animData; pvVar4 = other[2]._layerFrames; pvVar5 = other[2]._nullLayerFrames; this[2]._animation = other[2]._animation; this[2]._animData = pvVar1; this[2]._layerFrames = pvVar4; this[2]._nullLayerFrames = pvVar5; isPlaying = other[2]._isPlaying; uVar6 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(other[2])) + 0x15)))); this[2]._animFrame = other[2]._animFrame; this[2]._isPlaying = isPlaying; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[2])) + 0x15)))) = uVar6; this[2]._currentlyTriggeredEvents = other[2]._currentlyTriggeredEvents; this[2]._previouslyTriggeredEvents = other[2]._previouslyTriggeredEvents; *GHIDRA_CAST(&this[3]._animation) = *GHIDRA_CAST(&other[3]._animation); this[3]._animData = other[3]._animData; this[3]._layerFrames = other[3]._layerFrames; return this; } // 00440e30 int AnimationState::GetAnimationLength() { if (this->_animData == (void *)0x0) { return 0; } return *GHIDRA_CAST((GHIDRA_CAST(this->_animData) + 0x30)); }