mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-28 00:39:30 +00:00
Some enhancements in case of error, should fix some things on hardware.
This commit is contained in:
parent
ebd3a6804d
commit
94d69c646c
1 changed files with 27 additions and 9 deletions
|
|
@ -11,37 +11,55 @@
|
||||||
int load_ctr_lib(lua_State *L);
|
int load_ctr_lib(lua_State *L);
|
||||||
void unload_font_lib();
|
void unload_font_lib();
|
||||||
|
|
||||||
|
bool errored, gfxinit = false;
|
||||||
|
|
||||||
// Display an error
|
// Display an error
|
||||||
void error(const char *error) {
|
void error(const char *error) {
|
||||||
|
if (!gfxinit) {
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
|
}
|
||||||
|
|
||||||
consoleInit(GFX_TOP, NULL);
|
consoleInit(GFX_TOP, NULL);
|
||||||
printf("------------------ FATAL ERROR -------------------");
|
printf("------------------ FATAL ERROR -------------------");
|
||||||
printf(error);
|
printf(error);
|
||||||
printf("\n--------------------------------------------------");
|
printf("\n--------------------------------------------------");
|
||||||
printf("Please exit ctruLua by rebooting the console.");
|
printf("Please exit ctruLua by pressing start.");
|
||||||
|
|
||||||
|
errored = true;
|
||||||
|
|
||||||
while (aptMainLoop()) {
|
while (aptMainLoop()) {
|
||||||
|
hidScanInput();
|
||||||
|
if (hidKeysDown() & KEY_START)
|
||||||
|
break;
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
gfxSwapBuffers();
|
gfxSwapBuffers();
|
||||||
gspWaitForVBlank();
|
gspWaitForVBlank();
|
||||||
}
|
}
|
||||||
|
if (!gfxinit) {
|
||||||
|
gfxExit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
int main() {
|
int main() {
|
||||||
|
// Init Lua
|
||||||
|
lua_State *L = luaL_newstate();
|
||||||
|
if (L == NULL) error("Memory allocation error while creating a new Lua state");
|
||||||
|
if (errored) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Init GFX
|
// Init GFX
|
||||||
sf2d_init();
|
sf2d_init();
|
||||||
sftd_init();
|
sftd_init();
|
||||||
//sf2d_set_3d(true);
|
//sf2d_set_3d(true);
|
||||||
|
gfxinit = true;
|
||||||
|
|
||||||
// Init accel/gyro
|
// Init accel/gyro
|
||||||
HIDUSER_EnableAccelerometer();
|
HIDUSER_EnableAccelerometer();
|
||||||
HIDUSER_EnableGyroscope();
|
HIDUSER_EnableGyroscope();
|
||||||
|
|
||||||
// Init Lua
|
|
||||||
lua_State *L = luaL_newstate();
|
|
||||||
if (L == NULL) error("Memory allocation error while creating a new Lua state");
|
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
load_ctr_lib(L);
|
load_ctr_lib(L);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue