From b445d442daecf4760bf1af10b7da51beab2c644c Mon Sep 17 00:00:00 2001 From: Peter Hanraets Date: Wed, 17 Jan 2024 11:24:48 +0100 Subject: [PATCH] Fixed check for output file size --- prepare_msxpico_roms/Program.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/prepare_msxpico_roms/Program.cs b/prepare_msxpico_roms/Program.cs index a98cc31..d0751dc 100644 --- a/prepare_msxpico_roms/Program.cs +++ b/prepare_msxpico_roms/Program.cs @@ -82,7 +82,8 @@ static void Main(string[] args) FileInfo[] romFilesInfo = romFilesDirInfo.GetFiles("*.rom"); FileStream concatOutputFileStream = File.Open(Path.Combine(romFilesDirName, concatOutputFileName), FileMode.OpenOrCreate & FileMode.Truncate); - + concatOutputFileStream.SetLength(0); + byte[] initConcatOutputFile; initConcatOutputFile = Encoding.ASCII.GetBytes("MSXPICO_ROM_CAT "); @@ -98,7 +99,7 @@ static void Main(string[] args) string romGenerationString = romFileInfo.Name.Split('.')[0].Split('_')[2]; romHeader.size = (UInt32) romFileInfo.Length; - while (concatOutputSize + romHeader.size + (2 * 96) < (7 * 1024 * 1024)) + if (concatOutputSize + romHeader.size + (2 * 96) < (7 * 1024 * 1024)) { switch (romMapperString) { @@ -224,6 +225,10 @@ static void Main(string[] args) concatOutputSize += (romHeader.size + 96); } + else + { + Console.WriteLine("ROM file " + romHeader.name + " skipped because resulting outputfile would exceed 7MB."); + } } // Write a terminator header so pico knows he is finished;