-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Big endian fixes #282
base: master
Are you sure you want to change the base?
Big endian fixes #282
Conversation
Great idea! What do you think about calling the functions "readLE32()" or similar (or le32_to_cpu() like Linux kernel uses), to indicate to the casual code reader that the attempt is to read 32-bit little-endian formatted data into host cpu endianness? |
The name readLE32 implies some kind of I/O for me, also these functions are used for saving too, e.g. for DARKPILO.CFG. I didn't put much tought into the naming convention though, just copied what they are called in SDL2, so le32_to_cpu and co are fine by me. I'll look up how they are named in the linux kernel and replace them here. |
I renamed the functions and rebased the PR. The float variants had no Linux kernel equivalents, so I took some liberties there. Let me know what you think. |
for (s32 i = 0; i < 140; i++) | ||
{ | ||
saveData->ammo[i] = TFE_Endian::le32_to_cpu(saveData->ammo[i]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's written to file, shouldn't these all be "cpu_to_le32()" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, I'll add the reverse to the header for some syntactic sugar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked closer at this function: it's used for the darkpilo.cfg file which is created by TFE, therefore you don't need any endianness conversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I added byteswaps here so that people can continue where they left off in the dos version. It's also easy to copy this file along with the rest of the game data which can lead to confusion if it doesn't just work.
I compared the disassembly in a few places and at least on x86 all your changes are simply optimized away by the compiler, so good job :) |
I'm working on a custom Amiga port, TFE's own formats are currently not endian swapped, but I can add it there as well. |
Just rebased this to the latest head. Let me know if there's anything else I should change/add before it can be merged. |
I started working on porting TFE to big endian systems. I focused mostly on loading the original game data, editor-only features were not tested. This should allow TFE to run on various alternate systems, like PS3, XB360, Wii, WiiU, Amiga and its derivatives.
To avoid reinventing the wheel I wrapped SDL_endian.h in a header (TFE_System/endian.h), so it can be replaced with custom implementations if necessary.