Jump to content
  • Advertisement

Archived

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

Kaver

Question about 16-bit high color mode macros

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!