From 5a191f0896681f375401824fdc806c8e69fcafe9 Mon Sep 17 00:00:00 2001 From: Nach Date: Tue, 20 Nov 2007 16:03:49 +0000 Subject: [PATCH] HQXx now all working nicely in SDL. Can use assembly optimized in SDL port if compiled with USEASM=yes. --- Makefile | 10 ++++++++-- src/hq3x32.cpp | 29 +++++++++++++++++++++++++---- src/hqxx.h | 4 ++-- src/sdl/SDL.cpp | 8 ++++---- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 41955ed1..57ed5c23 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,6 @@ ifeq ($(PLATFORM),win-cross) OUT=vba.exe endif - MAINDIR=src SDLDIR=src/sdl DMGDIR=src/gb @@ -59,9 +58,16 @@ ${DMGDIR}/gbSound${OE} SDLOBJ=${SDLDIR}/debugger${OE} ${SDLDIR}/SDL${OE} ${SDLDIR}/dummy${OE} -OBJECTS=${MAINOBJ} ${DMGOBJ} ${SDLOBJ} ${CALTERNOBJ} +OBJECTS=${MAINOBJ} ${DMGOBJ} ${SDLOBJ} LIB=${RESAMPLEDIR}/filterkit${OE} ${RESAMPLEDIR}/resample${OE} ${RESAMPLEDIR}/resamplesubs${OE} +ifeq ($(USEASM),yes) +OBJECTS+=${ASMOBJ} +else +OBJECTS+=${CALTERNOBJ} +endif + + .SUFFIXES: .c .cpp .asm %${OE}: %.c diff --git a/src/hq3x32.cpp b/src/hq3x32.cpp index 0e50a9b3..f8d5cd14 100644 --- a/src/hq3x32.cpp +++ b/src/hq3x32.cpp @@ -55,13 +55,12 @@ void InitLUTs(void) int hq3xinited=0; extern int realsystemRedShift, realsystemBlueShift; +//16 bit input, see below for 32 bit input void hq3x32(unsigned char * pIn, unsigned int srcPitch, unsigned char *, unsigned char * pOut, unsigned int dstPitch, int Xres, int Yres) { - // NOTICE! This driver wants 16 bit, not 32 bit input! - if (!hq3xinited) { InitLUTs(); @@ -114,13 +113,12 @@ void hq4x16(unsigned char * pIn, unsigned int srcPitch, hq4x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2)); } +//16 bit input, see below for 32 bit input void hq4x32(unsigned char * pIn, unsigned int srcPitch, unsigned char *, unsigned char * pOut, unsigned int dstPitch, int Xres, int Yres) { - // NOTICE! This driver wants 16 bit, not 32 bit input! - if (!hq3xinited) { InitLUTs(); @@ -145,3 +143,26 @@ void hq4x32(unsigned char * pIn, unsigned int srcPitch, } } } + +static inline void convert32bpp_16bpp(unsigned char *pIn, unsigned int width) +{ + for (unsigned int i = 0; i < width; i+=4) + { + unsigned int p4 = ((unsigned int)pIn[i+2] << 16) | (unsigned int) (pIn[i+1] << 8) | pIn[i+0]; + unsigned short p2 = ((p4 >> 8)&0xF800) | ((p4 >> 5)&0x07E0) | ((p4 >> 3)&0x001F); + pIn[i/2] = (p2 >> 0); + pIn[i/2+1] = (p2 >> 8); + } +} + +void hq3x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres) +{ + convert32bpp_16bpp(pIn, srcPitch*Yres); + hq3x32(pIn, srcPitch/2, 0, pOut, dstPitch, Xres, Yres); +} + +void hq4x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres) +{ + convert32bpp_16bpp(pIn, srcPitch*Yres); + hq4x32(pIn, srcPitch/2, 0, pOut, dstPitch, Xres, Yres); +} diff --git a/src/hqxx.h b/src/hqxx.h index 2555c27d..43ccc789 100644 --- a/src/hqxx.h +++ b/src/hqxx.h @@ -271,7 +271,7 @@ void hq3x16(unsigned char * pIn, unsigned int srcPitch, unsigned char * pOut, unsigned int dstPitch, int Xres, int Yres) #elif defined(_32BIT) -void hq3x32(unsigned char * pIn, unsigned int srcPitch, +void hq3x32_32(unsigned char * pIn, unsigned int srcPitch, unsigned char *, unsigned char * pOut, unsigned int dstPitch, int Xres, int Yres) @@ -283,7 +283,7 @@ void hq4x16(unsigned char * pIn, unsigned int srcPitch, unsigned char * pOut, unsigned int dstPitch, int Xres, int Yres) #elif defined(_32BIT) -void hq4x32(unsigned char * pIn, unsigned int srcPitch, +void hq4x32_32(unsigned char * pIn, unsigned int srcPitch, unsigned char *, unsigned char * pOut, unsigned int dstPitch, int Xres, int Yres) diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index 180abb77..c073a11a 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -90,9 +90,9 @@ extern void hq2x32(u8*,u32,u8*,u8*,u32,int,int); extern void lq2x(u8*,u32,u8*,u8*,u32,int,int); extern void lq2x32(u8*,u32,u8*,u8*,u32,int,int); extern void hq3x16(u8*,u32,u8*,u8*,u32,int,int); -extern void hq3x32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq3x32_32(u8*,u32,u8*,u8*,u32,int,int); extern void hq4x16(u8*,u32,u8*,u8*,u32,int,int); -extern void hq4x32(u8*,u32,u8*,u8*,u32,int,int); +extern void hq4x32_32(u8*,u32,u8*,u8*,u32,int,int); extern void SmartIB(u8*,u32,int,int); extern void SmartIB32(u8*,u32,int,int); @@ -2538,10 +2538,10 @@ int main(int argc, char **argv) filterFunction = lq2x32; break; case 14: - filterFunction = hq3x32; + filterFunction = hq3x32_32; break; case 15: - filterFunction = hq4x32; + filterFunction = hq4x32_32; break; default: filterFunction = NULL;