home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / DOS / UTILITY / DIVERSEN / KWIKHELP / KWIKHELP.A86 < prev    next >
Text File  |  1994-12-01  |  10KB  |  421 lines

  1. ;----------------------------------------------------------------
  2. ; KWIKHELP 21 August 1994
  3. ; jtucker@adam.com.au
  4. ; JIM TUCKER 3:800/805
  5.  
  6. ; This reads a screen binary file (4000 bytes) then goes resident.
  7. ; The screen is popped up with a hot key. ESC pops it down.
  8. ;----------------------------------------------------------------
  9.  
  10. INCLUDE E:\ALIB\MACROS.INC
  11.  
  12.         jmp    install
  13.  
  14. KEY_SCAN    db    35            ;Default hotkey 'H'
  15. KEY_SHIFT    db    12            ;CTRL-ALT
  16.  
  17. POP_REQUESTED    db    0            ;Set by hotkey combination
  18. PUSH_REQUESTED    db    0            ;Set by ESC    
  19. ACTIVE        db    0            ;Set if displaying
  20. BUSY        db    0            ;Set by disk write and video
  21. ZERO_WORD    dw    0            ;For setting ES segment
  22. SWITCH        db    0            ;Tried to unload
  23. CURPOS        dw    ?            ;Saved by popup
  24. CURSIZE        dw    ?
  25.  
  26. VIDEO_SEG    dw    0B800h            ;default for now
  27. DISPLAY_SEG    dw    ?            ;the ".BIN" file
  28.  
  29. OLD_INT10    dd    ?            ;trapped but not used
  30.  
  31. ;----------------------------------------------------------------
  32. ; BIOS DISK This sets BUSY while doing disk stuff
  33. ;----------------------------------------------------------------
  34.  
  35. NEW_INT13:    cli                ;just set busy
  36.         inc    cs:BUSY
  37.         pushf                ;needed for call
  38.         db    09Ah            ;far call opcode
  39. OLD_INT13    dd    ?            ;filled by install
  40.         pushf                ;must preserve CF
  41.         dec    cs:BUSY            ;done, not busy
  42.         popf
  43.         retf    2            ;opcode CA0200
  44.  
  45. ;----------------------------------------------------------------
  46. ; BIOS VIDEO Returns CS if called by us else sets BUSY flag
  47. ;----------------------------------------------------------------
  48.  
  49. NEW_INT10:    cli
  50.         inc    cs:BUSY            ;doin' sumthin'
  51.         pushf                ;call while busy
  52.         call    cs:old_int10
  53.         dec    cs:BUSY            ;doin' nothin'
  54.         iret                ;done
  55.  
  56. ;----------------------------------------------------------------
  57. ; BIOS KEYBOARD Sets a flag if we are popped up and ESC
  58. ;               Sets a flag if we are not popped up and HOTKEY
  59. ;----------------------------------------------------------------
  60.  
  61. NEW_INT09:    pushf
  62.         STI
  63.         test    cs:ACTIVE        ;are we up?
  64.         jnz    >l3            ;yes, just exit
  65.  
  66.         push    ax,es
  67.         in    al,60h            ;get key code
  68.         cmp    al,cs:key_scan        ;our key?
  69.         jne    >l2            ;no, restore flags and exit
  70.         mov    ah,2            ;get shift status
  71.         int    16h
  72.         and    al,cs:key_shift
  73.         cmp    al,cs:key_shift        ;shift down?
  74.         jne    >l2            ;no, restore flags and exit
  75.         mov    cs:pop_requested,1    ;set flag
  76.  
  77.         in    al,61h            ;reset keyboard
  78.         mov    ah,al            ;see KWIKTEXT.A86
  79.         or    al,80h
  80.         out    61h,al
  81.         mov    al,ah
  82.         out    61h,al
  83.         cli
  84.         mov    al,20h
  85.         out    20h,al
  86.         sti
  87.  
  88. ; This loops for ESC
  89.  
  90. L1:        mov    ah,0            ;dos idle to give him time
  91.         int    28h
  92.         mov    ah,1            ;get key
  93.         int    16h            ;one ready?
  94.         jz    l1            ;no
  95.         mov    ah,0            ;yes, get it
  96.         int    16h    
  97.         cmp    al,27            ;ESC?
  98.         jne    l1            ;no
  99.  
  100. ; We have ESC    
  101.  
  102.         mov    cs:push_requested,1    ;request pop back
  103.         mov    es,cs:zero_word        ;clear the buffer
  104.         mov    ax,es:[041Ch]        ;get kb tail
  105.         mov    es:[041Ah],ax        ;make it the head
  106.  
  107.         pop    es,ax            ;restore regs
  108.         popf                ;and return
  109.         iret
  110.  
  111. L2:        pop    es,ax
  112. L3:        popf
  113.         db    0EAh            ;jmp imm16
  114. OLD_INT09    dd    ?
  115.  
  116. ;----------------------------------------------------------------
  117. ; BIOS TIMER POP up if pop_requested and we aren't busy
  118. ;            PUSH if ESC and we aren't busy
  119. ;----------------------------------------------------------------
  120.  
  121. NEW_INT08:    pushf
  122.         cli
  123.         DB    09Ah            ;call imm16
  124. OLD_INT08    dd    ?
  125.  
  126.         test    cs:BUSY            ;can we do it?    
  127.         if nz    jmp exit_08        ;no
  128.         test    cs:pop_requested    ;pop up?
  129.         if nz    jmp popup        ;yes
  130.         test    cs:push_requested    ;pop down?
  131.         if nz    jmp popdown        ;yes
  132.         jmp    exit_08            ;nothing to do
  133.  
  134. ; Pop up - Save his screen and display ours, wait for key to exit
  135.  
  136. POPUP:        mov    cs:ACTIVE,1
  137.         mov    cs:pop_requested,0
  138.  
  139.         pushall
  140.         mov    cs:video_seg,0B800h    ;guess
  141.         mov    ah,0Fh            ;get mode
  142.         int    10h
  143.         cmp    al,7            ;mono?
  144.         jne    >l1            ;no
  145.         mov    cs:video_seg,0B000h    ;bad guess
  146.  
  147. L1:        mov    ah,03h            ;save the curpos
  148.         mov    bh,0
  149.         int    10h
  150.         mov    cs:curpos,dx
  151.  
  152.         mov    ah,02h            ;move it off the screen
  153.         mov    dx,1A00h
  154.         int    10h
  155.  
  156.         mov    ds,cs:display_seg    ;establish the segments
  157.         mov    es,cs:video_seg
  158.         jmp    screen_swap
  159.  
  160. ; Here if ESC hit
  161.  
  162. POPDOWN:    mov    cs:ACTIVE,0
  163.         mov    cs:push_requested,0
  164.  
  165.         pushall
  166.         mov    ah,02h            ;restore the cursor
  167.         mov    dx,cs:curpos
  168.         mov    bh,0
  169.         int    10h
  170.  
  171.         mov    ds,cs:video_seg        ;just opposite to above
  172.         mov    es,cs:display_seg
  173.  
  174. SCREEN_SWAP:    xor    si,si
  175.         mov    cx,2000
  176. L1:        mov    ax,[si]            ;get char to display                ;get byte to display
  177.         xchg    ax,dx            ;save it in dx
  178.         mov    ax,es:[si]        ;get char from screen
  179.         mov    es:[si],dx        ;display the char
  180.         mov    [si],ax            ;and save the screen char
  181.         add    si,2
  182.         loop    l1
  183.         popall
  184. EXIT_08:    iret
  185.  
  186. ; This is the terminator
  187.  
  188. FINI:        rep    movsw
  189.         int    21h
  190. EVEN 16
  191. DISPLAY_SCREEN    db                ;the ".BIN" file ends here
  192.  
  193. ;----------------------------------------------------------------
  194. ; NON - RESIDENT INSTALL CODE FOLLOWS
  195. ;----------------------------------------------------------------
  196.  
  197. .NOLIST
  198. INCLUDE E:\ALIB\CMDLINE.INC
  199. @CAPS
  200. .LIST
  201.  
  202. INSTALLED_SEG    dw    0            ;non zero if we exist
  203. INSTALL:    call    cmdline            ;get filename, switch
  204.         call    read_file1        ;read the file
  205.         call    get_scan        ;read the switch
  206.  
  207.         mov    bx,OFFSET display_screen    ;set up segment
  208.         shr    bx,4                ; address for display
  209.         mov    ax,cs                ;our segment
  210.         add    ax,bx                ;add it
  211.         mov    display_seg,ax            ;segment
  212.  
  213.         mov    ax,3508h            ;trap INT 8
  214.         dosf
  215.         mov    word ptr old_int08,  bx
  216.          mov    word ptr old_int08+2,es
  217.         mov    ax,2508h
  218.         mov    dx, OFFSET new_int08
  219.         dosf
  220.  
  221.         mov    ax,3509h            ;trap INT 9
  222.         dosf
  223.         mov    word ptr old_int09,  bx
  224.          mov    word ptr old_int09+2,es
  225.         mov    ax,2509h
  226.         mov    dx, OFFSET new_int09
  227.         dosf
  228.  
  229.         mov    ax,3510h            ;trap INT 10
  230.         dosf
  231.         mov    word ptr old_int10,  bx
  232.          mov    word ptr old_int10+2,es
  233.         mov    ax,2510h
  234.         mov    dx, OFFSET new_int10
  235.         dosf
  236.  
  237.         mov    ax,3513h            ;trap INT 13
  238.         dosf
  239.         mov    word ptr old_int13,  bx
  240.          mov    word ptr old_int13+2,es
  241.         mov    ax,2513h
  242.         mov    dx, OFFSET new_int13
  243.         dosf
  244.  
  245.         mov    ax,[2ch]            ;release environ
  246.         mov    es,ax
  247.         mov    ah,49h
  248.         dosf
  249.  
  250.         mov    dx, OFFSET installed        ;tell them we live
  251.         mov    ah,9
  252.         dosf
  253.  
  254.         cmp    key_scan,59
  255.         jne    >l1
  256.         mov    dx,OFFSET hot_key_mesg2
  257.         mov    ah,9
  258.         dosf
  259.         jmp    >l2
  260. L1:        write    hot_key_mesg1
  261.  
  262. ; Set up regs for block move...
  263.  
  264. L2:        mov    cx,2000                ;length of file
  265.         mov    di,OFFSET display_screen    ;where it goes
  266.         mov    si,OFFSET screen_file        ;starting offset
  267.         mov    es,cs
  268.  
  269. ; ... and regs for exit resident
  270.  
  271.         mov    dx,di                ;table address
  272.         add    dx,4000                ;add size of table
  273.         add    dx,15                ;rounding
  274.         shr    dx,4                ;div by 16 for pars
  275.         mov    ax,3100h            ;exit resident
  276.         jmp    fini                ;end it
  277.  
  278. MESSAGE:    mov    ah,9
  279.         dosf
  280.         mov    ax,4CFFh
  281.         dosf
  282.  
  283. INSTALLED    db cr,lf,'KWIKHELP ■ Release 1994 JIM TUCKER',cr,lf
  284.         db 'Copyright (c) 1994 JIM TUCKER. All rights reserved'
  285.         db cr,lf,eom
  286.  
  287. HOT_KEY_MESG1    db    'Use <CTRL-ALT-'
  288. HOT_KEY        db    'H'
  289.         db    '> to POP UP',cr,lf,0
  290. HOT_KEY_MESG2    db    'Use F1 to POP UP',cr,lf,eom
  291.  
  292. ;----------------------------------------------------------------
  293. ; READ_FILE1: This reads the user file specified on the command line
  294. ;----------------------------------------------------------------
  295.  
  296. LENGTH        dw    ?
  297. READ_FILE1:    test    filename1
  298.         if z    jmp help        ;no file
  299.  
  300. L1:        mov     dx,filename1        ;open file
  301.         mov    ax,3d00h
  302.         int    21h
  303.         jnc    >l2
  304.         mov    dx,OFFSET no_file_mesg
  305.         jmp    error_message
  306.  
  307. L2:        mov    bx,ax
  308.         mov    ax,4202h        ;get length
  309.         mov    cx,0
  310.         mov    dx,0
  311.         int    21h
  312.         mov    length,ax
  313.         jnc    >l3
  314.         mov    dx,OFFSET bad_size_mesg
  315.         jmp    error_message
  316.  
  317. L3:        cmp    ax,4000            ;test length
  318.         je    >l4
  319.         mov    dx,OFFSET bad_size_mesg
  320.         jmp    error_message
  321.  
  322. L4:        mov    ax,4200h        ;rewind it
  323.         mov    cx,0
  324.         mov    dx,0
  325.         int    21h
  326.  
  327.         mov    ax,3F00h        ;read file
  328.         mov    cx,length
  329.         mov    dx,OFFSET screen_file
  330.         int    21h
  331.         jnc    >l5
  332.         mov    dx,OFFSET read_err_mesg
  333.         jmp    error_message
  334.  
  335. L5:        mov    ah,3Eh            ;close file
  336.         int    21h
  337.         ret
  338.  
  339. ;----------------------------------------------------------------
  340. ; GET_SCAN This gets scan code from switch /K=X
  341. ;----------------------------------------------------------------
  342.  
  343. GET_SCAN:    mov    si,OFFSET switch_buffer
  344. L1:        lodsb
  345. L2:        or    al,al
  346.         jz    ret        ;done
  347.         cmp    al,'/'        ;switch?
  348.         jne    l1        ;no
  349.         lodsb            ;get next
  350.         cmp    al,'K'        ;for us?
  351.         if ne    jmp help
  352.  
  353.         lodsb            ;get next
  354.         cmp    al,':'        ;must be this
  355.         je    >l3        ;yes
  356.         cmp    al,'='        ;or this
  357.         if ne    jmp help
  358.  
  359. L3:        lodsb
  360.         cmp    al,' '        ;space or less is illegal
  361.         if be    jmp help
  362.  
  363.         cmp    al,'#'        ;# substitute F1
  364.         jne    >l3        ;must be a key
  365.         mov    al,59        ;F1 keycode
  366.         mov    key_shift,0    ;no CLTR-ALT
  367.         jmp    >l5        ;save keycode
  368.  
  369. L3:        and    al,7Fh        ;no funny stuff
  370.         mov    di,OFFSET char_string
  371.         mov    cx,string_length
  372.         repne    scasb
  373.         jne    >l4
  374.         add    key_shift,2
  375.  
  376. L4:        mov    hot_key,al    ;save ASCII
  377.         mov    si,OFFSET scan    ;get scan code
  378.         mov    ah,0
  379.         add    si,ax
  380.         lodsb
  381. L5:        mov    key_scan,al    ;save scan code
  382.         ret                        
  383.  
  384. HELP:        mov    dx,OFFSET help_mesg
  385. ERROR_MESSAGE:    mov    ah,9
  386.         int    21h
  387.         mov    ax,4CFFh
  388.         int    21h
  389.  
  390. NO_FILE_MESG    db    cr,lf,'File not found',cr,lf,eom
  391. BAD_SIZE_MESG    db    cr,lf,'Screen file must be 4000 bytes',cr,lf,eom
  392. READ_ERR_MESG    db    cr,lf,'Error reading file',cr,lf,eom
  393.  
  394. HELP_MESG db cr,lf
  395.     db 'KWIKHELP V1.01 ■ Release 1994 JIM TUCKER',cr,lf
  396.     db 'Copyright (c) 1994 JIM TUCKER. All rights reserved',cr,lf
  397.     db 'Creates popup screen from binary screen image file',cr,lf
  398.     db 'USAGE: KWIKHELP FILENAME [/K=Hotkey]',cr,lf
  399.     db 'Example: KWIKHELP ASCIHLP1.BIN /K=A (Hotkey=CTRL-ALT-A)',cr,lf,eom
  400.  
  401. ; Translation table:  ASCII codes into keyboard scan codes
  402.  
  403. scan    db    03, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
  404.     db    25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 01, 26, 53, 27, 12
  405.     db    57, 02, 40, 04, 05, 06, 08, 40, 10, 11, 09, 13, 51, 12, 52, 53
  406.     db    11, 02, 03, 04, 05, 06, 07, 08, 09, 10, 39, 39, 51, 13, 52, 53
  407.     db    03, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
  408.     db    25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 26, 43, 27, 07, 12
  409.     db    41, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
  410.     db    25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 26, 43, 27, 41, 14
  411.  
  412. CHAR_STRING    db '~!@#$%^&*()_+|{}:"<>?'
  413. STRING_LENGTH    EQU $-OFFSET CHAR_STRING
  414.  
  415. ; The file is read here, then moved before resident
  416.  
  417. EVEN
  418. SCREEN_FILE    db    
  419.  
  420. END
  421.