home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 5
/
ctrom5b.zip
/
ctrom5b
/
DOS
/
UTILITY
/
DIVERSEN
/
KWIKHELP
/
KWIKHELP.A86
< prev
next >
Wrap
Text File
|
1994-12-01
|
10KB
|
421 lines
;----------------------------------------------------------------
; KWIKHELP 21 August 1994
; jtucker@adam.com.au
; JIM TUCKER 3:800/805
; This reads a screen binary file (4000 bytes) then goes resident.
; The screen is popped up with a hot key. ESC pops it down.
;----------------------------------------------------------------
INCLUDE E:\ALIB\MACROS.INC
jmp install
KEY_SCAN db 35 ;Default hotkey 'H'
KEY_SHIFT db 12 ;CTRL-ALT
POP_REQUESTED db 0 ;Set by hotkey combination
PUSH_REQUESTED db 0 ;Set by ESC
ACTIVE db 0 ;Set if displaying
BUSY db 0 ;Set by disk write and video
ZERO_WORD dw 0 ;For setting ES segment
SWITCH db 0 ;Tried to unload
CURPOS dw ? ;Saved by popup
CURSIZE dw ?
VIDEO_SEG dw 0B800h ;default for now
DISPLAY_SEG dw ? ;the ".BIN" file
OLD_INT10 dd ? ;trapped but not used
;----------------------------------------------------------------
; BIOS DISK This sets BUSY while doing disk stuff
;----------------------------------------------------------------
NEW_INT13: cli ;just set busy
inc cs:BUSY
pushf ;needed for call
db 09Ah ;far call opcode
OLD_INT13 dd ? ;filled by install
pushf ;must preserve CF
dec cs:BUSY ;done, not busy
popf
retf 2 ;opcode CA0200
;----------------------------------------------------------------
; BIOS VIDEO Returns CS if called by us else sets BUSY flag
;----------------------------------------------------------------
NEW_INT10: cli
inc cs:BUSY ;doin' sumthin'
pushf ;call while busy
call cs:old_int10
dec cs:BUSY ;doin' nothin'
iret ;done
;----------------------------------------------------------------
; BIOS KEYBOARD Sets a flag if we are popped up and ESC
; Sets a flag if we are not popped up and HOTKEY
;----------------------------------------------------------------
NEW_INT09: pushf
STI
test cs:ACTIVE ;are we up?
jnz >l3 ;yes, just exit
push ax,es
in al,60h ;get key code
cmp al,cs:key_scan ;our key?
jne >l2 ;no, restore flags and exit
mov ah,2 ;get shift status
int 16h
and al,cs:key_shift
cmp al,cs:key_shift ;shift down?
jne >l2 ;no, restore flags and exit
mov cs:pop_requested,1 ;set flag
in al,61h ;reset keyboard
mov ah,al ;see KWIKTEXT.A86
or al,80h
out 61h,al
mov al,ah
out 61h,al
cli
mov al,20h
out 20h,al
sti
; This loops for ESC
L1: mov ah,0 ;dos idle to give him time
int 28h
mov ah,1 ;get key
int 16h ;one ready?
jz l1 ;no
mov ah,0 ;yes, get it
int 16h
cmp al,27 ;ESC?
jne l1 ;no
; We have ESC
mov cs:push_requested,1 ;request pop back
mov es,cs:zero_word ;clear the buffer
mov ax,es:[041Ch] ;get kb tail
mov es:[041Ah],ax ;make it the head
pop es,ax ;restore regs
popf ;and return
iret
L2: pop es,ax
L3: popf
db 0EAh ;jmp imm16
OLD_INT09 dd ?
;----------------------------------------------------------------
; BIOS TIMER POP up if pop_requested and we aren't busy
; PUSH if ESC and we aren't busy
;----------------------------------------------------------------
NEW_INT08: pushf
cli
DB 09Ah ;call imm16
OLD_INT08 dd ?
test cs:BUSY ;can we do it?
if nz jmp exit_08 ;no
test cs:pop_requested ;pop up?
if nz jmp popup ;yes
test cs:push_requested ;pop down?
if nz jmp popdown ;yes
jmp exit_08 ;nothing to do
; Pop up - Save his screen and display ours, wait for key to exit
POPUP: mov cs:ACTIVE,1
mov cs:pop_requested,0
pushall
mov cs:video_seg,0B800h ;guess
mov ah,0Fh ;get mode
int 10h
cmp al,7 ;mono?
jne >l1 ;no
mov cs:video_seg,0B000h ;bad guess
L1: mov ah,03h ;save the curpos
mov bh,0
int 10h
mov cs:curpos,dx
mov ah,02h ;move it off the screen
mov dx,1A00h
int 10h
mov ds,cs:display_seg ;establish the segments
mov es,cs:video_seg
jmp screen_swap
; Here if ESC hit
POPDOWN: mov cs:ACTIVE,0
mov cs:push_requested,0
pushall
mov ah,02h ;restore the cursor
mov dx,cs:curpos
mov bh,0
int 10h
mov ds,cs:video_seg ;just opposite to above
mov es,cs:display_seg
SCREEN_SWAP: xor si,si
mov cx,2000
L1: mov ax,[si] ;get char to display ;get byte to display
xchg ax,dx ;save it in dx
mov ax,es:[si] ;get char from screen
mov es:[si],dx ;display the char
mov [si],ax ;and save the screen char
add si,2
loop l1
popall
EXIT_08: iret
; This is the terminator
FINI: rep movsw
int 21h
EVEN 16
DISPLAY_SCREEN db ;the ".BIN" file ends here
;----------------------------------------------------------------
; NON - RESIDENT INSTALL CODE FOLLOWS
;----------------------------------------------------------------
.NOLIST
INCLUDE E:\ALIB\CMDLINE.INC
@CAPS
.LIST
INSTALLED_SEG dw 0 ;non zero if we exist
INSTALL: call cmdline ;get filename, switch
call read_file1 ;read the file
call get_scan ;read the switch
mov bx,OFFSET display_screen ;set up segment
shr bx,4 ; address for display
mov ax,cs ;our segment
add ax,bx ;add it
mov display_seg,ax ;segment
mov ax,3508h ;trap INT 8
dosf
mov word ptr old_int08, bx
mov word ptr old_int08+2,es
mov ax,2508h
mov dx, OFFSET new_int08
dosf
mov ax,3509h ;trap INT 9
dosf
mov word ptr old_int09, bx
mov word ptr old_int09+2,es
mov ax,2509h
mov dx, OFFSET new_int09
dosf
mov ax,3510h ;trap INT 10
dosf
mov word ptr old_int10, bx
mov word ptr old_int10+2,es
mov ax,2510h
mov dx, OFFSET new_int10
dosf
mov ax,3513h ;trap INT 13
dosf
mov word ptr old_int13, bx
mov word ptr old_int13+2,es
mov ax,2513h
mov dx, OFFSET new_int13
dosf
mov ax,[2ch] ;release environ
mov es,ax
mov ah,49h
dosf
mov dx, OFFSET installed ;tell them we live
mov ah,9
dosf
cmp key_scan,59
jne >l1
mov dx,OFFSET hot_key_mesg2
mov ah,9
dosf
jmp >l2
L1: write hot_key_mesg1
; Set up regs for block move...
L2: mov cx,2000 ;length of file
mov di,OFFSET display_screen ;where it goes
mov si,OFFSET screen_file ;starting offset
mov es,cs
; ... and regs for exit resident
mov dx,di ;table address
add dx,4000 ;add size of table
add dx,15 ;rounding
shr dx,4 ;div by 16 for pars
mov ax,3100h ;exit resident
jmp fini ;end it
MESSAGE: mov ah,9
dosf
mov ax,4CFFh
dosf
INSTALLED db cr,lf,'KWIKHELP ■ Release 1994 JIM TUCKER',cr,lf
db 'Copyright (c) 1994 JIM TUCKER. All rights reserved'
db cr,lf,eom
HOT_KEY_MESG1 db 'Use <CTRL-ALT-'
HOT_KEY db 'H'
db '> to POP UP',cr,lf,0
HOT_KEY_MESG2 db 'Use F1 to POP UP',cr,lf,eom
;----------------------------------------------------------------
; READ_FILE1: This reads the user file specified on the command line
;----------------------------------------------------------------
LENGTH dw ?
READ_FILE1: test filename1
if z jmp help ;no file
L1: mov dx,filename1 ;open file
mov ax,3d00h
int 21h
jnc >l2
mov dx,OFFSET no_file_mesg
jmp error_message
L2: mov bx,ax
mov ax,4202h ;get length
mov cx,0
mov dx,0
int 21h
mov length,ax
jnc >l3
mov dx,OFFSET bad_size_mesg
jmp error_message
L3: cmp ax,4000 ;test length
je >l4
mov dx,OFFSET bad_size_mesg
jmp error_message
L4: mov ax,4200h ;rewind it
mov cx,0
mov dx,0
int 21h
mov ax,3F00h ;read file
mov cx,length
mov dx,OFFSET screen_file
int 21h
jnc >l5
mov dx,OFFSET read_err_mesg
jmp error_message
L5: mov ah,3Eh ;close file
int 21h
ret
;----------------------------------------------------------------
; GET_SCAN This gets scan code from switch /K=X
;----------------------------------------------------------------
GET_SCAN: mov si,OFFSET switch_buffer
L1: lodsb
L2: or al,al
jz ret ;done
cmp al,'/' ;switch?
jne l1 ;no
lodsb ;get next
cmp al,'K' ;for us?
if ne jmp help
lodsb ;get next
cmp al,':' ;must be this
je >l3 ;yes
cmp al,'=' ;or this
if ne jmp help
L3: lodsb
cmp al,' ' ;space or less is illegal
if be jmp help
cmp al,'#' ;# substitute F1
jne >l3 ;must be a key
mov al,59 ;F1 keycode
mov key_shift,0 ;no CLTR-ALT
jmp >l5 ;save keycode
L3: and al,7Fh ;no funny stuff
mov di,OFFSET char_string
mov cx,string_length
repne scasb
jne >l4
add key_shift,2
L4: mov hot_key,al ;save ASCII
mov si,OFFSET scan ;get scan code
mov ah,0
add si,ax
lodsb
L5: mov key_scan,al ;save scan code
ret
HELP: mov dx,OFFSET help_mesg
ERROR_MESSAGE: mov ah,9
int 21h
mov ax,4CFFh
int 21h
NO_FILE_MESG db cr,lf,'File not found',cr,lf,eom
BAD_SIZE_MESG db cr,lf,'Screen file must be 4000 bytes',cr,lf,eom
READ_ERR_MESG db cr,lf,'Error reading file',cr,lf,eom
HELP_MESG db cr,lf
db 'KWIKHELP V1.01 ■ Release 1994 JIM TUCKER',cr,lf
db 'Copyright (c) 1994 JIM TUCKER. All rights reserved',cr,lf
db 'Creates popup screen from binary screen image file',cr,lf
db 'USAGE: KWIKHELP FILENAME [/K=Hotkey]',cr,lf
db 'Example: KWIKHELP ASCIHLP1.BIN /K=A (Hotkey=CTRL-ALT-A)',cr,lf,eom
; Translation table: ASCII codes into keyboard scan codes
scan db 03, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
db 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 01, 26, 53, 27, 12
db 57, 02, 40, 04, 05, 06, 08, 40, 10, 11, 09, 13, 51, 12, 52, 53
db 11, 02, 03, 04, 05, 06, 07, 08, 09, 10, 39, 39, 51, 13, 52, 53
db 03, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
db 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 26, 43, 27, 07, 12
db 41, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24
db 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 26, 43, 27, 41, 14
CHAR_STRING db '~!@#$%^&*()_+|{}:"<>?'
STRING_LENGTH EQU $-OFFSET CHAR_STRING
; The file is read here, then moved before resident
EVEN
SCREEN_FILE db
END