#include "includes.h"
#include "dsfont.h"
#include "graphics.h"

extern SDL_Surface *screen;

void dsfont(SDL_Surface *font, const char *s, int xp, int yp, Uint32 col) {
    while(*s) {
        dsfont_char(font, *s++, xp, yp, col);
        xp += font->w/10;
    }
}

void dsfont_char(SDL_Surface *font, char c, int xp, int yp, Uint32 col) {
    int x, y, xoff, yoff;

    if(c <= 32 || c > '~') return;

    xoff = (font->w/10 * ((c-32) % 10));
    yoff = (font->h/10 * ((c-32) / 10));

    for(x = 0; x < font->w/10; x ++) {
        for(y = 0; y < font->h/10; y ++) {
            if(gp(font, x+xoff, y+yoff))
                wp(x+xp, y+yp, col);
        }
    }
}
