Advertisement
Guest User

Bit Mask debug

a guest
Dec 7th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. // Bit Masking Easy Reference Chart
  2. // Type/# _______________________________________________________________________________________
  3. // Byte |0 |1 |2 |3 |
  4. // |-------------------------------------------------------------------------------------|
  5. // Nibble |0 |1 |2 |3 |4 |5 |6 |7 |
  6. // |-------------------------------------------------------------------------------------|
  7. // 2 Bits |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |10 |11 |12 |13 |14 |15 |
  8. // |-------------------------------------------------------------------------------------|
  9. // Bits |0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
  10. // |-------------------------------------------------------------------------------------|
  11. //
  12. // All variables haves 4 Bytes, 8 Nibbles, 16 2Bits and/or 32 bits.
  13. // Byte range 0-255
  14. // Nibble range 0-15
  15. // 2Bit range 0-3
  16. // bit range 0 or 1
  17. //
  18. // One Nibble Translated:
  19. // Binary = Decimal
  20. // 0000 = 0
  21. // 0001 = 1
  22. // 0010 = 2
  23. // 0011 = 3
  24. // 0100 = 4
  25. // 0101 = 5
  26. // 0110 = 6
  27. // 0111 = 7
  28. // 1000 = 8
  29. // 1001 = 9
  30. // 1010 = 10
  31. // 1011 = 11
  32. // 1100 = 12
  33. // 1101 = 13
  34. // 1110 = 14
  35. // 1111 = 15
  36. //
  37. // Note: Therefore Setting Bits 4-7 to 1 will make Nibble 1 15.
  38. // Therefore Setting Bits 0-7 will make Nibble 0 & 1 15, and Byte 0 255
  39. //
  40. // Linear Quest Var:
  41. // BYTE:
  42. // 0: Step1.
  43. // 1: Step2.
  44. // ...
  45. // 255: Step256.
  46. // Nibble:
  47. // 0: Step1.
  48. // 1: Step2.
  49. // ...
  50. // 14: Step16.
  51. //
  52. // Non-linear Quest Var:
  53. // BYTE: Main Quest Line
  54. // NIBBLE: Current-Step
  55. // BIT: Step
  56. // BIT: Step
  57. // BIT: Step
  58. // BIT: Step
  59. // NIBBLE: Sub-Quest
  60. // 0-15: Step 1-16
  61.  
  62. // Dev Note: There are plans to make 64 bit quest variables.
  63.  
  64. 001-1.gat,40,36,0|script|BitMaskDebug|175,
  65. {
  66.  
  67. mes "[Bit Mask Debug]";
  68. mes "\"What you wyou like to do?\"";
  69. menu
  70. "Shift Byte 1.", L_ByteShift,
  71. "Shift Nibble 0.", L_NibbleShift,
  72. "Shift Bit 4.", L_BitShift,
  73. "Done.", L_Close;
  74.  
  75. L_ByteShift:
  76. set @debugexample, ((DEBUGEXAMPLE & BYTE_1_MASK) >> BYTE_1_SHIFT);
  77. message strcharinfo(0), @debugexample;
  78. if (@debugexample == 175)
  79. goto L_ByteUnset;
  80.  
  81. mes "Byte 1 set to 175";
  82. set DEBUGEXAMPLE, (DEBUGEXAMPLE & ~(BYTE_1_MASK) | (175 << BYTE_1_SHIFT));
  83. goto L_Close;
  84.  
  85. L_ByteUnset:
  86. mes "Byte 1 set to 0";
  87. set DEBUGEXAMPLE, (DEBUGEXAMPLE & ~(BYTE_1_MASK) | (0 << BYTE_1_SHIFT));
  88. goto L_Close;
  89.  
  90. L_NibbleShift:
  91. set @debugexample, ((DEBUGEXAMPLE & NIBBLE_0_MASK) >> NIBBLE_0_SHIFT);
  92. message strcharinfo(0), @debugexample;
  93. if (@debugexample == 10)
  94. goto L_NibbleUnset;
  95.  
  96. mes "Nibble 0 set to 10";
  97. set DEBUGEXAMPLE, (DEBUGEXAMPLE & ~(NIBBLE_0_MASK) | (10 << NIBBLE_0_SHIFT));
  98. goto L_Close;
  99.  
  100. L_NibbleUnset:
  101. mes "Nibble 0 set to 0";
  102. set DEBUGEXAMPLE, (DEBUGEXAMPLE & ~(NIBBLE_0_MASK) | (0 << NIBBLE_0_SHIFT));
  103. goto L_Close;
  104.  
  105. L_BitShift:
  106. set @debugexample, ((DEBUGEXAMPLE & NIBBLE_1_MASK) >> NIBBLE_1_SHIFT);
  107. message strcharinfo(0), @debugexample;
  108. if (DEBUGEXAMPLE & (1 << 4))
  109. goto L_BitUnset;
  110.  
  111. mes "Bit 4 Set to 1";
  112. set DEBUGEXAMPLE, DEBUGEXAMPLE | (1 << 4);
  113. set DEBUGEXAMPLE, DEBUGEXAMPLE | (1 << 5);
  114. set DEBUGEXAMPLE, DEBUGEXAMPLE | (1 << 6);
  115. set DEBUGEXAMPLE, DEBUGEXAMPLE | (1 << 7);
  116. goto L_Close;
  117.  
  118. L_BitUnset:
  119. mes "Bit 4 Set to 0";
  120. set DEBUGEXAMPLE, DEBUGEXAMPLE &~ (1 << 4);
  121. set DEBUGEXAMPLE, DEBUGEXAMPLE &~ (1 << 5);
  122. set DEBUGEXAMPLE, DEBUGEXAMPLE &~ (1 << 6);
  123. set DEBUGEXAMPLE, DEBUGEXAMPLE &~ (1 << 7);
  124. goto L_Close;
  125.  
  126. L_Close:
  127. set @debugexample, 0;
  128. close;
  129.  
  130. OnInit:
  131. if (debug)
  132. end;
  133. disablenpc "BitMaskDebug";
  134. end;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement