Skip to main content
gamedev.net
🔒 Locked

converting values

Started by Wilhelm van Huyssteen Dec 23, 2008 at 9:39 AM 2 replies 600+ views
Original Post
Wilhelm van Huyssteen
Wilhelm van Huyssteen
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
bitshifter
bitshifter
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.
alvaro
alvaro
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.