Message-Id: <199811131631.QAA10528@remus.clara.net> From: "Arthur" To: Subject: RE: fixed point + allegro Date: Fri, 13 Nov 1998 16:30:48 -0000 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 In-Reply-To: <01be0f0b$14c711c0$3cfaf8c8@aguia> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Importance: Normal Reply-To: djgpp AT delorie DOT com > Hi everybody, > > I need some help... i'd like to convert those fixed point routines of > allegro to use in a C++ Compiler 16 bits. But almost all code of > fixed point > in allegro is in assembler. You won't be able to convert it to 16-bit directly, as Allegro uses 32-bit fixed-point numbers (16.16). > Does anybody have source code of > anyother fixed > point functions (add, minus, mul, sub) ? I'm tring to convert allegro > functions but i really don't understand the AT&T format yet.... Just out of interest, why are you trying to convert it to another compiler? Fixed point is really simple. To do your own 32-bit fixed point code: short i; // 16-bit integer long f, f1, f2; // 32-bit fixed (stored in long - Allegro typedefs it) convert int to fixed: f = i << 16; convert fixed to int: i = f >> 16; add two fixed numbers: f1 += f2; sub two fixed numbers: f1 -= f2; mul two fixed numbers: f1 *= (f2 >> 16); div two fixed numbers: f1 /= (f2 >> 16); Allegro also checks for overflow errors on these functions, but as you can see, fixed point math is pretty easy to do. If you want this for a 16-bit compiler, change all the "16" above to "8". HTH James Arthur jaa AT arfa DOT clara DOT net ICQ#15054819