-setpal & getpal renamed to setcolor & getcolor
-setcolor & getcolor now use r, g & b instead of uint32
This commit is contained in:
22
lua.cpp
22
lua.cpp
@@ -57,16 +57,22 @@ extern "C" {
|
|||||||
loadpal(str);
|
loadpal(str);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int cpp_setpal(lua_State *L) {
|
static int cpp_setcolor(lua_State *L) {
|
||||||
uint8_t index = luaL_checkinteger(L, 1);
|
uint8_t index = luaL_checkinteger(L, 1);
|
||||||
uint8_t color = luaL_checkinteger(L, 2);
|
uint8_t r = luaL_checkinteger(L, 2);
|
||||||
setpal(index, color);
|
uint8_t g = luaL_checkinteger(L, 3);
|
||||||
|
uint8_t b = luaL_checkinteger(L, 4);
|
||||||
|
uint32_t color = (r<<16) + (g<<8) + b;
|
||||||
|
setcolor(index, color);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int cpp_getpal(lua_State *L) {
|
static int cpp_getcolor(lua_State *L) {
|
||||||
uint8_t index = luaL_checkinteger(L, 1);
|
uint8_t index = luaL_checkinteger(L, 1);
|
||||||
lua_pushinteger(L, getpal(index));
|
uint32_t color = getcolor(index);
|
||||||
return 1;
|
lua_pushinteger(L, (color>>16)&0xff);
|
||||||
|
lua_pushinteger(L, (color>>8)&0xff);
|
||||||
|
lua_pushinteger(L, color&0xff);
|
||||||
|
return 3;
|
||||||
}
|
}
|
||||||
static int cpp_settrans(lua_State *L) {
|
static int cpp_settrans(lua_State *L) {
|
||||||
uint8_t index = luaL_checkinteger(L, 1);
|
uint8_t index = luaL_checkinteger(L, 1);
|
||||||
@@ -613,8 +619,8 @@ void push_lua_funcs() {
|
|||||||
lua_pushcfunction(L,cpp_color); lua_setglobal(L, "color");
|
lua_pushcfunction(L,cpp_color); lua_setglobal(L, "color");
|
||||||
|
|
||||||
lua_pushcfunction(L,cpp_loadpal); lua_setglobal(L, "loadpal");
|
lua_pushcfunction(L,cpp_loadpal); lua_setglobal(L, "loadpal");
|
||||||
lua_pushcfunction(L,cpp_setpal); lua_setglobal(L, "setpal");
|
lua_pushcfunction(L,cpp_setcolor); lua_setglobal(L, "setcolor");
|
||||||
lua_pushcfunction(L,cpp_getpal); lua_setglobal(L, "getpal");
|
lua_pushcfunction(L,cpp_getcolor); lua_setglobal(L, "getcolor");
|
||||||
lua_pushcfunction(L,cpp_settrans); lua_setglobal(L, "settrans");
|
lua_pushcfunction(L,cpp_settrans); lua_setglobal(L, "settrans");
|
||||||
lua_pushcfunction(L,cpp_gettrans); lua_setglobal(L, "gettrans");
|
lua_pushcfunction(L,cpp_gettrans); lua_setglobal(L, "gettrans");
|
||||||
|
|
||||||
|
|||||||
4
mini.cpp
4
mini.cpp
@@ -308,11 +308,11 @@ void loadpal(const char* filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setpal(uint8_t index, uint32_t color) {
|
void setcolor(uint8_t index, uint32_t color) {
|
||||||
palette[index] = color;
|
palette[index] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getpal(uint8_t index) {
|
uint32_t getcolor(uint8_t index) {
|
||||||
return palette[index];
|
return palette[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
mini.h
4
mini.h
@@ -123,8 +123,8 @@ void cls(uint8_t color=0);
|
|||||||
void color(uint8_t color=6);
|
void color(uint8_t color=6);
|
||||||
|
|
||||||
void loadpal(const char* filename);
|
void loadpal(const char* filename);
|
||||||
void setpal(uint8_t index, uint32_t color);
|
void setcolor(uint8_t index, uint32_t color);
|
||||||
uint32_t getpal(uint8_t index);
|
uint32_t getcolor(uint8_t index);
|
||||||
void settrans(uint8_t index);
|
void settrans(uint8_t index);
|
||||||
uint8_t gettrans();
|
uint8_t gettrans();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user