// Custom implementation of memcpy. // This routine copies memory in DWORDS (4 bytes at a time) until there are only 3 // or less bytes to copy. Faster than the normal memcpy. void CopyMem(void* dest, void* src, UINT16 size) { // Yes, toraton, I get it. It's assembly. __asm { push eax push ecx push esi push edi mov eax, size mov ecx, eax shr ecx, 2 push ecx mov esi, dest mov edi, src rep movsd pop ecx shl ecx, 2 sub eax, ecx jz epilog mov ecx, eax rep movsb epilog: pop edi pop esi pop ecx pop eax } }