GB/GBC Games Include Source November 27
Pagetable is reporting that The Legend of Zelda - Link‚Äôs Awakening DX for the GB/GBC (as well as other games) has source code included and unencrypted. Apparently, the games needed to be 2MB in size, and if they weren’t big enough, padding with files already on hand was easy enough to do. So, if the files included information included in the RAM at the time, you get a nice chunk of the source code.
Imagine you’re writing a Game Boy game, and the resulting ROM with all the code and data is just a little over one megabyte in size. No big deal, just pad the game to two megabytes, and use a 2 MB ROM in the cartridge. Just tell the linker to allocate 2 MB or RAM, put the actual data at the beginning, and then write a 2 MB “.gb” image to disk, which will then be sent to the ROM chip factory.
Now imagine you’re doing this in MS-DOS. Your linker, probably written in C, calls malloc() of the runtime library of the C compiler. You already know where this is going?
While modern operating systems will always clear all malloc()ed memory, so that you cannot get to other processes’ data, this was uncommon in the single-user MS-DOS days. If you allocate 2 MB of RAM (the linker must have used a DOS extender or XMS), you’d get memory with random data in it: leftovers from whatever was in this memory before. (seppel tells me that this can also be caused by seek()ing over EOF in MS-DOS, in which case the previous data on the hard disk will be in the image.)
Discuss this topic in our forums.

