This is one binary! 🥳

#RetroProgramming #GBADev

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.

#RetroProgramming #GBDev #GBADev #DOS

@sjmulder That's super cool, I'd love to know how you did it!

@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

bridges.rom

Polyglot Death Stranding demake

Codeberg.org
@sjmulder @sean_earle I don't have mGBA handy at the moment, but does it boot the image successfully? it's far closer to the real hardware and possibly checks headers (although probably not the boot image, since that was supposed to be the copyrightable bit that Nintendo intended for use in court)

@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.

@sjmulder cool! a quick question: is it possible to modify the behavior of a pre-built ROM? I want to impress someone by "hacking" pokeamon firered :)
ROM hacking - Wikipedia

@sjmulder omg that's so neat!!