Permalink
Browse files

-CodeChange: add PowerPC G4/G5 altivec code for Video_DrawScreen_Near…

…est_Neighbor()
  • Loading branch information...
1 parent 5a19d8d commit 9c22d4d5306fce264ac475d9266544be7eaaa52e @miniupnp miniupnp committed with miniupnp Oct 12, 2015
Showing with 31 additions and 1 deletion.
  1. +5 −0 config.lib
  2. +5 −0 include/types.h
  3. +21 −1 src/video/video_sdl.c
View
@@ -895,6 +895,11 @@ make_cflags_and_ldflags() {
# Intel is only available starting from 10.4
CFLAGS="$CFLAGS -mmacosx-version-min=10.4"
fi
+ machine=$(machine)
+ case $machine in
+ ppc7400 | ppc7450 | ppc970)
+ CFLAGS="$CFLAGS -maltivec" ;;
+ esac
fi
fi
fi
View
@@ -100,6 +100,11 @@ typedef struct tile32 {
uint16 y;
} tile32;
+#ifdef __ALTIVEC__
+#undef bool
+#undef pixel
+#endif
+
#ifndef bool
typedef unsigned char bool;
#define false 0
View
@@ -1,12 +1,15 @@
/** @file src/video/video_sdl.c SDL video driver. */
#include <SDL.h>
+#if defined(__ALTIVEC__)
+#include <altivec.h>
+#endif /* __ALTIVEC__ */
#include "types.h"
#include "../os/error.h"
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#include <mmintrin.h>
-#endif
+#endif /* i386 / x86_64 */
#include "video.h"
@@ -267,6 +270,23 @@ static void Video_DrawScreen_Nearest_Neighbor(void)
*((__m64 *)gfx2) = m;
gfx2 += 8;
}
+#elif defined(__ALTIVEC__)
+ /* G4/G5 altivec code */
+ for (x = SCREEN_WIDTH / 16; x > 0; x--) {
+ vector unsigned char m0;
+ vector unsigned char m1;
+ m0 = *((vector unsigned char *)data);
+ m1 = m0;
+ data += 16;
+ m0 = vec_mergeh(m0, m0);
+ m1 = vec_mergel(m1, m1);
+ ((vector unsigned char *)gfx1)[0] = m0;
+ ((vector unsigned char *)gfx1)[1] = m1;
+ gfx1 += 32;
+ ((vector unsigned char *)gfx2)[0] = m0;
+ ((vector unsigned char *)gfx2)[1] = m1;
+ gfx2 += 32;
+ }
#else
for (x = 0; x < SCREEN_WIDTH; x++) {
uint8 value = *data++;

0 comments on commit 9c22d4d

Please sign in to comment.