Skip to content

Big endian support#557

Open
IntriguingTiles wants to merge 5 commits intoFWGS:masterfrom
IntriguingTiles:big-endian-upstreaming
Open

Big endian support#557
IntriguingTiles wants to merge 5 commits intoFWGS:masterfrom
IntriguingTiles:big-endian-upstreaming

Conversation

@IntriguingTiles
Copy link

Figured I'd start with something relatively small. This should be everything that needs to be byteswapped in hlsdk.

I've also added definitions for the s390x architecture which is the only big endian architecture that has official support from debian and some other big distros, which might be useful for CI.

dlls/util.cpp Outdated
LittleShortSW( data[i] );
}

BufferField( pname, sizeof(short) * count, (const char *)data );
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add some sort of argument to BufferField that will tell the data type, and only swap it when it's written to save file?

So that we don't modify original buffer

{
if ( pseqdesc2[i].seqgroup == pseqdesc->seqgroup )
{
panim = (mstudioanim_t *)( (byte *)paSequences[pseqdesc->seqgroup].data + pseqdesc2[i].animindex );
Copy link
Member

Choose a reason for hiding this comment

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

Let's reduce panim scope to this block.

uint32_t li = Swap32( bi );
return UintAsFloat( li );
}

Copy link
Member

Choose a reason for hiding this comment

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

As HLSDK written in C++, maybe we could have something like a template function that will automatically apply appropriate swap based on data type size.

It's completely fine without it too, it's just a minor nitpick.

dlls/nodes.cpp Outdated
LittleLongSW( m_cLinks );
LittleLongSW( m_nRouteInfo );

for ( int i = 0; i < 3; i++ )
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to avoid magic numbers.

There is a helper macro ARRAYSIZE to get the size of arrays.

Copy link
Member

Choose a reason for hiding this comment

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

(that applies to the whole PR, as it's not the only place, there is similar issue in studio model renderer)

Instead of 3 it could be ARRAYSIZE( m_RegionMin ) for example and instead of NUM_RANGES it could be `ARRAYSIZE( m_RangeStart[i] ).

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.

2 participants