(dat, pos)
return best_len, block_offset
Find a repeatable block in the data.

    Part of the literal port of the PICO-8 compression routine. See
    compress_code().

    Args:
        dat: Array of data bytes.
        pos: Starting index in dat.

    Returns:
        A tuple: (best_len, block_offset)
Find a repeatable block in the data.
Find a repeatable block in the data .
def _find_repeatable_block(dat, pos):
    """Find a repeatable block in the data.

    Part of the literal port of the PICO-8 compression routine. See
    compress_code().

    Args:
        dat: Array of data bytes.
        pos: Starting index in dat.

    Returns:
        A tuple: (best_len, block_offset)
    """
    max_block_len = 17
    max_hist_len = (255 - len(COMPRESSED_LUA_CHAR_TABLE)) * 16
    best_len = 0
    best_i = -100000

    max_len = min(max_block_len, len(dat) - pos)
    max_hist_len = min(max_hist_len, pos)

    i = pos - max_hist_len
    while i < pos:
        j = i
        while (j - i) < max_len and j < pos and dat[j] == dat[pos + j - i]:
            j += 1

        if (j - i) > best_len:
            best_len = j - i
            best_i = i

        i += 1

    block_offset = pos - best_i

    return best_len, block_offset
def _find_repeatable_block ( dat , pos ) : max_block_len = 17 max_hist_len = ( 255 - len ( COMPRESSED_LUA_CHAR_TABLE ) ) * 16 best_len = 0 best_i = - 100000 max_len = min ( max_block_len , len ( dat ) - pos ) max_hist_len = min ( max_hist_len , pos ) i = pos - max_hist_len while i < pos : j = i while ( j - i ) < max_len and j < pos and dat [ j ] == dat [ pos + j - i ] : j += 1 if ( j - i ) > best_len : best_len = j - i best_i = i i += 1 block_offset = pos - best_i return best_len , block_offset