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= LCD_SIZE) continue; for(j=0; j 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; } } }