//
// GJSmartBlockPreview::addTemplateGuide_1 from 0x100428c70 to 0x100429176 (1286 bytes)
//
// 2 xrefs:
// > GJSmartBlockPreview::addTemplateGuide @ 0x100428a5d
// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1004e9b5e
//
// 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
//
cocos2d::CCArray *__fastcall GJSmartBlockPreview::addTemplateGuide_1(
GJSmartBlockPreview *a1,
SmartPrefabResult a2,
float a3)
{
__int64 v3; // rsi
GJSmartBlockPreview_vtbl *v4; // rax
__int64 v5; // rax
double v6; // xmm0_8
cocos2d::CCNode *v7; // r12
size_t v8; // rbx
ObjectToolbox *v9; // rax
int v10; // esi
const char *v11; // r15
size_t v12; // rax
std::string::size_type v13; // r14
char *v14; // r13
const char *data; // rdi
cocos2d::CCSprite *v16; // r14
cocos2d::CCSprite_vtbl *v17; // rcx
std::string::size_type v18; // r12
int v19; // ecx
std::string::size_type v20; // r13
int v21; // ebx
const std::string::value_type *v22; // rsi
int v23; // ecx
const char *v24; // rdi
cocos2d::CCSprite *v25; // r14
unsigned int v26; // eax
int v27; // ecx
int v28; // ecx
bool v29; // zf
void (__cdecl *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // rax
unsigned int v31; // ebx
unsigned __int64 v33; // [rsp+Ch] [rbp-84h] BYREF
unsigned __int64 v34; // [rsp+14h] [rbp-7Ch] BYREF
unsigned int v35; // [rsp+1Ch] [rbp-74h]
std::string *v36; // [rsp+20h] [rbp-70h]
std::string *v37; // [rsp+28h] [rbp-68h]
cocos2d::CCArray *v38; // [rsp+30h] [rbp-60h]
size_t v39; // [rsp+38h] [rbp-58h]
std::string __dst; // [rsp+40h] [rbp-50h] BYREF
float v41; // [rsp+58h] [rbp-38h]
unsigned __int64 v42; // [rsp+5Ch] [rbp-34h] BYREF
__int16 v43; // [rsp+64h] [rbp-2Ch] BYREF
char v44; // [rsp+66h] [rbp-2Ah]
double v45; // 0:xmm0_8.8
cocos2d::CCPoint v46; // 0:xmm0_8.8
v41 = a3;
v38 = (cocos2d::CCArray *)sub_10071F9E0(a1, v3);
*(float *)&v36 = *(float *)((__int64 (__fastcall *)(GJSmartBlockPreview *))a1->getContentSize)(a1) * 0.5;
v4 = a1->__vftable;
v37 = (std::string *)a1;
v5 = ((__int64 (__fastcall *)(GJSmartBlockPreview *))v4->getContentSize)(a1);
*(_QWORD *)&v6 = (unsigned int)v36;
sub_10028CBE0((float *)&v33, *(float *)&v36, 0.5 * *(float *)(v5 + 4));
v44 = -1;
v43 = -1;
if ( !*(_DWORD *)(v3 + 56) )
{
if ( *(_QWORD *)v3 )
{
v44 = 0;
v43 = -256;
}
else
{
v44 = 0;
v43 = 255;
}
}
v7 = (cocos2d::CCNode *)operator new(0x140u);
cocos2d::CCNode::CCNode((__int64)v7);
v7->__vftable = (cocos2d::CCNode_vtbl *)off_1009350C0;
if ( cocos2d::CCNode::init(v7) )
{
cocos2d::CCObject::autorelease(v7);
}
else
{
((void (__fastcall *)(cocos2d::CCNode *))v7->~CCNode_0)(v7);
v7 = nullptr;
}
(*(void (__fastcall **)(std::string *, cocos2d::CCNode *))(v37->__r_.__value_.__r.__words[0] + 440))(v37, v7);
v36 = (std::string *)(v3 + 8);
v8 = (unsigned int)*std::string::at((std::string *)(v3 + 8), 0);
v9 = ObjectToolbox::sharedState();
v10 = 2895;
if ( (unsigned __int8)(v8 - 50) <= 0x1Au )
v10 = *(_DWORD *)&aP_1[4 * (unsigned __int8)(v8 - 50)];
v11 = ObjectToolbox::intKeyToFrame(v9, v10);
v12 = strlen(v11);
if ( v12 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v6);
v13 = v12;
if ( v12 >= 0x17 )
{
v39 = v8;
v8 = 26;
if ( (v12 | 7) != 0x17 )
v8 = (v12 | 7) + 1;
v14 = (char *)operator new(v8);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)v14;
__dst.__r_.__value_.__r.__words[0] = v8 + 1;
LODWORD(v8) = v39;
__dst.__r_.__value_.__l.__size_ = v13;
LABEL_53:
memmove(v14, v11, v13);
data = __dst.__r_.__value_.__s.__data_;
v14[v13] = 0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_15;
goto LABEL_14;
}
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v12);
v14 = __dst.__r_.__value_.__s.__data_;
if ( v12 )
goto LABEL_53;
data = __dst.__r_.__value_.__s.__data_;
__dst.__r_.__value_.__s.__data_[0] = 0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
LABEL_14:
data = __dst.__r_.__value_.__l.__data_;
LABEL_15:
v16 = cocos2d::CCSprite::createWithSpriteFrameName(data);
GJSmartTemplate::applyTransformationsForType((SmartBlockType)v8, v16);
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))v16->setColor)(v16, &v43);
*(cocos2d::CCPoint *)&v45 = GJSmartTemplate::offsetForType((SmartBlockType)&v34);
sub_10028CCE0((double *)&v42, &v33, &v34);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *, double))v16->setPosition)(v16, &v42, v45);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSprite *, _QWORD))v7->addChild_0)(v7, v16, 0);
v17 = v16->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v35 = (unsigned __int8)(int)(float)(255.0 * v41);
((void (__fastcall *)(cocos2d::CCSprite *))v17->setOpacity)(v16);
sub_10071FCD0(v38, v16);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v16->setTag)(v16, 0);
v39 = (size_t)v7;
v37 = (std::string *)((char *)v37 + 320);
v18 = 0;
LODWORD(v41) = (unsigned __int8)(int)(float)(v41 * 150.0);
do
{
v20 = v18++;
v21 = (unsigned __int8)*std::string::at(v36, v18);
v22 = "smartBlock02b_001.png";
switch ( v21 )
{
case '2':
case '3':
case '4':
case '5':
break;
case '6':
case '8':
case 'A':
case 'C':
case 'E':
case 'G':
case 'I':
case 'K':
v22 = "smartBlock03b_001.png";
break;
case '7':
case 'B':
if ( (unsigned int)(v20 + 1) > 8 )
goto LABEL_27;
v19 = 326;
if ( !_bittest(&v19, v20 + 1) )
goto LABEL_27;
continue;
case '9':
case 'D':
if ( (unsigned int)(v20 + 1) > 7 )
goto LABEL_27;
v23 = 166;
if ( !_bittest(&v23, v20 + 1) )
goto LABEL_27;
continue;
case 'F':
case 'H':
if ( (((_DWORD)v20 - 2) & 0xFFFFFFFA) != 0 )
goto LABEL_27;
continue;
case 'J':
case 'L':
if ( (unsigned int)(v20 - 2) < 4 )
continue;
LABEL_27:
if ( (unsigned __int8)(v21 - 55) >= 0x16u )
goto LABEL_29;
v22 = (char *)dword_10081BB1C + dword_10081BB1C[(unsigned __int8)(v21 - 55)];
break;
default:
LABEL_29:
v22 = "smartBlock01b_001.png";
break;
}
std::string::assign(&__dst, v22);
v24 = __dst.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
v24 = __dst.__r_.__value_.__l.__data_;
v25 = cocos2d::CCSprite::createWithSpriteFrameName(v24);
GJSmartTemplate::applyTransformationsForType((SmartBlockType)(char)v21, v25);
(*(void (__fastcall **)(size_t, cocos2d::CCSprite *, _QWORD))(*(_QWORD *)v39 + 448LL))(v39, v25, 0);
v46 = GJSmartTemplate::offsetForType((SmartBlockType)&v42);
v26 = v20 + 1;
if ( (unsigned int)(v20 + 1) <= 6 )
{
v27 = 98;
if ( _bittest(&v27, v26) )
{
v46 = (cocos2d::CCPoint)HIDWORD(v42);
v46.x = *((float *)&v42 + 1) + 30.0;
*((float *)&v42 + 1) = *((float *)&v42 + 1) + 30.0;
}
}
if ( v26 <= 8 )
{
v28 = 388;
if ( _bittest(&v28, v26) )
{
v46 = (cocos2d::CCPoint)HIDWORD(v42);
v46.x = *((float *)&v42 + 1) + -30.0;
*((float *)&v42 + 1) = *((float *)&v42 + 1) + -30.0;
}
}
if ( (v26 & 0xB) == 3 || v20 == 4 )
{
v46 = (cocos2d::CCPoint)(unsigned int)v42;
v46.x = *(float *)&v42 + -30.0;
*(float *)&v42 = *(float *)&v42 + -30.0;
}
if ( (v26 & 0xD) == 4 || v20 == 7 )
{
v46 = (cocos2d::CCPoint)(unsigned int)v42;
v46.x = *(float *)&v42 + 30.0;
*(float *)&v42 = *(float *)&v42 + 30.0;
}
sub_10028CCE0((double *)&v34, &v33, &v42);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *, double))v25->setPosition)(v25, &v34, *(double *)&v46);
v29 = *std::string::at(v37, v18) == 48;
setColor = v25->setColor;
if ( v29 )
{
((void (__fastcall *)(cocos2d::CCSprite *, void *))setColor)(v25, &unk_10081B8F8);
v31 = 2;
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v25->setOpacity)(v25, LODWORD(v41));
}
else
{
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))setColor)(v25, &v43);
v31 = 1;
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v25->setOpacity)(v25, v35);
}
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v25->setTag)(v25, v31);
sub_10071FCD0(v38, v25);
}
while ( v18 != 8 );
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
return v38;
}