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

64bit big endian not supported #73

Closed
grepwood opened this issue Mar 30, 2019 · 4 comments
Closed

64bit big endian not supported #73

grepwood opened this issue Mar 30, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@grepwood
Copy link

devilutionX on Linux ppc64 has allocated an enormous amount of memory.
The system provides mere 204MB after the kernel takes what it needs.
Apparently, devilutionX needs around 2.7GB of memory.

See my efforts:
https://cdn.discordapp.com/attachments/518540764754608131/561633899373920257/unknown.png
https://cdn.discordapp.com/attachments/518540764754608131/561633965014777866/unknown.png
https://cdn.discordapp.com/attachments/518540764754608131/561636905658351626/unknown.png

From the attachment, we can see it happens right after the following is printed:

DUMMY: RegisterClassExA @ /home/mdec/git/devilutionX/SourceX/miniwin/misc.cpp:328
@AJenbo
Copy link
Member

AJenbo commented Mar 30, 2019

This is probably because you are loading the file incorrectly, you need to do byte swapping since the PCX format is LE and your running this on a BE CPU, meaning instead of 640x480 you CPU think that the texture is 2147614720x3758161920 or something to that effect.

@AJenbo
Copy link
Member

AJenbo commented Mar 30, 2019

Add some debug printf that shows the values during the loading and compare it to your x86 build. This should make it clear where you need to apply byte swapping. My guess would be SBmpLoadImage, here are some hints from @pbekesky's effort:

#define endian16(A) \ ( ( ((uint16)(A)&0xFF00)>>8 )+( ((uint16)(A)&0xFF)<<8 ) )
#define le2nat16(A) endian16(A)
#define read_le16(P) le2nat16(*(uint16 *)(P))

if (!SFileReadFile(hFile, &pcxhdr, 128, 0, 0)) {
	SFileCloseFile(hFile); return false;
}
pcxhdr.xmin = read_le16(&pcxhdr.xmin);
pcxhdr.ymin = read_le16(&pcxhdr.ymin);
pcxhdr.xmax = read_le16(&pcxhdr.xmax);
pcxhdr.ymax = read_le16(&pcxhdr.ymax);
pcxhdr.horzRes = read_le16(&pcxhdr.horzRes);
pcxhdr.vertRes = read_le16(&pcxhdr.vertRes);
pcxhdr.bitsPerPixel = read_le16(&pcxhdr.bitsPerPixel);
pcxhdr.horzSize = read_le16(&pcxhdr.horzSize);
pcxhdr.vertSize = read_le16(&pcxhdr.vertSize);
pcxhdr.bytesPerScanLine = read_le16(&pcxhdr.bytesPerScanLine);

This should be enough to get the menu loading.

But the issue is probably also compounded it also being a 64bit CPU that your targeting since the games doesn't even fully work on x86_64 yet.

@AJenbo AJenbo changed the title Incredibly huge memory usage 64bit big endian not supported Mar 30, 2019
@AJenbo AJenbo added the enhancement New feature or request label Mar 30, 2019
@AJenbo
Copy link
Member

AJenbo commented Apr 7, 2019

Going to close this as its a duplicate of #21

@AJenbo AJenbo closed this as completed Apr 7, 2019
@grepwood
Copy link
Author

grepwood commented Apr 7, 2019

@AJenbo actually not #21 and not a devilutionX issue. The same can be replicated with any application that calls SDL_Init from SDL2 on PS3 under Linux. Probably something messed up with my libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants