MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / CopyLineSwap32

Function CopyLineSwap32

Source/HLEGraphics/RDPStateManager.cpp:265–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265static inline void CopyLineSwap32(void * dst, const void * src, u32 bytes)
266{
267 u32* src32 {(u32*)(src)};
268 u32* dst32 {(u32*)(dst)};
269
270#ifdef FAST_TMEM_COPY
271 DAEDALUS_ASSERT((bytes&0x7)==0, "CopyLineSwap32: Remaning bytes! (%d)",bytes);
272
273 if( ((uintptr_t)src32&0x3 )==0)
274 {
275 u32 size128 {bytes >> 4};
276
277 while (size128--)
278 {
279 dst32[0] = BSWAP32(src32[2]);
280 dst32[1] = BSWAP32(src32[3]);
281 dst32[2] = BSWAP32(src32[0]);
282 dst32[3] = BSWAP32(src32[1]);
283 dst32 += 4;
284 src32 += 4;
285 }
286
287 // Copy any remaining quadword
288 bytes&=0xF;
289 while(bytes--)
290 {
291 *(u32*)((uintptr_t)dst32++ ^ 0x8) = BSWAP32(src32[0]);
292 *(u32*)((uintptr_t)dst32++ ^ 0x8) = BSWAP32(src32[1]);
293 src32+=2;
294 }
295 }
296 else
297#endif
298 {
299 // Have yet to see game with unaligned copies here
300 //DBGConsole_Msg(0, "[WWarning CopyLineSwap32: Performing slow copy]" );
301
302 u8* src8 {(u8*)src32};
303 u8* dst8 {(u8*)dst32};
304 while(bytes--)
305 {
306 // Alternate 64 bit words are swapped
307 *(u8*)((uintptr_t)dst8++ ^ 0x8) = *(u8*)((uintptr_t)src8++ ^ U8_TWIDDLE);
308 }
309 }
310}
311#endif
312
313

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected