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

Updated the sf2dlib and sftdlib; Added the gfx.color.hex() function; Added the New3DS CPU mode control.

As the color order of the sf2dlib changed, you have to change it in your code, or use the color.hex() function.
To fix the problems, just change "0xRRGGBBAA" to "0xAABBGGRR".
Also, the shader compiler changed to Picasso, so you'll need it in order to compile.
https://github.com/fincs/picasso
This commit is contained in:
Firew0lf 2015-12-09 23:14:23 +01:00
parent 0105970ab7
commit b4d025d602
17 changed files with 205 additions and 131 deletions

View file

@ -76,12 +76,32 @@ static int color_RGBA8(lua_State *L) {
return 1;
}
/***
Return a color from a hexadecimal value.
@function hex
@tparam integer hex the hexadecimal color code: 0xRRGGBBAA
@treturn integer the color
*/
static int color_hex(lua_State *L) {
u32 hex = luaL_checkinteger(L, 1);
u8 r = (hex & 0xFF000000) >> 24;
u8 g = (hex & 0x00FF0000) >> 16;
u8 b = (hex & 0x0000FF00) >> 8;
u8 a = (hex & 0x000000FF);
lua_pushinteger(L, RGBA8(r, g, b, a));
return 1;
}
static const struct luaL_Reg color_lib[] = {
{ "setDefault", color_setDefault },
{ "getDefault", color_getDefault },
{ "setBackground", color_setBackground },
{ "getBackground", color_getBackground },
{ "RGBA8", color_RGBA8 },
{ "hex", color_hex },
{ NULL, NULL }
};
@ -92,4 +112,4 @@ int luaopen_color_lib(lua_State *L) {
void load_color_lib(lua_State *L) {
luaL_requiref(L, "ctr.gfx.color", luaopen_color_lib, false);
}
}

View file

@ -17,6 +17,7 @@ Initialize the PTM module.
*/
static int ptm_init(lua_State *L) {
ptmInit();
ptmSysmInit();
return 0;
}
@ -27,12 +28,13 @@ Disable the PTM module.
*/
static int ptm_shutdown(lua_State *L) {
ptmExit();
ptmSysmExit();
return 0;
}
/***
Return the shell state. Don't care about this.
Return the shell state.
@function getShellState
@treturn number shell state
*/
@ -101,6 +103,30 @@ static int ptm_getTotalStepCount(lua_State *L) {
return 1;
}
/***
Setup the new 3DS CPU features (overclock, 4 cores ...)
@newonly
@function configureNew3DSCPU
@tparam boolean enable enable the New3DS CPU features
@treturn boolean `true` if everything went fine
*/
static int ptm_configureNew3DSCPU(lua_State *L) {
u8 conf = false;
if (lua_isboolean(L, 1))
conf = lua_toboolean(L, 1);
Result ret = PTMSYSM_ConfigureNew3DSCPU(conf);
if (ret) {
lua_pushboolean(L, false);
lua_pushinteger(L, ret);
return 2;
}
lua_pushboolean(L, true);
return 1;
}
static const struct luaL_Reg ptm_lib[] = {
{"init", ptm_init },
{"shutdown", ptm_shutdown },
@ -109,6 +135,7 @@ static const struct luaL_Reg ptm_lib[] = {
{"getBatteryChargeState", ptm_getBatteryChargeState},
{"getPedometerState", ptm_getPedometerState },
{"getTotalStepCount", ptm_getTotalStepCount },
{"configureNew3DSCPU", ptm_configureNew3DSCPU },
{NULL, NULL}
};

View file

@ -35,13 +35,13 @@ int getType(const char *name) {
Load a texture from a file. Supported formats: PNG, JPEG, BMP.
@function load
@tparam string path path to the image file
@tparam[opt=PLACE_RAM] number place where to put the loaded texture
@tparam[opt=PLACE_VRAM] number place where to put the loaded texture
@tparam[opt=auto] number type type of the image
@treturn texture the loaded texture object
*/
static int texture_load(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
u8 place = luaL_optinteger(L, 2, SF2D_PLACE_RAM); //place in ram by default
u8 place = luaL_optinteger(L, 2, SF2D_PLACE_VRAM); //place in vram by default
u8 type = luaL_optinteger(L, 3, 3); //type 3 is "search at the end of the filename"
texture_userdata *texture;