Thanks for taking a look and suggesting an alternative Thoram. All your assumptions about RGB were spot on
I did a quick test - the code you posted doesn't always work unfortunately.
For example, if d0=$f4, d1=$12 and d2=$23 (which is perfectly possible with the way colour bytes are written into the CMAP structure in an ILBM file) the resulting colour moved into the copperlist should be: $0f12 - your code outputs $0f52