sdl12-compat: Implement SDL_revcpy correctly.

From dacb4cf935ba3a6faee53c67d8973e2b375a3fe9 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 18 May 2021 15:05:29 -0400
Subject: [PATCH] Implement SDL_revcpy correctly.

It actually _has to_ copy backwards, it wasn't just a CPU cache thing.
---
 src/SDL12_compat.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 3a49a11..25b670d 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -1121,13 +1121,17 @@ SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...)
 }
 
 DECLSPEC void * SDLCALL
-SDL_revcpy(void *dst, const void *src, size_t len)
-{
-    /* this doesn't reverse the data...I think this was just a memcpy that
-       was meant to be CPU-cache friendly if you knew you were working with
-       data going backwards in memory, instead of jumping over pages to copy
-       from the start...? Whatever, just do a memcpy here. */
-    return SDL20_memcpy(dst, src, len);
+SDL_revcpy(void *_dst, const void *_src, size_t len)
+{
+    if (len > 0) {
+        Uint8 *dst = (((Uint8 *) _dst) + len) - 1;
+        const Uint8 *src = (((const Uint8 *) _src) + len) - 1;
+        size_t i;
+        for (i = 0; i < len; i++, src--, dst--) {
+            *dst = *src;
+        }
+    }
+    return _dst;
 }