y_bit.inc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**--------------------------------------------------------------------------**\
  2. ===========================
  3. Y Sever Includes - Bit Core
  4. ===========================
  5. Description:
  6. Provides functions for bit manipulation and bit arrays greater than 32bits.
  7. The arrays are usually bigger than required due to cell boundaries but this
  8. shouldn't cause a major problem (bit tests on the 101st bit of a 100 bit
  9. array won't return 0 for out of bounds, but the 129th will).
  10. Note that y_commands has a few optimisations which bypass the code in here
  11. so any modifications to bit array layouts will need to be reflected there.
  12. Legal:
  13. Version: MPL 1.1
  14. The contents of this file are subject to the Mozilla Public License Version
  15. 1.1 (the "License"); you may not use this file except in compliance with
  16. the License. You may obtain a copy of the License at
  17. http://www.mozilla.org/MPL/
  18. Software distributed under the License is distributed on an "AS IS" basis,
  19. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  20. for the specific language governing rights and limitations under the
  21. License.
  22. The Original Code is the YSI bit include.
  23. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  24. Portions created by the Initial Developer are Copyright (C) 2011
  25. the Initial Developer. All Rights Reserved.
  26. Contributors:
  27. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  28. Thanks:
  29. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  30. ZeeX - Very productive conversations.
  31. koolk - IsPlayerinAreaEx code.
  32. TheAlpha - Danish translation.
  33. breadfish - German translation.
  34. Fireburn - Dutch translation.
  35. yom - French translation.
  36. 50p - Polish translation.
  37. Zamaroht - Spanish translation.
  38. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  39. for me to strive to better.
  40. Pixels^ - Running XScripters where the idea was born.
  41. Matite - Pestering me to release it and using it.
  42. Very special thanks to:
  43. Thiadmer - PAWN, whose limits continue to amaze me!
  44. Kye/Kalcor - SA:MP.
  45. SA:MP Team past, present and future - SA:MP.
  46. Version:
  47. 0.2
  48. Changelog:
  49. 21/10/12:
  50. Changed "Bit_Display" to print in the correct order.
  51. 22/02/12:
  52. Added the "BITS" iterator.
  53. 01/12/08:
  54. Rewrote most of the code to use shifts and ands not divs and mods.
  55. 24/06/07:
  56. Added Bit_GetBit
  57. 18/06/07:
  58. Added Bit_GetCount
  59. 30/04/07:
  60. Added Bit_SetAll
  61. 15/04/07:
  62. First version.
  63. Functions:
  64. Public:
  65. -
  66. Core:
  67. -
  68. Stock:
  69. Bit_Set - Sets a slot to the given value.
  70. Bit_Get - Gets a slot state.
  71. Bit_SetAll - Sets all the slots in an array to the same thing.
  72. Bit_GetCount - Gets the number of 1s in a bit array.
  73. Static:
  74. -
  75. Inline:
  76. Bit_Bits - Gets the number of cells required for a bit array.
  77. Bit_Let - Sets a slot to 1.
  78. Bit_Vet - Sets a slot to 0.
  79. Bit_GetBits - Gets the bit at a slot unsafely.
  80. API:
  81. -
  82. Callbacks:
  83. -
  84. Definitions:
  85. CELLSHIFT - Number of bits that can hold "cellbits"
  86. Enums:
  87. -
  88. Macros:
  89. -
  90. Tags:
  91. Bit - Bit array type.
  92. Variables:
  93. Global:
  94. -
  95. Static:
  96. -
  97. Commands:
  98. -
  99. Compile options:
  100. -
  101. \**--------------------------------------------------------------------------**/
  102. #if defined _INC_y_bit
  103. #endinput
  104. #endif
  105. #define _INC_y_bit
  106. #include "..\YSI_Internal\y_version"
  107. #include "..\YSI_Core\y_debug"
  108. #include "..\YSI_Core\y_utils"
  109. #include "..\YSI_Core\y_cell"
  110. #include "y_bit/impl"
  111. #if defined YSI_TESTS
  112. #include "..\YSI_Core\y_testing"
  113. #include "y_bit/tests"
  114. #endif