From 9ea029e7010a7fa10884294bbff6f5603bfa5aa9 Mon Sep 17 00:00:00 2001 From: yoshizf Date: Sat, 27 Sep 2003 09:53:42 +0000 Subject: [PATCH] Added advmame2x and advmame3x scalers --- Makefile | 2 +- Makefile.mingw | 2 +- scaler.cpp | 111 +++++++++++++++++++++++++++++++++++++++++++++++++ scaler.h | 33 +++++++++++++++ 4 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 scaler.cpp create mode 100644 scaler.h diff --git a/Makefile b/Makefile index 710d796..3d5353e 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ CP := cp RESSW := --define __WIN32__ --define __WIN95__ --define __GNUWIN32__ REZ_CMD := `wx-config --rezflags` -OBJS := file.o scummex.o resource.o mixer.o image.o sound.o wxwindows.o descumm.o descumm6.o codec37.o codec47.o bomp.o +OBJS := file.o scummex.o resource.o mixer.o image.o sound.o wxwindows.o descumm.o descumm6.o codec37.o codec47.o bomp.o scaler.o CXXFLAGS := -DOSUNIX -g -O -Wall -Wuninitialized -Wshadow -Wstrict-prototypes -Wno-unused-variable -Wno-long-long -Wno-multichar -Wno-unknown-pragmas CXXFLAGS += `wx-config --cxxflags` `sdl-config --cflags` LIBS := `wx-config --libs` `sdl-config --libs` -lSDL_mixer diff --git a/Makefile.mingw b/Makefile.mingw index 3c74543..c33f311 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -11,7 +11,7 @@ WX_LIBS=`wxmsw-2.4-config --libs` CC=g++ OBJECTS= bomp.o codec37.o codec47.o descumm.o descumm6.o file.o image.o mixer.o resource.o resources.o \ - scummex.o sound.o wxwindows.o + scaler.o scummex.o sound.o wxwindows.o CFLAGS= $(SDL_CFLAGS) $(WX_CFLAGS) -O -Wall -Wstrict-prototypes -Wuninitialized -Wno-long-long -Wno-multichar -Wno-unknown-pragmas LIBS= $(SDL_LIBS) $(WX_LIBS) -lmingw32 diff --git a/scaler.cpp b/scaler.cpp new file mode 100644 index 0000000..aa8442c --- /dev/null +++ b/scaler.cpp @@ -0,0 +1,111 @@ +/* ScummEX - Viewer for Scumm data files + * Copyright (C) 2003 Adrien Mercier + * Copyright (C) 2003 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header: /Users/sev/projects/sc/s/scummvm/scummex/scaler.cpp,v 1.1 2003/09/27 09:53:42 yoshizf Exp $ + * + */ + +#include "scaler.h" + +void AdvMame2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, + int width, int height) { + const uint32 nextlineSrc = srcPitch / sizeof(uint8); + const uint8 *p = srcPtr; + + const uint32 nextlineDst = dstPitch / sizeof(uint8); + uint8 *q = dstPtr; + + uint8 A, B, C; + uint8 D, E, F; + uint8 G, H, I; + + while (height--) { + B = *(p - 1 - nextlineSrc); + E = *(p - 1); + H = *(p - 1 + nextlineSrc); + C = *(p - nextlineSrc); + F = *(p); + I = *(p + nextlineSrc); + for (int i = 0; i < width; ++i) { + p++; + A = B; B = C; C = *(p - nextlineSrc); + D = E; E = F; F = *(p); + G = H; H = I; I = *(p + nextlineSrc); + + *(q) = D == B && B != F && D != H ? D : E; + *(q + 1) = B == F && B != D && F != H ? F : E; + *(q + nextlineDst) = D == H && D != B && H != F ? D : E; + *(q + nextlineDst + 1) = H == F && D != H && B != F ? F : E; + q += 2; + } + p += nextlineSrc - width; + q += (nextlineDst - width) << 1; + } +} + +void AdvMame3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, + int width, int height) { + const uint32 nextlineSrc = srcPitch / sizeof(uint8); + const uint8 *p = srcPtr; + + const uint32 nextlineDst = dstPitch / sizeof(uint8); + uint8 *q = dstPtr; + + uint8 A, B, C; + uint8 D, E, F; + uint8 G, H, I; + + while (height--) { + B = *(p - 1 - nextlineSrc); + E = *(p - 1); + H = *(p - 1 + nextlineSrc); + C = *(p - nextlineSrc); + F = *(p); + I = *(p + nextlineSrc); + for (int i = 0; i < width; ++i) { + p++; + A = B; B = C; C = *(p - nextlineSrc); + D = E; E = F; F = *(p); + G = H; H = I; I = *(p + nextlineSrc); + + *(q) = D == B && B != F && D != H ? D : E; + *(q + 1) = E; + *(q + 2) = B == F && B != D && F != H ? F : E; + *(q + nextlineDst) = E; + *(q + nextlineDst + 1) = E; + *(q + nextlineDst + 2) = E; + *(q + 2 * nextlineDst) = D == H && D != B && H != F ? D : E; + *(q + 2 * nextlineDst + 1) = E; + *(q + 2 * nextlineDst + 2) = H == F && D != H && B != F ? F : E; + q += 3; + } + p += nextlineSrc - width; + q += (nextlineDst - width) * 3; + } +} + +void scale(int scale, const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { + switch (scale) { + case 2 : + AdvMame2x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); + break; + case 3 : + AdvMame3x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); + break; + } +} diff --git a/scaler.h b/scaler.h new file mode 100644 index 0000000..f0dae73 --- /dev/null +++ b/scaler.h @@ -0,0 +1,33 @@ +/* ScummEX - Viewer for Scumm data files + * Copyright (C) 2003 Adrien Mercier + * Copyright (C) 2003 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header: /Users/sev/projects/sc/s/scummvm/scummex/scaler.h,v 1.1 2003/09/27 09:53:42 yoshizf Exp $ + * + */ + +#ifndef SCALER_H +#define SCALER_H + +#include "scummsys.h" + +void scale(int scale, const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); +void AdvMame2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); +void AdvMame3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); + +#endif +