foxygit / fake-08-xbox360 Log in
commit e32752f327e89fe1de7fca5508ad43d380d5dbd9
Author:     Jon Bell <jondbell@protonmail.com>
AuthorDate: Wed May 27 10:54:23 2020 -0600
Commit:     Jon Bell <jondbell@protonmail.com>
CommitDate: Wed May 27 10:54:23 2020 -0600

    Use ints instead of shorts
---
 platform/3ds/source/3dsHost.cpp |  14 ++--
 source/graphics.cpp             | 175 +++++++++++++++++++---------------------
 source/graphics.h               | 135 +++++++++++++++----------------
 source/picoluaapi.cpp           | 162 ++++++++++++++++++-------------------
 4 files changed, 240 insertions(+), 246 deletions(-)

diff --git a/platform/3ds/source/3dsHost.cpp b/platform/3ds/source/3dsHost.cpp
index ecd3717..655ac1b 100644
--- a/platform/3ds/source/3dsHost.cpp
+++ b/platform/3ds/source/3dsHost.cpp
@@ -250,12 +250,12 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, Color* paletteC
 	uint8_t* fbb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
 	memset(fbb, bgcolor, __3ds_BottomScreenWidth*__3ds_BottomScreenHeight*3);

-    short x, y;
+    int x, y;

     //these could be combined to shorten this method
 	if (stretch == PixelPerfect) {
-		short xOffset = __3ds_TopScreenWidth / 2 - PicoScreenWidth / 2;
-        short yOffset = __3ds_TopScreenHeight / 2 - PicoScreenHeight / 2;
+		int xOffset = __3ds_TopScreenWidth / 2 - PicoScreenWidth / 2;
+        int yOffset = __3ds_TopScreenHeight / 2 - PicoScreenHeight / 2;
         //todo: test if it is faster to convert colors to uint24_ts and write one instead of 3 (assuming these are )
         for(x = 0; x < 128; x++) {
             for(y = 0; y < 128; y++) {
@@ -274,8 +274,8 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, Color* paletteC
 		double ratio = (double)__3ds_TopScreenHeight / (double)PicoScreenHeight;
         int stretchedWidth = PicoScreenWidth * ratio;

-        short xOffset = __3ds_TopScreenWidth / 2 - stretchedWidth / 2;
-        short yOffset = 0;
+        int xOffset = __3ds_TopScreenWidth / 2 - stretchedWidth / 2;
+        int yOffset = 0;

         for(x = 0; x < stretchedWidth; x++) {
             for(y = 0; y < __3ds_TopScreenHeight; y++) {
@@ -298,8 +298,8 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, Color* paletteC
         int stretchedWidth = PicoScreenWidth * ratio;
         int stretchedHeight = PicoScreenHeight * ratio;

-        short xOffset = __3ds_TopScreenWidth / 2 - stretchedWidth / 2;
-        short yOffset = 0;
+        int xOffset = __3ds_TopScreenWidth / 2 - stretchedWidth / 2;
+        int yOffset = 0;

         for(x = 0; x < stretchedWidth; x++) {
             for(y = 0; y < __3ds_TopScreenHeight; y++) {
diff --git a/source/graphics.cpp b/source/graphics.cpp
index 9630317..5a2f5b6 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -77,19 +77,19 @@ Color* Graphics::GetPaletteColors(){
 //based on tac08 implementation of blitter()
 void Graphics::copySpriteToScreen(
 	uint8_t spritebuffer[],
-	short scr_x,
-	short scr_y,
-	short spr_x,
-	short spr_y,
-	short spr_w,
-	short spr_h,
+	int scr_x,
+	int scr_y,
+	int spr_x,
+	int spr_y,
+	int spr_w,
+	int spr_h,
 	bool flip_x,
 	bool flip_y)
 {

 	//note: no clipping yet
-	short scr_w = spr_w;
-	short scr_h = spr_h;
+	int scr_w = spr_w;
+	int scr_h = spr_h;

 	applyCameraToPoint(&scr_x, &scr_y);

@@ -129,7 +129,7 @@ void Graphics::copySpriteToScreen(
 		scr_h -= nclip;
 	}

-	short dy = 1;
+	int dy = 1;
 	if (flip_y) {
 		spr_y += spr_h - 1;
 		dy = -dy;
@@ -137,12 +137,12 @@ void Graphics::copySpriteToScreen(

 	//todo: honor x and y flipping

-	for (short y = 0; y < scr_h; y++) {
+	for (int y = 0; y < scr_h; y++) {
 		uint8_t* spr = spritebuffer + ((spr_y + y * dy) & 0x7f) * 64;

 		if (!flip_x) {
-			for (short x = 0; x < scr_w; x++) {
-				short combinedPixIdx = spr_x / 2 + x / 2;
+			for (int x = 0; x < scr_w; x++) {
+				int combinedPixIdx = spr_x / 2 + x / 2;
 				uint8_t bothPix = spr[combinedPixIdx];

 				uint8_t c = x % 2 == 0
@@ -154,9 +154,9 @@ void Graphics::copySpriteToScreen(
 				}
 			}
 		} else {
-			for (short x = 0; x < scr_w; x++) {
+			for (int x = 0; x < scr_w; x++) {
 				int pixIndex = spr_x + spr_w - (x + 1);
-				short combinedPixIdx = pixIndex / 2;
+				int combinedPixIdx = pixIndex / 2;
 				uint8_t bothPix = spr[combinedPixIdx];

 				uint8_t c = x % 2 == 0
@@ -277,31 +277,26 @@ void Graphics::copyStretchSpriteToScreen(
 	}
 }

-void Graphics::swap(short *x, short *y) {
-	short temp;
+void Graphics::swap(int *x, int *y) {
+	int temp;
 	temp = *x;
 	*x = *y;
 	*y = temp;
 }

-void Graphics::applyCameraToPoint(short *x, short *y) {
-	*x -= _gfxState_camera_x;
-	*y -= _gfxState_camera_y;
-}
-
 void Graphics::applyCameraToPoint(int *x, int *y) {
 	*x -= _gfxState_camera_x;
 	*y -= _gfxState_camera_y;
 }

-void Graphics::sortPointsLtoR(short *x1, short *y1, short *x2, short *y2){
+void Graphics::sortPointsLtoR(int *x1, int *y1, int *x2, int *y2){
 	if (*x1 > *x2) {
 		swap(x1, x2);
 		swap(y1, y2);
 	}
 }

-void Graphics::sortCoordsForRect(short *x1, short *y1, short *x2, short *y2){
+void Graphics::sortCoordsForRect(int *x1, int *y1, int *x2, int *y2){
 	if (*x1 > *x2) {
 		swap(x1, x2);
 	}
@@ -311,7 +306,7 @@ void Graphics::sortCoordsForRect(short *x1, short *y1, short *x2, short *y2){
 	}
 }

-bool Graphics::isOnScreen(short x, short y) {
+bool Graphics::isOnScreen(int x, int y) {
 	return
 		x >= 0 &&
 		x <= 127 &&
@@ -319,7 +314,7 @@ bool Graphics::isOnScreen(short x, short y) {
 		y <= 127;
 }

-bool Graphics::isWithinClip(short x, short y) {
+bool Graphics::isWithinClip(int x, int y) {
 	return
 		x >= _gfxState_clip_xb &&
 		x <= _gfxState_clip_xe &&
@@ -327,31 +322,31 @@ bool Graphics::isWithinClip(short x, short y) {
 		y <= _gfxState_clip_ye;
 }

-bool Graphics::isXWithinClip(short x) {
+bool Graphics::isXWithinClip(int x) {
 	return
 		x >= _gfxState_clip_xb &&
 		x <= _gfxState_clip_xe;
 }

-bool Graphics::isYWithinClip(short y) {
+bool Graphics::isYWithinClip(int y) {
 	return
 		y >= _gfxState_clip_yb &&
 		y <= _gfxState_clip_ye;
 }


-short clampCoordToScreenDims(short val) {
-	return std::clamp(val, (short)0, (short)127);
+int clampCoordToScreenDims(int val) {
+	return std::clamp(val, (int)0, (int)127);
 }


-void Graphics::_private_safe_pset(short x, short y, uint8_t col) {
+void Graphics::_private_safe_pset(int x, int y, uint8_t col) {
 	if (isWithinClip(x, y)){
 		_pico8_fb[(x * 128) + y] = _gfxState_drawPaletteMap[col];
 	}
 }

-void Graphics::_private_pset(short x, short y, uint8_t col) {
+void Graphics::_private_pset(int x, int y, uint8_t col) {
 	x = x & 127;
 	y = y & 127;

@@ -370,11 +365,11 @@ void Graphics::cls(uint8_t color) {
 	_gfxState_text_y = 0;
 }

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

-void Graphics::pset(short x, short y, uint8_t col){
+void Graphics::pset(int x, int y, uint8_t col){
 	color(col);

 	applyCameraToPoint(&x, &y);
@@ -384,7 +379,7 @@ void Graphics::pset(short x, short y, uint8_t col){
 	}
 }

-uint8_t Graphics::pget(short x, short y){
+uint8_t Graphics::pget(int x, int y){
 	if (isOnScreen(x, y)){
 		return _pico8_fb[(x * 128) + y];
 	}
@@ -409,54 +404,54 @@ void Graphics::line (uint8_t col){
 	this->line();
 }

-void Graphics::line (short x1, short y1){
+void Graphics::line (int x1, int y1){
 	if (this->_gfxState_line_valid){
 		this->line(_gfxState_line_x, _gfxState_line_y, x1, y1, this->_gfxState_color);
 	}
 }

-void Graphics::line (short x1, short y1, uint8_t col){
+void Graphics::line (int x1, int y1, uint8_t col){
 	if (this->_gfxState_line_valid){
 		this->line(_gfxState_line_x, _gfxState_line_y, x1, y1, col);
 	}
 }

-void Graphics::line (short x1, short y1, short x2, short y2){
+void Graphics::line (int x1, int y1, int x2, int y2){
 	this->line(_gfxState_line_x, _gfxState_line_y, x1, y1, this->_gfxState_color);
 }

-void Graphics::_private_h_line (short x1, short x2, short y, uint8_t col){
+void Graphics::_private_h_line (int x1, int x2, int y, uint8_t col){
 	if (!isYWithinClip(y)){
 		return;
 	}

-	short maxx = clampCoordToScreenDims(std::max(x1, x2));
-	short minx = clampCoordToScreenDims(std::min(x1, x2));
+	int maxx = clampCoordToScreenDims(std::max(x1, x2));
+	int minx = clampCoordToScreenDims(std::min(x1, x2));


 	//possible todo: check if memset is any better here? this seems to be wrong
 	//uint8_t* fb_line = _pico8_fb + y * PicoScreenWidth;
 	//memset(fb_line + minx, col, maxx - minx);
-	for (short x = minx; x <= maxx; x++){
+	for (int x = minx; x <= maxx; x++){
 		_private_pset(x, y, col);
 	}
 }

-void Graphics::_private_v_line (short y1, short y2, short x, uint8_t col){
+void Graphics::_private_v_line (int y1, int y2, int x, uint8_t col){
 	//save draw calls if its out
 	if (!isXWithinClip(x)){
 		return;
 	}

-	short maxy = clampCoordToScreenDims(std::max(y1, y2));
-	short miny = clampCoordToScreenDims(std::min(y1, y2));
+	int maxy = clampCoordToScreenDims(std::max(y1, y2));
+	int miny = clampCoordToScreenDims(std::min(y1, y2));

-	for (short y = miny; y <= maxy; y++){
+	for (int y = miny; y <= maxy; y++){
 		_private_pset(x, y, col);
 	}
 }

-void Graphics::line(short x0, short y0, short x1, short y1, uint8_t col) {
+void Graphics::line(int x0, int y0, int x1, int y1, uint8_t col) {
 	this->_gfxState_line_x = x1;
 	this->_gfxState_line_y = y1;
 	this->_gfxState_line_valid = true;
@@ -497,22 +492,22 @@ void Graphics::line(short x0, short y0, short x1, short y1, uint8_t col) {
 	}
 }

-void Graphics::circ(short ox, short oy){
+void Graphics::circ(int ox, int oy){
 	this->circ(ox, oy, 4);
 }

-void Graphics::circ(short ox, short oy, short r){
+void Graphics::circ(int ox, int oy, int r){
 	this->circ(ox, oy, r, this->_gfxState_color);
 }

-void Graphics::circ(short ox, short oy, short r, uint8_t col){
+void Graphics::circ(int ox, int oy, int r, uint8_t col){
 	color(col);

 	applyCameraToPoint(&ox, &oy);

-	short x = r;
-	short y = 0;
-	short decisionOver2 = 1-x;
+	int x = r;
+	int y = 0;
+	int decisionOver2 = 1-x;

 	while (y <= x) {
 		_private_safe_pset(ox + x, oy + y, col);
@@ -537,15 +532,15 @@ void Graphics::circ(short ox, short oy, short r, uint8_t col){

 }

-void Graphics::circfill(short ox, short oy){
+void Graphics::circfill(int ox, int oy){
 	this->circfill(ox, oy, 4);
 }

-void Graphics::circfill(short ox, short oy, short r){
+void Graphics::circfill(int ox, int oy, int r){
 	this->circfill(ox, oy, r, this->_gfxState_color);
 }

-void Graphics::circfill(short ox, short oy, short r, uint8_t col){
+void Graphics::circfill(int ox, int oy, int r, uint8_t col){
 	color(col);

 	applyCameraToPoint(&ox, &oy);
@@ -559,7 +554,7 @@ void Graphics::circfill(short ox, short oy, short r, uint8_t col){
 		_private_safe_pset(ox, oy + 1, col);
 	}
 	else if (r > 0) {
-		short x = -r, y = 0, err = 2 - 2 * r;
+		int x = -r, y = 0, err = 2 - 2 * r;
 		do {
 			_private_h_line(ox - x, ox + x, oy + y, col);
 			_private_h_line(ox - x, ox + x, oy - y, col);
@@ -573,11 +568,11 @@ void Graphics::circfill(short ox, short oy, short r, uint8_t col){

 }

-void Graphics::rect(short x1, short y1, short x2, short y2) {
+void Graphics::rect(int x1, int y1, int x2, int y2) {
 	this->rect(x1, y1, x2, y2, this->_gfxState_color);
 }

-void Graphics::rect(short x1, short y1, short x2, short y2, uint8_t col) {
+void Graphics::rect(int x1, int y1, int x2, int y2, uint8_t col) {
 	color(col);

 	applyCameraToPoint(&x1, &y1);
@@ -592,34 +587,34 @@ void Graphics::rect(short x1, short y1, short x2, short y2, uint8_t col) {
 	_private_v_line(y1, y2, x2, col);
 }

-void Graphics::rectfill(short x1, short y1, short x2, short y2) {
+void Graphics::rectfill(int x1, int y1, int x2, int y2) {
 	this->rectfill(x1, y1, x2, y2, this->_gfxState_color);
 }

-void Graphics::rectfill(short x1, short y1, short x2, short y2, uint8_t col) {
+void Graphics::rectfill(int x1, int y1, int x2, int y2, uint8_t col) {
 	color(col);

 	sortCoordsForRect(&x1, &y1, &x2, &y2);

-	for (short y = y1; y <= y2; y++) {
+	for (int y = y1; y <= y2; y++) {
 		_private_h_line(x1, x2, y, col);
 	}
 }

-short Graphics::print(std::string str) {
-	short result = this->print(str, _gfxState_text_x, _gfxState_text_y);
+int Graphics::print(std::string str) {
+	int result = this->print(str, _gfxState_text_x, _gfxState_text_y);

 	_gfxState_text_y += 6;

 	return result;
 }

-short Graphics::print(std::string str, short x, short y) {
+int Graphics::print(std::string str, int x, int y) {
 	return this->print(str, x, y, _gfxState_color);
 }

 //based on tac08 impl
-short Graphics::print(std::string str, short x, short y, uint16_t c) {
+int Graphics::print(std::string str, int x, int y, uint16_t c) {
 	color(c);

 	_gfxState_text_x = x;
@@ -637,11 +632,11 @@ short Graphics::print(std::string str, short x, short y, uint16_t c) {
 	for (size_t n = 0; n < str.length(); n++) {
 		uint8_t ch = str[n];
 		if (ch >= 0x10 && ch < 0x80) {
-			short index = ch - 0x10;
+			int index = ch - 0x10;
 			copySpriteToScreen(fontSpriteData, x, y, (index % 16) * 8, (index / 16) * 8, 4, 5, false, false);
 			x += 4;
 		} else if (ch >= 0x80) {
-			short index = ch - 0x80;
+			int index = ch - 0x80;
 			copySpriteToScreen(fontSpriteData, x, y, (index % 16) * 8, (index / 16) * 8 + 56, 8, 5, false, false);
 			x += 8;
 		} else if (ch == '\n') {
@@ -659,28 +654,28 @@ short Graphics::print(std::string str, short x, short y, uint16_t c) {
 }

 void Graphics::spr(
-	short n,
-	short x,
-	short y,
+	int n,
+	int x,
+	int y,
 	double w = 1.0,
 	double h = 1.0,
 	bool flip_x = false,
 	bool flip_y = false)
 {
-	short spr_x = (n % 16) * 8;
-	short spr_y = (n / 16) * 8;
+	int spr_x = (n % 16) * 8;
+	int spr_y = (n / 16) * 8;
 	copySpriteToScreen(spriteSheetData, x, y, spr_x, spr_y, w * 8, h * 8, flip_x, flip_y);
 }

 void Graphics::sspr(
-        short sx,
-        short sy,
-        short sw,
-        short sh,
-        short dx,
-        short dy,
-        short dw,
-        short dh,
+        int sx,
+        int sy,
+        int sw,
+        int sh,
+        int dx,
+        int dy,
+        int dw,
+        int dh,
         bool flip_x = false,
         bool flip_y = false)
 {
@@ -709,7 +704,7 @@ void Graphics::fset(uint8_t n, uint8_t v){
 }

 uint8_t Graphics::sget(uint8_t x, uint8_t y){
-	short combinedIdx = y * 64 + (x / 2);
+	int combinedIdx = y * 64 + (x / 2);

 	uint8_t combinedPix = this->spriteSheetData[combinedIdx];

@@ -721,7 +716,7 @@ uint8_t Graphics::sget(uint8_t x, uint8_t y){
 }

 void Graphics::sset(uint8_t x, uint8_t y, uint8_t c){
-	short combinedIdx = y * 64 + (x / 2);
+	int combinedIdx = y * 64 + (x / 2);

 	uint8_t currentByte = this->spriteSheetData[combinedIdx];
 	uint8_t mask;
@@ -741,7 +736,7 @@ void Graphics::camera() {
 	this->camera(0, 0);
 }

-void Graphics::camera(short x, short y) {
+void Graphics::camera(int x, int y) {
 	_gfxState_camera_x = x;
 	_gfxState_camera_y = y;
 }
@@ -750,9 +745,9 @@ void Graphics::clip() {
 	this->clip(0, 0, 127, 127);
 }

-void Graphics::clip(short x, short y, short w, short h) {
-	short xe = x + w;
-	short ye = y + h;
+void Graphics::clip(int x, int y, int w, int h) {
+	int xe = x + w;
+	int ye = y + h;
 	_gfxState_clip_xb = clampCoordToScreenDims(x);
 	_gfxState_clip_yb = clampCoordToScreenDims(y);
 	_gfxState_clip_xe = clampCoordToScreenDims(xe);
@@ -761,7 +756,7 @@ void Graphics::clip(short x, short y, short w, short h) {


 //map methods heavily based on tac08 implementation
-uint8_t Graphics::mget(short celx, short cely){
+uint8_t Graphics::mget(int celx, int cely){
 	if (cely < 32) {
 		return this->mapData[cely * 128 + celx];
 	}
@@ -772,7 +767,7 @@ uint8_t Graphics::mget(short celx, short cely){
 	return 0;
 }

-void Graphics::mset(short celx, short cely, uint8_t snum){
+void Graphics::mset(int celx, int cely, uint8_t snum){
 	if (cely < 32) {
 		this->mapData[cely * 128 + celx] = snum;
 	}
@@ -832,12 +827,12 @@ void Graphics::cursor() {
 	this->cursor(0, 0);
 }

-void Graphics::cursor(short x, short y) {
+void Graphics::cursor(int x, int y) {
 	_gfxState_text_x = x;
 	_gfxState_text_y = y;
 }

-void Graphics::cursor(short x, short y, uint8_t col) {
+void Graphics::cursor(int x, int y, uint8_t col) {
 	color(col);

 	this->cursor(x, y);
diff --git a/source/graphics.h b/source/graphics.h
index e8066af..15f0912 100644
--- a/source/graphics.h
+++ b/source/graphics.h
@@ -36,35 +36,35 @@ class Graphics {
 	uint8_t _gfxState_color;
     uint8_t _gfxState_bgColor;

-    short _gfxState_text_x;
-	short _gfxState_text_y;
+    int _gfxState_text_x;
+	int _gfxState_text_y;

-	short _gfxState_camera_x;
-	short _gfxState_camera_y;
+	int _gfxState_camera_x;
+	int _gfxState_camera_y;

-	short _gfxState_clip_xb;
-	short _gfxState_clip_yb;
-	short _gfxState_clip_xe;
-	short _gfxState_clip_ye;
+	int _gfxState_clip_xb;
+	int _gfxState_clip_yb;
+	int _gfxState_clip_xe;
+	int _gfxState_clip_ye;

 	uint8_t _gfxState_drawPaletteMap[16];
 	uint8_t _gfxState_screenPaletteMap[16];
 	bool _gfxState_transparencyPalette[16];

 	//not actually part of graphics state memory?
-	short _gfxState_line_x;
-	short _gfxState_line_y;
+	int _gfxState_line_x;
+	int _gfxState_line_y;
 	bool _gfxState_line_valid;


 	void copySpriteToScreen(
 		uint8_t spritebuffer[],
-		short scr_x,
-		short scr_y,
-		short spr_x,
-		short spr_y,
-		short spr_w,
-		short spr_h,
+		int scr_x,
+		int scr_y,
+		int spr_x,
+		int spr_y,
+		int spr_w,
+		int spr_h,
 		bool flip_x,
 		bool flip_y);

@@ -81,23 +81,22 @@ class Graphics {
 		bool flip_x,
 		bool flip_y);

-	void swap(short *x, short *y);
-	void applyCameraToPoint(short *x, short *y);
+	void swap(int *x, int *y);
 	void applyCameraToPoint(int *x, int *y);

-	void sortPointsLtoR(short *x1, short *y1, short *x2, short *y2);
+	void sortPointsLtoR(int *x1, int *y1, int *x2, int *y2);

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

-	bool isOnScreen(short x, short y);
-	bool isWithinClip(short x, short y);
-	bool isXWithinClip(short x);
-	bool isYWithinClip(short y);
+	bool isOnScreen(int x, int y);
+	bool isWithinClip(int x, int y);
+	bool isXWithinClip(int x);
+	bool isYWithinClip(int y);

-	void _private_pset(short x, short y, uint8_t col);
-	void _private_safe_pset(short x, short y, uint8_t col);
-	void _private_h_line (short x1, short x2, short y, uint8_t col);
-	void _private_v_line (short y1, short y2, short x, uint8_t col);
+	void _private_pset(int x, int y, uint8_t col);
+	void _private_safe_pset(int x, int y, uint8_t col);
+	void _private_h_line (int x1, int x2, int y, uint8_t col);
+	void _private_v_line (int y1, int y2, int x, uint8_t col);

 	public:
 	Graphics(std::string fontdata);
@@ -113,53 +112,53 @@ class Graphics {
 	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);
+	void pset(int x, int y);
+	void pset(int x, int y, uint8_t col);
+	uint8_t pget(int x, int y);

 	void color(uint8_t c);

 	void line ();
 	void line (uint8_t col);
-	void line (short x1, short y1);
-	void line (short x1, short y1, uint8_t col);
-	void line (short x1, short y1, short x2, short y2);
-	void line (short x1, short y1, short x2, short y2, uint8_t col);
-
-	void circ(short ox, short oy);
-	void circ(short ox, short oy, short r);
-	void circ(short ox, short oy, short r, uint8_t col);
-	void circfill(short ox, short oy);
-	void circfill(short ox, short oy, short r);
-	void circfill(short ox, short oy, short r, uint8_t col);
-
-	void rect(short x1, short y1, short x2, short y2);
-	void rect(short x1, short y1, short x2, short y2, uint8_t col);
-	void rectfill(short x1, short y1, short x2, short y2);
-	void rectfill(short x1, short y1, short x2, short y2, uint8_t col);
-
-	short print(std::string str);
-	short print(std::string str, short x, short y);
-	short print(std::string str, short x, short y, uint16_t c);
+	void line (int x1, int y1);
+	void line (int x1, int y1, uint8_t col);
+	void line (int x1, int y1, int x2, int y2);
+	void line (int x1, int y1, int x2, int y2, uint8_t col);
+
+	void circ(int ox, int oy);
+	void circ(int ox, int oy, int r);
+	void circ(int ox, int oy, int r, uint8_t col);
+	void circfill(int ox, int oy);
+	void circfill(int ox, int oy, int r);
+	void circfill(int ox, int oy, int r, uint8_t col);
+
+	void rect(int x1, int y1, int x2, int y2);
+	void rect(int x1, int y1, int x2, int y2, uint8_t col);
+	void rectfill(int x1, int y1, int x2, int y2);
+	void rectfill(int x1, int y1, int x2, int y2, uint8_t col);
+
+	int print(std::string str);
+	int print(std::string str, int x, int y);
+	int print(std::string str, int x, int y, uint16_t c);

 	void spr(
-		short n,
-		short x,
-		short y,
+		int n,
+		int x,
+		int y,
 		double w,
 		double h,
 		bool flip_x,
 		bool flip_y);

 	void sspr(
-        short sx,
-        short sy,
-        short sw,
-        short sh,
-        short dx,
-        short dy,
-        short dw,
-        short dh,
+        int sx,
+        int sy,
+        int sw,
+        int sh,
+        int dx,
+        int dy,
+        int dw,
+        int dh,
         bool flip_x,
         bool flip_y);

@@ -172,13 +171,13 @@ class Graphics {
 	void sset(uint8_t x, uint8_t y, uint8_t c);

 	void camera();
-	void camera(short x, short y);
+	void camera(int x, int y);

 	void clip();
-	void clip(short x, short y, short w, short h);
+	void clip(int x, int y, int w, int h);

-	uint8_t mget(short celx, short cely);
-	void mset(short celx, short cely, uint8_t snum);
+	uint8_t mget(int celx, int cely);
+	void mset(int celx, int cely, uint8_t snum);

 	void map(int celx, int cely, int sx, int sy, int celw, int celh);
 	void map(int celx, int cely, int sx, int sy, int celw, int celh, uint8_t layer);
@@ -189,8 +188,8 @@ class Graphics {
 	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 cursor(int x, int y);
+	void cursor(int x, int y, uint8_t col);

 };

diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index f2477f9..882d404 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -43,7 +43,7 @@ int cls(lua_State *L){
         _graphicsForLuaApi->cls();
     }
     else {
-        short c = lua_tonumber(L,1);
+        int c = lua_tonumber(L,1);
         _graphicsForLuaApi->cls(c);
     }

@@ -51,15 +51,15 @@ int cls(lua_State *L){
 }

 int pset(lua_State *L){
-    short x = lua_tonumber(L,1);
-    short y = lua_tonumber(L,2);
+    int x = lua_tonumber(L,1);
+    int y = lua_tonumber(L,2);

     if (lua_gettop(L) <= 2) {
         _graphicsForLuaApi->pset(x, y);
         return 0;
     }

-    short c = lua_tonumber(L,3);
+    int c = lua_tonumber(L,3);

     _graphicsForLuaApi->pset(x, y, (uint8_t)c);

@@ -70,7 +70,7 @@ int pget(lua_State *L){
     double x = lua_tonumber(L,1);
     double y = lua_tonumber(L,2);

-    uint8_t color = _graphicsForLuaApi->pget((short)x, (short)y);
+    uint8_t color = _graphicsForLuaApi->pget((int)x, (int)y);

     lua_pushinteger(L, color);

@@ -95,31 +95,31 @@ int line (lua_State *L){
         _graphicsForLuaApi->line(c);
     }
     else if (lua_gettop(L) == 2) {
-        short x1 = lua_tonumber(L,1);
-        short y1 = lua_tonumber(L,2);
+        int x1 = lua_tonumber(L,1);
+        int y1 = lua_tonumber(L,2);

         _graphicsForLuaApi->line(x1, y1);
     }
     else if (lua_gettop(L) == 3) {
-        short x1 = lua_tonumber(L,1);
-        short y1 = lua_tonumber(L,2);
+        int x1 = lua_tonumber(L,1);
+        int y1 = lua_tonumber(L,2);
         uint8_t c = lua_tonumber(L,3);

         _graphicsForLuaApi->line(x1, y1, c);
     }
     else if (lua_gettop(L) == 4) {
-        short x1 = lua_tonumber(L,1);
-        short y1 = lua_tonumber(L,2);
-        short x2 = lua_tonumber(L,3);
-        short y2 = lua_tonumber(L,4);
+        int x1 = lua_tonumber(L,1);
+        int y1 = lua_tonumber(L,2);
+        int x2 = lua_tonumber(L,3);
+        int y2 = lua_tonumber(L,4);

         _graphicsForLuaApi->line(x1, y1, x2, y2);
     }
     else {
-        short x1 = lua_tonumber(L,1);
-        short y1 = lua_tonumber(L,2);
-        short x2 = lua_tonumber(L,3);
-        short y2 = lua_tonumber(L,4);
+        int x1 = lua_tonumber(L,1);
+        int y1 = lua_tonumber(L,2);
+        int x2 = lua_tonumber(L,3);
+        int y2 = lua_tonumber(L,4);
         uint8_t c = lua_tonumber(L,5);

         _graphicsForLuaApi->line(x1, y1, x2, y2, c);
@@ -129,18 +129,18 @@ int line (lua_State *L){
 }

 int circ(lua_State *L){
-    short ox = lua_tonumber(L,1);
-    short oy = lua_tonumber(L,2);
+    int ox = lua_tonumber(L,1);
+    int oy = lua_tonumber(L,2);

     if (lua_gettop(L) == 2) {
         _graphicsForLuaApi->circ(ox, oy);
     }
     else if (lua_gettop(L) == 3){
-        short r = lua_tonumber(L,3);
+        int r = lua_tonumber(L,3);
         _graphicsForLuaApi->circ(ox, oy, r);
     }
     else if (lua_gettop(L) > 3){
-        short r = lua_tonumber(L,3);
+        int r = lua_tonumber(L,3);
         uint8_t c = lua_tonumber(L,4);

         _graphicsForLuaApi->circ(ox, oy, r, c);
@@ -150,18 +150,18 @@ int circ(lua_State *L){
 }

 int circfill(lua_State *L){
-    short ox = lua_tonumber(L,1);
-    short oy = lua_tonumber(L,2);
+    int ox = lua_tonumber(L,1);
+    int oy = lua_tonumber(L,2);

     if (lua_gettop(L) == 2) {
         _graphicsForLuaApi->circfill(ox, oy);
     }
     else if (lua_gettop(L) == 3){
-        short r = lua_tonumber(L,3);
+        int r = lua_tonumber(L,3);
         _graphicsForLuaApi->circfill(ox, oy, r);
     }
     else if (lua_gettop(L) > 3){
-        short r = lua_tonumber(L,3);
+        int r = lua_tonumber(L,3);
         uint8_t c = lua_tonumber(L,4);

         _graphicsForLuaApi->circfill(ox, oy, r, c);
@@ -173,10 +173,10 @@ int circfill(lua_State *L){
 int rect(lua_State *L){

     if (lua_gettop(L) >= 4) {
-        short x1 = lua_tonumber(L,1);
-        short y1 = lua_tonumber(L,2);
-        short x2 = lua_tonumber(L,3);
-        short y2 = lua_tonumber(L,4);
+        int x1 = lua_tonumber(L,1);
+        int y1 = lua_tonumber(L,2);
+        int x2 = lua_tonumber(L,3);
+        int y2 = lua_tonumber(L,4);

         if (lua_gettop(L) == 4){
             _graphicsForLuaApi->rect(x1, y1, x2, y2);
@@ -194,10 +194,10 @@ int rect(lua_State *L){

 int rectfill(lua_State *L){
     if (lua_gettop(L) >= 4) {
-        short x1 = lua_tonumber(L,1);
-        short y1 = lua_tonumber(L,2);
-        short x2 = lua_tonumber(L,3);
-        short y2 = lua_tonumber(L,4);
+        int x1 = lua_tonumber(L,1);
+        int y1 = lua_tonumber(L,2);
+        int x2 = lua_tonumber(L,3);
+        int y2 = lua_tonumber(L,4);

         if (lua_gettop(L) == 4){
             _graphicsForLuaApi->rectfill(x1, y1, x2, y2);
@@ -239,14 +239,14 @@ int print(lua_State *L){
         _graphicsForLuaApi->print(str);
     }
     else if (lua_gettop(L) == 3) {
-        short x = lua_tonumber(L,2);
-        short y = lua_tonumber(L,3);
+        int x = lua_tonumber(L,2);
+        int y = lua_tonumber(L,3);

         _graphicsForLuaApi->print(str, x, y);
     }
     else {
-        short x = lua_tonumber(L,2);
-        short y = lua_tonumber(L,3);
+        int x = lua_tonumber(L,2);
+        int y = lua_tonumber(L,3);

         uint8_t c = lua_tonumber(L,4);

@@ -261,9 +261,9 @@ int spr(lua_State *L) {
         return 0;
     }

-    short n = lua_tonumber(L,1);
-    short x = lua_tonumber(L,2);
-    short y = lua_tonumber(L,3);
+    int n = lua_tonumber(L,1);
+    int x = lua_tonumber(L,2);
+    int y = lua_tonumber(L,3);
     double w = 1.0;
     double h = 1.0;
     bool flip_x = false;
@@ -293,15 +293,15 @@ int sspr(lua_State *L) {
         return 0;
     }

-    short sx = lua_tonumber(L,1);
-    short sy = lua_tonumber(L,2);
-    short sw = lua_tonumber(L,3);
-    short sh = lua_tonumber(L,4);
-    short dx = lua_tonumber(L,5);
-    short dy = lua_tonumber(L,6);
+    int sx = lua_tonumber(L,1);
+    int sy = lua_tonumber(L,2);
+    int sw = lua_tonumber(L,3);
+    int sh = lua_tonumber(L,4);
+    int dx = lua_tonumber(L,5);
+    int dy = lua_tonumber(L,6);

-    short dw = sw;
-    short dh = sh;
+    int dw = sw;
+    int dh = sh;
     bool flip_x = false;
     bool flip_y = false;

@@ -366,8 +366,8 @@ int fset(lua_State *L) {
 }

 int sget(lua_State *L) {
-    short x = lua_tonumber(L,1);
-    short y = lua_tonumber(L,2);
+    int x = lua_tonumber(L,1);
+    int y = lua_tonumber(L,2);
     uint8_t result = _graphicsForLuaApi->sget((uint8_t)x, (uint8_t)y);
     lua_pushinteger(L, result);

@@ -375,8 +375,8 @@ int sget(lua_State *L) {
 }

 int sset(lua_State *L) {
-    short x = lua_tonumber(L,1);
-    short y = lua_tonumber(L,2);
+    int x = lua_tonumber(L,1);
+    int y = lua_tonumber(L,2);
     uint8_t c = lua_tonumber(L,3);
     _graphicsForLuaApi->sset(x, y, c);

@@ -384,8 +384,8 @@ int sset(lua_State *L) {
 }

 int camera(lua_State *L) {
-    short x = 0;
-    short y = 0;
+    int x = 0;
+    int y = 0;
     if (lua_gettop(L) > 0) {
         x = lua_tonumber(L,1);
     }
@@ -400,10 +400,10 @@ int camera(lua_State *L) {

 int clip(lua_State *L) {
     if (lua_gettop(L) >= 4) {
-        short x = lua_tonumber(L,1);
-        short y = lua_tonumber(L,2);
-        short w = lua_tonumber(L,3);
-        short h = lua_tonumber(L,4);
+        int x = lua_tonumber(L,1);
+        int y = lua_tonumber(L,2);
+        int w = lua_tonumber(L,3);
+        int h = lua_tonumber(L,4);

         _graphicsForLuaApi->clip(x, y, w, h);
     }
@@ -415,8 +415,8 @@ int clip(lua_State *L) {
 }

 int mget(lua_State *L) {
-    short celx = lua_tonumber(L,1);
-    short cely = lua_tonumber(L,2);
+    int celx = lua_tonumber(L,1);
+    int cely = lua_tonumber(L,2);

     uint8_t result = _graphicsForLuaApi->mget(celx, cely);
     lua_pushnumber(L, result);
@@ -425,8 +425,8 @@ int mget(lua_State *L) {
 }

 int mset(lua_State *L) {
-    short celx = lua_tonumber(L,1);
-    short cely = lua_tonumber(L,2);
+    int celx = lua_tonumber(L,1);
+    int cely = lua_tonumber(L,2);
     uint8_t snum = lua_tonumber(L, 3);

     _graphicsForLuaApi->mset(celx, cely, snum);
@@ -435,12 +435,12 @@ int mset(lua_State *L) {
 }

 int map(lua_State *L) {
-    short celx = lua_tonumber(L,1);
-    short cely = lua_tonumber(L,2);
-    short sx = lua_tonumber(L,3);
-    short sy = lua_tonumber(L,4);
-    short celw = lua_tonumber(L,5);
-    short celh = lua_tonumber(L,6);
+    int celx = lua_tonumber(L,1);
+    int cely = lua_tonumber(L,2);
+    int sx = lua_tonumber(L,3);
+    int sy = lua_tonumber(L,4);
+    int celw = lua_tonumber(L,5);
+    int celh = lua_tonumber(L,6);
     uint8_t layer = 0;

     if (lua_gettop(L) > 6){
@@ -489,8 +489,8 @@ int palt(lua_State *L) {
 }

 int cursor(lua_State *L) {
-    short x = lua_tonumber(L,1);
-    short y = lua_tonumber(L,2);
+    int x = lua_tonumber(L,1);
+    int y = lua_tonumber(L,2);

     if (lua_gettop(L) <= 2) {
         _graphicsForLuaApi->cursor(x, y);
@@ -519,7 +519,7 @@ int flip(lua_State *L) {
 int btn(lua_State *L){
     double i = lua_tonumber(L,1);

-    bool pressed = _inputForLuaApi->btn((short)i);
+    bool pressed = _inputForLuaApi->btn((int)i);

     lua_pushboolean(L, pressed);

@@ -528,7 +528,7 @@ int btn(lua_State *L){
 int btnp(lua_State *L){
     double i = lua_tonumber(L,1);

-    bool pressed = _inputForLuaApi->btnp((short)i);
+    bool pressed = _inputForLuaApi->btnp((int)i);

     lua_pushboolean(L, pressed);

@@ -554,13 +554,13 @@ int stat(lua_State *L) {
 //Audio
 int music(lua_State *L) {
     double n = lua_tonumber(L,1);
-    short fadems = 0;
+    int fadems = 0;
     if (lua_gettop(L) > 1) {
-        fadems = (short)lua_tonumber(L, 2);
+        fadems = (int)lua_tonumber(L, 2);
     }
-    short channelmask = 0;
+    int channelmask = 0;
     if (lua_gettop(L) > 2) {
-        channelmask = (short)lua_tonumber(L, 3);
+        channelmask = (int)lua_tonumber(L, 3);
     }

     _audioForLuaApi->api_music((uint8_t)n, fadems, channelmask);
@@ -570,16 +570,16 @@ int music(lua_State *L) {

 int sfx(lua_State *L) {
     double n = lua_tonumber(L,1);
-    short channel = -1;
+    int channel = -1;
     if (lua_gettop(L) > 1) {
-        channel = (short)lua_tonumber(L, 2);
+        channel = (int)lua_tonumber(L, 2);
     }
-    short offset = 0;
+    int offset = 0;
     if (lua_gettop(L) > 2) {
-        offset = (short)lua_tonumber(L, 3);
+        offset = (int)lua_tonumber(L, 3);
     }

-    _audioForLuaApi->api_sfx((short)n, channel, offset);
+    _audioForLuaApi->api_sfx((int)n, channel, offset);

     return 0;
 }