new tonclib

I've been making a lot of changes to tonclib – mostly adding, but also some removals. The most important changes are:

  • A more unified interface for the base drawing routines. Whereas I used to have something like bm8_foo(...), I now have bmp8_foo(..., void *dstBase, u32 dstPitch) for everything. Although the extra parameters make the routines a little slower, it makes it easier to switch video-modes.
  • A few color routines like blending/fading, convert to rgbscale (like grayscale, but for any color vector) and a few color adjustments.
  • I'm trying to include (well, annex, really) some of libgba's functionality. In terms of shared functionality, the libgba names can be used by including tonc_libgba.h. This is definitely not a finished item yet.
  • Tonc's Text Engine. I already had some basic routines for text on different video types, but this is a good deal better. Instead of having separate foo_puts() routines, TTE uses function pointers for placing glyphs on screen. This means there can be a single interface for all modes, and customizable writers. Already provides are glyph renderers for 8/16bit bitmaps and 4bit tiles, using a 1bpp bitpacked font. In principle, the renderers can handle any sized fixed and variable-width fonts (within reason: 128x128 fonts would be impractical, for example). There are also hooks for the stdio functions (printf, yay!) and some simple commands for positioning, color and font changes. Example of use:
    // Set-up 4bpp tile rendering bg 0 using cbb=0 and sbb=31.
    // The default options set implicitly here are: verdana 9 font, yellow for 
    // text color
    tte_init_chr4_dflt(0, BG_CBB(0)|BG_SBB(31));
    // Init stdio hooks
    // Print something at position (10,10)
    iprintf("\\{P:10,10}'Ello world!, %d", 1337);
    Aside from the initializer, using TTE is basically independent of what you're writing with or on. Of course, all this stuff does have a fair amount of per-character overhead (about 150 cycles, I believe). It shouldn't be too hard to port TTE to NDS; I am planning to do this at some point.

There are more smaller changes here and there, but those are of lesser consequence.

tonclib 1.3 linky.

One thought on “new tonclib

Leave a Reply

Your email address will not be published. Required fields are marked *