<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Fps from 60 to 12?!?</title>
<description> i have made a simpel block placment game and wen i place one block will it drop to 12 fps from 60! -_- easy way to fix this?
//Standard libray:
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
//Home menu:
//Coming Soon
//GRRLIB:
#include 

//Classes:
#include &quot;Blocks.h&quot;
#include &quot;oggplayer.h&quot;
#include &quot;drawcube.h&quot;
//#include &quot;NETWORK_SERVER.H&quot;
//#include &quot;minecraft.h&quot;

//Fonts:
#include &quot;minecraftFont_ttf.h&quot;
#include &quot;gfx/BMfont5.h&quot;

//Images:
#include &quot;terrain_png.h&quot;
#include &quot;gfx/mojang.h&quot;
#include &quot;gfx/pointer1.h&quot;
#include &quot;gfx/pointer2.h&quot;
//#include &quot;gfx/pointer3.h&quot;
//#include &quot;gfx/pointer4.h&quot;
#include &quot;gfx/grrlib_logo.h&quot;
#include &quot;gfx/panorama4.h&quot;

//OGG:
#include &quot;main_ogg.h&quot;

//Server:
/*#include&quot;_FindFirst.h&quot;
#include&quot;AutopatcherPatchContext.h&quot;
#include&quot;AutopatcherRepositoryInterface.h&quot;
#include&quot;BitStream.h&quot;
#include&quot;CCRakNetSlidingWindow.h&quot;
#include&quot;CCRakNetUDT.h&quot;
#include&quot;CheckSum.h&quot;
#include&quot;CloudClient.h&quot;
#include&quot;CloudCommon.h&quot;
#include&quot;CloudServer.h&quot;
#include&quot;CommandParserInterface.h&quot;
#include&quot;ConnectionGraph2.h&quot;
#include&quot;ConsoleServer.h&quot;
#include&quot;DataCompressor.h&quot;
#include&quot;RakPeer.h&quot;
#include&quot;RakPeerInterface.h&quot;
#include&quot;SimpleTCPServer.h&quot;
#include&quot;NetworkIDManager.h&quot;
#include
#include
#include&quot;RakPeerInterface.h&quot;
#include&quot;MessageIdentifiers.h&quot;
#include&quot;RakNetTime.h&quot;
#include&quot;RakNetTypes.h&quot;
#include&quot;SendToThread.h&quot;
#include&quot;BitStream.h&quot;
#include&quot;RakNetDefines.h&quot;
#include&quot;NetworkIDManager.h&quot;
#include&quot;RakNetTypes.h&quot;*/

//RGBA Colors
#define BLACK 0x000000FF
#define MAROON 0x800000FF
#define GREEN 0x008000FF
#define OLIVE 0x808000FF
#define NAVY 0x000080FF
#define PURPLE 0x800080FF
#define TEAL 0x008080FF
#define GRAY 0x808080FF
#define SILVER 0xC0C0C0FF
#define RED 0xFF0000FF
#define LIME 0x00FF00FF
#define YELLOW 0xFFFF00FF
#define BLUE 0x0000FFFF
#define FUCHSIA 0xFF00FFFF
#define AQUA 0x00FFFFFF
#define WHITE 0xFFFFFFFF
//Wiilight
#define HW_GPIO 0xCD0000C0;

#define DISC_SLOT_LED 0x20
//DEBUG:
#define DEBUG 0
//Server:
#define MAX_CLIENTS 6
#define SERVER_PORT 19132

using namespace std;
//using namespace minecraft;

//Initialize the IR
ir_t ir1;
ir_t ir2;
//ir_t ir3;
//ir_t ir4;

//--------------------------------------------------
//Wiilight
//--------------------------------------------------
lwp_t light_thread = 0;

void *light_loop (void *arg);

vu32 *light_reg = (u32*) HW_GPIO;

bool light_on = false;

u8 light_level = 0;

struct timespec light_timeon = { 0 };

struct timespec light_timeoff = { 0 };


static u8 CalculateFrameRate();

//----------------------------------------------------------
//Function&amp;#039;s:
//----------------------------------------------------------

