heasm66 / mdlzork

Different versions of original mainframe Zork reconstructed and patched to run under Confusion.
15 stars 6 forks source link

Confusion: ABS appears to be buggy, but probably doesn't affect Zork #44

Closed eriktorbjorn closed 1 year ago

eriktorbjorn commented 1 year ago
Welcome to 'Confusion', a MDL interpreter.
Copyright 2009 Matthew T. Russotto
This program comes with ABSOLUTELY NO WARRANTY; for details type <WARRANTY>.
This is free software, and you are welcome to distribute under certain conditions; type <COPYING> for details
LISTENING-AT-LEVEL 1 PROCESS 1
<ABS -3.14>
4609118966639786496.0000000

Well, that's how it behaved on one computer. On the one where I first saw it, Confusion crashed. I believe this is the proper fix for it:

diff --git a/confusion_patched/macros.cpp b/confusion_patched/macros.cpp
index a25eb6a..b63f28c 100644
--- a/confusion_patched/macros.cpp
+++ b/confusion_patched/macros.cpp
@@ -6186,7 +6186,7 @@ mdl_value_t *mdl_builtin_eval_abs(mdl_value_t *form, mdl_value_t *args)
 #ifdef MDL32
         return mdl_new_float(fabsf(num->v.fl));
 #else
-        return mdl_new_float(fabs(num->v.w));
+        return mdl_new_float(fabs(num->v.fl));
 #endif
     }
     else if (num->type == MDL_TYPE_FIX)