Colour Palette

by Garry Francis

 

Issue 20

Mar/Apr 86

Next Article >>

<< Prev Article

 

 

When it comes to computer graphics, the Atari 400/800/XL/XE micros are the undisputed leaders in the 8-bit field. Any idiot with two eyes and a brain can see that! (Unfortunately, that rules out one-eyed Commodore 64 and Apple owners.)

And what makes the Atari so superior to the others? Well, there's the large scale custom integrated circuits that make it all possible. There's the colour indirection from a palette of 256 colours. There's the 6 character graphics modes and the 11 bit-mapped graphics modes which can be mixed and matched anyway you like through custom display lists. There's the operating system's built-in drawing commands. There's the page flipping and the redefinable character set. There's the display list interrupts and the vertical blank interrupts. There's the inimitable Atari player-missile graphics which make animation such a cinch. There's the hardware controlled horizontal and vertical fine scrolling. And there's the pure fascination and excitement of having so much graphics potential at your fingertips!

However, all this graphics power is useless to you unless you have the tools and knowledge to use it. I can't give you the knowledge (that comes from reading every Atari magazine, book and technical manual that you can get your hands on), but I can provide you with a useful tool.

The accompanying program is a colour selection utility that I wrote some years ago and have found invaluable ever since. Simply type in the program, check it with TYPO III and save a copy before running. You don't need any instructions. Everything you need to know is presented on the screen. When typing the program in, be careful of the funny strings in lines 1080 and 1160-1180. I must apologise for these. I wouldn't normally submit a program full of funny characters because I know how hard they are to type in. Unfortunately, I didn't have time to change them.

Design notes

Colour Palette is a very interesting program from a programmer's point of view because of the sheer number of different graphics techniques used in such a short program. I had intended to describe these in some detail, but as I said above, I just ran out of time. You'll have to settle for the following sketchy notes.

Firstly, you should understand that Colour Palette was not just slapped together overnight, but was 'designed'. I gave a lot of thought to the best way to present a colour selection utility and what was the simplest and most intuitive way to use it. I eventually came up with the following goals:

  • Any program initialisation should be instantaneous (or as near as possible).

  • The initial display should include a title, a copyright notice and instructions for the user.

  • The crux of the display should show all 128 colours on the screen at once. (It is not necessary to show the 256 colours available in GRAPHICS 9 as this mode is rarely used and the screen is simply not big enough to display them all adequately.)

  • All the colours should be separated by black dividers to avoid colour bleeding.

  • The 'current' colour should be clearly identified by a cursor which is shaped so as not to obscure the colour underneath. The cursor's colour should alternate between black and white (i.e. flash) so as not to get lost amongst all the other colours.

  • The user should be able to select any colour by simply moving the cursor about with a joystick.

  • It should be possible to use the keyboard as an alternative to the joystick in case you don't have a joystick (highly unlikely), the joystick is busted or not plugged in or you simply prefer using the keyboard. The arrow keys are the obvious choice for cursor movement, but it shouldn't be necessary to press the CONTROL key unless you really want to.

  • Whenever the cursor moves, the value of the new colour should be displayed immediately. It should not be necessary to confirm a selection by (say) pressing the fire button. The colour values should be shown as both POKE values and SETCOLOR values.

  • The cursor should have a short delay after the first move, but should speed up on the following moves until the joystick or arrow keys are released.

  • The program should be crashproof.

  • And finally, it should be fun to use!

The end product uses a plethora of different graphics techniques including player-missile graphics and super fast string manipulation using some fairly standard tricks. The custom display list incorporates character graphics, bit-mapped graphics, blank scan lines and multiple display list interrupts. The latter are synchronised during the vertical blank interrupt. (The assembly language routines are shown in the accompanying listing for anyone interested. You do not have to type these in to use the program. ) Note the mixture of GTIA modes and non-GTIA modes. Who said it couldn't be done?

I think I've achieved my goals from the users' point of view, but some of the code could be improved. The auto-repeat routine is a case in point. Press an arrow key twice in quick succession to see what I mean. One of these days I'll rewrite the whole thing in assembly language. And one of these days I'll win the lottery too...

Anyway, type in Colour Palette and see what you think. I doubt that you'll be disappointed.

Listing

top