You are viewing a single thread.
View all comments
0 points

Context please, what is this bit shifting shenanigans that im witnessing right now?

permalink
report
reply
3 points

PA_ prefixed functions seem to be from palibds, which is a Nintendo DS homebrew development library.

DS being a constrained device it is logical that whoever wrote this code packed multiple byte-sized info into a bigger 16-bit short and using bit shifting to extract a specific byte

permalink
report
parent
reply
3 points

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!

permalink
report
parent
reply

Programming Horror

!programming_horror@programming.dev

Create post

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 @Ategon@programming.dev

Rules

  • Keep content in english
  • No advertisements (this includes both code in advertisements and advertisement in posts)
  • No generated code (a person has to have made it)

Credits

  • Icon base made by Lorc under CC BY 3.0 with modifications to add a gradient

Community stats

  • 256

    Monthly active users

  • 33

    Posts

  • 272

    Comments

Community moderators