catskull / GB-Logo-Generator

Online Gameboy logo rom creator utility
http://catskull.net/GB-Logo-Generator/
GNU General Public License v3.0
39 stars 3 forks source link

Pad logo data with valid rom header #5

Closed catskull closed 8 years ago

catskull commented 8 years ago

Get a no MBC rom (tetris) and use it's header info. Or, just figure out how the header data is laid out and make our own. Then downloading the rom will be a fully functional rom.

catskull commented 8 years ago

I have researched the rom header and have produced a rom with the correct data. It is 32kb in size since that is the smallest total rom size a gameboy can read. All data is just padded with FFFF which is correct if the data is not used in a real game. The logo data that needs to be re written is DEADBEEF in the rom. Here is the rom: https://drive.google.com/file/d/0B2JWZbiqagfDcmdicnVwaXpLa2s/view?usp=sharing

One problem is that a header checksum is calculated based on the data in the header. Since the logo changes every time, we need to re calculate this data. If it's incorrect, the gameboy won't boot. That may not actually be a problem though since our rom won't boot anyways! Here's some info on the checksum and how it's calculated: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header#014D_-_Header_Checksum

Note that below that there is a rom checksum. That should be correct since the data in the rom will not change.

catskull commented 8 years ago

I asked how the checksum is calculated on the gameboy dev forum. I got some responses: http://gbdev.gg8.se/forums/viewtopic.php?id=317

electr0sheep commented 8 years ago

To calculate checksum, perform the following operations on bytes 0x0134 through 0x014C: Invert all bytes i.e. 1010 0101 becomes 0101 1010 Then, start at 0000 0000 and add all the bytes to the result, trimming off any excess bits i.e. 1111 1111 + 1111 1111 becomes 1111 1110. This will provide the checksum.

Basically, what is in a very complicated looking formula (0 - current byte - 1) is a very simple process. Simply invert the byte and add.