//
// StartPosLayer::addSpeedButtons from 0x14045f9f0 to 0x14045fc87 (663 bytes)
//
// 2 xrefs:
// > StartPosLayer::init @ 0x14045e1e5
// > ??> @ 0x140927df4
//
// 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::addSpeedButtons(__int64 a1)
{
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rcx
cocos2d::CCObject *v5; // rax
__int64 v6; // rcx
cocos2d::CCArray *v7; // r15
int v8; // edi
int v9; // esi
const char *v10; // rcx
struct cocos2d::CCObject *v11; // r14
__int64 *v12; // rax
cocos2d::CCObject *v13; // rbx
__int64 v14; // rdx
__int64 v15; // rax
int v16; // ecx
int v17; // ecx
int v18; // ecx
int v19; // ecx
float v21[2]; // [rsp+30h] [rbp-78h] BYREF
void *v22; // [rsp+38h] [rbp-70h] BYREF
_BYTE v23[8]; // [rsp+40h] [rbp-68h] BYREF
_QWORD v24[4]; // [rsp+48h] [rbp-60h] BYREF
*(_DWORD *)(a1 + 1012) = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 1000) + 1856LL) + 332LL);
v2 = cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v2, v21);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v22,
v21[0] * 0.5,
(float)((float)(*(float *)(a1 + 736) * 0.5) + (float)(v21[1] * 0.5)) - 85.0);
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), v23, v3);
v5 = (cocos2d::CCObject *)cocos2d::CCArray::create(v4);
*(_QWORD *)(a1 + 1024) = v5;
cocos2d::CCObject::retain(v5);
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
v8 = 0;
v9 = 1;
do
{
SelectSettingLayer::frameForItem((__int64)v24, 2u, v8);
v10 = (const char *)v24;
if ( v24[3] > 0xFu )
v10 = (const char *)v24[0];
v11 = cocos2d::CCSprite::createWithSpriteFrameName(v10);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 1024), v11);
(*(void (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v11 + 160LL))(v11);
v22 = operator new(0x208u);
v12 = (__int64 *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v22);
v13 = (cocos2d::CCObject *)v12;
if ( v12 )
{
if ( CCMenuItemSpriteExtra::init(v12, (__int64 *)v11, 0, a1, (__int64)StartPosLayer::onSelectSpeed) )
{
cocos2d::CCObject::autorelease(v13);
goto LABEL_9;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v13 + 8LL))(v13, 1);
}
v13 = nullptr;
LABEL_9:
if ( v8 )
{
switch ( v8 )
{
case 1:
goto LABEL_14;
case 2:
v14 = 2;
break;
case 3:
v14 = 3;
break;
case 4:
v14 = 4;
break;
default:
LABEL_14:
v14 = 0;
break;
}
}
else
{
v14 = 1;
}
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v13 + 64LL))(v13, v14);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v13);
cocos2d::CCArray::addObject(v7, v13);
sub_14003D310((__int64)v24);
++v8;
}
while ( v8 < 5 );
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v22, (const struct cocos2d::CCPoint *)v23);
GameToolbox::alignItemsHorisontally((__int64)v7, 10.0, v15, 0);
v16 = *(_DWORD *)(a1 + 1012);
if ( v16 )
{
v17 = v16 - 1;
if ( v17 )
{
v18 = v17 - 1;
if ( v18 )
{
v19 = v18 - 1;
if ( v19 )
{
if ( v19 == 1 )
v9 = 4;
}
else
{
v9 = 3;
}
}
else
{
v9 = 2;
}
}
else
{
v9 = 0;
}
}
return sub_14045F690(*(cocos2d::CCArray **)(a1 + 1024), v9);
}