//
// SmartGameObject::updateSmartFrame from 0x1001b0d10 to 0x1001b0ed2 (450 bytes)
//
// 6 xrefs:
// > EditorUI::createSmartObjectsFromTemplate @ 0x100043274
// > EditorUI::createPrefab @ 0x100043abf
// > SmartGameObject::customObjectSetup @ 0x1001b1542
// > SmartGameObject::customObjectSetup @ 0x1001b156d
// > SetupSmartBlockLayer::onClose @ 0x1004e6c62
// > SetupSmartBlockLayer::onClose @ 0x1004e6cc2
//
// 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
//
void __fastcall SmartGameObject::updateSmartFrame(SmartGameObject *a1)
{
double v1; // xmm0_8
int m_objectID; // eax
const char *v4; // rax
std::string::value_type *v5; // r14
size_t v6; // rax
size_t v7; // r12
char *v8; // r15
char *v9; // r13
size_t v10; // r14
void *v11; // r13
unsigned int sizex2; // eax
std::array *p_shortStorage; // rdi
std::size_t size; // rax
size_t v15; // rdx
bool v16; // zf
char v17; // r15
cocos2d::CCSpriteFrameCache *v18; // rax
std::array *longStorage; // rsi
cocos2d::CCSpriteFrame *v20; // rax
size_t __dst; // [rsp+8h] [rbp-48h] BYREF
size_t v22; // [rsp+10h] [rbp-40h]
void *__s2; // [rsp+18h] [rbp-38h]
std::string::value_type *__s; // [rsp+20h] [rbp-30h]
m_objectID = a1->m_objectID;
switch ( m_objectID )
{
case 2897:
v4 = "smartBlock03b_001.png";
v5 = (std::string::value_type *)"smartBlock03_001.png";
break;
case 2896:
v4 = "smartBlock02b_001.png";
v5 = (std::string::value_type *)"smartBlock02_001.png";
break;
case 2895:
v4 = "smartBlock01b_001.png";
v5 = (std::string::value_type *)"smartBlock01_001.png";
break;
default:
return;
}
if ( a1->m_referenceOnly )
v5 = (std::string::value_type *)v4;
v6 = strlen(v5);
if ( v6 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v1);
v7 = v6;
v8 = (char *)&__dst + 1;
__s = v5;
if ( v6 >= 0x17 )
{
v10 = 26;
if ( (v6 | 7) != 0x17 )
v10 = (v6 | 7) + 1;
v9 = (char *)operator new(v10);
__s2 = v9;
__dst = v10 + 1;
v5 = __s;
v22 = v7;
}
else
{
LOBYTE(__dst) = 2 * v6;
v9 = (char *)&__dst + 1;
if ( !v6 )
goto LABEL_17;
}
memcpy(v9, v5, v7);
LABEL_17:
v9[v7] = 0;
v11 = __s2;
sizex2 = a1->m_smartFrame.m_data.m_short.sizex2;
p_shortStorage = &a1->m_smartFrame.m_data.m_short.shortStorage;
if ( (sizex2 & 1) != 0 )
{
size = a1->m_smartFrame.m_data.m_long.size;
p_shortStorage = (std::array *)a1->m_smartFrame.m_data.m_long.longStorage;
}
else
{
size = sizex2 >> 1;
}
v15 = (unsigned __int8)__dst >> 1;
if ( (__dst & 1) != 0 )
{
v15 = v22;
v8 = (char *)__s2;
}
v16 = v15 == size;
if ( v15 >= size )
v15 = size;
v17 = v16 & (memcmp(p_shortStorage, v8, v15) == 0);
if ( (__dst & 1) != 0 )
operator delete(v11);
if ( !v17 )
{
std::string::assign((std::string *)&a1->m_smartFrame, __s);
v18 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
longStorage = &a1->m_smartFrame.m_data.m_short.shortStorage;
if ( (a1->m_smartFrame.m_data.m_short.sizex2 & 1) != 0 )
longStorage = (std::array *)a1->m_smartFrame.m_data.m_long.longStorage;
v20 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v18, longStorage->__elems_);
((void (__fastcall *)(SmartGameObject *, cocos2d::CCSpriteFrame *))a1->setDisplayFrame)(a1, v20);
}
}