2 * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Copyright 2015, Augustin Cavalier <waddlesplash>. All rights reserved.
4 * Distributed under the terms of the MIT License.
6 * Effect from corTeX / Optimum.
9 #include <SupportDefs.h>
14 // Hand-translated from x86 assembly.
15 /* memshset (char *dst, int center_shade,int fixed_shade, int length_2) */
16 /* dst is the *center* of the dst segment */
17 /* center shade is the initial color (at center) (!! 8:8 also) */
18 /* fixed_shade is the fixed point increment (8:8) */
19 /* length_2 is the 1/2 length to set (to the left, and to the right) */
21 /* a memaddshadedset function (or something like that ) */
22 void memshset(char* dstParam
, int center_shade
, int fixed_shade
, int half_length
)
25 unsigned char* source
;
31 dst
= (unsigned char*)dstParam
;
33 dst
-= half_length
; // Left segment
34 source
+= half_length
; // Right segment
35 source
++; // Don't overlap at middle
39 offset
--; // For in-advance incl in loop
43 center_shade
+= fixed_shade
; // Increment color.
44 center_shade
&= 0xFFFF; // Mask so we can do overflow tests.
47 tmp
= dst
[half_length
] + (center_shade
>> 8); // Increment left pixel.
50 dst
[half_length
] = 255;
52 dst
[half_length
] = tmp
;
54 tmp
= source
[offset
] + (center_shade
>> 8); // Increment right pixel.
59 } while (--half_length
!= 0);
63 /* do the "motion blur" (actually the pixel fading) */
64 void mblur(char* srcParam
, int nbpixels
)
66 unsigned int clear1UpperBit
= 0x7f7f7f7f;
67 unsigned int clear3UpperBits
= 0x1f1f1f1f;
68 unsigned int* src
= (unsigned int*)srcParam
;
70 if ((nbpixels
>>= 2) == 0)
74 unsigned int eax
, ebx
;
81 eax
&= clear1UpperBit
;
83 ebx
&= clear3UpperBits
;
88 } while (--nbpixels
!= 0);