Advertisement

Question about 16-bit high color mode macros

Started by September 13, 2002 11:21 AM
3 comments, last by Kaver 22 years, 2 months ago
I am just reading up on the 16 bit high-color mode macros and I dont understand a few things. They are: 1) In the macros themselves which read like this: #define _RGB16BIT555(r,g,b) ((b%32) + ((g%32) << 5) + ((r%32)<< 10)) (a)what is happening with b%32? (b)and with ((g%32) << 5) why is there an << operator there? 2) Also the author in the ebook that I have keeps refering to WORD in the macro but I don't see any WORD declared in the macro. Where is this WORD? The ebook that I have is "Tricks of the Windows Game Programming Guru's" by Andre LaMothe. Thanks [edited by - Kaver on September 13, 2002 12:24:24 PM]
When the world has got you down, that's when you strike back and show them who you really are.
1)
% is the operator for calculating the division remainder (i''m not sure if thats how you say it in english
<< shifts some bytes
Advertisement
I explain it all in this thread.

***********************
          
Ok, lets see if I can answer some questions. As the AP said % is used to find the remainder when dividing two numbers. So in the example you provided b%32 will always return a number between 0 and 31 since any number divided by 32 will have a remainder between 0 and 31. If you dont believe me pick some numbers and divide them by 32 to see what happens.

<< is the left shift operator and is used for binary shifting. For example if I had this
num = 00001001 (9 for those of you who dont know binary)
num << 4 (shifts num 4 places to the left)
Num will now be 1001000


WORD is defined in some windows header file and is simply used as an easy way to define a 16 bit unsigned integer.

Hope all that helps some.
"Pfft, Facts! Facts can be used to prove anything!" -- Homer J. Simpson
Hello,

Thank you for all your replies it has actually cleared up this macro a bit. I''ll play around with it until I get it. Again thanks for clearing it up.
When the world has got you down, that's when you strike back and show them who you really are.

This topic is closed to new replies.

Advertisement