void WIILIGHT_TurnOn()
{

*(u32*)0xCD0000C0 |= 0x20;

}
void WIILIGHT_TurnOff()
{
*(u32*)0xCD0000C0 &amp;= ~0x20;
}
void WIILIGHT_SetLevel(int level)
{

light_level = MIN(MAX(level, 0), 100);



// Calculate the new on/off times for this light intensity

u32 level_on;

u32 level_off;

level_on = (light_level * 2.55) * 40000;

level_off = 10200000 - level_on;

light_timeon.tv_nsec = level_on;

light_timeoff.tv_nsec = level_off;

}



void init(){
//Disk light turn on and init
//WIILIGHT_Init();
WIILIGHT_SetLevel(255);
WIILIGHT_TurnOn();
// Initialise the Graphics &amp; Video subsystem
GRRLIB_Init();
//VIDEO_Init();
// button initialization
WPAD_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
// Initialse the sound system
ASND_Init();
//MP3Player_Init(); /*filfat: We don&amp;#039;t need this for the moment...*/

//Disk light turn off
WIILIGHT_TurnOff();
}

void cleanup(){
//ToDo
GRRLIB_Exit();
exit(EXIT_SUCCESS);
}

void network();

int main() {

init();

//-------------------------------------------------
//RAKNET
//-------------------------------------------------
/*
RakNet::RakPeerInterface *peer = RakNet::RakPeerInterface::GetInstance();

bool isServer;
RakNet::Packet *packet;
RakNet::BitStream bsOut;

RakNet::SocketDescriptor sd(SERVER_PORT,0);
peer-&amp;gt;Startup(MAX_CLIENTS, &amp;sd, 1);
isServer = 0;
*/
//-------------------------------------------------
//RAKNET
//-------------------------------------------------
u8 FPS = 0;
//int version = 0.3;
int blockInInventory = 1;
//int xb = 13;
//int yb = 12;
int lookingAttX = 0;
int lookingAttZ = 0;
int lookingAttY = 0;
const int sizex = 32;
const int sizey = 32;
const int sizez = 32;
//int saveX;
//int saveY;
//int saveZ;
bool save_used = false;
int aUsed = 0;

//Gets the IR positions
WPAD_IR(WPAD_CHAN_1, &amp;ir1);
//WPAD_IR(WPAD_CHAN_2, &amp;ir2);
//WPAD_IR(WPAD_CHAN_3, &amp;ir3);
//WPAD_IR(WPAD_CHAN_4, &amp;ir4);

GRRLIB_ttfFont *minecraftFont = GRRLIB_LoadTTF(minecraftFont_ttf, minecraftFont_ttf_size);
GRRLIB_texImg *tex_pointer1 = GRRLIB_LoadTexture(pointer1);
GRRLIB_texImg *tex_pointer2 = GRRLIB_LoadTexture(pointer2);
GRRLIB_texImg *terrain = GRRLIB_LoadTexture(terrain_png);
//GRRLIB_texImg *panorama4 = GRRLIB_LoadTexture(panorama4);
GRRLIB_texImg *tex_BMfont5 = GRRLIB_LoadTexture(BMfont5);
GRRLIB_InitTileSet(tex_BMfont5, 8, 16, 0);

//--------------------------------------------------
block Stone(&quot;Stone&quot;, 31, 15, 1);
block Grass(&quot;Grass&quot;, 63, 15, 2);
block Dirt(&quot;Dirt&quot;, 47/*filfat: can do wrong with the pixels.. please fix this joshua*/, 15, 3);
block CobbleStone(&quot;CobbleStone&quot;, 15, 31, 4);
//--------------------------------------------------


//-----------------------------------------------------
u8 world[sizex][sizey][sizez];
//-----------------------------------------------------

GRRLIB_Settings.antialias = false;

//PlayOgg(main_ogg, main_ogg_size, 0, OGG_ONE_TIME);
GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);
GRRLIB_Camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0);

drawcube cube(lookingAttX, lookingAttZ, lookingAttY);

