All pastes #83798 Raw Edit

Untitled

public text v1 · immutable
·published 2006-07-10 02:45 UTC
rendered paste body
void ClipSprite32_89_OR(short x, short y, short height, unsigned short *data, void *addr) {
	unsigned char i=0;
	unsigned long *pos=addr+(y*30);
	pos+=(x>>5); //increment pos according to x (x/32)

	for(;i<height;i++,(unsigned char *)pos+=30) {
		if(y+i<=99 && y+i>=0) {  //clip vertically
			if(x>=0 && x<=159-32) {  //if no horiz clipping is needed
				*pos |= data[i]>>(x&31); //(x%32)
				*(pos+1) |= data[i]<<(32-(x&31));
			}
			else {
				if(x<0 && x>-32) //if sprite is to the left
					*(pos+1) |= data[i]<<(32-(x&31));
				else             //if sprite is to the right
					*pos |= data[i]>>(x&31);
			}

		}
	}
}