funny bit shifts

This commit is contained in:
beerpsi 2023-12-29 00:23:09 +07:00
parent eb579f932f
commit bf59f9acb9

View File

@ -54,23 +54,17 @@ pub const OUTPUT_MEMORY_SIZE: usize = 240;
#[cfg(any(chuni, amdaemon))] #[cfg(any(chuni, amdaemon))]
#[inline(always)] #[inline(always)]
pub fn jvs_poll(input: &[u8]) -> (u8, u8) { pub fn jvs_poll(input: &[u8]) -> (u8, u8) {
let mut opbtn = 0; // FN1 | FN2
let mut beams = 0; let opbtn = input[3] >> 3 & 1
| input[3] >> 1 & 2;
if (input[3] & 8) != 0 { // IR1-6 in order
opbtn |= 1; let beams = input[3] >> 5 & 1
} | input[3] >> 3 & 2
| input[3] >> 5 & 4
if (input[3] & 4) != 0 { | input[3] >> 3 & 8
opbtn |= 2; | input[4] << 3 & 16
} | input[4] << 5 & 32;
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;
(opbtn, beams) (opbtn, beams)
} }