Skip to content

Commit

Permalink
Fixed check for output file size
Browse files Browse the repository at this point in the history
  • Loading branch information
sdsnatcher73 committed Jan 17, 2024
1 parent 2c87f82 commit b445d44
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions prepare_msxpico_roms/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ");
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b445d44

Please sign in to comment.