User Tag List

Results 1 to 3 of 3

Thread: sprite/entity 'fix' usage

  1. #1
    Developer ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,694
    Mentioned
    238 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,356
    Level
    32
    vBActivity - Bars
    Lv. Percent
    60.41%
    Daily Activity
    101.69%
    Weekly Activity
    60.14%
    Monthly Activity
    47.07%

    sprite/entity 'fix' usage

    I was looking over everywhere fix is used for sprites. It *looks* to me like it's questionable whether replacing it at some point later on will cause any issues. What happens is there are a lot of double-int32 conversions for remainders, and most of the time position values are truncated to integers anyway. 'delta' values certainly never exceed any kind of float threshold at all, meaning that usage of 'fix' is just something that's in there. :/ I can't find a single good reason why except that in 1998 maybe FPUs were not as widespread across hardware.

    I can see why from a perspective of drawing to bitmaps, since it's all ints, but that just means it's like that because it's tied to allegro. Am I missing something?
    This post contains the official Gleeok™ seal of approval. Look for these and other posts in an area near you.

  2. #2
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,222
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    10,754
    Level
    30
    vBActivity - Bars
    Lv. Percent
    75.43%
    Daily Activity
    16.95%
    Weekly Activity
    14.06%
    Monthly Activity
    36.32%
    If there's no place where the fixed-point semantics are truly needed (i.e., where the code assumes that one hundred "+= 0.01"s will yield 1.0 exactly) then we should get rid of them. I agree that they're most likely due to performance concerns that were dubious even in the late 90s.

  3. #3
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,222
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    10,754
    Level
    30
    vBActivity - Bars
    Lv. Percent
    75.43%
    Daily Activity
    16.95%
    Weekly Activity
    14.06%
    Monthly Activity
    36.32%
    So after some investigation the main issue I see with getting rid of "fix" entirely (and replacing them with true doubles) is in the sprite movement code. Sprites currently have step sizes that are fractions of the tile width, and due to rounding errors replacing the fixed-point position variables with floating point will alter the movement behavior.

    But I don't think that's actually a major issue, since sprites can store their positions in units of pixels instead of tiles; current movement code will only increment the position by integer number of pixels and since sufficiently small integers are exactly represented in floating-point, as long as the calculation of pixel->tile is rounded carefully there should be no functional change in the movement behavior.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social