//Loop forever
while (1){

GRRLIB_2dMode();
WPAD_SetVRes(0, 640, 480);
WPAD_ScanPads();

WPAD_IR(0, &amp;ir1);
WPAD_IR(0, &amp;ir2);
//WPAD_IR(0, &amp;ir3);
//WPAD_IR(0, &amp;ir4);

GRRLIB_DrawImg(ir1.sx - 48, ir1.sy - 45, tex_pointer1, 0, 1, 1, 0xffffffff);
//GRRLIB_DrawImg(ir2.sx - 48, ir2.sy - 45, tex_pointer2, 0, 1, 1, 0xffffffAA);
//GRRLIB_DrawImg(ir3.sx - 48, ir3.sy - 45, tex_pointer3, 0, 1, 1, 0xffffffAA);
//GRRLIB_DrawImg(ir4.sx - 48, ir4.sy - 45, tex_pointer4, 0, 1, 1, 0xffffffAA);
GRRLIB_Render();

cube.drawcube_normal(lookingAttX, lookingAttZ, lookingAttY);

if(save_used){
for(int x = 0;x &amp;lt;= sizex; x++){
for(int y = 0;y &amp;lt;= sizey; y++){
for(int z = 0;z &amp;lt;= sizez; z++){
if(world[x][y][z] == true){
do{
cube.drawcube_save(x,z,y);
}while(!1);
}
}
}
}

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_HOME) {
cleanup();
}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_B) {
world[lookingAttX][lookingAttY][lookingAttZ] = 0;
}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_A) {

world[lookingAttX][lookingAttY][lookingAttZ] = blockInInventory;

save_used = true;

/*for(int x = 0;x &amp;lt;= sizex; x++){
for(int y = 0;y &amp;lt;= sizey; y++){
for(int z = 0;z &amp;lt;= sizez; z++){
if(world[lookingAttX][lookingAttY][lookingAttZ]){
saveX = lookingAttX;
saveY = lookingAttY;
saveZ = lookingAttZ;
save_used = true;

}
}
}
}*/
aUsed++;

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_MINUS) {

lookingAttZ--;

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_PLUS) {

lookingAttZ++;

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_UP) {

lookingAttY++;

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_DOWN) {

lookingAttY--;

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_RIGHT) {

lookingAttX++;

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_LEFT) {

lookingAttX--;

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_1) {

blockInInventory++;

}

if (WPAD_ButtonsDown(0) &amp; WPAD_BUTTON_2) {

if(blockInInventory){
blockInInventory--;
}

}

GRRLIB_Printf(5, 18, tex_BMfont5, WHITE, 1, &quot;Minecraft Wii Edition 0.3&quot;);
GRRLIB_Printf(5, 39, tex_BMfont5, WHITE, 1, &quot;Current FPS: %d&quot;, FPS);
GRRLIB_Printf(5, 57, tex_BMfont5, WHITE, 1, &quot;X: %d&quot;, static_cast(lookingAttX));
GRRLIB_Printf(5, 76, tex_BMfont5, WHITE, 1, &quot;Y: %d&quot;, static_cast(lookingAttY));
GRRLIB_Printf(5, 95, tex_BMfont5, WHITE, 1, &quot;Z: %d&quot;, static_cast(lookingAttZ));

//GRRLIB_Render();
FPS = CalculateFrameRate();


}

GRRLIB_FreeTexture(terrain);
GRRLIB_FreeTexture(tex_pointer1);
GRRLIB_FreeTexture(tex_pointer2);
//GRRLIB_FreeTexture(panorama4);
GRRLIB_FreeTexture(tex_BMfont5);
GRRLIB_FreeTTF(minecraftFont);

cleanup();

exit(0);
}

static u8 CalculateFrameRate() {
static u8 frameCount = 0;
static u32 lastTime;
static u8 FPS = 0;
u32 currentTime = ticks_to_millisecs(gettime());

frameCount++;
if(currentTime - lastTime &amp;gt; 1000) {
lastTime = currentTime;
FPS = frameCount;
frameCount = 0;
}
return FPS;
}

