Oh, so trial-and-error coding :)

Remove all the shifting by 4 and I'll merge. The transparency problem is probably some other problem...