psyq2elf - Convert Psy-Q SDK libraries

Start a log and update it occasionally with your projects progress
Post Reply
jype
Interested PSXDEV User
Interested PSXDEV User
Posts: 6
Joined: May 19th, 2019, 6:36 am

psyq2elf - Convert Psy-Q SDK libraries

Post by jype » March 21st, 2020, 10:59 am

After using Psy-Q SDK for a while I got fed up with using the > 20 year old development environment through DOSBox. I liked having a complete SDK, but wished it could be used with modern tools.

Inspired by spirit_t0aster's work, I started looking into reverse engineering the remaining bits of the Psy-Q library format. At some point I realized that the format is similar enough to ELF, and could in fact be converted with minimal workarounds.

The Psy-Q library format supports arbitrary length expressions for relocations, which would be horrible to hack around with the ELF format. Luckily only a handful of the expression types are actually used in the library object files, and they can be expressed with ELF symbol offsets and relocations.

So I created a set of tools called psyq2elf that can convert Psy-Q libraries to ELF libraries. The converted libraries can be used to build PSX executables with modern GCC. So far, all Psy-Q SDK examples and test projects that I've tried have worked.

As has been said before, the Psy-Q SDK is copyrighted, and of poor quality. It would be better to focus on using and developing open source PSX SDKs.

But anyway, I hope the tools can be useful to someone, for PSX development or maybe even reverse engineering purposes.

psyq2elf source code and examples:
https://gitlab.com/jype/psyq2elf

Image

The example project also shows how to build PSX executables with only a linker script and objcopy (without elf2exe).

Projects that the work is based on:
spirit t0aster's worklog
armips
REDasm
PSn00bSDK (toolchain guide, EXE header)

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2393
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: psyq2elf - Convert Psy-Q SDK libraries

Post by Shadow » March 21st, 2020, 1:58 pm

That's really nice work! Would be very interesting to see a modern GCC compilers binary output and compare the assembly with the CCPSX compiler to see if it optimises better.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

SamuelHusky
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: April 7th, 2020, 2:29 am

Re: psyq2elf - Convert Psy-Q SDK libraries

Post by SamuelHusky » April 13th, 2020, 11:39 am

It's really nice to see something like this being worked on.

Your code built fine on Ubuntu with GCC 7.5.0 and converted the libraries as expected.

Toolchain is Binutils 2.34 and GCC 9.3.0 (mipsel-unknown) and the cube example compiles ok. However I seem to not be able to get it to run. (Have tried GCC 8.2.0 as well)

No$PSX seems to break at 1FC08E90 with a jrel instruction that comes up as Undef Opcode.

Any idea? Let me know if you need more info.

jype
Interested PSXDEV User
Interested PSXDEV User
Posts: 6
Joined: May 19th, 2019, 6:36 am

Re: psyq2elf - Convert Psy-Q SDK libraries

Post by jype » April 14th, 2020, 1:32 am

Thanks for trying it out, I did find a bug in the executable header - most emulators don't care about some of the values so it worked anyway. This is now fixed in the repository.

I tested the cube example with epsxe, no$psx, mednafen, pcsxr and on hardware.
Did you run "cube.exe" (not "cube" ELF file) with no$psx? Can you try pulling the fix from the repository and recompiling the example, and maybe also with another emulator?

If it still doesn't work you can upload "cube" ELF and I can try to debug it :)

SamuelHusky
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: April 7th, 2020, 2:29 am

Re: psyq2elf - Convert Psy-Q SDK libraries

Post by SamuelHusky » April 14th, 2020, 8:24 am

Dude, you are magic! Your change has fixed the issue I was having compiling the cube example.

As a side note I did try ePSXe originally, but just had black screen.

Image
You do not have the required permissions to view the files attached to this post.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests