26 #define MIN_AMOUNT_FOR_COMPLEX_COPY 8 27 #define MIN_AMOUNT_FOR_MISALIGNED_COPY 8 34 inline void lwl_copy(byte *dst,
const byte *src) {
36 asm volatile (
"lwr %0,0(%1)\n\t" 38 :
"=&r" (data) :
"r" (src),
"m" (*src));
40 asm volatile (
"swr %1,0(%2)\n\t" 42 :
"=m" (*dst) :
"r" (data),
"r" (dst));
50 static void testCopy(
const byte *debugDst,
const byte *debugSrc, uint32 debugBytes);
51 static void copy(byte *dst,
const byte *src, uint32 bytes);
52 static void copy32Aligned(uint32 *dst32,
const uint32 *src32, uint32 bytes);
53 static void copy32Misaligned(uint32 *dst32,
const byte *src, uint32 bytes, uint32 alignSrc);
55 static inline void copy8(byte *dst,
const byte *src, int32 bytes) {
57 uint32 words = bytes >> 2;
58 for (; words; words--) {
64 uint32 bytesLeft = bytes & 0x3;
65 for (; bytesLeft; bytesLeft--) {
72 static void *fastCopy(
void *dstv,
const void *srcv, int32 bytes) {
73 byte *dst = (byte *)dstv;
74 const byte *src = (
const byte *)srcv;
76 if (bytes < MIN_AMOUNT_FOR_COMPLEX_COPY) {
77 copy8(dst, src, bytes);
79 copy(dst, src, bytes);
86 inline void *psp_memcpy(
void *dst,
const void *src, int32 bytes) {
87 return PspMemory::fastCopy(dst, src, bytes);
92 #if defined(PSP_INCLUDE_SWAP) && !defined(PSP_MEMORY_SWAP_H) 93 #define PSP_MEMORY_SWAP_H 99 static void testSwap(
const uint16 *debugDst,
const uint16 *debugSrc, uint32 debugBytes,
PSPPixelFormat &format);
100 static void swap(uint16 *dst16,
const uint16 *src16, uint32 bytes,
PSPPixelFormat &format);
101 static void swap32Aligned(uint32 *dst32,
const uint32 *src32, uint32 bytes,
PSPPixelFormat &format);
102 static void swap32Misaligned(uint32 *dst32,
const uint16 *src16, uint32 bytes,
PSPPixelFormat &format);
104 static void swap16(uint16 *dst16,
const uint16 *src16, uint32 bytes,
PSPPixelFormat &format) {
105 PSP_DEBUG_PRINT(
"swap16 called with dst16[%p], src16[%p], bytes[%d]\n", dst16, src16, bytes);
106 uint32 shorts = bytes >> 1;
109 *dst16++ = format.swapRedBlue16(*src16++);
114 static void fastSwap(byte *dst,
const byte *src, uint32 bytes,
PSPPixelFormat &format) {
115 if (bytes < MIN_AMOUNT_FOR_COMPLEX_COPY * 2) {
116 swap16((uint16 *)dst, (
const uint16 *)src, bytes, format);
118 swap((uint16 *)dst, (
const uint16 *)src, bytes, format);