This is for use with libogc and DevkitPPC!
Keep in mind, I code in C and not C++!!!
Functions and how to use them!You can start a function a few ways.
If you are lazy (like me) and do not understand C very well (like me xD)
My tutorial is missing a chunk. Here is a fix.
If you need more space like Function Name, Instead of a space use _
It will not respond well to space or - due to it thinking it's an integer. lol
- Code:
-
s32 Function_Name()
{
// Code goes here!
return 0; // This needs to be at the end of s32 functions!
}
ALWAYS add the brackets beside the function name, or the compiler will be
(NOOB FIX IT!)
You may also use this:
- Code:
-
void function_name()
{
// code here! No return is needed for void functions.
}
Now, CALLING the function is easy. Just don't screw up.
(Code from the template)
- Code:
-
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
// Initialise the video system
VIDEO_Init();
// This function initialises the attached controllers
WPAD_Init();
// Obtain the preferred video mode from the system
// This will correspond to the settings in the Wii menu
rmode = VIDEO_GetPreferredMode(NULL);
// Allocate memory for the display in the uncached region
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
// Initialise the console, required for printf
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
// Set up the video registers with the chosen mode
VIDEO_Configure(rmode);
// Tell the video hardware where our display memory is
VIDEO_SetNextFramebuffer(xfb);
// Make the display visible
VIDEO_SetBlack(FALSE);
// Flush the video register changes to the hardware
VIDEO_Flush();
// Wait for Video setup to complete
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
// Now that all of the video is set up, you can run the function!
Function_Name();
}
Calling a function needs to be in this format:
Function_Name(); Always add the () brackets and the ; after it, to close the deal. (lol)
More later... I am too tired.