
-----------------------
PAL
© 1991 by Robert D'Asto
-----------------------

     PAL is a Basic programmer's utility, a tool for designing palettes used
in AmigaBASIC, AC/BASIC and HiSoft Basic programs. It provides for the
editing of the full 32-color Basic palette plus the extended colors of
HalfBrite Mode if desired. Palettes created with PAL can be saved as either
Basic source code for inclusion in your own programs or as "PAL files" that
can be reloaded into PAL for future editing.

USING PAL
     I suggest running the program by double-clicking the PAL icon and
playing with it a bit before reading all of this documentation file. Much of
it should be self-explanatory. Just don't do any saving of palettes yet, as
you might overwrite an existing file.
     PAL displays the full 32-color palette to the right of the screen along
with each color register number. These numbers correspond to those used in
the COLOR and PALETTE statements. The currently selected color is indicated
by an arrow next to it and by a text/color display at the bottom of the
screen.  Selecting a new color is done by clicking on it with the mouse in
the palette display area. On the left of the screen is a sketch pad which can
be drawn on with the mouse in the currently selected color. Choose "Clear
Sketch Pad" from the Project menu to erase it. The purpose of the sketch pad
is to provide an area for doodling and rough sketching in the various palette
colors so you can get a better idea of how they will look in your program.
PAL is not a paint program, however, and only a single drawing tool is
provided.  Neither is there a provision for saving sketches.

CREATING PALETTES
     Various tools are provided in the Edit menu for manipulating one or more
palette colors. A single color can be changed by selecting "Adjust Selected
Color". This pops up a color-adjustment window providing red, green and blue
slider gadgets that can be adjusted with the mouse, which changes the
selected color accordingly. The window itself can be moved around the screen
by dragging it by its title bar and then clicking in it to restore its
display. When finished adjusting a color with the sliders, either click on
the "OK" gadget to close the window or select another color for adjustment
from the palette display.
     Two palette colors can be swapped by selecting "Swap Two Colors" from
the Edit menu. This changes the appearance of the mouse pointer and produces
a "CANCEL" gadget at the bottom of the screen. Pick the two colors you wish
to swap by clicking on them in the palette display. Clicking the cancel
gadget cancels the operation if you change your mind.
     Similarly, the sequence of two or more palette colors can be reversed by
selecting "Reverse Order Of Colors" and then clicking on the first and last
color in the sequence of colors you wish reversed. A cancel gadget is also
provided.
     The Edit menu items "Scale Colors" and "Blend Colors" are used to create
various color scaling effects which can best be learned by experimenting with
them. Both provide submenus for selecting a portion of the whole palette to
be scaled or blended. Pop-up menus then display the various options that are
available and these selections are made by clicking on them with the mouse or
pressing the appropriate number key on the keyboard.
     The colors of the entire palette can be shifted up or down one position
by selecting "Shift Palette" and the appropriate submenu item.
     The "Restore Default Palette" option clears any changes you have made to
the palette and restores the default palette that existed when PAL was first
started.
     "Undo Last Change" is a one-level undo feature. PAL remembers the
palette as it was just before each change is made and this option can be used
to restore that previous palette if you make a mistake or change your mind.
It will only undo the last change.
     The Extras menu contains several other features. Selecting "HalfBrite
Mode" will display the extended colors of this mode providing your Amiga has
the special HalfBrite chip installed. All but some early A1000 models have
this chip. The HalfBrite colors are an extension of the 32 colors of the
basic Amiga palette. Their color numbers range from 32 to 63 and each is a
half-intensity version of the basic 32 colors. This is a toggle type feature,
selecting it again removes the HalfBrite colors.
     The "Show Menu Colors" feature creates a simulated menu display in the
sketch pad demonstrating what a Basic program's menu will look like with the
existing palette on screens of different depths in both normal and
highlighted states.
     The "Auto Cycle" feature automatically cycles the selected color's hue
until the "STOP" gadget is clicked. It runs through 96 basic hues from red to
blue and back to red again for quick approximation of colors. Fine
adjustments can then be made with the "Adjust Selected Color" slider gadgets.

SAVING YOUR WORK
     A palette created with PAL can be saved as either Basic source code that
can be inserted into your own programs or as a PAL file that can be loaded
back into PAL at a later time for further editing.
     The "Save As" item in the Project menu is used for this purpose and
provides a submenu with the above two choices. If you choose to save your
palette as source code, a pop-up menu will appear providing two more options.
The source code can be written as either 32 PALETTE statements that define
the entire palette you have created, or as a more compact FOR/NEXT loop with
DATA statements. The first option produces a longer file but one that is
easier to edit later within your program's code if you decide to make minor
changes.
     Once this decision is made, PAL'S file requester will appear displaying
