mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-22 18:49:18 +01:00
update VBA structure to match new VBA-M structure
This commit is contained in:
parent
dc7b84e4a5
commit
09d71bdde7
@ -1,302 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Advance project.
|
||||
*
|
||||
* Copyright (C) 2003 Andrea Mazzoleni
|
||||
*
|
||||
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* In addition, as a special exception, Andrea Mazzoleni
|
||||
* gives permission to link the code of this program with
|
||||
* the MAME library (or with modified versions of MAME that use the
|
||||
* same license as MAME), and distribute linked combinations including
|
||||
* the two. You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than MAME. If you modify
|
||||
* this file, you may extend this exception to your version of the
|
||||
* file, but you are not obligated to do so. If you do not wish to
|
||||
* do so, delete this exception statement from your version.
|
||||
*/
|
||||
|
||||
#ifndef __INTERP_H
|
||||
#define __INTERP_H
|
||||
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
typedef uint16_t interp_uint16;
|
||||
typedef uint32_t interp_uint32;
|
||||
|
||||
/***************************************************************************/
|
||||
/* Basic types */
|
||||
|
||||
/***************************************************************************/
|
||||
/* interpolation */
|
||||
|
||||
static unsigned interp_mask[2];
|
||||
static unsigned interp_bits_per_pixel;
|
||||
|
||||
#define INTERP_16_MASK_1(v) (v & interp_mask[0])
|
||||
#define INTERP_16_MASK_2(v) (v & interp_mask[1])
|
||||
|
||||
static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*2 + INTERP_16_MASK_1(p3)*1) / 8)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*2 + INTERP_16_MASK_2(p3)*1) / 8);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)*2) / 8)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)*2) / 8);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_611(u16 p1, u16 p2, u16 p3)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_71(u16 p1, u16 p2)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*7 + INTERP_16_MASK_1(p2)) / 8)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*7 + INTERP_16_MASK_2(p2)) / 8);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_211(u16 p1, u16 p2, u16 p3)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_772(u16 p1, u16 p2, u16 p3)
|
||||
{
|
||||
return INTERP_16_MASK_1(((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2))*7 + INTERP_16_MASK_1(p3)*2) / 16)
|
||||
| INTERP_16_MASK_2(((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2))*7 + INTERP_16_MASK_2(p3)*2) / 16);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_11(u16 p1, u16 p2)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_31(u16 p1, u16 p2)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)) / 4)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)) / 4);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_1411(u16 p1, u16 p2, u16 p3)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_431(u16 p1, u16 p2, u16 p3)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*4 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)) / 8)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*4 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)) / 8);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_53(u16 p1, u16 p2)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*3) / 8)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*3) / 8);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_151(u16 p1, u16 p2)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*15 + INTERP_16_MASK_1(p2)) / 16)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*15 + INTERP_16_MASK_2(p2)) / 16);
|
||||
}
|
||||
|
||||
static inline u16 interp_16_97(u16 p1, u16 p2)
|
||||
{
|
||||
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*9 + INTERP_16_MASK_1(p2)*7) / 16)
|
||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*9 + INTERP_16_MASK_2(p2)*7) / 16);
|
||||
}
|
||||
|
||||
#define INTERP_32_MASK_1(v) (v & 0xFF00FF)
|
||||
#define INTERP_32_MASK_2(v) (v & 0x00FF00)
|
||||
|
||||
static inline u32 interp_32_521(u32 p1, u32 p2, u32 p3)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*2 + INTERP_32_MASK_1(p3)*1) / 8)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*2 + INTERP_32_MASK_2(p3)*1) / 8);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_332(u32 p1, u32 p2, u32 p3)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)*2) / 8)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)*2) / 8);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_211(u32 p1, u32 p2, u32 p3)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_611(u32 p1, u32 p2, u32 p3)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_71(u32 p1, u32 p2)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*7 + INTERP_32_MASK_1(p2)) / 8)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*7 + INTERP_32_MASK_2(p2)) / 8);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_772(u32 p1, u32 p2, u32 p3)
|
||||
{
|
||||
return INTERP_32_MASK_1(((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2))*7 + INTERP_32_MASK_1(p3)*2) / 16)
|
||||
| INTERP_32_MASK_2(((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2))*7 + INTERP_32_MASK_2(p3)*2) / 16);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_11(u32 p1, u32 p2)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_31(u32 p1, u32 p2)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)) / 4)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)) / 4);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_1411(u32 p1, u32 p2, u32 p3)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_431(u32 p1, u32 p2, u32 p3)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*4 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)) / 8)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*4 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)) / 8);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_53(u32 p1, u32 p2)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*3) / 8)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*3) / 8);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_151(u32 p1, u32 p2)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*15 + INTERP_32_MASK_1(p2)) / 16)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*15 + INTERP_32_MASK_2(p2)) / 16);
|
||||
}
|
||||
|
||||
static inline u32 interp_32_97(u32 p1, u32 p2)
|
||||
{
|
||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*9 + INTERP_32_MASK_1(p2)*7) / 16)
|
||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*9 + INTERP_32_MASK_2(p2)*7) / 16);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* diff */
|
||||
|
||||
#define INTERP_Y_LIMIT (0x30*4)
|
||||
#define INTERP_U_LIMIT (0x07*4)
|
||||
#define INTERP_V_LIMIT (0x06*8)
|
||||
|
||||
static int interp_16_diff(u16 p1, u16 p2)
|
||||
{
|
||||
int r, g, b;
|
||||
int y, u, v;
|
||||
|
||||
if (p1 == p2)
|
||||
return 0;
|
||||
|
||||
if (interp_bits_per_pixel == 16) {
|
||||
b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
|
||||
g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3;
|
||||
r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8;
|
||||
} else {
|
||||
b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
|
||||
g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2;
|
||||
r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7;
|
||||
}
|
||||
|
||||
y = r + g + b;
|
||||
u = r - b;
|
||||
v = -r + 2*g - b;
|
||||
|
||||
if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
|
||||
return 1;
|
||||
|
||||
if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
|
||||
return 1;
|
||||
|
||||
if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int interp_32_diff(u32 p1, u32 p2)
|
||||
{
|
||||
int r, g, b;
|
||||
int y, u, v;
|
||||
|
||||
if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8))
|
||||
return 0;
|
||||
|
||||
b = (int)((p1 & 0xFF) - (p2 & 0xFF));
|
||||
g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8;
|
||||
r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16;
|
||||
|
||||
y = r + g + b;
|
||||
u = r - b;
|
||||
v = -r + 2*g - b;
|
||||
|
||||
if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
|
||||
return 1;
|
||||
|
||||
if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
|
||||
return 1;
|
||||
|
||||
if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void interp_set(unsigned bits_per_pixel)
|
||||
{
|
||||
interp_bits_per_pixel = bits_per_pixel;
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 15 :
|
||||
interp_mask[0] = 0x7C1F;
|
||||
interp_mask[1] = 0x03E0;
|
||||
break;
|
||||
case 16 :
|
||||
interp_mask[0] = 0xF81F;
|
||||
interp_mask[1] = 0x07E0;
|
||||
break;
|
||||
case 32 :
|
||||
interp_mask[0] = 0xFF00FF;
|
||||
interp_mask[1] = 0x00FF00;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,150 +0,0 @@
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include "System.h"
|
||||
|
||||
extern int RGB_LOW_BITS_MASK;
|
||||
|
||||
void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *nextLine, *finish;
|
||||
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *xP = (u32 *) deltaPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
u32 nextPixel;
|
||||
u32 currentDelta;
|
||||
u32 nextDelta;
|
||||
|
||||
finish = (u8 *) bP + ((width+2) << 1);
|
||||
nextPixel = *bP++;
|
||||
nextDelta = *xP++;
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
currentDelta = nextDelta;
|
||||
nextPixel = *bP++;
|
||||
nextDelta = *xP++;
|
||||
|
||||
if ((nextPixel != nextDelta) || (currentPixel != currentDelta)) {
|
||||
u32 colorA, colorB, product;
|
||||
|
||||
*(xP - 2) = currentPixel;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
colorA = currentPixel >> 16;
|
||||
colorB = currentPixel & 0xffff;
|
||||
#else
|
||||
colorA = currentPixel & 0xffff;
|
||||
colorB = currentPixel >> 16;
|
||||
#endif
|
||||
product = (((colorA & colorMask) >> 1) & colorMask) >> 1;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
*(nL) = (product << 16) | (product);
|
||||
*(dP) = (colorA << 16) | product;
|
||||
#else
|
||||
*(nL) = product | (product << 16);
|
||||
*(dP) = colorA | (product << 16);
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
colorA = nextPixel >> 16;
|
||||
#else
|
||||
colorA = nextPixel & 0xffff;
|
||||
#endif
|
||||
product = (((colorB & colorMask) >> 1) & colorMask) >> 1;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
*(nL + 1) = (product << 16) | (product);
|
||||
*(dP + 1) = (colorB << 16) | (product);
|
||||
#else
|
||||
*(nL + 1) = (product) | (product << 16);
|
||||
*(dP + 1) = (colorB) | (product << 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
deltaPtr += srcPitch;
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
}
|
||||
while (--height);
|
||||
}
|
||||
|
||||
void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *nextLine, *finish;
|
||||
u32 colorMask = ~RGB_LOW_BITS_MASK;
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
// u32 *xP = (u32 *) deltaPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
u32 nextPixel;
|
||||
|
||||
finish = (u8 *) bP + ((width+1) << 2);
|
||||
nextPixel = *bP++;
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
nextPixel = *bP++;
|
||||
|
||||
u32 colorA, colorB, product;
|
||||
|
||||
colorA = currentPixel;
|
||||
colorB = nextPixel;
|
||||
|
||||
product = (((colorA & colorMask) >> 1) & colorMask) >> 1;
|
||||
*(nL) = product;
|
||||
*(nL+1) = product;
|
||||
*(dP) = colorA;
|
||||
*(dP+1) = product;
|
||||
|
||||
nextPixel = *bP++;
|
||||
colorA = nextPixel;
|
||||
product = (((colorB & colorMask) >> 1) & colorMask) >> 1;
|
||||
*(nL + 2) = product;
|
||||
*(nL + 3) = product;
|
||||
*(dP + 2) = colorB;
|
||||
*(dP + 3) = product;
|
||||
|
||||
dP += 4;
|
||||
nL += 4;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
}
|
||||
while (--height);
|
||||
}
|
@ -1,220 +0,0 @@
|
||||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-1998 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
/* @(#) $Id: zutil.h,v 1.2 2004/01/17 23:07:32 kxu Exp $ */
|
||||
|
||||
#ifndef _Z_UTIL_H
|
||||
#define _Z_UTIL_H
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef STDC
|
||||
# include <stddef.h>
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef NO_ERRNO_H
|
||||
extern int errno;
|
||||
#else
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||
|
||||
typedef unsigned char uch;
|
||||
typedef uch FAR uchf;
|
||||
typedef unsigned short ush;
|
||||
typedef ush FAR ushf;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
/* (size given to avoid silly warnings with Visual C++) */
|
||||
|
||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||
|
||||
#define ERR_RETURN(strm,err) \
|
||||
return (strm->msg = (char*)ERR_MSG(err), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
|
||||
/* common constants */
|
||||
|
||||
#ifndef DEF_WBITS
|
||||
# define DEF_WBITS MAX_WBITS
|
||||
#endif
|
||||
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
||||
|
||||
#if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
#else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
#define STORED_BLOCK 0
|
||||
#define STATIC_TREES 1
|
||||
#define DYN_TREES 2
|
||||
/* The three kinds of block type */
|
||||
|
||||
#define MIN_MATCH 3
|
||||
#define MAX_MATCH 258
|
||||
/* The minimum and maximum match lengths */
|
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||
|
||||
/* target dependencies */
|
||||
|
||||
#ifdef MSDOS
|
||||
# define OS_CODE 0x00
|
||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||
/* Allow compilation with ANSI keywords only enabled */
|
||||
void _Cdecl farfree( void *block );
|
||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||
# else
|
||||
# include <alloc.h>
|
||||
# endif
|
||||
# else /* MSC or DJGPP */
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef OS2
|
||||
# define OS_CODE 0x06
|
||||
#endif
|
||||
|
||||
#ifdef WIN32 /* Window 95 & Windows NT */
|
||||
# define OS_CODE 0x0b
|
||||
#endif
|
||||
|
||||
#if defined(VAXC) || defined(VMS)
|
||||
# define OS_CODE 0x02
|
||||
# define F_OPEN(name, mode) \
|
||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||
#endif
|
||||
|
||||
#ifdef AMIGA
|
||||
# define OS_CODE 0x01
|
||||
#endif
|
||||
|
||||
#if defined(ATARI) || defined(atarist)
|
||||
# define OS_CODE 0x05
|
||||
#endif
|
||||
|
||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||
# define OS_CODE 0x07
|
||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||
# include <unix.h> /* for fdopen */
|
||||
# else
|
||||
# ifndef fdopen
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __50SERIES /* Prime/PRIMOS */
|
||||
# define OS_CODE 0x0F
|
||||
#endif
|
||||
|
||||
#ifdef TOPS20
|
||||
# define OS_CODE 0x0a
|
||||
#endif
|
||||
|
||||
#if defined(_BEOS_) || defined(RISCOS)
|
||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
#endif
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER > 600))
|
||||
# define fdopen(fd,type) _fdopen(fd,type)
|
||||
#endif
|
||||
|
||||
|
||||
/* Common defaults */
|
||||
|
||||
#ifndef OS_CODE
|
||||
# define OS_CODE 0x03 /* assume Unix */
|
||||
#endif
|
||||
|
||||
#ifndef F_OPEN
|
||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||
#endif
|
||||
|
||||
/* functions */
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
extern char *strerror OF((int));
|
||||
# define zstrerror(errnum) strerror(errnum)
|
||||
#else
|
||||
# define zstrerror(errnum) ""
|
||||
#endif
|
||||
|
||||
#if defined(pyr)
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||
/* Use our own functions for small and medium model with MSC <= 5.0.
|
||||
* You may have to use the same strategy for Borland C (untested).
|
||||
* The __SC__ check is for Symantec.
|
||||
*/
|
||||
# define NO_MEMCPY
|
||||
#endif
|
||||
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
||||
# define HAVE_MEMCPY
|
||||
#endif
|
||||
#ifdef HAVE_MEMCPY
|
||||
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
||||
# define zmemcpy _fmemcpy
|
||||
# define zmemcmp _fmemcmp
|
||||
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
||||
# else
|
||||
# define zmemcpy memcpy
|
||||
# define zmemcmp memcmp
|
||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||
# endif
|
||||
#else
|
||||
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
||||
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
||||
extern void zmemzero OF((Bytef* dest, uInt len));
|
||||
#endif
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef DEBUG
|
||||
# include <stdio.h>
|
||||
extern int z_verbose;
|
||||
extern void z_error OF((char *m));
|
||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
||||
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
||||
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
||||
#else
|
||||
# define Assert(cond,msg)
|
||||
# define Trace(x)
|
||||
# define Tracev(x)
|
||||
# define Tracevv(x)
|
||||
# define Tracec(c,x)
|
||||
# define Tracecv(c,x)
|
||||
#endif
|
||||
|
||||
|
||||
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
|
||||
uInt len));
|
||||
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
|
||||
void zcfree OF((voidpf opaque, voidpf ptr));
|
||||
|
||||
#define ZALLOC(strm, items, size) \
|
||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||
|
||||
#endif /* _Z_UTIL_H */
|
Loading…
Reference in New Issue
Block a user