Skip to content

Commit

Permalink
-CodeChange: add PowerPC G4/G5 altivec code for Video_DrawScreen_Near…
Browse files Browse the repository at this point in the history
…est_Neighbor()
  • Loading branch information
miniupnp committed Oct 23, 2015
1 parent 5a19d8d commit 9c22d4d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.lib
Expand Up @@ -895,6 +895,11 @@ make_cflags_and_ldflags() {
# Intel is only available starting from 10.4 # Intel is only available starting from 10.4
CFLAGS="$CFLAGS -mmacosx-version-min=10.4" CFLAGS="$CFLAGS -mmacosx-version-min=10.4"
fi fi
machine=$(machine)
case $machine in
ppc7400 | ppc7450 | ppc970)
CFLAGS="$CFLAGS -maltivec" ;;
esac
fi fi
fi fi
fi fi
Expand Down
5 changes: 5 additions & 0 deletions include/types.h
Expand Up @@ -100,6 +100,11 @@ typedef struct tile32 {
uint16 y; uint16 y;
} tile32; } tile32;


#ifdef __ALTIVEC__
#undef bool
#undef pixel
#endif

#ifndef bool #ifndef bool
typedef unsigned char bool; typedef unsigned char bool;
#define false 0 #define false 0
Expand Down
22 changes: 21 additions & 1 deletion src/video/video_sdl.c
@@ -1,12 +1,15 @@
/** @file src/video/video_sdl.c SDL video driver. */ /** @file src/video/video_sdl.c SDL video driver. */


#include <SDL.h> #include <SDL.h>
#if defined(__ALTIVEC__)
#include <altivec.h>
#endif /* __ALTIVEC__ */
#include "types.h" #include "types.h"
#include "../os/error.h" #include "../os/error.h"


#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#include <mmintrin.h> #include <mmintrin.h>
#endif #endif /* i386 / x86_64 */


#include "video.h" #include "video.h"


Expand Down Expand Up @@ -267,6 +270,23 @@ static void Video_DrawScreen_Nearest_Neighbor(void)
*((__m64 *)gfx2) = m; *((__m64 *)gfx2) = m;
gfx2 += 8; 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 #else
for (x = 0; x < SCREEN_WIDTH; x++) { for (x = 0; x < SCREEN_WIDTH; x++) {
uint8 value = *data++; uint8 value = *data++;
Expand Down

0 comments on commit 9c22d4d

Please sign in to comment.