All pastes #335219 Raw Edit

Tyler

public c v1 · immutable
·published 2007-02-01 05:03 UTC
rendered paste body
void ClipSpriteX8_OR(short x, short y, short h, unsigned char *sprite, short bytewidth, unsigned char *dest){	short bit_r, bit_l, new_x;	short first_byte;	short i, j;	unsigned char clipped;		// No bytewidth may exceed 30	if (bytewidth > 30)		return;		// Return if will never see	if (x <= -(bytewidth << 3) || y <= -h || x > 239 || y > 127)		return;		// Calculate	first_byte = (y * 30) + (x >> 3);	bit_r = x & 7;	bit_l = 8 - bit_r;		for(i=0; i<h; i++)	{		// Clip Y		if (first_byte + (30 * i) < 0 || first_byte + (30 * i) >= LCD_SIZE)			continue;				for(j=0; j<bytewidth; j++)		{			// Return if will never see			new_x = x + (j << 3);			if (new_x < -7 || new_x > 239)				continue;						// Clip X			if (new_x < 0)			{				clipped = *(sprite + (i * bytewidth) + j) << -new_x;				clipped >>= -new_x;			}			else if (new_x > 232)			{				clipped = *(sprite + (i * bytewidth) + j) >> (new_x - 232);				clipped <<= (new_x - 232);			}			else				clipped = *(sprite + (i * bytewidth) + j);						// OR Sprite Now			*(dest+first_byte+(30*i)+j) |= clipped >> bit_r;			if (bit_r)				*(dest+first_byte+(30*i)+j+1) |= clipped << bit_l;		}	}}