[Include] Bit Functions
#1

Include contains functions for manipulating bits / cells.

PHP Code:
/****************************************************************************************************
 *                                                                                                  *
 *                                     )(   Bit Functions   )(                                      *
 *                                                                                                  *
 * Copyright © 2019 Abyss Morgan. All rights reserved.                                              *
 *                                                                                                  *
 * Website:  adm.ct8.pl                                                                             *
 * Download: adm.ct8.pl/r/download                                                                  *
 *                                                                                                  *
 * Plugins: None                                                                                    *
 * Modules: None                                                                                    *
 *                                                                                                  *
 * File Version: 1.8.0                                                                              *
 *                                                                                                  *
 * bit 0 - 31:                                                                                      *
 * (bit 31) --> 11111111000000001111010001010000 <-- (bit 0)                                        *
 *                                                                                                  *
 * Example cell mode:                                                                               *
 * Mode 2 (cell id 15) --> 11 11 11 11 00 00 00 00 11 11 01 00 01 01 00 00 <-- (cell id 0)          *
 * Mode 4 (cell id 7) --> 1111 1111 0000 0000 1111 0100 0101 0000 <-- (cell id 0)                   *
 * Mode 8 (cell id 3) --> 11111111 00000000 11110100 01010000 <-- (cell id 0)                       *
 * Mode 16 (cell id 1) --> 1111111100000000 1111010001010000 <-- (cell id 0)                        *
 *                                                                                                  *
 * General Macros:                                                                                  *
 * GetValueBit(value,bit);                                                                          *
 * SetValueBit(&value,bit,power);  //power 0 or 1                                                   *
 * SetValueBitTrue(&value,bit);                                                                     *
 * SetValueBitFalse(&value,bit);                                                                    *
 * GetCellValue(value,cellid,mode);                                                                 *
 * SetCellValue(&value,cellid,mode,power);                                                          *
 * GetCellValueEx(value,offset,cellsize);                                                           *
 * SetCellValueEx(&value,offset,cellsize,power);                                                    *
 * InvertValue(value);                                                                              *
 * InvertValueEx(value,key); //default key 0xFFFFFFFF                                               *
 * bool:CheckValue(value,&count=0); //even - false,uneven - true                                    *
 *                                                                                                  *
 * File Byte Macros:                                                                                *
 * ExtractValue(value,&byte1,&byte2,&byte3,&byte4);                                                 *
 * ExtractFloat(Float:value,&byte1,&byte2,&byte3,&byte4);                                           *
 * MergeValue(&value,byte1,byte2,byte3,byte4);                                                      *
 * MergeFloat(&Float:value,byte1,byte2,byte3,byte4);                                                *
 * MergeValueEx(byte1,byte2,byte3,byte4);                                                           *
 * Float:MergeFloatEx(byte1,byte2,byte3,byte4);                                                     *
 *                                                                                                  *
 * Dynamic Toggle Config Macros:                                                                    *
 * GetConfigAddress(itemid);                                                                        *
 * GetConfigBit(itemid);                                                                            *
 * GetConfigSize(max_items);                                                                        *
 * IsToggleConfigInformation(variable,itemid);                                                      *
 * ToggleConfigInformation(variable,itemid,value); //values: 1/0                                    *
 *                                                                                                  *
 ****************************************************************************************************/ 
Download:
BitFunctions.inc

Example:
PHP Code:
new ExampleConfig[GetConfigSize(MAX_PLAYERS)];
//get:
IsToggleConfigInformation(ExampleConfig,playerid);
//set:
ToggleConfigInformation(ExampleConfig,playerid,1); 
Value Extract/Merge:
PHP Code:
new val 0x89ABCDEF;
new 
abcd;
ExtractValue(val,a,b,c,d);
printf("%x %x %x %x",a,b,c,d); //prints 89 AB CD EF
new tmp 0;
MergeValue(tmp,a,b,c,d);
printf("%x",tmp); //prints 89ABCDEF 
Reply


Messages In This Thread
Bit Functions - by AbyssMorgan - 09.10.2015, 18:31
Re: Bit Functions - by n0minal - 09.10.2015, 19:33
Re: Bit Functions - by AbyssMorgan - 09.10.2015, 19:36
Re: Bit Functions - by AbyssMorgan - 06.02.2016, 18:08
Re: Bit Functions - by AbyssMorgan - 15.03.2016, 19:16
Re: Bit Functions - by iKevin - 15.03.2016, 19:39
Re: Bit Functions - by AbyssMorgan - 27.03.2017, 15:28
Re: Bit Functions - by czop1223 - 28.05.2017, 18:33
Re: Bit Functions - by AbyssMorgan - 28.05.2017, 20:06
Re: Bit Functions - by czop1223 - 02.06.2017, 11:58

Forum Jump:


Users browsing this thread: 1 Guest(s)