Public Group

#### Archived

This topic is now archived and is closed to further replies.

# Question about 16-bit high color mode macros

This topic is 5937 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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]

##### Share on other sites
1)
% is the operator for calculating the division remainder (i''m not sure if thats how you say it in english
<< shifts some bytes

##### Share on other sites
I explain it all in this thread.

***********************

##### Share on other sites
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.

##### Share on other sites
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.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633734
• Total Posts
3013590
×