Actually, you can not put explicit code outside of functions, but you are allowed to put initial values for all variables. These must be constants, and can only be either arrays like (1,45,3,21,4,5...} or integers like 2.
They can also include basic expressions like:
Code:
#define M_PI 3.14159265358979
int my_circumference=2*M_PI
This code is executed, and I think that's what the ".cinit" seciton in your map file is for.
But, no actual code is allowed, and the order in which variables are initialized is also undefined. So you can and should only use this to initalize defaults. If you do not do this, then the variables will be uninitialized, meaning that they could start out with any value.
If you want code to run, then put all of that in your User_Initialization(). Beware that no pwms or inputs or control inputs can be read or written in the initialization function.
__________________
-Patrick Horn,
Paly Robotics
Check out the space simulator called
Vega Strike, modelled after the space simulator games Elite and Wing Commander. It's Open Source too!
If you have ever played
Wing Commander, or especially
Privateer, and had a feeling of nostalga derived from the you will enjoy these two Vega Strike mods:
Privateer Gemini Gold and
Privateer Remake!
I'm working on adding multiplayer support this year...