diff --git a/src/reskit/level/system.rs b/src/reskit/level/system.rs index 66061fd..26a8040 100644 --- a/src/reskit/level/system.rs +++ b/src/reskit/level/system.rs @@ -76,8 +76,9 @@ pub fn get_tilemap( tilemap: &TiledTilemap ) -> Result, Box> let layer_a: Option<&Layer> = tilemap.layers.iter().find( | layer | matches!( layer, Layer::Tile { system_plane: SystemPlane::MdPlaneA, tiles: _ } ) ); // Each entry in a `--system md` tilemap is 16 bits - let mut nametable: Vec = vec![ 0; tilemap.width * tilemap.height ]; + let mut total_nametable: Vec = Vec::new(); + let mut nametable: Vec = vec![ 0; tilemap.width * tilemap.height ]; if let Some( layer_b ) = layer_b { let layer_b = match layer_b { Layer::Tile { system_plane: _, tiles } => tiles, @@ -103,9 +104,11 @@ pub fn get_tilemap( tilemap: &TiledTilemap ) -> Result, Box> } } } + total_nametable.extend( nametable.iter() ); // Just do the same for layer a // Copy pasted because i'm lazy and tired + let mut nametable: Vec = vec![ 0; tilemap.width * tilemap.height ]; if let Some( layer_a ) = layer_a { let layer_a = match layer_a { Layer::Tile { system_plane: _, tiles } => tiles, @@ -131,11 +134,12 @@ pub fn get_tilemap( tilemap: &TiledTilemap ) -> Result, Box> } } } + total_nametable.extend( nametable.iter() ); // Convert the u16's to a series of u8 data let mut result: Vec = Vec::new(); - for i in 0..nametable.len() { - let bytes = nametable[ i ].to_be_bytes(); + for i in 0..total_nametable.len() { + let bytes = total_nametable[ i ].to_be_bytes(); for i in 0..2 { result.push( bytes[ i ] ); }