this post was submitted on 17 Jun 2023
9 points (100.0% liked)

Programming Horror

1877 readers
1 users here now

Welcome to Programming Horror!

This is a place to share strange or terrible code you come across.

For more general memes about programming there's also Programmer Humor.

Looking for mods. If youre interested in moderating the community feel free to dm @[email protected]

Rules

Credits

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 1 year ago

You're right, this is some homebrew I wrote for my DS when I was in highschool.

But it was nothing as clever or logical as that! I think I had read somewhere that floats were really expensive on the DS ARM9 CPU, as was division (?). So to allow fractional values for object positions, etc, you would store them in an integer at 256x their true value, then shift it by 8 to the right to 'divide' by 256 and get the proper value back.

Not sure whether this was actually true, but either way this would've been completely cancelled out by calling that 'lowestXInObj' function 20 times per frame - it loops through every object in the scene!