[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Attached is another modified version of Peter's patch to the one I posted
in my other message that hasn't arrived yet.
It uses LONG_LONG to do 64 bit arithmetic when it is available. Tested
locally (but not benchmarked yet).
Evert
? allegro.vcproj
Index: include/allegro/inline/fmaths.inl
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/inline/fmaths.inl,v
retrieving revision 1.7
diff -u -r1.7 fmaths.inl
--- include/allegro/inline/fmaths.inl 1 Feb 2005 13:12:04 -0000 1.7
+++ include/allegro/inline/fmaths.inl 16 May 2005 08:29:28 -0000
@@ -103,7 +103,30 @@
AL_INLINE(fixed, fixmul, (fixed x, fixed y),
{
+#if 0
return ftofix(fixtof(x) * fixtof(y));
+#elif defined LONG_LONG
+ LONG_LONG lx = x;
+ LONG_LONG ly = y;
+ LONG_LONG lres = (lx*ly)>>16;
+ int res = lres;
+ return res;
+#else
+ fixed sign = (x^y) & 0x80000000;
+ int mask_x = x >> 31;
+ int mask_y = y >> 31;
+ int mask_result = sign >> 31;
+ fixed result;
+
+ x = (x^mask_x) - mask_x;
+ y = (y^mask_y) - mask_y;
+
+ result = ((y >> 8)*(x >> 8) +
+ (((y >> 8)*(x&0xff)) >> 8) +
+ (((x >> 8)*(y&0xff)) >> 8));
+
+ return (result^mask_result) - mask_result;
+#endif
})