From 2290288e3b3b85156cbea6a90bb0158829c92f19 Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Mon, 11 May 2026 12:16:28 +0200 Subject: [PATCH] fix reorder bits --- src/tea3/lut.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/tea3/lut.py b/src/tea3/lut.py index f94012a..526fcbe 100644 --- a/src/tea3/lut.py +++ b/src/tea3/lut.py @@ -63,11 +63,33 @@ def F32_7(x0, x1, y0, y1): return (x0 & x1 & y1) ^ (x0 & y0 & y1) ^ (x0 & y0) ^ (x1 & y0 & y1) ^ x1 ^ y0 ^ y1 ^ 1 def main(): + F31_orders = [ + (0, 1, 2, 3), + (0, 1, 2, 3), + (3, 0, 1, 2), + (0, 1, 2, 3), + (0, 1, 2, 3), + (0, 1, 2, 3), + (0, 1, 2, 3), + (0, 1, 2, 3), + ] + + F32_orders = [ + (0, 1, 2, 3), + (0, 1, 2, 3), + (3, 0, 1, 2), + (0, 1, 2, 3), + (0, 1, 2, 3), + (0, 1, 2, 3), + (0, 1, 2, 3), + (0, 1, 2, 3), + ] + F31_coords = [F31_0, F31_1, F31_2, F31_3, F31_4, F31_5, F31_6, F31_7] F32_coords = [F32_0, F32_1, F32_2, F32_3, F32_4, F32_5, F32_6, F32_7] - lut_B = [pack_lut_4(f) for f in F31_coords] - lut_A = [pack_lut_4(f) for f in F32_coords] + lut_B = [pack_lut_4(f, o) for f, o in zip(F31_coords, F31_orders)] + lut_A = [pack_lut_4(f, o) for f, o in zip(F32_coords, F32_orders)] print("TEA3_LUT_A = [", end="") for x in lut_A: