How to copy. Most useful values are 0x00C0 for a vanilla copy, 0x0030 to invert the source and then copy or 0x0050 to ignore the source and just invert the destination. If you want to calculate other values, then you must know that channel A is set, if you are inside the rectangle, channel B is the source and channel C is the destination of the rectangle.
Bit ABC 0 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111
So 0x00C0 means: D is set if one is inside the rectangle (A is set) and B (the source) is set and cleared otherwise.
To fill the rectangle, you would want to set D when A is set, so the value is 0x00F0.