[OT] Sprite Momentum

Hi,

David Olofson <david.olofson at reologica.se> wrote:

itself is very trivial.) The coordinates are 24:8 fixed point, which

a stupid question from an “gamedev newbe”:

Does it make sense to use fixed point? I think nowadays CPUs (>=Pentium)
should have a fast enough FPU.

I use a lot of doubles in my game (ketm), do I get a speed improvement
if I change to fixed-point-ints? (and perhaps look-up tables for
sin/cos etc.)?

Walter

Hehe… tell that to my 66Mhz Linux PDA with no FPU :wink:

-bill!On Fri, Oct 26, 2001 at 05:12:43PM +0200, Walter Haslbeck wrote:

a stupid question from an “gamedev newbe”:

Does it make sense to use fixed point? I think nowadays CPUs (>=Pentium)
should have a fast enough FPU.

Hi,

David Olofson <david.olofson at reologica.se> wrote:

itself is very trivial.) The coordinates are 24:8 fixed point, which

a stupid question from an “gamedev newbe”:

Does it make sense to use fixed point? I think nowadays CPUs
(>=Pentium) should have a fast enough FPU.

Yes. In fact, if you’re doing significant amounts of calculations, FP is
usually faster than fixed point. (You avoid all explicit normalization
operations, among other things.)

However, rounding rules as defined by most programming languages force
compilers to generate very slow float<->int conversions. (This applies to
x86 as well as other CPUs.) You can get away with some asm macros that do
much faster conversions with native FPU rounding, but of course, that’s
non-portable, and it’s still not as fast as fixed<->int “conversions”.

I use a lot of doubles in my game (ketm), do I get a speed improvement
if I change to fixed-point-ints?

Not a trivial question to answer. (See above.)

If you’re doing lots of calculations, you’re probably better of sticking
with floats and doubles. Just try to minimize the number of float<->int
conversions, especially in inner loops. If your control system is mostly
FP, make it FP as far as possible, and convert to integers at some
sensible level between the CS and the rendering layer.

BTW, Kobo Deluxe and the Spitfire Engine are using fixed point values for
everything, including the frame rate conversion, but that’s mostly
because both are based on very old code (The Spitfire Engine is based on
a Pascal->C translation of the DOS game “Project Spitfire”, which was
meant to do 60 Hz full screen scrolling + sprites on 33 MHz 486 machines.)

(and perhaps look-up tables for
sin/cos etc.)?

I’m not sure about the current FPUs and sin/cos, etc, but in general,
LUTs have been obsolete for ages. Avoid them as far as possible, unless
you’re going to use them so frequently in some code that they’ll remain
in the cache. (Of course, they have to fit in the cache as well… :slight_smile:

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Friday 26 October 2001 17:12, Walter Haslbeck wrote: