Skip to content
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

Convert endianess upon read to support BE #8091

Closed
wants to merge 1 commit into from

Conversation

janisozaur
Copy link
Member

ping @Krutonium

@IntelOrca
Copy link
Contributor

  1. Why not use a namespace rather than this ORCT_ prefix?
  2. Why macros over functions?

@janisozaur
Copy link
Member Author

// Based on SDL2

That and I would like to know if it really helps.

What do you mean by "Why macros over functions"? Can you provide an example?

@IntelOrca
Copy link
Contributor

Can you do this without using #define? Like a constexpr or just inline function instead?

Copy link
Member

@Gymnasiast Gymnasiast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is worthwhile, considering only legacy systems (and some highly specialised ones) are big endian. It's also very easy to break, as none of us use it (apart from Kenton, who actually has a BE system lying around?).

I'm not going to go as far as vetoing it, but it's borderline.

@AaronVanGeffen
Copy link
Member

I'm not going to go as far as vetoing it, but it's borderline.

I don't understand this negativity. This PR introduces compatibility with an entirely new series of architectures, which will help in potentially porting the game to the Wii, for example. Moreover, it does so in a relatively non-intrusive way: essentially 48 lines are changed.

If this works as well as advertised, it has my blessing.

@Gymnasiast
Copy link
Member

I don't understand this negativity. This PR introduces compatibility with an entirely new series of architectures, which will help in potentially porting the game to the Wii, for example.

I think it has very, very limited use - nobody is going to play OpenRCT2 on the Wii. As it stands, Android barely works, and that's not likely to improve. Why increase the development burden for something nobody (or almost nobody) is going to use? It means that Janisozaur will now need to watch import code closely to check for any changes breaking big endian system, even though he doesn't seem to have such a system available (again, because nobody uses them any more).

Again, I'm not vetoing since apparently I'm in the minority and I'm not going to veto stuff on a whim.

@ZehMatt
Copy link
Member

ZehMatt commented Oct 16, 2018

I would rather vote for having "ReadValue" return the actual correct value regardless on what platform you are on, forgetting it just once will cause bugs.

@janisozaur
Copy link
Member Author

@ZehMatt This was actually my initial approach, but things start to fall apart in cases like auto header = fs.ReadValue<FileIndexHeader>(); where you have lots of fields.

@ZehMatt
Copy link
Member

ZehMatt commented Oct 16, 2018

Yeah that makes sense, one way is to specialize the templates, so in case of FileIndexHeader it would go over the members, I know its slightly more work but at the end no one has to deal with this anymore.

@Krutonium
Copy link
Member

Krutonium commented Oct 16, 2018

FYI, It's not just the Wii. PS3 (Which runs Linux if you want it to), XBOX 360, there could be BigEndian variants of RiscV in the future, as well as newer PowerPC Hardware (Being Sold Today) being able to switch easily, at any time. (And I think the 3DS as well?). I will admit that with most of these being last gen, and current gen mostly being x86, it doesn't matter as much as it once did, when the next gen consoles were likely to be PowerPC based.

I'm not saying we should increase code complexity if it hurts maintainability, though. If it can be done like ZehMatt says, as I understand it, that would probably be the best route. Take no weight with my words.

Edit: How does Locomotion do it?
Edit2: OpenTTD. Not Locomotion.

@Gymnasiast
Copy link
Member

Sure, it makes it possible to run on consoles, but who is going to do that? An Android version is way more viable, but even that is neglected to death. We could use our manpower way more efficiently than trying to chase platforms people won't use.

But since BE support is going to be merged anyway: has anyone actually tested this on BE hardware?

Copy link
Contributor

@IntelOrca IntelOrca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like @ZehMatt has suggested, the conversion should be done in the reader / writer either by wrapping the file stream with an adaptor or passing a flag. The edge cases where structs are directly written can be done on a case by case basis, most of that is limited to local-only files anyway like the caches.

@AaronVanGeffen AaronVanGeffen added this to the Post v0.2.2 milestone Oct 17, 2018
@pkubaj
Copy link
Contributor

pkubaj commented Oct 24, 2018

Note that there's also a new POWER9 desktop / server available (Talos II from Raptor Engineering).

@Gymnasiast
Copy link
Member

Sure, but who's going to run OpenRCT2 on that? Also, doesn't the new POWER hardware support little endian mode anyway?

@pkubaj
Copy link
Contributor

pkubaj commented Oct 25, 2018

Sure, but who's going to run OpenRCT2 on that? Also, doesn't the new POWER hardware support little endian mode anyway?

  1. Me, once I get Talos :)
  2. It does, but many people prefer BE mode. There's also issue of FreeBSD not supporting LE mode for POWER (only BE).
    EDIT: I thought, I'd mention it, since probably not many people run FreeBSD.
    One of the few Linux distros for POWER, Adelie Linux, is also BE-only and since the POWER developer will rather give up his soul than switch to LE, it won't switch to LE :)

@Traace
Copy link

Traace commented Feb 5, 2019

