home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 24b / keyboard.zip / SCROLOCK.ASM < prev    next >
Assembly Source File  |  1986-06-17  |  8KB  |  177 lines

  1.          page    60,132
  2.          title   SCROLOCK - routine to activate the scroll lock key
  3.          subttl  (C) Copyright 1984 by System Enhancement Associates
  4.          page
  5. ;
  6. ;        This routine is intended to make the scroll lock key
  7. ;        (uppermost, rightmost key) function as its name implies.
  8. ;        That is, stop the screen from scrolling.
  9. ;
  10. ;        BIOS normally performs this function in response to
  11. ;        control-numlock, for some mysterious reason, but the result
  12. ;        is neither elegant, convenient, nor esthetically pleasing.
  13. ;
  14. ;        This routine works by installing a resident module
  15. ;        that intercepts interrupts for video output.
  16. ;
  17. ;        Once this module is installed, any request for BIOS video
  18. ;        output comes here first. This module first passes the request
  19. ;        on to BIOS, then it checks the status of the scroll lock
  20. ;        toggle (which is maintained but ignored by BIOS). If scroll
  21. ;        lock is on, this routine will loop until it goes off.
  22. ;
  23. ;        Scroll locking action may be turned on and off by re-running
  24. ;        this module.
  25. ;
  26. ;        Two items of interest should be noted:
  27. ;
  28. ;        1)      This routine halts output by stopping the machine
  29. ;                from doing anything at all except wait for scroll lock
  30. ;                to go away. Hence, hitting scroll lock causes the
  31. ;                machine to effectively grind to a halt (the same is
  32. ;                true, however, about control-numlock).
  33. ;
  34. ;        2)      The machine does not, however, grind to a halt until
  35. ;                it tries to output something.  So you can hit scroll
  36. ;                lock, and your machine will continue to run until
  37. ;                it tries to type something.
  38. ;
  39. ;        3)      This module was originally driven by the keyboard
  40. ;                interrupt, and hence was guaranteed to pick up on
  41. ;                a keystroke, but it would occasionally stop the machine
  42. ;                when video output was disabled (thus reducing its
  43. ;                usefulness). This version is much less likely to do
  44. ;                that, but it will not stop output which is being
  45. ;                generated without using BIOS. Such output, however,
  46. ;                generally does not scroll.
  47. ;
  48.          page
  49.  
  50. code     segment
  51.          assume  cs:code
  52.  
  53.          org     100h
  54. scrolock:jmp     setup               ;skip over resident part
  55.  
  56. savevid  dd      ?                   ;old video interrupt
  57.  
  58. lockon   db      0                   ;non-zero when scroll locking enabled
  59.  
  60. newvid:  cmp     ah,50h              ;new video interrupt
  61.          jz      vidhey              ;are we installed?
  62.          cmp     ah,51h
  63.          jz      vidswit             ;turn locking on or off
  64.          jmp     short vidlock       ;else do our thing
  65.  
  66. vidhey:  mov     bx,1954h            ;hey to you, too
  67.          mov     al,cs:lockon        ;say how we are set
  68.          iret
  69.  
  70. vidswit: mov     cs:lockon,al        ;set our on/off switch
  71.          iret
  72.  
  73. vidlock: pushf                       ;get set to fake an interrupt
  74.          call    cs:savevid          ;fake old video call
  75.          push    ax                  ;save BIOS reply
  76.          sti                         ;allow more ints while we work
  77.  
  78. vidloop: cmp     cs:lockon,0         ;see if we are active
  79.          jz      videxit             ;forget it if not
  80.          mov     ah,2                ;check keyboard status
  81.          int     16h
  82.          and     al,10h              ;yes - check for scroll lock
  83.          jnz     vidloop             ;loop as long as it's on
  84.  
  85. videxit: pop     ax                  ;restore old value in ax
  86.          iret                        ;return transparently (we hope)
  87.  
  88. endres:  page
  89. ;
  90. ;        That takes care of the resident portion of SCROLOCK.
  91. ;        Now we do what is needed to get it properly set up and
  92. ;        in place.
  93. ;
  94. grtmsg   db      13,10,'S c r o L o c k     Version '
  95. TED_VERSION DB '2.09',13,10,'Created on '
  96. TED_DATE DB '06/17/86 at '
  97. TED_TIME DB '11:31:02, Our card:',13,10
  98.          db      '┌───────────────────────────────────┐',13,10
  99.          db      '│                                   │',13,10
  100.          db      '│                                   │',13,10
  101.          db      '│   System Enhancement Associates   │',13,10
  102.          db      '│   21 New Street, Wayne NJ 07470   │',13,10
  103.          db      '│                                   │',13,10
  104.          db      '│              Voice: (201) 694-4710│',13,10
  105.          db      '│               Data: (201) 472-8065│',13,10
  106.          db      '└───────────────────────────────────┘',13,10
  107.          db      '(C) Copyright 1984,85,86 by System Enhancement'
  108.          db      ' Associates;'
  109.          db      13,10,'    May be freely distributed.',13,10
  110.          db      13,10,'    Resident portion loaded, Boss!',13,10,'$'
  111.  
  112. onmsg    db      13,10,'Your scroll lock key is now enabled.',13,10,'$'
  113. offmsg   db      13,10,'Your scroll lock key is now disabled.',13,10,'$'
  114.  
  115. install  db      0                   ;non-zero when install must be done
  116.  
  117. setup:   mov     ah,50h              ;yoo hoo!
  118.          int     10h
  119.          cmp     bx,1954h            ;see if we are installed
  120.          je      herenow             ;skip setup if so
  121.          mov     install,1           ;else we must stay resident
  122.  
  123.          mov     ax,3510h            ;read old video output vector
  124.          int     21h
  125.          mov     savevid,bx          ;save offset
  126.          mov     savevid[2],es       ;save segment
  127.  
  128.          mov     dx,offset newvid    ;offset for new video routine
  129.          mov     ax,2510h            ;write new video output vector
  130.          int     21h
  131.  
  132.          mov     dx,offset grtmsg    ;point to greeting
  133.          mov     ah,09h              ;print string
  134.          int     21h
  135.  
  136.          push    ds                  ;set es to our segment
  137.          pop     es
  138.  
  139. herenow: mov     ah,50h              ;get current on/off state
  140.          int     10h
  141.  
  142.          cmp     al,0                ;see if we were on
  143.          jz      turnon
  144.          mov     al,0                ;turn off now
  145.          mov     dx,offset offmsg    ;point to off message
  146.          jmp     short done
  147.  
  148. turnon:  mov     al,1                ;turn on now
  149.          mov     dx,offset onmsg     ;point to on message
  150.  
  151. done:    mov     ah,51h              ;set on/off switch
  152.          int     10h
  153.  
  154.          mov     ah,09h              ;print string
  155.          int     21h
  156.  
  157.          cmp     install,0           ;are we to stay resident?
  158.          jnz     stayres             ;yes
  159.  
  160.          mov     ah,50h              ;get switch setting again
  161.          int     10h
  162.          mov     ah,4ch              ;terminate with error level
  163.          int     21h
  164.  
  165. stayres: mov     ax,offset endres    ;address of end of resident portion
  166.          mov     cl,4                ;shift count
  167.          shr     ax,cl               ;convert length to paragraph count
  168.          mov     dx,ax               ;put paragraph count in dx
  169.          inc     dx                  ;round up
  170.          mov     ah,50h              ;get switch setting again
  171.          int     10h
  172.          mov     ah,31h              ;terminate and stay resident
  173.          int     21h
  174.  
  175. code     ends
  176.          end     scrolock
  177.