Add fixed-point math parity test
Makes sure the more complex functions match regardless of bitdepth Currently (and very likely to stay) only FixedSqrt
This commit is contained in:
parent
9c9041484a
commit
6e6a94a6af
3 changed files with 57 additions and 0 deletions
|
|
@ -1654,6 +1654,7 @@ static const char *CON_LoadingStrings[LOADED_ALLDONE+1] =
|
|||
"Init rendering daemon...", //LOADED_RINIT
|
||||
"Init audio subsystem...", //LOADED_SINITSFXCHANNELS
|
||||
"Cache HUD...", //LOADED_STINIT
|
||||
"Test fixed-point arithmetic...", //LOADED_MATHINIT
|
||||
"Init ACSVM...", //LOADED_ACSINIT
|
||||
"Check game status...", //LOADED_DCHECKNETGAME
|
||||
"Now starting..."
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ typedef enum
|
|||
LOADED_RINIT,
|
||||
LOADED_SINITSFXCHANNELS,
|
||||
LOADED_STINIT,
|
||||
LOADED_MATHINIT,
|
||||
LOADED_ACSINIT,
|
||||
LOADED_DCHECKNETGAME,
|
||||
LOADED_ALLDONE = LOADED_DCHECKNETGAME,
|
||||
|
|
|
|||
|
|
@ -1814,6 +1814,61 @@ void D_SRB2Main(void)
|
|||
ST_Init();
|
||||
CON_SetLoadingProgress(LOADED_STINIT);
|
||||
|
||||
CONS_Printf("FixedSqrt of 32767 fracunits: %d; FixedSqrt64: %d\n",
|
||||
FixedSqrt(0x7FFF0000),
|
||||
FixedSqrt64(0x7FFF0000));
|
||||
|
||||
if (FixedSqrt(0x7FFF0000) == FixedSqrt64(0x7FFF0000))
|
||||
{
|
||||
CONS_Printf("\x83" "32767: Test OK!" "\x80" "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf("\x85" "32767: Test NG!" "\x80" "\n");
|
||||
}
|
||||
|
||||
CONS_Printf("FixedSqrt of 4 fracunits: %d; FixedSqrt64: %d\n",
|
||||
FixedSqrt(0x40000),
|
||||
FixedSqrt64(0x40000));
|
||||
|
||||
if (FixedSqrt(0x40000) == FixedSqrt64(0x40000))
|
||||
{
|
||||
CONS_Printf("\x83" "4: Test OK!" "\x80" "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf("\x85" "4: Test NG!" "\x80" "\n");
|
||||
}
|
||||
|
||||
// You should probably generate the weird number with RANDOM.org
|
||||
#define WEIRDNUMBER 3886284 /* 59.3 fracunits; this should approximate to around 7 */
|
||||
CONS_Printf("FixedSqrt of 59.3 fracunits: %d; FixedSqrt64: %d\n",
|
||||
FixedSqrt(WEIRDNUMBER),
|
||||
FixedSqrt64(WEIRDNUMBER));
|
||||
|
||||
if (FixedSqrt(WEIRDNUMBER) == FixedSqrt64(WEIRDNUMBER))
|
||||
{
|
||||
CONS_Printf("\x83" "59.3: Test OK!" "\x80" "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf("\x85" "59.3: Test NG!" "\x80" "\n");
|
||||
}
|
||||
#undef WEIRDNUMBER
|
||||
|
||||
CONS_Printf("FixedSqrt64 of 65535 fracunits: %d (not possible at 32-bit scale)\n",
|
||||
FixedSqrt64(0xFFFFFFFF));
|
||||
|
||||
CONS_Printf("IntSqrt of 32767: %d; IntSqrt64: %d\n",
|
||||
IntSqrt(0x7FFF),
|
||||
IntSqrt64(0x7FFF));
|
||||
|
||||
CONS_Printf("IntSqrt of 4: %d; IntSqrt64: %d\n",
|
||||
IntSqrt(4),
|
||||
IntSqrt64(4));
|
||||
|
||||
CON_SetLoadingProgress(LOADED_MATHINIT);
|
||||
|
||||
CONS_Printf("ACS_Init(): Init Action Code Script VM.\n");
|
||||
ACS_Init();
|
||||
CON_SetLoadingProgress(LOADED_ACSINIT);
|
||||
|
|
|
|||
Loading…
Reference in a new issue