From b58233bbe916f72dc6daf6113f34c80e0a1088e5 Mon Sep 17 00:00:00 2001 From: dsula Date: Thu, 10 Sep 2026 19:36:21 -0400 Subject: [PATCH 1/2] DOOM_NO_FLOATING_POINT switch added Opt-in by defining this switch to disable all float/double use. This is useful for deployment on MCU without FPU. Co-Authored-By: Claude Sonnet 5 --- PureDOOM.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/PureDOOM.h b/PureDOOM.h index 4ea9737e..619bf499 100644 --- a/PureDOOM.h +++ b/PureDOOM.h @@ -21222,8 +21222,19 @@ fixed_t FixedDiv(fixed_t a, fixed_t b) } +// Define DOOM_NO_FLOATING_POINT to disable use of floating point. fixed_t FixedDiv2(fixed_t a, fixed_t b) { +#if defined(DOOM_NO_FLOATING_POINT) + // Integer-only rewrite of the original double-precision version + long long c; + + c = ((long long)a << FRACBITS) / (long long)b; + + if (c >= 2147483648LL || c < -2147483648LL) + I_Error("Error: FixedDiv: divide by zero"); + return (fixed_t)c; +#else double c; c = ((double)a) / ((double)b) * FRACUNIT; @@ -21231,6 +21242,7 @@ fixed_t FixedDiv2(fixed_t a, fixed_t b) if (c >= 2147483648.0 || c < -2147483648.0) I_Error("Error: FixedDiv: divide by zero"); return (fixed_t)c; +#endif } #define SAVESTRINGSIZE 24 #define SKULLXOFF -32 From 5b22e9c22b7ab0380f0a8ac972530d74105a9073 Mon Sep 17 00:00:00 2001 From: dsula Date: Fri, 11 Sep 2026 08:14:04 -0400 Subject: [PATCH 2/2] Updated the source with the floating point option. Erroneously the previous commit touched the generated PureDOOM.h directly instead of the source. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01X2g3DzyZ1StUArEaGM33Es --- src/DOOM/m_fixed.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/DOOM/m_fixed.c b/src/DOOM/m_fixed.c index b1d98969..b67aeb53 100644 --- a/src/DOOM/m_fixed.c +++ b/src/DOOM/m_fixed.c @@ -47,8 +47,19 @@ fixed_t FixedDiv(fixed_t a, fixed_t b) } +// Define DOOM_NO_FLOATING_POINT to disable use of floating point. fixed_t FixedDiv2(fixed_t a, fixed_t b) { +#if defined(DOOM_NO_FLOATING_POINT) + // Integer-only rewrite of the original double-precision version + long long c; + + c = ((long long)a << FRACBITS) / (long long)b; + + if (c >= 2147483648LL || c < -2147483648LL) + I_Error("Error: FixedDiv: divide by zero"); + return (fixed_t)c; +#else double c; c = ((double)a) / ((double)b) * FRACUNIT; @@ -56,4 +67,5 @@ fixed_t FixedDiv2(fixed_t a, fixed_t b) if (c >= 2147483648.0 || c < -2147483648.0) I_Error("Error: FixedDiv: divide by zero"); return (fixed_t)c; +#endif }