mount empty memory for tex and tex palette memory when slots are unmapped. provide diagnostics when unmapped slots are referenced by textures.
This commit is contained in:
parent
92fb5e378f
commit
c3e28a662f
|
@ -24,7 +24,7 @@ struct ALIGN(16) ARM9_struct {
|
|||
|
||||
u8 *textureSlotAddr[4];
|
||||
|
||||
u8 *blank_memory[0x20000];
|
||||
u8 blank_memory[0x20000];
|
||||
};
|
||||
|
||||
extern ARM9_struct ARM9Mem;
|
||||
|
|
|
@ -461,18 +461,10 @@ void MMU_clearMem()
|
|||
osdA->setOffset(MainScreen.offset);
|
||||
osdB->setOffset(SubScreen.offset);
|
||||
|
||||
/* setup the texture slot pointers */
|
||||
#if 0
|
||||
ARM9Mem.textureSlotAddr[0] = ARM9Mem.blank_memory;
|
||||
ARM9Mem.textureSlotAddr[1] = ARM9Mem.blank_memory;
|
||||
ARM9Mem.textureSlotAddr[2] = ARM9Mem.blank_memory;
|
||||
ARM9Mem.textureSlotAddr[3] = ARM9Mem.blank_memory;
|
||||
#else
|
||||
ARM9Mem.textureSlotAddr[0] = &ARM9Mem.ARM9_LCD[0x20000 * 0];
|
||||
ARM9Mem.textureSlotAddr[1] = &ARM9Mem.ARM9_LCD[0x20000 * 1];
|
||||
ARM9Mem.textureSlotAddr[2] = &ARM9Mem.ARM9_LCD[0x20000 * 2];
|
||||
ARM9Mem.textureSlotAddr[3] = &ARM9Mem.ARM9_LCD[0x20000 * 3];
|
||||
#endif
|
||||
for(int i=0;i<4;i++)
|
||||
ARM9Mem.textureSlotAddr[i] = ARM9Mem.blank_memory;
|
||||
for(int i=0;i<6;i++)
|
||||
ARM9Mem.texPalSlot[i] = ARM9Mem.blank_memory;
|
||||
|
||||
LCDdst[0] = ARM9Mem.ARM9_LCD; // Bank A
|
||||
LCDdst[1] = ARM9Mem.ARM9_LCD + 0x20000; // Bank B
|
||||
|
@ -582,6 +574,21 @@ static inline void MMU_VRAMmapControl(u8 block, u8 VRAMBankCnt)
|
|||
u32 vram_map_addr = 0xFFFFFFFF;
|
||||
u8 *LCD_addr = LCDdst[block];
|
||||
|
||||
//unmap texmem
|
||||
for(int i=0;i<4;i++)
|
||||
if(ARM9Mem.textureSlotAddr[i] == LCD_addr)
|
||||
ARM9Mem.textureSlotAddr[i] = ARM9Mem.blank_memory;
|
||||
|
||||
//unmap texpal mem. This is not a straightforward way to do it,
|
||||
//but it is the only place we have this information stored.
|
||||
for(int i=0;i<4;i++)
|
||||
if(ARM9Mem.texPalSlot[i] == LCD_addr + 0x4000*i || ARM9Mem.texPalSlot[i] == LCD_addr)
|
||||
ARM9Mem.texPalSlot[i] = ARM9Mem.blank_memory;
|
||||
for(int i=4;i<6;i++)
|
||||
if(ARM9Mem.texPalSlot[i] == LCD_addr)
|
||||
ARM9Mem.texPalSlot[i] = ARM9Mem.blank_memory;
|
||||
|
||||
|
||||
switch (VRAMBankCnt & 0x07)
|
||||
{
|
||||
case 1:
|
||||
|
|
|
@ -147,16 +147,9 @@ static MemSpan MemSpan_TexMem(u32 ofs, u32 len)
|
|||
ofs += curr.len;
|
||||
currofs += curr.len;
|
||||
u8* ptr = ARM9Mem.textureSlotAddr[slot];
|
||||
//this is just a guess. what happens if there is a gap in the mapping? lets put zeros
|
||||
if(ptr == NULL) {
|
||||
PROGINFO("Texture gap in memory mapping. Trying to accomodate.\n");
|
||||
static u8* emptyTextureSlot = 0;
|
||||
if(emptyTextureSlot == NULL) {
|
||||
emptyTextureSlot = new u8[128*1024];
|
||||
memset(emptyTextureSlot,0,128*1024);
|
||||
}
|
||||
ptr = emptyTextureSlot;
|
||||
}
|
||||
|
||||
if(ptr == ARM9Mem.blank_memory)
|
||||
PROGINFO("Tried to reference unmapped texture memory: slot %d\n",slot);
|
||||
|
||||
curr.ptr = ptr + curr.start;
|
||||
}
|
||||
|
@ -185,16 +178,10 @@ static MemSpan MemSpan_TexPalette(u32 ofs, u32 len)
|
|||
//here is an actual test case of bank spanning
|
||||
currofs += curr.len;
|
||||
u8* ptr = ARM9Mem.texPalSlot[slot];
|
||||
//this is just a guess. what happens if there is a gap in the mapping? lets put zeros
|
||||
if(ptr == NULL) {
|
||||
PROGINFO("Texture palette gap in memory mapping. Trying to accomodate.\n");
|
||||
static u8* emptyTexturePalette = 0;
|
||||
if(emptyTexturePalette == NULL) {
|
||||
emptyTexturePalette = new u8[16*1024];
|
||||
memset(emptyTexturePalette,0,16*1024);
|
||||
}
|
||||
ptr = emptyTexturePalette;
|
||||
}
|
||||
|
||||
if(ptr == ARM9Mem.blank_memory)
|
||||
PROGINFO("Tried to reference unmapped texture palette memory: 16k slot #%d\n",slot);
|
||||
|
||||
curr.ptr = ptr + curr.start;
|
||||
}
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue