fixed bug with color layering issue
CI / Lint and Test (pull_request) Successful in 44s
CI / Version Check (pull_request) Failing after 3s

This commit is contained in:
2026-03-31 12:18:53 +02:00
parent 69d0269270
commit 7c8ecda29a
11 changed files with 126 additions and 51 deletions
+61 -21
View File
@@ -77,16 +77,36 @@ pub fn parse(data: &[u8]) -> Result<Vec<StitchCommand>, Error> {
/// Standard bit layout for dx across bytes b0, b1, b2.
fn decode_dx(b0: u8, b1: u8, b2: u8) -> i16 {
let mut x: i16 = 0;
if b0 & 0x01 != 0 { x += 1; }
if b0 & 0x02 != 0 { x -= 1; }
if b0 & 0x04 != 0 { x += 9; }
if b0 & 0x08 != 0 { x -= 9; }
if b1 & 0x01 != 0 { x += 3; }
if b1 & 0x02 != 0 { x -= 3; }
if b1 & 0x04 != 0 { x += 27; }
if b1 & 0x08 != 0 { x -= 27; }
if b2 & 0x04 != 0 { x += 81; }
if b2 & 0x08 != 0 { x -= 81; }
if b0 & 0x01 != 0 {
x += 1;
}
if b0 & 0x02 != 0 {
x -= 1;
}
if b0 & 0x04 != 0 {
x += 9;
}
if b0 & 0x08 != 0 {
x -= 9;
}
if b1 & 0x01 != 0 {
x += 3;
}
if b1 & 0x02 != 0 {
x -= 3;
}
if b1 & 0x04 != 0 {
x += 27;
}
if b1 & 0x08 != 0 {
x -= 27;
}
if b2 & 0x04 != 0 {
x += 81;
}
if b2 & 0x08 != 0 {
x -= 81;
}
x
}
@@ -94,16 +114,36 @@ fn decode_dx(b0: u8, b1: u8, b2: u8) -> i16 {
/// Standard bit layout for dy across bytes b0, b1, b2.
fn decode_dy(b0: u8, b1: u8, b2: u8) -> i16 {
let mut y: i16 = 0;
if b0 & 0x80 != 0 { y += 1; }
if b0 & 0x40 != 0 { y -= 1; }
if b0 & 0x20 != 0 { y += 9; }
if b0 & 0x10 != 0 { y -= 9; }
if b1 & 0x80 != 0 { y += 3; }
if b1 & 0x40 != 0 { y -= 3; }
if b1 & 0x20 != 0 { y += 27; }
if b1 & 0x10 != 0 { y -= 27; }
if b2 & 0x20 != 0 { y += 81; }
if b2 & 0x10 != 0 { y -= 81; }
if b0 & 0x80 != 0 {
y += 1;
}
if b0 & 0x40 != 0 {
y -= 1;
}
if b0 & 0x20 != 0 {
y += 9;
}
if b0 & 0x10 != 0 {
y -= 9;
}
if b1 & 0x80 != 0 {
y += 3;
}
if b1 & 0x40 != 0 {
y -= 3;
}
if b1 & 0x20 != 0 {
y += 27;
}
if b1 & 0x10 != 0 {
y -= 27;
}
if b2 & 0x20 != 0 {
y += 81;
}
if b2 & 0x10 != 0 {
y -= 81;
}
// DST Y axis is inverted (positive = up in machine coords, down in screen coords)
-y
}
@@ -166,7 +206,7 @@ mod tests {
assert_eq!(decode_dx(0x04, 0x00, 0x00), 9);
assert_eq!(decode_dx(0x00, 0x04, 0x00), 27);
assert_eq!(decode_dx(0x00, 0x00, 0x04), 81);
assert_eq!(decode_dx(0x05, 0x05, 0x04), 1 + 9 + 27 + 81); // 118
assert_eq!(decode_dx(0x05, 0x05, 0x04), 1 + 9 + 3 + 27 + 81); // 121
}
#[test]