the currently mounted disks. The file requester is similar to many such
devices found on Amiga programs. The path to the destination file is defined
by clicking on Disk/Directory/File names in the center display area or by
clicking in the appropriate string gadgets and typing in your choices. Other
gadgets can be clicked to manipulate the currently displayed directory.  When
the desired path is chosen click the "OK" gadget or, to cancel the save,
click the "CANCEL" box. If no file name is entered on a save, the file will
be named "NONAME" by default.
     All palettes saved as PAL files will have a ".pal" extension appended to
their names unless you provide this extension yourself. If no file name at
all is entered, the file will be named "NONAME.pal" by default. PAL files can
later be loaded by selecting "Load PAL File" from the Project menu and the
file requester will appear, SHOWING ONLY THE FILES WITH THIS EXTENSION TO
THEIR NAMES. When the PAL file is loaded the displayed palette will be
changed to that of the loaded file and can be further edited with PAL's tools
or saved as Basic source code.

USING PAL'S MENU
     Many of the menu items have keyboard shortcuts. These items can be
chosen in either the conventional manner using the right mouse button or via
the keyboard by holding down the Right Amiga key and pressing the character
key that is displayed next to that menu item.

THE PAL DISPLAY
     PAL allows manipulation of all the Amiga's color registers, including
those used by PAL in its own display. PAL does its best to keep track of the
colors used in its display and switches those colors when needed to provide
sufficient contrast for viewing the various gadgets and text. It is still
possible, however, to render the PAL display unreadable --- changing every
color of the palette to black, for example. If this should happen you can
solve the problem by selecting the "Undo Last Change" feature via the
keyboard by holding down the Right Amiga key and pressing the "X" key. This
will restore the palette as it was before the last change and should provide
you with a readable display. In addition, the palette displayed when PAL
first starts has one variation from the default palette: color 31 is changed
to black to provide more readable menus.

ABOUT PAL
     PAL was written entirely with HiSoft Basic Professional version 1.05. It
contains several enhanced menu features that are not directly supported by
HSB such as menu subitems, highlight control, keyboard shortcuts, and pop-up
menus. It also provides a file requester, which is not the ARP version but
one I wrote myself with HSB that employs 15 Intuition gadgets.
     PAL and this documentation file are copyright products and may not be
distributed without permission from the author.

PALETTE TIPS, TRICKS, AND TRIVIA
     Here are some terms related to color that you might find useful.

     Hue: a color of the visible spectrum, e.g., red, orange, yellow, blue
     Tint: a hue with white added
     Shade: a hue with black added
     Tone: a hue with gray (black and white) added

     The hues are the "colors of the rainbow". They represent different
frequencies of light waves in the visible spectrum. Red is at the low
frequency end and violet is at the high end. Below red is infrared and above
violet is ultraviolet. The major hues are ROYGBIV: red, orange, yellow,
green, blue, indigo and violet. White is all hues of light combined and black
is no hues (no light). The color brown, as an example, is not a hue.  It is a
shade or tone of a hue that is approximately orange. Pink is a tint of red.
The term "color" is broad and can encompass any hue, tint, shade, or tone
combination.
     An attractive palette for a program is not always one containing a
maximum number and variety of different colors. Often a palette of subtle
variations is the most pleasing choice. Professional-looking displays for
utility programs, for example, usually contain what I call a "shade triplet"
comprised of one color of medium brightness flanked by a lighter and darker
shade of the same color. This is how those embossed-look displays are
created. Call the medium color M and the lighter and darker shades L and D.
Here is how to create an embossed box:

            LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLD
            LMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD
            LMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD
            LMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD
            LMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD
            LMMMMMMMMMMMMMMMMMMMMMMMMMMMMMD
            LDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

     This gives the illusion of a raised area in the center with the right
and lower edges in shadow and the upper and left edges catching the light.
Many variations of this theme are possible and more complex shadings can be
done with a greater number of scaled colors.
     The color of the mouse pointer is defined by colors 16, 17, 18 and 19.
Color 16 is always displayed as transparent so nothing will happen to the
pointer if you change it. Changing colors 17-19 will change the pointer's
colors.  It doesn't matter if your program's screen has a depth that can
display only 16 or fewer colors, you can still change the color of the
pointer by using PALETTE statements that address color registers 17, 18, or
19.
     The menu colors displayed in Basic programs depend on the colors in use
