more anti-crash.

don't unmap VRAM in cases of overlaps. fixes NSMB minigames, for now.
This commit is contained in:
StapleButter 2017-02-01 17:05:12 +01:00
parent 6d2092a106
commit 03c1a9cbc8
3 changed files with 37 additions and 22 deletions

53
GPU.cpp
View File

@ -177,7 +177,7 @@ void MapVRAM_AB(u32 bank, u8 cnt)
break;
}
if (vrammap)
if (vrammap && *vrammap == vram)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
@ -273,7 +273,7 @@ void MapVRAM_CD(u32 bank, u8 cnt)
break;
}
if (vrammap)
if (vrammap && *vrammap == vram)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
@ -378,12 +378,16 @@ void MapVRAM_E(u32 bank, u8 cnt)
break;
}
if (vrammap)
if (vrammap && *vrammap == vram)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
}
else if (vrammap) vrammap += 4;
if (vrammap && *vrammap == vram)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
@ -485,14 +489,14 @@ void MapVRAM_FG(u32 bank, u8 cnt)
if (vrammap)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap = NULL;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap = NULL;
}
}
@ -573,14 +577,23 @@ void MapVRAM_H(u32 bank, u8 cnt)
break;
}
if (vrammap)
if (vrammap && *vrammap == vram)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
} else if (vrammap) vrammap += 2;
if (vrammap && *vrammap == vram)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
} else if (vrammap) vrammap += 2;
if (vrammap && *vrammap == vram)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
} else if (vrammap) vrammap += 2;
if (vrammap && *vrammap == vram)
{
*vrammap++ = NULL;
*vrammap = NULL;
}
@ -658,14 +671,14 @@ void MapVRAM_I(u32 bank, u8 cnt)
if (vrammap)
{
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap++ = NULL;
*vrammap = NULL;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
if (*vrammap == vram) *vrammap = NULL;
}
}

View File

@ -484,6 +484,7 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
tilenum <<= 5;
ytilefactor <<= 5;
u8* pixels = (Num ? GPU::VRAM_BOBJ : GPU::VRAM_AOBJ)[tilenum >> 14];
if (!pixels) return;
pixels += (tilenum & 0x3FFF);
u16* pal = (u16*)&GPU::Palette[Num ? 0x600 : 0x200];
@ -553,6 +554,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
// 16-color
tilenum <<= 5;
u8* pixels = (Num ? GPU::VRAM_BOBJ : GPU::VRAM_AOBJ)[tilenum >> 14];
if (!pixels) return;
pixels += (tilenum & 0x3FFF);
pixels += ((ypos & 0x7) << 2);

View File

@ -86,7 +86,7 @@
"NDS.h"
"SPI.h"
1485873275 source:c:\documents\sources\melonds\gpu2d.cpp
1485906742 source:c:\documents\sources\melonds\gpu2d.cpp
<stdio.h>
<string.h>
"NDS.h"
@ -117,7 +117,7 @@
1484698068 c:\documents\sources\melonds\dma.h
"types.h"
1485831589 source:c:\documents\sources\melonds\gpu.cpp
1485964826 source:c:\documents\sources\melonds\gpu.cpp
<stdio.h>
<string.h>
"NDS.h"