mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Fixed the documentation error with lzlib, Added gfx.get3D(), Enhanced the ir library errors returns.
This commit is contained in:
parent
22bcc3e2d5
commit
b47634f699
4 changed files with 60 additions and 11 deletions
16
source/gfx.c
16
source/gfx.c
|
|
@ -16,6 +16,7 @@ The `gfx` module.
|
|||
#include "font.h"
|
||||
|
||||
bool isGfxInitialised = false;
|
||||
bool is3DEnabled = false; //TODO: add a function for this in the ctrulib/sf2dlib.
|
||||
|
||||
/***
|
||||
The `ctr.gfx.color` module.
|
||||
|
|
@ -103,13 +104,23 @@ Enable or disable the stereoscopic 3D on the top screen.
|
|||
@tparam boolean enable true to enable, false to disable
|
||||
*/
|
||||
static int gfx_set3D(lua_State *L) {
|
||||
bool enable = lua_toboolean(L, 1);
|
||||
is3DEnabled = lua_toboolean(L, 1);
|
||||
|
||||
sf2d_set_3D(enable);
|
||||
sf2d_set_3D(is3DEnabled);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***
|
||||
Check whether or not the stereoscopic 3D is enabled.
|
||||
@function get3D
|
||||
@treturn boolean true if enabled, false if disabled
|
||||
*/
|
||||
static int gfx_get3D(lua_State *L) {
|
||||
lua_pushboolean(L, is3DEnabled);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***
|
||||
Get free VRAM space.
|
||||
@function vramSpaceFree
|
||||
|
|
@ -251,6 +262,7 @@ static const struct luaL_Reg gfx_lib[] = {
|
|||
{ "render", gfx_render },
|
||||
{ "getFPS", gfx_getFPS },
|
||||
{ "set3D", gfx_set3D },
|
||||
{ "get3D", gfx_get3D },
|
||||
{ "vramSpaceFree", gfx_vramSpaceFree },
|
||||
{ "line", gfx_line },
|
||||
{ "point", gfx_point },
|
||||
|
|
|
|||
45
source/ir.c
45
source/ir.c
|
|
@ -43,6 +43,11 @@ Initialize the IR module.
|
|||
static int ir_init(lua_State *L) {
|
||||
u8 bitrate = luaL_optinteger(L, 1, 6);
|
||||
bufferSize = luaL_optinteger(L, 2, 2048); //default: 2Kio
|
||||
if (bufferSize > 2048) {
|
||||
lua_pushboolean(L, false);
|
||||
lua_pushstring(L, "the buffer can't be larger than 2048 bytes.");
|
||||
return 2;
|
||||
}
|
||||
buffer = linearAlloc(bufferSize);
|
||||
|
||||
Result ret = IRU_Initialize(buffer, bufferSize);
|
||||
|
|
@ -62,9 +67,15 @@ Disable the IR module.
|
|||
@function shutdown
|
||||
*/
|
||||
static int ir_shutdown(lua_State *L) {
|
||||
IRU_Shutdown();
|
||||
Result ret = IRU_Shutdown();
|
||||
if (ret) {
|
||||
lua_pushboolean(L, false);
|
||||
lua_pushinteger(L, ret);
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
lua_pushboolean(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
@ -77,7 +88,12 @@ static int ir_send(lua_State *L) {
|
|||
u8 *data = (u8*)luaL_checkstring(L, 1);
|
||||
u32 wait = lua_toboolean(L, 2);
|
||||
|
||||
IRU_SendData(data, sizeof(data), wait);
|
||||
Result ret = IRU_SendData(data, sizeof(data), wait);
|
||||
if (ret) {
|
||||
lua_pushboolean(L, false);
|
||||
lua_pushinteger(L, ret);
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -89,12 +105,17 @@ Receive some data from the IR module.
|
|||
@tparam[opt=false] boolean wait wait until the data is received
|
||||
*/
|
||||
static int ir_receive(lua_State *L) {
|
||||
u32 size = luaL_optinteger(L, 1, 0x800);
|
||||
u32 size = luaL_optinteger(L, 1, bufferSize);
|
||||
u32 wait = lua_toboolean(L, 2);
|
||||
u8 *data = 0;
|
||||
u32 *transfercount = 0;
|
||||
|
||||
IRU_RecvData(data, size, 0x00, transfercount, wait);
|
||||
Result ret = IRU_RecvData(data, size, 0x00, transfercount, wait);
|
||||
if (ret) {
|
||||
lua_pushboolean(L, false);
|
||||
lua_pushinteger(L, ret);
|
||||
return 2;
|
||||
}
|
||||
|
||||
lua_pushstring(L, (const char *)data);
|
||||
|
||||
|
|
@ -109,7 +130,12 @@ Set the bitrate of the communication.
|
|||
static int ir_setBitRate(lua_State *L) {
|
||||
u8 bitrate = luaL_checkinteger(L, 1);
|
||||
|
||||
IRU_SetBitRate(bitrate);
|
||||
Result ret = IRU_SetBitRate(bitrate);
|
||||
if (ret) {
|
||||
lua_pushboolean(L, false);
|
||||
lua_pushinteger(L, ret);
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -122,7 +148,12 @@ Return the actual bitrate of the communication.
|
|||
static int ir_getBitRate(lua_State *L) {
|
||||
u8 bitrate = 0;
|
||||
|
||||
IRU_GetBitRate(&bitrate);
|
||||
Result ret = IRU_GetBitRate(&bitrate);
|
||||
if (ret) {
|
||||
lua_pushboolean(L, false);
|
||||
lua_pushinteger(L, ret);
|
||||
return 2;
|
||||
}
|
||||
|
||||
lua_pushinteger(L, bitrate);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
/***
|
||||
The `fs.lzlib` module. See https://github.com/LuaDist/lzlib for informations and documentation.
|
||||
@module ctr.fs.lzlib
|
||||
@usage local lzlib = require("ctr.fs.lzlib")
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
* Author : Tiago Dionizio <tiago.dionizio@gmail.com> *
|
||||
* Library : lzlib - Lua 5 interface to access zlib library functions *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue