;; ; @(#) scr_hide.asm - Show/hide screen TSR utility (for VGA). ; (c) 1997 Ivan Maidanski http://ivmai.chat.ru ; Freeware program source. All rights reserved. ;; ; Language: ASM8086 (for IBM PC/AT, MS-DOS v3.0+, COM file) ; Tested with: Turbo Assembler v3.1, Turbo Link v5.1 ; Last modified: 1997-10-08 20:15:00 GMT+04:00 ;; NAME Scr_Hide ; tasm /m2 scr_hide.asm ; tlink /t scr_hide.obj ; Comment: When this program installed, it enables You to hide ; (and show again) screen content by pressing Ctrl-Alt-S and ; also to clear screen content by pressing Ctrl-Alt-C. IDEAL MODEL TINY LOCALS CODESEG LABEL Null NEAR ; Start of program ORG 100h LABEL Start NEAR jmp Begin ; Resident part PROC Int09hHandler ; Keyboard InitKeyStatus EQU 00001100b ; Ctrl+Alt InitKey EQU 1Fh ; Key 'S' InitClsKey EQU 2Eh ; Key 'C' push ax in al,60h cmp al,InitKey je @@CheckStat cmp al,InitClsKey je @@CheckStat @@RunOld: pop ax jmp far 0:0 ORG $-4 OldInt09h DD ? @@CheckStat: push ax push ds xor ax,ax mov ds,ax mov ax,[ds:0417h] pop ds and al,InitKeyStatus cmp al,InitKeyStatus pop ax jne @@RunOld push ax ; Reset Keyboard in al,61h mov ah,al or al,80h out 61h,al mov al,ah out 61h,al mov al,20h ; Reset Interruption controller out 20h,al pop ax push bx cmp al,InitKey je @@Toggle call ClearScr jmp @@Ret @@Toggle: call ToggleScrSwitch @@Ret: pop bx ax iret ENDP PROC ToggleScrSwitch ; Expects: - ; Returns: - ; Uses: ax,bx mov ah,12h ; Toggle Show/Hide (only for VGA) mov al,0 ORG $-1 ScrSwitch DB ? mov bl,36h int 10h xor [cs:ScrSwitch],1h ret ENDP PROC ClearScr ; Expects: - ; Returns: - ; Uses: ax,bx mov ah,0Fh ; get video mode int 10h mov ah,0 ; set current video mode int 10h ret ENDP PROC Int2FhHandler ; MultiResident ; Expects: ah=IDNumber, al=0 ; Returns: ah=IDNumber, al=0FFh, es=Segment, si=IDString ; Uses: - (bx,cx,dx,di) cmp ah,0 ORG $-1 IDNumber DB ? je @@Analyze jmp far 0:0 ORG $-4 OldInt2Fh DD ? @@Analyze: sti cmp al,0 jne @@Another mov al,0FFh ; IDNumber Taken mov si,cs mov es,si mov si,OFFSET IDString @@Another: iret IDString DB 'Screen Hide Utility V2.0',0 IDStringLen= $-IDString ENDP ResidentLen= $-Null ; Program initialization LABEL Begin NEAR mov sp,OFFSET StackEnd mov bx,(ProgramLen+0Fh)/10h mov ah,4Ah int 21h ; Main program call AnalyzeDos call FreeEnvSeg call AnalyzeResident call GetOldInts mov [ScrSwitch],1h call SetNewInts call StayResident ; Procedures PROC AnalyzeDos ; Expects: - ; Returns: - ; Uses: ax,bx,cx mov ah,30h int 21h cmp al,3h jb @@Err ret @@Err: lea si,[@@MsgInvalidDos] call WriteStr mov ax,4C01h int 21h @@MsgInvalidDos DB 'Error: Invalid DOS version (must be 3.00 or higher).' DB 0Dh,0Ah,0 ENDP PROC FreeEnvSeg ; Expects: - ; Returns: - ; Uses: ax,bx,es mov ah,51h int 21h mov es,bx xor ax,ax xchg ax,[es:2Ch] and ax,ax jz @@Ret mov es,ax mov ah,49h int 21h jnc @@Ret lea si,[@@MsgFatal] call WriteStr mov ax,4CFFh int 21h @@Ret: ret @@MsgFatal DB 'Fatal memory error.',0Dh,0Ah,0 ENDP PROC AnalyzeResident ; Expects: - ; Returns: [ds:IDNumber] ; Uses: ax,bx,cx,dx,si,di,es mov ah,0C0h @@Loop: mov al,0 int 2Fh ; Analyze cmp al,0 je @@Free cmp al,0FFh jne @@BadValue mov di,si lea si,[IDString] mov cx,IDStringLen cld repe cmpsb je @@Loaded @@BadValue: inc ah jnz @@Loop lea si,[@@MsgOutOfIndex] call WriteStr mov ax,4C02h int 21h @@Loaded: call Deinstall lea si,[@@MsgDeinstall] call WriteStr mov ax,4C03h int 21h @@Free: mov [IDNumber],ah ret @@MsgOutOfIndex DB 'Error: All IDNumbers reserved.',0Dh,0Ah,0 @@MsgDeinstall DB 'Resident Deinstalled.',0Dh,0Ah,0 ENDP PROC GetOldInts ; Expects: - ; Returns: - ; Uses: ax,bx,es mov ah,35h mov al,09h ; for Keyboard int 21h mov [word ptr OldInt09h],bx mov [word ptr OldInt09h+2],es mov al,2Fh ; for MultiResident int 21h mov [word ptr OldInt2Fh],bx mov [word ptr OldInt2Fh+2],es ret ENDP PROC SetNewInts ; Expects: - ; Returns: - ; Uses: ax,dx,es mov ax,cs mov es,ax mov ah,25h mov al,09h ; for Keyboard lea dx,[Int09hHandler] int 21h mov al,2Fh ; for MultiResident lea dx,[Int2FhHandler] int 21h ret ENDP PROC StayResident ; Expects: ResidentLen ; Returns: (none) ; Uses: - lea si,[IDString] call WriteStr lea si,[@@MsgUsage] call WriteStr mov ax,3100h mov dx,(ResidentLen+0Fh)/10h int 21h @@MsgUsage DB 0Dh,0Ah DB ' Press Ctrl+Alt+S to toggle between Show/Hide.',0Dh,0Ah DB ' Press Ctrl+Alt+C to clear screen.',0Dh,0Ah,0 ENDP PROC AnalyzeCurrentInt ; Expects: al=IntNo, [si:cx]=IntHandler ; Returns: ZF=0 - Different intr vectors ; Uses: ax,bx,es mov ah,35h int 21h mov ax,es cmp ax,si jne @@Exit cmp bx,cx @@Exit: ret ENDP PROC TestOldInts ; Expects: si=ResidentSeg ; Returns: ZF=0 - Cannot change ; Uses: ax,bx,cx,es mov al,09h ; for Keyboard lea cx,[Int09hHandler] call AnalyzeCurrentInt jnz @@Error mov al,2Fh ; for MultiResident lea cx,[Int2FhHandler] call AnalyzeCurrentInt @@Error: ret ENDP PROC SetOldInt ; Expects: al=IntNo, [es:bx]=OldInt ; Returns: - ; Uses: ah,dx mov ah,25h push ds lds dx,[es:bx] int 21h pop ds ret ENDP PROC UpdateOldInts ; Expects: es=ResidentSeg ; Returns: ZF=0 - Cannot change ; Uses: ax,bx,dx mov al,09h ; for Keyboard lea bx,[OldInt09h] call SetOldInt mov al,2Fh ; for MultiResident lea bx,[OldInt2Fh] call SetOldInt ret ENDP PROC Deinstall ; Expects: es=ResidentSeg ; Returns: - ; Uses: ax,bx,cx,dx,si mov si,es call TestOldInts jnz @@Error mov es,si call UpdateOldInts cmp [es:ScrSwitch],0 jne @@SkipShow mov [ScrSwitch],0 call ToggleScrSwitch @@SkipShow: mov ah,49h int 21h jc @@FatalErr ret @@Error: lea si,[@@MsgCannotDeinstall] call WriteStr mov ax,4C04h int 21h @@FatalErr: lea si,[@@MsgCannotDeinstall] call WriteStr mov ax,4CFFh int 21h @@MsgCannotDeinstall DB 'Resident cannot be deinstalled now.',0Dh,0Ah,0 ENDP PROC WriteStr ; Expects: [ds:si] - ASCIIZ String ; Returns: - ; Uses: ah,dl,si mov ah,2h @@Loop: mov dl,[si] cmp dl,0 je @@Exit int 21h inc si jmp @@Loop @@Exit: ret ENDP ; Program Stack EVENDATA DB 100h DUP(?) LABEL StackEnd NEAR ; End of program ProgramLen= $-Null END Start