chrismaltby / gb-studio

A quick and easy to use drag and drop retro game creator for your favourite handheld video game system
https://www.gbstudio.dev
MIT License
8.45k stars 468 forks source link

Cartidge Header for ROM #90

Closed Audio-Rochey closed 5 years ago

Audio-Rochey commented 5 years ago

Some of us on discord are already disucssing what kind of cartidges we can flash our games on to.

Many of the cheap chinese clone cartidges are using MBC5 memory controllers, which makes me wonder what header bits are being set when we compile a rom?

Please have a look at: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header#0147_-_Cartridge_Type

This is an example of a header that needs to be set, dependent on the hardware that we're programming. Is there any chance of a simple GUI/Menu to select these?

Many thanks

Rochey

chrismaltby commented 5 years ago

Dev builds are currently using cartridge type 3 for MBC1+RAM+BATTERY since the save/load feature has been added. A few people have mentioned using MBC5 controllers now though so I could change to 1B for MBC5+RAM+BATTERY if that's better?

Audio-Rochey commented 5 years ago

Thanks Chris,

Just wondering if this should be an option, depending on which hardware you're writing to. MBC5 seems the most popular, but locking folks in seems a little strict.

chrismaltby commented 5 years ago

Yeah I think you're right.

I think the only valid options for the ROMs it creates are MBC5+RAM+BATTERY, MBC1+RAM+BATTERY, MBC5+RAM and MBC1+RAM so I'll add an option to choose one of these. And then if you don't include BATTERY I'll have to warn about if you try to use the Save/Load events

thomas-alrek commented 5 years ago

I tried to figure out how the cartridge header is generated. But couldn't find anything obvious in the makefile. Where are things like the cartridge title defined?

chrismaltby commented 5 years ago

Hi Thomas, I’ll sort this one, mostly got the UI done, just need to hook it to the makefile part. For your reference though it’s the flag -Wl-yt# in the makefile, currently hard coded as 3 in the develop branch http://gbdk.sourceforge.net/guidelines.html

thomas-alrek commented 5 years ago

Great :) While you are at it, could you also add the ability to change the cartridge title (0x134 - 0x143)?

chrismaltby commented 5 years ago

Done :-) 51d2d2a9b56fb4d733038dace9a9056ad38294f7 adds Cartridge Type to the "Game" menu, defaulting to MBC5+RAM+BATTERY

Screenshot 2019-04-29 at 23 09 06

The was no inbuilt method I could find for setting the cartridge title so I did it by manually editing the ROM data.

https://github.com/chrismaltby/gb-studio/blob/51d2d2a9b56fb4d733038dace9a9056ad38294f7/src/lib/compiler/makeBuild.js#L14-L21

Bit messy but it works :-)

Verified the ROM in hex editor, 0x134 - 0x143 contain the game title and the 1B just after the game title hex is 0x147 containing MBC5+RAM+BATTERY

Screenshot 2019-04-29 at 23 09 58