commit 65f2a0d7ebe693c06c14209b3175a71d57c65180
Author: Jon Bell <jondbell@protonmail.com>
AuthorDate: Sat Apr 25 14:48:09 2020 -0600
Commit: Jon Bell <jondbell@protonmail.com>
CommitDate: Sat Apr 25 14:48:09 2020 -0600
Add cursor impl and stub fillp to finish basic graphics
---
source/graphics.cpp | 15 +++++++++++++++
source/graphics.h | 4 ++++
source/picoluaapi.cpp | 26 ++++++++++++++++++++++++++
source/picoluaapi.h | 17 ++++-------------
4 files changed, 49 insertions(+), 13 deletions(-)
diff --git a/source/graphics.cpp b/source/graphics.cpp
index a0ff6e6..414c8a1 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -658,3 +658,18 @@ void Graphics::flipBuffer(uint8_t* fb) {
}
}
+void Graphics::cursor() {
+ this->cursor(0, 0);
+}
+
+void Graphics::cursor(short x, short y) {
+ _gfxState_text_x = x;
+ _gfxState_text_y = y;
+}
+
+void Graphics::cursor(short x, short y, uint8_t col) {
+ color(col);
+
+ this->cursor(x, y);
+}
+
diff --git a/source/graphics.h b/source/graphics.h
index f8ff6bc..6f44037 100644
--- a/source/graphics.h
+++ b/source/graphics.h
@@ -182,6 +182,10 @@ class Graphics {
void palt();
void palt(uint8_t c0, bool t);
+ void cursor();
+ void cursor(short x, short y);
+ void cursor(short x, short y, uint8_t col);
+
void flipBuffer(uint8_t* fb);
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index 114c812..baa80fa 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -19,6 +19,11 @@ void initPicoApi(Graphics* graphics, Input* input){
_inputForLuaApi = input;
}
+int noop(const char * name) {
+ //todo log name of unimplemented functions?
+ return 0;
+}
+
/*functions to expose to lua*/
//Graphics
int cls(lua_State *L){
@@ -471,6 +476,27 @@ int palt(lua_State *L) {
return 0;
}
+int cursor(lua_State *L) {
+ short x = lua_tonumber(L,1);
+ short y = lua_tonumber(L,2);
+
+ if (lua_gettop(L) <= 2) {
+ _graphicsForLuaApi->cursor(x, y);
+ return 0;
+ }
+
+ uint8_t c = lua_tonumber(L,3);
+
+ _graphicsForLuaApi->cursor(x, y, c);
+
+ return 0;
+
+}
+
+int fillp(lua_State *L) {
+ return noop("fillp");
+}
+
//Input
//input api
diff --git a/source/picoluaapi.h b/source/picoluaapi.h
index f4fc0ae..0212427 100644
--- a/source/picoluaapi.h
+++ b/source/picoluaapi.h
@@ -38,6 +38,10 @@ int mset(lua_State *L);
int map(lua_State *L);
int pal(lua_State *L);
int palt(lua_State *L);
+int cursor(lua_State *L);
+//todo:
+int fillp(lua_State *L);
+//end todo
//input api
int btn(lua_State *L);
@@ -46,19 +50,6 @@ int btnp(lua_State *L);
//TODO:
//graphics
-
-//api.flip()
-//int flip(lua_State *L);
-//api.camera(x, y)
-//int camera(lua_State *L);
-//api.clip(x, y, w, h)
-//int clip(lua_State *L);
-//api.cursor(x, y)
-//int cursor(lua_State *L);
-//api.pal(c0, c1, p)
-
-//api.palt(c, t)
-
//api.fillp(p)
//map