From 6dc4d620eeb0027398f4ec3b8608f0267bac9485 Mon Sep 17 00:00:00 2001 From: jaby Date: Fri, 3 Feb 2023 13:36:49 +0100 Subject: [PATCH] Smol fix --- src/Tools/psxcdgen_ex/src/types/overlay/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs b/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs index da453ceb..c8cbe09a 100644 --- a/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/overlay/mod.rs @@ -30,10 +30,14 @@ impl LBAEntry { pub fn write_entry(&mut self, lba: u16, mut size_bytes: usize) -> Result<(), Error> { const WORD_SIZE:usize = std::mem::size_of::(); + if self.lba != 0 || self.size_words != 0 { + return Err(Error::from_str("LBA Entry will overwrite non-zero value!\nIs no space allocated for the LBA Entries?")); + } + size_bytes = (size_bytes + (WORD_SIZE - 1))/WORD_SIZE; if (size_bytes as u16) as usize != size_bytes { - return Err(Error::from_text(format!("{} words can not be incoded into 16bit", size_bytes))); + return Err(Error::from_text(format!("{} words can not be encoded into 16bit", size_bytes))); } let lba = lba.to_le_bytes();