remove unneeded boilerplate from examples

This commit is contained in:
Dave Murphy 2015-01-09 08:14:01 +00:00
parent a2ce1e13ca
commit 678b89e9b2
9 changed files with 22 additions and 90 deletions

View File

@ -6,10 +6,7 @@
int main() int main()
{ {
srvInit(); // Needed
aptInit(); // Needed
gfxInitDefault(); // Init graphic stuff gfxInitDefault(); // Init graphic stuff
hidInit(NULL); // For input (buttons, touchscreen...)
// We need these 2 buffers for APT_DoAppJump() later. They can be smaller too // We need these 2 buffers for APT_DoAppJump() later. They can be smaller too
@ -46,11 +43,7 @@ int main()
} }
// Deinit everything before the app process get's terminated
hidExit();
gfxExit(); gfxExit();
aptExit();
srvExit();
return 0; return 0;
} }

View File

@ -13,11 +13,8 @@ int main()
u8 control=0x40; u8 control=0x40;
u32 audio_initialized = 0; u32 audio_initialized = 0;
srvInit();
aptInit();
gfxInitDefault(); gfxInitDefault();
hidInit(NULL);
if(CSND_initialize(NULL)==0)audio_initialized = 1; if(CSND_initialize(NULL)==0)audio_initialized = 1;
sharedmem = (u32*)memalign(0x1000, sharedmem_size); sharedmem = (u32*)memalign(0x1000, sharedmem_size);
@ -85,10 +82,7 @@ int main()
free(sharedmem); free(sharedmem);
linearFree(audiobuf); linearFree(audiobuf);
hidExit();
gfxExit(); gfxExit();
aptExit();
srvExit();
return 0; return 0;
} }

View File

@ -114,13 +114,13 @@ const vertex_s modelVboData[]=
//stolen from staplebutt //stolen from staplebutt
void GPU_SetDummyTexEnv(u8 num) void GPU_SetDummyTexEnv(u8 num)
{ {
GPU_SetTexEnv(num, GPU_SetTexEnv(num,
GPU_TEVSOURCES(GPU_PREVIOUS, 0, 0), GPU_TEVSOURCES(GPU_PREVIOUS, 0, 0),
GPU_TEVSOURCES(GPU_PREVIOUS, 0, 0), GPU_TEVSOURCES(GPU_PREVIOUS, 0, 0),
GPU_TEVOPERANDS(0,0,0), GPU_TEVOPERANDS(0,0,0),
GPU_TEVOPERANDS(0,0,0), GPU_TEVOPERANDS(0,0,0),
GPU_REPLACE, GPU_REPLACE,
GPU_REPLACE, GPU_REPLACE,
0xFFFFFFFF); 0xFFFFFFFF);
} }
@ -128,31 +128,31 @@ void GPU_SetDummyTexEnv(u8 num)
void renderFrame() void renderFrame()
{ {
GPU_SetViewport((u32*)osConvertVirtToPhys((u32)gpuDOut),(u32*)osConvertVirtToPhys((u32)gpuOut),0,0,240*2,400); GPU_SetViewport((u32*)osConvertVirtToPhys((u32)gpuDOut),(u32*)osConvertVirtToPhys((u32)gpuOut),0,0,240*2,400);
GPU_DepthRange(-1.0f, 0.0f); GPU_DepthRange(-1.0f, 0.0f);
GPU_SetFaceCulling(GPU_CULL_BACK_CCW); GPU_SetFaceCulling(GPU_CULL_BACK_CCW);
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00); GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_KEEP); GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_KEEP);
GPU_SetBlendingColor(0,0,0,0); GPU_SetBlendingColor(0,0,0,0);
GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL); GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
GPUCMD_AddSingleParam(0x00010062, 0); GPUCMD_AddSingleParam(0x00010062, 0);
GPUCMD_AddSingleParam(0x000F0118, 0); GPUCMD_AddSingleParam(0x000F0118, 0);
//setup shader //setup shader
SHDR_UseProgram(shader, 0); SHDR_UseProgram(shader, 0);
GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00); GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00);
GPU_SetTextureEnable(GPU_TEXUNIT0); GPU_SetTextureEnable(GPU_TEXUNIT0);
GPU_SetTexEnv(0, GPU_SetTexEnv(0,
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
GPU_TEVOPERANDS(0,0,0), GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
GPU_TEVOPERANDS(0,0,0), GPU_TEVOPERANDS(0,0,0),
GPU_MODULATE, GPU_MODULATE, GPU_TEVOPERANDS(0,0,0),
GPU_MODULATE, GPU_MODULATE,
0xFFFFFFFF); 0xFFFFFFFF);
GPU_SetDummyTexEnv(1); GPU_SetDummyTexEnv(1);
GPU_SetDummyTexEnv(2); GPU_SetDummyTexEnv(2);
@ -189,11 +189,8 @@ void renderFrame()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
//setup services
srvInit();
aptInit();
gfxInitDefault(); gfxInitDefault();
hidInit(NULL);
//initialize GPU //initialize GPU
GPU_Init(NULL); GPU_Init(NULL);
@ -321,9 +318,6 @@ int main(int argc, char** argv)
} }
gsExit(); gsExit();
hidExit();
gfxExit(); gfxExit();
aptExit();
srvExit();
return 0; return 0;
} }

