+
+tColour Video_AlphaBlend(tColour _orig, tColour _new, uint8_t _alpha)
+{
+ uint16_t ao,ro,go,bo;
+ uint16_t an,rn,gn,bn;
+ if( _alpha == 0 ) return _orig;
+ if( _alpha == 255 ) return _new;
+
+ ao = (_orig >> 24) & 0xFF;
+ ro = (_orig >> 16) & 0xFF;
+ go = (_orig >> 8) & 0xFF;
+ bo = (_orig >> 0) & 0xFF;
+
+ an = (_new >> 24) & 0xFF;
+ rn = (_new >> 16) & 0xFF;
+ gn = (_new >> 8) & 0xFF;
+ bn = (_new >> 0) & 0xFF;
+
+ if( _alpha == 0x80 ) {
+ ao = (ao + an) / 2;
+ ro = (ro + rn) / 2;
+ go = (go + gn) / 2;
+ bo = (bo + bn) / 2;
+ }
+ else {
+ ao = ao*(255-_alpha) + an*_alpha;
+ ro = ro*(255-_alpha) + rn*_alpha;
+ go = go*(255-_alpha) + gn*_alpha;
+ bo = bo*(255-_alpha) + bn*_alpha;
+ ao /= 255*2;
+ ro /= 255*2;
+ go /= 255*2;
+ bo /= 255*2;
+ }
+
+ return (ao << 24) | (ro << 16) | (go << 8) | bo;
+}
+