{"type": "func", "start": 5499336, "end": 5499890, "name": "BrowseSmartTemplateLayer::addPrefabMenuItem", "pseudocode": "// \n// BrowseSmartTemplateLayer::addPrefabMenuItem from 0x53e9c8 to 0x53ebf2 (554 bytes)\n// \n// 2 xrefs:\n// > BrowseSmartTemplateLayer::init @ 0x53ff8e\n// > BrowseSmartTemplateLayer::init @ 0x53fff4\n// \n// This function is hookable on this platform!\n// \n// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings\n// \n\nvoid BrowseSmartTemplateLayer::addPrefabMenuItem(BrowseSmartTemplateLayer *a1, SmartPrefabResult a2, int a3)\n{\n  const SmartPrefabResult *m_smartPrefab; // r8\n  stl::StringData<char>::Internal *m_data; // r10\n  cocos2d::CCDirector *v6; // r0\n  cocos2d::CCMenu *m_buttonMenu; // r6\n  int v8; // r1\n  int v9; // r2\n  cocos2d::CCNode *v10; // r6\n  float v11; // r2\n  GJSmartTemplate *m_template; // r11\n  int RandomPrefab; // r11\n  GameManager *v14; // r0\n  int m_prefabCount; // r1\n  CCMenuItemSpriteExtra *v16; // r4\n  int v17; // r8\n  int v18; // r10\n  void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9\n  float v20; // s16\n  cocos2d::CCSize v21; // [sp+10h] [bp-44h] BYREF\n  cocos2d::CCPoint v22; // [sp+18h] [bp-3Ch] BYREF\n  cocos2d::CCPoint v23; // [sp+20h] [bp-34h] BYREF\n  cocos2d::CCPoint v24; // [sp+28h] [bp-2Ch] BYREF\n  SmartPrefabResult v25; // [sp+30h] [bp-24h] BYREF\n\n  m_smartPrefab = (const SmartPrefabResult *)a2.m_smartPrefab;\n  m_data = a2.m_binaryKey.m_data.m_data;\n  v6 = cocos2d::CCDirector::sharedDirector();\n  cocos2d::CCDirector::getWinSize(&v21, v6);\n  m_buttonMenu = a1->m_buttonMenu;\n  cocos2d::CCPoint::CCPoint(\n    (cocos2d::CCPoint *)&v25,\n    v21.width * 0.5,\n    (float)((float)(v21.height * 0.5) + 140.0) - 50.0);\n  cocos2d::CCNode::convertToNodeSpace(&v22, m_buttonMenu, (const cocos2d::CCPoint *)&v25);\n  sub_775C20(&v25);\n  v10 = GJSmartBlockPreview::create((int)&v25, v8, v9);\n  sub_774008(&v25);\n  SmartPrefabResult::SmartPrefabResult(&v25, m_smartPrefab);\n  if ( m_smartPrefab->m_prefabCount > 0 )\n    v11 = 0.5;\n  else\n    v11 = 1.0;\n  GJSmartBlockPreview::addTemplateGuide((cocos2d::CCArray *)v10, &v25, v11);\n  SmartPrefabResult::~SmartPrefabResult(&v25);\n  if ( m_smartPrefab->m_prefabCount > 0 )\n  {\n    m_template = a1->m_template;\n    sub_775C20(&v25);\n    RandomPrefab = GJSmartTemplate::getRandomPrefab((stl::StringData<char>::Internal *)m_template);\n    sub_774008(&v25);\n    if ( RandomPrefab )\n    {\n      sub_775C20(&v24);\n      sub_775C20(&v25);\n      v14 = GameManager::sharedState();\n      GJSmartBlockPreview::addPreview((cocos2d::CCArray *)v10, (int)&v24, &v25, v14->m_levelEditorLayer);\n      sub_774008(&v25);\n      sub_774008(&v24);\n      m_prefabCount = m_smartPrefab->m_prefabCount;\n      if ( m_prefabCount > 1 )\n        GJSmartBlockPreview::addCount((GJSmartBlockPreview *)v10, m_prefabCount);\n    }\n  }\n  ((void (__fastcall *)(cocos2d::CCNode *, int))v10->setScale)(v10, 1056964608);\n  v25.m_smartPrefab = (GJSmartPrefab *)BrowseSmartTemplateLayer::onTemplateObject;\n  v25.m_binaryKey.m_data.m_data = nullptr;\n  v16 = CCMenuItemSpriteExtra::create(\n          v10,\n          nullptr,\n          (cocos2d::SEL_MenuHandler)__PAIR64__(BrowseSmartTemplateLayer::onTemplateObject, (unsigned int)a1));\n  a1->m_buttonMenu->addChild(a1->m_buttonMenu, v16);\n  v17 = (int)floorf((float)((int)m_data / 28));\n  v18 = (int)m_data - 28 * v17;\n  setPosition = v16->setPosition;\n  v20 = floorf((float)(v18 / 7));\n  cocos2d::CCPoint::CCPoint(&v23, (float)((float)((float)(v18 % 7) * 60.0) - 210.0) + 30.0, v20 * -60.0);\n  cocos2d::CCPoint::operator+(&v24, &v22, &v23);\n  setPosition(v16, &v24);\n  BrowseSmartTemplateLayer::addObjectToPage(a1, v16, v17);\n}", "assembly": "; \n; BrowseSmartTemplateLayer::addPrefabMenuItem from 0x53e9c8 to 0x53ebf2 (554 bytes)\n; \n; 2 xrefs:\n; > BrowseSmartTemplateLayer::init @ 0x53ff8e\n; > BrowseSmartTemplateLayer::init @ 0x53fff4\n; \n; This function is hookable on this platform!\n; \n; Using BromaIDA 8.0.0 @ https:;github.com/Stazzical/BromaIDA\n; Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https:;github.com/geode-sdk/bindings\n; \n\nPUSH.W          {R4-R11,LR}                                            ; +0x0, 0x53e9c8\nMOV             R8, R1                                                 ; +0x4, 0x53e9cc\nLDR             R5, =(__stack_chk_guard_ptr - 0x53E9DC)                ; +0x6, 0x53e9ce\nMOV             R10, R2                                                ; +0x8, 0x53e9d0\nVPUSH           {D8}                                                   ; +0xa, 0x53e9d2\nMOV             R7, R0                                                 ; +0xe, 0x53e9d6\nADD             R5, PC; __stack_chk_guard_ptr                          ; +0x10, 0x53e9d8\nLDR             R5, [R5]; __stack_chk_guard                            ; +0x12, 0x53e9da\nADD.W           R9, R8, #4                                             ; +0x14, 0x53e9dc\nLDR             R3, [R5]                                               ; +0x18, 0x53e9e0\nSUB             SP, SP, #0x54                                          ; +0x1a, 0x53e9e2\nADD             R4, SP, #0x54+var_24                                   ; +0x1c, 0x53e9e4\nSTR             R3, [SP,#0x54+var_8]                                   ; +0x1e, 0x53e9e6\nBL              _ZN7cocos2d10CCDirector14sharedDirectorEv; cocos2d::CCDirector::sharedDirector(void) ; +0x20, 0x53e9e8\nMOV             R1, R0                                                 ; +0x24, 0x53e9ec\nADD             R0, SP, #0x54+var_44; this                             ; +0x26, 0x53e9ee\nBL              _ZN7cocos2d10CCDirector10getWinSizeEv; cocos2d::CCDirector::getWinSize(void) ; +0x28, 0x53e9f0\nVMOV.F32        S14, #0.5                                              ; +0x2c, 0x53e9f4\nVLDR            S13, [SP,#0x54+var_40]                                 ; +0x30, 0x53e9f8\nMOV             R0, R4; this                                           ; +0x34, 0x53e9fc\nLDR.W           R6, [R7,#0x1B8]                                        ; +0x36, 0x53e9fe\nVLDR            S15, =140.0                                            ; +0x3a, 0x53ea02\nVMLA.F32        S15, S13, S14                                          ; +0x3e, 0x53ea06\nVLDR            S13, [SP,#0x54+var_44]                                 ; +0x42, 0x53ea0a\nVMUL.F32        S14, S13, S14                                          ; +0x46, 0x53ea0e\nVMOV            R1, S14; float                                         ; +0x4a, 0x53ea12\nVLDR            S14, =50.0                                             ; +0x4e, 0x53ea16\nVSUB.F32        S15, S15, S14                                          ; +0x52, 0x53ea1a\nVMOV            R2, S15; float                                         ; +0x56, 0x53ea1e\nBL              _ZN7cocos2d7CCPointC1Eff; cocos2d::CCPoint::CCPoint(float,float) ; +0x5a, 0x53ea22\nADD             R3, SP, #0x54+var_3C                                   ; +0x5e, 0x53ea26\nMOV             R1, R6; cocos2d::CCPoint *                             ; +0x60, 0x53ea28\nMOV             R2, R4                                                 ; +0x62, 0x53ea2a\nMOV             R0, R3; this                                           ; +0x64, 0x53ea2c\nSTR             R3, [SP,#0x54+var_4C]                                  ; +0x66, 0x53ea2e\nBL              _ZN7cocos2d6CCNode18convertToNodeSpaceERKNS_7CCPointE; cocos2d::CCNode::convertToNodeSpace(cocos2d::CCPoint const&) ; +0x68, 0x53ea30\nMOV             R0, R4                                                 ; +0x6c, 0x53ea34\nMOV             R1, R9                                                 ; +0x6e, 0x53ea36\nBL              sub_775C20                                             ; +0x70, 0x53ea38\nMOV             R0, R4                                                 ; +0x74, 0x53ea3c\nSTR             R5, [SP,#0x54+var_48]                                  ; +0x76, 0x53ea3e\nBL              _ZN19GJSmartBlockPreview6createESs; GJSmartBlockPreview::create(std::string) ; +0x78, 0x53ea40\nMOV             R6, R0                                                 ; +0x7c, 0x53ea44\nMOV             R0, R4                                                 ; +0x7e, 0x53ea46\nBL              sub_774008                                             ; +0x80, 0x53ea48\nMOV             R1, R8; SmartPrefabResult *                            ; +0x84, 0x53ea4c\nMOV             R0, R4; this                                           ; +0x86, 0x53ea4e\nBL              _ZN17SmartPrefabResultC2ERKS_; SmartPrefabResult::SmartPrefabResult(SmartPrefabResult const&) ; +0x88, 0x53ea50\nVMOV.F32        S15, #1.0                                              ; +0x8c, 0x53ea54\nLDR.W           R3, [R8,#0xC]                                          ; +0x90, 0x53ea58\nMOV             R0, R6                                                 ; +0x94, 0x53ea5c\nMOV             R1, R4                                                 ; +0x96, 0x53ea5e\nCMP             R3, #0                                                 ; +0x98, 0x53ea60\nVMOV.F32        S14, #0.5                                              ; +0x9a, 0x53ea62\nITE LE                                                                 ; +0x9e, 0x53ea66\nVMOVLE          R2, S15                                                ; +0xa0, 0x53ea68\nVMOVGT          R2, S14                                                ; +0xa4, 0x53ea6c\nBL              _ZN19GJSmartBlockPreview16addTemplateGuideE17SmartPrefabResultf; GJSmartBlockPreview::addTemplateGuide(SmartPrefabResult,float) ; +0xa8, 0x53ea70\nMOV             R0, R4; this                                           ; +0xac, 0x53ea74\nADD             R5, SP, #0x54+var_2C                                   ; +0xae, 0x53ea76\nBL              _ZN17SmartPrefabResultD2Ev; SmartPrefabResult::~SmartPrefabResult() ; +0xb0, 0x53ea78\nLDR.W           R3, [R8,#0xC]                                          ; +0xb4, 0x53ea7c\nCMP             R3, #0                                                 ; +0xb8, 0x53ea80\nBLE             loc_53EAE6                                             ; +0xba, 0x53ea82\nLDR.W           R11, [R7,#0x1F0]                                       ; +0xbc, 0x53ea84\nMOV             R1, R9                                                 ; +0xc0, 0x53ea88\nMOV             R0, R4                                                 ; +0xc2, 0x53ea8a\nBL              sub_775C20                                             ; +0xc4, 0x53ea8c\nMOV             R1, R4                                                 ; +0xc8, 0x53ea90\nMOV             R0, R11                                                ; +0xca, 0x53ea92\nBL              _ZN15GJSmartTemplate15getRandomPrefabESs; GJSmartTemplate::getRandomPrefab(std::string) ; +0xcc, 0x53ea94\nMOV             R11, R0                                                ; +0xd0, 0x53ea98\nMOV             R0, R4                                                 ; +0xd2, 0x53ea9a\nBL              sub_774008                                             ; +0xd4, 0x53ea9c\nCMP.W           R11, #0                                                ; +0xd8, 0x53eaa0\nBEQ             loc_53EAE6                                             ; +0xdc, 0x53eaa4\nMOV             R1, R9                                                 ; +0xde, 0x53eaa6\nMOV             R0, R5                                                 ; +0xe0, 0x53eaa8\nBL              sub_775C20                                             ; +0xe2, 0x53eaaa\nMOV             R0, R4                                                 ; +0xe6, 0x53eaae\nADD.W           R1, R11, #0x38 ; '8'                                   ; +0xe8, 0x53eab0\nBL              sub_775C20                                             ; +0xec, 0x53eab4\nBL              _ZN11GameManager11sharedStateEv; GameManager::sharedState(void) ; +0xf0, 0x53eab8\nMOV             R3, R0                                                 ; +0xf4, 0x53eabc\nMOV             R1, R5                                                 ; +0xf6, 0x53eabe\nMOV             R0, R6                                                 ; +0xf8, 0x53eac0\nMOV             R2, R4                                                 ; +0xfa, 0x53eac2\nLDR.W           R3, [R3,#0x170]                                        ; +0xfc, 0x53eac4\nBL              _ZN19GJSmartBlockPreview10addPreviewESsSsP16LevelEditorLayer; GJSmartBlockPreview::addPreview(std::string,std::string,LevelEditorLayer *) ; +0x100, 0x53eac8\nMOV             R0, R4                                                 ; +0x104, 0x53eacc\nBL              sub_774008                                             ; +0x106, 0x53eace\nMOV             R0, R5                                                 ; +0x10a, 0x53ead2\nBL              sub_774008                                             ; +0x10c, 0x53ead4\nLDR.W           R1, [R8,#0xC]; int                                     ; +0x110, 0x53ead8\nCMP             R1, #1                                                 ; +0x114, 0x53eadc\nBLE             loc_53EAE6                                             ; +0x116, 0x53eade\nMOV             R0, R6; this                                           ; +0x118, 0x53eae0\nBL              _ZN19GJSmartBlockPreview8addCountEi; GJSmartBlockPreview::addCount(int) ; +0x11a, 0x53eae2\nLDR             R3, [R6]                                               ; +0x11e, 0x53eae6\nMOV             R0, R6                                                 ; +0x120, 0x53eae8\nMOV.W           R1, #0x3F000000                                        ; +0x122, 0x53eaea\nLDR             R3, [R3,#0x50]                                         ; +0x126, 0x53eaee\nBLX             R3                                                     ; +0x128, 0x53eaf0\nLDR             R3, =(_ZN24BrowseSmartTemplateLayer16onTemplateObjectEPN7cocos2d8CCObjectE_ptr - 0x53EAFC) ; +0x12a, 0x53eaf2\nMOV             R2, R7                                                 ; +0x12c, 0x53eaf4\nMOVS            R1, #0                                                 ; +0x12e, 0x53eaf6\nADD             R3, PC; _ZN24BrowseSmartTemplateLayer16onTemplateObjectEPN7cocos2d8CCObjectE_ptr ; +0x130, 0x53eaf8\nLDR             R3, [R3]; BrowseSmartTemplateLayer::onTemplateObject(cocos2d::CCObject *) ; +0x132, 0x53eafa\nSTR             R1, [SP,#0x54+var_54]                                  ; +0x134, 0x53eafc\nMOV             R0, R6                                                 ; +0x136, 0x53eafe\nSTR             R3, [SP,#0x54+var_24]                                  ; +0x138, 0x53eb00\nSTR             R1, [SP,#0x54+var_20]                                  ; +0x13a, 0x53eb02\nBL              _ZN21CCMenuItemSpriteExtra6createEPN7cocos2d6CCNodeES2_PNS0_8CCObjectEMS3_FvS4_E; CCMenuItemSpriteExtra::create(cocos2d::CCNode *,cocos2d::CCNode *,cocos2d::CCObject *,void (cocos2d::CCObject::*)(cocos2d::CCObject *)) ; +0x13c, 0x53eb04\nADD             R6, SP, #0x54+var_34                                   ; +0x140, 0x53eb08\nMOV             R4, R0                                                 ; +0x142, 0x53eb0a\nLDR.W           R0, [R7,#0x1B8]                                        ; +0x144, 0x53eb0c\nMOV             R1, R4                                                 ; +0x148, 0x53eb10\nLDR             R3, [R0]                                               ; +0x14a, 0x53eb12\nLDR.W           R3, [R3,#0xDC]                                         ; +0x14c, 0x53eb14\nBLX             R3                                                     ; +0x150, 0x53eb18\nMOVS            R1, #0x1C                                              ; +0x152, 0x53eb1a\nMOV             R0, R10                                                ; +0x154, 0x53eb1c\nBLX             __aeabi_idiv                                           ; +0x156, 0x53eb1e\nVMOV            S15, R0                                                ; +0x15a, 0x53eb22\nVCVT.F32.S32    S15, S15                                               ; +0x15e, 0x53eb26\nVMOV            R0, S15; x                                             ; +0x162, 0x53eb2a\nBLX             floorf                                                 ; +0x166, 0x53eb2e\nMOVS            R3, #0x1C                                              ; +0x16a, 0x53eb32\nMOVS            R1, #7                                                 ; +0x16c, 0x53eb34\nVMOV            S15, R0                                                ; +0x16e, 0x53eb36\nVCVT.S32.F32    S15, S15                                               ; +0x172, 0x53eb3a\nVMOV            R8, S15                                                ; +0x176, 0x53eb3e\nMLS             R10, R3, R8, R10                                       ; +0x17a, 0x53eb42\nLDR             R3, [R4]                                               ; +0x17e, 0x53eb46\nLDR.W           R9, [R3,#0x5C]                                         ; +0x180, 0x53eb48\nMOV             R0, R10                                                ; +0x184, 0x53eb4c\nBLX             __aeabi_idiv                                           ; +0x186, 0x53eb4e\nVMOV            S15, R0                                                ; +0x18a, 0x53eb52\nVCVT.F32.S32    S15, S15                                               ; +0x18e, 0x53eb56\nVMOV            R0, S15; x                                             ; +0x192, 0x53eb5a\nBLX             floorf                                                 ; +0x196, 0x53eb5e\nMOVS            R1, #7                                                 ; +0x19a, 0x53eb62\nVMOV            S16, R0                                                ; +0x19c, 0x53eb64\nMOV             R0, R10                                                ; +0x1a0, 0x53eb68\nBLX             __aeabi_idivmod                                        ; +0x1a2, 0x53eb6a\nVLDR            S14, =60.0                                             ; +0x1a6, 0x53eb6e\nMOV             R0, R6; this                                           ; +0x1aa, 0x53eb72\nVMOV            S15, R1                                                ; +0x1ac, 0x53eb74\nVCVT.F32.S32    S13, S15                                               ; +0x1b0, 0x53eb78\nVLDR            S15, =210.0                                            ; +0x1b4, 0x53eb7c\nVNMLS.F32       S15, S13, S14                                          ; +0x1b8, 0x53eb80\nVMOV.F32        S14, #30.0                                             ; +0x1bc, 0x53eb84\nVADD.F32        S15, S15, S14                                          ; +0x1c0, 0x53eb88\nVMOV            R1, S15; float                                         ; +0x1c4, 0x53eb8c\nVLDR            S15, =-60.0                                            ; +0x1c8, 0x53eb90\nVMUL.F32        S15, S16, S15                                          ; +0x1cc, 0x53eb94\nVMOV            R2, S15; float                                         ; +0x1d0, 0x53eb98\nBL              _ZN7cocos2d7CCPointC1Eff; cocos2d::CCPoint::CCPoint(float,float) ; +0x1d4, 0x53eb9c\nMOV             R2, R6                                                 ; +0x1d8, 0x53eba0\nMOV             R0, R5                                                 ; +0x1da, 0x53eba2\nLDR             R1, [SP,#0x54+var_4C]                                  ; +0x1dc, 0x53eba4\nBL              _ZNK7cocos2d7CCPointplERKS0_; cocos2d::CCPoint::operator+(cocos2d::CCPoint const&) ; +0x1de, 0x53eba6\nMOV             R0, R4                                                 ; +0x1e2, 0x53ebaa\nMOV             R1, R5                                                 ; +0x1e4, 0x53ebac\nBLX             R9                                                     ; +0x1e6, 0x53ebae\nMOV             R2, R8; int                                            ; +0x1e8, 0x53ebb0\nMOV             R0, R7; this                                           ; +0x1ea, 0x53ebb2\nMOV             R1, R4; cocos2d::CCObject *                            ; +0x1ec, 0x53ebb4\nBL              _ZN24BrowseSmartTemplateLayer15addObjectToPageEPN7cocos2d8CCObjectEi; BrowseSmartTemplateLayer::addObjectToPage(cocos2d::CCObject *,int) ; +0x1ee, 0x53ebb6\nLDR             R3, [SP,#0x54+var_48]                                  ; +0x1f2, 0x53ebba\nLDR             R2, [SP,#0x54+var_8]                                   ; +0x1f4, 0x53ebbc\nLDR             R3, [R3]                                               ; +0x1f6, 0x53ebbe\nCMP             R2, R3                                                 ; +0x1f8, 0x53ebc0\nBEQ             loc_53EBE8                                             ; +0x1fa, 0x53ebc2\nBLX             __stack_chk_fail                                       ; +0x1fc, 0x53ebc4\nB               loc_53EBD4                                             ; +0x200, 0x53ebc8\nMOV             R0, R4; this                                           ; +0x202, 0x53ebca\nBL              _ZN17SmartPrefabResultD2Ev; SmartPrefabResult::~SmartPrefabResult() ; +0x204, 0x53ebcc\nBL              __cxa_end_cleanup                                      ; +0x208, 0x53ebd0\nMOV             R0, R4                                                 ; +0x20c, 0x53ebd4\nBL              sub_774008                                             ; +0x20e, 0x53ebd6\nB               loc_53EBD0                                             ; +0x212, 0x53ebda\nMOV             R0, R4                                                 ; +0x214, 0x53ebdc\nBL              sub_774008                                             ; +0x216, 0x53ebde\nB               loc_53EBE4                                             ; +0x21a, 0x53ebe2\nMOV             R0, R5                                                 ; +0x21c, 0x53ebe4\nB               loc_53EBD6                                             ; +0x21e, 0x53ebe6\nADD             SP, SP, #0x54 ; 'T'                                    ; +0x220, 0x53ebe8\nVPOP            {D8}                                                   ; +0x222, 0x53ebea\nPOP.W           {R4-R11,PC}                                            ; +0x226, 0x53ebee", "xrefs": ["BrowseSmartTemplateLayer::init @ 0x53ff8e", "BrowseSmartTemplateLayer::init @ 0x53fff4"], "is_objc": false, "is_arm32": false, "is_arm64": false, "bida_info": "8.0.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings"}