NES: show more informative error logs for certain INES header screwballs

This commit is contained in:
goyuken 2014-11-27 18:03:00 +00:00
parent 96b626434f
commit 6d04f9089a
1 changed files with 10 additions and 4 deletions

View File

@ -721,8 +721,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
LoadReport.Flush();
CoreComm.RomStatusDetails = LoadReport.ToString();
//create the board's rom and vrom
if (iNesHeaderInfo != null)
@ -734,10 +732,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
board.VROM = new byte[choice.chr_size * 1024];
int vrom_offset = iNesHeaderInfo.prg_size * 1024;
// if file isn't long enough for VROM, truncate
Array.Copy(file, 16 + vrom_offset, board.VROM, 0, Math.Min(board.VROM.Length, file.Length - 16 - vrom_offset));
// if file isn't long enough for VROM, truncate
int vrom_copy_size = Math.Min(board.VROM.Length, file.Length - 16 - vrom_offset);
Array.Copy(file, 16 + vrom_offset, board.VROM, 0, vrom_copy_size);
if (vrom_copy_size < board.VROM.Length)
LoadWriteLine("Less than the expected VROM was found in the file: {0} < {1}", vrom_copy_size, board.VROM.Length);
}
if (choice.prg_size != iNesHeaderInfo.prg_size || choice.chr_size != iNesHeaderInfo.chr_size)
LoadWriteLine("Warning: Detected choice has different filesizes than the INES header!");
}
else
{
@ -745,6 +748,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
board.VROM = unif.CHR;
}
LoadReport.Flush();
CoreComm.RomStatusDetails = LoadReport.ToString();
// IF YOU DO ANYTHING AT ALL BELOW THIS LINE, MAKE SURE THE APPROPRIATE CHANGE IS MADE TO FDS (if applicable)
//create the vram and wram if necessary