(codedata, version)
return code_length, code, compressed_size
Gets the code text from the byte data.

    Args:
        codedata: The bytes of the code region (0x4300:0x8000).
        version: The version of the cart data.

    Returns:
        The tuple (code_length, code, compressed_size). compressed_size is
        None if the code data was not compressed. code is a bytestring.
Gets the code text from the byte data.
Gets the code text from the byte data .
def get_code_from_bytes(codedata, version):
    """Gets the code text from the byte data.

    Args:
        codedata: The bytes of the code region (0x4300:0x8000).
        version: The version of the cart data.

    Returns:
        The tuple (code_length, code, compressed_size). compressed_size is
        None if the code data was not compressed. code is a bytestring.
    """

    if version == 0 or bytes(codedata[:4]) != b':c:\x00':
        # code is ASCII

        try:
            code_length = codedata.index(0)
        except ValueError:
            # Edge case: uncompressed code completely fills the code area.
            code_length = 0x8000 - 0x4300

        code = bytes(codedata[:code_length]) + b'\n'
        compressed_size = None

    else:
        # code is compressed
        code_length, code, compressed_size = \
            compress.decompress_code(codedata)

    code = code.replace(b'\r', b' ')

    return code_length, code, compressed_size
def get_code_from_bytes ( codedata , version ) : if version == 0 or bytes ( codedata [ : 4 ] ) != b':c:\x00' : # code is ASCII try : code_length = codedata . index ( 0 ) except ValueError : # Edge case: uncompressed code completely fills the code area. code_length = 0x8000 - 0x4300 code = bytes ( codedata [ : code_length ] ) + b'\n' compressed_size = None else : # code is compressed code_length , code , compressed_size = compress . decompress_code ( codedata ) code = code . replace ( b'\r' , b' ' ) return code_length , code , compressed_size