import fxconv def convert(input, output, params, target): if params["custom-type"] == "level": convert_level(input, output, params, target) return 0 else: return 1 def convert_level(input, output, params, target): with open(input, "r") as fp: lines = fp.read().split("\n") lines = [tempo.split(",") for tempo in lines if not tempo.startswith("#")] blocks = bytes() block_count = 0 for (tempo, rects) in enumerate(lines): for r in [r for r in rects if r]: r = r.strip().split() print(tempo, r) shape, action, position = -1, 0, -1 # Shape if "square" in r: shape = 0 if "small" in r: shape = 2 if "medium" in r: shape = 3 if "normal" in r: shape = 4 if "long" in r: shape = 5 if "huge" in r: shape = 6 if "long_vertical" in r: shape = 7 # Action # Position if "left" in r: position = 0 if "right" in r: position = 1 if "middle" in r: position = 2 # Implicit rules if shape < 0 and action == 0: shape = 4 if shape < 0 or action < 0 or position < 0: raise fxconv.FxconvError("Incomplete in '" + " ".join(r) + "'") blocks += fxconv.u32(tempo) blocks += fxconv.u32(shape) blocks += fxconv.u32(position) blocks += fxconv.u32(action) block_count += 1 o = fxconv.ObjectData() o += fxconv.u32(0x40000000) # 2.0 as a float o += fxconv.u32(block_count) o += fxconv.ref(blocks) fxconv.elf(o, output, "_" + params["name"], **target)