I am now reading #4 of Icztutes. How do you know what values to put into the macro below to come out with the color you want? How would you get Purple, Gray, or Orange? I would like to understand the principle to create colors.

RGB macro red,green,blue
xor eax,eax
mov ah,blue
shl eax,8
mov ah,green
mov al,red

Thank You,
Posted on 2002-12-16 05:49:51 by bgong68
Different amounts of red, blue, green create the different colors. Though I am not pretty sure how much of red,blue or green is needed to create orange. The principle of mixing color would probably be the usage of different amounts of red,blue and green.
Posted on 2002-12-16 06:49:02 by roticv
Just open up your favorite paint editor (not paint) like PSP or Photoshop. Pick a color and have a look at the numbers for blue, green and red. There'a also a ColorPicker on Iczelions site (iirc) which gives you back those values after you picked a color. I generally hardcode any colors needed when they aren't changing during program execution. :)

PS: Also there's a RGB macro here on the board somewhere which does all the calculations during the compiling so you don't really need the macro at all.
Posted on 2002-12-16 07:16:19 by JimmyClif
Well since 100%red and 100%green is yellow, then orange would be halfway between the two along the hue line, so orange = 100%red and 50%green. Or in HTML terms, #FF8000.

Posted on 2002-12-16 07:26:18 by iblis
Hi bgong68,
Colors on a CRT are additive. In some other filter based color systems, they are subtractive. Your CRT has three electron guns that each activate one of three color phosphers (RGB) on your screen. Those RGB numbers designate how much current each color gun uses to excite its designated phospher. Zero means no current and 255 means the maximum current allowed by the hardware settings.

Included in the zip file are two programs I transcribed from C to Asm from Charles Petzolds's book, Programming Windows. WHATCOLR is a cursor that you put over any color on the screen, and it tells you what the RGB values are in hex and decimal. COLORS1 is a program that lets you mix and match whatever values you want with the three scrollbars. Between those two programs, you should be able to tune into whatever color you want.

Why are you using a macro that generates code to be executed?? MASM or any other assembler should be able to figure out the values needed for either a EQU or DD directive. TEST.ASM included in the zip file shows how this is done. Notice that the code needed must be assembled in the opposite order (BGR) order within a DWORD. The leftmost byte of the DWORD is zero. Ratch
Posted on 2002-12-16 14:04:45 by Ratch
Hi Ratch,
Thanks for the examples. I will be able to experiment with the color combos now to get the color I want. I use the macro because that was the example I saw in #4 of Icztutes.
Posted on 2002-12-17 05:54:29 by bgong68
Thanks for all the help everyone.
Posted on 2002-12-17 05:56:16 by bgong68