//
// KeybindingsLayer::addKeyPair from 0x1402c02a0 to 0x1402c0641 (929 bytes)
//
// 50 xrefs:
// > KeybindingsLayer::init @ 0x1402bfc15
// > KeybindingsLayer::init @ 0x1402bfc3e
// > KeybindingsLayer::init @ 0x1402bfc54
// > KeybindingsLayer::init @ 0x1402bfc6a
// > KeybindingsLayer::init @ 0x1402bfc80
// > KeybindingsLayer::init @ 0x1402bfca0
// > KeybindingsLayer::init @ 0x1402bfcc9
// > KeybindingsLayer::init @ 0x1402bfcdf
// > KeybindingsLayer::init @ 0x1402bfcf5
// > KeybindingsLayer::init @ 0x1402bfd0b
// > KeybindingsLayer::init @ 0x1402bfd21
// > KeybindingsLayer::init @ 0x1402bfd37
// > KeybindingsLayer::init @ 0x1402bfd4d
// > KeybindingsLayer::init @ 0x1402bfd63
// > KeybindingsLayer::init @ 0x1402bfd79
// > KeybindingsLayer::init @ 0x1402bfd8f
// > KeybindingsLayer::init @ 0x1402bfda5
// > KeybindingsLayer::init @ 0x1402bfdbb
// > KeybindingsLayer::init @ 0x1402bfdd1
// > KeybindingsLayer::init @ 0x1402bfde7
// > KeybindingsLayer::init @ 0x1402bfdfd
// > KeybindingsLayer::init @ 0x1402bfe13
// > KeybindingsLayer::init @ 0x1402bfe29
// > KeybindingsLayer::init @ 0x1402bfe3f
// > KeybindingsLayer::init @ 0x1402bfe55
// > KeybindingsLayer::init @ 0x1402bfe6b
// > KeybindingsLayer::init @ 0x1402bfe81
// > KeybindingsLayer::init @ 0x1402bfe97
// > KeybindingsLayer::init @ 0x1402bfead
// > KeybindingsLayer::init @ 0x1402bfec3
// > KeybindingsLayer::init @ 0x1402bfed9
// > KeybindingsLayer::init @ 0x1402bfeef
// > KeybindingsLayer::init @ 0x1402bff05
// > KeybindingsLayer::init @ 0x1402bff1b
// > KeybindingsLayer::init @ 0x1402bff31
// > KeybindingsLayer::init @ 0x1402bff47
// > KeybindingsLayer::init @ 0x1402bff5d
// > KeybindingsLayer::init @ 0x1402bff73
// > KeybindingsLayer::init @ 0x1402bff89
// > KeybindingsLayer::init @ 0x1402bff9f
// > KeybindingsLayer::init @ 0x1402bffb5
// > KeybindingsLayer::init @ 0x1402bffcb
// > KeybindingsLayer::init @ 0x1402bffe1
// > KeybindingsLayer::init @ 0x1402bfff7
// > KeybindingsLayer::init @ 0x1402c000d
// > KeybindingsLayer::init @ 0x1402c0023
// > KeybindingsLayer::init @ 0x1402c0039
// > KeybindingsLayer::init @ 0x1402c004f
// > KeybindingsLayer::init @ 0x1402c0065
// > ??> @ 0x1406d293c
//
// 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=1
cocos2d::CCLabelBMFont *KeybindingsLayer::addKeyPair(KeybindingsLayer *a1, const char *a2, const char *a3)
{
int m_keyCount; // ecx
float v7; // xmm0_4
unsigned int v8; // r15d
int m_maxPage; // eax
cocos2d::CCLayer *v10; // rsi
__int64 v11; // rcx
cocos2d::CCDirector *v12; // rax
GLubyte v13; // al
struct cocos2d::CCLayerColor *v14; // rbx
size_t v15; // r12
float v16; // xmm0_4
double v17; // xmm0_8
cocos2d::CCLabelBMFont *v18; // r13
cocos2d::CCLabelBMFont_vtbl *v19; // rbx
const cocos2d::CCPoint *v20; // rax
float v21; // xmm0_4
double v22; // xmm0_8
cocos2d::CCLabelBMFont *v23; // rdi
cocos2d::CCLabelBMFont_vtbl *v24; // rbx
const cocos2d::CCPoint *v25; // rax
float v26; // xmm0_4
KeybindingsLayer *v27; // rbx
int v28; // edi
cocos2d::CCString *v29; // rax
const char *CString; // rax
struct cocos2d::CCString *v31; // rax
void *v32; // rcx
float v34; // [rsp+20h] [rbp-60h] BYREF
_BYTE v35[4]; // [rsp+28h] [rbp-58h] BYREF
float v36; // [rsp+2Ch] [rbp-54h]
cocos2d::CCPoint v37; // [rsp+30h] [rbp-50h] BYREF
KeybindingsLayer *v38; // [rsp+40h] [rbp-40h]
void *Block[2]; // [rsp+48h] [rbp-38h] BYREF
__int128 v40; // [rsp+58h] [rbp-28h]
v38 = a1;
m_keyCount = a1->m_keyCount;
a1->m_keyCount = m_keyCount + 1;
v7 = floorf((float)(m_keyCount / 7));
v8 = (int)fmaxf(0.0, v7);
m_maxPage = a1->m_maxPage;
if ( m_maxPage <= (int)v8 )
m_maxPage = v8;
a1->m_maxPage = m_maxPage;
v10 = KeybindingsLayer::layerForPage(a1, v8);
v12 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v11);
cocos2d::CCDirector::getWinSize(v12);
cocos2d::CCPoint::CCPoint(v7, v34 * 0.5);
v36 = v36 - (float)(int)(30 * KeybindingsLayer::countForPage(a1, v8) + 30);
LOWORD(v34) = 0;
BYTE2(v34) = 0;
v13 = 100;
if ( (a1->m_keyCount & 1) == 0 )
v13 = 50;
HIBYTE(v34) = v13;
v14 = cocos2d::CCLayerColor::create((const struct cocos2d::_ccColor4B *)&v34, 360.0, 30.0);
v15 = -1;
v16 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCLayerColor *, __int64))v10->addChild_0)(
v10,
v14,
0xFFFFFFFFLL);
cocos2d::CCPoint::CCPoint(v16, -180.0);
v17 = cocos2d::CCPoint::operator+(v35, &v37);
v14->setPosition_0(v14, &v37);
v18 = cocos2d::CCLabelBMFont::create(a2, (const char *)&qword_14052A4D8);
v19 = v18->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v17, 0.0);
v19->setAnchorPoint(v18, v20);
v21 = ((float (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))v10->addChild_1)(v10, v18);
cocos2d::CCPoint::CCPoint(v21, -170.0);
v22 = cocos2d::CCPoint::operator+(v35, &v37);
v18->setPosition_0(v18, &v37);
cocos2d::CCLabelBMFont::limitLabelWidth(v18, 260.0, 0.5, 0.0);
v23 = cocos2d::CCLabelBMFont::create(a3, "goldFont.fnt");
v24 = v23->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v22, 1.0);
v24->setAnchorPoint(v23, v25);
v26 = ((float (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))v10->addChild_1)(v10, v23);
cocos2d::CCPoint::CCPoint(v26, 170.0);
cocos2d::CCPoint::operator+(v35, &v37);
v23->setPosition_0(v23, &v37);
cocos2d::CCLabelBMFont::limitLabelWidth(v23, 100.0, 0.60000002, 0.0);
v27 = v38;
v28 = KeybindingsLayer::countForPage(v38, v8);
v29 = cocos2d::CCString::createWithFormat("page_%i", v8);
CString = cocos2d::CCString::getCString(v29);
*(_OWORD *)Block = 0;
v40 = 0;
do
++v15;
while ( CString[v15] );
sub_14003A930(Block, CString, v15);
v31 = cocos2d::CCString::createWithFormat("%i", v28 + 1);
cocos2d::CCDictionary::setObject(v27->m_values, v31, Block);
if ( *((_QWORD *)&v40 + 1) > 0xFu )
{
v32 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v40 + 1) + 1LL) >= 0x1000 )
{
v32 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v32 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v32);
}
return v18;
}