home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programming
/
powerprogramming1994.iso
/
progtool
/
microcrn
/
issue_49.arc
/
TSR-CODE.ARC
/
RENEGADE.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-07-11
|
8KB
|
201 lines
; Micro Cornucopia Issue #49
; TSR Figure 4 - RENEGADE.ASM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; RENEGADE.ASM ;;
;; Same operation as POPUP.ASM but takes over INT 1CH and ;;
;; invokes CHECK procedure 18.2 times per second. ;;
;; Recaptures INT 9H and excludes other resident programs. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IVT SEGMENT AT 0H ;INTERRUPT TABLE SEGMENT
ORG 9H*4
KEYBD DW 2 DUP (?) ;INT 9H VECTOR
ORG 1CH*4
TIMER DW 2 DUP (?) ;INT 1CH VECTOR
IVT ENDS
;--------------------------------------------------------------------
CODE SEGMENT PARA PUBLIC 'CODE' ;CODE SEGMENT
ASSUME CS:CODE
ORG 100H
BEGIN: JMP INIT ;GOTO INITIALIZATION ROUTINE
OLDKB LABEL DWORD ;INT 9H ADDRESS IN ROM
DB 87H,0E9H,00H,0F0H ;STORE INT 9H VECTOR
NEWKEY DW 2 DUP (?) ;CURRENT INT 9H VECTOR
SCREEN DB 4000 DUP ('S') ;STORE ORIGINAL SCREEN
SHIFT DB 0 ;SAVE SHIFT STATUS CODE
STATUS DB 0 ;CHECK NEW SCREEN STATUS
POPUP DB 4000 DUP ('P') ;POP-UP SCREEN
;--------------------------------------------------------------------
;MAIN is made resident and every keystroke routed here.
;--------------------------------------------------------------------
MAIN PROC NEAR ;NEW INT 9H VECTOR POINTS HERE
STI ;ENABLE INTERRUPTS
PUSH AX ;SAVE REGISTERS
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH DS
PUSH ES
PUSHF ;SIMULATE INTERRUPT RETURN
CALL OLDKB ;PROCESS OLD KEYBD ROUTINE IN ROM
MOV AH,2 ;RETURN KEYBD FLAGS
INT 16H
MOV SHIFT,AL ;SAVE SHIFT STATUS
AND AL,3
CMP AL,3 ;BOTH SHIFT KEYS PRESSED?
JE SAVE ;IF YES, THEN SAVE SCREEN
MOV AL,SHIFT ;RESTORE SHIFT STATUS
AND AL,9 ;ALT AND RT. SHIFT KEYS PRESSED?
CMP AL,9
JNE EXIT ;IF NO, THEN EXIT HANDLER
MOV STATUS,0 ;EXPECT NEW SCREEN
JMP SAVE ;GET NEW SCREEN
EXIT: POP ES ;RESTORE REGISTERS AND EXIT
POP DS
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
IRET ;RETURN TO PARENT PROGRAM
;--------------------------------------------------------------------
;This routine activated when both shift keys or Alt/Rt shift pressed.
;--------------------------------------------------------------------
;Save the original cursor position
SAVE: MOV AH,3 ;READ CURSOR POSITION
MOV BH,0 ;SELECT PAGE 0
INT 10H
PUSH DX ;SAVE CURSOR POSITION
PUSH CX ;SAVE CURSOR SIZE
;Save the original screen
MOV AX,0B800H ;COLOR GRAPHICS MEMORY
MOV DS,AX ;SOURCE SEGMENT
MOV SI,0 ;SOURCE OFFSET
PUSH CS
POP ES ;DEST. SEG
MOV DI,OFFSET SCREEN ;DEST. OFFSET
CLD ;CLEAR DIRECTIONAL FLAG
MOV CX,4000 ;MOVE 4000 BYTES
REP MOVSB ;FROM VIDEO TO MEMORY
;Determine if new screen
CMP STATUS,0FFH ;CHECK NEW SCREEN STATUS
JE READY ;IF YES, THEN GOTO READY
;Move the first pop-up screen
PUSH CS
POP DS ;SOURCE SEG
PUSH CS
POP ES ;DEST. SEG
MOV SI,OFFSET SCREEN ;SOURCE OFFSET
MOV DI,OFFSET POPUP ;DEST. OFFSET
MOV CX,4000 ;MOVE 4000 BYTES
REP MOVSB ;FROM SCREEN TO POPUP
MOV STATUS,0FFH ;CHANGE STATUS AFTER FIRST RUN
JMP POS
;Save new pop-up screen
READY: MOV DI,0 ;DEST. OFFSET
MOV SI,OFFSET POPUP ;SOURCE OFFSET
PUSH CS
POP DS ;SOURCE SEG
MOV AX,0B800H
MOV ES,AX ;DEST. SEG
CLD
MOV CX,4000 ;MOVE 4000 BYTES
REP MOVSB ;FROM MEMORY TO VIDEO
;Turn cursor off
POS: MOV AH,2 ;POSITION CURSOR
MOV BH,0
MOV DL,0 ;FIRST COLUMN
MOV DH,25 ;ROW OFF VIDEO DISPLAY
INT 10H
;Wait for escape keystroke
WAIT: MOV AH,0 ;WAIT FOR KEYSTROKE
INT 16H
CMP AL,27 ;ESCAPE KEY?
JNZ WAIT
;Restore original cursor
POP CX ;ORIGINAL CURSOR SIZE
POP DX ;ORIGINAL CURSOR POSITION
MOV BH,0
MOV AH,2 ;SET CURSOR
INT 10H
;Restore original screen
MOV DI,0 ;DEST. OFFSET
MOV SI,OFFSET SCREEN ;SOURCE OFFSET
PUSH CS
POP DS ;SOURCE SEGMENT
MOV AX,0B800H
MOV ES,AX ;DEST. SEGMENT
CLD
MOV CX,4000 ;MOVE 4000 BYTES
REP MOVSB ;FROM MEMORY TO VIDEO
JMP EXIT ;HANDLER IS DONE
MAIN ENDP
;--------------------------------------------------------------------
;Once installed, CHECK is invoked 18.2 times/sec.
;INT 1CH vector point here.
;--------------------------------------------------------------------
CHECK PROC NEAR
STI ;ENABLE INTERRUPTS
PUSH AX ;SAVE REGISTERS
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH DS
PUSH ES
PUSH CS
POP DS ;SOURCE SEGMENT
;Determine if INT 9H vector was changed
MOV SI,OFFSET NEWKEY ;SOURCE OFFSET
MOV AX,0
MOV ES,AX ;DEST. SEGMENT
MOV DI,9H*4 ;DEST. OFFSET
MOV CX,2 ;COMPARE 2 WORDS
REPE CMPSW
JE SKIP ;IF MATCH, EXIT
;Reinstate INT 9H vector
MOV AX,IVT
MOV DS,AX
ASSUME DS:IVT
CLI ;DISABLE INTERRUPTS
MOV KEYBD,OFFSET MAIN ;REINSTATE KEYBD VECTOR
MOV KEYBD[2],CS
STI ;ENABLE INTERRUPTS
SKIP: JMP EXIT
CHECK ENDP
;--------------------------------------------------------------------
;INIT is executed once and is not made resident.
;--------------------------------------------------------------------
INIT PROC NEAR
MOV AX,IVT ;SET DS TO INTERRUPT VECTOR TABLE
MOV DS,AX
ASSUME DS:IVT
CLI ;DISABLE INTERRUPTS
MOV KEYBD,OFFSET MAIN ;INSTALL NEW VECTOR
MOV KEYBD[2],CS
MOV TIMER,OFFSET CHECK ;INSTALL NEW TIMER VECTOR
MOV TIMER[2],CS
STI ;ENABLE INTERRUPTS
MOV DX,OFFSET INIT ;SAVE TO END OF CHECK PROCEDURE
INT 27H ;TSR
INIT ENDP
;----------------------------------------------------------
CODE ENDS
END BEGIN