Skip to content

Commit

Permalink
Fixing code identation and minor tips.
Browse files Browse the repository at this point in the history
Fixing code identation and minor tips.
  • Loading branch information
Rinnegatamante committed Aug 1, 2016
1 parent f0a508f commit dae2d25
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
42 changes: 21 additions & 21 deletions source/luaControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,35 @@ static int lua_readright(lua_State *L)

static int lua_check(lua_State *L)
{
if (lua_gettop(L) != 2) return luaL_error(L, "wrong number of arguments.");
int pad = luaL_checknumber(L, 1);
int button = luaL_checknumber(L, 2);
lua_pushboolean(L, (pad & button));
return 1;
if (lua_gettop(L) != 2) return luaL_error(L, "wrong number of arguments.");
int pad = luaL_checknumber(L, 1);
int button = luaL_checknumber(L, 2);
lua_pushboolean(L, (pad & button));
return 1;
}

static int lua_touchpad(lua_State *L)
{
if (lua_gettop(L) != 0) return luaL_error(L, "wrong number of arguments.");
SceTouchData touch;
sceTouchPeek(SCE_TOUCH_PORT_FRONT, &touch, 1);
for (SceUInt32 i=0;i<touch.reportNum;i++){
lua_pushnumber(L, lerp(touch.report[i].x, 1919, 960));
lua_pushnumber(L, lerp(touch.report[i].y, 1087, 544));
}
return touch.reportNum<<1;
if (lua_gettop(L) != 0) return luaL_error(L, "wrong number of arguments.");
SceTouchData touch;
sceTouchPeek(SCE_TOUCH_PORT_FRONT, &touch, 1);
for (SceUInt32 i=0;i<touch.reportNum;i++){
lua_pushnumber(L, lerp(touch.report[i].x, 1919, 960));
lua_pushnumber(L, lerp(touch.report[i].y, 1087, 544));
}
return touch.reportNum<<1;
}

static int lua_touchpad2(lua_State *L)
{
if (lua_gettop(L) != 0) return luaL_error(L, "wrong number of arguments.");
SceTouchData touch;
sceTouchPeek(SCE_TOUCH_PORT_BACK, &touch, 1);
for (SceUInt32 i=0;i<touch.reportNum;i++){
lua_pushnumber(L, lerp(touch.report[i].x, 1919, 960));
lua_pushnumber(L, lerp(touch.report[i].y, 1087, 544));
}
return touch.reportNum<<1;
if (lua_gettop(L) != 0) return luaL_error(L, "wrong number of arguments.");
SceTouchData touch;
sceTouchPeek(SCE_TOUCH_PORT_BACK, &touch, 1);
for (SceUInt32 i=0;i<touch.reportNum;i++){
lua_pushnumber(L, lerp(touch.report[i].x, 1919, 960));
lua_pushnumber(L, lerp(touch.report[i].y, 1087, 544));
}
return touch.reportNum<<1;
}

//Register our Controls Functions
Expand Down
32 changes: 18 additions & 14 deletions source/luaGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,23 @@ static int lua_loadimg(lua_State *L)
uint16_t magic;
sceIoRead(file, &magic, 2);
vita2d_texture* result;
if (magic == 0x4D42){
sceIoClose(file);
result = vita2d_load_BMP_file(text);
}else if (magic == 0xD8FF){
sceIoClose(file);
result = vita2d_load_JPEG_file(text);
}else if (magic == 0x5089){
sceIoClose(file);
result = vita2d_load_PNG_file(text);
}else{
sceIoClose(file);
return luaL_error(L, "Error loading image.");
switch(magic){
case 0x4D42:
sceIoClose(file);
result = vita2d_load_BMP_file(text);
break;
case 0xD8FF:
sceIoClose(file);
result = vita2d_load_JPEG_file(text);
break;
case 0x5089:
sceIoClose(file);
result = vita2d_load_PNG_file(text);
break;
default:
sceIoClose(file);
return luaL_error(L, "Error loading image.");
break;
}
lua_pushinteger(L, (int)(result));
return 1;
Expand Down Expand Up @@ -294,13 +299,12 @@ static int lua_unloadFont(lua_State *L) {

static int lua_fprint(lua_State *L) {
int argc = lua_gettop(L);
if (argc != 6) return luaL_error(L, "wrong number of arguments");
if (argc != 5) return luaL_error(L, "wrong number of arguments");
ttf* font = (ttf*)(luaL_checkinteger(L, 1));
int x = luaL_checkinteger(L, 2);
int y = luaL_checkinteger(L, 3);
char* text = (char*)(luaL_checkstring(L, 4));
uint32_t color = luaL_checkinteger(L,5);
int screen = luaL_checkinteger(L,6);
#ifndef SKIP_ERROR_HANDLING
if (font->magic != 0x4C464E54) return luaL_error(L, "attempt to access wrong memory block type");
#endif
Expand Down

0 comments on commit dae2d25

Please sign in to comment.