dethrace
dethrace copied to clipboard
Big endian fixes
This could be useful for porting Dethrace to XB360, PS3, Wii consoles, or perhaps more obscure platforms.
Thanks! On what platforms have you tested this?
- Instead of doing
#if defined(__m68__) || defined(__ppc__)
, I would use theTestBigEndian
CMake module. That way we don't need to maintain a list of big endian architectures. - There is also endian dependent code here, concerning the savegames.
Yes, please don't just defined(__ppc__)
-- there are little-endian PowerPC systems too. Raptor POWER9s can swing both ways (my Talos II is little-endian).
It looks like TestBigEndian is deprecated, can CMAKE_C_BYTE_ORDER be used here? The save game code should be easy to fix, I'll make SWAP32_BE a no-op if BR_ENDIAN_BIG is 1.
That's fine to me. Supporting older CMake versions is not a priority here.
@dethrace-labs. WDYT? CMake 3.20 is widely available by now.
Don't forget to bump the the minimum required version.
Just to clarify I'm not very familiar with CMake, so I don't insist on using the newer method. I'll look into whichever way you say would suit the project better.
Yep, I like the use of CMAKE_C_BYTE_ORDER
. I'm fine to take a dependency on cmake 3.20. Thanks for the PR!
I'm not at my usual setup so I tried to use WSL2 to test my changes. It turns out Ubuntu Bionic only has CMake 3.10.2 so I tried to use the older method. I added this to the root CMakeLists.txt, but it doesn't seem to change the generated Makefile:
include(TestBigEndian)
test_big_endian(IS_BIGENDIAN)
if (IS_BIGENDIAN)
add_compile_definitions(BR_ENDIAN_BIG=1)
else()
add_compile_definitions(BR_ENDIAN_LITTLE=1)
endif()
Maybe I put this in the wrong place?
@madebr Sorry, I was so preoccupied with CMake that I forgot to answer your original question. I tested this on the Amiga.
Maybe I put this in the wrong place?
Because you're using add_compile_options
(and not target_compile_options(<target> PUBLIC <compile_optoins>)
),
you need to do the add_compile_options
BEFORE any add_library
calls.
Also, it needs be put AFTER the first call to project
.
So somewhere in this range.
@madebr Sorry, I was so preoccupied with CMake that I forgot to answer your original question. I tested this on the Amiga.
Nice. Tested on a real Amiga or an emulated one? Is OpenGL support done through software emulation?
Maybe I put this in the wrong place?
Because you're using
add_compile_options
(and nottarget_compile_options(<target> PUBLIC <compile_optoins>)
), you need to do theadd_compile_options
BEFORE anyadd_library
calls. Also, it needs be put AFTER the first call toproject
. So somewhere in this range.
I see, thanks. I'll try fiddle around with this after work.
@madebr Sorry, I was so preoccupied with CMake that I forgot to answer your original question. I tested this on the Amiga.
Nice. Tested on a real Amiga or an emulated one? Is OpenGL support done through software emulation?
Only in emulation for now, the lack of software renderer is a big roadblock. I cobbled together some code to draw wireframe models, but it's quick just a test, very buggy and slow. I'm still contemplating what to do about this, as OpenGL is not an option on 25 year old hardware.
that sounds awesome! Could you post a couple of screenshots!?
It's nothing to write home about, but here's one where it's not immediately obvious that I didn't do any clipping:
looks awesome :)
I'm not a CMake expert at all, but heres what I tried:
In the top-level CMakelists.txt
, I added
include(TestBigEndian)
test_big_endian(IS_BIGENDIAN)
above find_package(SDL2 REQUIRED)
In BRSRC13/CMakeLists.txt
, I added
if(IS_BIGENDIAN)
target_compile_definitions(brender PRIVATE BR_ENDIAN_BIG)
else()
target_compile_definitions(brender PRIVATE BR_ENDIAN_LITTLE)
endif()
In DETHRACE/CMakeLists.txt
:
if(IS_BIGENDIAN)
target_compile_definitions(dethrace PRIVATE BR_ENDIAN_BIG)
else()
target_compile_definitions(dethrace PRIVATE BR_ENDIAN_LITTLE)
endif()
A similar pattern should be added to S3/CMakeLists.txt
.
It seems to set the value correctly as seen by the pre-processor. Maybe give that a try?
May I post your screenshot on the https://twitter.com/dethrace_labs twitter feed?
Of course, if you think it's interesting feel free to post it. I'll rebase the PR and implement the changes you have suggested.