• Please review our updated Terms and Rules here

SCREEN (Graphics) OPTIONS IN BASIC PROGRAM RUNNING ON IBM5155 COMPUTER

Since I am just learning to program graphics I should probably stick to BASIC ! I have worked out all the states for the color select register on the CGA card in screen 1 mode (320 x 200 graphics mode), for the 6 control bits and I can write to them to get any of the 8 background colors, intensified or not, the two text colors (yel or white), the selection of which by the 6th bit (or by writing 32 to the register) also flips it between the two color sets, either the Cyan, magenta, white one or the red,green,brown one. And I can get the same results with BASIC OUT commands, writing to the register directly at hex 3D9.
But there is something here I'm not sure of: When I'm in one of the color sets, say green, red, brown so far I have only been able to select from those colors within that set with a BASIC instruction like LINE (X, Y)-(X+A, Y+B),Q,BF say to draw a filled box where Q is either 1, 2 or 3 to select either green red or brown from the color set. There are two bits of a register (called C0 & C1 in the CGA graphics card manual ) that the BASIC command is controlling which I think might be in the 6845 CRT controller register. It is a two step command using address 3D4 and 3D5 but so far I haven't figured out the BASIC syntax (for writing directly to the register with an OUT command) to get the C0,C1 bits to change state....or maybe C0,C1 is elsewhere?
 
Last edited:
Yes, the COLOR command has the format in this case of COLOR A,B where A sets the background color and B can either be 0 or 1. Zero (or any even value entered) sets the text to yellow and simultaneously sets the color set to Red,Green,Brown. Setting it to 1 (or any odd number) selects the other color set Cyan,Magenta,white and sets the text to white. By trying to add another parameter to COLOR, like the format A,B,C (used in text modes where A is background,B is text color and C is border) didn't help selecting a color from inside the color set of either group three colors. I need to find the C0,C1 register so I can write to it directly....as noted there is a way to do it with the LINE command in BASIC, but it would be better to know how to modify it directly at the register.
 
Last edited:
Trixter, thanks for that link. Even with that info it doesn't answer my question, so my question might be defective or poorly posed.

I'll explain how I came to this question might help;

I wrote a brief program to draw a box on the screen in 320 x 200 graphics mode, selecting one color from the palette using the LINE command when the box was drawn for each new screen. Then I organised it to cycle through every possible state of the color control register, by writing to its address (decimal values 0 to 63 to manipulate all 6 bits), then with a time delay, so I could see on the screen every possible color combination for background, text and a new drawn graphic. I made a spread sheet for later use.

Of course by the time the count is 32 sent to the color control register, it switches to the alternate palette color, so the new drawn graphic changes to that and at the same time the text color changes from yellow to white and aside from intensifying the graphic & text and cycling through the background colors etc, there is no change in the palette color for the remainder of the count.. from 32 to 63.

Therefore I noticed that while the color control register can switch between alternate palettes, no bit in that register is responsible for selecting the color from within the palette.

Its not clear (to me) from the data on the CGA card registers where the physical register is that selects from the 4 possible states within a palette, exactly how to write to it with an OUT command, and it is not in the color control register it appears.

The BASIC program designers must know because the LINE command enables individual selection of the colors within a Palette at the time the graphic is drawn.

Can you give me an example of how you select between colors within a palette with a processor OUT command ?
 
The color used is whatever value you write to video memory. You don't need to "select" a color. If you are using BASIC to draw the graphics, you specify this value with your PSET/LINE/CIRCLE statement. BASIC has an internal "active color" variable so it will remember the last color and use that if you don't specify one.
 
Back
Top