JK> CB>> if (inp(0x64) & 1) // same as kbhit()
JK> He's inputing, not outputing, so there's NP there.
JK> I would recomend him to use kbhit() instead...
Eek!
If kbhit() is not available, you CAN use the keyboard
hardware port, but not like THAT! ;)
You want to look for a change in the port status.
int key = inp(0x64), alarm = 0;
while(key == inp(0x64))
{
alarm = (alarm + 1) & 1023;
printf"\rHit a key dagnabbit!!%c", alarm ? ' ' : '\a');
}
This will read the port status at the beginning of the code
block, and test the port to see if anything changes.
If something does, then a key has been hit or released.
This would be useful if you have no kbhit() and have no way
of knowing where the keyboard buffer will be located, but
DO know where the keyboard hardware port is.
You could write a kbhit() function from this.
int my_kbhit(int init = 0)
{
static int port_status;
if(init)
port_status = inp(0x64);
return (port_status != inp(0x64);
}
You would still need to initialize it, however.
> ] Those who don't learn from the past are... Rats! I forgot...
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|