Round up the rom size to the nearest power of two before mirroring.

This commit is contained in:
skidau 2015-05-01 13:27:07 +00:00
parent d505399566
commit def2c61993
3 changed files with 15 additions and 7 deletions

View File

@ -1764,11 +1764,18 @@ int CPULoadRomData(const char *data, int size)
void doMirroring (bool b) void doMirroring (bool b)
{ {
u32 mirroredRomSize = (((romSize)>>20) & 0x3F)<<20; int romSizeRounded = romSize;
u32 mirroredRomAddress = romSize; romSizeRounded--;
romSizeRounded |= romSizeRounded >> 1;
romSizeRounded |= romSizeRounded >> 2;
romSizeRounded |= romSizeRounded >> 4;
romSizeRounded |= romSizeRounded >> 8;
romSizeRounded |= romSizeRounded >> 16;
romSizeRounded++;
u32 mirroredRomSize = (((romSizeRounded) >> 20) & 0x3F) << 20;
u32 mirroredRomAddress = mirroredRomSize;
if ((mirroredRomSize <=0x800000) && (b)) if ((mirroredRomSize <=0x800000) && (b))
{ {
mirroredRomAddress = mirroredRomSize;
if (mirroredRomSize==0) if (mirroredRomSize==0)
mirroredRomSize=0x100000; mirroredRomSize=0x100000;
while (mirroredRomAddress<0x01000000) while (mirroredRomAddress<0x01000000)

View File

@ -180,7 +180,7 @@ enum VIDEO_SIZE{
u32 throttleLastTime = 0; u32 throttleLastTime = 0;
bool pauseNextFrame = false; bool pauseNextFrame = false;
int sdlMirroringEnable = 0; int sdlMirroringEnable = 1;
static int ignore_first_resize_event = 0; static int ignore_first_resize_event = 0;

View File

@ -207,20 +207,21 @@ void GameArea::LoadGame(const wxString &name)
flashSetSize(fsz); flashSetSize(fsz);
cpuSaveType = cfg->Read(wxT("saveType"), cpuSaveType); cpuSaveType = cfg->Read(wxT("saveType"), cpuSaveType);
if(cpuSaveType < 0 || cpuSaveType > 5) if(cpuSaveType < 0 || cpuSaveType > 5)
cpuSaveType = cpuSaveType; cpuSaveType = 0;
if (cpuSaveType == 0) if (cpuSaveType == 0)
utilGBAFindSave(rom_size); utilGBAFindSave(rom_size);
else else
saveType = cpuSaveType; saveType = cpuSaveType;
mirroringEnable = cfg->Read(wxT("mirroringEnabled"), (long)0); mirroringEnable = cfg->Read(wxT("mirroringEnabled"), (long)1);
cfg->SetPath(wxT("/")); cfg->SetPath(wxT("/"));
} else { } else {
rtcEnable(rtcEnabled); rtcEnable(rtcEnabled);
flashSetSize(0x10000 << winFlashSize); flashSetSize(0x10000 << winFlashSize);
cpuSaveType = cpuSaveType; if (cpuSaveType < 0 || cpuSaveType > 5)
cpuSaveType = 0;
if (cpuSaveType == 0) if (cpuSaveType == 0)
utilGBAFindSave(rom_size); utilGBAFindSave(rom_size);
else else