Jump to content
  • Advertisement
Sign in to follow this  
EternityZA

converting values

This topic is 3614 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

hey. im currently fooling around with emulation. more specifick im trying to emulate the Chip-8 that was used long ago to power some of the first game consoles anyway. im at a point where i have 2 sequential bytes in a array and of those 2 bytes i need to get the decimal value of the last 12 bits. in other words i want to ignore the first 4 bits of the first byte. now this sounds pretty simple but i need this to be as fast as possible and im not quite sure how to do this properly since im not used to such low level stuff. im writing this thing in java but i dont mind a c/c++ explanation thnx in advance

Share this post


Link to post
Share on other sites
Advertisement
Is this an 8bit processor your are playing with?
Do you have a bit format table for 2byte decimals?
In C/C++ the smallest decimal is of type 'float'
which is four bytes in size.
The only way to do it in these languages is to
use a 2byte value with some fancy masks/shifts.

Share this post


Link to post
Share on other sites
sixteen_bit_value = (first_byte << 8) + second_byte;

twelve_bit_value = sixteen_bit_value & 0x3f;


EDIT: I don't know why you think you need the "decimal value" of this number. You probably don't.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!