View File

@ -17,16 +17,12 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
// Initialize services
srvInit();
aptInit();
gfxInitDefault(); gfxInitDefault();
hidInit(NULL);
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one //Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
consoleInit(GFX_TOP, NULL); consoleInit(GFX_TOP, NULL);
//Move the cursor to row 15 and column 19 and then prints "Hello World!" //Move the cursor to row 15 and column 19 and then prints "Hello World!"
//To move the cursor you have tu print "\x1b[r;cH", where r and c are respectively //To move the cursor you have tu print "\x1b[r;cH", where r and c are respectively
//the row and column where you want your cursor to move //the row and column where you want your cursor to move
//The top screen has 30 rows and 50 columns //The top screen has 30 rows and 50 columns
@ -54,10 +50,6 @@ int main(int argc, char **argv)
gspWaitForVBlank(); gspWaitForVBlank();
} }
// Exit services
gfxExit(); gfxExit();
hidExit();
aptExit();
srvExit();
return 0; return 0;
} }

View File

@ -87,10 +87,6 @@ int main()
Result ret=0; Result ret=0;
httpcContext context; httpcContext context;
// Initialize services
srvInit();
aptInit();
hidInit(NULL);
gfxInitDefault(); gfxInitDefault();
//gfxSet3D(true); // uncomment if using stereoscopic 3D //gfxSet3D(true); // uncomment if using stereoscopic 3D
httpcInit(); httpcInit();
@ -123,9 +119,6 @@ int main()
// Exit services // Exit services
httpcExit(); httpcExit();
gfxExit(); gfxExit();
hidExit();
aptExit();
srvExit();
return 0; return 0;
} }

View File

@ -4,10 +4,6 @@ int main()
{ {
u32 val, i; u32 val, i;
// Initialize services
srvInit();
aptInit();
hidInit(NULL);
gfxInitDefault(); gfxInitDefault();
//gfxSet3D(true); // uncomment if using stereoscopic 3D //gfxSet3D(true); // uncomment if using stereoscopic 3D
@ -42,9 +38,6 @@ int main()
// Exit services // Exit services
gfxExit(); gfxExit();
hidExit();
aptExit();
srvExit();
return 0; return 0;
} }

View File

@ -106,13 +106,7 @@ void draw_startup()
int main() int main()
{ {
// Initialize services
srvInit();
aptInit();
hidInit(NULL);
gfxInitDefault(); gfxInitDefault();
fsInit();
sdmcInit();
//gfxSet3D(true); // uncomment if using stereoscopic 3D //gfxSet3D(true); // uncomment if using stereoscopic 3D
memset(logstring, 0, 256); memset(logstring, 0, 256);
@ -143,13 +137,7 @@ int main()
if(inaddr)linearFree(inaddr); if(inaddr)linearFree(inaddr);
if(outaddr)linearFree(outaddr); if(outaddr)linearFree(outaddr);
// Exit services
sdmcExit();
fsExit();
gfxExit(); gfxExit();
hidExit();
aptExit();
srvExit();
return 0; return 0;
} }

View File

@ -11,10 +11,6 @@ int main()
qtmHeadtrackingInfo qtminfo; qtmHeadtrackingInfo qtminfo;
u32 colors[4] = {0x0000FF, 0x00FF00, 0xFF0000, 0xFFFFFF}; u32 colors[4] = {0x0000FF, 0x00FF00, 0xFF0000, 0xFFFFFF};
// Initialize services
srvInit();
aptInit();
hidInit(NULL);
gfxInitDefault(); gfxInitDefault();
//gfxSet3D(true); // uncomment if using stereoscopic 3D //gfxSet3D(true); // uncomment if using stereoscopic 3D
@ -84,9 +80,6 @@ int main()
// Exit services // Exit services
qtmExit(); qtmExit();
gfxExit(); gfxExit();
hidExit();
aptExit();
srvExit();
return 0; return 0;
} }

View File

@ -4,10 +4,6 @@
int main() int main()
{ {
// Initialize services
srvInit();
aptInit();
hidInit(NULL);
gfxInitDefault(); gfxInitDefault();
//gfxSet3D(true); // uncomment if using stereoscopic 3D //gfxSet3D(true); // uncomment if using stereoscopic 3D
@ -36,10 +32,6 @@ int main()
gfxSwapBuffers(); gfxSwapBuffers();
} }
// Exit services
gfxExit(); gfxExit();
hidExit();
aptExit();
srvExit();
return 0; return 0;
} }