This is one binary! 🥳
This is one binary! 🥳
It works on real GBA hardware too, except the Everdrive GBA doesn't skip the logo check, so I had to add that back in, borking the DOS header.
That means a GBA+DOS/Win32 polyglot is not possible on real hardware. Bummer.
Now with two more targets! 🎉
...to facilitate which I rewrote the rendering (across all targets) to use maps and tiles, since the Game Boy and Game Boy Color do not support bitmaps!
They all use the same tiles, map and palette - the latter is organized in 4 columns roughly in luminance order such that the indices also work as grayscale values.
@sean_earle I'll do a write-up when I get to where I want it to be, but in short:
- The first few bytes are simultaneously a valid MZ (DOS .exe) header, x86 trampoline code and ARM trampoline code. That was the trickiest bit by far
- The BIOS boot landing code set up memory segments to mimic DOS, then jumps to the DOS code
- Apart from the trampoline, the part of the GBA header that overlaps with MZ is the compressed Nintendo logo. But it turns out emulators and flashcarts don't really check for this, so I can just use it for the MZ fields
- The two intermediate binaries (x86 and ARM) adhere to shared layout constraints, and are sliced into the final binary
- The 320x224 splash image is sized with also the SNES in mind, but that makes it too large to fit in a real-mode memory segment, so for DOS+BIOS I had to compress it and abuse wraparound on decompression.
Code for this POC here: https://codeberg.org/sjmulder/bridges.rom/src/branch/_start/pocs/splash
@astraleureka @sean_earle it does work with mGBA! (without the logo)
mGBA always runs it in GBA mode though, I don't know how to force it to load the ROM as GB(C). It doesn't look at the file extension.
@anon oh yes that's a whole thing!: