{"type": "func", "start": 4795688, "end": 4796066, "name": "GJBaseGameLayer::handleButton", "pseudocode": "// \n// GJBaseGameLayer::handleButton from 0x492d28 to 0x492ea2 (378 bytes)\n// \n// 1 xrefs:\n// > GJBaseGameLayer::processQueuedButtons @ 0x492efc\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 GJBaseGameLayer::handleButton(GJBaseGameLayer *a1, bool a2, int a3, bool a4)\n{\n  int v4; // r7\n  _BOOL4 v6; // r6\n  _BOOL4 m_twoPlayerMode; // r8\n  GameManager *v9; // r0\n  _BOOL4 hasActiveDualTouch; // r0\n  _BOOL4 v11; // r9\n  PlayerObject *m_player1; // r0\n  _BOOL4 v13; // r0\n  _BOOL4 m_isDualMode; // r0\n  PlayerObject *m_player2; // r0\n  _BOOL4 v16; // r0\n  unsigned int v17; // r3\n  GJGameEvent v18; // r1\n  int v19; // r3\n  char m_useReplay; // r3\n\n  v4 = a4;\n  v6 = a2;\n  m_twoPlayerMode = a1->m_levelSettings->m_twoPlayerMode;\n  if ( !a1->m_isPlatformer && !a1->m_useReplay )\n  {\n    v9 = GameManager::sharedState();\n    if ( GameManager::getGameVariable(v9, \"0010\") )\n      v4 ^= 1u;\n  }\n  hasActiveDualTouch = GJEffectManager::hasActiveDualTouch(a1->m_effectManager);\n  if ( v6 )\n  {\n    a1->m_dualTouchTrigger = hasActiveDualTouch;\n  }\n  else if ( !a1->m_dualTouchTrigger )\n  {\n    hasActiveDualTouch = 0;\n  }\n  if ( !v4 )\n  {\n    if ( hasActiveDualTouch )\n      goto LABEL_43;\n    if ( m_twoPlayerMode )\n      goto LABEL_11;\n  }\n  if ( GJBaseGameLayer::isButtonAllowed(a1, v6, a3, 1) )\n  {\n    m_player1 = a1->m_player1;\n    if ( v6 )\n      v13 = PlayerObject::pushButton(m_player1, (PlayerButton)a3);\n    else\n      v13 = PlayerObject::releaseButton(m_player1, (PlayerButton)a3);\n    v11 = v13;\n  }\n  else\n  {\nLABEL_11:\n    v11 = 0;\n  }\n  if ( a1->m_dualTouchTrigger )\n  {\n    m_isDualMode = 0;\n    goto LABEL_27;\n  }\n  m_isDualMode = a1->m_gameState.m_isDualMode;\n  if ( !a1->m_gameState.m_isDualMode )\n  {\nLABEL_27:\n    if ( !v11 )\n      goto LABEL_43;\n    if ( !m_twoPlayerMode )\n      m_isDualMode = 0;\n    goto LABEL_33;\n  }\n  if ( !v4 || !m_twoPlayerMode )\n  {\n    m_isDualMode = GJBaseGameLayer::isButtonAllowed(a1, v6, a3, 0);\n    if ( m_isDualMode )\n    {\n      m_player2 = a1->m_player2;\n      if ( v6 )\n        v16 = PlayerObject::pushButton(m_player2, (PlayerButton)a3);\n      else\n        v16 = PlayerObject::releaseButton(m_player2, (PlayerButton)a3);\n      v11 = v16;\n      m_isDualMode = 1;\n    }\n    goto LABEL_27;\n  }\n  if ( !v11 )\n    goto LABEL_43;\n  m_isDualMode = a1->m_dualTouchTrigger;\nLABEL_33:\n  v17 = a3 - 1;\n  if ( v6 )\n  {\n    if ( v17 > 2 )\n      goto LABEL_43;\n    v18 = *((unsigned __int8 *)&unk_9ABF60 + v17 + 104);\n  }\n  else\n  {\n    if ( v17 > 2 )\n      goto LABEL_43;\n    v18 = *((unsigned __int8 *)&unk_9ABF60 + v17 + 108);\n  }\n  if ( v18 )\n  {\n    if ( m_isDualMode )\n      v19 = 2;\n    else\n      v19 = 1;\n    GJBaseGameLayer::gameEventTriggered(a1, v18, 0, v19);\n  }\nLABEL_43:\n  if ( !a1->m_player1->m_isDead )\n    GJEffectManager::playerButton(a1->m_effectManager, v6, v4);\n  m_useReplay = a1->m_useReplay;\n  if ( !m_useReplay )\n  {\n    if ( m_twoPlayerMode )\n      m_useReplay = v4 ^ 1;\n    GJBaseGameLayer::recordAction(a1, a3, v6, m_useReplay);\n  }\n  if ( v6 )\n  {\n    ++a1->m_clicks;\n    ++a1->m_clickIndex;\n    if ( a3 == 1 )\n      a1->m_jumping = 1;\n  }\n}", "assembly": "; \n; GJBaseGameLayer::handleButton from 0x492d28 to 0x492ea2 (378 bytes)\n; \n; 1 xrefs:\n; > GJBaseGameLayer::processQueuedButtons @ 0x492efc\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          {R3-R9,LR}                                             ; +0x0, 0x492d28\nMOV             R7, R3                                                 ; +0x4, 0x492d2c\nLDR.W           R3, [R0,#0x8C0]                                        ; +0x6, 0x492d2e\nMOV             R4, R0                                                 ; +0xa, 0x492d32\nMOV             R6, R1                                                 ; +0xc, 0x492d34\nMOV             R5, R2                                                 ; +0xe, 0x492d36\nLDRB.W          R8, [R3,#0x118]                                        ; +0x10, 0x492d38\nMOVW            R3, #0x2A12                                            ; +0x14, 0x492d3c\nLDRB            R3, [R0,R3]                                            ; +0x18, 0x492d40\nCBNZ            R3, loc_492D5E                                         ; +0x1a, 0x492d42\nMOVW            R3, #0x2A88                                            ; +0x1c, 0x492d44\nLDRB            R3, [R0,R3]                                            ; +0x20, 0x492d48\nCBNZ            R3, loc_492D5E                                         ; +0x22, 0x492d4a\nBL              _ZN11GameManager11sharedStateEv; GameManager::sharedState(void) ; +0x24, 0x492d4c\nLDR             R1, =(a0010 - 0x492D56); \"0010\"                        ; +0x28, 0x492d50\nADD             R1, PC; \"0010\"                                         ; +0x2a, 0x492d52\nBL              _ZN11GameManager15getGameVariableEPKc; GameManager::getGameVariable(char const*) ; +0x2c, 0x492d54\nCMP             R0, #0                                                 ; +0x30, 0x492d58\nBNE.W           loc_492E94                                             ; +0x32, 0x492d5a\nLDR.W           R0, [R4,#0x690]; this                                  ; +0x36, 0x492d5e\nBL              _ZN15GJEffectManager18hasActiveDualTouchEv; GJEffectManager::hasActiveDualTouch(void) ; +0x3a, 0x492d62\nMOVW            R3, #0x29F0                                            ; +0x3e, 0x492d66\nCMP             R6, #0                                                 ; +0x42, 0x492d6a\nBNE.W           loc_492E9A                                             ; +0x44, 0x492d6c\nLDRB            R3, [R4,R3]                                            ; +0x48, 0x492d70\nCMP             R3, #0                                                 ; +0x4a, 0x492d72\nIT EQ                                                                  ; +0x4c, 0x492d74\nMOVEQ           R0, #0                                                 ; +0x4e, 0x492d76\nCBNZ            R7, loc_492D8A                                         ; +0x50, 0x492d78\nCMP             R0, #0                                                 ; +0x52, 0x492d7a\nBNE             loc_492E3A                                             ; +0x54, 0x492d7c\nCMP.W           R8, #0                                                 ; +0x56, 0x492d7e\nBEQ             loc_492D8A                                             ; +0x5a, 0x492d82\nMOV.W           R9, #0                                                 ; +0x5c, 0x492d84\nB               loc_492DAE                                             ; +0x60, 0x492d88\nMOV             R0, R4; this                                           ; +0x62, 0x492d8a\nMOV             R1, R6; bool                                           ; +0x64, 0x492d8c\nMOV             R2, R5; int                                            ; +0x66, 0x492d8e\nMOVS            R3, #1; bool                                           ; +0x68, 0x492d90\nBL              _ZN15GJBaseGameLayer15isButtonAllowedEbib; GJBaseGameLayer::isButtonAllowed(bool,int,bool) ; +0x6a, 0x492d92\nCMP             R0, #0                                                 ; +0x6e, 0x492d96\nBEQ             loc_492D84                                             ; +0x70, 0x492d98\nLDR.W           R0, [R4,#0x8B8]; this                                  ; +0x72, 0x492d9a\nMOV             R1, R5                                                 ; +0x76, 0x492d9e\nCBZ             R6, loc_492DA8                                         ; +0x78, 0x492da0\nBL              _ZN12PlayerObject10pushButtonE12PlayerButton; PlayerObject::pushButton(PlayerButton) ; +0x7a, 0x492da2\nB               loc_492DAC                                             ; +0x7e, 0x492da6\nBL              _ZN12PlayerObject13releaseButtonE12PlayerButton; PlayerObject::releaseButton(PlayerButton) ; +0x80, 0x492da8\nMOV             R9, R0                                                 ; +0x84, 0x492dac\nMOVW            R3, #0x29F0                                            ; +0x86, 0x492dae\nLDRB            R3, [R4,R3]                                            ; +0x8a, 0x492db2\nCBNZ            R3, loc_492DEA                                         ; +0x8c, 0x492db4\nLDRB.W          R0, [R4,#0x372]                                        ; +0x8e, 0x492db6\nCBZ             R0, loc_492DEC                                         ; +0x92, 0x492dba\nCBZ             R7, loc_492DC4                                         ; +0x94, 0x492dbc\nCMP.W           R8, #0                                                 ; +0x96, 0x492dbe\nBNE             loc_492DFC                                             ; +0x9a, 0x492dc2\nMOV             R0, R4; this                                           ; +0x9c, 0x492dc4\nMOV             R1, R6; bool                                           ; +0x9e, 0x492dc6\nMOV             R2, R5; int                                            ; +0xa0, 0x492dc8\nMOVS            R3, #0; bool                                           ; +0xa2, 0x492dca\nBL              _ZN15GJBaseGameLayer15isButtonAllowedEbib; GJBaseGameLayer::isButtonAllowed(bool,int,bool) ; +0xa4, 0x492dcc\nCBZ             R0, loc_492DEC                                         ; +0xa8, 0x492dd0\nLDR.W           R0, [R4,#0x8BC]; this                                  ; +0xaa, 0x492dd2\nMOV             R1, R5                                                 ; +0xae, 0x492dd6\nCBZ             R6, loc_492DE0                                         ; +0xb0, 0x492dd8\nBL              _ZN12PlayerObject10pushButtonE12PlayerButton; PlayerObject::pushButton(PlayerButton) ; +0xb2, 0x492dda\nB               loc_492DE4                                             ; +0xb6, 0x492dde\nBL              _ZN12PlayerObject13releaseButtonE12PlayerButton; PlayerObject::releaseButton(PlayerButton) ; +0xb8, 0x492de0\nMOV             R9, R0                                                 ; +0xbc, 0x492de4\nMOVS            R0, #1                                                 ; +0xbe, 0x492de6\nB               loc_492DEC                                             ; +0xc0, 0x492de8\nMOVS            R0, #0                                                 ; +0xc2, 0x492dea\nCMP.W           R9, #0                                                 ; +0xc4, 0x492dec\nBEQ             loc_492E3A                                             ; +0xc8, 0x492df0\nCMP.W           R8, #0                                                 ; +0xca, 0x492df2\nIT EQ                                                                  ; +0xce, 0x492df6\nMOVEQ           R0, #0                                                 ; +0xd0, 0x492df8\nB               loc_492E04                                             ; +0xd2, 0x492dfa\nCMP.W           R9, #0                                                 ; +0xd4, 0x492dfc\nBEQ             loc_492E3A                                             ; +0xd8, 0x492e00\nMOV             R0, R3                                                 ; +0xda, 0x492e02\nSUBS            R3, R5, #1                                             ; +0xdc, 0x492e04\nCBZ             R6, loc_492E18                                         ; +0xde, 0x492e06\nCMP             R3, #2                                                 ; +0xe0, 0x492e08\nBHI             loc_492E3A                                             ; +0xe2, 0x492e0a\nLDR             R2, =(unk_9ABF60 - 0x492E12)                           ; +0xe4, 0x492e0c\nADD             R2, PC; unk_9ABF60                                     ; +0xe6, 0x492e0e\nADD             R3, R2                                                 ; +0xe8, 0x492e10\nLDRB.W          R1, [R3,#0x68]                                         ; +0xea, 0x492e12\nB               loc_492E26                                             ; +0xee, 0x492e16\nCMP             R3, #2                                                 ; +0xf0, 0x492e18\nBHI             loc_492E3A                                             ; +0xf2, 0x492e1a\nLDR             R2, =(unk_9ABF60 - 0x492E22)                           ; +0xf4, 0x492e1c\nADD             R2, PC; unk_9ABF60                                     ; +0xf6, 0x492e1e\nADD             R3, R2                                                 ; +0xf8, 0x492e20\nLDRB.W          R1, [R3,#0x6C]                                         ; +0xfa, 0x492e22\nCBZ             R1, loc_492E3A                                         ; +0xfe, 0x492e26\nCMP             R0, #0                                                 ; +0x100, 0x492e28\nMOV.W           R2, #0                                                 ; +0x102, 0x492e2a\nMOV             R0, R4                                                 ; +0x106, 0x492e2e\nITE NE                                                                 ; +0x108, 0x492e30\nMOVNE           R3, #2                                                 ; +0x10a, 0x492e32\nMOVEQ           R3, #1                                                 ; +0x10c, 0x492e34\nBL              _ZN15GJBaseGameLayer18gameEventTriggeredE11GJGameEventii; GJBaseGameLayer::gameEventTriggered(GJGameEvent,int,int) ; +0x10e, 0x492e36\nLDR.W           R3, [R4,#0x8B8]                                        ; +0x112, 0x492e3a\nLDRB.W          R3, [R3,#0x7B8]                                        ; +0x116, 0x492e3e\nCBNZ            R3, loc_492E50                                         ; +0x11a, 0x492e42\nLDR.W           R0, [R4,#0x690]; this                                  ; +0x11c, 0x492e44\nMOV             R1, R6; bool                                           ; +0x120, 0x492e48\nMOV             R2, R7; bool                                           ; +0x122, 0x492e4a\nBL              _ZN15GJEffectManager12playerButtonEbb; GJEffectManager::playerButton(bool,bool) ; +0x124, 0x492e4c\nMOVW            R3, #0x2A88                                            ; +0x128, 0x492e50\nLDRB            R3, [R4,R3]                                            ; +0x12c, 0x492e54\nCBNZ            R3, loc_492E6C                                         ; +0x12e, 0x492e56\nCMP.W           R8, #0                                                 ; +0x130, 0x492e58\nBEQ             loc_492E62                                             ; +0x134, 0x492e5c\nEOR.W           R3, R7, #1; bool                                       ; +0x136, 0x492e5e\nMOV             R0, R4; this                                           ; +0x13a, 0x492e62\nMOV             R1, R5; int                                            ; +0x13c, 0x492e64\nMOV             R2, R6; bool                                           ; +0x13e, 0x492e66\nBL              _ZN15GJBaseGameLayer12recordActionEibb; GJBaseGameLayer::recordAction(int,bool,bool) ; +0x140, 0x492e68\nCBZ             R6, locret_492E9E                                      ; +0x144, 0x492e6c\nMOVW            R2, #0x29F4                                            ; +0x146, 0x492e6e\nCMP             R5, #1                                                 ; +0x14a, 0x492e72\nLDR             R3, [R4,R2]                                            ; +0x14c, 0x492e74\nADD.W           R3, R3, #1                                             ; +0x14e, 0x492e76\nSTR             R3, [R4,R2]                                            ; +0x152, 0x492e7a\nMOVW            R2, #0x2C9C                                            ; +0x154, 0x492e7c\nLDR             R3, [R4,R2]                                            ; +0x158, 0x492e80\nADD.W           R3, R3, #1                                             ; +0x15a, 0x492e82\nSTR             R3, [R4,R2]                                            ; +0x15e, 0x492e86\nBNE             locret_492E9E                                          ; +0x160, 0x492e88\nMOVW            R3, #0x29FC                                            ; +0x162, 0x492e8a\nSTRB            R5, [R4,R3]                                            ; +0x166, 0x492e8e\nPOP.W           {R3-R9,PC}                                             ; +0x168, 0x492e90\nEOR.W           R7, R7, #1                                             ; +0x16c, 0x492e94\nB               loc_492D5E                                             ; +0x170, 0x492e98\nSTRB            R0, [R4,R3]                                            ; +0x172, 0x492e9a\nB               loc_492D78                                             ; +0x174, 0x492e9c\nPOP.W           {R3-R9,PC}                                             ; +0x176, 0x492e9e", "xrefs": ["GJBaseGameLayer::processQueuedButtons @ 0x492efc"], "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"}