@neauoire @cancel Thanks. I got it working now.
codeberg.org/spazzpp2/julz/src
(Never do trial and error on index offsets in the middle of the night. Also, know your libraries).

I mostly used the table and the C implementation from wiki.xxiivv.com/site/ulz_forma for reference.

I was a little disappointed when I learned that CPY doesn't copy from the input but from the output array. So, no self-modification. Good for debugging, though.

Would you get more out of it when you assume, the compression always starts with LIT and then simply alternates between CPY and LIT? Their first bit would then be obsolete (twice as much length). You probably need a zero-length LIT as well.

CPY with length > offset repeating over and over again is a really nice idea, especially for ordered dither images!