From bf59f9acb9db5b3f0cae4d98b5aea6c6263cfe44 Mon Sep 17 00:00:00 2001 From: beerpsi Date: Fri, 29 Dec 2023 00:23:09 +0700 Subject: [PATCH] funny bit shifts --- src/backends/tasoller_v1.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/backends/tasoller_v1.rs b/src/backends/tasoller_v1.rs index 7b19e97..737fda3 100644 --- a/src/backends/tasoller_v1.rs +++ b/src/backends/tasoller_v1.rs @@ -54,23 +54,17 @@ pub const OUTPUT_MEMORY_SIZE: usize = 240; #[cfg(any(chuni, amdaemon))] #[inline(always)] pub fn jvs_poll(input: &[u8]) -> (u8, u8) { - let mut opbtn = 0; - let mut beams = 0; - - if (input[3] & 8) != 0 { - opbtn |= 1; - } - - if (input[3] & 4) != 0 { - opbtn |= 2; - } - - beams |= (input[3] >> 5) & 1; - beams |= (2 * (input[3] >> 4)) & 2; - beams |= (4 * (input[3] >> 7)) & 4; - beams |= (8 * (input[3] >> 6)) & 8; - beams |= (16 * (input[4] >> 1)) & 16; - beams |= (32 * input[4]) & 32; + // FN1 | FN2 + let opbtn = input[3] >> 3 & 1 + | input[3] >> 1 & 2; + + // IR1-6 in order + let beams = input[3] >> 5 & 1 + | input[3] >> 3 & 2 + | input[3] >> 5 & 4 + | input[3] >> 3 & 8 + | input[4] << 3 & 16 + | input[4] << 5 & 32; (opbtn, beams) }