| 247 | } |
| 248 | |
| 249 | void DMA_PI_CopyToRDRAM() |
| 250 | { |
| 251 | u32 mem_address {Memory_PI_GetRegister(PI_DRAM_ADDR_REG) & 0x00FFFFFF}; |
| 252 | u32 cart_address {Memory_PI_GetRegister(PI_CART_ADDR_REG) & 0xFFFFFFFF}; |
| 253 | u32 pi_length_reg {(Memory_PI_GetRegister(PI_WR_LEN_REG) & 0xFFFFFFFF) + 1}; |
| 254 | |
| 255 | #ifdef DAEDLAUS_PROFILER |
| 256 | DPF( DEBUG_MEMORY_PI, "PI: Copying %d bytes of data from 0x%08x to 0x%08x", pi_length_reg, cart_address, mem_address ); |
| 257 | #endif |
| 258 | //DAEDALUS_ASSERT(!IsDom1Addr1(cart_address), "The code below doesn't handle dom1/addr1 correctly"); |
| 259 | //DAEDALUS_ASSERT(!IsDom1Addr3(cart_address), "The code below doesn't handle dom1/addr3 correctly"); |
| 260 | |
| 261 | if (cart_address < 0x10000000) |
| 262 | { |
| 263 | if (IsFlashDomAddr(cart_address)) |
| 264 | { |
| 265 | const u8 * p_src( (const u8 *)g_pMemoryBuffers[MEM_SAVE] ); |
| 266 | u32 src_size( ( MemoryRegionSizes[MEM_SAVE] ) ); |
| 267 | cart_address -= PI_DOM2_ADDR2; |
| 268 | |
| 269 | if (g_ROM.settings.SaveType != SAVE_TYPE_FLASH) |
| 270 | DMA_HandleTransfer( g_pu8RamBase, mem_address, gRamSize, p_src, cart_address, src_size, pi_length_reg ); |
| 271 | else |
| 272 | DMA_FLASH_CopyToDRAM(mem_address, cart_address, pi_length_reg); |
| 273 | } |
| 274 | #ifdef DAEDALUS_DEBUG_CONSOLE |
| 275 | else if (IsDom1Addr1(cart_address)) |
| 276 | { |
| 277 | DBGConsole_Msg(0, "[YReading from Cart domain 1/addr1] (Ignored)"); |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | DBGConsole_Msg(0, "[YUnknown PI Address 0x%08x]", cart_address); |
| 282 | } |
| 283 | #endif |
| 284 | } |
| 285 | else |
| 286 | { |
| 287 | if (cart_address < 0x1fc00000) |
| 288 | { |
| 289 | //DBGConsole_Msg(0, "[YReading from Cart domain 1/addr2]"); |
| 290 | cart_address -= PI_DOM1_ADDR2; |
| 291 | CPU_InvalidateICacheRange( 0x80000000 | mem_address, pi_length_reg ); |
| 292 | RomBuffer::CopyToRam( g_pu8RamBase, mem_address, gRamSize, cart_address, pi_length_reg ); |
| 293 | |
| 294 | OnCopiedRom(); |
| 295 | } |
| 296 | #ifdef DAEDALUS_DEBUG_CONSOLE |
| 297 | else |
| 298 | { |
| 299 | // Paper Mario |
| 300 | DBGConsole_Msg(0, "[YReading from Cart domain 1/addr3]"); |
| 301 | } |
| 302 | #endif |
| 303 | } |
| 304 | |
| 305 | Memory_PI_ClrRegisterBits(PI_STATUS_REG, PI_STATUS_DMA_BUSY); |
| 306 | Memory_MI_SetRegisterBits(MI_INTR_REG, MI_INTR_PI); |
nothing calls this directly
no test coverage detected