#include "commun.h"

unsigned int IWRAM_CODE AjSprite(const unsigned char *adr_sprite, unsigned short taille)
{
        int i;

        if (skip || nSprGba >= MAX_SPRITES_GBA)
                return 0;

        taille >>= 1;

        /****************************************
                    LENT ?!!!!
    ****************************************/
        for (i = nSprGba - 1; i >= 0; i--)
                if (sprGba[i].tile_sprite == adr_sprite && sprGba[i].taille_tiles == taille)
                        return sprGba[i].n_tile;

        sprGba[nSprGba].tile_sprite = adr_sprite;
        sprGba[nSprGba].taille_tiles = taille;
        sprGba[nSprGba].n_tile = n_tile;
        i = n_tile;
        n_tile += (taille >> 5);
        nSprGba++;
        return i;
}

unsigned int IWRAM_CODE AjSpriteRapide(const unsigned char *adr_sprite, unsigned short taille)
{
        int i;

        if (skip || nSprGba >= MAX_SPRITES_GBA)
                return 0;

        taille >>= 1;

        sprGba[nSprGba].tile_sprite = adr_sprite;
        sprGba[nSprGba].taille_tiles = taille;
        sprGba[nSprGba].n_tile = n_tile;
        i = n_tile;
        n_tile += (taille >> 5);
        nSprGba++;
        return i;
}
