In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Changes

Jump to navigation Jump to search
537 bytes removed ,  08:13, 24 November 2010
Undo revision 93724 by Ynurisuhy (talk)
Line 1: Line 1: −
----
  −
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
  −
----
  −
=[http://ehiqikag.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
  −
----
  −
=[http://ehiqikag.co.cc CLICK HERE]=
  −
----
  −
</div>
   
==General Programming Tips==
 
==General Programming Tips==
 
*Keep your code commented throughout; it helps others help you. How much you comment it is a matter of debate; in general, people tend to comment bits of code where it isn't obvious what it actually does or why, or variables that aren't obvious what they are used for (or are not used until quite a bit later on).
 
*Keep your code commented throughout; it helps others help you. How much you comment it is a matter of debate; in general, people tend to comment bits of code where it isn't obvious what it actually does or why, or variables that aren't obvious what they are used for (or are not used until quite a bit later on).
Line 18: Line 10:  
Here is the video detect code from the DevKitPro Wii example.
 
Here is the video detect code from the DevKitPro Wii example.
 
Keep in mind, however, the libogc included in DevkitPPC since r15 does this for you already with one function call.
 
Keep in mind, however, the libogc included in DevkitPPC since r15 does this for you already with one function call.
&lt;source lang="c">
+
<source lang="c">
#include &lt;gccore.h>
+
#include <gccore.h>
 
static GXRModeObj *rmode = NULL;
 
static GXRModeObj *rmode = NULL;
 
// ...
 
// ...
Line 30: Line 22:  
}
 
}
 
VIDEO_Configure(rmode);
 
VIDEO_Configure(rmode);
&lt;/source>
+
</source>
    
Please see also: [[Display Issues]]
 
Please see also: [[Display Issues]]
Line 36: Line 28:  
=== Exit to Loader ===
 
=== Exit to Loader ===
 
It's a good idea to add some way to return to the loader, otherwise you have to reboot your Wii to exit.
 
It's a good idea to add some way to return to the loader, otherwise you have to reboot your Wii to exit.
&lt;source lang="c">
+
<source lang="c">
 
// Just call the exit() function to go back to the loader
 
// Just call the exit() function to go back to the loader
 
// Returning from main also works, since that calls exit for you
 
// Returning from main also works, since that calls exit for you
     #include &lt;stdlib.h>
+
     #include <stdlib.h>
 
     // ...
 
     // ...
 
     exit(0);
 
     exit(0);
&lt;/source>
+
</source>
    
=== How to use the Wiimote ===
 
=== How to use the Wiimote ===
Line 49: Line 41:  
=== Reboot Wii ===
 
=== Reboot Wii ===
 
Use:
 
Use:
&lt;source lang="c">
+
<source lang="c">
#include &lt;gccore.h>
+
#include <gccore.h>
 
// ...
 
// ...
 
SYS_ResetSystem(SYS_RESTART,0,0);
 
SYS_ResetSystem(SYS_RESTART,0,0);
&lt;/source>
+
</source>
    
Or use SYS_RETURNTOMENU for a "soft" return to the system menu, SYS_POWEROFF to shut down the wii (automatically to the appropriate Idle or Standby mode, depending on the WC24 setting), or SYS_POWEROFF_STANDBY or _IDLE to specify the mode and override the system setting.
 
Or use SYS_RETURNTOMENU for a "soft" return to the system menu, SYS_POWEROFF to shut down the wii (automatically to the appropriate Idle or Standby mode, depending on the WC24 setting), or SYS_POWEROFF_STANDBY or _IDLE to specify the mode and override the system setting.
Line 59: Line 51:  
=== How to use the callback function for Power and Reset ===
 
=== How to use the callback function for Power and Reset ===
 
This is just a way of doing this stuff, feel free to change the code.
 
This is just a way of doing this stuff, feel free to change the code.
&lt;source lang="c">
+
<source lang="c">
 
s8 HWButton = -1;
 
s8 HWButton = -1;
   Line 115: Line 107:  
return 0;
 
return 0;
 
}
 
}
&lt;/source>
+
</source>
 
