andreasjhkarlsson / gbdk-n

gbdk libraries updated for newer versions of sdcc
174 stars 25 forks source link

Gameboy Color Support #17

Open sreuter opened 5 years ago

sreuter commented 5 years ago

Lddc supports setting the -Wl-yp0x143=0x80 flag to set things as Gameboy Color compatible. Is there an equivalent way for doing this with gbdk-n / sdcc?

sreuter commented 5 years ago

Ok, here comes something awesome. I thought I was stuck here and would need to go back to gbdk / lcc... Luckily, with a bit of more googling I stumbled upon this post: http://gbdev.gg8.se/forums/viewtopic.php?id=463

@DonaldHays, as part of his work on his game, build a great, much more versatile tool for the linking part... conveniently for me, in node :)

node ihx2gb/ihx2gb.js --help

  Usage: ihx2gb [options] <in_file> <out_file>

  Options:

    -h, --help                 output usage information
    -n, --name [value]         The name in the header. Default: "MY GAME"
    -m, --manufacturer [code]  The manufacturer code. Default: ""
    -c, --cgb [flag]           The decimal Game Boy Color support flag. 128 for CGB+GB, 192 for CGB-only. Default: 0
    -l, --licensee [code]      The ASCII licensee code. Default: "00"
    -s, --sgb [flag]           The decimal Super Game Boy support flag. 3 to enable. Default: 0
    -t, --cartridge [type]     The decimal cartridge type. Default: 0
    -r, --rom [code]           The decimal ROM size code. File will be 32KB << value, except for 82, 83, and 84. Default: 0
    -a, --ram [code]           The decimal external RAM size code. Default: 0
    -d, --destination [code]   The destination code. 0 for Japan, 1 for international. Default: 1
    --oldlicensee [code]       The decimal old licensee code. 51 to use new licensee code. SGB will not work if != 51. Default: 51
    -v, --version [version]    The ROM version. Default: 0

Go to http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header for header details, including values for Cartridge Type, ROM Size, and RAM Size. That site lists codes in hex, but must be provided here in decimal.

I'd highly recommend you two to catch up on how to get this in a the default tool for gbdk-n.. or, at the very least, add a note to the README.md.

Anyway, I'm most delighted. Thanks folks!

DonaldHays commented 5 years ago

Indeed I did make that tool! I've also gone into some detail about it on this very repository on issue #5 at https://github.com/andreasjhkarlsson/gbdk-n/issues/5#issuecomment-313583450 .

Notably, while it works, and I have banking working on it, banking support has a serious asterisk, in that it depends on behavior in SDCC that's consistent in my experience, but unspecified, and so may change at any time.

If you don't need banking, I think the tool works perfectly fine. If you do need banking, then I think you need to understand the unspecified behavior risk before using it, and I think that qualification makes it difficult to recommend the tool for the general case.

(I have lately been doing some experiments with writing a full linker for SDCC to Game Boy, which would replace this tool, and not rely on unspecified behavior. It's a larger project than IHX2GB, but it would be an easier recommendation for a default tool).

basxto commented 4 years ago

~Just use makebin -Z -yc or add the -yc flag to gbdk-n-make-rom.sh~ gbdk-n-make-rom.sh -yc