foxygit / fake-08-xbox360 Log in
commit f6365f321028c96693f12dcf4aeea4118c70d58d
Author:     Jon Bell <jondbell@protonmail.com>
AuthorDate: Wed Apr 22 19:07:55 2020 -0600
Commit:     Jon Bell <jondbell@protonmail.com>
CommitDate: Wed Apr 22 19:07:55 2020 -0600

    implement cls and pset overloads
---
 source/graphics.cpp | 22 +++++++++++++++++-----
 source/graphics.h   |  4 +++-
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/source/graphics.cpp b/source/graphics.cpp
index c253644..55c0203 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -181,24 +181,36 @@ void Graphics::sortCoordsForRect(short *x1, short *y1, short *x2, short *y2){
 	}
 }

-bool Graphics::isOnScreen(short *x, short* y) {
-	return *x >= 0 && *x <= 127 && *y >= 0 && *y <= 127;
+bool Graphics::isOnScreen(short x, short y) {
+	return x >= 0 && x <= 127 && y >= 0 && y <= 127;
 }
 //end helper methods

 void Graphics::cls() {
-	memset(_pico8_fb, this->_gfxState_bgColor, sizeof(_pico8_fb));
+	this->cls(0);
+}
+
+void Graphics::cls(uint8_t color) {
+	memset(_pico8_fb, color, sizeof(_pico8_fb));
+
+	_gfxState_text_x = 0;
+	_gfxState_text_y = 0;
+}

+void Graphics::pset(short x, short y){
+	this->pset(x, y, _gfxState_color);
 }

 void Graphics::pset(short x, short y, uint8_t col){
-	if (isOnScreen(&x, &y)){
+	color(col);
+
+	if (isOnScreen(x, y)){
 		_pico8_fb[(x * 128) + y] = col;
 	}
 }

 uint8_t Graphics::pget(short x, short y){
-	if (isOnScreen(&x, &y)){
+	if (isOnScreen(x, y)){
 		return _pico8_fb[(x * 128) + y];
 	}

diff --git a/source/graphics.h b/source/graphics.h
index 4c25ec2..ff84d43 100644
--- a/source/graphics.h
+++ b/source/graphics.h
@@ -73,7 +73,7 @@ class Graphics {

 	void sortCoordsForRect(short *x1, short *y1, short *x2, short *y2);

-	bool isOnScreen(short *x, short* y);
+	bool isOnScreen(short x, short y);

 	public:
 	Graphics(std::string fontdata);
@@ -82,7 +82,9 @@ class Graphics {
 	void setSpriteFlags(std::string spriteFlagsString);

 	void cls();
+	void cls(uint8_t color);

+	void pset(short x, short y);
 	void pset(short x, short y, uint8_t col);
 	uint8_t pget(short x, short y);