home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / GAMES / infocom_src.lha / fns.c < prev    next >
Text File  |  1993-03-03  |  2KB  |  172 lines

  1. /*
  2. **    File:    fns.c
  3. **
  4. **    (C)opyright 1987-1992 InfoTaskforce.
  5. */
  6.  
  7. #include    "infocom.h"
  8.  
  9. Void
  10. plus ( a,b )
  11. word    a,b ;
  12. {
  13.     store ( a + b ) ;
  14. }
  15.  
  16. Void
  17. minus ( a,b )
  18. word    a,b ;
  19. {
  20.     store ( a - b ) ;
  21. }
  22.  
  23. Void
  24. multiply ( a,b )
  25. word    a,b ;
  26. {
  27.     store ((word)((signed_word)a * (signed_word)b)) ;
  28. }
  29.  
  30. Void
  31. divide ( a,b )
  32. word    a,b ;
  33. {
  34.     store ((word)((signed_word)a / (signed_word)b)) ;
  35. }
  36.  
  37. Void
  38. mod ( a,b )
  39. word    a,b ;
  40. {
  41.     store ((word)((signed_word)a % (signed_word)b)) ;
  42. }
  43.  
  44. Void
  45. std_random ( param1 )
  46. word    param1 ;
  47. {
  48.     extern word        random1 ;
  49.     extern word        random2 ;
  50.  
  51.     register word    temp ;
  52.  
  53.     temp = random1 >> 1 ;
  54.     if ( random2 & 0x0001 )
  55.         temp |= 0x8000 ;
  56.     random1 = random2 ;
  57.     temp = ( random2 ^= temp ) ;
  58.     store (((int)( temp & 0x7FFF ) % (int)param1 ) + 1 ) ;
  59. }
  60.  
  61. Void
  62. plus_random ( param1 )
  63. word    param1 ;
  64. {
  65.     extern word        random1 ;
  66.     extern word        random2 ;
  67.     extern word        random3 ;
  68.     extern word        random4 ;
  69.  
  70.     register word    temp ;
  71.  
  72.     if ((signed_word)param1 <= 0)
  73.     {
  74.         random3 = random4 = -((signed_word)param1) ;
  75.         store ( (word)1 ) ;
  76.         return ;
  77.     }
  78.  
  79.     if ( random4 != 0 )
  80.     {
  81.         /*
  82.         **    Note that even if random3 & ramdom4
  83.         **    were unsigned, there is no way that
  84.         **    they can ever be negative !
  85.         */
  86.  
  87.         if ( ++random3 >= random4 )
  88.             random3 = 0 ;
  89.         temp = random3 ;
  90.     }
  91.     else
  92.     {
  93.         temp = random1 >> 1 ;
  94.         if ( random2 & 0x0001 )
  95.             temp |= 0x8000 ;
  96.         random1 = random2 ;
  97.         temp = ( random2 ^= temp ) ;
  98.     }
  99.     store (((int)( temp & 0x7FFF ) % (int)param1 ) + 1 ) ;
  100. }
  101.  
  102. Void
  103. less_than ( a,b )
  104. word    a,b ;
  105. {
  106.     ret_value ( (signed_word)a < (signed_word)b ) ;
  107. }
  108.  
  109. Void
  110. greater_than ( a,b )
  111. word    a,b ;
  112. {
  113.     ret_value ( (signed_word)a > (signed_word)b ) ;
  114. }
  115.  
  116. Void
  117. bit ( a,b )
  118. word    a,b ;
  119. {
  120.     ret_value ((( b & ( ~a )) == 0)) ;
  121. }
  122.  
  123. Void
  124. or ( a,b )
  125. word    a,b ;
  126. {
  127.     store ( a | b ) ;
  128. }
  129.  
  130. Void
  131. not ( a )
  132. word    a ;
  133. {
  134.     store ( ~a ) ;
  135. }
  136.  
  137. Void
  138. and ( a,b )
  139. word    a,b ;
  140. {
  141.     store ( a & b ) ;
  142. }
  143.  
  144. Void
  145. compare ()
  146. {
  147.     extern word        param_stack[] ;
  148.  
  149.     register word    *param_ptr = ¶m_stack[0] ;
  150.     register word    num_params ;
  151.     register word    param1 ;
  152.  
  153.     num_params = *param_ptr++ ;
  154.     param1 = *param_ptr++ ;
  155.     while ( --num_params != 0 )
  156.     {
  157.         if ( param1 == *param_ptr++ )
  158.         {
  159.             ret_value ( TRUE ) ;
  160.             return ;
  161.         }
  162.     }
  163.     ret_value ( FALSE ) ;
  164. }
  165.  
  166. Void
  167. cp_zero ( a )
  168. word    a ;
  169. {
  170.     ret_value (( a == 0 )) ;
  171. }
  172.