//
// StartPosLayer::addModeButtons from 0x14045f710 to 0x14045f985 (629 bytes)
//
// 2 xrefs:
// > StartPosLayer::init @ 0x14045e1dd
// > ??> @ 0x140927ddc
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:32:33 +0000
//
// Hidden C++ exception states: #wind=2
unsigned int __fastcall StartPosLayer::addModeButtons(__int64 a1)
{
__int64 v2; // rax
char v3; // r14
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rcx
cocos2d::CCObject *v7; // rax
__int64 v8; // rcx
cocos2d::CCArray *v9; // r15
int i; // edi
const char *v11; // rcx
struct cocos2d::CCSprite *v12; // rsi
__int64 *v13; // rax
cocos2d::CCObject *v14; // rbx
__int64 v15; // rdx
__int64 v16; // rax
float v18[2]; // [rsp+30h] [rbp-78h] BYREF
void *v19; // [rsp+38h] [rbp-70h] BYREF
_BYTE v20[8]; // [rsp+40h] [rbp-68h] BYREF
_QWORD v21[4]; // [rsp+48h] [rbp-60h] BYREF
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 1000) + 1856LL);
v3 = *(_BYTE *)(v2 + 341);
*(_DWORD *)(a1 + 1008) = *(_DWORD *)(v2 + 328);
v4 = cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v4, v18);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v19,
v18[0] * 0.5,
(float)((float)(*(float *)(a1 + 736) * 0.5) + (float)(v18[1] * 0.5)) - 30.0);
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), v20, v5);
v7 = (cocos2d::CCObject *)cocos2d::CCArray::create(v6);
*(_QWORD *)(a1 + 1016) = v7;
cocos2d::CCObject::retain(v7);
v9 = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
for ( i = 0; i < 8; ++i )
{
SelectSettingLayer::frameForItem((__int64)v21, v3 != 0, i);
v11 = (const char *)v21;
if ( v21[3] > 0xFu )
v11 = (const char *)v21[0];
v12 = cocos2d::CCSprite::createWithSpriteFrameName(v11);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 1016), v12);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v12 + 160LL))(v12);
v19 = operator new(0x208u);
v13 = (__int64 *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v19);
v14 = (cocos2d::CCObject *)v13;
if ( !v13 )
goto LABEL_8;
if ( !CCMenuItemSpriteExtra::init(v13, (__int64 *)v12, 0, a1, (__int64)StartPosLayer::onSelectMode) )
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v14 + 8LL))(v14, 1);
LABEL_8:
v14 = nullptr;
goto LABEL_9;
}
cocos2d::CCObject::autorelease(v14);
LABEL_9:
if ( v3 && (i == 4 || i == 7) )
{
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v14 + 936LL))(v14, 0);
LOBYTE(v15) = 125;
(*(void (__fastcall **)(__int64, __int64))(*((_QWORD *)v12 + 40) + 40LL))((__int64)v12 + 320, v15);
}
(*(void (__fastcall **)(cocos2d::CCObject *, _QWORD))(*(_QWORD *)v14 + 64LL))(v14, (unsigned int)i);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v14);
cocos2d::CCArray::addObject(v9, v14);
sub_14003D310((__int64)v21);
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v19, (const struct cocos2d::CCPoint *)v20);
GameToolbox::alignItemsHorisontally((__int64)v9, 5.0, v16, 0);
return sub_14045F690(*(cocos2d::CCArray **)(a1 + 1016), *(_DWORD *)(a1 + 1008));
}