home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / ERROR1.ASM < prev    next >
Assembly Source File  |  1994-11-15  |  5KB  |  176 lines

  1.     page    66,132
  2. ;******************************** ERROR1.ASM *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. ;----------------------------------------------------------------------------
  13.     extrn    one_beep:far
  14.     extrn    draw_box:far
  15.     extrn    library_terminate:far
  16.     extrn    restore_window:far
  17.     extrn    box_shrink:far
  18.     extrn    save_window:far
  19.     extrn    key_read:far
  20.     extrn    display_string_fill:far
  21.     extrn    window_string:far
  22.         
  23.     extrn    bar_hotkey_color:byte
  24.     extrn    entry_seg:word
  25.     extrn    entry_bp:word
  26.     extrn    error_number:byte
  27.     extrn    error_flags:byte
  28.     extrn    error_index:word
  29. ;-----------------------------------------------------------------------------
  30. comment 
  31. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  ERROR  )
  32. LIB_ERROR_HANDLER1 - handle pre defined library errors
  33. ;
  34. ; inputs:     al = error number (see error_index)
  35. ;          ah = flags 80h = fatal_error, abort after display
  36. ;                        40h = non_fatal1, return to retry
  37. ;                        20h = non_fatal2, return after any key press
  38. ;                        10h = fatal_return, fatal error but return after key
  39. ;                        08h = spare
  40. ;                        04h = spare
  41. ;             02h = spare
  42. ;             01h = spare
  43. ;
  44. ; output:  displayed error message as follows:
  45. ;          1 - Incompatable display mode
  46. ;          2 - Code error, Contact program author for possible
  47. ;              problem resolution
  48. ;          3 - Disk read error, Press any key to contine
  49. ;          4 - Fatal disk error, Press any key
  50. ;          5 - Out of memory, Press any key to abort current operation
  51. ;          6 - Path change failed, Press any key
  52. ;          7 - insufficient DOS memory to run program,
  53. ;              Press any key to abort.
  54. ;          8 - Error in finding/reading quote file QUOTE.DAT
  55. ;          9 - Memory manager transfer error.  This is usually
  56. ;              a programming error.  Contact the author for assistance.
  57. ;         10 - Open of above file failed, possibly the file does not
  58. ;              exist or is not in correct directory.
  59. ;         11 - The program configuration (.CFG) file is missing an <end>
  60. ;              statement.   press any key to continue
  61. ;
  62. ; note:  LIB_ERROR_HANDLER1 is intended for library use only, but can be
  63. ;        called from application.               
  64. ;* * * * * * * * * * * * * *
  65. 
  66.     public    lib_ERROR_HANDLER1
  67. lib_ERROR_HANDLER1    proc    far
  68.     apush    ax,bx,si,ds
  69.     sub    bx,bx
  70.     mov    bl,al
  71.     shl    bx,1
  72.     add    bx,offset error_index-2  ;adjust of errors starting with 1
  73.     mov    si,word ptr cs:[bx]     ;get ptr to error msg
  74.     push    cs
  75.     pop    ds
  76.     call    error_HANDLER1
  77.     apop    ds,si,bx,ax
  78.     retf    
  79. lib_ERROR_HANDLER1    endp
  80. comment 
  81. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  ERROR  )
  82. ERROR_HANDLER1 - handle fatal errors
  83. ;
  84. ; inputs:     ds:si = error text terminated with null character (00).
  85. ;                ah = flags 80h - fatal_error, abort after display
  86. ;                           40h - non_fatal1, return to retry
  87. ;                           20h - non_fatal2, return after any key press
  88. ;                           10h - fatal_return, fatal error but return after key
  89. ;                           08h - spare
  90. ;                04h - spare
  91. ;                02h - spare
  92. ;                01h - spare
  93. ;
  94. ; output:    ax = last keypress if a return was requested.
  95. ;
  96. ; notes:  If the abort option is requested, the library will be closed and
  97. ;         the DOS return call executed.
  98. ;* * * * * * * * * * * * * *
  99. 
  100.  
  101. error_key_save    dw    0    ;user key press used to confirm box is viewed.
  102.  
  103.     public    ERROR_HANDLER1
  104. ERROR_HANDLER1    proc    far
  105.     apush    bx,cx,dx,si,di,ds,es
  106.     mov    cs:entry_seg,ds
  107.     mov    bx,cs
  108.     mov    ds,bx
  109.     mov    es,bx
  110.  
  111.     mov    entry_bp,si
  112.     mov    error_number,al
  113.     mov    error_flags,ah
  114.     call    one_beep
  115. ;
  116. ; display with error in box, es:si point at error
  117. ;
  118. eh_box_display:
  119.     mov    ah,byte ptr bar_hotkey_color
  120.     mov    dx,0101h
  121.     mov    bx,0630h
  122. ;
  123. ; check if screen save needed
  124. ;
  125.     test    cs:error_flags,non_fatal1+non_fatal2+fatal_return
  126.     jz    eh_boxit    ;jmp if no window save
  127.     call    save_window
  128. eh_boxit:
  129.     call    draw_box
  130.     call    box_shrink
  131.     push    es
  132.     pop    ds
  133.     mov    ah,byte ptr bar_hotkey_color
  134. ;
  135. ; display the error text inside the box
  136. ;
  137. eh_cont2:
  138.     push    ds
  139.     mov    si,cs:entry_bp
  140.     mov    ds,cs:entry_seg
  141.     call    window_string
  142.     pop    ds
  143. ;
  144. ; check type of exit processing, and wait for key if necessary, then exit
  145. ;
  146. error_key:
  147.     call    KEY_READ            ;get key press
  148.     mov    cs:error_key_save,ax        ;save keypress
  149. ;
  150. ; check if screen restore needed
  151. ;
  152.     test    cs:error_flags,non_fatal1+non_fatal2+fatal_return
  153.     jz    eh_error_key        ;jmp if no window save
  154.     call    restore_window
  155. eh_error_key:
  156. ;
  157. ; determine what type of exit is needed
  158. ;
  159.     apop    es,ds,di,si,dx,cx,bx
  160.     test    cs:error_flags,fatal_error
  161.     jnz    error_abort        ;jmp if no return from error
  162.     mov    ax,cs:error_key_save    ;restore key press
  163.     retf
  164.  
  165. error_abort:
  166.     mov    ax,0
  167.     call    library_terminate
  168.     mov    ah,4ch
  169.     int    21h
  170.     
  171. ERROR_HANDLER1    endp
  172. ;---------------------------------------------------------------------------
  173.  
  174. LIBSEG    ENDS
  175.     end
  176.