Skip to content

Commit

Permalink
Errors in 2D. Cleaned main.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuh committed Aug 20, 2015
1 parent ee4ea72 commit 547512c
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions source/main.c
Expand Up @@ -11,41 +11,36 @@
int load_ctr_lib(lua_State *L);
void unload_font_lib();

bool errored, gfxinit = false;
bool gfxinit = false;

// Display an error
void error(const char *error) {
if (!gfxinit) {
gfxInitDefault();
}
if (!gfxinit) gfxInitDefault();
gfxSet3D(false);

consoleInit(GFX_TOP, NULL);
printf("------------------ FATAL ERROR -------------------");
printf(error);
printf("\n--------------------------------------------------");
printf("Please exit ctruLua by pressing start.");

errored = true;

while (aptMainLoop()) {
hidScanInput();
if (hidKeysDown() & KEY_START)
break;
if (hidKeysDown() & KEY_START) break;
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();
}
if (!gfxinit) {
gfxExit();
}

if (!gfxinit) gfxExit();
}

// Main loop
int main() {
// Init Lua
lua_State *L = luaL_newstate();
if (L == NULL) error("Memory allocation error while creating a new Lua state");
if (errored) {
if (L == NULL) {
error("Memory allocation error while creating a new Lua state");
return 0;
}

Expand All @@ -59,7 +54,7 @@ int main() {
HIDUSER_EnableAccelerometer();
HIDUSER_EnableGyroscope();


// Load libs
luaL_openlibs(L);
load_ctr_lib(L);

Expand Down

0 comments on commit 547512c

Please sign in to comment.