1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Added some code

This commit is contained in:
Reuh 2015-08-17 18:15:37 +02:00
parent 5f22a4008a
commit 03baa21c10
80 changed files with 36025 additions and 0 deletions

53
source/main.c Normal file
View file

@ -0,0 +1,53 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <3ds.h>
#include <sf2d.h>
#include <sftd.h>
#include <lua.h>
#include <lauxlib.h>
#define BOOT_FILE "/ctruLua/main.lua"
int load_ctr_lib(lua_State *L);
// Display an error
void error(char *error) {
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
printf("------------------ FATAL ERROR -------------------");
printf(error);
printf("\n--------------------------------------------------");
printf("Please exit ctruLua by pressing the home button.");
while (aptMainLoop()) {
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();
}
}
// Main loop
int main() {
// Init GFX
sf2d_init();
sftd_init();
//sf2d_set_3d(true);
// Init Lua
lua_State *L = luaL_newstate();
if (L == NULL) error("memory allocation error while creating a new Lua state");
luaL_openlibs(L);
load_ctr_lib(L);
// Do the actual thing
luaL_dofile(L, BOOT_FILE);
// Un-init (?)
sftd_fini();
sf2d_fini();
return 0;
}