home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 1
/
FishNMoreVol1.bin
/
more
/
code_examples
/
fade
/
fade.zoo
/
fade.c
next >
Wrap
C/C++ Source or Header
|
1989-06-15
|
2KB
|
84 lines
#include <exec/types.h>
#include <proto/graphics.h>
#include <proto/dos.h>
#include <graphics/view.h>
#include <intuition/intuition.h>
#define FindRed(value) ((value >> 8) & 0xf)
#define FindGreen(value) ((value >> 4) & 0xf)
#define FindBlue(value) ( value & 0xf)
#define PAckColors(r,g,b) (((r) << 8) | ((g) << 4) | (b))
void Fade(screen, destMap, delay, numcolors)
struct Screen *screen;
UWORD destMap[];
BYTE delay;
BYTE numcolors;
{
UBYTE CurrColors[32][3];
int Subs[32][3];
register int x, y, z;
/* struct ViewPort *vp = &(screen->ViewPort); */
struct ColorMap *cm = (screen->ViewPort.ColorMap);
register UWORD temp;
/* Find differences */
/* Copy current colors to 8 bit instead of 4 bit */
for (x = 0; x < numcolors; ++x)
{
temp = GetRGB4(cm,x);
Subs[x][0] = FindRed(temp) - FindRed(destMap[x]);
Subs[x][1] = FindGreen(temp) - FindGreen(destMap[x]);
Subs[x][2] = FindBlue(temp) - FindBlue(destMap[x]);
CurrColors[x][0] = ((FindRed(temp) << 4) & 0xf0);
CurrColors[x][1] = ((FindGreen(temp) << 4) & 0xf0);
CurrColors[x][2] = ((FindBlue(temp) << 4) & 0xf0);
/* printf("%d %d %d %d, %d %d %d, %x\n", x, Subs[x][0],Subs[x][1],Subs[x][2],
CurrColors[x][0], CurrColors[x][1], CurrColors[x][2], temp); */
}
/* DO THE FADE!! do the fade!! (hehe..) */
for (x = 0; x < numcolors; ++x)
{
for (y = 0; y < 3; ++y)
{
if (Subs[x][y] < 0)
CurrColors[x][y] -= Subs[x][y];
}
}
for (z = 0; z < 15; ++z)
{
/* printf("."); */
for (x = 0; x < numcolors; ++x)
{
for (y = 0; y < 3; ++y)
{
CurrColors[x][y] -= Subs[x][y];
}
SetRGB4(&(screen->ViewPort),x,(CurrColors[x][0] >> 4) & 15,
(CurrColors[x][1] >> 4) & 15,
(CurrColors[x][2] >> 4) & 15);
}
Delay(delay);
}
/* printf("\n"); */
}
void FadeToBlack(screen, delay, numcolors)
struct Screen *screen;
BYTE delay;
BYTE numcolors;
{
UWORD colormap[32] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
Fade(screen, colormap, delay, numcolors);
}