Exemplo n.º 1
0
void putsprite_8(
    int x, int y, int is_flip, s_sprite *sprite, s_screen *screen,
    unsigned char *remap, unsigned char *blend
) {
    int *linetab;
    int w, h;
    unsigned char *dest;
    // Get screen size
    int screenwidth = screen->width;
    int screenheight = screen->height;
    // Adjust coords for centering
    if(is_flip) x += sprite->centerx;
    else x -= sprite->centerx;
    y -= sprite->centery;
    // Get sprite dimensions
    w = sprite->width;
    h = sprite->height;
    // trivial clip all directions
    if(is_flip)
    {
        if(x-w >= screenwidth) return;
        if(x <= 0) return;
    }
    else
    {
        if(x >= screenwidth) return;
        if((x+w) <= 0) return;
    }
    if(y >= screenheight) return;
    if((y+h) <= 0) return;
    // Init line table pointer
    linetab = (int*)(sprite->data);
    // clip top
    if(y < 0) {
        h += y; // subtract from height
        linetab -= y; // add to linetab
        y = 0; // add to y
    }
    // clip bottom
    if((y+h) > screenheight) {
        h = screenheight - y;
    }
    // calculate destination pointer
    dest = ((unsigned char*)(screen->data)) + y*screenwidth;

    if(blend&&remap) {
        if(is_flip) putsprite_remapblend_flip_(dest, x, linetab, h, screenwidth, remap, blend);
        else        putsprite_remapblend_     (dest, x  , linetab, h, screenwidth,remap, blend);
    } else if(blend) {
        if(is_flip) putsprite_blend_flip_(dest, x, linetab, h, screenwidth, blend);
        else        putsprite_blend_     (dest, x  , linetab, h, screenwidth, blend);
    } else if(remap) {
        if(is_flip) putsprite_remap_flip_(dest, x, linetab, h, screenwidth, remap);
        else        putsprite_remap_     (dest, x  , linetab, h, screenwidth, remap);
    } else {
        if(is_flip) putsprite_flip_      (dest, x, linetab, h, screenwidth);
        else        putsprite_           (dest, x  , linetab, h, screenwidth);
    }
}
Exemplo n.º 2
0
void putsprite_x8p16(
    int x, int y, int is_flip, s_sprite *sprite, s_screen *screen,
    unsigned short *remap, blend16fp blend
)
{
    int *linetab, *masklinetab = NULL;
    int w, h;
    unsigned short *dest;
    unsigned short *m;
    // Get screen size
    int screenwidth = screen->width;
    int xmin = useclip ? MAX(clipx1, 0) : 0,
        xmax = useclip ? MIN(clipx2, screen->width) : screen->width,
        ymin = useclip ? MAX(clipy1, 0) : 0,
        ymax = useclip ? MIN(clipy2, screen->height) : screen->height;
    // Adjust coords for centering
    if(is_flip)
    {
        x += sprite->centerx;
    }
    else
    {
        x -= sprite->centerx;
    }
    y -= sprite->centery;
    // Get sprite dimensions
    w = sprite->width;
    h = sprite->height;
    // trivial clip all directions
    if(is_flip)
    {
        if(x - w >= xmax)
        {
            return;
        }
        if(x <= xmin)
        {
            return;
        }
    }
    else
    {
        if(x >= xmax)
        {
            return;
        }
        if((x + w) <= xmin)
        {
            return;
        }
    }
    if(y >= ymax)
    {
        return;
    }
    if((y + h) <= ymin)
    {
        return;
    }
    // Init line table pointer
    linetab = (int *)(sprite->data);
    if(sprite->mask)
    {
        masklinetab = (int *)(sprite->mask->data);
        //if(w!=sprite->mask->width) { printf("Wrong mask width. %i %i\n", w, sprite->mask->width); return; }
        //if(h!=sprite->mask->height) { printf("Wrong mask height. %i %i\n", h, sprite->mask->height); return; }
    }
    // clip top
    if(y < ymin)
    {
        int diff = y - ymin;
        h += diff; // subtract from height
        linetab -= diff; // add to linetab
        masklinetab -= diff;
        y = ymin; // add to y
    }
    // clip bottom
    if((y + h) > ymax)
    {
        h = ymax - y;
    }
    // calculate destination pointer
    dest = ((unsigned short *)(screen->data)) + y * screenwidth;
    if(remap)
    {
        m = remap;
    }
    else
    {
        m = (unsigned short *)sprite->palette;
    }
    if(sprite->mask)
    {
        if(is_flip)
        {
            putsprite_mask_flip_ (dest, x, xmin, xmax, linetab, m, h, screenwidth, masklinetab);
        }
        else
        {
            putsprite_mask_      (dest, x, xmin, xmax, linetab, m, h, screenwidth, masklinetab);
        }
    }
    else if(blend)
    {
        if(is_flip)
        {
            putsprite_blend_flip_(dest, x, xmin, xmax, linetab, m , h, screenwidth, blend);
        }
        else
        {
            putsprite_blend_     (dest, x, xmin, xmax, linetab, m , h, screenwidth, blend);
        }
    }
    else
    {
        if(is_flip)
        {
            putsprite_flip_      (dest, x, xmin, xmax, linetab, m , h, screenwidth);
        }
        else
        {
            putsprite_           (dest, x, xmin, xmax, linetab, m , h, screenwidth);
        }
    }
}
Exemplo n.º 3
0
void putsprite_x8p32(int x, int y, int is_flip, s_sprite * sprite, s_screen * screen, unsigned *remap, blend32fp blend) {
	int *linetab, *masklinetab = NULL;
	int w, h;
	unsigned *dest;
	unsigned *m;
	// Get screen size
	int screenwidth = screen->width;
	int screenheight = screen->height;
	// Adjust coords for centering
	if(is_flip)
		x += sprite->centerx;
	else
		x -= sprite->centerx;
	y -= sprite->centery;
	// Get sprite dimensions
	w = sprite->width;
	h = sprite->height;
	// trivial clip all directions
	if(is_flip) {
		if(x - w >= screenwidth)
			return;
		if(x <= 0)
			return;
	} else {
		if(x >= screenwidth)
			return;
		if((x + w) <= 0)
			return;
	}
	if(y >= screenheight)
		return;
	if((y + h) <= 0)
		return;
	// Init line table pointer
	linetab = (int *) (sprite->data);
	if(sprite->mask) {
		masklinetab = (int *) (sprite->mask->data);
		//if(w!=sprite->mask->width) { printf("Wrong mask width. %i %i\n", w, sprite->mask->width); return; }
		//if(h!=sprite->mask->height) { printf("Wrong mask height. %i %i\n", h, sprite->mask->height); return; }
	}
	// clip top
	if(y < 0) {
		h += y;		// subtract from height
		linetab -= y;	// add to linetab
		y = 0;		// add to y
	}
	// clip bottom
	if((y + h) > screenheight) {
		h = screenheight - y;
	}
	// calculate destination pointer
	dest = ((unsigned *) (screen->data)) + y * screenwidth;
	if(remap)
		m = remap;
	else
		m = (unsigned *) sprite->palette;
	if(sprite->mask) {
		if(is_flip)
			putsprite_mask_flip_(dest, x, linetab, m, h, screenwidth, masklinetab);
		else
			putsprite_mask_(dest, x, linetab, m, h, screenwidth, masklinetab);
	} else if(blend) {
		if(is_flip)
			putsprite_blend_flip_(dest, x, linetab, m, h, screenwidth, blend);
		else
			putsprite_blend_(dest, x, linetab, m, h, screenwidth, blend);
	} else {
		if(is_flip)
			putsprite_flip_(dest, x, linetab, m, h, screenwidth);
		else
			putsprite_(dest, x, linetab, m, h, screenwidth);
	}
}