예제 #1
0
파일: parse.py 프로젝트: zappfinger/pch2csd
def parse_module_list(blob: bitarray, patch: Patch):
    bits = BitArrayStream(blob)
    loc, num_modules = bits.read_ints([2, 8])
    num_modules, = unpack('>B', blob[2:10].tobytes())
    for i in range(num_modules):
        mod_type, mod_id = bits.read_ints([8, 8])
        hpos, vpos, color = bits.read_ints([7, 7, 8])
        _, _n = bits.read_ints([8, 4])
        _ = bits.read_ints([6] * _n)
        mod = Module(patch.data, Location.from_int(loc), mod_type, mod_id)
        patch.modules.append(mod)
예제 #2
0
파일: parse.py 프로젝트: holotape/pch2csd
def parse_module_parameters(blob: bitarray, patch: Patch):
    bits = BitArrayStream(blob)
    loc, num_modules, num_variations = bits.read_ints([2, 8, 8])
    for imod in range(num_modules):
        mod_id, num_params = bits.read_ints([8, 7])
        mod_params = ModuleParameters(Location.from_int(loc), mod_id, num_params)
        for ivar in range(num_variations):
            var, *p_list = bits.read_ints([8] + [7] * num_params)
            if var == patch.description.active_variation:
                mod_params.values.extend(p_list)  # TODO variations support
        patch.mod_params.append(mod_params)
예제 #3
0
파일: parse.py 프로젝트: zappfinger/pch2csd
def parse_cable_list(blob: bitarray, patch: Patch):
    bits = BitArrayStream(blob)
    loc, _skip_, num_cables = bits.read_ints([2, 14, 8])
    for i in range(num_cables):
        color, module_from, jack_from, cable_type, module_to, jack_to = bits.read_ints(
            [3, 8, 6, 1, 8, 6])
        c = Cable(Location.from_int(loc), CableType.from_int(cable_type),
                  CableColor.from_int(color), module_from, jack_from,
                  module_to, jack_to)
        if c.type == CableType.IN_TO_IN:
            # By some reason, in2in cables have sources swapped back with destinations...
            c.module_from = module_to
            c.module_to = module_from
            c.jack_from = jack_to
            c.jack_to = jack_from
        patch.cables.append(c)
예제 #4
0
파일: parse.py 프로젝트: zappfinger/pch2csd
def parse_location(loc: int):
    return Location.from_int(loc >> 6)