void network(){
#ifdef DEBUG
//GRRLIB_Printf(200, 27, tex_BMfont5, WHITE, 1, &quot;Current ip:&quot;);
#endif
}</description><link>http://forum.wiibrew.org/read.php?11,71892,71892#msg-71892</link><lastBuildDate>Tue, 16 Jun 2026 02:08:06 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71932#msg-71932</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71932#msg-71932</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>antibyte</strong><br />SifJar is right, just pass the pointer.... or store it as a member in your drawcube class. Loading and Freeing on a drawcall basis is just not the way to do this.</div></blockquote> and remove it using destructior (~)]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 21:15:01 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71931#msg-71931</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71931#msg-71931</link><description><![CDATA[ ahh XD any another good way that i could use too?]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 21:13:24 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71930#msg-71930</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71930#msg-71930</link><description><![CDATA[ SifJar is right, just pass the pointer.... or store it as a member in your drawcube class. Loading and Freeing on a drawcall basis is just not the way to do this.]]></description>
<dc:creator>antibyte</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 20:55:30 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71929#msg-71929</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71929#msg-71929</link><description><![CDATA[ anywan thats know a way to remove Thumbs.db.o?]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 18:17:30 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71928#msg-71928</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71928#msg-71928</link><description><![CDATA[ I can&#039;t C only C++ XD<br /><br />but now is it on 30 insted of 12 (if fixed an bug in the u8 wolrd file ;) )]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 18:14:26 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71927#msg-71927</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71927#msg-71927</link><description><![CDATA[ Can you not pass a pointer to it to the function? I&#039;m not really sure, I&#039;m just starting to learn C, but I think that would be how to do it.<br /><br />i.e. have as one of the function parameters something like GRRLIB_texImg *texture<br /><br />and then call the function with that parameter as "terrain_png" or whatever, and within the function call GRRLIB_SetTexture(texture);<br /><br />Again, as I said I don&#039;t really know a whole lot about C just yet, but as I understand it, you need to do it something like this. Also, I&#039;m quite confused about how pointers pointers, so I may have made a bit of a mistake in how they work etc.]]></description>
<dc:creator>SifJar</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 17:59:36 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71926#msg-71926</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71926#msg-71926</link><description><![CDATA[ it wont work i need to declare it in every fuction ;-)]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 17:46:04 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71924#msg-71924</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71924#msg-71924</link><description><![CDATA[ XD]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 17:43:56 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71921#msg-71921</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71921#msg-71921</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>filfat</strong><br />wont work: <pre class="bbcode">
error: &#039;terrain2&#039; was not declared in this scope
</pre></div></blockquote><br />That&#039;s a compiler error. Make it work. ;)]]></description>
<dc:creator>antibyte</dc:creator>
<category>Coding</category><pubDate>Mon, 26 Nov 2012 16:19:44 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71909#msg-71909</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71909#msg-71909</link><description><![CDATA[ wont work: <pre class="bbcode">
error: &#039;terrain2&#039; was not declared in this scope
</pre>]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 22:07:10 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71907#msg-71907</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71907#msg-71907</link><description><![CDATA[ i can try.]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 18:54:14 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71906#msg-71906</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71906#msg-71906</link><description><![CDATA[ I&#039;m not using grrlib myself, but after taking a quick look at GRRLIB_LoadTexture(), it seems to check if the texture is a png, jpg or bmp and then decompresses it on the fly. If this is what happens, then you should not call it on a drawcall basis. Call it once at initialization time and then only set the texture using GRRLIB_SetTexture()]]></description>
<dc:creator>antibyte</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 18:50:02 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71905#msg-71905</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71905#msg-71905</link><description><![CDATA[ adn so you know i are not so good in gx XD]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 18:34:05 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71904#msg-71904</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71904#msg-71904</link><description><![CDATA[ link: <a href="https://sourceforge.net/projects/wiicraft/?source=updater" rel="nofollow">HERE</a>]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 18:33:29 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71903#msg-71903</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71903#msg-71903</link><description><![CDATA[ if you have sourceforge can i add you to the Wiicraft project. if you want&#039;s to help =)]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 18:32:13 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71902#msg-71902</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71902#msg-71902</link><description><![CDATA[ her is it: <pre class="bbcode">
#include <iostream>
#include <grrlib.h>
#include "drawcube.h"
#include "terrain_png.h"


