[FEAT] crlf

This commit is contained in:
2021-12-13 16:14:26 +01:00
parent e5798f4b71
commit 62c513db56
3 changed files with 12 additions and 0 deletions

View File

@@ -335,6 +335,11 @@ void print(const char *str, int x, int y) {
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) {
return keys[i];
}

View File

@@ -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 print(const char *str, int x = -1, int y = -1);
void crlf();
bool btn(uint8_t i);
bool btnp(uint8_t i);

View File

@@ -54,6 +54,11 @@ extern "C" {
return 0;
}
static int cpp_crlf(lua_State *L) {
crlf();
return 0;
}
static int cpp_btn(lua_State *L) {
uint8_t i = luaL_checkinteger(L, 1);
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_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_btnp); lua_setglobal(L, "btnp");