SparrowDefines contains many #defines used by the library or which may be usefull for your application
sparrowDefines | SparrowDefines contains many #defines used by the library or which may be usefull for your application |
Macros | |
Fixed Point Arithmetic Constants | The following #defines are for the fixed point arithmetic in sparrow3d. |
Fixed Point Arithmetics | These are some #defines for fast multiplication and division of fixed point numbers. |
Fixed Point Conversion | These conversions are no function calls, but defines. |
Generic Buttons | The following (long) list of #defines gives you the numbers and names of the generic device buttons or of the buttons on the explicit device. |
Generic Buttons Names | |
Generic Buttons Masks | Mask of the buttons, Useful for spPollKeyboardInputs last parameter. |
Directions | These are some #defines e.g. |
SP_NO_TOUCHSCREEN_EMULATION | Used by spSetTouchscreenEmulationButtons |
SP_ALPHA_COLOR | If alphatest is enabled, this (pink) color will not be drawn, it is “transparent”. |
SP_DEVICE_STRING | Gives you the name of the device, e.g. |
The following #defines are for the fixed point arithmetic in sparrow3d. Change the values only, if you know, what you are doing. There should be optimal already.
SP_ACCURACY | Defines how many bits are used for the decimal place |
SP_HALF_ACCURACY | The half of SP_ACCURACY |
SP_ACCURACY_FACTOR | 2 ^ SP_ACCURACY. Needed for float conversation |
SP_SQRT_ACCURACY | Accurary of the internal sqrt lookuptable |
SP_PI | Fixed point Pi |
SP_MATH_ACCURACY | (In)accuracy of the cos and sin lookup table |
SP_ONE | 1.0f in fixed point |
These are some #defines for fast multiplication and division of fixed point numbers. Use them like normal functions, e.g. Sint32 a = spMul(b,c); instead of a = b * c (which will not work). However multiplying a fixed point number with a “normal” integer just works with the normal multiplication. For addition you have to convert!
spMul(a,b) | Multiplies fixed point number a with the fixed point number b |
spMulHigh(a,b) | Does the same as spMul(a,b), but with guaranteed high precision |
spMulLow(a,b) | Does the same as spMul(a,b), but maybe with lower precision |
spDiv(a,b) | Divides fixed point number a with the fixed point number b |
spDivHigh(a,b) | Does the same as spDiv(a,b), but with guaranteed high precision |
spDivLow(a,b) | Does the same as spDiv(a,b), but maybe with lower precision |
spSquare(a) | Squares the fixed point number a with the help of spMul(a,b). |
These conversions are no function calls, but defines. That means before the compiler compiles the code, it is replaced by the defined rule. E.g., you want to convert the float a to a fixed point number using spFloatToFixed. You call
Sint32 foo = spFloatToFixed(bar);
Internal the compiler will make this:
Sint32 foo = ((Sint32)((float)(bar)*SP_ACCURACY_FACTOR));
This saves you a function call. But it gets MUCH cheaper, if you don’t have a float variable as parameter, but a number like 1.5f. Example:
Sint32 foo = spFloatToFixed(1.5);
will become to:
Sint32 foo = ((Sint32)((float)(1.5f)*SP_ACCURACY_FACTOR));
As no unknown parameter is in this equation the compiler will calculate it at compile time, which means: In you final binary, the (binary) code will just be:
Sint32 foo = 98304;
which is obviouly incredible fast.
The following (long) list of #defines gives you the numbers and names of the generic device buttons or of the buttons on the explicit device. The Dingoo e.g. has the A button on the right, but GP2X and others on the left. That means: If you want the button with the CAPTION “A” use SP_BUTTON_A, but if you want the LEFT Button on every device use SP_BUTTON_LEFT, which will be SP_BUTTON_A on the gp2x or SP_BUTTON_Y on the Dingoo. The same for the names. Buttons like SP_BUTTON_L or similar are defined just one time - because they are the same on every device.
Mask of the buttons, Useful for spPollKeyboardInputs last parameter.
Used by spSetTouchscreenEmulationButtons
Prints all following keyboard input (that is numbers, letters and symbols) into the passed buffer.
PREFIX void spPollKeyboardInput( char * buffer, int bufferSize, Sint32 enter_key_mask )
Sets, whether on systems without touchscreen or mouse (like the GP2X F100) a touchscreen is emulated.
PREFIX void spSetTouchscreenEmulationButtons( int switch_button, int ok_button )