/* ************************************************************************** */ /* */ /* ML_bmp_xor_cl.c */ /* | Project : libmonochrome */ /* */ /* By: Pierre "PierrotLL" Le Gall */ /* Last updated: 2011/11/22 */ /* */ /* ************************************************************************** */ #include void ML_bmp_xor_cl(const unsigned char *bmp, int x, int y, int width, int height) { unsigned short line; char shift, *screen, *p; int i, j, real_width, begin_x, end_x, begin_y, end_y; char bool1=1, bool2=1, bool3; if(!bmp || x<1-width || x>127 || y<1-height || y>63 || height<1 || width<1) return; p = (char*)&line; real_width = (width-1>>3<<3)+8; if(y < 0) begin_y = -y; else begin_y = 0; if(y+height > 64) end_y = 64-y; else end_y = height; shift = 8-(x&7); if(x<0) { begin_x = -x>>3; if(shift != 8) bool1 = 0; } else begin_x = 0; if(x+real_width > 128) end_x = 15-(x>>3), bool2 = 0; else end_x = real_width-1>>3; bool3 = (end_x == real_width-1>>3); screen = ML_vram_adress()+(y+begin_y<<4)+(x>>3); for(i=begin_y ; i>3)+begin_x] << shift; if(bool1) screen[begin_x] ^= *p; if(shift!=8) screen[begin_x+1] ^= *(p+1); for(j=begin_x+1 ; j>3)+j] << shift; screen[j] ^= *p; if(shift!=8) screen[j+1] ^= *(p+1); } } line = bmp[i*(real_width>>3)+end_x]; if(bool3) line &= -1<