commit ddc589897e66bac48adba15fe6c45ba0027aa591
Author: Sam Sussman-Randall <samsussman-randall@sams-mbp-2.attlocal.net>
AuthorDate: Tue Jun 14 16:30:11 2022 -0400
Commit: Sam Sussman-Randall <samsussman-randall@sams-mbp-2.attlocal.net>
CommitDate: Tue Jun 14 16:30:11 2022 -0400
Added pal(p) support
---
source/graphics.cpp | 10 ++++++++++
source/graphics.h | 1 +
source/picoluaapi.cpp | 5 +++++
3 files changed, 16 insertions(+)
diff --git a/source/graphics.cpp b/source/graphics.cpp
index 11d9e2e..98f5c21 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -1498,6 +1498,16 @@ void Graphics::pal() {
this->palt();
}
+void Graphics::pal(uint8_t p) {
+ for (uint8_t c = 0; c < 16; c++) {
+ if (p == 0) {
+ _memory->drawState.drawPaletteMap[c] = c;
+ } else if (p == 1) {
+ _memory->drawState.screenPaletteMap[c] = c;
+ }
+ }
+}
+
uint8_t Graphics::pal(uint8_t c0, uint8_t c1, uint8_t p){
//0-15 alowed
c0 &= 0x0f;
diff --git a/source/graphics.h b/source/graphics.h
index 173ef60..f385097 100644
--- a/source/graphics.h
+++ b/source/graphics.h
@@ -153,6 +153,7 @@ class Graphics {
void map(int celx, int cely, int sx, int sy, int celw, int celh, uint8_t layer);
void pal();
+ void pal(uint8_t p);
uint8_t pal(uint8_t c0, uint8_t c1, uint8_t p);
void palt();
bool palt(uint8_t c0, bool t);
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index 644cc2f..3a2b84a 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -613,6 +613,11 @@ int pal(lua_State *L) {
}
return 0;
+ } else if (numArgs == 1) {
+ p = lua_tonumber(L, 0);
+ _graphicsForLuaApi->pal(p);
+ lua_pushnumber(L, 0);
+ return 1;
}