# $Id: src-blitters.tmpl,v 1.2 1995/10/29 23:50:17 mat Exp $

begin_src_func
end_func


begin_mode copy_noshift max_unwrap
 repeat		@dst@ = @src@;
 mask		@dst@ = (@dst@ & ~arg) | (@src@ & arg);
end_mode

begin_mode or_noshift max_unwrap
 repeat		@dst@ |= @src@;
 mask		@dst@ |= (@src@ & arg);
end_mode

begin_mode xor_noshift max_unwrap
 repeat		@dst@ ^= @src@;
 mask		@dst@ ^= (@src@ & arg);
end_mode

begin_mode xor_noshift_fgbk max_unwrap
 repeat		@dst@ ^= @src@;
 mask		@dst@ ^= (@src@ & arg);
end_mode

begin_mode and_noshift max_unwrap
 repeat		@dst@ &= @src@;
 mask		@dst@ &= (@src@ | ~arg);
end_mode

begin_mode notcopy_noshift max_unwrap
 repeat		@dst@ = ~@src@;
 mask		@dst@ = (@dst@ & ~arg) | (~@src@ & arg);
end_mode

begin_mode notor_noshift max_unwrap
 repeat		@dst@ |= ~@src@;
 mask		@dst@ |= (~@src@ & arg);
end_mode

begin_mode notxor_noshift max_unwrap
 repeat		@dst@ ^= ~@src@;
 mask		@dst@ ^= (~@src@ & arg);
end_mode

begin_mode notxor_noshift_fgbk max_unwrap
 repeat		@dst@ ^= ~@src@;
 mask		@dst@ ^= (~@src@ & arg);
end_mode

begin_mode notand_noshift max_unwrap
 repeat		@dst@ &= ~@src@;
 mask		@dst@ &= ~(@src@ & arg);
end_mode


begin_src_func
 init const long left_shift = srcblt_shift_offset;
 init const long right_shift = 32 - left_shift;
end_func

begin_mode copy_shift max_unwrap
 repeat		@dst@ = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift));
 mask		@dst@ = (@dst@ & ~arg) | (CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) & arg);
end_mode

begin_mode or_shift max_unwrap
 repeat		@dst@ |= CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift));
 mask		@dst@ |= CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) & arg;
end_mode

begin_mode xor_shift max_unwrap
 repeat		@dst@ ^= CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift));
 mask		@dst@ ^= CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) & arg;
end_mode

begin_mode xor_shift_fgbk max_unwrap
 repeat		@dst@ ^= CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift));
 mask		@dst@ ^= CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) & arg;
end_mode

begin_mode and_shift max_unwrap
 repeat		@dst@ &= CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift));
 mask		@dst@ &= CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) | ~arg;
end_mode

begin_mode notcopy_shift max_unwrap
 repeat		@dst@ = ~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)));
 mask		@dst@ = (@dst@ & ~arg) | (~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift))) & arg);
end_mode

begin_mode notor_shift max_unwrap
 repeat		@dst@ |= ~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)));
 mask		@dst@ |= (~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)))) & arg;
end_mode

begin_mode notxor_shift max_unwrap
 repeat		@dst@ ^= ~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)));
 mask		@dst@ ^= (~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)))) & arg;
end_mode

begin_mode notxor_shift_fgbk max_unwrap
 repeat		@dst@ ^= ~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)));
 mask		@dst@ ^= (~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)))) & arg;
end_mode

begin_mode notand_shift max_unwrap
 repeat		@dst@ &= ~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)));
 mask		@dst@ &= ~((CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift))) & arg);
end_mode



begin_src_func
 init	const uint32 fg_bits = srcblt_fg_color;
 init	const uint32 bk_bits = srcblt_bk_color;
end_func

begin_mode copy_noshift_fgbk max_unwrap
 repeat	{ const uint32 s = @src@; @dst@ = (s & fg_bits) | (~s & bk_bits); }
 mask	{ const uint32 s = @src@; @dst@ = (@dst@ & ~arg) | (((s & fg_bits) | (~s & bk_bits)) & arg); }
end_mode

begin_mode notcopy_noshift_fgbk max_unwrap
 repeat	{ const uint32 s = @src@; @dst@ = (~s & fg_bits) | (s & bk_bits); }
 mask	{ const uint32 s = @src@; @dst@ = (@dst@ & ~arg) | (((~s & fg_bits) | (s & bk_bits)) & arg); }
end_mode


