freddix wrote: I've checked over the net and on my C book to understand how I can set/clear or test a bit in an int value but it remain unclear for me :(
I've found how to test !
int TestBit( int Var, int itID ){ return Var & ( 1<<BitID ); }
But not how to set/clear.
Can someone help me ?
EDIT : I think I've found a solution :
void SetBit( int *Var, int BitID ){ *Var = *Var | ( 1<<BitID ); }
void ClearBit( int *Var, int BitID ){ *Var = *Var ^ ( 1<<BitID ); }
Do you think it's correct ?
Regards, Freddix / AmiDARK
The ClearBit function you've got is actually a toggle bit function. If you call it twice on the same variable with the same bit you end up with what you started out with. Also the test bit doesn't return a 1 on true. The correct versions are as follows:
void ClearBit( int *Var, int BitID ){
*Var = *Var & ~( 1<<BitID );
}
int TestBit(int Var, int BitID ){
return ((Var>>BitID) & 1);
}
If you're using C++ you can use std::bitset instead though. That'll save you from having to think about it.
void ClearBit( int *Var, int BitID ){ *Var = *Var ^ ( 1<<BitID ); }
As pointed out, this toggles the bits, not clear them. I could instantly tell you how to clear a bit in E, but my C is a bit rusty so not all these brackets may be required:
void ClearBit( int *Var, int BitID ){ *Var = *Var & (~( 1<<BitID )); }
edit: Ooops, hadn't noticed that Samurai_Crow had actually posted corrected versions.
@Samurai_Crow Ok Thank you for these changes. I will test them today :)
@yescop: Yes, the project continue. I don't tell all news and progress because I do small things by small things and it could take too much post to tell everything each time .. Here is my dev log from alchimie to now :
(translated by google cos I don't have time now to translate it manually :p, the original is in French ) : Quote:
2009.12.04: ------------ - Addition of internal management functions of bits (set / clear / test) - Added function DESyncMask () and its management in the Proceedings of cameras.
2009.11.29: ------------ - Added playback functions of free memory - Added functions to enable / disable the Escape key to exit the application. - Placing orders DESyncOn () DESyncOff () DESyncRate (VAL);
2009.11.27: ------------ - Fix the glClear mode multi-cameras to delete only the area of the current camera.
2009.11.25: ------------ - Added timer.device to manage functions of frame rate and animations. - Added functions DEScreenFPS () and DEStatistics ()
2009.11.23: ----------- - Improved user function DEKeyState () - Improved internal function MyKeyboardFunc () management via the keyboard MiniGL. - Fix for managing the backdrop for the cameras not to erase the traces Basic2D. - Added function: DEBoxEx (Left, Top, Right, Bottom, Color1, Color2, color3, color4) - Added support for background color cameras (Backdrop) - Added support for the close button of window to exit the application. - Addition of various orders of "core".
2009.11.11: ------------ - If object 3D insensitive to light, turning off the global illumination on the object.
2009.11.08: ----------- - Amendments to applications textures to match DarkBASIC Professional - Change the camera to move as default DarkBASIC Professional - Change the camera to move as default DarkBASIC Professional
2009.11.03: ----------- - Added support for various keyboard functions (scancode, Keystation, special keys: up, down, left, right, function keys F1 to F12
2009.10.17: ----------- BASIC 3D - Added support for bilinear / trilinear / no filtering on 3D objects. - Added support for extra propoerties (fog, light, ambient 3D objects sensitivity) - Added support for object Ambience, Specular, Diffuse and Emissive Properties functions. SETUP - Added support for switching from windowed to fullscreen and reverse.
2009.10.16: ------------------ BASIC 3D - Added support for Ghost Object functions (On / Off Ex with support for dark ghost mode too) - Added support for ScaleObject () function IMAGE - Added DrawToFront & DrawToBack priority function to change between 2D and 3D drawing.
2009.10.12: ------------------ BASIC 3D - Added support for transparency using BLENDING command set: Set One Alpha Mapping.
2009.10.05: ------------------ BASIC 3D - Fixed Camera & Objects rotation to be the same than Default DarkBASIC Professional ones. - Added support for 3D Objects bodies.
2009.10.05: ------------------ FILE - Added support for FILES command set (OpenToRead, OpenToWrite, Close, MakeMemblockFromfile)
2009.09.01: ----------------- Basic3D - Support for Loading Images as Images & Textures - Support for Objects Texturing, Lighting (Light 0) Normals. LIGHTS - Adding Ambient light support IMAGE - Adding some IMAGE command set MEMBLOCK - Adding some MEMBLOCK command set SYSTEM - Internal structure object development.
All we have to decide is what to do with the time that is given to us.
@kas1e in fact, I don't know ... I progress on "feeling". That mean .. that I develop things in a total chaotic order .. Sound can be the next thing I'll start to work ... or maybe not ...
However, I should add 2D / 3D sound support soonly because it's not the hardest task to do :p
Regards, Freddix / AmiDARK
All we have to decide is what to do with the time that is given to us.