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

Is Nanosaur big endian compatible? #37

Closed
chzigotzky opened this issue Apr 1, 2023 · 8 comments
Closed

Is Nanosaur big endian compatible? #37

chzigotzky opened this issue Apr 1, 2023 · 8 comments

Comments

@chzigotzky
Copy link

chzigotzky commented Apr 1, 2023

Hi Jorio,

I compiled Nanosaur 1.4.4 with Void PPC on my X5000 today.
Further information: https://forum.hyperion-entertainment.com/viewtopic.php?p=56760#p56760

Unfortunately it doesn't start.

NANOSAUR ASSERTION FAILED: in + packetBytes <= eod - DecompressRLE:58

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  40 (X_TranslateCoords)
  Resource id in failed request:  0x1400247
  Serial number of failed request:  244
  Current serial number in output stream:  0

grep -i DecompressRLE . -r

./src/System/TGA.c:static void DecompressRLE(short refNum, TGAHeader* header, uint8_t* out)
./src/System/TGA.c:		DecompressRLE(refNum, &header, pixelData);

Is Nanosaur big endian compatible?

Thanks,
Christian

@jorio
Copy link
Owner

jorio commented Apr 12, 2023

In ReadTGA (TGA.c), try to add the line marked 'ADD THIS' below (untested, let me know if it works):

        /* ... */

	// Read header
	readCount = sizeof(TGAHeader);
	err = FSRead(refNum, &readCount, (Ptr) &header);
	if (err != noErr || readCount != sizeof(TGAHeader))
	{
		FSClose(refNum);
		return err;
	}

	UnpackStructs("<8B4H2B", sizeof(TGAHeader), 1, &header); // <---------- ADD THIS

	// Make sure we support the format
	switch (header.imageType)

        /* ... */

@chzigotzky
Copy link
Author

It starts with the patch above and I see the Nanosaur title screen in wrong colors and after pressing the key SPACE, the Credits screen in wrong colors either. Then after the pressing the key SPACE again, I see the Pangea logo with the correct colors. After that it crashes with the error message "Segmentation fault".

Debugging with GDB (backtrace):

gdb Nanosaur

Output:

GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from Nanosaur...

(gdb) run

Starting program: /home/amigaone/Downloads/Nanosaur/build/Nanosaur 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib32/libthread_db.so.1".
[New Thread 0xe6df03c0 (LWP 7279)]
[New Thread 0xd6bff3c0 (LWP 7280)]
[New Thread 0xcf3ee3c0 (LWP 7284)]
[New Thread 0xce8be3c0 (LWP 7285)]

Thread 1 "Nanosaur" received signal SIGSEGV, Segmentation fault.
0x00427dc8 in UpdateSkinnedGeometry_Recurse (skelNode=skelNode@entry=0x518478 <gObjNodeMemory+944>, joint=joint@entry=0) at /home/amigaone/Downloads/Nanosaur/src/Skeleton/Bones.c:331
331			numRefs = decomposedPointList[i].numRefs;									// get # times this point is referenced

bt

Output:

#0  0x00427dc8 in UpdateSkinnedGeometry_Recurse (skelNode=skelNode@entry=0x518478 <gObjNodeMemory+944>, joint=joint@entry=0)
        at /home/amigaone/Downloads/Nanosaur/src/Skeleton/Bones.c:331
    #1  0x00428628 in UpdateSkinnedGeometry (theNode=theNode@entry=0x518478 <gObjNodeMemory+944>) at /home/amigaone/Downloads/Nanosaur/src/Skeleton/Bones.c:206
    #2  0x0042a490 in MakeNewSkeletonObject (newObjDef=0x5900ec <gNewObjectDefinition>) at /home/amigaone/Downloads/Nanosaur/src/Skeleton/SkeletonObj.c:154
    Backtrace stopped: Cannot access memory at address 0xffffe424

@jorio
Copy link
Owner

jorio commented Apr 13, 2023

In src/System/File.c, try to comment out all calls to ByteswapInts.

@chzigotzky
Copy link
Author

Thanks

It starts. The title and credits screen has wrong colors. The Pangea logo has correct colors. After the logo, the menu appears with correct colors. The game itself has correct colors but the edge not.

Nanosaur_Linux_PowerPC_2

Nanosaur_Linux_PowerPC_1

@jorio
Copy link
Owner

jorio commented Apr 16, 2023

Try to replace GL_UNSIGNED_INT_8_8_8_8 with GL_UNSIGNED_INT_8_8_8_8_REV in:

  • src/QD3D/Renderer.c
  • src/QD3D/QD3D_Support.c
  • src/Screens/Infobar.c

@chzigotzky
Copy link
Author

It works with the correct colors! :-) Great! Thanks a lot! :-)

Nanosaur_1 4 4_Linux_PowerPC

@BeWorld2018
Copy link

Working fine on MorphOS (PPC), thanks

jorio added a commit that referenced this issue May 21, 2023
@jorio
Copy link
Owner

jorio commented May 21, 2023

The big-endian fixes have been pushed to master. Feel free to reopen this issue if anything's missing.

@jorio jorio closed this as completed May 21, 2023
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

No branches or pull requests

3 participants