//
// PlayerObject::updateRobotAnimationSpeed from 0x1403a10e0 to 0x1403a14cd (1005 bytes)
//
// 3 xrefs:
// > PlayerObject::togglePlayerScale @ 0x1403a0d0f
// > PlayerObject::updateTimeMod @ 0x1403a1054
// > ??> @ 0x1406d695c
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=3
void PlayerObject::updateRobotAnimationSpeed(PlayerObject *a1)
{
float v2; // xmm0_4
float v3; // xmm1_4
float m_playerSpeed; // xmm2_4
float v5; // xmm3_4
float v6; // xmm2_4
SpriteAnimationManager *m_animationManager; // rcx
cocos2d::CCDictionary *m_animateDict; // rcx
cocos2d::CCDictElement *m_pElements; // rcx
cocos2d::CCDictElement *i; // rax
cocos2d::CCObject *m_pObject; // rcx
float v12; // xmm1_4
SpriteAnimationManager *v13; // rcx
cocos2d::CCDictionary *v14; // rcx
cocos2d::CCDictElement *v15; // rcx
cocos2d::CCDictElement *j; // rax
cocos2d::CCObject *v17; // rcx
size_t v18; // rdi
unsigned __int64 v19; // rsi
char v20; // r15
void **v21; // rcx
unsigned __int64 v22; // r14
size_t v23; // r8
bool v24; // r14
void **v25; // rcx
size_t v26; // r8
void *v27; // rcx
char *v28; // rdx
float v29; // xmm0_4
__int64 v30; // rax
void *Buf1[2]; // [rsp+28h] [rbp-21h] BYREF
unsigned __int64 v32; // [rsp+38h] [rbp-11h]
unsigned __int64 v33; // [rsp+40h] [rbp-9h]
void *Block[2]; // [rsp+48h] [rbp-1h] BYREF
__int64 v35; // [rsp+58h] [rbp+Fh]
__int64 v36; // [rsp+60h] [rbp+17h]
__int128 Buf2; // [rsp+68h] [rbp+1Fh] BYREF
__int64 v38; // [rsp+78h] [rbp+2Fh]
__int64 v39; // [rsp+80h] [rbp+37h]
v2 = 1.0;
v3 = 1.0;
m_playerSpeed = a1->m_playerSpeed;
if ( m_playerSpeed != 0.89999998 )
{
if ( m_playerSpeed == 0.69999999 )
{
v3 = 0.89999998;
}
else if ( m_playerSpeed == 1.1 )
{
v3 = 1.15;
}
else if ( m_playerSpeed == 1.3 )
{
v3 = 1.3;
}
else if ( m_playerSpeed == 1.6 )
{
v3 = 1.5;
}
}
if ( a1->m_vehicleSize < 1.0 )
v2 = 0.85000002;
v5 = v2;
if ( m_playerSpeed >= 1.1 )
v5 = v2 * 1.1;
v6 = v3 / v2;
m_animationManager = a1->m_robotSprite->m_animationManager;
if ( m_animationManager->m_speed != (float)(v3 / v2) )
{
m_animationManager->m_speed = v6;
m_animateDict = m_animationManager->m_animateDict;
if ( m_animateDict )
{
m_pElements = m_animateDict->m_pElements;
if ( m_pElements )
{
for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )
{
m_pObject = m_pElements->m_pObject;
if ( !m_pObject->m_eObjType )
*(float *)&m_pObject[1].m_uReference = v6;
m_pElements = i;
if ( !i )
break;
}
}
}
}
v12 = v3 / v5;
v13 = a1->m_spiderSprite->m_animationManager;
if ( v13->m_speed != v12 )
{
v13->m_speed = v12;
v14 = v13->m_animateDict;
if ( v14 )
{
v15 = v14->m_pElements;
if ( v15 )
{
for ( j = (cocos2d::CCDictElement *)v15->hh.next; ; j = (cocos2d::CCDictElement *)j->hh.next )
{
v17 = v15->m_pObject;
if ( !v17->m_eObjType )
*(float *)&v17[1].m_uReference = v12;
v15 = j;
if ( !j )
break;
}
}
}
}
v18 = 4;
if ( a1->m_isSpider )
{
sub_14003BDB0((__int64)Buf1, (__int64)&a1->m_spiderSprite->m_animationManager->m_currentAnimation);
Buf2 = 0;
v38 = 4;
v19 = 15;
v39 = 15;
strcpy((char *)&Buf2, "walk");
v20 = 5;
v21 = Buf1;
if ( v33 > 0xF )
v21 = (void **)Buf1[0];
v22 = v32;
v23 = v32;
if ( v32 > 4 )
v23 = 4;
if ( !memcmp(v21, &Buf2, v23) && v22 == 4 )
{
v19 = v36;
v24 = 1;
}
else
{
*(_OWORD *)Block = 0;
v35 = 3;
v36 = 15;
LOWORD(Block[0]) = *(_WORD *)"run";
WORD1(Block[0]) = (unsigned __int8)aRun[2];
v20 = 7;
v25 = Buf1;
if ( v33 > 0xF )
v25 = (void **)Buf1[0];
v26 = v22;
if ( v22 > 3 )
v26 = 3;
v24 = !memcmp(v25, Block, v26) && v22 == 3;
}
if ( (v20 & 2) != 0 && v19 > 0xF )
{
v27 = Block[0];
if ( v19 + 1 >= 0x1000 )
{
v27 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v27 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v27);
}
if ( v24 )
PlayerObject::playDynamicSpiderRun(a1);
sub_14003A830((__int64)Buf1);
}
if ( a1->m_robotAnimation1Enabled && a1->m_playerSpeed == 0.69999999 )
{
v28 = "run3";
}
else if ( a1->m_robotAnimation2Enabled && ((v29 = a1->m_playerSpeed, v29 == 1.3) || v29 == 1.6) )
{
v28 = "run2";
}
else
{
v28 = "run";
v18 = 3;
}
sub_14003CCE0((void **)&a1->m_currentRobotAnimation, v28, v18);
if ( a1->m_isRobot )
{
sub_14003BDB0((__int64)&Buf2, (__int64)&a1->m_robotSprite->m_animationManager->m_currentAnimation);
if ( sub_14003A760(&Buf2, &a1->m_currentRobotAnimation.m_data.m_bigStorage) )
{
v30 = sub_14003BDB0((__int64)Buf1, (__int64)&a1->m_currentRobotAnimation);
CCAnimatedSprite::runAnimation((__int64)a1->m_robotSprite, v30);
}
sub_14003A830((__int64)&Buf2);
}
}