[comp.sys.amiga.tech] A Minor Programming Proverbial Menace..

rickf@pnet02.cts.com (Rick Flower) (06/15/89)

Well, I'm in the process of writing a small program in which I want to be able
to control the default colors of a custom screen / window that I open.  Will
using (oops, I meant while!) PowerWindows to generate my structures, it
generated a "palette" structure for me to use with my copper colors (or
whatever they are called {8-:>)  Anyway, I started looking through all of my
Amiga books, but I couldn't really find any relevant information except about
SetRGB4 and LoadRGB4 in the graphics library.  In order to use these
functions, I get the feeling (after the code didn't work) that I must first
create a view / viewport in order to do all of that?  Do I also need to create
a ColorMap for this entire thing?  

OR am I going about this in the wrong fashon?

Thanks!
+-----------------------------------------------------------------------------+
|               Caution, Assembly Language Programmer at Play!                |
|                                                                             |
|             UUCP: {ames!elroy, <backbone>}!gryphon!pnet02!rickf             |
|             INET: rickf@pnet02.cts.com                                      |
+=============================================================================+

cmcmanis%pepper@Sun.COM (Chuck McManis) (06/20/89)

In article <16752@gryphon.COM> rickf@pnet02.cts.com (Rick Flower) writes:
>Well, I'm in the process of writing a small program in which I want to be able
>to control the default colors of a custom screen / window that I open.

This means you don't want to use the Palette program on the 1.3 disks? Some
people don't realize that Palette opens on what ever is the frontmost screen
when it is run. Thus you can run it on *any* application that doesn't 
dynamically reset the colors, just start the application pull it down a bit
and then run palette. If the application can't be dragged down then you
can write a little execute script that will wait for 10 seconds or so
and then run palette, giving you plenty of time to start your application.

>  Will
>using (oops, I meant while!) PowerWindows to generate my structures, it
>generated a "palette" structure for me to use with my copper colors (or
>whatever they are called {8-:>)  Anyway, I started looking through all of my
>Amiga books, but I couldn't really find any relevant information except about
>SetRGB4 and LoadRGB4 in the graphics library.  In order to use these
>functions, I get the feeling (after the code didn't work) that I must first
>create a view / viewport in order to do all of that?  Do I also need to create
>a ColorMap for this entire thing?  

Not exactly. The Load/SetRGB4 functions do work on Views and viewports but
when you open a custom screen you get a Viewport for free. Look at the
definition of the screen structure for a pointer to it. I use the following
code :

/* Define the colors our screen will use */

static USHORT colors[] = {
        0x0aaa,         /* Color 0 = Grey (Background)          */
        0x0444,         /* Color 1 = Dark Grey (Shadow)         */
        0x044f,         /* Color 2 = Dark Blue (Cell A Color)   */
        0x0aaf,         /* Color 3 = Light Blue (Highlight)     */
        0x0f44,         /* Color 4 = Dark Red (Cell B Color)    */
        0x0faa,         /* Color 5 = Light Red (Highlight)      */
        0x022a,         /* Color 6 = Dark Blue (Window Bkgrnd)  */
        0x0fff          /* Color 7 = White     (Window Detail)  */
        };

And in your main code somewhere ...
  LoadRGB4(&(MyScreen->ViewPort),colors,8); /* Load in our colors */


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.
"A most excellent barbarian ... Genghis Kahn!"