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
Windows 98 simulator

Code:
COLOR 15,1:CLS
1 GOTO 1
Quote:Why dont you clear the keyboard buffer? The sticking problem will dissappear =P.

I do clear the KB buffer...

DEF SEG = &H40: POKE &H1C, PEEK(&H1A)

Do I need to clear it using another method?
(K$=INKEY$ would be slower by the way.)
Thank SJ for this. Try it out =P.

Code:
DECLARE FUNCTION KEYSPRESSED$ ()

DIM SHARED Keyflag%(0 TO 127)
DO
  
    li% = i%
    i% = INP(&H60)
    IF i% = 170 OR i% = 54 OR i% = 42 THEN FOR a = 0 TO 127: Keyflag%(a) = 0: NEXT a
    IF (i% AND 128) THEN Keyflag%(i% XOR 128) = 0
    IF (i% AND 128) = 0 THEN Keyflag%(i%) = -1
    WHILE INKEY$ <> "": WEND
    IF i% = 1 THEN END

  IF i% <> li% THEN
    LOCATE 1, 1: PRINT KEYSPRESSED$
  END IF
  IF ext% THEN EXIT DO
LOOP
END

FUNCTION KEYSPRESSED$
  'A string of all the keys curently being pressed
  kp$ = ""
  FOR k% = 0 TO 127

    IF Keyflag%(k%) THEN
      kpa$ = LTRIM$(RTRIM$(STR$(k%))): kl% = LEN(kpa$)
      kpa$ = "*" + kpa$
      kp$ = kp$ + kpa$
    END IF
  NEXT k%
  kp$ = kp$ + "*"
  lk% = LEN(kp$)
  kp$ = kp$ + (SPACE$((40 - lk%)))
  KEYSPRESSED$ = kp$
END FUNCTION
Pages: 1 2 3 4