NES: truncate if a iNES file's supposed VROM size is longer than the leftover length of the iNES file. seems to fix some hacks\translations

This commit is contained in:
goyuken 2014-01-21 22:29:51 +00:00
parent 3889d687d1
commit 8bf8213a7d
1 changed files with 3 additions and 1 deletions

View File

@ -749,7 +749,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
board.VROM = new byte[choice.chr_size * 1024];
int vrom_offset = iNesHeaderInfo.prg_size * 1024;
Array.Copy(file, 16 + vrom_offset, board.VROM, 0, board.VROM.Length);
// 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));
}
}
else