dolphin emulator gives the error "tring to compile at 0,LR=00000000", this is my code:
Code: Select all
#include <stdlib.h>
#include <grrlib.h>
#include <math.h>
#include <ML.h>
#define BLACK 0xFFFFFFFF
#define RED 0xFF0000FF
#define GREEN 0x00FF00FF
#define BLUE 0x0000FFFF
#define YELLOW 0xFFFF00FF
#define random(min,max) ((min)+rand()%((max)+1))
#include <verdana_ttf.h>
f32 x=0;
f32 y=0;
f32 z=3;
f32 a1=0;
f32 a2=0;
int main()
{
GRRLIB_Init();
ML_Init();
GRRLIB_ttfFont* font = GRRLIB_LoadTTF(verdana_ttf,verdana_ttf_size);
void camera(void);
GRRLIB_SetBackgroundColour(0x0,0xBB,0xBB,0xFF);
GRRLIB_SetAntiAliasing(true);
GRRLIB_SetLightAmbient(0x000000FF);
srand(time(NULL));
char str[64];
// definition of "world" is here <---------------------
u8 world[64][64][64];
u8 tx=0;
u8 ty=0;
u8 tz=0;
for (tx=0;tx<64;tx++) {
for (ty=0;ty<64;ty++) {
world[tx][ty][0]=1;
}
}
while (!ML_Pressed(cHome))
{
ML_Update(0);
camera();
GRRLIB_3dMode(0.1,1000,90,0,1);
GRRLIB_Camera3dSettings(x,y,z,0,0,1,x+cos(a1),y+sin(a1),z+sin(a2));
GRRLIB_SetLightDiff(0,(guVector){x,y,z},3,1,0xFFFFFFFF);
for (tx=0;tx<64;tx++) {
for (ty=0;ty<64;ty++) {
for (tz=0;tz<1;tz++) {
//if (world[tx][ty][0]) // <---- uncommenting this results in crash
GRRLIB_ObjectView(tx,ty,tz,0,0,0,1,1,1);
GRRLIB_DrawCube(1,true,0x00FF00FF);
}
}
}
GRRLIB_2dMode();
sprintf(str,"%.2f %.2f %.2f %d",x,y,z,5); // <---------------- replacing 5 with world[0][0][0] results in crash
GRRLIB_PrintfTTF(10,40,font,str,16,YELLOW);
GRRLIB_Render();
}
return 0;
}
void camera(void)
{
if (ML_IrX<128)
a1+=0.13;
if (ML_IrX>640-128)
a1-=0.13;
if (ML_IrY<128)
a2+=0.13;
if (ML_IrY>480-128)
a2-=0.13;
if (a2>M_PI_2) {a2=M_PI_2;}
if (a2<-M_PI_2) {a2=-M_PI_2;}
if (ML_Held(cA)) {
x+=cos(a1);
y+=sin(a1);
z+=sin(a2);
}
if (ML_Held(cB)) {
x-=cos(a1);
y-=sin(a1);
z-=sin(a2);
}
}