using namespace std;

drawcube::drawcube(int x, int z, int y){
	GRRLIB_texImg *terrain2 = GRRLIB_LoadTexture(terrain_png);
GRRLIB_3dMode(0.1,1000,45,1,0);
        GRRLIB_SetTexture(terrain2,0);
        GRRLIB_ObjectView(x,y,z, 0,0,0, 1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();
		GRRLIB_2dMode();
	GRRLIB_FreeTexture(terrain2);
}

void drawcube::drawcube_save(int x, int z, int y){
	GRRLIB_texImg *terrain2 = GRRLIB_LoadTexture(terrain_png);
	GRRLIB_3dMode(0.1,1000,45,1,0);
        GRRLIB_SetTexture(terrain2,0);
        GRRLIB_ObjectView(x,y,z, 0,0,0, 1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

			GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();
		GRRLIB_2dMode();
	GRRLIB_FreeTexture(terrain2);
}

void drawcube::drawcube_normal(int x, int z, int y){
	GRRLIB_texImg *terrain2 = GRRLIB_LoadTexture(terrain_png);
	GRRLIB_3dMode(0.1,1000,45,1,0);
        GRRLIB_SetTexture(terrain2,0);
        GRRLIB_ObjectView(x,y,z, 0,0,0, 1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();
		GRRLIB_2dMode();
	GRRLIB_FreeTexture(terrain2);
}

void drawcube::drawcube_withoutLeft(int x, int z, int y){
	GRRLIB_texImg *terrain2 = GRRLIB_LoadTexture(terrain_png);
	GRRLIB_3dMode(0.1,1000,45,1,0);
        GRRLIB_SetTexture(terrain2,0);
        GRRLIB_ObjectView(x,y,z, 0,0,0, 1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();
		GRRLIB_2dMode();
	GRRLIB_FreeTexture(terrain2);
}
</pre>]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 18:31:11 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71899#msg-71899</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71899#msg-71899</link><description><![CDATA[ Could you also please post the cube.drawcube_save() code? :)]]></description>
<dc:creator>antibyte</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 17:54:05 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71898#msg-71898</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71898#msg-71898</link><description><![CDATA[ If "cube.drawcube_save(x,z,y);" is not the culprit, then it seems like your 3 dimensional array is not suitable for traversing your world. Maybe try an Octree instead. Depending on what you want to do with it.]]></description>
<dc:creator>antibyte</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 17:18:51 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71897#msg-71897</guid>
<title>Re: Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71897#msg-71897</link><description><![CDATA[ i need to fix the render part but how:<br /><pre class="bbcode">
if(save_used){
        for(int x = 0;x &lt;= sizex; x++){
            for(int y = 0;y &lt;= sizey; y++){
                for(int z = 0;z &lt;= sizez; z++){
                    if(world[x][y][z] == true){
                        do{
                        cube.drawcube_save(x,z,y);
                        }while(!1);
                    }
                }
            }
        }
    }
</pre>]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 16:42:10 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71896#msg-71896</guid>
<title>Re: Fps form 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71896#msg-71896</link><description><![CDATA[ any easy render code?]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 16:34:57 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71895#msg-71895</guid>
<title>Re: Fps form 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71895#msg-71895</link><description><![CDATA[ it wont lagg... how can i fix this?]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 16:34:13 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71894#msg-71894</guid>
<title>Re: Fps form 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71894#msg-71894</link><description><![CDATA[ It&#039;s hard to tell without looking at it closely, so I&#039;ll just give it a shot: you iterate 32^3 times to draw one cube. What happens if you draw that one cube without iterating over that 32768 array?]]></description>
<dc:creator>antibyte</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 16:29:51 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,71892,71892#msg-71892</guid>
<title>Fps from 60 to 12?!?</title><link>http://forum.wiibrew.org/read.php?11,71892,71892#msg-71892</link><description><![CDATA[ i have made a simpel block placment game and wen i place one block will it drop to 12 fps from 60! -_- easy way to fix this?<br /><pre class="bbcode">//Standard libray:
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <malloc.h>
#include <asndlib.h>
#include <mp3player.h>
#include <time.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <ogc/lwp.h>
#include <ogc/lwp_watchdog.h>
#include <ogcsys.h>
#include <wiiuse/wpad.h>
#include <network.h>
#include <errno.h>
//Home menu:
//Coming Soon
//GRRLIB:
#include <grrlib.h>

//Classes:
#include "Blocks.h"
#include "oggplayer.h"
#include "drawcube.h"
//#include "NETWORK_SERVER.H"
//#include "minecraft.h"

//Fonts:
#include "minecraftFont_ttf.h"
#include "gfx/BMfont5.h"

//Images:
#include "terrain_png.h"
#include "gfx/mojang.h"
#include "gfx/pointer1.h"
#include "gfx/pointer2.h"
//#include "gfx/pointer3.h"
//#include "gfx/pointer4.h"
#include "gfx/grrlib_logo.h"
#include "gfx/panorama4.h"

//OGG:
#include "main_ogg.h"

//Server:
/*#include"_FindFirst.h"
#include"AutopatcherPatchContext.h"
#include"AutopatcherRepositoryInterface.h"
#include"BitStream.h"
#include"CCRakNetSlidingWindow.h"
#include"CCRakNetUDT.h"
#include"CheckSum.h"
#include"CloudClient.h"
#include"CloudCommon.h"
#include"CloudServer.h"
#include"CommandParserInterface.h"
#include"ConnectionGraph2.h"
#include"ConsoleServer.h"
#include"DataCompressor.h"
#include"RakPeer.h"
#include"RakPeerInterface.h"
#include"SimpleTCPServer.h"
#include"NetworkIDManager.h"
#include<stdio.h>
#include<string.h>
#include"RakPeerInterface.h"
#include"MessageIdentifiers.h"
#include"RakNetTime.h"
#include"RakNetTypes.h"
#include"SendToThread.h"
#include"BitStream.h"
#include"RakNetDefines.h"
#include"NetworkIDManager.h"
#include"RakNetTypes.h"*/

//RGBA Colors
#define BLACK  0x000000FF
#define MAROON  0x800000FF
#define GREEN  0x008000FF
#define OLIVE  0x808000FF
#define NAVY    0x000080FF
#define PURPLE  0x800080FF
#define TEAL    0x008080FF
#define GRAY    0x808080FF
#define SILVER  0xC0C0C0FF
#define RED    0xFF0000FF
#define LIME    0x00FF00FF
#define YELLOW  0xFFFF00FF
#define BLUE    0x0000FFFF
#define FUCHSIA 0xFF00FFFF
#define AQUA    0x00FFFFFF
#define WHITE  0xFFFFFFFF
//Wiilight
#define HW_GPIO            0xCD0000C0;

#define DISC_SLOT_LED      0x20
//DEBUG:
#define DEBUG                0
//Server:
#define MAX_CLIENTS 6
#define SERVER_PORT 19132

using namespace std;
//using namespace minecraft;

    //Initialize the IR
    ir_t ir1;
    ir_t ir2;
    //ir_t ir3;
    //ir_t ir4;

    //--------------------------------------------------
    //Wiilight
    //--------------------------------------------------
    lwp_t light_thread = 0;

    void *light_loop (void *arg);

    vu32 *light_reg = (u32*) HW_GPIO;

    bool light_on = false;

    u8 light_level = 0;

    struct timespec light_timeon = { 0 };

    struct timespec light_timeoff = { 0 };


    static u8 CalculateFrameRate();

    //----------------------------------------------------------
    //Function&#039;s:
    //----------------------------------------------------------

    void WIILIGHT_TurnOn()
    {

    *(u32*)0xCD0000C0 |= 0x20;

}
    void WIILIGHT_TurnOff()
    {
    *(u32*)0xCD0000C0 &= ~0x20;
}
void WIILIGHT_SetLevel(int level)
    {

    light_level = MIN(MAX(level, 0), 100);



    // Calculate the new on/off times for this light intensity

    u32 level_on;

    u32 level_off;

    level_on = (light_level * 2.55) * 40000;

    level_off = 10200000 - level_on;

    light_timeon.tv_nsec = level_on;

    light_timeoff.tv_nsec = level_off;

}



    void init(){
    //Disk light turn on and init
    //WIILIGHT_Init();
    WIILIGHT_SetLevel(255);
    WIILIGHT_TurnOn();
    // Initialise the Graphics & Video subsystem
    GRRLIB_Init();
    //VIDEO_Init();
    // button initialization
    WPAD_Init();
    WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
    // Initialse the sound system
    ASND_Init();
    //MP3Player_Init(); /*filfat: We don&#039;t need this for the moment...*/

    //Disk light turn off
    WIILIGHT_TurnOff();
}

void cleanup(){
    //ToDo
    GRRLIB_Exit();
    exit(EXIT_SUCCESS);
}

void network();

int main()  {

    init();

    //-------------------------------------------------
    //RAKNET
    //-------------------------------------------------
    /*
    RakNet::RakPeerInterface *peer = RakNet::RakPeerInterface::GetInstance();

    bool isServer;
    RakNet::Packet *packet;
    RakNet::BitStream bsOut;

    RakNet::SocketDescriptor sd(SERVER_PORT,0);
    peer-&gt;Startup(MAX_CLIENTS, &sd, 1);
    isServer = 0;
    */
    //-------------------------------------------------
    //RAKNET
    //-------------------------------------------------
    u8 FPS = 0;
    //int version = 0.3;
    int blockInInventory = 1;
    //int xb = 13;
    //int yb = 12;
    int lookingAttX = 0;
    int lookingAttZ = 0;
    int lookingAttY = 0;
    const int sizex = 32;
    const int sizey = 32;
    const int sizez = 32;
    //int saveX;
    //int saveY;
    //int saveZ;
    bool save_used = false;
    int aUsed = 0;

    //Gets the IR positions
    WPAD_IR(WPAD_CHAN_1, &ir1);
    //WPAD_IR(WPAD_CHAN_2, &ir2);
    //WPAD_IR(WPAD_CHAN_3, &ir3);
    //WPAD_IR(WPAD_CHAN_4, &ir4);

    GRRLIB_ttfFont *minecraftFont = GRRLIB_LoadTTF(minecraftFont_ttf, minecraftFont_ttf_size);
    GRRLIB_texImg *tex_pointer1 = GRRLIB_LoadTexture(pointer1);
    GRRLIB_texImg *tex_pointer2 = GRRLIB_LoadTexture(pointer2);
    GRRLIB_texImg *terrain = GRRLIB_LoadTexture(terrain_png);
    //GRRLIB_texImg *panorama4 = GRRLIB_LoadTexture(panorama4);
    GRRLIB_texImg *tex_BMfont5 = GRRLIB_LoadTexture(BMfont5);
    GRRLIB_InitTileSet(tex_BMfont5, 8, 16, 0);

    //---<Blocks>-----------------------------------------------
    block Stone("Stone", 31, 15, 1);
    block Grass("Grass", 63, 15, 2);
    block Dirt("Dirt", 47/*filfat: can do wrong with the pixels.. please fix this joshua*/, 15, 3);
    block CobbleStone("CobbleStone", 15, 31, 4);
    //---<Blocks>-----------------------------------------------


    //---<Map>--------------------------------------------------
    u8 world[sizex][sizey][sizez];
    //---<Map>--------------------------------------------------

    GRRLIB_Settings.antialias = false;

    //PlayOgg(main_ogg, main_ogg_size, 0, OGG_ONE_TIME);
    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);
    GRRLIB_Camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0);

    drawcube cube(lookingAttX, lookingAttZ, lookingAttY);

    //Loop forever
    while (1){

    GRRLIB_2dMode();
    WPAD_SetVRes(0, 640, 480);
    WPAD_ScanPads();

    WPAD_IR(0, &ir1);
    WPAD_IR(0, &ir2);
    //WPAD_IR(0, &ir3);
    //WPAD_IR(0, &ir4);

    GRRLIB_DrawImg(ir1.sx - 48, ir1.sy - 45, tex_pointer1, 0, 1, 1, 0xffffffff);
    //GRRLIB_DrawImg(ir2.sx - 48, ir2.sy - 45, tex_pointer2, 0, 1, 1, 0xffffffAA);
    //GRRLIB_DrawImg(ir3.sx - 48, ir3.sy - 45, tex_pointer3, 0, 1, 1, 0xffffffAA);
    //GRRLIB_DrawImg(ir4.sx - 48, ir4.sy - 45, tex_pointer4, 0, 1, 1, 0xffffffAA);
    GRRLIB_Render();

    cube.drawcube_normal(lookingAttX, lookingAttZ, lookingAttY);

    if(save_used){
        for(int x = 0;x &lt;= sizex; x++){
            for(int y = 0;y &lt;= sizey; y++){
                for(int z = 0;z &lt;= sizez; z++){
                    if(world[x][y][z] == true){
                        do{
                        cube.drawcube_save(x,z,y);
                        }while(!1);
                    }
                }
            }
        }
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) {
        cleanup();
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_B) {
        world[lookingAttX][lookingAttY][lookingAttZ] = 0;
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) {
   
        world[lookingAttX][lookingAttY][lookingAttZ] = blockInInventory;
   
        save_used = true;
   
        /*for(int x = 0;x &lt;= sizex; x++){
            for(int y = 0;y &lt;= sizey; y++){
                for(int z = 0;z &lt;= sizez; z++){
                    if(world[lookingAttX][lookingAttY][lookingAttZ]){
                            saveX = lookingAttX;
                            saveY = lookingAttY;
                            saveZ = lookingAttZ;
                            save_used = true;
                   
                    }
                }
            }
        }*/
        aUsed++;
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS) {
   
        lookingAttZ--;
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS) {
   
        lookingAttZ++;
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_UP) {
   
        lookingAttY++;
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_DOWN) {
   
        lookingAttY--;
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_RIGHT) {
   
        lookingAttX++;
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_LEFT) {
   
        lookingAttX--;
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_1) {
   
        blockInInventory++;
   
    }

    if (WPAD_ButtonsDown(0) & WPAD_BUTTON_2) {
   
        if(blockInInventory){
            blockInInventory--;
        }
   
    }

    GRRLIB_Printf(5, 18, tex_BMfont5, WHITE, 1, "Minecraft Wii Edition 0.3");
    GRRLIB_Printf(5, 39, tex_BMfont5, WHITE, 1, "Current FPS: %d", FPS);
    GRRLIB_Printf(5, 57, tex_BMfont5, WHITE, 1, "X: %d", static_cast<int>(lookingAttX));
    GRRLIB_Printf(5, 76, tex_BMfont5, WHITE, 1, "Y: %d", static_cast<int>(lookingAttY));
    GRRLIB_Printf(5, 95, tex_BMfont5, WHITE, 1, "Z: %d", static_cast<int>(lookingAttZ));

    //GRRLIB_Render();
    FPS = CalculateFrameRate();


    }

    GRRLIB_FreeTexture(terrain);
    GRRLIB_FreeTexture(tex_pointer1);
    GRRLIB_FreeTexture(tex_pointer2);
    //GRRLIB_FreeTexture(panorama4);
    GRRLIB_FreeTexture(tex_BMfont5);
    GRRLIB_FreeTTF(minecraftFont);

    cleanup();

    exit(0);
}

static u8 CalculateFrameRate() {
    static u8 frameCount = 0;
    static u32 lastTime;
    static u8 FPS = 0;
    u32 currentTime = ticks_to_millisecs(gettime());

    frameCount++;
    if(currentTime - lastTime &gt; 1000) {
        lastTime = currentTime;
        FPS = frameCount;
        frameCount = 0;
    }
    return FPS;
}

void network(){
    #ifdef DEBUG
    //GRRLIB_Printf(200, 27, tex_BMfont5, WHITE, 1, "Current ip:");
    #endif
}</pre>]]></description>
<dc:creator>filfat</dc:creator>
<category>Coding</category><pubDate>Sun, 25 Nov 2012 14:48:24 +0100</pubDate></item>
</channel>
</rss>