home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / lib / div0.h < prev    next >
Text File  |  1998-06-08  |  4KB  |  90 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/div/rcs/div0.h $
  15.  * $Revision: 1.2 $
  16.  * $Author: john $
  17.  * $Date: 1994/01/14 15:34:25 $
  18.  *
  19.  * Header file for divide by zero handler
  20.  *
  21.  * $Log: div0.h $
  22.  * Revision 1.2  1994/01/14  15:34:25  john
  23.  * Added counters for number of overflows.
  24.  * 
  25.  * Revision 1.1  1993/09/17  12:37:58  john
  26.  * Initial revision
  27.  * 
  28.  *
  29.  */
  30.  
  31. // D I V 0 . H
  32.  
  33. //==========================================================================
  34. // These are constants passed for the default mode.  If the address of the div
  35. // instruction is not in the Callback (CB) list and also not in the
  36. // Saturate (SAT) list, then the default mode will be used. It will either
  37. // do an int 3 and then dump the registers and break to DOS (DM_ERROR)
  38. // or else it will saturate the result and allow the program to continue
  39. // if DM_SATURATE is specified.
  40. #define DM_ERROR 0
  41. #define DM_SATURATE 1
  42.  
  43.  
  44. //==========================================================================
  45. // This initializes and grabs the Divide by 0 Exception.  See above for mode.
  46. // Returns 1=Installed OK, 0=Failed.  Failed probably means old DPMI host, but
  47. // I think that as long as we use DOS4GW v1.90 or higher we're ok.
  48. extern int div0_init(int mode);
  49. extern void div0_close();           // Closes it.
  50.  
  51. //==========================================================================
  52. // Sets the default handler behavior.  See above constant descriptions.
  53. extern void div0_set_mode(int mode);
  54.  
  55. //==========================================================================
  56. // Adds a handler to the list of handlers to jump to whem an overflow occurs.
  57. // All registers, etc should be exactly as before the DIV instruction. This
  58. // doesn't work within C. This returns 1 if ok, and 0 if there isn't any more
  59. // "slots" available.  The number of slots can be changed in div0.asm by
  60. // changing the MAX_SIZE constant.  MAX_SIZE = 100 now.
  61. // In ASM, the parameters are:
  62. // EAX = *div_addr, EDX=*handler_addr, Return value in EAX.
  63. extern int div0_set_handler( void *div_addr, void *handler_addr );
  64.  
  65. //==========================================================================
  66. // Same as above, but saturates the result instead of jumping to a handler.
  67. // Doesn't need the void*handler_addr parameter.  Uses the same MAX_SIZE.
  68. extern int div0_set_saturate( void *div_addr );
  69.  
  70. //==========================================================================
  71. // These three variables count the number of times the divide by zero handler
  72. // has been used. 
  73. //   - div0_num_handled_by_cblist is the number of times a divide exception
  74. //     has occurred and was corrected by calling a user-specified function.
  75. //   - div0_num_handled_by_satlist is the number of times a divide exception
  76. //     has occured and the result was saturated because it specifically was
  77. //     in the saturation list.
  78. //   - div0_num_saturated are the divides that aren't handled by the programmer
  79. //     explicitly, but the handler went ahead and sautrated anyway.  These
  80. //     probably shouldn't be happening very often.
  81.  
  82. extern int div0_num_handled_by_cblist;
  83. extern int div0_num_handled_by_satlist;
  84. extern int div0_num_saturated;
  85.  
  86.  
  87.  
  88.  
  89. 
  90.