diff --git a/crates/ericrfb/src/codec/tight.rs b/crates/ericrfb/src/codec/tight.rs index 9c857b5..6dbc434 100644 --- a/crates/ericrfb/src/codec/tight.rs +++ b/crates/ericrfb/src/codec/tight.rs @@ -171,8 +171,8 @@ pub fn decode_tight( ))); } - let packed_colors = read_u8(r)?; palette_2 = Some(if let Some(pal) = palette_for_selector(pal_selector) { + let packed_colors = read_u8(r)?; match pal_selector { 1 => [ pal[(packed_colors >> 1) as usize], @@ -189,13 +189,10 @@ pub fn decode_tight( _ => [packed_colors >> 4, packed_colors & 0x0F], } } else { - // Default: read 2 separate color bytes - // Actually for selector 0 the Java code reads 2 bytes: - // nArray[0] = this.K[aw2.w.read()]; nArray[1] = this.K[aw2.w.read()]; - // But packed_colors was already read as 1 byte. The protocol - // for selector 0 reads colors differently. Since this path is rare - // and we've already read the packed byte, treat high/low nibbles. - [packed_colors >> 4, packed_colors & 0x0F] + // Selector 0: two separate RGB332 color bytes (line 421-422) + let c0 = read_u8(r)?; + let c1 = read_u8(r)?; + [c0, c1] }); row_bytes = (rw as usize).div_ceil(8);