Category : Display Utilities
Archive   : NOYB11.ZIP
Filename : NOYB11.ASM

Output of file : NOYB11.ASM contained in archive : NOYB11.ZIP

page 66,132
title NOYB.ASM - None Of Your Business - Resident Screen Blanking Program
; Program: None Of Your Business (NOYB.ASM)
; Version: 1.0
; Author : Gerald D. Mooshool
; Date : July, 1986
; Remarks: This is a resident screen "blanker", intended to be use for a
; quick erasor of the current video display. The screen will be
; blanked out when and NOYB's toggle key are pressed, and
; restored the screen when the toggle key alone it pressed. As
; the title explains, the major use of this program is to allow
; the user to quickly clear the video display when nosiy office
; mates try to stare over your shoulder. It is also well suited
; for those times when you must rush out of the office quickly
; but do not want to exit the application you are currently using.
; NOTE REV 1.1 by Dave Roznar Saratoga, Ca. February 14, 1987. I added
; small loop at "wait_for_toggle" to allow for two keys, key1 and
; key2, to be required to turn on the screen. In this case a Z or
; z, followed by a F, or f, is required to turn screen back on. I
; did not change opening message, as this was just more security.
; To use more than two keys to turn on screen, just define more
; bytes in the db in beginning of program ie: key3 db xx etc
; and continue the cmp ah,keyx loop, but two should prevent a
; person from hitting one key, as was possible in REV 1.0, and
; getting the screen to come on. Don't forget that you are defining
; scan codes!

interrupts segment at 0h ;interrupt table segment
org 9h * 4 ;interrupt number 9,
keyboard_int dw 2 dup (?) ; the keyboard interrupt
interrupts ends

code segment para public 'code'
assume cs:code
org 100h
begin: jmp initialize

recursion_flag db 0 ;flag used to check for
; recursive entry

key1 db 44 ;FIRST key scan code to
;turn on screen 'Z or 'z'

key2 db 33 ;second key required to
;turn on screen 'F' or 'f'

toggle_keyscan db 44 ;keyboard scan code for
; 'Z' and 'z' key.

video_mode db ? ;active video mode
video_page db ? ;active video page
cursor_pos dw ? ;cursor position
cursor_type dw ? ;cursor scan lines
save_screen db 4000 dup (?) ;save screen image buffer

mono_segment dw 0b000h ;mono segment address
cga_segments dw 0b800h,0b900h,0ba00h,0bb00h ;cga page segments

tsr_message db 13,10 ;tell them its loaded
db 213,40 dup(205),184,13,10
db 179,' NOYB (V1.1) Loaded Resident ',179,13,10
db 179,' ',179,13,10
db 179,' Press The and Keys To Toggle ',179,13,10
db 212,40 dup(205),190,13,10,'$'

old_kb_int label dword ;segment and offset of the
old_keyboard_int dw 2 dup (?) ; keyboard interrupt

; When loaded resident, this now becomes the entry point for the keyboard
; interrupt.
main proc near
sti ;enable software interrupts
push ax ;save all registers
push bx
push cx
push dx
push si
push di
push ds
push es

pushf ;push flags for call to the
call old_kb_int ; old kbd interrupt
mov ah,2 ;check shift status of keys
int 16h
and al,8 ;test if bit 3 is set
cmp al,8 ;8 = depressed.
jne exit
mov ah,1 ;check keyboard buffer to see
int 16h ; if something is in it
jz exit ;0 = nothing in buffer
cmp ah,toggle_keyscan ;44 = the 'Z' key
jne exit
mov ah,0 ;now, read the buffer to clear
int 16h ; it of the toggle key
jmp start_program

; Return to callers program
exit: pop es ;restore callers registers
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
iret ;interrupt return

; When this program's toggle keys are pressed, program execution will continue
; here.
push cs ;set ds to cs segment
pop ds
push cs ;set es to cs segment
pop es

cmp recursion_flag,0 ;check for recursion
jne exit

mov ah,15 ;get video information and
int 10h ; determine if the caller
cmp al,2 ; is in a video mode which
je video_mode_ok ; NOYB will operate in.
cmp al,3 ; if not, just bypass the
je video_mode_ok ; request by returning to
cmp al,7 ; calling program.
jne exit

mov recursion_flag,1 ;NOYB is toggled.....set flag
mov video_mode,al ;save callers video mode
mov video_page,bh ;save callers video page

mov ah,3 ;get caller's cursor state
int 10h
mov cursor_pos,dx ;save callers cursor position
mov cursor_type,cx ;save callers cursor type

mov ax,mono_segment ;lets assume mode mono
cmp video_mode,7 ;is it mode mono?
je save_callers_screen ;yes....carry on
mov bx,0 ;no.....use video page as a
mov bl,video_page ; pointer into the table of
mov ax,cga_segments [bx] ; cga page segments

mov ds,ax ;ds = current video segment
mov si,0 ;si = offset into video seg
push cs
pop es ;es = current code segment
lea di,save_screen ;di = points to data area
mov cx,4000 ;save 4000 bytes from the
cld ; video buffer into our
rep movsb ; save buffer

mov ah,1 ;turn the cursor off
mov cx,2000h
int 10h

mov ax,mono_segment
cmp video_mode,7
je clear_screen
mov bx,0
mov bl,video_page
mov ax,cga_segments [bx]

mov es,ax ;es = current video segment
mov di,0 ;di = offset into video seg
mov ax,0720h ;char & attrib to clear with
mov cx,2000 ;2000 words (char & attrib)
cld ; to move to the video area
rep stosw

mov ah,0 ; continue to loop until
int 16h ; key1 is followed by
cmp ah,key1 ; key2, or video remains
jne wait_for_toggle ; cleared.
mov ah,0 ;
int 16h ; continue this loop for
cmp ah,key2 ; more keys if desired
jne wait_for_toggle

mov ax,mono_segment ;when toggle key is pressed
cmp video_mode,7 ; the callers screen and
je rcs1 ; cursor are restored.
mov bx,0
mov bl,video_page
mov ax,cga_segments [bx]

rcs1: mov es,ax ;here we will restore the
mov di,0 ; callers screen with the
push cs ; image of it that was saved
pop ds ; in our data buffer
lea si,save_screen
mov cx,4000
rep movsb

mov ah,1 ;reset cursor to the way it
mov cx,cursor_type ; appeared on the callers
int 10h ; screen

mov recursion_flag,0 ;reset flag for next time
jmp exit
main endp

; Initialization code will change the interrupt vector table and load resident
initialize proc near
assume ds:code, es:code

mov ah,9 ;send loaded message
lea dx,tsr_message
int 21h

mov recursion_flag,0 ;intialize flag to 0='no'

mov ax,interrupts
mov ds,ax ;ds = interrupts segment adr
assume ds:interrupts

mov ax,keyboard_int
mov old_keyboard_int,ax ;save old vector address
mov ax,keyboard_int[2]
mov old_keyboard_int[2],ax

cli ;clear interrupts
mov keyboard_int,offset main ;install new vector
mov keyboard_int[2],cs
sti ;start interrupts

mov dx,offset initialize ;dx = end of tsr code
int 27h ;terminate and stay resident
initialize endp

code ends ;end of code segment
end begin ;end of program