* Copyright 2004, Axel DΓΆrfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2015, Augustin Cavalier <waddlesplash>. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Effect from corTeX / Optimum.
*/
#include <SupportDefs.h>
#include "Draw.h"
void memshset(char* dstParam, int center_shade, int fixed_shade, int half_length)
{
unsigned char* dst;
unsigned char* source;
int offset;
if (half_length == 0)
return;
dst = (unsigned char*)dstParam;
source = dst;
dst -= half_length;
source += half_length;
source++;
offset = half_length;
offset = -offset;
offset--;
do {
int tmp;
center_shade += fixed_shade;
center_shade &= 0xFFFF;
offset++;
tmp = dst[half_length] + (center_shade >> 8);
if (tmp & 0xFF00)
dst[half_length] = 255;
else
dst[half_length] = tmp;
tmp = source[offset] + (center_shade >> 8);
if (tmp & 0xFF00)
source[offset] = 255;
else
source[offset] = tmp;
} while (--half_length != 0);
}
void mblur(char* srcParam, int nbpixels)
{
unsigned int clear1UpperBit = 0x7f7f7f7f;
unsigned int clear3UpperBits = 0x1f1f1f1f;
unsigned int* src = (unsigned int*)srcParam;
if ((nbpixels >>= 2) == 0)
return;
do {
unsigned int eax, ebx;
eax = *src;
ebx = eax;
eax >>= 1;
ebx >>= 3;
eax &= clear1UpperBit;
ebx &= clear3UpperBits;
eax += ebx;
*src = eax;
src++;
} while (--nbpixels != 0);
}