home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / wordperf / wpfkeys5.arc / SHOFKEYS.A < prev    next >
Encoding:
Text File  |  1989-08-06  |  11.5 KB  |  596 lines

  1.  
  2.  
  3. ;ShoFKeys -- help display line for WordPerfect (uses nth line of display)
  4. ;
  5. ; 12/5/87 by Davidson Corry
  6. ;         4610 SW Lander
  7. ;         Seattle, WA  98116
  8. ;         (206) 935-0244
  9. ;
  10. ; This program is released to the public domain by its author.
  11. ; Please feel free to use it, distribute it and (especially)
  12. ; improve it in any way you feel appropriate.
  13. ;
  14. ; Money contributions are neither required nor expected.  If you like
  15. ; the program and want to express your gratitude, do one of the following:
  16. ;
  17. ;  1) Write some useful program and upload it to your favorite BBS'es
  18. ;  2) Help support your local BBS with money, time or interest
  19. ;  3) Teach someone something about programming
  20. ;  4) Do the dishes tonight
  21. ;  5) Don't tell your lover you've heard that old joke (n) times before
  22. ;
  23. ; ...or some other public service.  Hope you find it useful.  --Davidson
  24. ;
  25. ;
  26. ; Modified 8/5/89 by Alan D. Ariel to reflect proper WP 5.0 key functions
  27. ; COM file also modified
  28.  
  29.  
  30. ; shift status bits from BIOS call
  31. alt    equ    00001000b
  32. ctrl    equ    00000100b
  33. lshift    equ    00000010b
  34. rshift    equ    00000001b
  35. shifts    equ    lshift or rshift
  36. my_hotshift    equ    ctrl or lshift    ;hot key is CTRL-LEFTSHIFT-F
  37. my_hotkey    equ    33
  38.  
  39. ega    equ    1
  40. not_ega equ    0
  41.  
  42. ;Colors/attributes for display attributes
  43. blink    equ    10000000b
  44. intense equ    00001000b
  45. black    equ    0
  46. blue    equ    1
  47. green    equ    2
  48. cyan    equ    3
  49. red    equ    4
  50. magenta equ    5
  51. brown    equ    6
  52. grey    equ    7
  53. yellow    equ    intense or brown
  54. white    equ    intense or grey
  55. underline    equ    blue
  56.  
  57. ; key/function color selections for a color monitor.  Choose your own.
  58. ; Use OR rather than + to turn bits in the attribute byte on.
  59. ; Background colors occupy the high nibble: (BACKCOLOR SHL 4)
  60. ; Foreground colors occupy the low nibble:   FORECOLOR
  61.  
  62. ;KEY     EQU     INTENSE OR RED OR(CYAN SHL 4) ;"hot red" on cyan
  63. ;FNX     EQU     GREY OR (BLUE SHL 4)        ;grey on blue
  64.  
  65. ; key/function "color" selections for a monochrome monitor.
  66. ; These will work well on both color monitors (bright blue keynumber, grey words)
  67. ; and on monochrome monitors (keynumber underlined and bright, grey words)
  68.  
  69. key    equ     intense or underline    ;"hot blue" on black
  70. fnx    equ     grey            ;grey on black
  71.  
  72. in_keypress    equ    1
  73. inactivated      equ      10h
  74.  
  75. _text    segment byte public 'CODE'
  76.     assume cs:_text, ds:_text, es:_text, ss:_text
  77.     org    100h
  78.     public    begin
  79. begin:
  80.     jmp    initialize
  81.  
  82.     public    users_ss, users_sp, local_stack
  83.  
  84. users_ss    dw    0
  85. users_sp    dw    0
  86.         dw    20 dup(0)
  87. local_stack    label    word
  88.  
  89.     public    activity, adapter_type, old_keypress, last_shiftstate, video_seg
  90.  
  91. activity    db    inactivated    ;comes up "dormant" at load time
  92.  
  93. adapter_type    db    0
  94.  
  95. old_keypress    dd    0
  96.  
  97. last_shiftstate db    0
  98.  
  99. video_seg    dw    0
  100.  
  101.     public    new_keypress, not_our_hotkey, which_keyset
  102.  
  103. new_keypress:
  104.     push    ax            ;save AX register, we're going to use it
  105.     in    al,60h            ;get scancode of key just pressed
  106.     .if    <cmp     al,my_hotkey>,e    ;it's our base hotkey, see if shiftbits are right
  107.         mov    ah,2
  108.         int    16h        ;get shiftbits through BIOS
  109.         and    al,0fh        ;shiftbits only
  110.         .if    <cmp    al,my_hotshift>,e    ;it's our hotkey!! toggle ACTIVATION bit of ACTIVITY byte
  111.             in    al,61h    ;These instructions reset
  112.             mov    ah,al    ; the keyboard.  "Forgets" the hotkey
  113.             or    al,80h
  114.             out    61h,al
  115.             mov    al,ah
  116.             jmp    short $+2    ;I/O delay for fast AT's
  117.             out    61h,al
  118.             cli        ;Disable interrupts and
  119.             mov    al,20h    ;reset the int controller
  120.             out    20h,al
  121.             sti        ;Allow interrupts
  122.             xor    cs:activity,inactivated ;toggle the ACTIVATED bit in activity flag byte
  123.             pop    ax    ;restore the AX register saved at entry to hotkey test
  124.             iret        ;and return to caller
  125.         .endif
  126.     .endif
  127.     pop    ax            ;restore AX register saved above
  128.  
  129. not_our_hotkey:
  130.  
  131. ;do nothing if already in the FUNCTION KEY DISPLAY or
  132. ;  if the TSR is in the "inactivated" state
  133.     .if    <test     cs:activity,in_keypress or inactivated>,nz
  134.         jmp    cs:old_keypress
  135.     .endif
  136.  
  137. which_keyset:
  138. ;active and flying, show the function keys appropriate to the shift state
  139.     or    cs:activity,in_keypress    ;flag "showing function keys"
  140.     sti
  141.     pushf                ;simulate a INT to process the key just pressed/released
  142.     call    cs:old_keypress
  143.  
  144.     push    ax            ;save AX and SI registers, they get local values on shiftstatus
  145.     push    si
  146.     mov    ah,2
  147.     int    16h            ;get shiftstatus
  148.     .if    <test  al,alt>,nz    ;ALT is on, show ALT function keyset
  149.         mov    al,alt
  150.         mov    si,offset altfunx
  151.     .elseif  <test    al,ctrl>,nz    ;ALT not on but CTRL is, CTRL keyset
  152.         mov    al,ctrl
  153.         mov    si,offset ctrlfunx
  154.     .elseif  <test    al,shifts>,nz    ;ALT and CTRL not on but a SHIFT key is, show SHIFT keyset
  155.         mov    al,shifts
  156.         mov    si,offset shiftfunx
  157.     .else                ;ALT CTRL SHIFT all off, show "NORMAL" keyset
  158.         xor    al,al
  159.         mov    si,offset normfunx
  160.     .endif
  161.  
  162.     .if    <cmp    al,cs:last_shiftstate>,ne    ;display keyset ONLY if this is a change from last shown
  163.         call    show_new_shiftkeys
  164.     .endif
  165.  
  166.     pop    si            ;restore the registers used testing shiftstatus
  167.     pop    ax
  168.     and    cs:activity,not in_keypress    ;flag "not displaying keysets"
  169.     iret                ;and return to caller
  170.  
  171.     public    show_new_shiftkeys
  172. show_new_shiftkeys:
  173.         mov    cs:last_shiftstate,al
  174.         cli        ;disable interrupts while diddling stack
  175.         mov    cs:users_sp,sp     ;save old stack
  176.         mov    cs:users_ss,ss
  177.         mov    sp,cs    ;establish local stack instead
  178.         mov    ss,sp
  179.         mov    sp,offset local_stack
  180.         sti        ;new stack context installed, re-enable interrupts
  181.         push    ds        ;save user registers, we need 'em
  182.         push    es
  183.         push    di
  184.         push    cx
  185.         mov    ax,cs        ;get local datasegment context
  186.         mov    ds,ax
  187.         mov    cx,24        ;assume 25 rows on display, funxkeys shown on #24
  188.         .if    <cmp    adapter_type,ega>,e    ;EGA, may be using 43 rows
  189.             mov    ax,0040h
  190.             mov    es,ax
  191.             mov    cl,es:84h    ;number of last row in use
  192.         .endif
  193.         mov    ax,80*2     ;number of bytes per display row (byte char + byte attribute)
  194.         mul    cl        ;byte*byte = word, doesn't disturb DX
  195.         mov    di,ax        ;offset of last row on display
  196.         mov    ax,video_seg    ;base of video display memory
  197.         mov    es,ax
  198.         cld
  199.         mov    cx,80
  200.         rep    movsw        ;copy keyset databytes directly to video memory
  201.         pop    cx        ;restore user's registers
  202.         pop    di
  203.         pop    es
  204.         pop    ds
  205.         cli        ;disable interrupts while restoring user's stack context
  206.         mov    ss,cs:users_ss
  207.         mov    sp,cs:users_sp
  208.         sti        ;user's stack restored, enable interrupts
  209.     ret
  210.  
  211.  
  212. ; text (char+attribute) for function-key display lines
  213.  
  214.     public    normfunx, altfunx, shiftfunx, ctrlfunx
  215.  
  216. normfunx    db    '1',key
  217.     db    'C',fnx
  218.     db    'a',fnx
  219.     db    'n',fnx
  220.     db    'c',fnx
  221.     db    'e',fnx
  222.     db    'l',fnx
  223.     db    ' ',fnx
  224.     db    '2',key
  225.     db    'S',fnx
  226.     db    'r',fnx
  227.     db    'c',fnx
  228.     db    'h',fnx
  229.     db    '-',fnx
  230.     db    '>',fnx
  231.     db    ' ',fnx
  232.     db    '3',key
  233.     db    ' ',fnx
  234.     db    'H',fnx
  235.     db    'e',fnx
  236.     db    'l',fnx
  237.     db    'p',fnx
  238.     db    ' ',fnx
  239.     db    ' ',fnx
  240.     db    '4',key
  241.     db    ' ',fnx
  242.     db    '>',fnx
  243.     db    'I',fnx
  244.     db    'n',fnx
  245.     db    'd',fnx
  246.     db    't',fnx
  247.     db    ' ',fnx
  248.     db    '5',key
  249.     db    ' ',fnx
  250.     db    'F',fnx
  251.     db    'i',fnx
  252.     db    'l',fnx
  253.     db    'e',fnx
  254.     db    's',fnx
  255.     db    ' ',fnx
  256.     db    '6',key
  257.     db    ' ',fnx
  258.     db    'B',fnx
  259.     db    'o',fnx
  260.     db    'l',fnx
  261.     db    'd',fnx
  262.     db    ' ',fnx
  263.     db    ' ',fnx
  264.     db    '7',key
  265.     db    ' ',fnx
  266.     db    'E',fnx
  267.     db    'x',fnx
  268.     db    'i',fnx
  269.     db    't',fnx
  270.     db    ' ',fnx
  271.     db    ' ',fnx
  272.     db    '8',key
  273.     db    ' ',fnx
  274.     db    'U',fnx
  275.     db    'n',fnx
  276.     db    'd',fnx
  277.     db    'l',fnx
  278.     db    'n',fnx
  279.     db    ' ',fnx
  280.     db    '9',key
  281.     db    ' ',fnx
  282.     db    'M',fnx
  283.     db    'r',fnx
  284.     db    'g',fnx
  285.     db    ' ',fnx
  286.     db    'R',fnx
  287.     db    ' ',fnx
  288.     db    '0',key
  289.     db    ' ',fnx
  290.     db    'S',fnx
  291.     db    'a',fnx
  292.     db    'v',fnx
  293.     db    'e',fnx
  294.     db    ' ',fnx
  295.     db    ' ',fnx
  296.  
  297. shiftfunx     db     '1',key
  298.     db    ' ',fnx
  299.     db    'S',fnx
  300.     db    'e',fnx
  301.     db    't',fnx
  302.     db    'u',fnx
  303.     db    'p',fnx
  304.     db    ' ',fnx
  305.     db    '2',key
  306.     db    ' ',fnx
  307.     db    '<',fnx
  308.     db    'S',fnx
  309.     db    'r',fnx
  310.     db    'c',fnx
  311.     db    'h',fnx
  312.     db    ' ',fnx
  313.     db    '3',key
  314.     db    ' ',fnx
  315.     db    'S',fnx
  316.     db    'w',fnx
  317.     db    't',fnx
  318.     db    'c',fnx
  319.     db    'h',fnx
  320.     db    ' ',fnx
  321.     db    '4',key
  322.     db    ' ',fnx
  323.     db    '>',fnx
  324.     db    'I',fnx
  325.     db    'n',fnx
  326.     db    'd',fnx
  327.     db    '<',fnx
  328.     db    ' ',fnx
  329.     db    '5',key
  330.     db    ' ',fnx
  331.     db    'D',fnx
  332.     db    'a',fnx
  333.     db    't',fnx
  334.     db    'e',fnx
  335.     db    ' ',fnx
  336.     db    ' ',fnx
  337.     db    '6',key
  338.     db    ' ',fnx
  339.     db    'C',fnx
  340.     db    'e',fnx
  341.     db    'n',fnx
  342.     db    't',fnx
  343.     db    'r',fnx
  344.     db    ' ',fnx
  345.     db    '7',key
  346.     db    ' ',fnx
  347.     db    'P',fnx
  348.     db    'r',fnx
  349.     db    'i',fnx
  350.     db    'n',fnx
  351.     db    't',fnx
  352.     db    ' ',fnx
  353.     db    '8',key
  354.     db    ' ',fnx
  355.     db    'F',fnx
  356.     db    'o',fnx
  357.     db    'r',fnx
  358.     db    'm',fnx
  359.     db    't',fnx
  360.     db    ' ',fnx
  361.     db    '9',key
  362.     db    ' ',fnx
  363.     db    'M',fnx
  364.     db    'r',fnx
  365.     db    'g',fnx
  366.     db    ' ',fnx
  367.     db    'C',fnx
  368.     db    ' ',fnx
  369.     db    '0',key
  370.     db    ' ',fnx
  371.     db    'R',fnx
  372.     db    'e',fnx
  373.     db    't',fnx
  374.     db    'r',fnx
  375.     db    'v',fnx
  376.     db    ' ',fnx
  377.  
  378. ctrlfunx    db    '1',key
  379.     db    ' ',fnx
  380.     db    'S',fnx
  381.     db    'h',fnx
  382.     db    'e',fnx
  383.     db    'l',fnx
  384.     db    'l',fnx
  385.     db    ' ',fnx
  386.     db    '2',key
  387.     db    ' ',fnx
  388.     db    'S',fnx
  389.     db    'p',fnx
  390.     db    'e',fnx
  391.     db    'l',fnx
  392.     db    'l',fnx
  393.     db    ' ',fnx
  394.     db    '3',key
  395.     db    ' ',fnx
  396.     db    'S',fnx
  397.     db    'c',fnx
  398.     db    'r',fnx
  399.     db    'n',fnx
  400.     db    ' ',fnx
  401.     db    ' ',fnx
  402.     db    '4',key
  403.     db    ' ',fnx
  404.     db    'M',fnx
  405.     db    'o',fnx
  406.     db    'v',fnx
  407.     db    'e',fnx
  408.     db    ' ',fnx
  409.     db    ' ',fnx
  410.     db    '5',key
  411.     db    ' ',fnx
  412.     db    'T',fnx
  413.     db    'e',fnx
  414.     db    'x',fnx
  415.     db    't',fnx
  416.     db    ' ',fnx
  417.     db    ' ',fnx
  418.     db    '6',key
  419.     db    ' ',fnx
  420.     db    'T',fnx
  421.     db    'a',fnx
  422.     db    'b',fnx
  423.     db    ' ',fnx
  424.     db    'A',fnx
  425.     db    ' ',fnx
  426.     db    '7',key
  427.     db    ' ',fnx
  428.     db    'F',fnx
  429.     db    'o',fnx
  430.     db    'o',fnx
  431.     db    't',fnx
  432.     db    ' ',fnx
  433.     db    ' ',fnx
  434.     db    '8',key
  435.     db    ' ',fnx
  436.     db    'F',fnx
  437.     db    'o',fnx
  438.     db    'n',fnx
  439.     db    't',fnx
  440.     db    ' ',fnx
  441.     db    ' ',fnx
  442.     db    '9',key
  443.     db    ' ',fnx
  444.     db    'M',fnx
  445.     db    'r',fnx
  446.     db    'g',fnx
  447.     db    'S',fnx
  448.     db    'r',fnx
  449.     db    't',fnx
  450.     db    ' ',fnx
  451.     db    '0',key
  452.     db    ' ',fnx
  453.     db    'D',fnx
  454.     db    'f',fnx
  455.     db    'M',fnx
  456.     db    'a',fnx
  457.     db    'c',fnx
  458.  
  459. altfunx        db      '1',key
  460.     db    ' ',fnx
  461.     db    'T',fnx
  462.     db    'h',fnx
  463.     db    'e',fnx
  464.     db    's',fnx
  465.     db    ' ',fnx
  466.     db    ' ',fnx
  467.     db    '2',key
  468.     db    ' ',fnx
  469.     db    'R',fnx
  470.     db    'e',fnx
  471.     db    'p',fnx
  472.     db    'l',fnx
  473.     db    'c',fnx
  474.     db    ' ',fnx
  475.     db    '3',key
  476.     db    ' ',fnx
  477.     db    'R',fnx
  478.     db    'C',fnx
  479.     db    'o',fnx
  480.     db    'd',fnx
  481.     db    'e',fnx
  482.     db    ' ',fnx
  483.     db    '4',key
  484.     db    ' ',fnx
  485.     db    'B',fnx
  486.     db    'l',fnx
  487.     db    'o',fnx
  488.     db    'c',fnx
  489.     db    'k',fnx
  490.     db    ' ',fnx
  491.     db    '5',key
  492.     db    ' ',fnx
  493.     db    'M',fnx
  494.     db    'a',fnx
  495.     db    'r',fnx
  496.     db    'k',fnx
  497.     db    ' ',fnx
  498.     db    ' ',fnx
  499.     db    '6',key
  500.     db    ' ',fnx
  501.     db    'F',fnx
  502.     db    'l',fnx
  503.     db    ' ',fnx
  504.     db    'R',fnx
  505.     db    't',fnx
  506.     db    ' ',fnx
  507.     db    '7',key
  508.     db    ' ',fnx
  509.     db    'M',fnx
  510.     db    't',fnx
  511.     db    'h',fnx
  512.     db    'C',fnx
  513.     db    'l',fnx
  514.     db    ' ',fnx
  515.     db    '8',key
  516.     db    ' ',fnx
  517.     db    'S',fnx
  518.     db    't',fnx
  519.     db    'y',fnx
  520.     db    'l',fnx
  521.     db    'e',fnx
  522.     db    ' ',fnx
  523.     db    '9',key
  524.     db    ' ',fnx
  525.     db    'G',fnx
  526.     db    'r',fnx
  527.     db    'a',fnx
  528.     db    'p',fnx
  529.     db    'h',fnx
  530.     db    ' ',fnx
  531.     db    '0',key
  532.     db    ' ',fnx
  533.     db    'M',fnx
  534.     db    'a',fnx
  535.     db    'c',fnx
  536.     db    'r',fnx
  537.     db    'o',fnx
  538.     db    ' ',fnx
  539.  
  540.  
  541.     public    initialize
  542.  
  543. initialize:
  544. ;  Deallocate the copy of the environment loaded with the program.
  545.  
  546.     mov    ax,word ptr ds:[2ch]    ;Address of environment
  547.     mov    es,ax            ;In ES register
  548.     mov    ah,49h            ;Release allocated memory
  549.     int    21h            ;Thru DOS
  550.  
  551. ;
  552. ;what kind of video adapter are we using??
  553. ;
  554.     mov    adapter_type,not_ega
  555.     mov    ax,0040h        ;BIOS data segment
  556.     mov    es,ax
  557.     mov     ah,12h            ;see if EGA is present
  558.     mov     bl,10h
  559.     int    10h
  560.     .if  <cmp bl,10h>,ne        ;EGA.  Assume it's active.
  561.         mov    ax,0b800h
  562.         mov    adapter_type,ega
  563.     .elseif    <test    word ptr es:63h,40h>,nz    ;CGA
  564.         mov    ax,0b800h
  565.     .else                ;MDA
  566.         mov    ax,0b000h
  567.     .endif
  568.     mov    video_seg,ax        ;base segment for video display memory
  569.  
  570. ;
  571. ;grab the "keypress" interrupt (9)
  572.     mov    ax,3509h
  573.     int    21h
  574.     mov    word ptr old_keypress[0],bx
  575.     mov    word ptr old_keypress[2],es
  576.     mov    dx,offset new_keypress
  577.     mov    ax,2509h
  578.     int    21h
  579.  
  580. ;
  581. ;say how to use the program
  582.     mov    dx,offset usagemsg
  583.     mov    ah,9
  584.     int    21h
  585.  
  586. ;
  587. ;exit retaining resident portion of code
  588.     mov    dx,(offset initialize - offset _text + 15)/16
  589.     mov    ax,3100h
  590.     int    21h
  591.  
  592. usagemsg    db    'CTRL-LEFTSHIFT-F toggles WordPerfect function key list on last display line$'
  593.  
  594. _text    ends
  595.     end    begin
  596.