fix: correct binary arithmetic bug in forestry op translation

This commit is contained in:
Nat 2024-12-11 10:42:24 -08:00
parent 89c9d273e2
commit ba5a1b6256
1 changed files with 6 additions and 1 deletions

View File

@ -88,7 +88,12 @@ fn parse_forestry_op(tokens: &Vec<&str>, opcode: u16) -> Result<u16, String> {
} else if relative_y > 15 || relative_y < -16 {
Err(format!("Cannot reach cell at {relative_y} along the Y-axis; trees may only access cells in the range of -16 to 15"))
} else {
Ok(opcode<<11 | stack<<10 | (relative_x as u16)<<5 | (relative_y as u16))
Ok(
opcode<<11
| stack<<10
| ((relative_x as u16)<<5) & 0b11111
| (relative_y as u16) & 0b11111
)
}
}