begin_src_func
 init	const uint32 fg_bits = srcblt_fg_color;
end_func

begin_mode or_noshift_fgbk max_unwrap
 repeat	{ uint32 s = @src@, d; d = @dst@ & ~s; d |= (s & fg_bits); @dst@ = d; }
 mask	{ uint32 s = @src@ & arg, d; d = @dst@ & ~s; d |= (s & fg_bits); @dst@ = d; }
end_mode

begin_mode notor_noshift_fgbk max_unwrap
 repeat	{ uint32 s = @src@, d; d = @dst@ & s; d |= (~s & fg_bits); @dst@ = d; }
 mask	{ uint32 s = ~@src@ & arg, d; d = @dst@ & ~s; d |= (s & fg_bits); @dst@ = d; }
end_mode


begin_src_func
 init	const uint32 bk_bits = srcblt_bk_color;
end_func

begin_mode and_noshift_fgbk max_unwrap
 repeat	{ uint32 s = @src@, d; d = @dst@ & s; d |= (~s & bk_bits); @dst@ = d; }
 mask	{ uint32 s = @src@ | ~arg, d; d = @dst@ & s; d |= (~s & bk_bits); @dst@ = d; }
end_mode

begin_mode notand_noshift_fgbk max_unwrap
 repeat	{ uint32 s = @src@, d; d = @dst@ & ~s; d |= (s & bk_bits); @dst@ = d; }
 mask	{ uint32 s = @src@ & arg, d; d = @dst@ & ~s; d |= (s & bk_bits); @dst@ = d; }
end_mode



begin_src_func
 init	const long left_shift = srcblt_shift_offset;
 init	const long right_shift = 32 - left_shift;
 init	const uint32 fg_bits = srcblt_fg_color;
 init	const uint32 bk_bits = srcblt_bk_color;
end_func

begin_mode copy_shift_fgbk max_unwrap
 repeat	{ const uint32 s = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)); @dst@ = (s & fg_bits) | (~s & bk_bits); }
 mask	{ const uint32 s = (CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) & arg); uint32 d = @dst@ & ~arg; d |= ((s & fg_bits) | (~s & bk_bits)) & arg; @dst@ = d; }
end_mode

begin_mode notcopy_shift_fgbk max_unwrap
 repeat	{ const uint32 s = (CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift))); @dst@ = (~s & fg_bits) | (s & bk_bits); }
 mask	{ const uint32 s = (CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) & arg); uint32 d = @dst@ & ~arg; d |= ((~s & fg_bits) | (s & bk_bits)) & arg; @dst@ = d; }
end_mode


begin_src_func
 init	const long left_shift = srcblt_shift_offset;
 init	const long right_shift = 32 - left_shift;
 init	const uint32 fg_bits = srcblt_fg_color;
end_func

begin_mode or_shift_fgbk max_unwrap
 repeat	{ const uint32 s = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)); uint32 d = @dst@ & ~s; d |= (s & fg_bits); @dst@ = d; }
 mask	{ const uint32 s = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) & arg; uint32 d = @dst@ & ~s; d |= (s & fg_bits); @dst@ = d; }
end_mode

begin_mode notor_shift_fgbk max_unwrap
 repeat	{ const uint32 s = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)); uint32 d = @dst@ & s; d |= (~s & fg_bits); @dst@ = d; }
 mask	{ const uint32 s = ~(CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift))) & arg; uint32 d = @dst@ & ~s; d |= (s & fg_bits); @dst@ = d; }
end_mode


begin_src_func
 init	const long left_shift = srcblt_shift_offset;
 init	const long right_shift = 32 - left_shift;
 init	const uint32 bk_bits = srcblt_bk_color;
end_func

begin_mode and_shift_fgbk max_unwrap
 repeat	{ const uint32 s = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)); uint32 d = @dst@ & s; d |= (~s & bk_bits); @dst@ = d; }
 mask	{ const uint32 s = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) | ~arg; uint32 d = @dst@ & s; d |= (~s & bk_bits); @dst@ = d; }
end_mode

begin_mode notand_shift_fgbk max_unwrap
 repeat	{ const uint32 s = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)); uint32 d = @dst@ & ~s; d |= (s & bk_bits); @dst@ = d; }
 mask	{ const uint32 s = CL ((CL (@src@) << left_shift) | (CL (@src_plus_1@) >> right_shift)) & arg; uint32 d = @dst@ & ~s; d |= (s & bk_bits); @dst@ = d; }
end_mode
