[FEAT] crlf
This commit is contained in:
@@ -335,6 +335,11 @@ void print(const char *str, int x, int y) {
|
|||||||
cursor_y = (pos+len)/screen_width;
|
cursor_y = (pos+len)/screen_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void crlf() {
|
||||||
|
cursor_x=0;
|
||||||
|
cursor_y = min(cursor_y+1, screen_height-1);
|
||||||
|
}
|
||||||
|
|
||||||
bool btn(uint8_t i) {
|
bool btn(uint8_t i) {
|
||||||
return keys[i];
|
return keys[i];
|
||||||
}
|
}
|
||||||
|
|||||||
1
ascii.h
1
ascii.h
@@ -120,6 +120,7 @@ void color(uint8_t ink, uint8_t paper, int8_t border=-1);
|
|||||||
|
|
||||||
void locate(uint8_t x, uint8_t y); // global::cursorx, global::cursory
|
void locate(uint8_t x, uint8_t y); // global::cursorx, global::cursory
|
||||||
void print(const char *str, int x = -1, int y = -1);
|
void print(const char *str, int x = -1, int y = -1);
|
||||||
|
void crlf();
|
||||||
|
|
||||||
bool btn(uint8_t i);
|
bool btn(uint8_t i);
|
||||||
bool btnp(uint8_t i);
|
bool btnp(uint8_t i);
|
||||||
|
|||||||
6
lua.cpp
6
lua.cpp
@@ -54,6 +54,11 @@ extern "C" {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_crlf(lua_State *L) {
|
||||||
|
crlf();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int cpp_btn(lua_State *L) {
|
static int cpp_btn(lua_State *L) {
|
||||||
uint8_t i = luaL_checkinteger(L, 1);
|
uint8_t i = luaL_checkinteger(L, 1);
|
||||||
lua_pushboolean(L, btn(i));
|
lua_pushboolean(L, btn(i));
|
||||||
@@ -326,6 +331,7 @@ void lua_init(const char* filename, const bool start_playing) {
|
|||||||
|
|
||||||
lua_pushcfunction(L,cpp_locate); lua_setglobal(L, "locate");
|
lua_pushcfunction(L,cpp_locate); lua_setglobal(L, "locate");
|
||||||
lua_pushcfunction(L,cpp_print); lua_setglobal(L, "print");
|
lua_pushcfunction(L,cpp_print); lua_setglobal(L, "print");
|
||||||
|
lua_pushcfunction(L,cpp_crlf); lua_setglobal(L, "crlf");
|
||||||
|
|
||||||
lua_pushcfunction(L,cpp_btn); lua_setglobal(L, "btn");
|
lua_pushcfunction(L,cpp_btn); lua_setglobal(L, "btn");
|
||||||
lua_pushcfunction(L,cpp_btnp); lua_setglobal(L, "btnp");
|
lua_pushcfunction(L,cpp_btnp); lua_setglobal(L, "btnp");
|
||||||
|
|||||||
Reference in New Issue
Block a user