Add number of metatiles to dmapack structure
parent
93558cf3c8
commit
6ef2a1eb74
|
@ -109,11 +109,12 @@ pub fn get_tiles( tilemap: &TiledTilemap ) -> Result<(Vec<u8>, Vec<u8>), Box<dyn
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the .map file containing metatile definitions, as well as B and A metatile-based maps.
|
||||
* Get the .map file containing `dmapack`-formatted metatiles, as well as B and A metatile-based maps.
|
||||
*
|
||||
* Format:
|
||||
* <<< HEADER >>>
|
||||
* 2 bytes: The offset to the instances table
|
||||
* 2 bytes: The number of metatiles in the `dmapack` structure
|
||||
* For each metatile:
|
||||
* 2 bytes: Metatile width
|
||||
* 2 bytes: Metatile height
|
||||
|
@ -136,7 +137,7 @@ pub fn get_metatile_maps( tilemap: &TiledTilemap ) -> Result<Vec<u8>, Box<dyn Er
|
|||
print_info( &format!( "number of metatiles: {}", tilemap.metatiles.len() ) );
|
||||
|
||||
// Assemble header of offsets
|
||||
let header_offset = ( tilemap.metatiles.len() * 6 ) + 2;
|
||||
let header_offset = ( tilemap.metatiles.len() * 6 ) + 4;
|
||||
let mut header: Vec<u8> = vec![];
|
||||
|
||||
// Get offsets for each bucket
|
||||
|
@ -246,6 +247,8 @@ pub fn get_metatile_maps( tilemap: &TiledTilemap ) -> Result<Vec<u8>, Box<dyn Er
|
|||
let mut result: Vec<u8> = vec![];
|
||||
let offset_to_instances = header_offset + definitions.len();
|
||||
result.extend( ( offset_to_instances as u16 ).to_be_bytes() );
|
||||
let num_metatiles: u16 = tilemap.metatiles.len() as u16;
|
||||
result.extend( num_metatiles.to_be_bytes() );
|
||||
result.extend( header );
|
||||
result.extend( definitions );
|
||||
result.extend( instances );
|
||||
|
|
Loading…
Reference in New Issue