Skip to content

Commit

Permalink
ensure conflated tilemaps output actual size in log
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Mar 3, 2020
1 parent 18480e9 commit aa269d0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/cmd/asm/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ where
}
}
common::output_to_file(&file_name, output.as_bytes(), &asm_args.sd_image)?;
let size = v.size_in_bytes()?;
let size = v.size_in_bytes(conflate)?;
// Warn if we're getting close to t
info!("Resource {} has size {}", v.id(), size);
if size >= (LOW_RAM_SIZE as f64 * LOW_RAM_WARN_THRESHOLD) as usize
&& asm_args.format != AsmFormat::Bin
{
warn!("Resource {} has a size of {} bytes, which approaches or exceeds the size of Low RAM ({}) bytes. Consider outputting as .BIN instead.", v.id(), size, LOW_RAM_SIZE);
}
assembled_size += v.size_in_bytes()?;
assembled_size += v.size_in_bytes(conflate)?;
}
Ok(assembled_size)
}
Expand Down
2 changes: 1 addition & 1 deletion vera/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait Assemblable {
fn id(&self) -> &str;

/// Size, in bytes, of assembled asset
fn size_in_bytes(&self) -> Result<usize, Error>;
fn size_in_bytes(&self, conflated_size: bool) -> Result<usize, Error>;
}

/// Enum for variations ToAsm implementors can assemble to
Expand Down
2 changes: 1 addition & 1 deletion vera/src/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl<'a> Assemblable for VeraBitmap<'a> {
&self.id
}

fn size_in_bytes(&self) -> Result<usize, Error> {
fn size_in_bytes(&self, _conflated: bool) -> Result<usize, Error> {
match self.imageset {
Some(i) => Ok(i.size()),
None => Err(ErrorKind::BitmapNoImageSet(format!("{}", self.id)).into()),
Expand Down
2 changes: 1 addition & 1 deletion vera/src/imageset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ impl Assemblable for VeraImageSet {
&self.id
}

fn size_in_bytes(&self) -> Result<usize, Error> {
fn size_in_bytes(&self, _conflated: bool) -> Result<usize, Error> {
Ok(self.size())
}

Expand Down
2 changes: 1 addition & 1 deletion vera/src/palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Assemblable for VeraPalette {
&self.id
}

fn size_in_bytes(&self) -> Result<usize, Error> {
fn size_in_bytes(&self, _conflated: bool) -> Result<usize, Error> {
Ok(self.size())
}

Expand Down
2 changes: 1 addition & 1 deletion vera/src/sprite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<'a> Assemblable for VeraSprite<'a> {
&self.id
}

fn size_in_bytes(&self) -> Result<usize, Error> {
fn size_in_bytes(&self, _conflated: bool) -> Result<usize, Error> {
match self.imageset {
Some(i) => Ok(i.size()),
None => Err(ErrorKind::SpriteNoImageSet(format!("{}", self.id)).into()),
Expand Down
10 changes: 7 additions & 3 deletions vera/src/tilemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Assemblable for VeraTileMapEntry {
"0"
}

fn size_in_bytes(&self) -> Result<usize, Error> {
fn size_in_bytes(&self, _conflated: bool) -> Result<usize, Error> {
Ok(2)
}

Expand Down Expand Up @@ -480,8 +480,12 @@ impl Assemblable for VeraTileMap {
&self.id
}

fn size_in_bytes(&self) -> Result<usize, Error> {
Ok(self.size())
fn size_in_bytes(&self, conflated: bool) -> Result<usize, Error> {
if !conflated {
Ok(self.size())
} else {
Ok(self.map_width.val_as_u32() as usize * self.map_height.val_as_u32() as usize * 2)
}
}

fn assemble(&self) -> Result<AssembledPrimitive, Error> {
Expand Down

0 comments on commit aa269d0

Please sign in to comment.