playdate-reverse-engineering
playdate-reverse-engineering copied to clipboard
Document `pdex.bin` file format and add improved conversion script
I documented the pdex.bin file format. It is essentially a stripped-down ELF file consisting of metadata, a program segment and relocation entries.
I also replaced the pdex2elf.py with pdex2elf.ps1. pdex2elf.py does not actually work with pdex.bin files. I'm late to the Playdate game but I suspect (much) older versions of the SDK produced executable files in a much different format from what is in use currently.
The new pdex2elf.ps1 script creates well-formed ELF file that can be analyzed by readelf or objdump and decompiled by Ghidra, and it can even be compiled back by pdc into a bit-for-bit idential copy of the original pdex.bin. I tested it with both some of my own WIP games as well as some non-encrypted games from the catalog and they round-tripped perfectly.
It is a PowerShell script which I expect to be a bit controversial 😛 but PS is the only shell scripting-like language I'm proficient in so take it for what it is. If you would like to port the functionality to Python or whatever you have my blessing.
@jaames Pinging just in case you haven't yet seen this PR.