//
// GJBaseGameLayer::createMiddleground from 0x58bdc2 to 0x58be08 (70 bytes)
//
// 6 xrefs:
// > PlayLayer::setupHasCompleted @ 0x40a150
// > LevelEditorLayer::init @ 0x47643a
// > GJBaseGameLayer::asyncMGLoaded @ 0x58c7e6
// > GJBaseGameLayer::swapMiddleground @ 0x58c826
// > GJBaseGameLayer::syncBGTextures @ 0x596518
// > LevelSettingsLayer::selectArtClosed @ 0x6a8cf4
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:53:02 +0000
//
GJBaseGameLayer *__fastcall GJBaseGameLayer::createMiddleground(GJBaseGameLayer *this, GJMGLayer *a2)
{
GJBaseGameLayer *v2; // r5
GJMGLayer *v3; // r4
cocos2d::CCLayer *v4; // r0
v2 = this;
v3 = a2;
if ( *((_DWORD *)this + 616) )
this = (GJBaseGameLayer *)GJBaseGameLayer::removeMiddleground(this);
if ( (int)v3 > 0 )
{
if ( (int)v3 >= 3 )
v3 = (GJMGLayer *)((char *)&dword_0 + 3);
v4 = GJMGLayer::create(v3, (int)a2);
*((_DWORD *)v2 + 616) = v4;
(*(void (__fastcall **)(cocos2d::CCLayer *, GJMGLayer *))(*(_DWORD *)v4 + 36))(v4, v3);
return (GJBaseGameLayer *)(*(int (__fastcall **)(_DWORD, _DWORD, int))(**((_DWORD **)v2 + 606) + 232))(
*((_DWORD *)v2 + 606),
*((_DWORD *)v2 + 616),
-39);
}
return this;
}