//
// TutorialLayer::loadPage from 0x1004dcc70 to 0x1004dd078 (1032 bytes)
//
// 2 xrefs:
// > TutorialLayer::init @ 0x1004dcb33
// > TutorialLayer::onNext @ 0x1004dcc56
//
// 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 TutorialLayer::loadPage(TutorialLayer *a1, int a2)
{
cocos2d::CCString *v3; // rax
const char *CString; // r15
cocos2d::CCTextureCache *v5; // rax
cocos2d::CCString *v6; // rax
const char *v7; // rax
cocos2d::CCSprite *v8; // r15
__int64 v9; // xmm0_8
const std::string::value_type *v10; // rsi
const std::string::value_type *v11; // rsi
const char *data; // r14
size_t v13; // rax
size_t v14; // r15
char *v15; // r12
size_t v16; // r13
char *v17; // r14
int m_page; // r14d
CCMenuItemSpriteExtra *m_nextButton; // rdi
void (__cdecl *setVisible)(cocos2d::CCNode *__hidden, bool); // rax
char v21; // [rsp+0h] [rbp-80h]
__int128 __dst; // [rsp+8h] [rbp-78h] BYREF
void *__p; // [rsp+18h] [rbp-68h]
double v24; // [rsp+20h] [rbp-60h] BYREF
std::string v25; // [rsp+28h] [rbp-58h] BYREF
float v26; // [rsp+44h] [rbp-3Ch] BYREF
float v27; // [rsp+48h] [rbp-38h]
float v28; // [rsp+4Ch] [rbp-34h]
float v29; // [rsp+50h] [rbp-30h]
float v30; // [rsp+54h] [rbp-2Ch]
((void (__fastcall *)(cocos2d::CCLayer *, __int64))a1->m_tutorialLayer->removeAllChildrenWithCleanup)(
a1->m_tutorialLayer,
1);
if ( a1->m_page )
{
v3 = (cocos2d::CCString *)sub_1007AB580("tutorial_%02d.png", v21);
CString = cocos2d::CCString::getCString(v3);
v5 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::removeTextureForKey(v5, CString);
}
a1->m_page = a2;
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v26);
v6 = (cocos2d::CCString *)sub_1007AB580("tutorial_%02d.png", v21);
v7 = cocos2d::CCString::getCString(v6);
v8 = cocos2d::CCSprite::create_1(v7);
v29 = 0.0;
sub_10028CBE0((float *)&v25, 0.0, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, std::string *))v8->setAnchorPoint)(v8, &v25);
if ( AppDelegate::get()->m_unk0ec )
((void (__fastcall *)(cocos2d::CCSprite *, float))v8->setScale)(v8, 2.0);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *))a1->m_tutorialLayer->addChild)(a1->m_tutorialLayer, v8);
sub_10028CBE0((float *)&v25, (float)((float)(v26 * 0.5) + -210.0) + 10.0, (float)((float)(0.5 * v27) + -130.0) + 10.0);
((void (__fastcall *)(cocos2d::CCSprite *, std::string *))v8->setPosition)(v8, &v25);
*(_WORD *)&v25.__r_.__value_.__l.0 = 0;
v30 = 0.69999999;
v9 = 1109393408;
v28 = 40.0;
switch ( a2 )
{
case 1:
v10 = "Tap the screen to jump.\nHold down to keep jumping.";
goto LABEL_12;
case 2:
v10 = "Hold to fly up.\nRelease to fly down.";
LABEL_12:
std::string::assign(&v25, v10);
break;
case 3:
v11 = "You can enter practice mode from the pause menu.\n"
"Practice mode lets you place checkpoints.";
goto LABEL_9;
case 4:
std::string::assign(
&v25,
"You can place checkpoints manually, or use the auto-checkpoint feature.\n"
"Tap the delete button to remove your last checkpoint.");
v30 = 0.55000001;
v29 = -13.0;
v9 = 1110704128;
v28 = 45.0;
break;
case 5:
v11 = "Jump Orbs activate when you are on top of them.\n"
"Tap while touching an orb to interact with it and use its effect.";
LABEL_9:
std::string::assign(&v25, v11);
v30 = 0.60000002;
v9 = 3243245568LL;
v29 = -13.0;
break;
default:
break;
}
if ( (*(_BYTE *)&v25.__r_.__value_.__s.0 & 1) != 0 )
data = v25.__r_.__value_.__l.__data_;
else
data = v25.__r_.__value_.__s.__data_;
v13 = strlen(data);
if ( v13 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)&v9);
v14 = v13;
if ( v13 >= 0x17 )
{
v16 = 26;
if ( (v13 | 7) != 0x17 )
v16 = (v13 | 7) + 1;
v15 = (char *)operator new(v16);
__p = v15;
*(_QWORD *)&__dst = v16 | 1;
*((_QWORD *)&__dst + 1) = v14;
goto LABEL_23;
}
LOBYTE(__dst) = 2 * v13;
v15 = (char *)&__dst + 1;
if ( v13 )
LABEL_23:
memmove(v15, data, v14);
v15[v14] = 0;
sub_10028CBE0((float *)&v24, 0.5, 1.0);
v17 = TextArea::create(&__dst, (__int64)"bigFont.fnt", &v24, 0, 1.0, 400.0 / v30, v28);
if ( (__dst & 1) != 0 )
operator delete(__p);
(*(void (__fastcall **)(char *, float))(*(_QWORD *)v17 + 160LL))(v17, v30);
((void (__fastcall *)(cocos2d::CCLayer *, char *))a1->m_tutorialLayer->addChild)(a1->m_tutorialLayer, v17);
sub_10028CBE0((float *)&v24, v26 * 0.5, v29 + (float)((float)((float)(0.5 * v27) + 130.0) + -75.0));
(*(void (__fastcall **)(char *, double *))(*(_QWORD *)v17 + 184LL))(v17, &v24);
m_page = a1->m_page;
m_nextButton = a1->m_nextButton;
setVisible = m_nextButton->setVisible;
if ( m_page < 5 )
{
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))setVisible)(m_nextButton, 1);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))a1->m_nextButton->setEnabled)(a1->m_nextButton, 1);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_exitButton->setVisible)(a1->m_exitButton, 0);
}
else
{
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))setVisible)(m_nextButton, 0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_nextButton->setEnabled)(a1->m_nextButton, 0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))a1->m_exitButton->setVisible)(a1->m_exitButton, 1);
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_exitButton->setEnabled)(a1->m_exitButton, m_page >= 5);
if ( (*(_BYTE *)&v25.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v25.__r_.__value_.__l.__data_);
}