MULTICOLOR GRAPHICS ON THE PLUS/4 By James Hehl This article was inspired by the recent work that I have been doing with the Multicolor (GRAPHIC3) area, on the Plus/4. It is not the "Final Word" on this subject as very little has been done with this mode, on the Plus/4. I simply thought that you might use this information as a start, in your own efforts to utilize Multicolor mode. By the way, much of what will be discussed applies to the C128 as well. There are several files that will accompany this article. Most of them are graphic files that were converted either from Koalas, or from Micro Illustrator graphics. I'd like to point out that if you have Micro Illustrator C64-Plus/4, you'll quickly find out that the resulting files are sometimes NOT color compatable. True hi-res bitmaps like Doodle! can be translated into Plus/4 files without any loss of pixels or colors, for the most part. Multicolor bitmaps, however, cannot be easily translated. The C-64 uses foreground/background colors from the video matrix, screen background from a background register, and an "extra" color from its color nybbles. That is to say, it uses three independent RAM based colors and one register color for each character cell. The Plus/4 uses foreground/background colors from its video matrix, but both screen background and "extra" colors come from color registers. Here, there are only two independent RAM based colors and two register colors for each character cell. This sounds like there is a lot of color incompatability, but most four color Koalas can be translated with little or no loss. You may have to "tweak" the proper color values a bit, as there are actual colors on the Plus/4, in the place of the three shades of grey on the C64/C128. In Multicolor mode, the Plus/4 has a screen resolution of 160x200. That is half of the possible resolution of High-Resolution mode (GRAPHIC1). That is because each pair of dots on the screen is controlled by a pair of bits in memory (32,000 pairs of pixels), rather that each pixel being individually controlled by a single bit as in Hi-res mode. In Mutlicolor mode, color flexibility has been improved by the addition of two "global" colors. In each byte if the bitmap, the HIGH 2 bits will determine the color of the pair of pixels on the left side. The LOW 2 bits will determine the color of the pair on the right side. The color bits are set as follows: BIT PAIR LUMINANCE SOURCE COLOR SOURCE -------------------------------------------- 00 $FF15 (65301) $FF15 01 low nybble of lum. high nybble of color 10 high nybble of lum. low nybble of color 11 $FF16 (65302) $FF16 Let's not worry about trying to figure out what the above table represents, at present. That will be the subject of the next article on multicolor mode, along with using multicolor from machine language. For now, let's just experiment with a multicolor graphic from BASIC. The easiest way of entering into multicolor mode, on the Plus/4, is to type GRAPHIC3 and them press the Return key. There are two parameters that can be added with a comma after the GRAPHIC3 command. GRAPHIC3,0 is the default when you simply type the GRAPHIC3 command. It will kick your Plus/4 into multicolor mode but the screen will be filled with garbage, unless you have previously loaded a multicolor bitmap. The second parameter is GRAPHIC3,1 which will clear out the garbage and display a blank screen. The GRAPHIC3,1 command is also useful to erase a bitmap in memory, when you want to start fresh and load a new one. An overview of what is happening is this: Normally, on the Plus/4, the start of BASIC is at 4097 ($1001), color memory is at 2048 ($800) and screen memory resides at 3072 ($C00). When the GRAPHIC command is used, the start of BASIC is shifted to 16384 ($4000), color memory is placed at 7168 ($1C00) and screen memory is re-expressed as a luminance matrix at 6144 ($1800). This action clears out the area of memory that will be necessary to load your graphic file into. The C128 uses a similar method and the GRAPHIC command. The graphic files, included with this article were converted from both Koala and Micro Illustrator files. The differences in formats is, for the most part, the differences in memory where the bitmap, color and video matrix are stored. These locations are: KOALA Micro Illus. --------------------------------------- BITMAP 24756 ($6000) 8384 ($20C0) COLOR INFO 33576 ($8382) 6384 ($18F0) VIDEO INFO 32576 ($7F40) 7384 ($1CD8) There is also a memory location in each of these formats that holds the value for the Background Color, they are 34576 for Koala and 6364 for Micro Illustrator. This value can be PEEKed and then POKEd into the registers that control the colors for the background (screen) and the border, like so: For Koalas - POKE65301,PEEK(34576) For Micro I - POKE65301,PEEK(6364) You may also want to POKE the background color into the border register at 65305. With this quick overview out of the way, I guess it's time to try out the demo files. You may simply LOAD and RUN them if you'd just like to look at them. If you'd like to play with them a bit, I'd suggest that you have a disk handy with space enough to hold a couple of 49 disk block files and a couple of 40 disk block files. The demos on this disk have been crunched to save Jack some disk space (this was done with a custom cruncher I've written for the Plus/4). The names of the files are: MISSIONDEMO.CMP and BETTYDEMO.CMP After Running and viewing the demo graphics, just press any key to exit. You may use the DSAVE command , as usual, to SAVE the uncrunched (49 block) demo file. If you'd like to grab just the graphic file at this point, for further experimenting, then type: RUN100 and press Return. The actual graphic file (BITMAP, CM and VM) will be saved as a 40 block file with the name of the demo, with a .BMP suffix. Go ahead and LIST the program and you'll see how the program was set up to display the graphics. It is REMed to make it easiy to follow. The first part of the program gets the values for the screen, border and foreground colors to be POKEd into the proper registers. I've placed the values in these demo files, in an unused area at the end of the bitmap, for your convenience. That operation is as follows: 5 POKE65301,PEEK(16192):REM SCREEN 7 POKE65305,PEEK(16193):REM BORDER 8 POKE65302,PEEK(16194):REM FOREGROUND Lines 10 to 20 call the GRAPHIC3 command to put your Plus/4 into Multicolor mode, waits for any key to be pressed and then kicks back into Text mode: 10 GRAPHIC3 15 GETA$:IFA$=""THEN15 20 GRAPHIC0:GRAPHICCLR The GRAPHICCLR command isn't really necessary, except that its function is to shift the start of memory back to the normal 4097 ($1001) position. Lines 30 to 60 restore the default Plus/4 screen colors and end the program: 30 POKE65301,112:REM DEFAULT SCREEN 40 POKE65305,110:REM DEFAULT BORDER 50 POKE1339,16:REM DEFAULT CHARACTER 60 END When you RUN line 100, the area of memory from 6144 ($1800) to 16384 ($4000) is saved as a file to your disk (by the way, this line can be used to save ANY area of memory to a file by substituting the proper values): 100 SYS43115"filename",8,0:POKE178,0 :POKE179,24:POKE157,68:POKE158,63 :SYS61860 The format is start of memory area to save POKE178,(low byte):POKE179,(hi byte) and end of area to be saved POKE157,(low byte)+1:POKE158,(hi byte). The 40 disk block file that this routine makes, will LOAD into the proper area of your Plus/4's memory to be viewed or played with. Use the syntax: LOAD"filename",8,1 to do this. If you'd like to load this graphic from within a BASIC program, then you may do it with the following line: 10 SYS43115"filename",8,0:POKE2034,0 :POKE2035,0:POKE2036,24:sys65493 :GRAPHIC3 Then you can POKE the screen, border and foreground colors from the file or insert the colors of YOUR choice. The file BETTYBOOP.BMP file, for example, can be colored with the PEEKs (as outlined above) or using the COLOR commands. They are: COLOR0,x,x = POKE65301,x COLOR4,x,x = POKE65305,x COLOR3,x,x = POKE65302,x The Plus/4 gets it's 120+ colors by adjusting the brigthness (luminance) of the basic 16 colors available. The manual claims 128 colors... but one of these is the color BLACK (and the eight possible shades of BLACK are still BLACK!). There are eight luminance levels of each color (numbered 0 to 7). this is the third parameter following the COLOR command. The first is the color register number (the 0, 4 and 3 above). The second parameter is the basic color number. The third is the brightness of that color. So a value of 2 (white) as the second parameter in the command will change the color registers value to white. If you are happy with a bright white, then you do not have to use the last parameter at all. The Plus/4 will default to the highest value of brightness, of a given color, if you don't enter a third parameter. COLOR4,2 (white border) is the same as COLOR4,2,7. If you want a darker shade of white (grey) then use the last parameter to adjust the luminance of your color. COLOR4,2,6 will give a light grey and COLOR4,2,0 will give the darkest shade of grey. Getting back to the BETTYBOOP file, the proper colors to use for viewing are: COLOR0,2,7:COLOR4,1,1:COLOR3,9,5 If you'd prefer to POKE directly to the registers (65301, 65305, etc) you will note that there is only one value that you can poke there. How to calculate the proper value to POKE there, if you are using two parameters in the COLOR statement? Simply use the following formula to do it: Luminance * 16 + color# + 1 (0-7) (1-16) This will give you the proper conversion of the two parameters, in the COLOR statement, to POKE into the register. I've about run out of room for this article. What you might do is to experiment with the files that have been provided. When you have them in memory and are back in text mode, just type in: 10 COLOR0,x,x:COLOR4,x,x:COLOR3,x,x :GRAPHIC3 20 GETA$:IFA$=""THEN20 30 GRAPHIC0 Then substitute the color and luminance values that you'd like to try. RUN the program and check them out. When you hit any key, you'll exit back to the "Ready" screen. Then you may LIST the lines, change them and re-RUN the program to see the results. I'll continue this article with a bit deeper look at the workings of your Plus/4, in the graphic modes. We'll get into accessing them from machine language. We will also look at the split-screen modes that are available in both Hi-res and Multicolor, on your Plus/4. We will use a machine language color corrector, to allow us to use GG and Koala file, directly. Finally, there will be an 80 column emulator for your Plus/4. Enjoy and hang in there!