home *** CD-ROM | disk | FTP | other *** search
- page 60,132
- title 4DOS24H.ASM
- subttl DOS critical interrupt handler for 4DOS
- page
-
- ; This source file and the compiled program are released to the Public Domain
- ; Nobody is authorized to charge any amount of money for them. In any form
- ; and for any reason.
- ; JP Software is herewith authorized to include 4DOS24H in the 4DOS package
- ; without any claim from me.
-
- ; To assemble
- ; TASM or MASM 4DOS24H;
- ; LINK 4DSO24H;
- ; EXE2BIN 4DOS24H.EXE 4DOS24H.COM
- ; DEL 4DOS24H.EXE
-
-
- Intr EQU 24h ;Interrupt 24H
- Dos EQU 21h ;DOS Interrupt
- Get_Vector EQU 35h ;Get interrupt vector service
- Tsr EQU 27h ;Terminate and stay resident
- False EQU 0
- True EQU 1
- WinSize EQU 800
-
- Code SEGMENT
- ASSUME CS:Code, DS:Code, ES:Code, SS:Code
- ORG 100h
-
- _4DOS24h: JMP Start ;Go to installation process
-
- Old_Int EQU $
- Old_Int_Ofs DW ? ;Place holder for old
- Old_Int_Seg DW ? ; interrupt vector
- Screen_Seg DW ? ;Screen address
-
- Device_Hdr_Seg DW ? ;Place holder for address
- Device_Hdr_Ofs DW ? ; of device in error
- Errcode DW ? ;Place holder for error code
-
- LineSaver DB WinSize DUP (?) ;Screen saver
-
- Keys DB 'AarRiIFf' ;Possible user response keys
- KeysLen EQU $-Keys
- Codes DB 2,2,1,1,0,0,3,3 ;Response translation table
- Area DB 'DTRF' ;Error area codes
- ErrType DB 'RW' ;Error types codes
-
- IgnoreFlag DB True ;Authorization flags
- RetryFlag DB True
- FailFlag DB True
-
- Msg0 DB 'Write protected disk '
- Msg1 DB 'Unknown unit '
- Msg2 DB 'Drive not ready '
- Msg3 DB 'Unknown command '
- Msg4 DB 'Data Error (CRC) '
- Msg5 DB 'Bad request struc. len.'
- Msg6 DB 'Seek error '
- Msg7 DB 'Unknown media type '
- Msg8 DB 'Sector not found '
- Msg9 DB 'Printer out of paper '
- MsgA DB 'Write fault '
- MsgB DB 'Read fault '
- MsgC DB 'General failure '
- Unknown_Ofs EQU $-Msg0
- MsgU DB 'Error code unknown '
- MSG_LEN EQU $-MsgU
-
-
-
- Infoline DB '┌'
- DW 78 DUP (01FC4h)
- DB '┐'
- DB '│Please hit A(bort),R(etry),I(gno'
- DB 're) or F(ail). 4DOS24H version 1.0 │'
- DB '│Disk error: N Error type: ? Read'
- DB '/Write: ? Drive: ? Device name: ???????? │'
- DB '│Error : '
- DB ' │'
- DB '└'
- DW 78 DUP (01FC4h)
- DB '┘'
-
- ; I know, this is a little clumsy but this saves a lot of code.
-
- ;*****************
- ; Save user screen
- ;*****************
-
- SaveScr PROC NEAR
-
- PUSH CX ;Save used registers
- PUSH DS
- PUSH ES
- PUSH DI
- PUSH SI
-
- MOV CX, WinSize ;Put overwritten characters in
- PUSH CS ; LineSaver
- POP ES
- MOV DI, Offset LineSaver
- MOV DS, CS:Screen_Seg
- MOV SI, 0
- CLD
- REP MOVSB
-
- POP SI
- POP DI
- POP ES
- POP DS
- POP CX
-
- RET
-
- SaveScr ENDP
-
- ;***************
- ; Display window
- ;***************
-
- PutScr PROC NEAR
-
- PUSH CX ;Save used registers
- PUSH ES
- PUSH SI
- PUSH DI
-
- MOV CX, WinSize ;Display our window
- MOV SI, Offset InfoLine
- MOV ES, CS:Screen_Seg
- MOV DI, 0
- CLD
-
- REP MOVSB
-
- POP DI
- POP SI
- POP ES
- POP CX
-
- RET
-
- PutScr ENDP
-
- ;***************
- ; Restore Screen
- ;***************
-
- ResScr PROC NEAR
-
- PUSH CX ;Save used registers
- PUSH DS
- PUSH ES
- PUSH SI
- PUSH DI
-
- MOV CX, WinSize ;Restore user screen
- MOV ES, CS:Screen_Seg
- MOV DI, 0
- PUSH CS
- POP DS
- MOV SI, Offset LineSaver
- CLD
- REP MOVSB
-
- POP DI
- POP SI
- POP ES
- POP DS
- POP CX
-
- RET
-
- ResScr ENDP
-
- ;**********************
- ; New interrupt handler
- ;**********************
-
- New_Int:
-
- PUSHF ;Save registers on entry
- PUSH BX
- PUSH CX
- PUSH DX
- PUSH SI
- PUSH DI
- PUSH ES
- PUSH DS
- PUSH BP
-
- PUSH CS ;DS has now the right value
- POP DS
-
- PUSH AX ;AX holds all the information we need
-
- MOV Device_Hdr_Seg, BP ;Save Address of device driver header
- MOV Device_Hdr_Ofs, SI
- MOV ErrCode, DI ;Save Error code
- AND ErrCode, 000Fh
-
- MOV AH, 0Fh ;Get video mode
- INT 10h
- CMP AL, 7
- JE Mono
- JMP Color
- Mono:
- MOV Screen_Seg, 0B03Ch ;Set display address
- JMP Done
- Color:
- CMP AL, 3
- JLE NotGraphic
- JMP OldInt ;We don't process graphics modes
- NotGraphic:
- MOV Screen_Seg, 0B83Ch
- Done:
- CALL SaveScr ;Save user screen
- CALL PutScr ;Display our window
-
- POP AX
- TEST AH, 80h ;Disk error ?
- PUSH AX
- JNZ GetName ;No. Will now see if device
- ; is char device and display name
- MOV DS, Screen_Seg
- MOV BYTE PTR DS:[346], 'Y'
-
- AND AH, 6 ;Get error area info
- MOV CL, 9
- SHR AX, CL
- MOV BX, AX
- MOV DI, Offset Area
- MOV AL, CS:[DI+BX]
- MOV BYTE PTR DS:[374], AL;Display it
- POP AX
-
- PUSH AX ;Get error type info
- AND AH, 1
- MOV CL, 8
- SHR AX, CL
- MOV BX, AX
- MOV DI, Offset ErrType
- MOV AL, CS:[DI+BX]
- MOV BYTE PTR DS:[402], AL;Display it
- POP AX
-
- MOV BYTE PTR DS:[420], AL ;Get drive info and
- ADD BYTE PTR DS:[420], 'A' ;Display it
- PUSH AX
- GetName:
- MOV DS, CS:Device_Hdr_Seg ;Get name of device driver
- MOV SI, CS:Device_Hdr_Ofs ; only if char device
- TEST [SI+4],8000h
- JZ GetError
- MOV CX, 8
- MOV ES, CS:Screen_Seg
- MOV DI, 450 ;Point to Name field
- ADD SI, 10 ;Point to device name
- GetLoop1:
- MOVSB
- INC DI ;Skip over attribute
- LOOP GetLoop1 ;Display it
-
- GetError:
- PUSH CS ;Reset DS
- POP DS
- MOV AX, Unknown_Ofs
- MOV SI, Offset Msg0
- MOV CX, MSG_LEN ;Setup for loop
- CMP Errcode, 0Ch ;Error code valid ?
- JG NotValid
- MOV AX, CX ;Compute offset in
- MUL ErrCode ; message table
- NotValid:
- ADD SI, AX
- MOV DI, 498 ;ES:DI -> Error field
- MOV ES, Screen_Seg
-
- GetLoop2:
- MOVSB
- INC DI ;Skip over attribute
- LOOP GetLoop2 ;Display it
-
-
- GetKey:
- PUSH CS
- POP DS
- MOV AH, 8 ;Get user input
- INT 21h
-
- PUSH CS
- POP ES
- MOV DI, Offset Keys
- MOV CX, KeysLen
- CLD
- REPNE SCASB
- JNZ GetKey
-
- CALL ResScr ;Restore screen
- MOV BL, [DI+KeysLen-1] ;User response in BL
- POP AX
- TestIgnore:
- TEST AH, 20h ;Ignore allowed ?
- JNZ TestRetry
- MOV CS:IgnoreFlag, False ;Set relevant flag
- TestRetry:
- TEST AH, 10h ;Retry allowed ?
- JNZ TestFail
- MOV CS:RetryFlag, False ;Set relevant flag
- TestFail:
- TEST AH, 8 ;Fail allowed ?
- JNZ ProcessIgnore
- MOV CS:FailFlag, False ;Set relevant flag
- ProcessIgnore:
- CMP BL, 0 ;User input was Ignore ?
- JNE ProcessRetry
- CMP CS:IgnoreFlag, TRUE ;Ignore allowed ?
- JE FlagOk
- MOV BL, 3
- ProcessRetry:
- CMP BL, 1 ;User input was Retry ?
- JNE ProcessFail
- CMP CS:RetryFlag, TRUE ;Fail allowed ?
- JE FlagOk
- MOV BL, 3
- ProcessFail:
- CMP BL, 3 ;User input was Fail ?
- JNE FlagOk
- CMP CS:FailFlag, TRUE ;Fail allowed
- JE FlagOk
- MOV BL, 2
- FlagOk:
- MOV AL, BL
- CMP AL, 2 ;4DOS doesn't seem to accept
- JNE Exit ; this return code. So we issue
- INT 23h ; the INT 23h ourselves
- Exit:
- POP BP ;Restore registers
- POP DS
- POP ES
- POP DI
- POP SI
- POP DX
- POP CX
- POP BX
- POPF
- IRET
-
- OldInt: ;Jump to old interrupt handler
- POP AX ; when in graphics mode
- POP BP
- POP DS
- POP ES
- POP DI
- POP SI
- POP DX
- POP CX
- POP BX
- POPF
- JMP DWORD PTR CS:Old_Int
-
- End_Code EQU $
-
-
- Banner DB '4DOS24H - Version 1.1 - Patrick Philippot 1990',13,10
- Msg DB 'Resident part installed',13,10,'$'
-
- Start: ;INSTALLATION - This part of the
- MOV AL, Intr ; program doesn't remain in memory
- MOV AH, Get_Vector ;Save old interrupt vector.
- INT Dos
- MOV Word Ptr Old_Int_Seg, ES
- MOV Word Ptr Old_Int_Ofs, BX
-
- MOV CS:[12h], Offset New_Int ;Install our handler by modifying
- MOV CS:[14h], CS ; the PSP
-
- ; The following code is necessary to allow 4DOS24H to be loaded "high" with
- ; QEMM or 386 MAX
-
- PUSH DS
- MOV DS, CS:[16h] ;Get parent's PSP
- MOV DS:[12h], Offset New_Int
- MOV DS:[14h], CS ;Modify parent's PSP (LOADHI)
- POP DS
-
- MOV DX, offset Banner ;Display banner
- MOV AH, 9
- INT Dos
-
- MOV DX, Offset End_Code ;Terminate and Stay Res.
- INT Tsr
-
- Code ENDS
- END _4DOS24H