//
// GJBaseGameLayer::createMiddleground from 0x1002787cc to 0x100278854 (136 bytes)
//
// 6 xrefs:
// > PlayLayer::setupHasCompleted @ 0x10013f72c
// > LevelSettingsLayer::selectArtClosed @ 0x10020d9d4
// > GJBaseGameLayer::swapMiddleground @ 0x100278788
// > GJBaseGameLayer::asyncMGLoaded @ 0x100278864
// > GJBaseGameLayer::syncBGTextures @ 0x10029ef60
// > LevelEditorLayer::init @ 0x1003f7118
//
// 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 11:01:51 +0000
//
__int64 __fastcall GJBaseGameLayer::createMiddleground(__int64 a1, int a2)
{
__int64 v2; // x20
__int64 result; // x0
char *v5; // x0
LODWORD(v2) = a2;
result = *(_QWORD *)(a1 + 3976);
if ( result )
{
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)result + 520LL))(result);
*(_QWORD *)(a1 + 3976) = 0;
}
if ( (int)v2 >= 1 )
{
if ( (unsigned int)v2 >= 3 )
v2 = 3;
else
v2 = (unsigned int)v2;
v5 = sub_1000300E0(v2);
*(_QWORD *)(a1 + 3976) = v5;
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v5 + 72LL))(v5, v2);
return (*(__int64 (__fastcall **)(_QWORD, _QWORD, __int64))(**(_QWORD **)(a1 + 3896) + 464LL))(
*(_QWORD *)(a1 + 3896),
*(_QWORD *)(a1 + 3976),
4294967257LL);
}
return result;
}