NES: fix crash when loading UNIF with incomplete gamedb entry

This commit is contained in:
goyuken 2012-10-24 23:30:46 +00:00
parent ff08e1f83e
commit 57349cdbcb
1 changed files with 16 additions and 4 deletions

View File

@ -591,10 +591,22 @@ namespace BizHawk.Emulation.Consoles.Nintendo
origin = EDetectionOrigin.GameDB;
LoadWriteLine("Chose board from bizhawk gamedb: " + choice.board_type);
//gamedb entries that dont specify prg/chr sizes can infer it from the ines header
if (choice.prg_size == -1) choice.prg_size = iNesHeaderInfo.prg_size;
if (choice.chr_size == -1) choice.chr_size = iNesHeaderInfo.chr_size;
if (choice.vram_size == -1) choice.vram_size = iNesHeaderInfo.vram_size;
if (choice.wram_size == -1) choice.wram_size = iNesHeaderInfo.wram_size;
if (iNesHeaderInfo != null)
{
if (choice.prg_size == -1) choice.prg_size = iNesHeaderInfo.prg_size;
if (choice.chr_size == -1) choice.chr_size = iNesHeaderInfo.chr_size;
if (choice.vram_size == -1) choice.vram_size = iNesHeaderInfo.vram_size;
if (choice.wram_size == -1) choice.wram_size = iNesHeaderInfo.wram_size;
}
else if (unif != null)
{
if (choice.prg_size == -1) choice.prg_size = unif.GetCartInfo().prg_size;
if (choice.chr_size == -1) choice.chr_size = unif.GetCartInfo().chr_size;
// unif has no wram\vram sizes; hope the board impl can figure it out...
if (choice.vram_size == -1) choice.vram_size = 0;
if (choice.wram_size == -1) choice.wram_size = 0;
}
}
}
else