Menu

[GBZ80] is there a c standard library for SDCC?

Help
2015-08-21
2015-09-02
  • tom lukeywood

    tom lukeywood - 2015-08-21

    i figured out how to compile sdcc gameboy programs but
    dose anyone know if there is a standerd libary avalible for the sdcc?
    so i can do putchar('A')

     
  • Philipp Klaus Krause

    I do not know about a GB-specific standard library. SDCC comes with a standard library, but it does not include the GB-specific putchar(). Once youhave supplied your own putchar() though, printf(), etc will work.

    Philipp

     
  • David Cary

    David Cary - 2015-08-27

    When you figure out the answer, could you please edit http://en.wikibooks.org/wiki/GBA_Development or http://gbdev.gg8.se/wiki/ , or both, so the next person who has this exact problem will see your answer?

    I see that at least one person says the gameboy development kit GBDK works fine with SDCC: "Character output worked right out of the box" -- https://sourceforge.net/p/sdcc/support-requests/83/

    The GBDK http://gbdk.sourceforge.net/ includes a standard library including a GB-specific putchar().
    The Gameboy putchar() function is implemented in the file "font.ms" and "output.sol".

     
  • clobber

    clobber - 2015-08-28

    I see that at least one person says the gameboy development kit GBDK works fine with SDCC

    That was a 15 year old version of SDCC customized to work with a now ancient GBDK library. That development kit as-is will not work with recent SDCC.

    Someone has done a bit of work to update the GBDK libraries to compile with newer SDCC (https://github.com/rotmoset/gbdk-n), but I cannot get 'makebin' to create binaries from the intel hex. I always get 'error: size of the buffer is too small.'

    I opened up a ticket on their tracker (https://github.com/rotmoset/gbdk-n/issues/2) but maybe someone here has an idea as to the problem? It'd be nice to finally be able to use that library again with new SDCC.

     

    Last edit: clobber 2015-08-28
  • Frieder Ferlemann

    Hi, maybe check with e.g. srec_info srecord.sf.net whether the address range matches your expectations.
    If that's the case you could also try to use srec_cat or objcopy to generate a binary from an intel hex file.

    If you need to you could insert more diagnostic info into sdcc/support/makebin/makebin.c near line 298 (e.g. the value of addr + nbytes).

     
  • clobber

    clobber - 2015-09-02

    Thanks for the response. I was just linking incorrectly passing a .c file instead of .rel, so now everything is working as it should with the gbdk-n fork. The GBDK library can finally be used with the latest SDCC!

    One thing I did notice is makebin is lacking support for handling gameboy color headers. For example, rgbfix from rgbds has a flag to write 0x80 at offset 0x143 for setting the binary "gameboy color compatible" or 0xC0 for "gameboy color only" and a few other useful ones. Those would be great to have in makebin.

     

Log in to post a comment.