Some functions in libgba for handling, e.g., basic
video stuff would be cool. For example: initialising
backgrounds, fading/alpha blending, initialising
sprites, etc. I don't mean as high level as, say,
HAMlib, but something a bit higher than writing direct
to registers. If only to make code less wordy. For
example, to initialise a background I have this kind of
thing (untested, hacked out of c++ code):
void gba_set_background(
int number,
int charbase,
int screenbase,
int flags )
{
REG_DISPCNT |= BG_ON(number);
BGCTRL[number] = SCREEN_BASE(screenbase) |
CHAR_BASE(charbase) | flags;
}
Also, for hardware "fading":
typedef enum {
BLDMOD_OBJECT=0,
BLDMOD_ALPHA=1,
BLDMOD_WHITE=2,
BLDMOD_FADE=3,
} BLDMOD_MODE_t;
void gba_set_blend(int first, int second, BLDMOD_MODE_t
mode) {
REG_BLDCNT = ((first)|((second)<<8)|(BLDMOD_MODE(mode)));
}
void gba_screen_fade(int level)
{
if (level > 16)
level = 16;
if (level < 0)
level = 0;
gba_set_blend( BLDMOD_BG1 | BLDMOD_BG0 | BLDMOD_BG2|
BLDMOD_OBJ ,
BLDMOD_BD , BLDMOD_FADE);
REG_BLDY = level;
}
Naming conventions are probably wrong there, but that's
the idea. Nothing really clever, just funcitons to save
typing LOTS_OF_THINGS = IN_CAPS. Or is this not the
direction libgba should take?