//
// GJBaseGameLayer::createMiddleground from 0x9997c8 to 0x999848 (128 bytes)
//
// 7 xrefs:
// > PlayLayer::setupHasCompleted @ 0x707af4
// > LevelEditorLayer::init @ 0x7af230
// > GJBaseGameLayer::asyncMGLoaded @ 0x99a62c
// > GJBaseGameLayer::swapMiddleground @ 0x99a6b8
// > GJBaseGameLayer::syncBGTextures @ 0x9a917c
// > LevelSettingsLayer::selectArtClosed @ 0xb61c58
// > ??> @ 0xcd318
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 12:58:03 +0000
//
__int64 __fastcall GJBaseGameLayer::createMiddleground(__int64 this, __int64 a2)
{
__int64 v2; // x19
__int64 v3; // x0
int v4; // [xsp+28h] [xbp+28h]
__int64 v5; // [xsp+28h] [xbp+28h]
v2 = this;
if ( *(_QWORD *)(this + 3976) )
{
v4 = a2;
this = GJBaseGameLayer::removeMiddleground(this);
LODWORD(a2) = v4;
}
if ( (int)a2 > 0 )
{
if ( (int)a2 > 3 )
a2 = 3;
else
a2 = (unsigned int)a2;
v5 = a2;
v3 = GJMGLayer::create((GJMGLayer *)(unsigned int)a2);
*(_QWORD *)(v2 + 3976) = v3;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v3 + 72LL))(v3, v5);
return (*(__int64 (__fastcall **)(_QWORD, _QWORD, __int64))(**(_QWORD **)(v2 + 3896) + 464LL))(
*(_QWORD *)(v2 + 3896),
*(_QWORD *)(v2 + 3976),
4294967257LL);
}
return this;
}