- add autofix the device capacity value in broken header (fix bug [#1353]);
This commit is contained in:
mtabachenko 2013-12-02 12:49:36 +00:00
parent d2ed4ca30e
commit 702879c848
1 changed files with 16 additions and 0 deletions

View File

@ -399,6 +399,22 @@ bool GameInfo::loadROM(std::string fname, u32 type)
if (res)
{
cardSize = (128 * 1024) << header.cardSize;
if (cardSize < romsize)
{
msgbox->warn("The ROM header is invalid.\nThe device size has been increased to allow for the provided file size.\n");
for (u32 i = header.cardSize; i < 0xF; i++)
{
if (((128 * 1024) << i) >= romsize)
{
header.cardSize = i;
cardSize = (128 * 1024) << i;
break;
}
}
}
mask = (cardSize - 1);
mask |= (mask >>1);
mask |= (mask >>2);