//
// fmt::BasicWriter::FormatDouble from 0x60cae0 to 0x60cd3c (604 bytes)
//
// 5 xrefs:
// > fmt::BasicWriter::operator<< @ 0x2edf52
// > LevelSettingsObject::getSaveString @ 0x373a62
// > DS_Dictionary::setFloatForKey @ 0x5ffc4c
// > fmt::internal::PrintfParser::Format @ 0x60d004
// > fmt::BasicFormatter::format @ 0x60d39a
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
char *__fastcall fmt::BasicWriter::FormatDouble(unsigned int *a1, double a2, int a3)
{
unsigned int v6; // r6
int v7; // r3
int v8; // r4
int v9; // r2
char *v10; // r1
unsigned int v11; // r2
char *result; // r0
unsigned int v13; // r8
int v14; // r7
int v15; // r1
int v16; // r2
char *v17; // r3
size_t v18; // r1
int v19; // r3
char *v20; // r6
char *v21; // r0
int v22; // r0
unsigned int v23; // r11
char v24; // r1
int v25; // r7
unsigned int v26; // r1
char *v27; // r4
double v28; // [sp+0h] [bp-34h]
int v29; // [sp+14h] [bp-20h]
char format; // [sp+20h] [bp-14h] BYREF
char v31; // [sp+21h] [bp-13h] BYREF
char v32; // [sp+22h] [bp-12h] BYREF
v6 = *(unsigned __int8 *)(a3 + 20);
if ( v6 > 0x47 )
{
if ( v6 == 97 || v6 >= 0x61 && v6 - 101 <= 2 )
goto LABEL_13;
goto LABEL_12;
}
if ( v6 >= 0x45 )
goto LABEL_11;
if ( *(_BYTE *)(a3 + 20) )
{
if ( v6 != 65 )
{
LABEL_12:
fmt::internal::ReportUnknownType((fmt::internal *)*(unsigned __int8 *)(a3 + 20), (char)"double", _stack_chk_guard);
LABEL_13:
v7 = 0;
goto LABEL_14;
}
LABEL_11:
v7 = 1;
goto LABEL_14;
}
v7 = 0;
LOBYTE(v6) = 103;
LABEL_14:
if ( a2 >= 0.0 )
{
v9 = *(_DWORD *)(a3 + 12);
v8 = v9 & 1;
if ( (v9 & 1) != 0 )
{
if ( (v9 & 2) != 0 )
v8 = 43;
else
v8 = 32;
}
}
else
{
a2 = -a2;
v8 = 45;
}
if ( fabs(a2) > 1.79769313e308 )
{
if ( v7 )
v10 = " INF";
else
v10 = " inf";
if ( v8 )
{
v11 = 4;
}
else
{
++v10;
v11 = 3;
}
result = fmt::BasicWriter::write_str(a1, v10, v11, a3);
if ( v8 )
*result = v8;
return result;
}
v13 = *a1;
v14 = *(_DWORD *)a3;
if ( v8 )
{
if ( v14 )
v15 = *(_DWORD *)a3;
else
v15 = 1;
fmt::internal::Array::reserve((int)a1, v15 + v13);
if ( v14 )
--v14;
++v13;
}
format = 37;
v16 = *(_DWORD *)(a3 + 8);
if ( (*(_DWORD *)(a3 + 12) & 4) != 0 )
{
v31 = 35;
v17 = &v32;
}
else
{
v17 = &v31;
}
if ( v16 == 3 )
{
v14 = 0;
}
else
{
if ( v16 == 1 )
*v17++ = 45;
if ( v14 )
*v17++ = 42;
}
if ( *(int *)(a3 + 16) >= 0 )
{
*v17 = 46;
v17[1] = 42;
v17 += 2;
}
*v17 = v6;
v17[1] = 0;
v29 = *(_DWORD *)(a3 + 4);
while ( 1 )
{
v18 = a1[1] - v13;
v19 = *(_DWORD *)(a3 + 16);
v20 = (char *)(a1[2] + v13);
if ( v14 )
{
if ( v19 >= 0 )
{
v22 = snprintf(v20, v18, &format, v14, *(_DWORD *)(a3 + 16));
goto LABEL_54;
}
v28 = a2;
v21 = (char *)(a1[2] + v13);
v19 = v14;
}
else
{
v28 = a2;
v21 = (char *)(a1[2] + v13);
}
v22 = snprintf(v21, v18, &format, v19, v28);
LABEL_54:
v23 = v22;
if ( v22 >= 0 && v22 + v13 < a1[1] )
break;
if ( v22 < 0 )
v26 = a1[1] + 1;
else
v26 = v13 + 1 + v22;
fmt::internal::Array::reserve((int)a1, v26);
}
if ( v8 )
{
if ( (*(_DWORD *)(a3 + 8) & 0xFFFFFFFD) != 0 )
{
v24 = v8;
v8 = 0;
}
else if ( *v20 == 32 )
{
v24 = v29;
}
else
{
v24 = v8;
v8 = *(_DWORD *)(a3 + 8) & 0xFFFFFFFD;
}
v23 = v22 + 1;
*(v20 - 1) = v24;
}
if ( *(_DWORD *)(a3 + 8) == 3 && (v25 = *(_DWORD *)a3, *(_DWORD *)a3 > v23) )
{
v27 = (char *)fmt::BasicWriter::GrowBuffer(a1, *(_DWORD *)a3);
std::__copy_move::__copy_m(v27, &v27[v23], &v27[(v25 - v23) >> 1]);
return fmt::BasicWriter::FillPadding(v27, *(_DWORD *)a3, v23, v29);
}
else
{
if ( *(_DWORD *)(a3 + 4) != 32 || v8 )
{
while ( *v20 == 32 )
*v20++ = v29;
if ( v8 )
*(v20 - 1) = v8;
}
return (char *)fmt::BasicWriter::GrowBuffer(a1, v23);
}
}