def clut8_rgb565(i):
    """RBG565 CLUT for wasp-os.

    This CLUT implements the same palette as :py:meth:`clut8_888` but
    outputs RGB565 pixels.

    .. note::

        This function is unused within this file but needs to be
        maintained alongside the reference clut so it is reproduced
        here.

    :param int i: Index (from 0..255 inclusive) into the CLUT
    :return:      16-bit colour in RGB565 format
    """
    if i < 216:
        rgb565  = (( i  % 6) * 0x33) >> 3
        rg = i // 6
        rgb565 += ((rg  % 6) * (0x33 << 3)) & 0x07e0
        rgb565 += ((rg // 6) * (0x33 << 8)) & 0xf800
    elif i < 252:
        i -= 216
        rgb565  = (0x7f + (( i  % 3) * 0x33)) >> 3
        rg = i // 3
        rgb565 += ((0x4c << 3) + ((rg  % 4) * (0x33 << 3))) & 0x07e0
        rgb565 += ((0x7f << 8) + ((rg // 4) * (0x33 << 8))) & 0xf800
    else:
        i -= 252
        gr6 = (0x2c + (0x10 * i)) >> 2
        gr5 = gr6 >> 1
        rgb565 = (gr5 << 11) + (gr6 << 5) + gr5

    return rgb565