home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / FIXLOK.ZIP / FIXLOCK.ASM next >
Assembly Source File  |  1987-09-14  |  5KB  |  373 lines

  1.     TITLE fixlock
  2.  
  3. ;scan codes
  4. CAPS_LOCK    equ    3ah
  5. NUM_LOCK    equ    45h
  6. SCR_LOCK    equ    46h
  7. SYSREQ        equ    54h
  8.  
  9. _text    segment
  10.     assume cs:_text, ds:_text, ss:_text
  11.     org    100h
  12.  
  13. start:
  14.     jmp    begin
  15.  
  16. oldint9        dd    0
  17. oldint28    dd    0
  18.  
  19. myint9    proc    far
  20.     pushf
  21.     push    ax
  22.  
  23.     in    al,60h
  24.  
  25.     cmp    al,SYSREQ
  26.     jne    testit
  27.     mov    cs:[was_sysreq],1
  28.     jmp    short continue
  29.  
  30. testit:
  31.     cmp    cs:[mode_type],0
  32.     jne    continue
  33.  
  34.     and    al,7fh
  35.     cmp    al,CAPS_LOCK
  36.     je    ignore
  37.     cmp    al,NUM_LOCK
  38.     je    ignore
  39.     cmp    al,SCR_LOCK
  40.     jne    continue
  41. ignore:
  42.     mov    al,20h
  43.     out    20h,al
  44.     pop    ax
  45.     popf
  46.     iret
  47. continue:
  48.     pop    ax
  49.     popf
  50.     jmp    dword ptr cs:[oldint9]
  51.  
  52. myint9    endp
  53.  
  54. onmode    db 'ON ',0
  55. offmode    db 'OFF',0
  56. mode_len equ    3
  57.  
  58. msg_1    db    '┌────────────────────────────┐',0
  59. msg_2    db    '│ Current Lock Status: ___   │',0
  60. msg_3    db    '│                            │',0
  61. msg_4    db    '│  Type SpaceBar to Change   │',0
  62. msg_5    db    '│        <ESC> to Exit       │',0
  63. msg_6    db    '└────────────────────────────┘',0
  64.  
  65. save_buffer db 400 dup(?)
  66.  
  67. mode_type    db 0
  68.  
  69. msg_len equ    30
  70. msg_att equ    7
  71. mode_att equ    70h
  72. msg_x equ 25
  73. msg_y equ 2
  74. mode_x equ 48
  75. mode_y equ 3
  76.  
  77. in28    db    0
  78. was_sysreq db 0
  79.  
  80. signature    dw    4352h
  81.  
  82. myint28    proc    far
  83.     pushf
  84.  
  85.     cmp    cs:[in28],0
  86.     jne    no_28
  87.     cmp    cs:[was_sysreq],0
  88.     je    no_28
  89.  
  90.     dec    cs:[was_sysreq]
  91.     jnz    no_28
  92.     inc    cs:[in28]
  93.  
  94.     push    es
  95.     push    ds
  96.     push    ax
  97.     push    bx
  98.     push    cx
  99.     push    dx
  100.     push    bp
  101.     push    di
  102.     push    si
  103.  
  104.     call    save_box
  105.     call    write_box
  106.     call    wait_key
  107.     call    rest_box
  108.  
  109.     pop    si
  110.     pop    di
  111.     pop    bp
  112.     pop    dx
  113.     pop    cx
  114.     pop    bx
  115.     pop    ax
  116.     pop    ds
  117.     pop    es
  118.  
  119.     dec    cs:[in28]
  120.     mov    cs:[was_sysreq],0
  121. no_28:
  122.     popf
  123.     jmp    dword ptr cs:[oldint28]
  124. myint28    endp
  125.  
  126. cursor_1    dw    0
  127. cursor_2    dw    0
  128.  
  129. save_box proc near
  130.     mov    ah,3
  131.     xor    bx,bx
  132.     int    10h    ;get cursor position
  133.     mov    cs:[cursor_1],cx
  134.     mov    cs:[cursor_2],dx
  135.     mov    ah,1
  136.     xor    bx,bx
  137.     mov    cx,0f000h
  138.     int    10h    ;turn cursor off
  139.  
  140.  
  141.     push    cs
  142.     pop    es
  143.     lea    di,save_buffer
  144.  
  145.     mov    dh,msg_y
  146.     mov    dl,msg_x
  147.  
  148.     mov    cx,6
  149.     push    dx
  150.  
  151. box_loop1:
  152.     push    cx
  153.     mov    cx,30d
  154.  
  155. line_loop1:
  156.     xor    bh,bh
  157.     mov    ah,2
  158.     int    10h    ;set position
  159.  
  160.     mov    ah,8
  161.     mov    bh,0
  162.     int    10h    ;get character
  163.  
  164.     stosw
  165.     inc    dl
  166.     loop    line_loop1
  167.  
  168.     pop    cx    ;get back line count
  169.     pop    dx
  170.     inc    dh
  171.     push    dx    ;save for later
  172.  
  173.     loop    box_loop1
  174.  
  175.     pop    dx
  176.  
  177.     ret
  178. save_box endp
  179.  
  180. rest_box proc near
  181.  
  182.     push    cs
  183.     pop    ds
  184.     lea    si,save_buffer
  185.  
  186.     mov    dh,msg_y
  187.     mov    dl,msg_x
  188.  
  189.     mov    cx,6
  190.     push    dx
  191.  
  192. box_loop:
  193.     push    cx
  194.     mov    cx,30d
  195.  
  196. line_loop:
  197.     xor    bh,bh
  198.     mov    ah,2
  199.     int    10h    ;set position
  200.  
  201.     lodsw
  202.     mov    bl,ah    ;mov attribute
  203.  
  204.     push    cx
  205.     mov    ah,9
  206.     mov    bh,0
  207.     mov    cx,1
  208.     int    10h    ;put character
  209.     pop    cx
  210.  
  211.     inc    dl
  212.     loop    line_loop
  213.  
  214.     pop    cx    ;get back line count
  215.     pop    dx
  216.     inc    dh
  217.     push    dx    ;save for later
  218.  
  219.     loop    box_loop
  220.  
  221.     pop    dx
  222.  
  223.  
  224.     mov    ah,1
  225.     xor    bx,bx
  226.     mov    cx,cs:[cursor_1]
  227.     int    10h    ;set cursor type
  228.     mov    ah,2
  229.     xor    bx,bx
  230.     mov    dx,cs:[cursor_2]
  231.     int    10h    ;set cursor position
  232.     ret
  233. rest_box endp
  234.  
  235. write_box proc near
  236.     mov    bl,msg_att
  237.     mov    cx,msg_len
  238.     mov    dh,msg_y
  239.     mov    dl,msg_x
  240.     push    cs
  241.     pop    es
  242.     lea    bp,msg_1
  243.     call    write_string
  244.     inc    dh
  245.     lea    bp,msg_2
  246.     call    write_string
  247.     inc    dh
  248.     lea    bp,msg_3
  249.     call    write_string
  250.     inc    dh
  251.     lea    bp,msg_4
  252.     call    write_string
  253.     inc    dh
  254.     lea    bp,msg_5
  255.     call    write_string
  256.     inc    dh
  257.     lea    bp,msg_6
  258.     call    write_string
  259.  
  260.     call    write_mode
  261.     ret
  262. write_box endp
  263.  
  264. write_mode proc near
  265.     mov    bl,mode_att
  266.     mov    cx,mode_len
  267.     mov    dh,mode_y
  268.     mov    dl,mode_x
  269.  
  270.     cmp    cs:[mode_type],0
  271.     je    do_off
  272.  
  273.     lea    bp,onmode
  274.     jmp    short writeit
  275.  
  276. do_off:
  277.     lea    bp,offmode
  278. writeit:
  279.     call    write_string
  280.     ret
  281.  
  282. write_mode endp
  283.  
  284. wait_key proc near
  285.     sti
  286. try_again:
  287.     mov    ah,0
  288.     int    16h
  289.     cmp    al,01bh        ;escape to exit?
  290.     je    exit_key
  291.     cmp    al,20h        ;change mode?
  292.     jne    try_again
  293.     xor    cs:[mode_type],1    ;change modes
  294.     call    write_mode
  295.     jmp    short try_again
  296. exit_key:
  297.     ret
  298. wait_key endp
  299.  
  300. write_string proc near
  301.     mov    ax,1300h
  302.     mov    bh,0
  303.     int    10h
  304.     ret
  305. write_string endp
  306.  
  307. end_resident:
  308.  
  309. error_msg    db    'You must be using OS/2 to use this program',0dh,0ah,'$'
  310. error_msg1    db    'FIXLOCK is already resident!',0dh,0ah,'$'
  311. ok_msg    db    'FIXLOCK has been loaded!',0dh,0ah,'$'
  312.  
  313. begin:
  314. ;comment the next four lines to let this run under MS-DOS
  315.     mov    ax,3000h
  316.     int    21h
  317.     cmp    al,0ah    ;is it 0S/2?
  318.     jne    error_exit
  319.     xor    ax,ax
  320.     mov    es,ax
  321.     mov    byte ptr es:[417h],0    ;clear current flags
  322.  
  323.     mov    ax,3528h
  324.     int    21h
  325.     mov    word ptr [oldint28],bx
  326.     mov    word ptr [oldint28+2],es
  327.  
  328.     cmp    word ptr es:[bx-2],4352h
  329.     je    already_res
  330.  
  331.     lea    dx,myint28
  332.     mov    ax,2528h
  333.     int    21h
  334.  
  335.     mov    ax,3509h
  336.     int    21h
  337.     mov    word ptr [oldint9],bx
  338.     mov    word ptr [oldint9+2],es
  339.     lea    dx,myint9
  340.     mov    ax,2509h
  341.     int    21h
  342.  
  343.     mov    cs:[mode_type],0    ;initialize
  344.  
  345.     lea    dx,ok_msg
  346.     mov    ax,0900h
  347.     int    21h
  348.  
  349.     mov    ax, offset end_resident
  350.     add    ax,16
  351.     xor    dx,dx
  352.     mov    si,10h
  353.     div    si
  354.     mov    dx,ax
  355.     mov    ax,3100h
  356.     int    21h
  357.  
  358. already_res:
  359.     lea    dx,error_msg1
  360.     jmp    short out1
  361. error_exit:
  362.     lea    dx,error_msg
  363. out1:
  364.     mov    ax,0900h
  365.     int    21h
  366.  
  367.     mov    ax,4c01h
  368.     int    21h
  369.  
  370. _text ends
  371.  
  372. end start
  373.