home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / NFSRC305.ZIP / ASM / KSPEED.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-01  |  6.2 KB  |  137 lines

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