I asked for BE support almost a year ago in the forums. Gymnasiast responded there with same agumentation then he did here.

@AaronVanGeffen I agree to you that his opinions about niche systems are very negative.
What makes libretro or openttd so special? It runs on everything.

Our PowerMac's would benefit from this BE support,too. What many don't know, we can still build SDL2 for OSX Leopard PowerPC. It just needs a few fixes and no offical support ofc :)
The community around this systems still exist. Currently there is the PowerPC 2019 Challange. Like every year. We are here, and we like to play!

Thanks to the people who acutally work on BE support, no matter what others say. I'm following this thread now, still learning C tho, hope to get better in future to deliver proper fixes to this project.

@pkubaj
Copy link
Contributor

pkubaj commented Feb 12, 2019

Just if anyone cares, OpenRCT2 0.2.1 with this patch builds on FreeBSD 12.0-RELEASE on POWER:
https://talos.anongoth.pl/data/powerpc64-default/2019-02-10_00h35m23s/logs/openrct2-0.2.1.log

@IntelOrca
Copy link
Contributor

@pkubaj What causes it to not build without this patch?

# else
# define RCT2_ENDIANESS __ORDER_BIG_ENDIAN__
# define HIBYTE(w) ((uint8_t)(w))
# define LOBYTE(w) ((uint8_t)(((uint16_t)(w) >> 8) & 0xFF))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IntelOrca these are required, I added #error in case RCT2_ENDIANESS is not defined and HIBYTE and LOBYTE are used somewhere.

uqs pushed a commit to freebsd/freebsd-ports that referenced this pull request May 3, 2019
…o 0.2.2, fix build with big-endian architectures, change maintainer

Patch for big-endian compatibility taken from upstream at OpenRCT2/OpenRCT2#8091

PR:		226897
Approved by:	mat (mentor)
Differential Revision:	https://reviews.freebsd.org/D19941


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@500708 35697150-7ecd-e111-bb59-0022644237b5
uqs pushed a commit to freebsd/freebsd-ports that referenced this pull request May 3, 2019
…o 0.2.2, fix build with big-endian architectures, change maintainer

Patch for big-endian compatibility taken from upstream at OpenRCT2/OpenRCT2#8091

PR:		226897
Approved by:	mat (mentor)
Differential Revision:	https://reviews.freebsd.org/D19941
Jehops pushed a commit to Jehops/freebsd-ports-legacy that referenced this pull request May 3, 2019
…o 0.2.2, fix build with big-endian architectures, change maintainer

Patch for big-endian compatibility taken from upstream at OpenRCT2/OpenRCT2#8091

PR:		226897
Approved by:	mat (mentor)
Differential Revision:	https://reviews.freebsd.org/D19941


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@500708 35697150-7ecd-e111-bb59-0022644237b5
swills pushed a commit to swills/freebsd-ports that referenced this pull request May 4, 2019
…o 0.2.2, fix build with big-endian architectures, change maintainer

Patch for big-endian compatibility taken from upstream at OpenRCT2/OpenRCT2#8091

PR:		226897
Approved by:	mat (mentor)
Differential Revision:	https://reviews.freebsd.org/D19941


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@500708 35697150-7ecd-e111-bb59-0022644237b5
@Gymnasiast Gymnasiast removed this from the v0.2.3 milestone May 14, 2019
@janisozaur
Copy link
Member Author

Closing this for now. It might get resumed at some point in the future, but I don't feel like working on this now.

@janisozaur janisozaur closed this May 15, 2019
@grepwood
Copy link

I have a PS3 which happens to be a big endian ppc64 of the Power7 variety with SPU, and I am willing to compile and test on it.

@janisozaur
Copy link
Member Author

@grepwood thanks for your offer, porting to PS3 (assuming the game OS) would first require confirming all the libraries work fine.

There's little interest in big endian port and while personally I would love to see it done, I just can't find it rewarding enough to do. It's not even a question of platform availability at this stage, I was able to run and improve our tests for big endian using qemu, but never really got around to fixing them.

I fear just contributing platform time is not enough to make this happen.

@grepwood
Copy link

@janisozaur just to get 1 thing out of the way - I would not count on a GameOS port anytime soon. I have already broke my back trying to port ec-/Quake3e and we found out the SDK has a mostly missing network stack. But a Linux port? It's totally doable.

@janisozaur
Copy link
Member Author

Would you be willing to work on such port?

@grepwood
Copy link

You bet! Aaron from Discord already said to fork from develop branch. I'm on it.

@janisozaur
Copy link
Member Author

Sounds great. You can use this PR if you find it useful. Ping me on discord as well, I might be able to collaborate a bit too.

svmhdvn pushed a commit to svmhdvn/freebsd-ports that referenced this pull request Jan 10, 2024
…o 0.2.2, fix build with big-endian architectures, change maintainer

Patch for big-endian compatibility taken from upstream at OpenRCT2/OpenRCT2#8091

PR:		226897
Approved by:	mat (mentor)
Differential Revision:	https://reviews.freebsd.org/D19941
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants