home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / KSPEED.ASM < prev    next >
Assembly Source File  |  1991-08-16  |  7KB  |  142 lines

  1. ; File......: KSPEED.ASM
  2. ; Author....: James R. Zack
  3. ; CIS ID....: 75410,1567
  4. ; Date......: $Date:   15 Aug 1991 23:06:54  $
  5. ; Revision..: $Revision:   1.2  $
  6. ; Log File..: $Logfile:   E:/nanfor/src/kspeed.asv  $
  7. ;
  8. ; This is an original work by James R. Zack and is placed in the
  9. ; public domain.
  10. ;
  11. ; Modification history:
  12. ; ---------------------
  13. ;
  14. ; $Log:   E:/nanfor/src/kspeed.asv  $
  15. ;  
  16. ;     Rev 1.2   15 Aug 1991 23:06:54   GLENN
  17. ;  Forest Belt proofread/edited/cleaned up doc
  18. ;  
  19. ;     Rev 1.1   14 Jun 1991 19:54:40   GLENN
  20. ;  Minor edit to file header
  21. ;  
  22. ;     Rev 1.0   01 Apr 1991 01:03:28   GLENN
  23. ;  Nanforum Toolkit
  24. ;  
  25. ;
  26.  
  27.  
  28. ; $DOC$
  29. ; $FUNCNAME$
  30. ;     FT_SETRATE()
  31. ; $CATEGORY$
  32. ;     Keyboard/Mouse
  33. ; $ONELINER$
  34. ;     Set the keyboard delay and repeat rate on PC/AT & PS/2
  35. ; $SYNTAX$
  36. ;     FT_SETRATE( [ <nDelayTime> ] [, <nRepeatRate> ] ) -> NIL
  37. ; $ARGUMENTS$
  38. ;     <nDelayTime> is the keyboard delay time.
  39. ;
  40. ;     <nRepeatRate> is the keyboard repeat rate.
  41. ;
  42. ;          ┌───────────────────────┐  ┌────────────────────────┐
  43. ;          │ nDelayTime      DELAY │  │ RepeatRate      SPEED  │
  44. ;          ├───────────────────────┤  ├────────────────────────┤
  45. ;          │     0           250ms │  │    0           30.0cps │
  46. ;          │     1 (default) 500ms │  │    1           26.7cps │
  47. ;          │     2           750ms │  │    2           24.0cps │
  48. ;          │     3          1000ms │  │    3           21.8cps │
  49. ;          └───────────────────────┘  │    4           20.0cps │
  50. ;                                     │    5           18.5cps │
  51. ;                                     │    6           17.1cps │
  52. ;                                     │    7           16.0cps │
  53. ;                                     │    8           15.0cps │
  54. ;                                     │    9           13.3cps │
  55. ;                                     │   10           12.0cps │
  56. ;                                     │   11           10.9cps │
  57. ;                                     │   12 (default) 10.0cps │
  58. ;                                     │   13            9.2cps │
  59. ;                                     │   14            8.6cps │
  60. ;                                     │   15            8.0cps │
  61. ;                                     │   16            7.5cps │
  62. ;                                     │   17            6.7cps │
  63. ;                                     │   18            6.0cps │
  64. ;                                     │   19            5.5cps │
  65. ;                                     │   20            5.0cps │
  66. ;                                     │   21            4.6cps │
  67. ;                                     │   22            4.3cps │
  68. ;                                     │   23            4.0cps │
  69. ;                                     │   24            3.7cps │
  70. ;                                     │   25            3.3cps │
  71. ;                                     │   26            3.0cps │
  72. ;                                     │   27            2.7cps │
  73. ;                                     │   28            2.5cps │
  74. ;                                     │   29            2.3cps │
  75. ;                                     │   30            2.1cps │
  76. ;                                     │   31            2.0cps │
  77. ;                                     └────────────────────────┘
  78. ; $RETURNS$
  79. ;    NIL
  80. ; $DESCRIPTION$
  81. ;    This routine is used to adjust the IBM PC/AT and PS/2 "typematic"
  82. ;    repeat and delay feature.  This is used to allow the users of your
  83. ;    application to adjust these speeds to the most comfortable level.
  84. ;
  85. ;    This source code is written for Microsoft Assembler v5.1.
  86. ; $EXAMPLES$
  87. ;    FT_SETRATE(0,0)    // Set keyboard to fastest possible settings
  88. ;    FT_SETRATE()       // Set keyboard to AT defaults (10.9cps,500ms delay)
  89. ;    FT_SETRATE(11,1)   // Set keyboard to PS/2 defaults (10cps,500ms delay)
  90. ; $END$
  91.  
  92. PUBLIC     FT_SETRATE                   ; MAKE ROUTINE VISIBLE
  93.  
  94. EXTRN      __PARNI:FAR                  ; DECLARE EXTERNALS
  95. EXTRN      __RET:FAR
  96. EXTRN      __PARINFO:FAR
  97.  
  98. _NANFOR   SEGMENT       'CODE'
  99.            ASSUME        CS:_NANFOR     ; POINT CS TO MY CODE
  100. FT_SETRATE PROC          FAR
  101.            PUSH          BP             ; SAVE BASE POINTER
  102.            MOV           BP,SP          ; POINT TO TOP OF STACK
  103.            PUSH          DS             ; SAVE REGISTERS
  104.            PUSH          ES
  105.            PUSH          SI
  106.            PUSH          DI
  107.            MOV           AX,0           ; LOOK AT NUMBER OF PARAMS PASSED
  108.            PUSH          AX             ; SET UP FOR __PARINFO
  109.            CALL          __PARINFO      ; GET NUMBER OF PARAMS PASSED
  110.            ADD           SP,2           ; ADJUST STACK
  111.            CMP           AX,2           ; WERE BOTH PARMS PASSED?
  112.            JL            DEFAULTS       ; NO, USE DEFAULTS
  113.            JMP           GETPARMS       ; OTHERWISE, LETS GET SOME PARAMS.
  114. DEFAULTS:  MOV           BX,010CH       ; SET UP DEFAULTS (for AT)
  115.            jmp           goodparm       ; and make the int call.
  116. getparms:  mov           ax,01h         ; First param is repeat rate
  117.            push          ax             ; Set up for __PARNI
  118.            call          __PARNI        ; Get first param
  119.            add           sp,2           ; Adjust stack
  120.            mov           bl,al          ; Put repeat rate into BL
  121.            cmp           bl,20h         ; Is BL > 20h? (max value)
  122.            jg            defaults       ; Yes, then use defaults
  123.            mov           ax,02h         ; Second parm is typeamatic delay
  124.            push          ax             ; Set up for __PARNI
  125.            call          __PARNI        ; Get second param
  126.            add           sp,2           ; Adjust stack
  127.            mov           bh,al          ; Put delay into BH
  128.            cmp           bh,04h         ; Is BH > 04h (max value)
  129.            jg            defaults       ; Yes, then use defaults
  130. goodparm:  mov           ax,0305h       ; BIOS Function 03 Subfunction 05
  131.            int           16h            ; Set Typematic Rate and Delay
  132. exit:      pop           di             ; Retore registers
  133.            pop           si
  134.            pop           es
  135.            pop           ds
  136.            pop           bp
  137.            call          __RET          ; Clean up for Clipper
  138.            ret                          ; Pass control back to Clipper
  139. FT_SETRATE ENDP
  140. _NanFor    ENDS
  141.            END
  142.