aboutsummaryrefslogtreecommitdiff
path: root/scripts/cut-recording-cycle.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cut-recording-cycle.py')
-rw-r--r--scripts/cut-recording-cycle.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/cut-recording-cycle.py b/scripts/cut-recording-cycle.py
new file mode 100644
index 0000000..ba1491b
--- /dev/null
+++ b/scripts/cut-recording-cycle.py
@@ -0,0 +1,21 @@
+import sys
+
+file = open(sys.argv[1], "rb")
+output_file = open(sys.argv[2], "wb")
+cycle = int(sys.argv[3])
+
+last_cycle_update = 0
+while True:
+ next_cycle_update_buf = file.read(16)
+ if len(next_cycle_update_buf) < 16:
+ break
+ inputs = file.read(2)
+
+ next_cycle_update = int.from_bytes(next_cycle_update_buf, byteorder="little", signed=False)
+ print("CYCLES: %d, input1: %08x, input2: %08x" % (next_cycle_update, inputs[0], inputs[1]))
+
+ if next_cycle_update > cycle:
+ break
+
+ output_file.write(next_cycle_update.to_bytes(16, byteorder="little", signed=False))
+ output_file.write(inputs)