Possible values for HWButton are:
 
Possible values for HWButton are:
&lt;source lang="c">
+
<source lang="c">
#define SYS_RESTART 0 /*!&lt; Reboot the gamecube, force, if necessary, to boot the IPL menu. Cold reset is issued */
+
#define SYS_RESTART 0 /*!< Reboot the gamecube, force, if necessary, to boot the IPL menu. Cold reset is issued */
#define SYS_HOTRESET 1 /*!&lt; Restart the application. Kind of softreset */
+
#define SYS_HOTRESET 1 /*!< Restart the application. Kind of softreset */
#define SYS_SHUTDOWN 2 /*!&lt; Shutdown the thread system, card management system etc. Leave current thread running and return to caller */
+
#define SYS_SHUTDOWN 2 /*!< Shutdown the thread system, card management system etc. Leave current thread running and return to caller */
#define SYS_RETURNTOMENU 3 /*!&lt; Directly load the Wii Channels menu, without actually cold-resetting the system */
+
#define SYS_RETURNTOMENU 3 /*!< Directly load the Wii Channels menu, without actually cold-resetting the system */
#define SYS_POWEROFF 4 /*!&lt; Powers off the Wii, automatically choosing Standby or Idle mode depending on the user's configuration */
+
#define SYS_POWEROFF 4 /*!< Powers off the Wii, automatically choosing Standby or Idle mode depending on the user's configuration */
#define SYS_POWEROFF_STANDBY 5 /*!&lt; Powers off the Wii to standby (red LED, WC24 off) mode. */
+
#define SYS_POWEROFF_STANDBY 5 /*!< Powers off the Wii to standby (red LED, WC24 off) mode. */
#define SYS_POWEROFF_IDLE 6 /*!&lt; Powers off the Wii to idle (yellow LED, WC24 on) mode. */
+
#define SYS_POWEROFF_IDLE 6 /*!< Powers off the Wii to idle (yellow LED, WC24 on) mode. */
&lt;/source>
+
</source>
    
== Note on Projection Matrices ==
 
== Note on Projection Matrices ==
 
There are a lot of tutorials and projects out there that are using standard 'Mtx' variables for projection matrices. Although this works in many cases (because the variables declared right after the matrix don't mind being corrupted once or twice), this is not correct, and is a crash waiting to happen. These matrices should be declared as 'Mtx44' objects instead. Note the prototypes for the projection matrix functions (see "ogc/gu.h"):
 
There are a lot of tutorials and projects out there that are using standard 'Mtx' variables for projection matrices. Although this works in many cases (because the variables declared right after the matrix don't mind being corrupted once or twice), this is not correct, and is a crash waiting to happen. These matrices should be declared as 'Mtx44' objects instead. Note the prototypes for the projection matrix functions (see "ogc/gu.h"):
&lt;source lang="c">
+
<source lang="c">
 
void guFrustum(Mtx44 mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 f);
 
void guFrustum(Mtx44 mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 f);
 
void guPerspective(Mtx44 mt,f32 fovy,f32 aspect,f32 n,f32 f);
 
void guPerspective(Mtx44 mt,f32 fovy,f32 aspect,f32 n,f32 f);
 
void guOrtho(Mtx44 mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 f);
 
void guOrtho(Mtx44 mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 f);
&lt;/source>
+
</source>
 
One way to catch such errors is to enable more warnings in gcc like:
 
One way to catch such errors is to enable more warnings in gcc like:
&lt;source lang="bash">gcc -Wall -pedantic -std=c99&lt;/source>
+
<source lang="bash">gcc -Wall -pedantic -std=c99</source>
   −
''For example the current ''''devkitPro\examples\wii\graphics\gx\triangle.c'''' uses 'Mtx' but it should be using 'Mtx44' - I fell into this trap, please be carefull &amp; take note of the above.''
+
''For example the current ''''devkitPro\examples\wii\graphics\gx\triangle.c'''' uses 'Mtx' but it should be using 'Mtx44' - I fell into this trap, please be carefull & take note of the above.''
    
== GX Tips ==
 
== GX Tips ==
82

edits

Navigation menu