'=========================================================================== ' Subject: KEYBOARD PORT TO SET DELAY Date: 07-01-97 (19:00) ' Author: Robert Fortune Code: QB, QBasic, PDS ' Origin: Ethan Winer's BASIC Techniques Packet: KEYBOARD.ABC '=========================================================================== '>I am making this "action"-game, where you have to avoid asteroids to get '>points. However, I don't know how to get rid of keyboard delay, which is '>VERY disturbing in a game like this. Does anyone know to get completely '>rid of it? I have gotten it to minimum with DOS-command: '>"mode con rate=32 delay=1", but there is still delay. Can anyone help '>me? ' From Ethan Winer's book "BASIC: Techniques and Utilities" (available ' in freeware form in the WINER.ZIP file): ' Keyboard Ports ' There are several ports associated with the keyboard, and one is of ' particular interest. The enhanced keyboards that come with AT-class ' and later computers allow you to control how quickly keystrokes are ' repeated automatically. There are actually two values - one sets the ' initial delay before keys begin to repeat, and the other establishes ' the repeat rate. By sending the correct values through the keyboard ' port, you can control the keyboard's typematic response. The complete ' program that follows shows how to do this, and Table 10.3 shows how ' the delay and repeat values are determined. OUT &H60, &HF3 ' get keyboard's attention FOR D& = 1 TO 100 ' brief delay to give the hardware time to settle NEXT Value = 7 ' 1/4 second initial delay, 16 CPS OUT &H60, Value ' Table 10.3 shows only some of the possible values that can be used. ' However, you can interpolate additional values for delay times and ' repeat rates between those shown. ' Table 10.3 ' Sample Values for Setting the initial and Repeat Rate on AT-Style Keyboard ' -------------------------------------------------------------------------- ' Initial Delay 0.25 0.50 0.75 1.00 ' 30 characters per second 00 20 40 60 ' 16 characters per second 07 27 47 67 ' 8 characters per second 0F 2F 4F 6F ' 4 characters per second 17 37 57 77 ' 2 characters per second 1F 3F 5F 7F ' Note: All values are shown in hexadecimal ' ---------------------------------------------------------------------------