by the window's border and title text. The default colors for Basic windows
are 0 and 1, the window borders are COLOR 1 and the text displayed in the
title bar is done with COLOR 0. These are the same colors used for
unhighlighted menu items: COLOR 0 text on a COLOR 1 background. Highlighted
menu items are displayed in the "complements" of these colors.
     Complements work like this:
     The complement of the lowest COLOR number (always 0) is the highest
COLOR number that can be displayed with the current screen depth. For
example, a screen with a depth of 2 can display 4 possible colors numbered 0-
3. The complement of COLOR 0 on that screen would be the highest displayable
color, which would be COLOR 3. The complement of the second color (1) is the
second highest color number or COLOR 2 and so on.  Increasing the screen's
depth changes the resulting complements. For example, changing the depth to 3
means 8 colors can be displayed numbered 0-7. The complement of COLOR 0
becomes COLOR 7 and the complement of COLOR 1 becomes COLOR 6 and so on.
This is why the colors used to highlight menu items change as the screen
depth changes.
     It is possible to change the colors used for windows from the default 0
and 1, which would also change the colors used in the menus. Here is a sub
that does this. Using the sub requires that the intuition library be opened
first and that requires the intuition.bmap file in the LIBS directory of your
Work-bench disk or in the same directory as the program that uses this sub.
Here it is in AmigaBASIC:

LIBRARY "intuition.library"   'needed at the top of your source
  
  
SUB WindowColors(WindowNum%,border%,title%) STATIC
   WINDOW OUTPUT WindowNum%
   POKE WINDOW(7)+99,border%
   POKE WINDOW(7)+98,title%
   RefreshWindowFrame WINDOW(7)
END SUB

     The first parameter is the number of the window you wish to change. The
last two are the desired border color and text color respectively. Try it.
It's nice to get away from the same old default window colors now and then.
     HalfBrite is a special 64-color Amiga display mode employing a screen
with a depth of six. HalfBrite Mode screens are easily created with HiSoft
BASIC and can be done with AC and AmigaBASIC with a bit more work. In HSB a
Half-Brite screen is created with a single line of code, as follows:

SCREEN 1,320,200,6,1,&H80

     HSB HalfBrite screens defined with the SCREEN statement must be low-res,
non-interlaced. Don't forget the "6" depth parameter and the "&H80" type
parameter. Incidentally, a HAM Mode (4096-color) screen is done in nearly the
same way, the only difference is the type parameter, which is &H800 rather
than &H80, but that's another story. HAM screens are complex and space does
not permit a full explanation of their use here.
     A HalfBrite screen can be created with AC and AmigaBASICs but a special
subprogram is required. The sub uses an intuition library routine and a
function from the graphics library, so both of these libraries must be opened
before the sub can be called. This requires the files "intuition.bmap" and
"graphics.bmap" in the LIBS directory of your Workbench disk or in the same
directory as the program source.
     First open the libraries and declare the function like this:

LIBRARY "intuition.library"
LIBRARY "graphics.library"
DECLARE FUNCTION AllocRaster&() LIBRARY

     Then set up a lo-res screen with a depth of 5 and open a window like this:

SCREEN 1,320,200,5,1
WINDOW 1,,,16,1

     The screen must have a width of 320 and a depth of 5. The window can be
of any type, but you must open a window. Then call the following sub to
convert the screen to HB mode:

SUB HalfBriteMode STATIC
  IF WINDOW(7)=0 THEN EXIT SUB
  BitMap&=PEEKL(WINDOW(7)+46)+184
  IF PEEK(BitMap&+5) <> 5 THEN
    PRINT "Must have depth 5 screen"
    EXIT SUB
  END IF
  plane6&=AllocRaster&(320,200)
  IF plane6&=0 THEN 
    PRINT "Insufficient Memory For HB Mode"
    EXIT SUB
  END IF
  POKEL BitMap&+28,plane6&
  POKE BitMap&+5,6
  ModeAddr&=PEEKL(WINDOW(7)+46)+76
  POKEW ModeAddr&,2^7
  CALL RemakeDisplay&
END SUB

     The sub creates the sixth bitplane, attaches it to the 5-bitplane screen
already opened with the SCREEN statement, and signals the system to operate
in the HalfBrite display mode. It requires no parameters and a SCREEN CLOSE
statement at the end of the program will close the screen.
     Drawing on an HB screen is done in the normal fashion except that you may
now specify any COLOR from 0 to 63 in the Basic graphics statements. COLOR 32
will be a half-intensity version of COLOR 0, COLOR 33 will be half of COLOR 1
and so on. When designing an HB palette keep the basic colors 0-31 in the
higher intensity ranges, otherwise there will be little or no noticeable
difference between the basic colors and the HB colors. The HalfBrite colors
(32-63) cannot be changed directly with the PALETTE statement.

END OF TEXT
