From f385752705de73b04cbbda735a71f14c19e241a6 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Fri, 1 Feb 2013 00:33:30 -0500 Subject: memcpy vs memmove: memmove correctly handles overlapping source and destination memory buffers, but is slower than memcpy in many implementations. When memory buffers don't overlap, memcpy may be more efficient. The DS2 SDK is such an implementation, so change many memmoves into memcpys. --- source/sa1.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/sa1.cpp') diff --git a/source/sa1.cpp b/source/sa1.cpp index 4dbf9b0..addeed7 100644 --- a/source/sa1.cpp +++ b/source/sa1.cpp @@ -742,7 +742,8 @@ void S9xSetSA1 (uint8 byte, uint32 address) if ((Memory.FillRAM [0x2230] & 0xb0) == 0xa0) { // Char conversion 2 DMA enabled - memmove (&Memory.ROM [CMemory::MAX_ROM_SIZE - 0x10000] + SA1.in_char_dma * 16, + // memmove converted: Same malloc but constant non-overlapping addresses [Neb] + memcpy (&Memory.ROM [CMemory::MAX_ROM_SIZE - 0x10000] + SA1.in_char_dma * 16, &Memory.FillRAM [0x2240], 16); SA1.in_char_dma = (SA1.in_char_dma + 1) & 7; if ((SA1.in_char_dma & 3) == 0) @@ -895,6 +896,7 @@ static void S9xSA1DMA () len &= 0x3ff; d = &Memory.FillRAM [0x3000] + dst; } + // memmove required: Can overlap arbitrarily [Neb] memmove (d, s, len); Memory.FillRAM [0x2301] |= 0x20; -- cgit v1.2.3