0x8000??????
-
Hi there SHORT nState = GetAsyncKeyState(VK_CONTROL); BOOL bDown = (nState & 0x8000); what does 0x8000 mean and where can i find the infomation? By the way, What does (nState & 0x8000) mean? Thanks
0x8000 is a hexadecimal number equal to 32768 in decimal or 1000000000000000 in binary. The value returned by GetAsyncKeyState() has bit 15 set if the key is down. However, since the value is a 16-bit SIGNED integer, a more intuitive way would be to code it like this:
SHORT nState = GetAsyncKeyState(VK_CONROL);
BOOL bDown = (nState < 0);If the state is less than 0, the key is pressed, otherwise it is released. Hope this helps,
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Hi there SHORT nState = GetAsyncKeyState(VK_CONTROL); BOOL bDown = (nState & 0x8000); what does 0x8000 mean and where can i find the infomation? By the way, What does (nState & 0x8000) mean? Thanks
-
0x8000 is a hexadecimal number equal to 32768 in decimal or 1000000000000000 in binary. The value returned by GetAsyncKeyState() has bit 15 set if the key is down. However, since the value is a 16-bit SIGNED integer, a more intuitive way would be to code it like this:
SHORT nState = GetAsyncKeyState(VK_CONROL);
BOOL bDown = (nState < 0);If the state is less than 0, the key is pressed, otherwise it is released. Hope this helps,
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
Intuitive?? :-D The bitmask is better, since it doesn't rely on SHORT being typedef-ed to a signed quantity. I know it should be, but hey, I've still got code from Win3.1 that works, and one day when I have a 64 bit processor, I might port it... :laugh: Steve S
-
Intuitive?? :-D The bitmask is better, since it doesn't rely on SHORT being typedef-ed to a signed quantity. I know it should be, but hey, I've still got code from Win3.1 that works, and one day when I have a 64 bit processor, I might port it... :laugh: Steve S
Ok, ok. So I find it more intuitive :rolleyes:
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Ok, ok. So I find it more intuitive :rolleyes:
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
and I for one, will defend your right to say so. In my day, of course, one would have done a shift operation (or was that a rotate left? Ah, that's why I've stopped writing assembly code:-O ) and tested the carry flag... :sigh: Steve S
Steve S wrote: In my day, of course, one would have done a shift operation (or was that a rotate left? Either one would work, as long as you used a 16-bit shift ;) BTW, what do you mean your day?? I'm 23, and still write assembler :P
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Steve S wrote: In my day, of course, one would have done a shift operation (or was that a rotate left? Either one would work, as long as you used a 16-bit shift ;) BTW, what do you mean your day?? I'm 23, and still write assembler :P
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
But you are young and think it is cool to do ASM. Back in OUR day we had to. ;) Tim Smith I'm going to patent thought. I have yet to see any prior art.
Tim Smith wrote: you are young and think it is cool to do ASM. Wrong. I do VC++ mainly, but I also do a lot of embedded programming - not much choice there... ;)
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Tim Smith wrote: you are young and think it is cool to do ASM. Wrong. I do VC++ mainly, but I also do a lot of embedded programming - not much choice there... ;)
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
Ah. Embedded programming. Fitting lots of functionality into a small device (in terms of memory and sometimes processor speed). Imagine having to do that *all* the time, when 32Kb was expensive, and mass-storage meant paper-tape... Of course, it meant viruses were easier to spot - if your executable size went up more than a few bytes, it probably wouldn't run anymore;P Steve S