home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / 4DOS / 4D2411.ZIP / 4DOS24H.ASM next >
Encoding:
Assembly Source File  |  1990-10-20  |  13.2 KB  |  398 lines

  1.          page    60,132
  2.          title   4DOS24H.ASM
  3.          subttl  DOS critical interrupt handler for 4DOS
  4.          page
  5.  
  6. ; This source file and the compiled program are released to the Public Domain
  7. ; Nobody is authorized to charge any amount of money for them. In any form
  8. ; and for any reason.
  9. ; JP Software is herewith authorized to include 4DOS24H in the 4DOS package
  10. ; without any claim from me.
  11.  
  12. ; To assemble
  13. ;   TASM or MASM 4DOS24H;
  14. ;   LINK 4DSO24H;
  15. ;   EXE2BIN 4DOS24H.EXE 4DOS24H.COM
  16. ;   DEL 4DOS24H.EXE
  17.  
  18.  
  19. Intr           EQU      24h  ;Interrupt 24H
  20. Dos            EQU      21h  ;DOS Interrupt
  21. Get_Vector     EQU      35h  ;Get interrupt vector service
  22. Tsr            EQU      27h  ;Terminate and stay resident
  23. False          EQU      0
  24. True           EQU      1
  25. WinSize        EQU      800
  26.  
  27. Code           SEGMENT
  28.                ASSUME   CS:Code, DS:Code, ES:Code, SS:Code
  29.                ORG      100h
  30.  
  31. _4DOS24h:      JMP      Start  ;Go to installation process
  32.  
  33. Old_Int        EQU      $
  34. Old_Int_Ofs    DW       ?      ;Place holder for old
  35. Old_Int_Seg    DW       ?      ; interrupt vector
  36. Screen_Seg     DW       ?      ;Screen address
  37.  
  38. Device_Hdr_Seg DW       ?                   ;Place holder for address
  39. Device_Hdr_Ofs DW       ?                   ; of device in error
  40. Errcode        DW       ?                   ;Place holder for error code
  41.  
  42. LineSaver      DB   WinSize DUP (?)         ;Screen saver
  43.  
  44. Keys           DB       'AarRiIFf'          ;Possible user response keys
  45. KeysLen        EQU      $-Keys
  46. Codes          DB       2,2,1,1,0,0,3,3     ;Response translation table
  47. Area           DB       'DTRF'              ;Error area codes
  48. ErrType        DB       'RW'                ;Error types codes
  49.  
  50. IgnoreFlag     DB       True                ;Authorization flags
  51. RetryFlag      DB       True
  52. FailFlag       DB       True
  53.  
  54. Msg0           DB   'Write protected disk   '
  55. Msg1           DB   'Unknown unit           '
  56. Msg2           DB   'Drive not ready        '
  57. Msg3           DB   'Unknown command        '
  58. Msg4           DB   'Data Error (CRC)       '
  59. Msg5           DB   'Bad request struc. len.'
  60. Msg6           DB   'Seek error             '
  61. Msg7           DB   'Unknown media type     '
  62. Msg8           DB   'Sector not found       '
  63. Msg9           DB   'Printer out of paper   '
  64. MsgA           DB   'Write fault            '
  65. MsgB           DB   'Read fault             '
  66. MsgC           DB   'General failure        '
  67. Unknown_Ofs    EQU  $-Msg0
  68. MsgU           DB   'Error code unknown     '
  69. MSG_LEN        EQU  $-MsgU
  70.  
  71.  
  72.  
  73. Infoline       DB   '┌'
  74.                DW   78 DUP (01FC4h)
  75.                DB   '┐'
  76.                DB   '│Please hit A(bort),R(etry),I(gno'
  77.                DB   're) or F(ail).           4DOS24H version 1.0  │'
  78.                DB   '│Disk error: N Error type: ? Read'
  79.                DB   '/Write: ? Drive: ? Device name: ????????      │'
  80.                DB   '│Error :                         '
  81.                DB   '                                              │'
  82.                DB   '└'
  83.                DW   78 DUP (01FC4h)
  84.                DB   '┘'
  85.  
  86. ; I know, this is a little clumsy but this saves a lot of code.
  87.  
  88. ;*****************
  89. ; Save user screen
  90. ;*****************
  91.  
  92. SaveScr  PROC     NEAR
  93.  
  94.          PUSH     CX                        ;Save used registers
  95.          PUSH     DS
  96.          PUSH     ES
  97.          PUSH     DI
  98.          PUSH     SI
  99.  
  100.          MOV      CX, WinSize               ;Put overwritten characters in
  101.          PUSH     CS                        ; LineSaver
  102.          POP      ES
  103.          MOV      DI, Offset LineSaver
  104.          MOV      DS, CS:Screen_Seg
  105.          MOV      SI, 0
  106.          CLD
  107. REP      MOVSB
  108.  
  109.          POP      SI
  110.          POP      DI
  111.          POP      ES
  112.          POP      DS
  113.          POP      CX
  114.  
  115.          RET
  116.  
  117. SaveScr  ENDP
  118.  
  119. ;***************
  120. ; Display window
  121. ;***************
  122.  
  123. PutScr   PROC     NEAR
  124.  
  125.          PUSH     CX                        ;Save used registers
  126.          PUSH     ES
  127.          PUSH     SI
  128.          PUSH     DI
  129.  
  130.          MOV      CX, WinSize               ;Display our window
  131.          MOV      SI, Offset InfoLine
  132.          MOV      ES, CS:Screen_Seg
  133.          MOV      DI, 0
  134.          CLD
  135.  
  136. REP      MOVSB
  137.  
  138.          POP      DI
  139.          POP      SI
  140.          POP      ES
  141.          POP      CX
  142.  
  143.          RET
  144.  
  145. PutScr   ENDP
  146.  
  147. ;***************
  148. ; Restore Screen
  149. ;***************
  150.  
  151. ResScr   PROC     NEAR
  152.  
  153.          PUSH     CX                        ;Save used registers
  154.          PUSH     DS
  155.          PUSH     ES
  156.          PUSH     SI
  157.          PUSH     DI
  158.  
  159.          MOV      CX, WinSize               ;Restore user screen
  160.          MOV      ES, CS:Screen_Seg
  161.          MOV      DI, 0
  162.          PUSH     CS
  163.          POP      DS
  164.          MOV      SI, Offset LineSaver
  165.          CLD
  166. REP      MOVSB
  167.  
  168.          POP      DI
  169.          POP      SI
  170.          POP      ES
  171.          POP      DS
  172.          POP      CX
  173.  
  174.          RET
  175.  
  176. ResScr   ENDP
  177.  
  178. ;**********************
  179. ; New interrupt handler
  180. ;**********************
  181.  
  182. New_Int:
  183.  
  184.                PUSHF                        ;Save registers on entry
  185.                PUSH     BX
  186.                PUSH     CX
  187.                PUSH     DX
  188.                PUSH     SI
  189.                PUSH     DI
  190.                PUSH     ES
  191.                PUSH     DS
  192.                PUSH     BP
  193.  
  194.                PUSH     CS                  ;DS has now the right value
  195.                POP      DS
  196.  
  197.                PUSH     AX                  ;AX holds all the information we need
  198.  
  199.                MOV      Device_Hdr_Seg, BP  ;Save Address of device driver header
  200.                MOV      Device_Hdr_Ofs, SI
  201.                MOV      ErrCode, DI         ;Save Error code
  202.                AND      ErrCode, 000Fh
  203.  
  204.                MOV      AH, 0Fh             ;Get video mode
  205.                INT      10h
  206.                CMP      AL, 7
  207.                JE       Mono
  208.                JMP      Color
  209. Mono:
  210.                MOV      Screen_Seg, 0B03Ch  ;Set display address
  211.                JMP      Done
  212. Color:
  213.                CMP      AL, 3
  214.                JLE      NotGraphic
  215.                JMP      OldInt              ;We don't process graphics modes
  216. NotGraphic:
  217.                MOV      Screen_Seg, 0B83Ch
  218. Done:
  219.                CALL     SaveScr             ;Save user screen
  220.                CALL     PutScr              ;Display our window
  221.  
  222.                POP      AX
  223.                TEST     AH, 80h             ;Disk error ?
  224.                PUSH     AX
  225.                JNZ      GetName             ;No. Will now see if device
  226.                                             ; is char device and display name
  227.                MOV      DS, Screen_Seg
  228.                MOV      BYTE PTR DS:[346], 'Y'
  229.  
  230.                AND      AH, 6               ;Get error area info
  231.                MOV      CL, 9
  232.                SHR      AX, CL
  233.                MOV      BX, AX
  234.                MOV      DI, Offset Area
  235.                MOV      AL, CS:[DI+BX]
  236.                MOV      BYTE PTR DS:[374], AL;Display it
  237.                POP      AX
  238.  
  239.                PUSH     AX                  ;Get error type info
  240.                AND      AH, 1
  241.                MOV      CL, 8
  242.                SHR      AX, CL
  243.                MOV      BX, AX
  244.                MOV      DI, Offset ErrType
  245.                MOV      AL, CS:[DI+BX]
  246.                MOV      BYTE PTR DS:[402], AL;Display it
  247.                POP      AX
  248.  
  249.                MOV      BYTE PTR DS:[420], AL  ;Get drive info and
  250.                ADD      BYTE PTR DS:[420], 'A' ;Display it
  251.                PUSH     AX
  252. GetName:
  253.                MOV      DS, CS:Device_Hdr_Seg  ;Get name of device driver
  254.                MOV      SI, CS:Device_Hdr_Ofs  ; only if char device
  255.                TEST     [SI+4],8000h
  256.                JZ       GetError
  257.                MOV      CX, 8
  258.                MOV      ES, CS:Screen_Seg
  259.                MOV      DI, 450                ;Point to Name field
  260.                ADD      SI, 10                 ;Point to device name
  261. GetLoop1:
  262.                MOVSB
  263.                INC      DI                     ;Skip over attribute
  264.                LOOP     GetLoop1               ;Display it
  265.  
  266. GetError:
  267.                PUSH     CS                     ;Reset DS
  268.                POP      DS
  269.                MOV      AX, Unknown_Ofs
  270.                MOV      SI, Offset Msg0
  271.                MOV      CX, MSG_LEN            ;Setup for loop
  272.                CMP      Errcode, 0Ch           ;Error code valid ?
  273.                JG       NotValid
  274.                MOV      AX, CX                 ;Compute offset in
  275.                MUL      ErrCode                ; message table
  276. NotValid:
  277.                ADD      SI, AX
  278.                MOV      DI, 498                ;ES:DI -> Error field
  279.                MOV      ES, Screen_Seg
  280.  
  281. GetLoop2:
  282.                MOVSB
  283.                INC      DI                     ;Skip over attribute
  284.                LOOP     GetLoop2               ;Display it
  285.  
  286.  
  287. GetKey:
  288.                PUSH     CS
  289.                POP      DS
  290.                MOV      AH, 8                  ;Get user input
  291.                INT      21h
  292.  
  293.                PUSH     CS
  294.                POP      ES
  295.                MOV      DI, Offset Keys
  296.                MOV      CX, KeysLen
  297.                CLD
  298.                REPNE    SCASB
  299.                JNZ      GetKey
  300.  
  301.                CALL     ResScr                 ;Restore screen
  302.                MOV      BL, [DI+KeysLen-1]     ;User response in BL
  303.                POP      AX
  304. TestIgnore:
  305.                TEST     AH, 20h                ;Ignore allowed ?
  306.                JNZ      TestRetry
  307.                MOV      CS:IgnoreFlag, False   ;Set relevant flag
  308. TestRetry:
  309.                TEST     AH, 10h                ;Retry allowed ?
  310.                JNZ      TestFail
  311.                MOV      CS:RetryFlag, False    ;Set relevant flag
  312. TestFail:
  313.                TEST     AH, 8                  ;Fail allowed ?
  314.                JNZ      ProcessIgnore
  315.                MOV      CS:FailFlag, False     ;Set relevant flag
  316. ProcessIgnore:
  317.                CMP      BL, 0                  ;User input was Ignore ?
  318.                JNE      ProcessRetry
  319.                CMP      CS:IgnoreFlag, TRUE    ;Ignore allowed ?
  320.                JE       FlagOk
  321.                MOV      BL, 3
  322. ProcessRetry:
  323.                CMP      BL, 1                  ;User input was Retry ?
  324.                JNE      ProcessFail
  325.                CMP      CS:RetryFlag, TRUE     ;Fail allowed ?
  326.                JE       FlagOk
  327.                MOV      BL, 3
  328. ProcessFail:
  329.                CMP      BL, 3                  ;User input was Fail ?
  330.                JNE      FlagOk
  331.                CMP      CS:FailFlag, TRUE      ;Fail allowed
  332.                JE       FlagOk
  333.                MOV      BL, 2
  334. FlagOk:
  335.                MOV      AL, BL
  336.                CMP      AL, 2                  ;4DOS doesn't seem to accept
  337.                JNE      Exit                   ; this return code. So we issue
  338.                INT      23h                    ; the INT 23h ourselves
  339. Exit:
  340.                POP      BP                     ;Restore registers
  341.                POP      DS
  342.                POP      ES
  343.                POP      DI
  344.                POP      SI
  345.                POP      DX
  346.                POP      CX
  347.                POP      BX
  348.                POPF
  349.                IRET
  350.  
  351. OldInt:                                        ;Jump to old interrupt handler
  352.                POP     AX                      ; when in graphics mode
  353.                POP     BP
  354.                POP     DS
  355.                POP     ES
  356.                POP     DI
  357.                POP     SI
  358.                POP     DX
  359.                POP     CX
  360.                POP     BX
  361.                POPF
  362.                JMP     DWORD PTR CS:Old_Int
  363.  
  364. End_Code       EQU     $
  365.  
  366.  
  367. Banner         DB       '4DOS24H - Version 1.1 - Patrick Philippot 1990',13,10
  368. Msg            DB       'Resident part installed',13,10,'$'
  369.  
  370. Start:                                         ;INSTALLATION - This part of the
  371.                MOV      AL, Intr               ; program doesn't remain in memory
  372.                MOV      AH, Get_Vector         ;Save old interrupt vector.
  373.                INT      Dos
  374.                MOV      Word Ptr Old_Int_Seg, ES
  375.                MOV      Word Ptr Old_Int_Ofs, BX
  376.  
  377.                MOV      CS:[12h], Offset New_Int ;Install our handler by modifying
  378.                MOV      CS:[14h], CS             ; the PSP
  379.  
  380. ; The following code is necessary to allow 4DOS24H to be loaded "high" with
  381. ; QEMM or 386 MAX
  382.  
  383.                PUSH     DS
  384.                MOV      DS, CS:[16h]           ;Get parent's PSP
  385.                MOV      DS:[12h], Offset New_Int
  386.                MOV      DS:[14h], CS           ;Modify parent's PSP (LOADHI)
  387.                POP      DS
  388.  
  389.                MOV      DX, offset Banner      ;Display banner
  390.                MOV      AH, 9
  391.                INT      Dos
  392.  
  393.                MOV      DX, Offset End_Code    ;Terminate and Stay Res.
  394.                INT      Tsr
  395.  
  396. Code           ENDS
  397.                END      _4DOS24H
  398.