diff --git a/src/memory/memory.h b/src/memory/memory.h index 3566d22e3..552ed43d8 100644 --- a/src/memory/memory.h +++ b/src/memory/memory.h @@ -72,6 +72,14 @@ extern void (*writememd[0x10000])(void); #endif +#ifdef __arm__ + void __aeabi_memcpy4(void*, void*, uint32_t); //this is present in libc6 on Raspberry PI + #define MEMCPY4(...) __aeabi_memcpy4(__VA_ARGS__) +#else + #define MEMCPY4(...) memcpy(__VA_ARGS__) +#endif + + static void masked_write(uint32_t* dst, uint32_t value, uint32_t mask) { *dst = (*dst & ~mask) | (value & mask); diff --git a/src/pi/pi_controller.c b/src/pi/pi_controller.c index 9c12cc15a..49b6f6d09 100644 --- a/src/pi/pi_controller.c +++ b/src/pi/pi_controller.c @@ -126,9 +126,17 @@ static void dma_pi_write(struct pi_controller* pi) dram = (uint8_t*)pi->ri->rdram.dram; rom = pi->cart_rom.rom; - for(i = 0; i < longueur; ++i) + // Check for 32-bit word alignment for faster copying + if (((dram_address | rom_address | longueur) & 3) != 0) { - dram[(dram_address+i)^S8] = rom[(rom_address+i)^S8]; + for(i = 0; i < longueur; ++i) + { + dram[(dram_address+i)^S8] = rom[(rom_address+i)^S8]; + } + } + else + { + MEMCPY4(&dram[dram_address], &rom[rom_address], longueur); } invalidate_r4300_cached_code(0x80000000 + dram_address, longueur); diff --git a/src/rsp/rsp_core.c b/src/rsp/rsp_core.c index d6aa0744f..374844c06 100644 --- a/src/rsp/rsp_core.c +++ b/src/rsp/rsp_core.c @@ -40,20 +40,35 @@ static void dma_sp_write(struct rsp_core* sp) unsigned int length = ((l & 0xfff) | 7) + 1; unsigned int count = ((l >> 12) & 0xff) + 1; unsigned int skip = ((l >> 20) & 0xfff); - + unsigned int memaddr = sp->regs[SP_MEM_ADDR_REG] & 0xfff; unsigned int dramaddr = sp->regs[SP_DRAM_ADDR_REG] & 0xffffff; unsigned char *spmem = (unsigned char*)sp->mem + (sp->regs[SP_MEM_ADDR_REG] & 0x1000); unsigned char *dram = (unsigned char*)sp->ri->rdram.dram; - for(j=0; jmem + (sp->regs[SP_MEM_ADDR_REG] & 0x1000); unsigned char *dram = (unsigned char*)sp->ri->rdram.dram; - for(j=0; jr4300->mi.regs[MI_INTR_REG] &= ~MI_INTR_SP; sp->regs[SP_STATUS_REG] &= ~0x300; - } else {