diff --git a/Source/Project64/N64 System/Mips/Dma.cpp b/Source/Project64/N64 System/Mips/Dma.cpp index 9ab9ea30d..c82b1a6df 100644 --- a/Source/Project64/N64 System/Mips/Dma.cpp +++ b/Source/Project64/N64 System/Mips/Dma.cpp @@ -213,6 +213,18 @@ void CDMA::PI_DMA_WRITE() *(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3)); } } + else if (g_Reg->PI_CART_ADDR_REG >= g_Rom->GetRomSize()) + { + DWORD cart = g_Reg->PI_CART_ADDR_REG - g_Rom->GetRomSize(); + while (cart >= g_Rom->GetRomSize()) + { + cart -= g_Rom->GetRomSize(); + } + for (i = 0; i < PI_WR_LEN_REG; i++) + { + *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((cart + i) ^ 3)); + } + } else { DWORD Len; diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index eb4ffbcd8..cb64a4c78 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -2622,7 +2622,15 @@ bool CMipsMemoryVM::LW_NonMemory(DWORD PAddr, DWORD* Value) { g_System->m_SaveUsing = SaveChip_FlashRam; } - if (g_System->m_SaveUsing != SaveChip_FlashRam) + if (g_System->m_SaveUsing == SaveChip_Sram) + { + //Load Sram + BYTE tmp[4] = ""; + DmaFromSram(tmp, PAddr - 0x08000000, 4); + *Value = tmp[3] << 24 | tmp[2] << 16 | tmp[1] << 8 | tmp[0]; + return true; + } + else if (g_System->m_SaveUsing != SaveChip_FlashRam) { *Value = PAddr & 0xFFFF; *Value = (*Value << 16) | *Value; @@ -3321,6 +3329,17 @@ bool CMipsMemoryVM::SW_NonMemory(DWORD PAddr, DWORD Value) } break; case 0x08000000: + if (g_System->m_SaveUsing == SaveChip_Sram) + { + //Store Sram + BYTE tmp[4] = ""; + tmp[0] = 0xFF & (Value); + tmp[1] = 0xFF & (Value >> 8); + tmp[2] = 0xFF & (Value >> 16); + tmp[3] = 0xFF & (Value >> 24); + DmaFromSram(tmp, PAddr - 0x08000000, 4); + return true; + } if (PAddr != 0x08010000) { return false;