home *** CD-ROM | disk | FTP | other *** search
- /*
-
-
- ****************************************************************************
- SCREEN COLOR ROUTINES
-
- CREATED BY:
- HAROLD WALPERT
- 6224 BERKELEY AVE
- BALTIMORE, MD. 21209
- for
- BALTIMORE AMIGA USER'S DEVELOPERS(BAUD) LTD.
- (AN AMIGA USER GROUP)
- P.O.BOX 2432
- BALTIMORE, MARYLAND 21203-2432
-
- All copyrights are retained by Harold Walpert but the code described is
- freely distributable in the public domain.
-
- NO warranty is implied--use at your own risk. As far as I know they do work.
- ***************************************************************************
-
-
-
-
-
- PURPOSE: The reason a person might want to use these routines is to make
- switching pallettes, screens, windows, programs more professional looking.
- These routines will allow you to gently fade from one set of colors to
- another set or to turn the screen black for a while and then to bring it
- back, etc. The members of BAUD seem to like them and we use them in our
- club magazine (which is on disk-if you would like to get a copy they aren't too
- expensive-drop us a line).
-
- A FULL SET OF CODE INCLUDES
- :
- backgnd.c
- fade.c
- nbackgnd.c
- restore1.c
- solidcolor.c
-
- FUNCTIONS: The following functions are contained in the above code. I've also
- indicated after each function the proper declarations for the variables con-
- tained in the function call. The functions are very similar to each other and
- you could probably build on them.
-
- (1) backgnd_colors(vp,nColors) [Contained in backgnd.c]
- struct ViewPort *vp;
- LONG nColors;
-
- (2) fade_colors(vp,nColors) [Contained in fade.c]
- struct ViewPort *vp;
- LONG nColors;
-
- (3) nbackgnd_colors(vp,colortable,nColors) [Contained in nbackgnd.c]
- struct ViewPort *vp;
- LONG nColors;
- WORD *colortable;
-
- (4) restore_colors(vp,colortable,nColors) [Contained in restore1.c]
- struct ViewPort *vp;
- LONG nColors;
- WORD *colortable;
-
- (5) solid_colors(vp,colortable,nColors,k) [Contained in solidcolor.c]
- struct ViewPort *vp;
- LONG nColors,k;
- WORD *colortable;
-
- WHAT THEY DO:
-
- (1) fade_colors() is passed the address of the current viewport and
- the number of colors in the viewport color table i.e. 4,8,16, or 32. The
- function then sets them all to black. The screen then slowly fades out.
-
- (2) restore_colors() is passed the address of the viewport you are
- planning to use, the address of the colortable you want to use and the
- number of colors in the color table. The function then restores the screen
- to these colors and, voila, the screen slowly comes back in the new colors.
-
- (3) backgnd_colors() is similar to fade_colors() but instead fades
- the screen to the current color #0 of the viewport color table.
-
- (4) nbackgnd_colors() is similar to backgnd_colors() but instead
- of fading to the current viewport color #0 , it fades all of the screen colors
- to a designated colortable color #0.
-
- (5) solid_colors() is similar to nbackgnd_colors() but instead of
- fading the screen colors to the designated colortable #0 it will fade the
- screen colors to any chosen color from those in a designated colortable(i.e.
- color "k").
-
- YOU SHOULD BE ABLE TO COMPILE THESE IN MANX--HAVE FUN!
-
- Harold
-
- */
-
- #include <stdio.h>
- #include <exec/io.h>
- #include <exec/types.h>
- #include <exec/nodes.h>
- #include <exec/libraries.h>
- #include <ctype.h>
- #include <functions.h>
- #include <exec/memory.h>
- #include <graphics/gfx.h>
- #include <hardware/dmabits.h>
- #include <hardware/custom.h>
- #include <hardware/blit.h>
- #include <graphics/rastport.h>
- #include <graphics/gfxmacros.h>
- #include <graphics/view.h>
- #include <graphics/gels.h>
- #include <graphics/regions.h>
- #include <graphics/clip.h>
- #include <graphics/display.h>
- #include <exec/exec.h>
- #include <graphics/text.h>
- #include <graphics/gfxbase.h>
- #include <devices/console.h>
- #include <devices/keymap.h>
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
- #include <libraries/diskfont.h>
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
-
- restore_colors(vp,colortable,nColors)
- struct ViewPort *vp;
- LONG nColors;
- WORD *colortable;
- {
-
- WORD col[32];
- long i,more;
-
- for (i=0;i<nColors;i++)
- col[i] = GetRGB4(vp->ColorMap,i);
-
- more = TRUE;
- while (more == TRUE)
- {
- more = FALSE;
-
- for (i=0;i<nColors;i++)
- {
- if ((col[i] & 0x0f00) < (*(colortable + i) & 0x0f00 ))
- { col[i] += 0x0100; more = TRUE; }
- if ((col[i] & 0x00f0) < (*(colortable + i) & 0x00f0))
- { col[i] += 0x0010; more = TRUE; }
- if ((col[i] & 0x000f) < (*(colortable + i) & 0x000f))
- { col[i] += 0x0001; more = TRUE; }
- if ((col[i] & 0x0f00) > (*(colortable + i) & 0x0f00 ))
- { col[i] -= 0x0100; more = TRUE; }
- if ((col[i] & 0x00f0) > (*(colortable + i) & 0x00f0))
- { col[i] -= 0x0010; more = TRUE; }
- if ((col[i] & 0x000f) > (*(colortable + i) & 0x000f))
- { col[i] -= 0x0001; more = TRUE; }
- }
-
- LoadRGB4(vp, &col[0], nColors);
- Delay(2);
- }
- }
-
-
-