Qbasicnews.com

Full Version: Make the BEST simulation EVER!! :D !!!SUPER CHALLENGE!!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
INP takes a port number, and returns the number in that port.

Code:
IF INP(&H60)=1 THEN PRINT "ESC!"
oohhh
so if it = 1, then it has been pressed?
yes.

you can either use INP(96) or INP(&H60). I would recommend learning this before you get to know about multi key handlers. The theory behind the multikey handlers is quite complex.
Cry
weelllllll..... could you give me the code for muilty key and then give a short explination plse?

I think I can handle it
ok

check out this thread: http://forum.qbasicnews.com/viewtopic.php?t=5307

The theory: When a key is pressed, it emits a pressed code. the is basically the scancode(shown in the list before). THis is fine for checking if 1 key is pressed at a time. But of course, when two or more keys are held down, INP(96) can only give the scancode of one of the keys. so this is where the multikey comes in. It detects when a key is pressed, and also when the key is --released--- using a release code. The scancode + 128 = release code for that key. So when the scancode is recieved, the key is marked as being "on". when the release code is detected, the key is marked as being "off".

I suppose its not that complicated... =)
thanks man. I will use that code in my programs now. my friends had been complaining that the current key thing SUCKED! Cry

thanks! :lol:
Quote:weelllllll..... could you give me the code for muilty key and then give a short explination plse?

I think I can handle it

Code:
CLS
DO
I = INP(&H60)
IF (I AND &H80) THEN
  BOARD(I XOR &H80) = FALSE
ELSE
  BOARD(I) = NOT FALSE
END IF
DEF SEG = &H40: POKE &H1C, PEEK(&H1A)
LOCATE 1, 1: PRINT "Arrow up:    "; BOARD(72); "   "
LOCATE 2, 1: PRINT "Arrow down:  "; BOARD(80); "   "
LOCATE 3, 1: PRINT "Arrow right: "; BOARD(77); "   "
LOCATE 4, 1: PRINT "Arrow left:  "; BOARD(75); "   "
LOCATE 6, 1: PRINT "Esc to exit."
LOOP UNTIL BOARD(1)

Make sure Num Lock is off.
This works well for me, unless there's alot of time between the
key handler and the code calling it. (The keys will stick.)
Anyways, that's just a quick example, but I'm going to find a solution to the sticky key problem, sometime soon.
If I resolve this problem I'll post the code here.

Cya.
Why dont you clear the keyboard buffer? The sticking problem will dissappear =P.
Pages: 1 2 3 4