(data: &[u8], offset: i32, length: u16, magic_rlew_word: &[u8; 2])
| 523 | } |
| 524 | |
| 525 | fn get_plane(data: &[u8], offset: i32, length: u16, magic_rlew_word: &[u8; 2]) -> [[u16; 64]; 64] { |
| 526 | let plane_start = offset as usize; |
| 527 | let plane_end = plane_start + length as usize; |
| 528 | let decarmackized = carmack_decompress(&data[plane_start..plane_end]); |
| 529 | let bytes = rlew_decompress(&decarmackized[4..], magic_rlew_word); |
| 530 | let mut bytes = bytes |
| 531 | .chunks_exact(2) |
| 532 | .map(|word| u16::from_le_bytes(word.try_into().unwrap())); |
| 533 | let mut result = [[0; MAP_HEIGHT]; MAP_WIDTH]; |
| 534 | for y in 0..MAP_HEIGHT { |
| 535 | for x in result.iter_mut().take(MAP_WIDTH) { |
| 536 | x[y] = bytes.next().unwrap(); |
| 537 | } |
| 538 | } |
| 539 | result |
| 540 | } |
| 541 | |
| 542 | fn parse_map_data<P: AsRef<Path>>(path: P, meta: MapHead) -> Vec<Map> { |
| 543 | let raw_data = fs::read(path).expect("could not read GAMEMAPS file"); |
no test coverage detected