[Scummvm-git-logs] scummvm master -> cd017a73c7be6df926492df0a306f6fdbc59240e

dreammaster dreammaster at scummvm.org
Wed Feb 17 03:45:33 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b38670950f AGS: Clang fix and cleanup for AGSPalRender plugin
cd017a73c7 AGS: Revert Standardization of number types


Commit: b38670950f06c9e04ad4edb66415a3d6ef59a28e
    https://github.com/scummvm/scummvm/commit/b38670950f06c9e04ad4edb66415a3d6ef59a28e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-02-16T19:33:43-08:00

Commit Message:
AGS: Clang fix and cleanup for AGSPalRender plugin

Changed paths:
    engines/ags/plugins/ags_pal_render/ags_pal_render.cpp
    engines/ags/plugins/ags_pal_render/raycast.cpp
    engines/ags/plugins/ags_pal_render/raycast.h


diff --git a/engines/ags/plugins/ags_pal_render/ags_pal_render.cpp b/engines/ags/plugins/ags_pal_render/ags_pal_render.cpp
index 2af4b854a2..afa5466e1d 100644
--- a/engines/ags/plugins/ags_pal_render/ags_pal_render.cpp
+++ b/engines/ags/plugins/ags_pal_render/ags_pal_render.cpp
@@ -1743,8 +1743,8 @@ NumberPtr AGSPalRender::AGS_EngineOnEvent(int event, NumberPtr data) {
 		engine->FWrite(&moveSpeed, sizeof(double), data);
 		engine->FWrite(&rotSpeed, sizeof(double), data);
 		if (raycastOn) { //If the raycaster is active, we have additional data to save.
-			for (int i = 0; i < mapWidth; ++i)
-				for (int j = 0; j < mapHeight; ++j) {
+			for (int i = 0; i < MAP_WIDTH; ++i)
+				for (int j = 0; j < MAP_HEIGHT; ++j) {
 					engine->FWrite(&worldMap [i][j], sizeof(unsigned char), data);
 					engine->FWrite(&lightMap [i][j], sizeof(unsigned char), data);
 					engine->FWrite(&ceilingMap [i][j], sizeof(int), data);
@@ -1816,8 +1816,8 @@ NumberPtr AGSPalRender::AGS_EngineOnEvent(int event, NumberPtr data) {
 		engine->FRead(&moveSpeed, sizeof(double), data);
 		engine->FRead(&rotSpeed, sizeof(double), data);
 		if (raycastOn) { //If the raycaster is currently running, we have additional data to load.
-			for (int i = 0; i < mapWidth; ++i) {
-				for (int j = 0; j < mapHeight; ++j) {
+			for (int i = 0; i < MAP_WIDTH; ++i) {
+				for (int j = 0; j < MAP_HEIGHT; ++j) {
 					engine->FRead(&worldMap [i][j], sizeof(unsigned char), data);
 					engine->FRead(&lightMap [i][j], sizeof(unsigned char), data);
 					engine->FRead(&ceilingMap [i][j], sizeof(int), data);
diff --git a/engines/ags/plugins/ags_pal_render/raycast.cpp b/engines/ags/plugins/ags_pal_render/raycast.cpp
index 3adf6cc378..66212dddfc 100644
--- a/engines/ags/plugins/ags_pal_render/raycast.cpp
+++ b/engines/ags/plugins/ags_pal_render/raycast.cpp
@@ -28,24 +28,22 @@ namespace Plugins {
 namespace AGSPalRender {
 
 #define PI         (3.1415926535f)
+#define S_WIDTH 320
+#define S_HEIGHT 160
 
-//Variable Declaration
+// Variable Declaration
 bool raycastOn;
 double posX = 22.0, posY = 11.5; //x and y start position
 double dirX = -1.0, dirY = 0.0; //initial direction vector
 double planeX = 0.0, planeY = 0.77; //the 2d raycaster version of camera plane
 double moveSpeed = (1.0 / 60.0) * 3.0; //the constant value is in squares/second
 double rotSpeed = (1.0 / 60.0) * 2.0; //the constant value is in radians/second
-unsigned char worldMap[64][64];
-unsigned char lightMap[64][64];
-int ceilingMap[64][64];
-int floorMap[64][64];
-int heightMap[64][64];
-unsigned char seenMap[64][64];
-//int mapWidth;
-//int mapHeight;
-#define mapWidth 64
-#define mapHeight 64
+unsigned char worldMap[MAP_WIDTH][MAP_HEIGHT];
+unsigned char lightMap[MAP_WIDTH][MAP_HEIGHT];
+int ceilingMap[MAP_WIDTH][MAP_HEIGHT];
+int floorMap[MAP_WIDTH][MAP_HEIGHT];
+int heightMap[MAP_WIDTH][MAP_HEIGHT];
+unsigned char seenMap[MAP_WIDTH][MAP_HEIGHT];
 int textureSlot;
 int ambientlight;
 int ambientweight = 0;
@@ -53,12 +51,7 @@ int ambientcolor = 0;
 int ambientcolorAmount = 0;
 
 Sprite sprite[numSprites] = {};
-
-
-#define sWidth 320
-#define sHeight 160
-
-int editorMap [sWidth][sHeight] = {};
+int editorMap [S_WIDTH][S_HEIGHT] = {};
 
 unsigned char texture[MAX_TEXTURES][texWidth * texHeight];
 
@@ -87,8 +80,8 @@ int selectedY;
 unsigned char selectedColor;
 
 void Ray_SelectTile(int x, int y, unsigned char color) {
-	if (x < 0 || x > mapWidth) selectedX = -1;
-	else if (y < 0 || y > mapWidth) selectedY = -1;
+	if (x < 0 || x >= MAP_WIDTH) selectedX = -1;
+	else if (y < 0 || y >= MAP_HEIGHT) selectedY = -1;
 	else {
 		selectedX = x;
 		selectedY = y;
@@ -97,8 +90,8 @@ void Ray_SelectTile(int x, int y, unsigned char color) {
 }
 
 int Ray_HasSeenTile(int x, int y) {
-	if (x < 0 || x > mapWidth) return -1;
-	else if (y < 0 || y > mapWidth) return -1;
+	if (x < 0 || x >= MAP_WIDTH) return -1;
+	else if (y < 0 || y >= MAP_HEIGHT) return -1;
 	return seenMap [x][y];
 }
 
@@ -113,40 +106,40 @@ int Ray_GetNoClip() {
 void Ray_DrawTile(int spr, int tile) {
 	BITMAP *img = engine->GetSpriteGraphic(spr);
 	unsigned char **sprarray = engine->GetRawBitmapSurface(img);
-	for (int y = 0; y < 64; ++y)
-		for (int x = 0; x < 64; ++x)
-			sprarray [y][x] = texture [tile][(texWidth * y) + x];
+	for (int y = 0; y < MAP_HEIGHT; ++y)
+		for (int x = 0; x < MAP_WIDTH; ++x)
+			sprarray[y][x] = texture [tile][(texWidth * y) + x];
 	engine->ReleaseBitmapSurface(img);
 }
 
 void Ray_DrawOntoTile(int spr, int tile) {
 	BITMAP *img = engine->GetSpriteGraphic(spr);
 	unsigned char **sprarray = engine->GetRawBitmapSurface(img);
-	for (int y = 0; y < 64; ++y)
-		for (int x = 0; x < 64; ++x)
+	for (int y = 0; y < MAP_HEIGHT; ++y)
+		for (int x = 0; x < MAP_WIDTH; ++x)
 			texture [tile][(texWidth * y) + x] = sprarray [y][x];
 	engine->ReleaseBitmapSurface(img);
 }
 
 int Ray_GetTileX_At(int x, int y) {
-	if (x < 0 || x > 319  || y < 0 || y > 159) return -1;
+	if (x < 0 || x >= S_WIDTH  || y < 0 || y >= S_HEIGHT) return -1;
 	else return editorMap [x][y] >> 16;
 }
 
 int Ray_GetTileY_At(int x, int y) {
-	if (x < 0 || x > 319  || y < 0 || y > 159) return -1;
+	if (x < 0 || x >= S_WIDTH  || y < 0 || y >= S_HEIGHT) return -1;
 	else return editorMap [x][y] & 0x0000FFFF;
 }
 
 void Ray_SetWallAt(int x, int y, int id) {
-	if (x < 0 || x >= mapWidth) return;
-	if (y < 0 || y >= mapHeight) return;
+	if (x < 0 || x >= MAP_WIDTH) return;
+	if (y < 0 || y >= MAP_HEIGHT) return;
 	worldMap [x][y] = id;
 }
 
 int Ray_GetWallAt(int x, int y) {
-	if (x < 0 || x >= mapWidth) return -1;
-	if (y < 0 || y >= mapHeight) return -1;
+	if (x < 0 || x >= MAP_WIDTH) return -1;
+	if (y < 0 || y >= MAP_HEIGHT) return -1;
 	return worldMap [x][y];
 }
 
@@ -334,7 +327,7 @@ void Ray_SetPlayerAngle(int angle) {
 void LoadHeightMap(int heightmapSlot) {
 	int tempw = engine->GetSpriteWidth(heightmapSlot);
 	int temph = engine->GetSpriteHeight(heightmapSlot);
-	if (tempw != mapWidth || temph != mapHeight) engine->AbortGame("LoadHeightMap: Map sizes are mismatched!");
+	if (tempw != MAP_WIDTH || temph != MAP_HEIGHT) engine->AbortGame("LoadHeightMap: Map sizes are mismatched!");
 	BITMAP *heightmapBm = engine->GetSpriteGraphic(heightmapSlot);
 	if (!heightmapBm) engine->AbortGame("LoadHeightMap: Cannot load sprite into memory.");
 	unsigned char **hmArray = engine->GetRawBitmapSurface(heightmapBm);
@@ -571,29 +564,29 @@ void MakeTextures(int slot) {
 //double ZBuffer[screenWidth][screenHeight];
 
 void Ray_SetFloorAt(int x, int y, int tex) {
-	if (x < 0 || x > mapWidth || y < 0 || y > mapHeight || tex > 511) return;
+	if (x < 0 || x > MAP_WIDTH || y < 0 || y > MAP_HEIGHT || tex > 511) return;
 	else floorMap[x][y] = tex;
 }
 
 void Ray_SetCeilingAt(int x, int y, int tex) {
-	if (x < 0 || x > mapWidth || y < 0 || y > mapHeight || tex > 511) return;
+	if (x < 0 || x > MAP_WIDTH || y < 0 || y > MAP_HEIGHT || tex > 511) return;
 	else ceilingMap[x][y] = tex;
 }
 
 int Ray_GetCeilingAt(int x, int y) {
-	if (x < 0 || x > mapWidth || y < 0 || y > mapHeight) return -1;
+	if (x < 0 || x > MAP_WIDTH || y < 0 || y > MAP_HEIGHT) return -1;
 	else return ceilingMap [x][y];
 }
 
 
 int Ray_GetFloorAt(int x, int y) {
-	if (x < 0 || x > mapWidth || y < 0 || y > mapHeight) return -1;
+	if (x < 0 || x > MAP_WIDTH || y < 0 || y > MAP_HEIGHT) return -1;
 	else return floorMap [x][y];
 }
 
 
 int Ray_GetLightingAt(int x, int y) {
-	if (x < 0 || x > mapWidth || y < 0 || y > mapHeight) return -1;
+	if (x < 0 || x > MAP_WIDTH || y < 0 || y > MAP_HEIGHT) return -1;
 	else {
 		int lighting = 0;
 		if (ceilingMap[x][y] == 0) {
@@ -605,7 +598,7 @@ int Ray_GetLightingAt(int x, int y) {
 }
 
 void Ray_SetLightingAt(int x, int y, unsigned char lighting) {
-	if (x < 0 || x > mapWidth || y < 0 || y > mapHeight) return;
+	if (x < 0 || x > MAP_WIDTH || y < 0 || y > MAP_HEIGHT) return;
 	else {
 		lightMap [x][y] = lighting;
 	}
@@ -624,21 +617,21 @@ int Ray_GetSkyBox(int slot) {
 
 int Ray_GetHotspotAt(int x, int y) {
 	if (!interactionmap) return -1;
-	else if (x > sWidth || x < 0 || y > sHeight || y < 0) return -1;
-	else return interactionmap [x * sWidth + y] & 0x00FF;
+	else if (x > S_WIDTH || x < 0 || y > S_HEIGHT || y < 0) return -1;
+	else return interactionmap [x * S_WIDTH + y] & 0x00FF;
 }
 
 int Ray_GetObjectAt(int x, int y) {
 	if (!interactionmap) return -1;
-	else if (x > sWidth || x < 0 || y > sHeight || y < 0) return -1;
-	else return interactionmap [x * sWidth + y] >> 8;
+	else if (x > S_WIDTH || x < 0 || y > S_HEIGHT || y < 0) return -1;
+	else return interactionmap [x * S_WIDTH + y] >> 8;
 }
 
 FLOAT_RETURN_TYPE Ray_GetDistanceAt(int x, int y) {
 	float falsereturn = -1.0f;
 	if (!ZBuffer) {
 		RETURN_FLOAT(falsereturn);
-	} else if (x > sWidth || x < 0 || y > sHeight || y < 0) {
+	} else if (x > S_WIDTH || x < 0 || y > S_HEIGHT || y < 0) {
 		RETURN_FLOAT(falsereturn);
 	} else {
 
@@ -651,22 +644,22 @@ void Init_Raycaster() {
 	if (ZBuffer)
 		return;
 	//if (!worldMap) return;
-	transcolorbuffer = new unsigned char *[sWidth];
-	transalphabuffer = new unsigned char *[sWidth];
-	transslicedrawn = new bool[sWidth]();
-	transzbuffer = new double*[sWidth];
-	transwallblendmode = new int [mapWidth]();
-	ZBuffer = new double*[sWidth];
-	distTable = new double[sHeight + (sHeight >> 1)];
-	interactionmap = new short[sWidth * sHeight]();
-	for (int y = 0; y < sHeight + (sHeight >> 1); y++) {
-		distTable [y] = sHeight / (2.0 * y - sHeight);
+	transcolorbuffer = new unsigned char *[S_WIDTH];
+	transalphabuffer = new unsigned char *[S_WIDTH];
+	transslicedrawn = new bool[S_WIDTH]();
+	transzbuffer = new double*[S_WIDTH];
+	transwallblendmode = new int [MAP_WIDTH]();
+	ZBuffer = new double*[S_WIDTH];
+	distTable = new double[S_HEIGHT + (S_HEIGHT >> 1)];
+	interactionmap = new short[S_WIDTH * S_HEIGHT]();
+	for (int y = 0; y < S_HEIGHT + (S_HEIGHT >> 1); y++) {
+		distTable [y] = S_HEIGHT / (2.0 * y - S_HEIGHT);
 	}
-	for (int x = 0; x < sWidth; x++) {
-		transcolorbuffer[x] = new unsigned char [sHeight * (mapWidth)]();
-		transalphabuffer[x] = new unsigned char [sHeight * (mapWidth)]();
-		transzbuffer[x] = new double [sHeight * (mapWidth)]();
-		ZBuffer[x] = new double [sHeight]();
+	for (int x = 0; x < S_WIDTH; x++) {
+		transcolorbuffer[x] = new unsigned char [S_HEIGHT * (MAP_WIDTH)]();
+		transalphabuffer[x] = new unsigned char [S_HEIGHT * (MAP_WIDTH)]();
+		transzbuffer[x] = new double [S_HEIGHT * (MAP_WIDTH)]();
+		ZBuffer[x] = new double [S_HEIGHT]();
 		transslicedrawn [x] = false;
 	}
 }
@@ -677,7 +670,7 @@ void Raycast_Render(int slot) {
 	raycastOn = true;
 	double playerrad = atan2(dirY, dirX) + (2.0 * PI);
 	rendering = true;
-	int w = sWidth, h = sHeight;
+	int w = S_WIDTH, h = S_HEIGHT;
 	BITMAP *screen = engine->GetSpriteGraphic(slot);
 	if (!screen) engine->AbortGame("Raycast_Render: No valid sprite to draw on.");
 	engine->GetBitmapDimensions(screen, &w, &h, nullptr);
@@ -704,7 +697,7 @@ void Raycast_Render(int slot) {
 		}
 	}
 	//int multiplier = mapWidth;
-	memset(interactionmap, 0, sizeof(short) * (sHeight * sWidth));
+	memset(interactionmap, 0, sizeof(short) * (S_HEIGHT * S_WIDTH));
 	//start the main loop
 	for (int x = 0; x < w; x++) {
 		transwallcount = 0;
@@ -769,7 +762,7 @@ void Raycast_Render(int slot) {
 			} else if (sideDistX < sideDistY) { // jump to next map square, OR in x-direction, OR in y-direction
 				sideDistX += deltaDistX;
 				mapX += stepX;
-				mapX = abs(mapX) % mapHeight;
+				mapX = abs(mapX) % MAP_HEIGHT;
 				side = 0;
 				if (oppositedrawn && worldMap[mapX][mapY] > 8) {
 					opposite = true;
@@ -787,7 +780,7 @@ void Raycast_Render(int slot) {
 			} else {
 				sideDistY += deltaDistY;
 				mapY += stepY;
-				mapY = abs(mapY) % mapHeight;
+				mapY = abs(mapY) % MAP_HEIGHT;
 				side = 1;
 				if (oppositedrawn && worldMap[mapX][mapY] > 8) {
 					opposite = true;
@@ -848,25 +841,25 @@ void Raycast_Render(int slot) {
 				bool do_ambient = false;
 				if (!opposite) {
 					if (rayDirX > 0 && side == 0) {
-						wall_light = lightMap [(int)mapX - 1 % mapWidth][(int)mapY] << 5;
-						if (ceilingMap [(int)mapX - 1 % mapWidth][(int)mapY] <= 1) do_ambient = true;
-						else if (texture[ceilingMap [(int)mapX - 1 % mapWidth][(int)mapY] - 1][(texWidth * (63 - texX)) + 63] == 0) do_ambient = true;
+						wall_light = lightMap [(int)mapX - 1 % MAP_WIDTH][(int)mapY] << 5;
+						if (ceilingMap [(int)mapX - 1 % MAP_WIDTH][(int)mapY] <= 1) do_ambient = true;
+						else if (texture[ceilingMap [(int)mapX - 1 % MAP_WIDTH][(int)mapY] - 1][(texWidth * (63 - texX)) + 63] == 0) do_ambient = true;
 					}
 					if (rayDirX < 0 && side == 0) {
-						wall_light = lightMap [(int)mapX + 1 % mapWidth][(int)mapY] << 5;
-						if (ceilingMap [(int)mapX + 1 % mapWidth][(int)mapY] <= 1) do_ambient = true;
-						else if (texture[ceilingMap [(int)mapX + 1 % mapWidth][(int)mapY] - 1][(texWidth * texX) + 0] == 0) do_ambient = true;
+						wall_light = lightMap [(int)mapX + 1 % MAP_WIDTH][(int)mapY] << 5;
+						if (ceilingMap [(int)mapX + 1 % MAP_WIDTH][(int)mapY] <= 1) do_ambient = true;
+						else if (texture[ceilingMap [(int)mapX + 1 % MAP_WIDTH][(int)mapY] - 1][(texWidth * texX) + 0] == 0) do_ambient = true;
 
 					}
 					if (rayDirY > 0 && side == 1) {
-						wall_light = lightMap [(int)mapX][(int)mapY - 1 % mapHeight] << 5;
-						if (ceilingMap [(int)mapX][(int)mapY - 1 % mapHeight] <= 1) do_ambient = true;
-						else if (texture[ceilingMap [(int)mapX][(int)mapY - 1 % mapHeight] - 1][(texWidth * 63) + texX] == 0) do_ambient = true;
+						wall_light = lightMap [(int)mapX][(int)mapY - 1 % MAP_HEIGHT] << 5;
+						if (ceilingMap [(int)mapX][(int)mapY - 1 % MAP_HEIGHT] <= 1) do_ambient = true;
+						else if (texture[ceilingMap [(int)mapX][(int)mapY - 1 % MAP_HEIGHT] - 1][(texWidth * 63) + texX] == 0) do_ambient = true;
 					}
 					if (rayDirY < 0 && side == 1) {
-						wall_light = lightMap [(int)mapX][(int)mapY + 1 % mapHeight] << 5;
-						if (ceilingMap [(int)mapX][(int)mapY + 1 % mapHeight] <= 1) do_ambient = true;
-						else if (texture[ceilingMap [(int)mapX][(int)mapY + 1 % mapHeight] - 1][(texWidth * 0) + 63 - texX] == 0) do_ambient = true;
+						wall_light = lightMap [(int)mapX][(int)mapY + 1 % MAP_HEIGHT] << 5;
+						if (ceilingMap [(int)mapX][(int)mapY + 1 % MAP_HEIGHT] <= 1) do_ambient = true;
+						else if (texture[ceilingMap [(int)mapX][(int)mapY + 1 % MAP_HEIGHT] - 1][(texWidth * 0) + 63 - texX] == 0) do_ambient = true;
 					}
 				} else if (opposite) {
 					wall_light = lightMap [(int)mapX][(int)mapY] << 5;
@@ -903,12 +896,12 @@ void Raycast_Render(int slot) {
 								if (ambientpixels) ambientweight++;
 								//SET THE ZBUFFER FOR THE SPRITE CASTING
 								ZBuffer[x][y] = perpWallDist; //perpendicular distance is used
-								interactionmap [x * sWidth + y] = wallData[worldMap[mapX][mapY]].hotspotinteract;
+								interactionmap [x * S_WIDTH + y] = wallData[worldMap[mapX][mapY]].hotspotinteract;
 								editorMap [x][y] = ((short)mapX) << 16 | ((short)mapY);
 							} else {
 								if (transslicedrawn[x] == false) {
-									memset(transcolorbuffer[x], 0, sizeof(unsigned char) * (sHeight * mapWidth));
-									memset(transalphabuffer[x], 0, sizeof(unsigned char) * (sHeight * mapWidth));
+									memset(transcolorbuffer[x], 0, sizeof(unsigned char) * (S_HEIGHT * MAP_WIDTH));
+									memset(transalphabuffer[x], 0, sizeof(unsigned char) * (S_HEIGHT * MAP_WIDTH));
 									//memset (transzbuffer[x],0,sizeof(double)*(sHeight*mapWidth));
 									transslicedrawn[x] = true;
 								}
@@ -940,13 +933,13 @@ void Raycast_Render(int slot) {
 					}
 				}
 				if (alphastripe) {
-					if (transwallcount < mapWidth) {
+					if (transwallcount < MAP_WIDTH) {
 						transwallcount++;
 					}
 					alphastripe = false;
 				}
 				if (opposite) {
-					if (mapX == 0 || mapX == mapWidth || mapY == 0 || mapY == mapHeight) {
+					if (mapX == 0 || mapX == MAP_WIDTH || mapY == 0 || mapY == MAP_HEIGHT) {
 						deeper = false;
 						hit = 0;
 					}
@@ -1024,10 +1017,10 @@ void Raycast_Render(int slot) {
 
 				int floorTexX, floorTexY;
 				int cmapX = (int)currentFloorX;
-				if (cmapX > mapWidth - 1) cmapX = mapWidth - 1;
+				if (cmapX > MAP_WIDTH - 1) cmapX = MAP_WIDTH - 1;
 				if (cmapX < 0) cmapX = 0;
 				int cmapY = (int)currentFloorY;
-				if (cmapY > mapHeight - 1) cmapY = mapHeight - 1;
+				if (cmapY > MAP_HEIGHT - 1) cmapY = MAP_HEIGHT - 1;
 				if (cmapY < 0) cmapY = 0;
 				if (heightMap[cmapX][cmapY] - 1 < 1) continue;
 				int lighting = lightMap [cmapX][cmapY] << 5;
@@ -1060,7 +1053,7 @@ void Raycast_Render(int slot) {
 							if (ny < h && (ZBuffer[x][ny] > currentDist || ZBuffer[x][ny] == 0)) {
 								ZBuffer[x][ny] = currentDist; //perpendicular distance is used
 								buffer[ny][x] = floorcolor;
-								interactionmap [x * sWidth + ny] = 0;
+								interactionmap [x * S_WIDTH + ny] = 0;
 								editorMap [x][ny] = ((short)mapX) << 16 | ((short)mapY);
 							}
 						}
@@ -1074,9 +1067,9 @@ void Raycast_Render(int slot) {
 				double currentFloorY = weight * floorYWall + (1.0 - weight) * posY;
 
 				int floorTexX, floorTexY;
-				int cmapX = (int)currentFloorX % mapWidth;
+				int cmapX = (int)currentFloorX % MAP_WIDTH;
 				if (cmapX < 0) cmapX = 0;
-				int cmapY = (int)currentFloorY % mapHeight;
+				int cmapY = (int)currentFloorY % MAP_HEIGHT;
 				if (cmapY < 0) cmapY = 0;
 				int lighting = lightMap [cmapX][cmapY] << 5;
 				lighting = MIN(255, MAX(0, lighting));
@@ -1108,7 +1101,7 @@ void Raycast_Render(int slot) {
 							if (ZBuffer[x][ny] > currentDist || ZBuffer[x][ny] == 0) {
 								ZBuffer[x][ny] = currentDist; //perpendicular distance is used
 								buffer[ny][x] = floorcolor;
-								interactionmap [x * sWidth + ny] = 0;
+								interactionmap [x * S_WIDTH + ny] = 0;
 								editorMap [x][ny] = ((short)cmapX) << 16 | ((short)cmapY);
 							}
 						}
@@ -1130,8 +1123,8 @@ void Raycast_Render(int slot) {
 					} else ZBuffer[x][h - y] = 999999999999.0;
 					editorMap [x][h - y] = ((short)cmapX) << 16 | ((short)cmapY);
 				}
-				interactionmap [x * sWidth + y] = 0;
-				interactionmap [x * sWidth + (h - y)] = 0;
+				interactionmap [x * S_WIDTH + y] = 0;
+				interactionmap [x * S_WIDTH + (h - y)] = 0;
 				if ((int)cmapX == selectedX && (int)cmapY == selectedY) {
 					if (floorTexX == 0 || floorTexX == 63 || floorTexY == 0 || floorTexY == 63) {
 						buffer[y][x] = selectedColor;
@@ -1295,7 +1288,7 @@ void Raycast_Render(int slot) {
 								buffer[y][stripe] = color; //paint pixel if it isn't black, black is the invisible color
 								ZBuffer[stripe][y] = spriteTransformY[i]; //put the sprite on the zbuffer so we can draw around it.
 							}
-							interactionmap [stripe * sWidth + y] = sprite[spriteOrder[i]].objectinteract << 8;
+							interactionmap [stripe * S_WIDTH + y] = sprite[spriteOrder[i]].objectinteract << 8;
 						}
 					}
 				}
@@ -1310,7 +1303,7 @@ void Raycast_Render(int slot) {
 
 void QuitCleanup() {
 	if (!rendering) {
-		for (int i = 0; i < sWidth; ++i) {
+		for (int i = 0; i < S_WIDTH; ++i) {
 			if (transcolorbuffer[i])delete [] transcolorbuffer[i];
 			if (transalphabuffer[i])delete [] transalphabuffer[i];
 			if (transzbuffer[i])delete [] transzbuffer[i];
@@ -1369,14 +1362,14 @@ void MoveForward() {
 	}
 
 	if (!noclip && !inside) {
-		if (wallData[worldMap[int(newposx)][int(posY)]].solid[texsidex] == false && wallData[worldMap[int(posX)][int(posY)]].solid[inside_texsidex] == false && int(newposx) > -1 && int(newposx) < mapWidth) posX += dirX * moveSpeed;
-		if (wallData[worldMap[int(posX)][int(newposy)]].solid[texsidey] == false && wallData[worldMap[int(posX)][int(posY)]].solid[inside_texsidey] == false && int(newposy) > -1 && int(newposy) < mapHeight) posY += dirY * moveSpeed;
+		if (wallData[worldMap[int(newposx)][int(posY)]].solid[texsidex] == false && wallData[worldMap[int(posX)][int(posY)]].solid[inside_texsidex] == false && int(newposx) > -1 && int(newposx) < MAP_WIDTH) posX += dirX * moveSpeed;
+		if (wallData[worldMap[int(posX)][int(newposy)]].solid[texsidey] == false && wallData[worldMap[int(posX)][int(posY)]].solid[inside_texsidey] == false && int(newposy) > -1 && int(newposy) < MAP_HEIGHT) posY += dirY * moveSpeed;
 	} else if (!noclip && inside) {
 		posX += dirX * moveSpeed;
 		posY += dirY * moveSpeed;
 	} else {
-		if (int(newposx) > -1 && int(newposx) < mapWidth) posX += dirX * moveSpeed;
-		if (int(newposy) > -1 && int(newposy) < mapHeight) posY += dirY * moveSpeed;
+		if (int(newposx) > -1 && int(newposx) < MAP_WIDTH) posX += dirX * moveSpeed;
+		if (int(newposy) > -1 && int(newposy) < MAP_HEIGHT) posY += dirY * moveSpeed;
 	}
 }
 
@@ -1425,14 +1418,14 @@ void MoveBackward() {
 
 	if ((int)posX == (int)newposy && (int)posY == (int)newposy) inside = true;
 	if (!noclip && !inside) {
-		if (wallData[worldMap[int(newposx)][int(posY)]].solid[texsidex] == false && wallData[worldMap[int(posX)][int(posY)]].solid[inside_texsidex] == false && int(newposx) > -1 && int(newposx) < mapWidth) posX -= dirX * moveSpeed;
-		if (wallData[worldMap[int(posX)][int(newposy)]].solid[texsidey] == false && wallData[worldMap[int(posX)][int(posY)]].solid[inside_texsidey] == false && int(newposy) > -1 && int(newposy) < mapHeight) posY -= dirY * moveSpeed;
+		if (wallData[worldMap[int(newposx)][int(posY)]].solid[texsidex] == false && wallData[worldMap[int(posX)][int(posY)]].solid[inside_texsidex] == false && int(newposx) > -1 && int(newposx) < MAP_WIDTH) posX -= dirX * moveSpeed;
+		if (wallData[worldMap[int(posX)][int(newposy)]].solid[texsidey] == false && wallData[worldMap[int(posX)][int(posY)]].solid[inside_texsidey] == false && int(newposy) > -1 && int(newposy) < MAP_HEIGHT) posY -= dirY * moveSpeed;
 	} else if (!noclip && inside) {
 		posX -= dirX * moveSpeed;
 		posY -= dirY * moveSpeed;
 	} else {
-		if (int(newposx) > -1 && int(newposx) < mapWidth) posX -= dirX * moveSpeed;
-		if (int(newposy) > -1 && int(newposy) < mapHeight) posY -= dirY * moveSpeed;
+		if (int(newposx) > -1 && int(newposx) < MAP_WIDTH) posX -= dirX * moveSpeed;
+		if (int(newposy) > -1 && int(newposy) < MAP_HEIGHT) posY -= dirY * moveSpeed;
 	}
 }
 
diff --git a/engines/ags/plugins/ags_pal_render/raycast.h b/engines/ags/plugins/ags_pal_render/raycast.h
index f12947968f..d0bcb7e78f 100644
--- a/engines/ags/plugins/ags_pal_render/raycast.h
+++ b/engines/ags/plugins/ags_pal_render/raycast.h
@@ -29,8 +29,8 @@ namespace AGS3 {
 namespace Plugins {
 namespace AGSPalRender {
 
-#define mapWidth 64
-#define mapHeight 64
+#define MAP_WIDTH 64
+#define MAP_HEIGHT 64
 
 struct Sprite {
 	double x;
@@ -68,14 +68,12 @@ extern double planeX;
 extern double planeY; //the 2d raycaster version of camera plane
 extern double moveSpeed; //the constant value is in squares/second
 extern double rotSpeed; //the constant value is in radians/second
-extern unsigned char worldMap[64][64];
-extern unsigned char lightMap[64][64];
-extern int ceilingMap[64][64];
-extern int floorMap[64][64];
-extern int heightMap[64][64];
-extern unsigned char seenMap[64][64];
-//extern int mapWidth;
-//extern int mapHeight;
+extern unsigned char worldMap[MAP_WIDTH][MAP_HEIGHT];
+extern unsigned char lightMap[MAP_WIDTH][MAP_HEIGHT];
+extern int ceilingMap[MAP_WIDTH][MAP_HEIGHT];
+extern int floorMap[MAP_WIDTH][MAP_HEIGHT];
+extern int heightMap[MAP_WIDTH][MAP_HEIGHT];
+extern unsigned char seenMap[MAP_WIDTH][MAP_HEIGHT];
 extern int textureSlot;
 extern int ambientlight;
 


Commit: cd017a73c7be6df926492df0a306f6fdbc59240e
    https://github.com/scummvm/scummvm/commit/cd017a73c7be6df926492df0a306f6fdbc59240e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-02-16T19:45:02-08:00

Commit Message:
AGS: Revert Standardization of number types

This reverts commit a96422af522485d43e620ffe75ef92ffebd71429.

Changed paths:
    engines/ags/engine/ac/audiochannel.cpp
    engines/ags/engine/ac/audioclip.cpp
    engines/ags/engine/ac/button.cpp
    engines/ags/engine/ac/character.cpp
    engines/ags/engine/ac/character.h
    engines/ags/engine/ac/datetime.cpp
    engines/ags/engine/ac/dialog.cpp
    engines/ags/engine/ac/dialogoptionsrendering.cpp
    engines/ags/engine/ac/display.cpp
    engines/ags/engine/ac/draw_software.cpp
    engines/ags/engine/ac/drawingsurface.cpp
    engines/ags/engine/ac/dynamicsprite.cpp
    engines/ags/engine/ac/dynobj/cc_agsdynamicobject.cpp
    engines/ags/engine/ac/dynobj/cc_agsdynamicobject.h
    engines/ags/engine/ac/dynobj/cc_character.cpp
    engines/ags/engine/ac/dynobj/cc_character.h
    engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp
    engines/ags/engine/ac/dynobj/cc_dynamicarray.h
    engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp
    engines/ags/engine/ac/dynobj/cc_dynamicobject.h
    engines/ags/engine/ac/dynobj/cc_dynamicobject_addr_and_manager.h
    engines/ags/engine/ac/dynobj/managedobjectpool.cpp
    engines/ags/engine/ac/dynobj/managedobjectpool.h
    engines/ags/engine/ac/dynobj/scriptdict.cpp
    engines/ags/engine/ac/dynobj/scriptdict.h
    engines/ags/engine/ac/dynobj/scriptfile.cpp
    engines/ags/engine/ac/dynobj/scriptfile.h
    engines/ags/engine/ac/dynobj/scriptset.cpp
    engines/ags/engine/ac/dynobj/scriptset.h
    engines/ags/engine/ac/dynobj/scriptuserobject.cpp
    engines/ags/engine/ac/dynobj/scriptuserobject.h
    engines/ags/engine/ac/file.cpp
    engines/ags/engine/ac/file.h
    engines/ags/engine/ac/game.cpp
    engines/ags/engine/ac/gamestate.cpp
    engines/ags/engine/ac/gamestate.h
    engines/ags/engine/ac/global_api.cpp
    engines/ags/engine/ac/global_character.cpp
    engines/ags/engine/ac/global_file.cpp
    engines/ags/engine/ac/global_file.h
    engines/ags/engine/ac/gui.cpp
    engines/ags/engine/ac/guicontrol.cpp
    engines/ags/engine/ac/hotspot.cpp
    engines/ags/engine/ac/inventoryitem.cpp
    engines/ags/engine/ac/invwindow.cpp
    engines/ags/engine/ac/label.cpp
    engines/ags/engine/ac/lipsync.h
    engines/ags/engine/ac/listbox.cpp
    engines/ags/engine/ac/math.cpp
    engines/ags/engine/ac/mouse.cpp
    engines/ags/engine/ac/movelist.cpp
    engines/ags/engine/ac/movelist.h
    engines/ags/engine/ac/object.cpp
    engines/ags/engine/ac/overlay.cpp
    engines/ags/engine/ac/parser.cpp
    engines/ags/engine/ac/region.cpp
    engines/ags/engine/ac/richgamemedia.cpp
    engines/ags/engine/ac/room.cpp
    engines/ags/engine/ac/room.h
    engines/ags/engine/ac/roomobject.cpp
    engines/ags/engine/ac/roomobject.h
    engines/ags/engine/ac/roomstatus.cpp
    engines/ags/engine/ac/roomstatus.h
    engines/ags/engine/ac/route_finder_impl_legacy.cpp
    engines/ags/engine/ac/screen.cpp
    engines/ags/engine/ac/screenoverlay.cpp
    engines/ags/engine/ac/screenoverlay.h
    engines/ags/engine/ac/scriptcontainers.cpp
    engines/ags/engine/ac/slider.cpp
    engines/ags/engine/ac/speech.cpp
    engines/ags/engine/ac/statobj/agsstaticobject.cpp
    engines/ags/engine/ac/statobj/agsstaticobject.h
    engines/ags/engine/ac/statobj/staticarray.cpp
    engines/ags/engine/ac/statobj/staticarray.h
    engines/ags/engine/ac/statobj/staticobject.h
    engines/ags/engine/ac/string.cpp
    engines/ags/engine/ac/system.cpp
    engines/ags/engine/ac/textbox.cpp
    engines/ags/engine/ac/viewframe.cpp
    engines/ags/engine/ac/viewport_script.cpp
    engines/ags/engine/ac/walkablearea.cpp
    engines/ags/engine/game/game_init.cpp
    engines/ags/engine/game/savegame_components.cpp
    engines/ags/engine/game/savegame_internal.h
    engines/ags/engine/gfx/gfx_util.cpp
    engines/ags/engine/gfx/gfxdefines.h
    engines/ags/engine/gfx/gfxdriverbase.cpp
    engines/ags/engine/gui/gui_engine.cpp
    engines/ags/engine/main/config.cpp
    engines/ags/engine/main/config.h
    engines/ags/engine/main/engine.cpp
    engines/ags/engine/main/graphics_mode.cpp
    engines/ags/engine/main/graphics_mode.h
    engines/ags/engine/main/update.cpp
    engines/ags/engine/main/update.h
    engines/ags/engine/platform/base/agsplatformdriver.h
    engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp
    engines/ags/engine/script/cc_instance.cpp
    engines/ags/engine/script/cc_instance.h
    engines/ags/engine/script/runtimescriptvalue.cpp
    engines/ags/engine/script/runtimescriptvalue.h
    engines/ags/engine/script/script_api.cpp
    engines/ags/engine/script/script_api.h
    engines/ags/engine/script/script_runtime.cpp
    engines/ags/engine/util/scaling.h
    engines/ags/game_scanner.cpp
    engines/ags/lib/allegro/fixed.h
    engines/ags/lib/allegro/system.cpp
    engines/ags/lib/allegro/system.h
    engines/ags/lib/hq2x/hq2x3x.cpp
    engines/ags/plugins/ags_blend/ags_blend.cpp
    engines/ags/plugins/ags_creditz/ags_creditz.h
    engines/ags/plugins/ags_creditz/ags_creditz2.cpp
    engines/ags/plugins/ags_creditz/ags_creditz2.h
    engines/ags/plugins/ags_creditz/drawing.h
    engines/ags/plugins/ags_flashlight/ags_flashlight.cpp
    engines/ags/plugins/ags_flashlight/ags_flashlight.h
    engines/ags/plugins/ags_pal_render/ags_pal_render.cpp
    engines/ags/plugins/ags_pal_render/pal_render.h
    engines/ags/plugins/ags_pal_render/raycast.cpp
    engines/ags/plugins/ags_parallax/ags_parallax.cpp
    engines/ags/plugins/ags_parallax/ags_parallax.h
    engines/ags/plugins/ags_snow_rain/ags_snow_rain.cpp
    engines/ags/plugins/ags_snow_rain/ags_snow_rain.h
    engines/ags/plugins/ags_sprite_font/sprite_font_renderer.cpp
    engines/ags/plugins/ags_sprite_font/variable_width_sprite_font.cpp
    engines/ags/plugins/agsplugin.cpp
    engines/ags/plugins/agsplugin.h
    engines/ags/plugins/global_plugin.cpp
    engines/ags/shared/ac/characterinfo.h
    engines/ags/shared/ac/dialogtopic.h
    engines/ags/shared/ac/gamesetupstruct.cpp
    engines/ags/shared/ac/gamesetupstructbase.cpp
    engines/ags/shared/ac/gamesetupstructbase.h
    engines/ags/shared/ac/gamestructdefines.h
    engines/ags/shared/ac/inventoryiteminfo.h
    engines/ags/shared/ac/spritecache.cpp
    engines/ags/shared/ac/spritecache.h
    engines/ags/shared/ac/view.h
    engines/ags/shared/api/stream_api.h
    engines/ags/shared/core/asset.h
    engines/ags/shared/core/types.h
    engines/ags/shared/debugging/debugmanager.cpp
    engines/ags/shared/debugging/debugmanager.h
    engines/ags/shared/debugging/out.h
    engines/ags/shared/debugging/outputhandler.h
    engines/ags/shared/font/wfnfont.cpp
    engines/ags/shared/font/wfnfont.h
    engines/ags/shared/font/wfnfontrenderer.cpp
    engines/ags/shared/game/interactions.cpp
    engines/ags/shared/game/main_game_file.cpp
    engines/ags/shared/game/room_file.cpp
    engines/ags/shared/game/room_file_deprecated.cpp
    engines/ags/shared/game/roomstruct.h
    engines/ags/shared/gfx/bitmap.cpp
    engines/ags/shared/gfx/bitmap.h
    engines/ags/shared/gui/guibutton.h
    engines/ags/shared/gui/guiinv.h
    engines/ags/shared/gui/guilabel.h
    engines/ags/shared/gui/guilistbox.h
    engines/ags/shared/gui/guimain.cpp
    engines/ags/shared/gui/guimain.h
    engines/ags/shared/gui/guiobject.h
    engines/ags/shared/gui/guislider.h
    engines/ags/shared/gui/guitextbox.h
    engines/ags/shared/script/cc_script.cpp
    engines/ags/shared/script/cc_script.h
    engines/ags/shared/util/alignedstream.cpp
    engines/ags/shared/util/alignedstream.h
    engines/ags/shared/util/bbop.h
    engines/ags/shared/util/bufferedstream.cpp
    engines/ags/shared/util/bufferedstream.h
    engines/ags/shared/util/compress.cpp
    engines/ags/shared/util/compress.h
    engines/ags/shared/util/datastream.cpp
    engines/ags/shared/util/datastream.h
    engines/ags/shared/util/filestream.cpp
    engines/ags/shared/util/filestream.h
    engines/ags/shared/util/geometry.h
    engines/ags/shared/util/memory.h
    engines/ags/shared/util/mutifilelib.cpp
    engines/ags/shared/util/proxystream.cpp
    engines/ags/shared/util/proxystream.h
    engines/ags/shared/util/stream.cpp
    engines/ags/shared/util/stream.h
    engines/ags/shared/util/string_types.h
    engines/ags/shared/util/version.cpp
    engines/ags/shared/util/version.h
    engines/ags/tests/test_file.cpp
    engines/ags/tests/test_memory.cpp


diff --git a/engines/ags/engine/ac/audiochannel.cpp b/engines/ags/engine/ac/audiochannel.cpp
index 1b6bc61101..5659ead8d6 100644
--- a/engines/ags/engine/ac/audiochannel.cpp
+++ b/engines/ags/engine/ac/audiochannel.cpp
@@ -207,75 +207,75 @@ void AudioChannel_SetRoomLocation(ScriptAudioChannel *channel, int xPos, int yPo
 //=============================================================================
 
 // int | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioChannel, AudioChannel_GetID);
 }
 
 // int | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_GetIsPlaying(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetIsPlaying(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioChannel, AudioChannel_GetIsPlaying);
 }
 
 // int | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_GetPanning(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetPanning(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioChannel, AudioChannel_GetPanning);
 }
 
 // void | ScriptAudioChannel *channel, int newPanning
-RuntimeScriptValue Sc_AudioChannel_SetPanning(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_SetPanning(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptAudioChannel, AudioChannel_SetPanning);
 }
 
 // ScriptAudioClip* | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_GetPlayingClip(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetPlayingClip(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(ScriptAudioChannel, ScriptAudioClip, ccDynamicAudioClip, AudioChannel_GetPlayingClip);
 }
 
 // int | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_GetPosition(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetPosition(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioChannel, AudioChannel_GetPosition);
 }
 
 // int | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_GetPositionMs(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetPositionMs(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioChannel, AudioChannel_GetPositionMs);
 }
 
 // int | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_GetLengthMs(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetLengthMs(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioChannel, AudioChannel_GetLengthMs);
 }
 
 // int | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_GetVolume(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetVolume(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioChannel, AudioChannel_GetVolume);
 }
 
 // int | ScriptAudioChannel *channel, int newVolume
-RuntimeScriptValue Sc_AudioChannel_SetVolume(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_SetVolume(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT(ScriptAudioChannel, AudioChannel_SetVolume);
 }
 
 // void | ScriptAudioChannel *channel
-RuntimeScriptValue Sc_AudioChannel_Stop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_Stop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptAudioChannel, AudioChannel_Stop);
 }
 
 // void | ScriptAudioChannel *channel, int newPosition
-RuntimeScriptValue Sc_AudioChannel_Seek(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_Seek(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptAudioChannel, AudioChannel_Seek);
 }
 
 // void | ScriptAudioChannel *channel, int xPos, int yPos
-RuntimeScriptValue Sc_AudioChannel_SetRoomLocation(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_SetRoomLocation(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptAudioChannel, AudioChannel_SetRoomLocation);
 }
 
-RuntimeScriptValue Sc_AudioChannel_GetSpeed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_GetSpeed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioChannel, AudioChannel_GetSpeed);
 }
 
-RuntimeScriptValue Sc_AudioChannel_SetSpeed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioChannel_SetSpeed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptAudioChannel, AudioChannel_SetSpeed);
 }
 
diff --git a/engines/ags/engine/ac/audioclip.cpp b/engines/ags/engine/ac/audioclip.cpp
index f30d3af14e..19b4c41630 100644
--- a/engines/ags/engine/ac/audioclip.cpp
+++ b/engines/ags/engine/ac/audioclip.cpp
@@ -85,42 +85,42 @@ ScriptAudioChannel *AudioClip_PlayQueued(ScriptAudioClip *clip, int priority, in
 #include "ags/engine/script/script_api.h"
 #include "ags/engine/script/script_runtime.h"
 
-RuntimeScriptValue Sc_AudioClip_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioClip_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioClip, AudioClip_GetID);
 }
 
 // int | ScriptAudioClip *clip
-RuntimeScriptValue Sc_AudioClip_GetFileType(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioClip_GetFileType(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioClip, AudioClip_GetFileType);
 }
 
 // int | ScriptAudioClip *clip
-RuntimeScriptValue Sc_AudioClip_GetType(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioClip_GetType(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioClip, AudioClip_GetType);
 }
 
 // int | ScriptAudioClip *clip
-RuntimeScriptValue Sc_AudioClip_GetIsAvailable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioClip_GetIsAvailable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptAudioClip, AudioClip_GetIsAvailable);
 }
 
 // void | ScriptAudioClip *clip
-RuntimeScriptValue Sc_AudioClip_Stop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioClip_Stop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptAudioClip, AudioClip_Stop);
 }
 
 // ScriptAudioChannel* | ScriptAudioClip *clip, int priority, int repeat
-RuntimeScriptValue Sc_AudioClip_Play(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioClip_Play(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ_PINT2(ScriptAudioClip, ScriptAudioChannel, ccDynamicAudio, AudioClip_Play);
 }
 
 // ScriptAudioChannel* | ScriptAudioClip *clip, int position, int priority, int repeat
-RuntimeScriptValue Sc_AudioClip_PlayFrom(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioClip_PlayFrom(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ_PINT3(ScriptAudioClip, ScriptAudioChannel, ccDynamicAudio, AudioClip_PlayFrom);
 }
 
 // ScriptAudioChannel* | ScriptAudioClip *clip, int priority, int repeat
-RuntimeScriptValue Sc_AudioClip_PlayQueued(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AudioClip_PlayQueued(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ_PINT2(ScriptAudioClip, ScriptAudioChannel, ccDynamicAudio, AudioClip_PlayQueued);
 }
 
diff --git a/engines/ags/engine/ac/button.cpp b/engines/ags/engine/ac/button.cpp
index 06ab3a67bb..e6e1267e95 100644
--- a/engines/ags/engine/ac/button.cpp
+++ b/engines/ags/engine/ac/button.cpp
@@ -309,115 +309,115 @@ void Button_SetTextAlignment(GUIButton *butt, int align) {
 extern ScriptString myScriptStringImpl;
 
 // void | GUIButton *butt, int view, int loop, int speed, int repeat
-RuntimeScriptValue Sc_Button_Animate(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_Animate(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(GUIButton, Button_Animate);
 }
 
 // const char* | GUIButton *butt
-RuntimeScriptValue Sc_Button_GetText_New(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetText_New(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(GUIButton, const char, myScriptStringImpl, Button_GetText_New);
 }
 
 // void | GUIButton *butt, char *buffer
-RuntimeScriptValue Sc_Button_GetText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(GUIButton, Button_GetText, char);
 }
 
 // void | GUIButton *butt, const char *newtx
-RuntimeScriptValue Sc_Button_SetText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_SetText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(GUIButton, Button_SetText, const char);
 }
 
 // void | GUIButton *butt, int newFont
-RuntimeScriptValue Sc_Button_SetFont(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_SetFont(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIButton, Button_SetFont);
 }
 
 // int | GUIButton *butt
-RuntimeScriptValue Sc_Button_GetFont(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetFont(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetFont);
 }
 
 // int | GUIButton *butt
-RuntimeScriptValue Sc_Button_GetClipImage(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetClipImage(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetClipImage);
 }
 
 // void | GUIButton *butt, int newval
-RuntimeScriptValue Sc_Button_SetClipImage(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_SetClipImage(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIButton, Button_SetClipImage);
 }
 
 // int | GUIButton *butt
-RuntimeScriptValue Sc_Button_GetGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetGraphic);
 }
 
 // int | GUIButton *butt
-RuntimeScriptValue Sc_Button_GetMouseOverGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetMouseOverGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetMouseOverGraphic);
 }
 
 // void | GUIButton *guil, int slotn
-RuntimeScriptValue Sc_Button_SetMouseOverGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_SetMouseOverGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIButton, Button_SetMouseOverGraphic);
 }
 
 // int | GUIButton *butt
-RuntimeScriptValue Sc_Button_GetNormalGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetNormalGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetNormalGraphic);
 }
 
 // void | GUIButton *guil, int slotn
-RuntimeScriptValue Sc_Button_SetNormalGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_SetNormalGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIButton, Button_SetNormalGraphic);
 }
 
 // int | GUIButton *butt
-RuntimeScriptValue Sc_Button_GetPushedGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetPushedGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetPushedGraphic);
 }
 
 // void | GUIButton *guil, int slotn
-RuntimeScriptValue Sc_Button_SetPushedGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_SetPushedGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIButton, Button_SetPushedGraphic);
 }
 
 // int | GUIButton *butt
-RuntimeScriptValue Sc_Button_GetTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetTextColor);
 }
 
 // void | GUIButton *butt, int newcol
-RuntimeScriptValue Sc_Button_SetTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_SetTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIButton, Button_SetTextColor);
 }
 
-RuntimeScriptValue Sc_Button_Click(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_Click(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIButton, Button_Click);
 }
 
-RuntimeScriptValue Sc_Button_GetAnimating(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetAnimating(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(GUIButton, Button_IsAnimating);
 }
 
-RuntimeScriptValue Sc_Button_GetTextAlignment(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetTextAlignment(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetTextAlignment);
 }
 
-RuntimeScriptValue Sc_Button_SetTextAlignment(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_SetTextAlignment(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIButton, Button_SetTextAlignment);
 }
 
-RuntimeScriptValue Sc_Button_GetFrame(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetFrame(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetAnimFrame);
 }
 
-RuntimeScriptValue Sc_Button_GetLoop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetLoop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetAnimLoop);
 }
 
-RuntimeScriptValue Sc_Button_GetView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Button_GetView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIButton, Button_GetAnimView);
 }
 
diff --git a/engines/ags/engine/ac/character.cpp b/engines/ags/engine/ac/character.cpp
index 493fdf9acf..7db64928e7 100644
--- a/engines/ags/engine/ac/character.cpp
+++ b/engines/ags/engine/ac/character.cpp
@@ -103,7 +103,7 @@ extern CCInventory ccDynamicInv;
 
 CharacterExtras *charextra;
 CharacterInfo *playerchar;
-int _sc_PlayerCharPtr = 0;
+int32_t _sc_PlayerCharPtr = 0;
 int char_lowest_yp;
 
 // Sierra-style speech settings
@@ -1856,7 +1856,7 @@ int doNextCharMoveStep(CharacterInfo *chi, int &char_index, CharacterExtras *che
 	return 0;
 }
 
-int find_nearest_walkable_area_within(int *xx, int *yy, int range, int step) {
+int find_nearest_walkable_area_within(int32_t *xx, int32_t *yy, int range, int step) {
 	int ex, ey, nearest = 99999, thisis, nearx = 0, neary = 0;
 	int startx = 0, starty = 14;
 	int roomWidthLowRes = room_to_mask_coord(thisroom.Width);
@@ -1914,7 +1914,7 @@ int find_nearest_walkable_area_within(int *xx, int *yy, int range, int step) {
 	return 0;
 }
 
-void find_nearest_walkable_area(int *xx, int *yy) {
+void find_nearest_walkable_area(int32_t *xx, int32_t *yy) {
 
 	int pixValue = thisroom.WalkAreaMask->GetPixel(room_to_mask_coord(xx[0]), room_to_mask_coord(yy[0]));
 	// only fix this code if the game was built with 2.61 or above
@@ -2856,697 +2856,697 @@ PViewport FindNearestViewport(int charid) {
 extern ScriptString myScriptStringImpl;
 
 // void | CharacterInfo *chaa, ScriptInvItem *invi, int addIndex
-RuntimeScriptValue Sc_Character_AddInventory(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_AddInventory(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ_PINT(CharacterInfo, Character_AddInventory, ScriptInvItem);
 }
 
 // void | CharacterInfo *chaa, int x, int y
-RuntimeScriptValue Sc_Character_AddWaypoint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_AddWaypoint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(CharacterInfo, Character_AddWaypoint);
 }
 
 // void | CharacterInfo *chaa, int loop, int delay, int repeat, int blocking, int direction
-RuntimeScriptValue Sc_Character_Animate(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_Animate(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(CharacterInfo, Character_Animate);
 }
 
-RuntimeScriptValue Sc_Character_AnimateFrom(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_AnimateFrom(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT6(CharacterInfo, Character_AnimateFrom);
 }
 
 // void | CharacterInfo *chaa, int room, int x, int y
-RuntimeScriptValue Sc_Character_ChangeRoom(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_ChangeRoom(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(CharacterInfo, Character_ChangeRoom);
 }
 
-RuntimeScriptValue Sc_Character_ChangeRoomSetLoop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_ChangeRoomSetLoop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(CharacterInfo, Character_ChangeRoomSetLoop);
 }
 
 // void | CharacterInfo *chaa, int room, int newPos
-RuntimeScriptValue Sc_Character_ChangeRoomAutoPosition(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_ChangeRoomAutoPosition(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(CharacterInfo, Character_ChangeRoomAutoPosition);
 }
 
 // void | CharacterInfo *chap, int vii
-RuntimeScriptValue Sc_Character_ChangeView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_ChangeView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_ChangeView);
 }
 
 // void | CharacterInfo *char1, CharacterInfo *char2, int blockingStyle
-RuntimeScriptValue Sc_Character_FaceCharacter(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_FaceCharacter(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ_PINT(CharacterInfo, Character_FaceCharacter, CharacterInfo);
 }
 
 // void | CharacterInfo *char1, int direction, int blockingStyle
-RuntimeScriptValue Sc_Character_FaceDirection(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_FaceDirection(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(CharacterInfo, Character_FaceDirection);
 }
 
 // void | CharacterInfo *char1, int xx, int yy, int blockingStyle
-RuntimeScriptValue Sc_Character_FaceLocation(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_FaceLocation(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(CharacterInfo, Character_FaceLocation);
 }
 
 // void | CharacterInfo *char1, ScriptObject *obj, int blockingStyle
-RuntimeScriptValue Sc_Character_FaceObject(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_FaceObject(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ_PINT(CharacterInfo, Character_FaceObject, ScriptObject);
 }
 
 // void | CharacterInfo *chaa, CharacterInfo *tofollow, int distaway, int eagerness
-RuntimeScriptValue Sc_Character_FollowCharacter(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_FollowCharacter(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ_PINT2(CharacterInfo, Character_FollowCharacter, CharacterInfo);
 }
 
 // int (CharacterInfo *chaa, const char *property)
-RuntimeScriptValue Sc_Character_GetProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(CharacterInfo, Character_GetProperty, const char);
 }
 
 // void (CharacterInfo *chaa, const char *property, char *bufer)
-RuntimeScriptValue Sc_Character_GetPropertyText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetPropertyText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ2(CharacterInfo, Character_GetPropertyText, const char, char);
 }
 
 // const char* (CharacterInfo *chaa, const char *property)
-RuntimeScriptValue Sc_Character_GetTextProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetTextProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_POBJ(CharacterInfo, const char, myScriptStringImpl, Character_GetTextProperty, const char);
 }
 
-RuntimeScriptValue Sc_Character_SetProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ_PINT(CharacterInfo, Character_SetProperty, const char);
 }
 
-RuntimeScriptValue Sc_Character_SetTextProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetTextProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ2(CharacterInfo, Character_SetTextProperty, const char, const char);
 }
 
 // int (CharacterInfo *chaa, ScriptInvItem *invi)
-RuntimeScriptValue Sc_Character_HasInventory(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_HasInventory(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(CharacterInfo, Character_HasInventory, ScriptInvItem);
 }
 
 // int (CharacterInfo *char1, CharacterInfo *char2)
-RuntimeScriptValue Sc_Character_IsCollidingWithChar(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_IsCollidingWithChar(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(CharacterInfo, Character_IsCollidingWithChar, CharacterInfo);
 }
 
 // int (CharacterInfo *chin, ScriptObject *objid)
-RuntimeScriptValue Sc_Character_IsCollidingWithObject(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_IsCollidingWithObject(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(CharacterInfo, Character_IsCollidingWithObject, ScriptObject);
 }
 
-RuntimeScriptValue Sc_Character_IsInteractionAvailable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_IsInteractionAvailable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_PINT(CharacterInfo, Character_IsInteractionAvailable);
 }
 
 // void (CharacterInfo *chap, int vii)
-RuntimeScriptValue Sc_Character_LockView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_LockView);
 }
 
 // void (CharacterInfo *chap, int vii, int stopMoving)
-RuntimeScriptValue Sc_Character_LockViewEx(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewEx(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(CharacterInfo, Character_LockViewEx);
 }
 
 // void (CharacterInfo *chap, int vii, int loop, int align)
-RuntimeScriptValue Sc_Character_LockViewAligned_Old(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewAligned_Old(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(CharacterInfo, Character_LockViewAligned_Old);
 }
 
 // void (CharacterInfo *chap, int vii, int loop, int align, int stopMoving)
-RuntimeScriptValue Sc_Character_LockViewAlignedEx_Old(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewAlignedEx_Old(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(CharacterInfo, Character_LockViewAlignedEx_Old);
 }
 
-RuntimeScriptValue Sc_Character_LockViewAligned(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewAligned(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(CharacterInfo, Character_LockViewAligned);
 }
 
-RuntimeScriptValue Sc_Character_LockViewAlignedEx(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewAlignedEx(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(CharacterInfo, Character_LockViewAlignedEx);
 }
 
 // void (CharacterInfo *chaa, int view, int loop, int frame)
-RuntimeScriptValue Sc_Character_LockViewFrame(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewFrame(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(CharacterInfo, Character_LockViewFrame);
 }
 
 // void (CharacterInfo *chaa, int view, int loop, int frame, int stopMoving)
-RuntimeScriptValue Sc_Character_LockViewFrameEx(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewFrameEx(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(CharacterInfo, Character_LockViewFrameEx);
 }
 
 // void (CharacterInfo *chap, int vii, int xoffs, int yoffs)
-RuntimeScriptValue Sc_Character_LockViewOffset(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewOffset(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(CharacterInfo, Character_LockViewOffset);
 }
 
 // void (CharacterInfo *chap, int vii, int xoffs, int yoffs, int stopMoving)
-RuntimeScriptValue Sc_Character_LockViewOffsetEx(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LockViewOffsetEx(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(CharacterInfo, Character_LockViewOffsetEx);
 }
 
 // void (CharacterInfo *chap, ScriptInvItem *invi)
-RuntimeScriptValue Sc_Character_LoseInventory(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_LoseInventory(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(CharacterInfo, Character_LoseInventory, ScriptInvItem);
 }
 
 // void (CharacterInfo *chaa, int x, int y, int blocking, int direct)
-RuntimeScriptValue Sc_Character_Move(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_Move(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(CharacterInfo, Character_Move);
 }
 
 // void (CharacterInfo *chap)
-RuntimeScriptValue Sc_Character_PlaceOnWalkableArea(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_PlaceOnWalkableArea(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(CharacterInfo, Character_PlaceOnWalkableArea);
 }
 
 // void (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_RemoveTint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_RemoveTint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(CharacterInfo, Character_RemoveTint);
 }
 
 // void (CharacterInfo *chaa, int mood)
-RuntimeScriptValue Sc_Character_RunInteraction(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_RunInteraction(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_RunInteraction);
 }
 
 // void (CharacterInfo *chaa, const char *texx, ...)
-RuntimeScriptValue Sc_Character_Say(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_Say(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_SCRIPT_SPRINTF(Character_Say, 1);
 	Character_Say((CharacterInfo *)self, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (CharacterInfo *chaa, int x, int y, int width, const char *texx)
-RuntimeScriptValue Sc_Character_SayAt(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SayAt(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3_POBJ(CharacterInfo, Character_SayAt, const char);
 }
 
 // ScriptOverlay* (CharacterInfo *chaa, const char *texx)
-RuntimeScriptValue Sc_Character_SayBackground(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SayBackground(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJAUTO_POBJ(CharacterInfo, ScriptOverlay, Character_SayBackground, const char);
 }
 
 // void (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_SetAsPlayer(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetAsPlayer(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(CharacterInfo, Character_SetAsPlayer);
 }
 
 // void (CharacterInfo *chaa, int iview, int itime)
-RuntimeScriptValue Sc_Character_SetIdleView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetIdleView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(CharacterInfo, Character_SetIdleView);
 }
 
-RuntimeScriptValue Sc_Character_HasExplicitLight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_HasExplicitLight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(CharacterInfo, Character_GetHasExplicitLight);
 }
 
-RuntimeScriptValue Sc_Character_GetLightLevel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetLightLevel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetLightLevel);
 }
 
-RuntimeScriptValue Sc_Character_SetLightLevel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetLightLevel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetLightLevel);
 }
 
-RuntimeScriptValue Sc_Character_GetTintBlue(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetTintBlue(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetTintBlue);
 }
 
-RuntimeScriptValue Sc_Character_GetTintGreen(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetTintGreen(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetTintGreen);
 }
 
-RuntimeScriptValue Sc_Character_GetTintRed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetTintRed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetTintRed);
 }
 
-RuntimeScriptValue Sc_Character_GetTintSaturation(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetTintSaturation(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetTintSaturation);
 }
 
-RuntimeScriptValue Sc_Character_GetTintLuminance(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetTintLuminance(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetTintLuminance);
 }
 
 /*
-RuntimeScriptValue Sc_Character_SetOption(void *self, const RuntimeScriptValue *params, int param_count)
+RuntimeScriptValue Sc_Character_SetOption(void *self, const RuntimeScriptValue *params, int32_t param_count)
 {
 }
 */
 
 // void (CharacterInfo *chaa, int xspeed, int yspeed)
-RuntimeScriptValue Sc_Character_SetSpeed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetSpeed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(CharacterInfo, Character_SetSpeed);
 }
 
 // void (CharacterInfo *charp)
-RuntimeScriptValue Sc_Character_StopMoving(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_StopMoving(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(CharacterInfo, Character_StopMoving);
 }
 
 // void (CharacterInfo *chaa, const char *texx, ...)
-RuntimeScriptValue Sc_Character_Think(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_Think(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_SCRIPT_SPRINTF(Character_Think, 1);
 	Character_Think((CharacterInfo *)self, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 //void (CharacterInfo *chaa, int red, int green, int blue, int opacity, int luminance)
-RuntimeScriptValue Sc_Character_Tint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_Tint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(CharacterInfo, Character_Tint);
 }
 
 // void (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_UnlockView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_UnlockView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(CharacterInfo, Character_UnlockView);
 }
 
 // void (CharacterInfo *chaa, int stopMoving)
-RuntimeScriptValue Sc_Character_UnlockViewEx(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_UnlockViewEx(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_UnlockViewEx);
 }
 
 // void (CharacterInfo *chaa, int x, int y, int blocking, int direct)
-RuntimeScriptValue Sc_Character_Walk(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_Walk(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(CharacterInfo, Character_Walk);
 }
 
 // void (CharacterInfo *chaa, int xx, int yy, int blocking)
-RuntimeScriptValue Sc_Character_WalkStraight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_WalkStraight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(CharacterInfo, Character_WalkStraight);
 }
 
-RuntimeScriptValue Sc_GetCharacterAtRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetCharacterAtRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(CharacterInfo, ccDynamicCharacter, GetCharacterAtRoom);
 }
 
 // CharacterInfo *(int xx, int yy)
-RuntimeScriptValue Sc_GetCharacterAtScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetCharacterAtScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(CharacterInfo, ccDynamicCharacter, GetCharacterAtScreen);
 }
 
 // ScriptInvItem* (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetActiveInventory(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetActiveInventory(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(CharacterInfo, ScriptInvItem, ccDynamicInv, Character_GetActiveInventory);
 }
 
 // void (CharacterInfo *chaa, ScriptInvItem* iit)
-RuntimeScriptValue Sc_Character_SetActiveInventory(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetActiveInventory(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(CharacterInfo, Character_SetActiveInventory, ScriptInvItem);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetAnimating(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetAnimating(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetAnimating);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetAnimationSpeed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetAnimationSpeed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetAnimationSpeed);
 }
 
 // void (CharacterInfo *chaa, int newval)
-RuntimeScriptValue Sc_Character_SetAnimationSpeed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetAnimationSpeed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetAnimationSpeed);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetBaseline(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetBaseline(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetBaseline);
 }
 
 // void (CharacterInfo *chaa, int basel)
-RuntimeScriptValue Sc_Character_SetBaseline(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetBaseline(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetBaseline);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetBlinkInterval(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetBlinkInterval(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetBlinkInterval);
 }
 
 // void (CharacterInfo *chaa, int interval)
-RuntimeScriptValue Sc_Character_SetBlinkInterval(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetBlinkInterval(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetBlinkInterval);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetBlinkView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetBlinkView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetBlinkView);
 }
 
 // void (CharacterInfo *chaa, int vii)
-RuntimeScriptValue Sc_Character_SetBlinkView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetBlinkView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetBlinkView);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetBlinkWhileThinking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetBlinkWhileThinking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetBlinkWhileThinking);
 }
 
 // void (CharacterInfo *chaa, int yesOrNo)
-RuntimeScriptValue Sc_Character_SetBlinkWhileThinking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetBlinkWhileThinking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetBlinkWhileThinking);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetBlockingHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetBlockingHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetBlockingHeight);
 }
 
 // void (CharacterInfo *chaa, int hit)
-RuntimeScriptValue Sc_Character_SetBlockingHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetBlockingHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetBlockingHeight);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetBlockingWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetBlockingWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetBlockingWidth);
 }
 
 // void (CharacterInfo *chaa, int wid)
-RuntimeScriptValue Sc_Character_SetBlockingWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetBlockingWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetBlockingWidth);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetClickable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetClickable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetClickable);
 }
 
 // void (CharacterInfo *chaa, int clik)
-RuntimeScriptValue Sc_Character_SetClickable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetClickable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetClickable);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetDiagonalWalking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetDiagonalWalking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetDiagonalWalking);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetDiagonalWalking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetDiagonalWalking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetDiagonalWalking);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetFrame(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetFrame(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetFrame);
 }
 
 // void (CharacterInfo *chaa, int newval)
-RuntimeScriptValue Sc_Character_SetFrame(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetFrame(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetFrame);
 }
 
-RuntimeScriptValue Sc_Character_GetHasExplicitTint_Old(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetHasExplicitTint_Old(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetHasExplicitTint_Old);
 }
 
-RuntimeScriptValue Sc_Character_GetHasExplicitTint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetHasExplicitTint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetHasExplicitTint);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetID);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetIdleView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetIdleView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetIdleView);
 }
 
 // int (CharacterInfo *chaa, int index)
-RuntimeScriptValue Sc_Character_GetIInventoryQuantity(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetIInventoryQuantity(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT(CharacterInfo, Character_GetIInventoryQuantity);
 }
 
 // void (CharacterInfo *chaa, int index, int quant)
-RuntimeScriptValue Sc_Character_SetIInventoryQuantity(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetIInventoryQuantity(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(CharacterInfo, Character_SetIInventoryQuantity);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetIgnoreLighting(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetIgnoreLighting(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetIgnoreLighting);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetIgnoreLighting(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetIgnoreLighting(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetIgnoreLighting);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetIgnoreScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetIgnoreScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetIgnoreScaling);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetIgnoreScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetIgnoreScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetIgnoreScaling);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetIgnoreWalkbehinds(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetIgnoreWalkbehinds(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetIgnoreWalkbehinds);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetIgnoreWalkbehinds(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetIgnoreWalkbehinds(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetIgnoreWalkbehinds);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetLoop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetLoop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetLoop);
 }
 
 // void (CharacterInfo *chaa, int newval)
-RuntimeScriptValue Sc_Character_SetLoop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetLoop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetLoop);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetManualScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetManualScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetManualScaling);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetMovementLinkedToAnimation(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetMovementLinkedToAnimation(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetMovementLinkedToAnimation);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetMovementLinkedToAnimation(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetMovementLinkedToAnimation(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetMovementLinkedToAnimation);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetMoving(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetMoving(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetMoving);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetDestinationX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetDestinationX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetDestinationX);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetDestinationY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetDestinationY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetDestinationY);
 }
 
 // const char* (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetName(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetName(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(CharacterInfo, const char, myScriptStringImpl, Character_GetName);
 }
 
 // void (CharacterInfo *chaa, const char *newName)
-RuntimeScriptValue Sc_Character_SetName(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetName(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(CharacterInfo, Character_SetName, const char);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetNormalView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetNormalView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetNormalView);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetPreviousRoom(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetPreviousRoom(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetPreviousRoom);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetRoom(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetRoom(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetRoom);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetScaleMoveSpeed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetScaleMoveSpeed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetScaleMoveSpeed);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetScaleMoveSpeed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetScaleMoveSpeed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetScaleMoveSpeed);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetScaleVolume(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetScaleVolume(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetScaleVolume);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetScaleVolume(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetScaleVolume(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetScaleVolume);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetScaling);
 }
 
 // void (CharacterInfo *chaa, int zoomlevel)
-RuntimeScriptValue Sc_Character_SetScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetScaling);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetSolid(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetSolid(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetSolid);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetSolid(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetSolid(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetSolid);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetSpeaking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetSpeaking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetSpeaking);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetSpeakingFrame(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetSpeakingFrame(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetSpeakingFrame);
 }
 
 // int (CharacterInfo *cha)
-RuntimeScriptValue Sc_GetCharacterSpeechAnimationDelay(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetCharacterSpeechAnimationDelay(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, GetCharacterSpeechAnimationDelay);
 }
 
 // void (CharacterInfo *chaa, int newDelay)
-RuntimeScriptValue Sc_Character_SetSpeechAnimationDelay(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetSpeechAnimationDelay(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetSpeechAnimationDelay);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetSpeechColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetSpeechColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetSpeechColor);
 }
 
 // void (CharacterInfo *chaa, int ncol)
-RuntimeScriptValue Sc_Character_SetSpeechColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetSpeechColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetSpeechColor);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetSpeechView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetSpeechView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetSpeechView);
 }
 
 // void (CharacterInfo *chaa, int vii)
-RuntimeScriptValue Sc_Character_SetSpeechView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetSpeechView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetSpeechView);
 }
 
-RuntimeScriptValue Sc_Character_GetThinking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetThinking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(CharacterInfo, Character_GetThinking);
 }
 
-RuntimeScriptValue Sc_Character_GetThinkingFrame(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetThinkingFrame(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetThinkingFrame);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetThinkView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetThinkView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetThinkView);
 }
 
 // void (CharacterInfo *chaa, int vii)
-RuntimeScriptValue Sc_Character_SetThinkView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetThinkView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetThinkView);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetTransparency(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetTransparency(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetTransparency);
 }
 
 // void (CharacterInfo *chaa, int trans)
-RuntimeScriptValue Sc_Character_SetTransparency(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetTransparency(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetTransparency);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetTurnBeforeWalking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetTurnBeforeWalking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetTurnBeforeWalking);
 }
 
 // void (CharacterInfo *chaa, int yesorno)
-RuntimeScriptValue Sc_Character_SetTurnBeforeWalking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetTurnBeforeWalking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetTurnBeforeWalking);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetView);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetWalkSpeedX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetWalkSpeedX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetWalkSpeedX);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetWalkSpeedY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetWalkSpeedY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetWalkSpeedY);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetX);
 }
 
 // void (CharacterInfo *chaa, int newval)
-RuntimeScriptValue Sc_Character_SetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetX);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetY);
 }
 
 // void (CharacterInfo *chaa, int newval)
-RuntimeScriptValue Sc_Character_SetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetY);
 }
 
 // int (CharacterInfo *chaa)
-RuntimeScriptValue Sc_Character_GetZ(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_GetZ(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(CharacterInfo, Character_GetZ);
 }
 
 // void (CharacterInfo *chaa, int newval)
-RuntimeScriptValue Sc_Character_SetZ(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Character_SetZ(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(CharacterInfo, Character_SetZ);
 }
 
diff --git a/engines/ags/engine/ac/character.h b/engines/ags/engine/ac/character.h
index d70eab4679..41aba50dc2 100644
--- a/engines/ags/engine/ac/character.h
+++ b/engines/ags/engine/ac/character.h
@@ -184,8 +184,8 @@ void fix_player_sprite(MoveList *cmls, CharacterInfo *chinf);
 // Check whether two characters have walked into each other
 int  has_hit_another_character(int sourceChar);
 int  doNextCharMoveStep(CharacterInfo *chi, int &char_index, CharacterExtras *chex);
-int  find_nearest_walkable_area_within(int *xx, int *yy, int range, int step);
-void find_nearest_walkable_area(int *xx, int *yy);
+int  find_nearest_walkable_area_within(int32_t *xx, int32_t *yy, int range, int step);
+void find_nearest_walkable_area(int32_t *xx, int32_t *yy);
 void walk_character(int chac, int tox, int toy, int ignwal, bool autoWalkAnims);
 void FindReasonableLoopForCharacter(CharacterInfo *chap);
 void walk_or_move_character(CharacterInfo *chaa, int x, int y, int blocking, int direct, bool isWalk);
@@ -222,7 +222,7 @@ PViewport FindNearestViewport(int charid);
 extern CharacterInfo *playerchar;
 extern CharacterExtras *charextra;
 extern MoveList *mls;
-extern int _sc_PlayerCharPtr;
+extern int32_t _sc_PlayerCharPtr;
 
 // order of loops to turn character in circle from down to down
 extern int turnlooporder[8];
diff --git a/engines/ags/engine/ac/datetime.cpp b/engines/ags/engine/ac/datetime.cpp
index e2d94cd95e..fd07d3050a 100644
--- a/engines/ags/engine/ac/datetime.cpp
+++ b/engines/ags/engine/ac/datetime.cpp
@@ -80,42 +80,42 @@ int DateTime_GetRawTime(ScriptDateTime *sdt) {
 //=============================================================================
 
 // ScriptDateTime* ()
-RuntimeScriptValue Sc_DateTime_Now(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DateTime_Now(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO(ScriptDateTime, DateTime_Now);
 }
 
 // int (ScriptDateTime *sdt)
-RuntimeScriptValue Sc_DateTime_GetYear(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DateTime_GetYear(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDateTime, DateTime_GetYear);
 }
 
 // int (ScriptDateTime *sdt)
-RuntimeScriptValue Sc_DateTime_GetMonth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DateTime_GetMonth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDateTime, DateTime_GetMonth);
 }
 
 // int (ScriptDateTime *sdt)
-RuntimeScriptValue Sc_DateTime_GetDayOfMonth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DateTime_GetDayOfMonth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDateTime, DateTime_GetDayOfMonth);
 }
 
 // int (ScriptDateTime *sdt)
-RuntimeScriptValue Sc_DateTime_GetHour(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DateTime_GetHour(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDateTime, DateTime_GetHour);
 }
 
 // int (ScriptDateTime *sdt)
-RuntimeScriptValue Sc_DateTime_GetMinute(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DateTime_GetMinute(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDateTime, DateTime_GetMinute);
 }
 
 // int (ScriptDateTime *sdt)
-RuntimeScriptValue Sc_DateTime_GetSecond(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DateTime_GetSecond(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDateTime, DateTime_GetSecond);
 }
 
 // int (ScriptDateTime *sdt)
-RuntimeScriptValue Sc_DateTime_GetRawTime(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DateTime_GetRawTime(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDateTime, DateTime_GetRawTime);
 }
 
diff --git a/engines/ags/engine/ac/dialog.cpp b/engines/ags/engine/ac/dialog.cpp
index 10e44ea349..aa7fd563c5 100644
--- a/engines/ags/engine/ac/dialog.cpp
+++ b/engines/ags/engine/ac/dialog.cpp
@@ -1032,7 +1032,7 @@ int show_dialog_options(int _dlgnum, int sayChosenOption, bool _runGameLoopsInBa
 	int dialog_choice = DlgOpt.chose;
 	if (dialog_choice != CHOSE_TEXTPARSER) {
 		DialogTopic *dialog_topic = DlgOpt.dtop;
-		int &option_flags = dialog_topic->optionflags[dialog_choice];
+		int32_t &option_flags = dialog_topic->optionflags[dialog_choice];
 		const char *option_name = DlgOpt.dtop->optionnames[dialog_choice];
 
 		option_flags |= DFLG_HASBEENCHOSEN;
@@ -1160,51 +1160,51 @@ void do_conversation(int dlgnum) {
 extern ScriptString myScriptStringImpl;
 
 // int (ScriptDialog *sd)
-RuntimeScriptValue Sc_Dialog_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialog, Dialog_GetID);
 }
 
 // int (ScriptDialog *sd)
-RuntimeScriptValue Sc_Dialog_GetOptionCount(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_GetOptionCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialog, Dialog_GetOptionCount);
 }
 
 // int (ScriptDialog *sd)
-RuntimeScriptValue Sc_Dialog_GetShowTextParser(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_GetShowTextParser(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialog, Dialog_GetShowTextParser);
 }
 
 // int (ScriptDialog *sd, int sayChosenOption)
-RuntimeScriptValue Sc_Dialog_DisplayOptions(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_DisplayOptions(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT(ScriptDialog, Dialog_DisplayOptions);
 }
 
 // int (ScriptDialog *sd, int option)
-RuntimeScriptValue Sc_Dialog_GetOptionState(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_GetOptionState(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT(ScriptDialog, Dialog_GetOptionState);
 }
 
 // const char* (ScriptDialog *sd, int option)
-RuntimeScriptValue Sc_Dialog_GetOptionText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_GetOptionText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_PINT(ScriptDialog, const char, myScriptStringImpl, Dialog_GetOptionText);
 }
 
 // int (ScriptDialog *sd, int option)
-RuntimeScriptValue Sc_Dialog_HasOptionBeenChosen(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_HasOptionBeenChosen(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT(ScriptDialog, Dialog_HasOptionBeenChosen);
 }
 
-RuntimeScriptValue Sc_Dialog_SetHasOptionBeenChosen(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_SetHasOptionBeenChosen(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT_PBOOL(ScriptDialog, Dialog_SetHasOptionBeenChosen);
 }
 
 // void (ScriptDialog *sd, int option, int newState)
-RuntimeScriptValue Sc_Dialog_SetOptionState(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_SetOptionState(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptDialog, Dialog_SetOptionState);
 }
 
 // void (ScriptDialog *sd)
-RuntimeScriptValue Sc_Dialog_Start(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dialog_Start(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptDialog, Dialog_Start);
 }
 
diff --git a/engines/ags/engine/ac/dialogoptionsrendering.cpp b/engines/ags/engine/ac/dialogoptionsrendering.cpp
index 481398e3ca..059d6aa07e 100644
--- a/engines/ags/engine/ac/dialogoptionsrendering.cpp
+++ b/engines/ags/engine/ac/dialogoptionsrendering.cpp
@@ -143,109 +143,109 @@ void DialogOptionsRendering_SetActiveOptionID(ScriptDialogOptionsRendering *dlgO
 #include "ags/engine/script/script_api.h"
 #include "ags/engine/script/script_runtime.h"
 
-RuntimeScriptValue Sc_DialogOptionsRendering_Update(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_Update(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptDialogOptionsRendering, DialogOptionsRendering_Update);
 }
 
-RuntimeScriptValue Sc_DialogOptionsRendering_RunActiveOption(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_RunActiveOption(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(ScriptDialogOptionsRendering, DialogOptionsRendering_RunActiveOption);
 }
 
 // int (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetActiveOptionID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetActiveOptionID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetActiveOptionID);
 }
 
 // void (ScriptDialogOptionsRendering *dlgOptRender, int activeOptionID)
-RuntimeScriptValue Sc_DialogOptionsRendering_SetActiveOptionID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetActiveOptionID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDialogOptionsRendering, DialogOptionsRendering_SetActiveOptionID);
 }
 
 // ScriptDialog* (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetDialogToRender(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetDialogToRender(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(ScriptDialogOptionsRendering, ScriptDialog, ccDynamicDialog, DialogOptionsRendering_GetDialogToRender);
 }
 
 // int (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetHeight);
 }
 
 // void (ScriptDialogOptionsRendering *dlgOptRender, int newHeight)
-RuntimeScriptValue Sc_DialogOptionsRendering_SetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDialogOptionsRendering, DialogOptionsRendering_SetHeight);
 }
 
 // int (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetParserTextboxX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetParserTextboxX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetParserTextboxX);
 }
 
 // void (ScriptDialogOptionsRendering *dlgOptRender, int newX)
-RuntimeScriptValue Sc_DialogOptionsRendering_SetParserTextboxX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetParserTextboxX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDialogOptionsRendering, DialogOptionsRendering_SetParserTextboxX);
 }
 
 // int (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetParserTextboxY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetParserTextboxY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetParserTextboxY);
 }
 
 // void (ScriptDialogOptionsRendering *dlgOptRender, int newY)
-RuntimeScriptValue Sc_DialogOptionsRendering_SetParserTextboxY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetParserTextboxY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDialogOptionsRendering, DialogOptionsRendering_SetParserTextboxY);
 }
 
 // int (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetParserTextboxWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetParserTextboxWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetParserTextboxWidth);
 }
 
 // void (ScriptDialogOptionsRendering *dlgOptRender, int newWidth)
-RuntimeScriptValue Sc_DialogOptionsRendering_SetParserTextboxWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetParserTextboxWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDialogOptionsRendering, DialogOptionsRendering_SetParserTextboxWidth);
 }
 
 // ScriptDrawingSurface* (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetSurface(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetSurface(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJAUTO(ScriptDialogOptionsRendering, ScriptDrawingSurface, DialogOptionsRendering_GetSurface);
 }
 
 // int (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetWidth);
 }
 
 // void (ScriptDialogOptionsRendering *dlgOptRender, int newWidth)
-RuntimeScriptValue Sc_DialogOptionsRendering_SetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDialogOptionsRendering, DialogOptionsRendering_SetWidth);
 }
 
 // int (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetX);
 }
 
 // void (ScriptDialogOptionsRendering *dlgOptRender, int newX)
-RuntimeScriptValue Sc_DialogOptionsRendering_SetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDialogOptionsRendering, DialogOptionsRendering_SetX);
 }
 
 // int (ScriptDialogOptionsRendering *dlgOptRender)
-RuntimeScriptValue Sc_DialogOptionsRendering_GetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetY);
 }
 
 // void (ScriptDialogOptionsRendering *dlgOptRender, int newY)
-RuntimeScriptValue Sc_DialogOptionsRendering_SetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDialogOptionsRendering, DialogOptionsRendering_SetY);
 }
 
-RuntimeScriptValue Sc_DialogOptionsRendering_GetHasAlphaChannel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_GetHasAlphaChannel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDialogOptionsRendering, DialogOptionsRendering_GetHasAlphaChannel);
 }
 
-RuntimeScriptValue Sc_DialogOptionsRendering_SetHasAlphaChannel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DialogOptionsRendering_SetHasAlphaChannel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PBOOL(ScriptDialogOptionsRendering, DialogOptionsRendering_SetHasAlphaChannel);
 }
 
diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index e312f3420b..9726ad63e3 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -451,9 +451,9 @@ void wouttextxy_AutoOutline_Semitransparent2Opaque(Bitmap *map) {
 	size_t const height = map->GetHeight();
 
 	for (size_t y = 0; y < height; y++) {
-		int *sc_line = reinterpret_cast<int *>(map->GetScanLineForWriting(y));
+		int32 *sc_line = reinterpret_cast<int32 *>(map->GetScanLineForWriting(y));
 		for (size_t x = 0; x < width; x++) {
-			int &px = sc_line[x];
+			int32 &px = sc_line[x];
 			int const transparency = geta(px);
 			if (0 < transparency && transparency < 255)
 				px = makeacol32(
@@ -467,7 +467,7 @@ void wouttextxy_AutoOutline_Semitransparent2Opaque(Bitmap *map) {
 #endif
 
 // Draw outline that is calculated from the text font, not derived from an outline font
-void wouttextxy_AutoOutline(Bitmap *ds, size_t font, int color, const char *texx, int &xxp, int &yyp) {
+void wouttextxy_AutoOutline(Bitmap *ds, size_t font, int32_t color, const char *texx, int &xxp, int &yyp) {
 	int const thickness = game.fonts.at(font).AutoOutlineThickness;
 	auto const style = game.fonts.at(font).AutoOutlineStyle;
 	if (thickness <= 0)
diff --git a/engines/ags/engine/ac/draw_software.cpp b/engines/ags/engine/ac/draw_software.cpp
index 579458f28a..67eb7450db 100644
--- a/engines/ags/engine/ac/draw_software.cpp
+++ b/engines/ags/engine/ac/draw_software.cpp
@@ -375,8 +375,8 @@ void update_invalid_region(Bitmap *ds, Bitmap *src, const DirtyRects &rects, boo
 			const int bypp = src->GetBPP();
 			// do the fast memory copy
 			for (int i = 0; i < surf_height; i++) {
-				const uint8 *src_scanline = src->GetScanLine(i + src_y);
-				uint8 *dst_scanline = ds->GetScanLineForWriting(i + dst_y);
+				const uint8_t *src_scanline = src->GetScanLine(i + src_y);
+				uint8_t *dst_scanline = ds->GetScanLineForWriting(i + dst_y);
 				const IRRow &dirty_row = dirtyRow[i];
 				for (int k = 0; k < dirty_row.numSpans; k++) {
 					int tx1 = dirty_row.span[k].x1;
diff --git a/engines/ags/engine/ac/drawingsurface.cpp b/engines/ags/engine/ac/drawingsurface.cpp
index 09790ed0f3..13b86da26a 100644
--- a/engines/ags/engine/ac/drawingsurface.cpp
+++ b/engines/ags/engine/ac/drawingsurface.cpp
@@ -453,123 +453,123 @@ int DrawingSurface_GetPixel(ScriptDrawingSurface *sds, int x, int y) {
 //=============================================================================
 
 // void (ScriptDrawingSurface *sds, int colour)
-RuntimeScriptValue Sc_DrawingSurface_Clear(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_Clear(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDrawingSurface, DrawingSurface_Clear);
 }
 
 // ScriptDrawingSurface* (ScriptDrawingSurface *sds)
-RuntimeScriptValue Sc_DrawingSurface_CreateCopy(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_CreateCopy(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJAUTO(ScriptDrawingSurface, ScriptDrawingSurface, DrawingSurface_CreateCopy);
 }
 
 // void (ScriptDrawingSurface *sds, int x, int y, int radius)
-RuntimeScriptValue Sc_DrawingSurface_DrawCircle(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawCircle(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(ScriptDrawingSurface, DrawingSurface_DrawCircle);
 }
 
 // void (ScriptDrawingSurface* sds, int xx, int yy, int slot, int trans, int width, int height)
-RuntimeScriptValue Sc_DrawingSurface_DrawImage_6(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawImage_6(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT6(ScriptDrawingSurface, DrawingSurface_DrawImage);
 }
 
-RuntimeScriptValue Sc_DrawingSurface_DrawImage(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawImage(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_OBJ_PARAM_COUNT(METHOD, 10);
 	DrawingSurface_DrawImageEx((ScriptDrawingSurface *)self, params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue, params[5].IValue,
 		params[6].IValue, params[7].IValue, params[8].IValue, params[9].IValue);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (ScriptDrawingSurface *sds, int fromx, int fromy, int tox, int toy, int thickness)
-RuntimeScriptValue Sc_DrawingSurface_DrawLine(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawLine(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(ScriptDrawingSurface, DrawingSurface_DrawLine);
 }
 
 // void (ScriptDrawingSurface *sds, int xx, int yy, int wid, int font, int msgm)
-RuntimeScriptValue Sc_DrawingSurface_DrawMessageWrapped(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawMessageWrapped(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(ScriptDrawingSurface, DrawingSurface_DrawMessageWrapped);
 }
 
 // void (ScriptDrawingSurface *sds, int x, int y)
-RuntimeScriptValue Sc_DrawingSurface_DrawPixel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawPixel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptDrawingSurface, DrawingSurface_DrawPixel);
 }
 
 // void (ScriptDrawingSurface *sds, int x1, int y1, int x2, int y2)
-RuntimeScriptValue Sc_DrawingSurface_DrawRectangle(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawRectangle(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(ScriptDrawingSurface, DrawingSurface_DrawRectangle);
 }
 
 // void (ScriptDrawingSurface *sds, int xx, int yy, int font, const char* texx, ...)
-RuntimeScriptValue Sc_DrawingSurface_DrawString(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawString(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_SCRIPT_SPRINTF(DrawingSurface_DrawString, 4);
 	DrawingSurface_DrawString((ScriptDrawingSurface *)self, params[0].IValue, params[1].IValue, params[2].IValue, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (ScriptDrawingSurface *sds, int xx, int yy, int wid, int font, int alignment, const char *msg)
-RuntimeScriptValue Sc_DrawingSurface_DrawStringWrapped_Old(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawStringWrapped_Old(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5_POBJ(ScriptDrawingSurface, DrawingSurface_DrawStringWrapped_Old, const char);
 }
 
-RuntimeScriptValue Sc_DrawingSurface_DrawStringWrapped(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawStringWrapped(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5_POBJ(ScriptDrawingSurface, DrawingSurface_DrawStringWrapped, const char);
 }
 
 // void (ScriptDrawingSurface* target, ScriptDrawingSurface* source, int translev)
-RuntimeScriptValue Sc_DrawingSurface_DrawSurface_2(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawSurface_2(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ_PINT(ScriptDrawingSurface, DrawingSurface_DrawSurface, ScriptDrawingSurface);
 }
 
-RuntimeScriptValue Sc_DrawingSurface_DrawSurface(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawSurface(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_OBJ_PARAM_COUNT(METHOD, 10);
 	DrawingSurface_DrawSurfaceEx((ScriptDrawingSurface *)self, (ScriptDrawingSurface *)params[0].Ptr,
 		params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue, params[5].IValue,
 		params[6].IValue, params[7].IValue, params[8].IValue, params[9].IValue);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (ScriptDrawingSurface *sds, int x1, int y1, int x2, int y2, int x3, int y3)
-RuntimeScriptValue Sc_DrawingSurface_DrawTriangle(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_DrawTriangle(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT6(ScriptDrawingSurface, DrawingSurface_DrawTriangle);
 }
 
 // int (ScriptDrawingSurface *sds, int x, int y)
-RuntimeScriptValue Sc_DrawingSurface_GetPixel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_GetPixel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT2(ScriptDrawingSurface, DrawingSurface_GetPixel);
 }
 
 // void (ScriptDrawingSurface* sds)
-RuntimeScriptValue Sc_DrawingSurface_Release(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_Release(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptDrawingSurface, DrawingSurface_Release);
 }
 
 // int (ScriptDrawingSurface *sds)
-RuntimeScriptValue Sc_DrawingSurface_GetDrawingColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_GetDrawingColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDrawingSurface, DrawingSurface_GetDrawingColor);
 }
 
 // void (ScriptDrawingSurface *sds, int newColour)
-RuntimeScriptValue Sc_DrawingSurface_SetDrawingColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_SetDrawingColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDrawingSurface, DrawingSurface_SetDrawingColor);
 }
 
 // int (ScriptDrawingSurface *sds)
-RuntimeScriptValue Sc_DrawingSurface_GetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_GetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDrawingSurface, DrawingSurface_GetHeight);
 }
 
 // int (ScriptDrawingSurface *sds)
-RuntimeScriptValue Sc_DrawingSurface_GetUseHighResCoordinates(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_GetUseHighResCoordinates(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDrawingSurface, DrawingSurface_GetUseHighResCoordinates);
 }
 
 // void (ScriptDrawingSurface *sds, int highRes)
-RuntimeScriptValue Sc_DrawingSurface_SetUseHighResCoordinates(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_SetUseHighResCoordinates(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDrawingSurface, DrawingSurface_SetUseHighResCoordinates);
 }
 
 // int (ScriptDrawingSurface *sds)
-RuntimeScriptValue Sc_DrawingSurface_GetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DrawingSurface_GetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDrawingSurface, DrawingSurface_GetWidth);
 }
 
diff --git a/engines/ags/engine/ac/dynamicsprite.cpp b/engines/ags/engine/ac/dynamicsprite.cpp
index 34504ccdef..1cafa99166 100644
--- a/engines/ags/engine/ac/dynamicsprite.cpp
+++ b/engines/ags/engine/ac/dynamicsprite.cpp
@@ -509,112 +509,112 @@ void free_dynamic_sprite(int gotSlot) {
 //=============================================================================
 
 // void (ScriptDynamicSprite *sds, int width, int height, int x, int y)
-RuntimeScriptValue Sc_DynamicSprite_ChangeCanvasSize(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_ChangeCanvasSize(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(ScriptDynamicSprite, DynamicSprite_ChangeCanvasSize);
 }
 
 // void (ScriptDynamicSprite *sds, int sourceSprite)
-RuntimeScriptValue Sc_DynamicSprite_CopyTransparencyMask(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_CopyTransparencyMask(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDynamicSprite, DynamicSprite_CopyTransparencyMask);
 }
 
 // void (ScriptDynamicSprite *sds, int x1, int y1, int width, int height)
-RuntimeScriptValue Sc_DynamicSprite_Crop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_Crop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(ScriptDynamicSprite, DynamicSprite_Crop);
 }
 
 // void (ScriptDynamicSprite *sds)
-RuntimeScriptValue Sc_DynamicSprite_Delete(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_Delete(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptDynamicSprite, DynamicSprite_Delete);
 }
 
 // void (ScriptDynamicSprite *sds, int direction)
-RuntimeScriptValue Sc_DynamicSprite_Flip(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_Flip(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptDynamicSprite, DynamicSprite_Flip);
 }
 
 // ScriptDrawingSurface* (ScriptDynamicSprite *dss)
-RuntimeScriptValue Sc_DynamicSprite_GetDrawingSurface(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_GetDrawingSurface(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJAUTO(ScriptDynamicSprite, ScriptDrawingSurface, DynamicSprite_GetDrawingSurface);
 }
 
 // void (ScriptDynamicSprite *sds, int width, int height)
-RuntimeScriptValue Sc_DynamicSprite_Resize(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_Resize(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptDynamicSprite, DynamicSprite_Resize);
 }
 
 // void (ScriptDynamicSprite *sds, int angle, int width, int height)
-RuntimeScriptValue Sc_DynamicSprite_Rotate(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_Rotate(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(ScriptDynamicSprite, DynamicSprite_Rotate);
 }
 
 // int (ScriptDynamicSprite *sds, const char* namm)
-RuntimeScriptValue Sc_DynamicSprite_SaveToFile(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_SaveToFile(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(ScriptDynamicSprite, DynamicSprite_SaveToFile, const char);
 }
 
 // void (ScriptDynamicSprite *sds, int red, int green, int blue, int saturation, int luminance)
-RuntimeScriptValue Sc_DynamicSprite_Tint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_Tint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(ScriptDynamicSprite, DynamicSprite_Tint);
 }
 
 // int (ScriptDynamicSprite *sds)
-RuntimeScriptValue Sc_DynamicSprite_GetColorDepth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_GetColorDepth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDynamicSprite, DynamicSprite_GetColorDepth);
 }
 
 // int (ScriptDynamicSprite *sds)
-RuntimeScriptValue Sc_DynamicSprite_GetGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_GetGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDynamicSprite, DynamicSprite_GetGraphic);
 }
 
 // int (ScriptDynamicSprite *sds)
-RuntimeScriptValue Sc_DynamicSprite_GetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_GetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDynamicSprite, DynamicSprite_GetHeight);
 }
 
 // int (ScriptDynamicSprite *sds)
-RuntimeScriptValue Sc_DynamicSprite_GetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_GetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDynamicSprite, DynamicSprite_GetWidth);
 }
 
 // ScriptDynamicSprite* (int width, int height, int alphaChannel)
-RuntimeScriptValue Sc_DynamicSprite_Create(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_Create(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT3(ScriptDynamicSprite, DynamicSprite_Create);
 }
 
 // ScriptDynamicSprite* (int frame, int x1, int y1, int width, int height)
-RuntimeScriptValue Sc_DynamicSprite_CreateFromBackground(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_CreateFromBackground(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT5(ScriptDynamicSprite, DynamicSprite_CreateFromBackground);
 }
 
 // ScriptDynamicSprite* (ScriptDrawingSurface *sds, int x, int y, int width, int height)
-RuntimeScriptValue Sc_DynamicSprite_CreateFromDrawingSurface(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_CreateFromDrawingSurface(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_POBJ_PINT4(ScriptDynamicSprite, DynamicSprite_CreateFromDrawingSurface, ScriptDrawingSurface);
 }
 
 // ScriptDynamicSprite* (int slot)
-RuntimeScriptValue Sc_DynamicSprite_CreateFromExistingSprite_Old(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_CreateFromExistingSprite_Old(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT(ScriptDynamicSprite, DynamicSprite_CreateFromExistingSprite_Old);
 }
 
 // ScriptDynamicSprite* (int slot, int preserveAlphaChannel)
-RuntimeScriptValue Sc_DynamicSprite_CreateFromExistingSprite(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_CreateFromExistingSprite(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT2(ScriptDynamicSprite, DynamicSprite_CreateFromExistingSprite);
 }
 
 // ScriptDynamicSprite* (const char *filename)
-RuntimeScriptValue Sc_DynamicSprite_CreateFromFile(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_CreateFromFile(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_POBJ(ScriptDynamicSprite, DynamicSprite_CreateFromFile, const char);
 }
 
 // ScriptDynamicSprite* (int sgslot, int width, int height)
-RuntimeScriptValue Sc_DynamicSprite_CreateFromSaveGame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_CreateFromSaveGame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT3(ScriptDynamicSprite, DynamicSprite_CreateFromSaveGame);
 }
 
 // ScriptDynamicSprite* (int width, int height)
-RuntimeScriptValue Sc_DynamicSprite_CreateFromScreenShot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DynamicSprite_CreateFromScreenShot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT2(ScriptDynamicSprite, DynamicSprite_CreateFromScreenShot);
 }
 
diff --git a/engines/ags/engine/ac/dynobj/cc_agsdynamicobject.cpp b/engines/ags/engine/ac/dynobj/cc_agsdynamicobject.cpp
index 5864d91d45..e711ba3963 100644
--- a/engines/ags/engine/ac/dynobj/cc_agsdynamicobject.cpp
+++ b/engines/ags/engine/ac/dynobj/cc_agsdynamicobject.cpp
@@ -92,16 +92,16 @@ void AGSCCDynamicObject::Read(const char *address, intptr_t offset, void *dest,
 	memcpy(dest, address + offset, size);
 }
 
-uint8 AGSCCDynamicObject::ReadInt8(const char *address, intptr_t offset) {
-	return *(const uint8 *)(address + offset);
+uint8_t AGSCCDynamicObject::ReadInt8(const char *address, intptr_t offset) {
+	return *(const uint8_t *)(address + offset);
 }
 
-int16 AGSCCDynamicObject::ReadInt16(const char *address, intptr_t offset) {
-	return *(const int16 *)(address + offset);
+int16_t AGSCCDynamicObject::ReadInt16(const char *address, intptr_t offset) {
+	return *(const int16_t *)(address + offset);
 }
 
-int AGSCCDynamicObject::ReadInt32(const char *address, intptr_t offset) {
-	return *(const int *)(address + offset);
+int32_t AGSCCDynamicObject::ReadInt32(const char *address, intptr_t offset) {
+	return *(const int32_t *)(address + offset);
 }
 
 float AGSCCDynamicObject::ReadFloat(const char *address, intptr_t offset) {
@@ -112,16 +112,16 @@ void AGSCCDynamicObject::Write(const char *address, intptr_t offset, void *src,
 	memcpy((void *)(const_cast<char *>(address) + offset), src, size);
 }
 
-void AGSCCDynamicObject::WriteInt8(const char *address, intptr_t offset, uint8 val) {
-	*(uint8 *)(const_cast<char *>(address) + offset) = val;
+void AGSCCDynamicObject::WriteInt8(const char *address, intptr_t offset, uint8_t val) {
+	*(uint8_t *)(const_cast<char *>(address) + offset) = val;
 }
 
-void AGSCCDynamicObject::WriteInt16(const char *address, intptr_t offset, int16 val) {
-	*(int16 *)(const_cast<char *>(address) + offset) = val;
+void AGSCCDynamicObject::WriteInt16(const char *address, intptr_t offset, int16_t val) {
+	*(int16_t *)(const_cast<char *>(address) + offset) = val;
 }
 
-void AGSCCDynamicObject::WriteInt32(const char *address, intptr_t offset, int val) {
-	*(int *)(const_cast<char *>(address) + offset) = val;
+void AGSCCDynamicObject::WriteInt32(const char *address, intptr_t offset, int32_t val) {
+	*(int32_t *)(const_cast<char *>(address) + offset) = val;
 }
 
 void AGSCCDynamicObject::WriteFloat(const char *address, intptr_t offset, float val) {
diff --git a/engines/ags/engine/ac/dynobj/cc_agsdynamicobject.h b/engines/ags/engine/ac/dynobj/cc_agsdynamicobject.h
index b941a101d8..c7e16d6010 100644
--- a/engines/ags/engine/ac/dynobj/cc_agsdynamicobject.h
+++ b/engines/ags/engine/ac/dynobj/cc_agsdynamicobject.h
@@ -40,14 +40,14 @@ public:
 	// Legacy support for reading and writing object values by their relative offset
 	const char *GetFieldPtr(const char *address, intptr_t offset) override;
 	void    Read(const char *address, intptr_t offset, void *dest, int size) override;
-	uint8 ReadInt8(const char *address, intptr_t offset) override;
-	int16 ReadInt16(const char *address, intptr_t offset) override;
-	int ReadInt32(const char *address, intptr_t offset) override;
+	uint8_t ReadInt8(const char *address, intptr_t offset) override;
+	int16_t ReadInt16(const char *address, intptr_t offset) override;
+	int32_t ReadInt32(const char *address, intptr_t offset) override;
 	float   ReadFloat(const char *address, intptr_t offset) override;
 	void    Write(const char *address, intptr_t offset, void *src, int size) override;
-	void    WriteInt8(const char *address, intptr_t offset, uint8 val) override;
-	void    WriteInt16(const char *address, intptr_t offset, int16 val) override;
-	void    WriteInt32(const char *address, intptr_t offset, int val) override;
+	void    WriteInt8(const char *address, intptr_t offset, uint8_t val) override;
+	void    WriteInt16(const char *address, intptr_t offset, int16_t val) override;
+	void    WriteInt32(const char *address, intptr_t offset, int32_t val) override;
 	void    WriteFloat(const char *address, intptr_t offset, float val) override;
 
 protected:
diff --git a/engines/ags/engine/ac/dynobj/cc_character.cpp b/engines/ags/engine/ac/dynobj/cc_character.cpp
index 81c3da86ac..a4a03ad253 100644
--- a/engines/ags/engine/ac/dynobj/cc_character.cpp
+++ b/engines/ags/engine/ac/dynobj/cc_character.cpp
@@ -50,8 +50,8 @@ void CCCharacter::Unserialize(int index, const char *serializedData, int dataSiz
 	ccRegisterUnserializedObject(index, &game.chars[num], this);
 }
 
-void CCCharacter::WriteInt16(const char *address, intptr_t offset, int16 val) {
-	*(int16 *)(const_cast<char *>(address) + offset) = val;
+void CCCharacter::WriteInt16(const char *address, intptr_t offset, int16_t val) {
+	*(int16_t *)(const_cast<char *>(address) + offset) = val;
 
 	// Detect when a game directly modifies the inventory, which causes the displayed
 	// and actual inventory to diverge since 2.70. Force an update of the displayed
diff --git a/engines/ags/engine/ac/dynobj/cc_character.h b/engines/ags/engine/ac/dynobj/cc_character.h
index 5d1eaba915..8c800ec846 100644
--- a/engines/ags/engine/ac/dynobj/cc_character.h
+++ b/engines/ags/engine/ac/dynobj/cc_character.h
@@ -38,7 +38,7 @@ struct CCCharacter final : AGSCCDynamicObject {
 
 	void Unserialize(int index, const char *serializedData, int dataSize) override;
 
-	void WriteInt16(const char *address, intptr_t offset, int16 val) override;
+	void WriteInt16(const char *address, intptr_t offset, int16_t val) override;
 };
 
 } // namespace AGS3
diff --git a/engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp b/engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp
index df5728a84d..0d12ddb439 100644
--- a/engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp
+++ b/engines/ags/engine/ac/dynobj/cc_dynamicarray.cpp
@@ -80,7 +80,7 @@ DynObjectRef CCDynamicArray::Create(int numElements, int elementSize, bool isMan
 	if (isManagedType)
 		sizePtr[0] |= ARRAY_MANAGED_TYPE_FLAG;
 	void *obj_ptr = &newArray[8];
-	int handle = ccRegisterManagedObject(obj_ptr, this);
+	int32_t handle = ccRegisterManagedObject(obj_ptr, this);
 	if (handle == 0) {
 		delete[] newArray;
 		return DynObjectRef(0, nullptr);
@@ -97,16 +97,16 @@ void CCDynamicArray::Read(const char *address, intptr_t offset, void *dest, int
 	memcpy(dest, address + offset, size);
 }
 
-uint8 CCDynamicArray::ReadInt8(const char *address, intptr_t offset) {
-	return *(const uint8 *)(address + offset);
+uint8_t CCDynamicArray::ReadInt8(const char *address, intptr_t offset) {
+	return *(const uint8_t *)(address + offset);
 }
 
-int16 CCDynamicArray::ReadInt16(const char *address, intptr_t offset) {
-	return *(const int16 *)(address + offset);
+int16_t CCDynamicArray::ReadInt16(const char *address, intptr_t offset) {
+	return *(const int16_t *)(address + offset);
 }
 
-int CCDynamicArray::ReadInt32(const char *address, intptr_t offset) {
-	return *(const int *)(address + offset);
+int32_t CCDynamicArray::ReadInt32(const char *address, intptr_t offset) {
+	return *(const int32_t *)(address + offset);
 }
 
 float CCDynamicArray::ReadFloat(const char *address, intptr_t offset) {
@@ -117,16 +117,16 @@ void CCDynamicArray::Write(const char *address, intptr_t offset, void *src, int
 	memcpy((void *)(const_cast<char *>(address) + offset), src, size);
 }
 
-void CCDynamicArray::WriteInt8(const char *address, intptr_t offset, uint8 val) {
-	*(uint8 *)(const_cast<char *>(address) + offset) = val;
+void CCDynamicArray::WriteInt8(const char *address, intptr_t offset, uint8_t val) {
+	*(uint8_t *)(const_cast<char *>(address) + offset) = val;
 }
 
-void CCDynamicArray::WriteInt16(const char *address, intptr_t offset, int16 val) {
-	*(int16 *)(const_cast<char *>(address) + offset) = val;
+void CCDynamicArray::WriteInt16(const char *address, intptr_t offset, int16_t val) {
+	*(int16_t *)(const_cast<char *>(address) + offset) = val;
 }
 
-void CCDynamicArray::WriteInt32(const char *address, intptr_t offset, int val) {
-	*(int *)(const_cast<char *>(address) + offset) = val;
+void CCDynamicArray::WriteInt32(const char *address, intptr_t offset, int32_t val) {
+	*(int32_t *)(const_cast<char *>(address) + offset) = val;
 }
 
 void CCDynamicArray::WriteFloat(const char *address, intptr_t offset, float val) {
@@ -138,11 +138,11 @@ CCDynamicArray globalDynamicArray;
 
 DynObjectRef DynamicArrayHelpers::CreateStringArray(const std::vector<const char *> items) {
 	// NOTE: we need element size of "handle" for array of managed pointers
-	DynObjectRef arr = globalDynamicArray.Create(items.size(), sizeof(int), true);
+	DynObjectRef arr = globalDynamicArray.Create(items.size(), sizeof(int32_t), true);
 	if (!arr.second)
 		return arr;
 	// Create script strings and put handles into array
-	int *slots = static_cast<int *>(arr.second);
+	int32_t *slots = static_cast<int32_t *>(arr.second);
 	for (auto s : items) {
 		DynObjectRef str = stringClassImpl->CreateString(s);
 		*(slots++) = str.first;
diff --git a/engines/ags/engine/ac/dynobj/cc_dynamicarray.h b/engines/ags/engine/ac/dynobj/cc_dynamicarray.h
index cbf7089583..d68244e64c 100644
--- a/engines/ags/engine/ac/dynobj/cc_dynamicarray.h
+++ b/engines/ags/engine/ac/dynobj/cc_dynamicarray.h
@@ -45,14 +45,14 @@ struct CCDynamicArray final : ICCDynamicObject {
 	// Legacy support for reading and writing object values by their relative offset
 	const char *GetFieldPtr(const char *address, intptr_t offset) override;
 	void    Read(const char *address, intptr_t offset, void *dest, int size) override;
-	uint8 ReadInt8(const char *address, intptr_t offset) override;
-	int16 ReadInt16(const char *address, intptr_t offset) override;
-	int ReadInt32(const char *address, intptr_t offset) override;
+	uint8_t ReadInt8(const char *address, intptr_t offset) override;
+	int16_t ReadInt16(const char *address, intptr_t offset) override;
+	int32_t ReadInt32(const char *address, intptr_t offset) override;
 	float   ReadFloat(const char *address, intptr_t offset) override;
 	void    Write(const char *address, intptr_t offset, void *src, int size) override;
-	void    WriteInt8(const char *address, intptr_t offset, uint8 val) override;
-	void    WriteInt16(const char *address, intptr_t offset, int16 val) override;
-	void    WriteInt32(const char *address, intptr_t offset, int val) override;
+	void    WriteInt8(const char *address, intptr_t offset, uint8_t val) override;
+	void    WriteInt16(const char *address, intptr_t offset, int16_t val) override;
+	void    WriteInt32(const char *address, intptr_t offset, int32_t val) override;
 	void    WriteFloat(const char *address, intptr_t offset, float val) override;
 };
 
diff --git a/engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp b/engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp
index d1bbb6d993..8492137105 100644
--- a/engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp
+++ b/engines/ags/engine/ac/dynobj/cc_dynamicobject.cpp
@@ -58,8 +58,8 @@ void ccSetStringClassImpl(ICCStringClass *theClass) {
 
 // register a memory handle for the object and allow script
 // pointers to point to it
-int ccRegisterManagedObject(const void *object, ICCDynamicObject *callback, bool plugin_object) {
-	int handl = pool.AddObject((const char *)object, callback, plugin_object);
+int32_t ccRegisterManagedObject(const void *object, ICCDynamicObject *callback, bool plugin_object) {
+	int32_t handl = pool.AddObject((const char *)object, callback, plugin_object);
 
 	ManagedObjectLog("Register managed object type '%s' handle=%d addr=%08X",
 		((callback == NULL) ? "(unknown)" : callback->GetType()), handl, object);
@@ -68,7 +68,7 @@ int ccRegisterManagedObject(const void *object, ICCDynamicObject *callback, bool
 }
 
 // register a de-serialized object
-int ccRegisterUnserializedObject(int index, const void *object, ICCDynamicObject *callback, bool plugin_object) {
+int32_t ccRegisterUnserializedObject(int index, const void *object, ICCDynamicObject *callback, bool plugin_object) {
 	return pool.AddUnserializedObject((const char *)object, callback, plugin_object, index);
 }
 
@@ -93,17 +93,17 @@ int ccUnserializeAllObjects(Stream *in, ICCObjectReader *callback) {
 }
 
 // dispose the object if RefCount==0
-void ccAttemptDisposeObject(int handle) {
+void ccAttemptDisposeObject(int32_t handle) {
 	pool.CheckDispose(handle);
 }
 
 // translate between object handles and memory addresses
-int ccGetObjectHandleFromAddress(const char *address) {
+int32_t ccGetObjectHandleFromAddress(const char *address) {
 	// set to null
 	if (address == nullptr)
 		return 0;
 
-	int handl = pool.AddressToHandle(address);
+	int32_t handl = pool.AddressToHandle(address);
 
 	ManagedObjectLog("Line %d WritePtr: %08X to %d", currentline, address, handl);
 
@@ -114,7 +114,7 @@ int ccGetObjectHandleFromAddress(const char *address) {
 	return handl;
 }
 
-const char *ccGetObjectAddressFromHandle(int handle) {
+const char *ccGetObjectAddressFromHandle(int32_t handle) {
 	if (handle == 0) {
 		return nullptr;
 	}
@@ -129,7 +129,7 @@ const char *ccGetObjectAddressFromHandle(int handle) {
 	return addr;
 }
 
-ScriptValueType ccGetObjectAddressAndManagerFromHandle(int handle, void *&object, ICCDynamicObject *&manager) {
+ScriptValueType ccGetObjectAddressAndManagerFromHandle(int32_t handle, void *&object, ICCDynamicObject *&manager) {
 	if (handle == 0) {
 		object = nullptr;
 		manager = nullptr;
@@ -142,14 +142,14 @@ ScriptValueType ccGetObjectAddressAndManagerFromHandle(int handle, void *&object
 	return obj_type;
 }
 
-int ccAddObjectReference(int handle) {
+int ccAddObjectReference(int32_t handle) {
 	if (handle == 0)
 		return 0;
 
 	return pool.AddRef(handle);
 }
 
-int ccReleaseObjectReference(int handle) {
+int ccReleaseObjectReference(int32_t handle) {
 	if (handle == 0)
 		return 0;
 
diff --git a/engines/ags/engine/ac/dynobj/cc_dynamicobject.h b/engines/ags/engine/ac/dynobj/cc_dynamicobject.h
index 7ceb602794..dc1a3ce503 100644
--- a/engines/ags/engine/ac/dynobj/cc_dynamicobject.h
+++ b/engines/ags/engine/ac/dynobj/cc_dynamicobject.h
@@ -44,7 +44,7 @@ class Stream;
 using namespace AGS; // FIXME later
 
 // A pair of managed handle and abstract object pointer
-typedef std::pair<int, void *> DynObjectRef;
+typedef std::pair<int32_t, void *> DynObjectRef;
 
 
 // OBJECT-BASED SCRIPTING RUNTIME FUNCTIONS
@@ -80,14 +80,14 @@ struct ICCDynamicObject {
 	// offset 0 means getting pointer to whole object or a pointer to its first field.
 	virtual const char *GetFieldPtr(const char *address, intptr_t offset) = 0;
 	virtual void    Read(const char *address, intptr_t offset, void *dest, int size) = 0;
-	virtual uint8 ReadInt8(const char *address, intptr_t offset) = 0;
-	virtual int16 ReadInt16(const char *address, intptr_t offset) = 0;
-	virtual int ReadInt32(const char *address, intptr_t offset) = 0;
+	virtual uint8_t ReadInt8(const char *address, intptr_t offset) = 0;
+	virtual int16_t ReadInt16(const char *address, intptr_t offset) = 0;
+	virtual int32_t ReadInt32(const char *address, intptr_t offset) = 0;
 	virtual float   ReadFloat(const char *address, intptr_t offset) = 0;
 	virtual void    Write(const char *address, intptr_t offset, void *src, int size) = 0;
-	virtual void    WriteInt8(const char *address, intptr_t offset, uint8 val) = 0;
-	virtual void    WriteInt16(const char *address, intptr_t offset, int16 val) = 0;
-	virtual void    WriteInt32(const char *address, intptr_t offset, int val) = 0;
+	virtual void    WriteInt8(const char *address, intptr_t offset, uint8_t val) = 0;
+	virtual void    WriteInt16(const char *address, intptr_t offset, int16_t val) = 0;
+	virtual void    WriteInt32(const char *address, intptr_t offset, int32_t val) = 0;
 	virtual void    WriteFloat(const char *address, intptr_t offset, float val) = 0;
 
 protected:
@@ -109,9 +109,9 @@ struct ICCStringClass {
 extern void  ccSetStringClassImpl(ICCStringClass *theClass);
 // register a memory handle for the object and allow script
 // pointers to point to it
-extern int ccRegisterManagedObject(const void *object, ICCDynamicObject *, bool plugin_object = false);
+extern int32_t ccRegisterManagedObject(const void *object, ICCDynamicObject *, bool plugin_object = false);
 // register a de-serialized object
-extern int ccRegisterUnserializedObject(int index, const void *object, ICCDynamicObject *, bool plugin_object = false);
+extern int32_t ccRegisterUnserializedObject(int index, const void *object, ICCDynamicObject *, bool plugin_object = false);
 // unregister a particular object
 extern int   ccUnRegisterManagedObject(const void *object);
 // remove all registered objects
@@ -121,15 +121,15 @@ extern void  ccSerializeAllObjects(Shared::Stream *out);
 // un-serialise all objects (will remove all currently registered ones)
 extern int   ccUnserializeAllObjects(Shared::Stream *in, ICCObjectReader *callback);
 // dispose the object if RefCount==0
-extern void  ccAttemptDisposeObject(int handle);
+extern void  ccAttemptDisposeObject(int32_t handle);
 // translate between object handles and memory addresses
-extern int ccGetObjectHandleFromAddress(const char *address);
+extern int32_t ccGetObjectHandleFromAddress(const char *address);
 // TODO: not sure if it makes any sense whatsoever to use "const char*"
 // in these functions, might as well change to char* or just void*.
-extern const char *ccGetObjectAddressFromHandle(int handle);
+extern const char *ccGetObjectAddressFromHandle(int32_t handle);
 
-extern int ccAddObjectReference(int handle);
-extern int ccReleaseObjectReference(int handle);
+extern int ccAddObjectReference(int32_t handle);
+extern int ccReleaseObjectReference(int32_t handle);
 
 extern ICCStringClass *stringClassImpl;
 
diff --git a/engines/ags/engine/ac/dynobj/cc_dynamicobject_addr_and_manager.h b/engines/ags/engine/ac/dynobj/cc_dynamicobject_addr_and_manager.h
index e554ecbe60..91830bee0e 100644
--- a/engines/ags/engine/ac/dynobj/cc_dynamicobject_addr_and_manager.h
+++ b/engines/ags/engine/ac/dynobj/cc_dynamicobject_addr_and_manager.h
@@ -29,7 +29,7 @@
 namespace AGS3 {
 
 extern ScriptValueType ccGetObjectAddressAndManagerFromHandle(
-	int handle, void *&object, ICCDynamicObject *&manager);
+	int32_t handle, void *&object, ICCDynamicObject *&manager);
 
 } // namespace AGS3
 
diff --git a/engines/ags/engine/ac/dynobj/managedobjectpool.cpp b/engines/ags/engine/ac/dynobj/managedobjectpool.cpp
index 25980e28c2..1b6b6f08dc 100644
--- a/engines/ags/engine/ac/dynobj/managedobjectpool.cpp
+++ b/engines/ags/engine/ac/dynobj/managedobjectpool.cpp
@@ -62,7 +62,7 @@ int ManagedObjectPool::Remove(ManagedObject &o, bool force) {
 	return 1;
 }
 
-int ManagedObjectPool::AddRef(int handle) {
+int32_t ManagedObjectPool::AddRef(int32_t handle) {
 	if (handle < 0 || (size_t)handle >= objects.size()) {
 		return 0;
 	}
@@ -76,7 +76,7 @@ int ManagedObjectPool::AddRef(int handle) {
 	return o.refCount;
 }
 
-int ManagedObjectPool::CheckDispose(int handle) {
+int ManagedObjectPool::CheckDispose(int32_t handle) {
 	if (handle < 0 || (size_t)handle >= objects.size()) {
 		return 1;
 	}
@@ -90,7 +90,7 @@ int ManagedObjectPool::CheckDispose(int handle) {
 	return Remove(o);
 }
 
-int ManagedObjectPool::SubRef(int handle) {
+int32_t ManagedObjectPool::SubRef(int32_t handle) {
 	if (handle < 0 || (size_t)handle >= objects.size()) {
 		return 0;
 	}
@@ -110,7 +110,7 @@ int ManagedObjectPool::SubRef(int handle) {
 	return newRefCount;
 }
 
-int ManagedObjectPool::AddressToHandle(const char *addr) {
+int32_t ManagedObjectPool::AddressToHandle(const char *addr) {
 	if (addr == nullptr) {
 		return 0;
 	}
@@ -122,7 +122,7 @@ int ManagedObjectPool::AddressToHandle(const char *addr) {
 }
 
 // this function is called often (whenever a pointer is used)
-const char *ManagedObjectPool::HandleToAddress(int handle) {
+const char *ManagedObjectPool::HandleToAddress(int32_t handle) {
 	if (handle < 0 || (size_t)handle >= objects.size()) {
 		return nullptr;
 	}
@@ -134,7 +134,7 @@ const char *ManagedObjectPool::HandleToAddress(int handle) {
 }
 
 // this function is called often (whenever a pointer is used)
-ScriptValueType ManagedObjectPool::HandleToAddressAndManager(int handle, void *&object, ICCDynamicObject *&manager) {
+ScriptValueType ManagedObjectPool::HandleToAddressAndManager(int32_t handle, void *&object, ICCDynamicObject *&manager) {
 	if (handle < 0 || (size_t)handle >= objects.size()) {
 		return kScValUndefined;
 	}
@@ -183,7 +183,7 @@ void ManagedObjectPool::RunGarbageCollection() {
 }
 
 int ManagedObjectPool::AddObject(const char *address, ICCDynamicObject *callback, bool plugin_object) {
-	int handle;
+	int32_t handle;
 
 	if (!available_ids.empty()) {
 		handle = available_ids.front();
diff --git a/engines/ags/engine/ac/dynobj/managedobjectpool.h b/engines/ags/engine/ac/dynobj/managedobjectpool.h
index c586746e80..a27034358a 100644
--- a/engines/ags/engine/ac/dynobj/managedobjectpool.h
+++ b/engines/ags/engine/ac/dynobj/managedobjectpool.h
@@ -51,7 +51,7 @@ private:
 	// TODO: find out if we can make handle size_t
 	struct ManagedObject {
 		ScriptValueType obj_type;
-		int handle;
+		int32_t handle;
 		// TODO: this makes no sense having this as "const char*",
 		// void* will be proper (and in all related functions)
 		const char *addr;
@@ -65,31 +65,31 @@ private:
 		ManagedObject()
 			: obj_type(kScValUndefined), handle(0), addr(nullptr), callback(nullptr), refCount(0) {
 		}
-		ManagedObject(ScriptValueType obj_type_, int handle_, const char *addr_, ICCDynamicObject *callback_)
+		ManagedObject(ScriptValueType obj_type_, int32_t handle_, const char *addr_, ICCDynamicObject *callback_)
 			: obj_type(obj_type_), handle(handle_), addr(addr_), callback(callback_), refCount(0) {
 		}
 	};
 
 	int objectCreationCounter;  // used to do garbage collection every so often
 
-	int nextHandle{}; // TODO: manage nextHandle's going over INT32_MAX !
-	std::queue<int> available_ids;
+	int32_t nextHandle{}; // TODO: manage nextHandle's going over INT32_MAX !
+	std::queue<int32_t> available_ids;
 	std::vector<ManagedObject> objects;
-	std::unordered_map<const char *, int, Pointer_Hash> handleByAddress;
+	std::unordered_map<const char *, int32_t, Pointer_Hash> handleByAddress;
 
-	void Init(int theHandle, const char *theAddress, ICCDynamicObject *theCallback, ScriptValueType objType);
+	void Init(int32_t theHandle, const char *theAddress, ICCDynamicObject *theCallback, ScriptValueType objType);
 	int Remove(ManagedObject &o, bool force = false);
 
 	void RunGarbageCollection();
 
 public:
 
-	int AddRef(int handle);
-	int CheckDispose(int handle);
-	int SubRef(int handle);
-	int AddressToHandle(const char *addr);
-	const char *HandleToAddress(int handle);
-	ScriptValueType HandleToAddressAndManager(int handle, void *&object, ICCDynamicObject *&manager);
+	int32_t AddRef(int32_t handle);
+	int CheckDispose(int32_t handle);
+	int32_t SubRef(int32_t handle);
+	int32_t AddressToHandle(const char *addr);
+	const char *HandleToAddress(int32_t handle);
+	ScriptValueType HandleToAddressAndManager(int32_t handle, void *&object, ICCDynamicObject *&manager);
 	int RemoveObject(const char *address);
 	void RunGarbageCollectionIfAppropriate();
 	int AddObject(const char *address, ICCDynamicObject *callback, bool plugin_object);
diff --git a/engines/ags/engine/ac/dynobj/scriptdict.cpp b/engines/ags/engine/ac/dynobj/scriptdict.cpp
index f03ae33493..7991471e11 100644
--- a/engines/ags/engine/ac/dynobj/scriptdict.cpp
+++ b/engines/ags/engine/ac/dynobj/scriptdict.cpp
@@ -35,7 +35,7 @@ const char *ScriptDictBase::GetType() {
 }
 
 int ScriptDictBase::Serialize(const char *address, char *buffer, int bufsize) {
-	size_t total_sz = CalcSerializeSize() + sizeof(int) * 2;
+	size_t total_sz = CalcSerializeSize() + sizeof(int32_t) * 2;
 	if (bufsize < 0 || total_sz >(size_t)bufsize) {
 		// buffer not big enough, ask for a bigger one
 		return -((int)total_sz);
diff --git a/engines/ags/engine/ac/dynobj/scriptdict.h b/engines/ags/engine/ac/dynobj/scriptdict.h
index dbeee6c119..5b642a0381 100644
--- a/engines/ags/engine/ac/dynobj/scriptdict.h
+++ b/engines/ags/engine/ac/dynobj/scriptdict.h
@@ -141,10 +141,10 @@ private:
 	}
 
 	size_t CalcSerializeSize() override {
-		size_t total_sz = sizeof(int);
+		size_t total_sz = sizeof(int32_t);
 		for (auto it = _dic.begin(); it != _dic.end(); ++it) {
-			total_sz += sizeof(int) + it->_key.GetLength();
-			total_sz += sizeof(int) + it->_value.GetLength();
+			total_sz += sizeof(int32_t) + it->_key.GetLength();
+			total_sz += sizeof(int32_t) + it->_value.GetLength();
 		}
 		return total_sz;
 	}
diff --git a/engines/ags/engine/ac/dynobj/scriptfile.cpp b/engines/ags/engine/ac/dynobj/scriptfile.cpp
index 00bad77d74..8798d2bb41 100644
--- a/engines/ags/engine/ac/dynobj/scriptfile.cpp
+++ b/engines/ags/engine/ac/dynobj/scriptfile.cpp
@@ -72,15 +72,15 @@ const char *sc_File::GetFieldPtr(const char *address, intptr_t offset) {
 void sc_File::Read(const char *address, intptr_t offset, void *dest, int size) {
 }
 
-uint8 sc_File::ReadInt8(const char *address, intptr_t offset) {
+uint8_t sc_File::ReadInt8(const char *address, intptr_t offset) {
 	return 0;
 }
 
-int16 sc_File::ReadInt16(const char *address, intptr_t offset) {
+int16_t sc_File::ReadInt16(const char *address, intptr_t offset) {
 	return 0;
 }
 
-int sc_File::ReadInt32(const char *address, intptr_t offset) {
+int32_t sc_File::ReadInt32(const char *address, intptr_t offset) {
 	return 0;
 }
 
@@ -91,13 +91,13 @@ float sc_File::ReadFloat(const char *address, intptr_t offset) {
 void sc_File::Write(const char *address, intptr_t offset, void *src, int size) {
 }
 
-void sc_File::WriteInt8(const char *address, intptr_t offset, uint8 val) {
+void sc_File::WriteInt8(const char *address, intptr_t offset, uint8_t val) {
 }
 
-void sc_File::WriteInt16(const char *address, intptr_t offset, int16 val) {
+void sc_File::WriteInt16(const char *address, intptr_t offset, int16_t val) {
 }
 
-void sc_File::WriteInt32(const char *address, intptr_t offset, int val) {
+void sc_File::WriteInt32(const char *address, intptr_t offset, int32_t val) {
 }
 
 void sc_File::WriteFloat(const char *address, intptr_t offset, float val) {
diff --git a/engines/ags/engine/ac/dynobj/scriptfile.h b/engines/ags/engine/ac/dynobj/scriptfile.h
index c73c42d911..b5085c2e5a 100644
--- a/engines/ags/engine/ac/dynobj/scriptfile.h
+++ b/engines/ags/engine/ac/dynobj/scriptfile.h
@@ -35,7 +35,7 @@ using namespace AGS; // FIXME later
 #define scFileAppend 3
 
 struct sc_File final : ICCDynamicObject {
-	int             handle;
+	int32_t             handle;
 
 	static const Shared::FileOpenMode fopenModes[];
 	static const Shared::FileWorkMode fworkModes[];
@@ -54,14 +54,14 @@ struct sc_File final : ICCDynamicObject {
 	// Legacy support for reading and writing object values by their relative offset
 	const char *GetFieldPtr(const char *address, intptr_t offset) override;
 	void    Read(const char *address, intptr_t offset, void *dest, int size) override;
-	uint8 ReadInt8(const char *address, intptr_t offset) override;
-	int16 ReadInt16(const char *address, intptr_t offset) override;
-	int ReadInt32(const char *address, intptr_t offset) override;
+	uint8_t ReadInt8(const char *address, intptr_t offset) override;
+	int16_t ReadInt16(const char *address, intptr_t offset) override;
+	int32_t ReadInt32(const char *address, intptr_t offset) override;
 	float   ReadFloat(const char *address, intptr_t offset) override;
 	void    Write(const char *address, intptr_t offset, void *src, int size) override;
-	void    WriteInt8(const char *address, intptr_t offset, uint8 val) override;
-	void    WriteInt16(const char *address, intptr_t offset, int16 val) override;
-	void    WriteInt32(const char *address, intptr_t offset, int val) override;
+	void    WriteInt8(const char *address, intptr_t offset, uint8_t val) override;
+	void    WriteInt16(const char *address, intptr_t offset, int16_t val) override;
+	void    WriteInt32(const char *address, intptr_t offset, int32_t val) override;
 	void    WriteFloat(const char *address, intptr_t offset, float val) override;
 };
 
diff --git a/engines/ags/engine/ac/dynobj/scriptset.cpp b/engines/ags/engine/ac/dynobj/scriptset.cpp
index ff4de4a455..8141fc8913 100644
--- a/engines/ags/engine/ac/dynobj/scriptset.cpp
+++ b/engines/ags/engine/ac/dynobj/scriptset.cpp
@@ -35,7 +35,7 @@ const char *ScriptSetBase::GetType() {
 }
 
 int ScriptSetBase::Serialize(const char *address, char *buffer, int bufsize) {
-	size_t total_sz = CalcSerializeSize() + sizeof(int) * 2;
+	size_t total_sz = CalcSerializeSize() + sizeof(int32_t) * 2;
 	if (bufsize < 0 || total_sz >(size_t)bufsize) {
 		// buffer not big enough, ask for a bigger one
 		return -((int)total_sz);
diff --git a/engines/ags/engine/ac/dynobj/scriptset.h b/engines/ags/engine/ac/dynobj/scriptset.h
index cfca033f24..1782f4f461 100644
--- a/engines/ags/engine/ac/dynobj/scriptset.h
+++ b/engines/ags/engine/ac/dynobj/scriptset.h
@@ -120,9 +120,9 @@ private:
 	}
 
 	size_t CalcSerializeSize() override {
-		size_t total_sz = sizeof(int);
+		size_t total_sz = sizeof(int32_t);
 		for (auto it = _set.begin(); it != _set.end(); ++it)
-			total_sz += sizeof(int) + it->GetLength();
+			total_sz += sizeof(int32_t) + it->GetLength();
 		return total_sz;
 	}
 
diff --git a/engines/ags/engine/ac/dynobj/scriptuserobject.cpp b/engines/ags/engine/ac/dynobj/scriptuserobject.cpp
index 3c0f489958..81a7095405 100644
--- a/engines/ags/engine/ac/dynobj/scriptuserobject.cpp
+++ b/engines/ags/engine/ac/dynobj/scriptuserobject.cpp
@@ -87,16 +87,16 @@ void ScriptUserObject::Read(const char *address, intptr_t offset, void *dest, in
 	memcpy(dest, _data + offset, size);
 }
 
-uint8 ScriptUserObject::ReadInt8(const char *address, intptr_t offset) {
-	return *(uint8 *)(_data + offset);
+uint8_t ScriptUserObject::ReadInt8(const char *address, intptr_t offset) {
+	return *(uint8_t *)(_data + offset);
 }
 
-int16 ScriptUserObject::ReadInt16(const char *address, intptr_t offset) {
-	return *(int16 *)(_data + offset);
+int16_t ScriptUserObject::ReadInt16(const char *address, intptr_t offset) {
+	return *(int16_t *)(_data + offset);
 }
 
-int ScriptUserObject::ReadInt32(const char *address, intptr_t offset) {
-	return *(int *)(_data + offset);
+int32_t ScriptUserObject::ReadInt32(const char *address, intptr_t offset) {
+	return *(int32_t *)(_data + offset);
 }
 
 float ScriptUserObject::ReadFloat(const char *address, intptr_t offset) {
@@ -107,16 +107,16 @@ void ScriptUserObject::Write(const char *address, intptr_t offset, void *src, in
 	memcpy((void *)(_data + offset), src, size);
 }
 
-void ScriptUserObject::WriteInt8(const char *address, intptr_t offset, uint8 val) {
-	*(uint8 *)(_data + offset) = val;
+void ScriptUserObject::WriteInt8(const char *address, intptr_t offset, uint8_t val) {
+	*(uint8_t *)(_data + offset) = val;
 }
 
-void ScriptUserObject::WriteInt16(const char *address, intptr_t offset, int16 val) {
-	*(int16 *)(_data + offset) = val;
+void ScriptUserObject::WriteInt16(const char *address, intptr_t offset, int16_t val) {
+	*(int16_t *)(_data + offset) = val;
 }
 
-void ScriptUserObject::WriteInt32(const char *address, intptr_t offset, int val) {
-	*(int *)(_data + offset) = val;
+void ScriptUserObject::WriteInt32(const char *address, intptr_t offset, int32_t val) {
+	*(int32_t *)(_data + offset) = val;
 }
 
 void ScriptUserObject::WriteFloat(const char *address, intptr_t offset, float val) {
@@ -126,9 +126,9 @@ void ScriptUserObject::WriteFloat(const char *address, intptr_t offset, float va
 
 // Allocates managed struct containing two ints: X and Y
 ScriptUserObject *ScriptStructHelpers::CreatePoint(int x, int y) {
-	ScriptUserObject *suo = ScriptUserObject::CreateManaged(sizeof(int) * 2);
+	ScriptUserObject *suo = ScriptUserObject::CreateManaged(sizeof(int32_t) * 2);
 	suo->WriteInt32((const char *)suo, 0, x);
-	suo->WriteInt32((const char *)suo, sizeof(int), y);
+	suo->WriteInt32((const char *)suo, sizeof(int32_t), y);
 	return suo;
 }
 
diff --git a/engines/ags/engine/ac/dynobj/scriptuserobject.h b/engines/ags/engine/ac/dynobj/scriptuserobject.h
index 9726695a70..44ae8bf68c 100644
--- a/engines/ags/engine/ac/dynobj/scriptuserobject.h
+++ b/engines/ags/engine/ac/dynobj/scriptuserobject.h
@@ -55,14 +55,14 @@ public:
 	// Support for reading and writing object values by their relative offset
 	const char *GetFieldPtr(const char *address, intptr_t offset) override;
 	void    Read(const char *address, intptr_t offset, void *dest, int size) override;
-	uint8 ReadInt8(const char *address, intptr_t offset) override;
-	int16 ReadInt16(const char *address, intptr_t offset) override;
-	int ReadInt32(const char *address, intptr_t offset) override;
+	uint8_t ReadInt8(const char *address, intptr_t offset) override;
+	int16_t ReadInt16(const char *address, intptr_t offset) override;
+	int32_t ReadInt32(const char *address, intptr_t offset) override;
 	float   ReadFloat(const char *address, intptr_t offset) override;
 	void    Write(const char *address, intptr_t offset, void *src, int size) override;
-	void    WriteInt8(const char *address, intptr_t offset, uint8 val) override;
-	void    WriteInt16(const char *address, intptr_t offset, int16 val) override;
-	void    WriteInt32(const char *address, intptr_t offset, int val) override;
+	void    WriteInt8(const char *address, intptr_t offset, uint8_t val) override;
+	void    WriteInt16(const char *address, intptr_t offset, int16_t val) override;
+	void    WriteInt32(const char *address, intptr_t offset, int32_t val) override;
 	void    WriteFloat(const char *address, intptr_t offset, float val) override;
 
 private:
@@ -72,7 +72,7 @@ private:
 	// enough. Since this interface is also a part of Plugin API, we would
 	// need more significant change to program before we could use different
 	// approach.
-	int  _size;
+	int32_t  _size;
 	char *_data;
 };
 
diff --git a/engines/ags/engine/ac/file.cpp b/engines/ags/engine/ac/file.cpp
index 8b0828af67..a63329e06c 100644
--- a/engines/ags/engine/ac/file.cpp
+++ b/engines/ags/engine/ac/file.cpp
@@ -587,7 +587,7 @@ ScriptFileHandle *check_valid_file_handle_ptr(Stream *stream_ptr, const char *op
 	return nullptr;
 }
 
-ScriptFileHandle *check_valid_file_handle_int32(int handle, const char *operation_name) {
+ScriptFileHandle *check_valid_file_handle_int32(int32_t handle, const char *operation_name) {
 	if (handle > 0) {
 		for (int i = 0; i < num_open_script_files; ++i) {
 			if (handle == valid_handles[i].handle) {
@@ -601,7 +601,7 @@ ScriptFileHandle *check_valid_file_handle_int32(int handle, const char *operatio
 	return nullptr;
 }
 
-Stream *get_valid_file_stream_from_handle(int handle, const char *operation_name) {
+Stream *get_valid_file_stream_from_handle(int32_t handle, const char *operation_name) {
 	ScriptFileHandle *sc_handle = check_valid_file_handle_int32(handle, operation_name);
 	return sc_handle ? sc_handle->stream : nullptr;
 }
@@ -615,95 +615,95 @@ Stream *get_valid_file_stream_from_handle(int handle, const char *operation_name
 extern ScriptString myScriptStringImpl;
 
 // int (const char *fnmm)
-RuntimeScriptValue Sc_File_Delete(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_Delete(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(File_Delete, const char);
 }
 
 // int (const char *fnmm)
-RuntimeScriptValue Sc_File_Exists(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_Exists(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(File_Exists, const char);
 }
 
 // void *(const char *fnmm, int mode)
-RuntimeScriptValue Sc_sc_OpenFile(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_OpenFile(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_POBJ_PINT(sc_File, sc_OpenFile, const char);
 }
 
 // void (sc_File *fil)
-RuntimeScriptValue Sc_File_Close(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_Close(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(sc_File, File_Close);
 }
 
 // int (sc_File *fil)
-RuntimeScriptValue Sc_File_ReadInt(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_ReadInt(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(sc_File, File_ReadInt);
 }
 
 // int (sc_File *fil)
-RuntimeScriptValue Sc_File_ReadRawChar(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_ReadRawChar(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(sc_File, File_ReadRawChar);
 }
 
 // int (sc_File *fil)
-RuntimeScriptValue Sc_File_ReadRawInt(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_ReadRawInt(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(sc_File, File_ReadRawInt);
 }
 
 // void (sc_File *fil, char* buffer)
-RuntimeScriptValue Sc_File_ReadRawLine(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_ReadRawLine(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(sc_File, File_ReadRawLine, char);
 }
 
 // const char* (sc_File *fil)
-RuntimeScriptValue Sc_File_ReadRawLineBack(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_ReadRawLineBack(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(sc_File, const char, myScriptStringImpl, File_ReadRawLineBack);
 }
 
 // void (sc_File *fil, char *toread)
-RuntimeScriptValue Sc_File_ReadString(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_ReadString(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(sc_File, File_ReadString, char);
 }
 
 // const char* (sc_File *fil)
-RuntimeScriptValue Sc_File_ReadStringBack(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_ReadStringBack(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(sc_File, const char, myScriptStringImpl, File_ReadStringBack);
 }
 
 // void (sc_File *fil, int towrite)
-RuntimeScriptValue Sc_File_WriteInt(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_WriteInt(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(sc_File, File_WriteInt);
 }
 
 // void (sc_File *fil, int towrite)
-RuntimeScriptValue Sc_File_WriteRawChar(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_WriteRawChar(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(sc_File, File_WriteRawChar);
 }
 
 // void (sc_File *fil, const char *towrite)
-RuntimeScriptValue Sc_File_WriteRawLine(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_WriteRawLine(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(sc_File, File_WriteRawLine, const char);
 }
 
 // void (sc_File *fil, const char *towrite)
-RuntimeScriptValue Sc_File_WriteString(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_WriteString(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(sc_File, File_WriteString, const char);
 }
 
-RuntimeScriptValue Sc_File_Seek(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_Seek(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT2(sc_File, File_Seek);
 }
 
 // int (sc_File *fil)
-RuntimeScriptValue Sc_File_GetEOF(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_GetEOF(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(sc_File, File_GetEOF);
 }
 
 // int (sc_File *fil)
-RuntimeScriptValue Sc_File_GetError(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_GetError(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(sc_File, File_GetError);
 }
 
-RuntimeScriptValue Sc_File_GetPosition(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_File_GetPosition(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(sc_File, File_GetPosition);
 }
 
diff --git a/engines/ags/engine/ac/file.h b/engines/ags/engine/ac/file.h
index b21ce8df15..fb116d1213 100644
--- a/engines/ags/engine/ac/file.h
+++ b/engines/ags/engine/ac/file.h
@@ -58,14 +58,14 @@ int     File_GetPosition(sc_File *fil);
 
 struct ScriptFileHandle {
 	Stream *stream;
-	int  handle;
+	int32_t  handle;
 };
 extern ScriptFileHandle valid_handles[MAX_OPEN_SCRIPT_FILES + 1];
 extern int num_open_script_files;
 
 ScriptFileHandle *check_valid_file_handle_ptr(Stream *stream_ptr, const char *operation_name);
-ScriptFileHandle *check_valid_file_handle_int32(int handle, const char *operation_name);
-Stream *get_valid_file_stream_from_handle(int handle, const char *operation_name);
+ScriptFileHandle *check_valid_file_handle_int32(int32_t handle, const char *operation_name);
+Stream *get_valid_file_stream_from_handle(int32_t handle, const char *operation_name);
 
 } // namespace AGS3
 
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index 0d3eff33f3..37967c343c 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -917,10 +917,10 @@ void serialize_bitmap(const Shared::Bitmap *thispic, Stream *out) {
 				out->WriteArray(&thispic->GetScanLine(cc)[0], thispic->GetWidth(), 1);
 				break;
 			case 16:
-				out->WriteArrayOfInt16((const int16 *)&thispic->GetScanLine(cc)[0], thispic->GetWidth());
+				out->WriteArrayOfInt16((const int16_t *)&thispic->GetScanLine(cc)[0], thispic->GetWidth());
 				break;
 			case 32:
-				out->WriteArrayOfInt32((const int *)&thispic->GetScanLine(cc)[0], thispic->GetWidth());
+				out->WriteArrayOfInt32((const int32_t *)&thispic->GetScanLine(cc)[0], thispic->GetWidth());
 				break;
 			}
 		}
@@ -977,10 +977,10 @@ Bitmap *read_serialized_bitmap(Stream *in) {
 			in->ReadArray(thispic->GetScanLineForWriting(vv), picwid, 1);
 			break;
 		case 16:
-			in->ReadArrayOfInt16((int16 *)thispic->GetScanLineForWriting(vv), picwid);
+			in->ReadArrayOfInt16((int16_t *)thispic->GetScanLineForWriting(vv), picwid);
 			break;
 		case 32:
-			in->ReadArrayOfInt32((int *)thispic->GetScanLineForWriting(vv), picwid);
+			in->ReadArrayOfInt32((int32_t *)thispic->GetScanLineForWriting(vv), picwid);
 			break;
 		}
 	}
@@ -1191,7 +1191,7 @@ void restore_game_play(Stream *in, RestoredData &r_data) {
 	int screenfadedout_was = play.screen_is_faded_out;
 	int roomchanges_was = play.room_changes;
 	// make sure the pointer is preserved
-	int *gui_draw_order_was = play.gui_draw_order;
+	int32_t *gui_draw_order_was = play.gui_draw_order;
 
 	ReadGameState_Aligned(in, r_data);
 	r_data.Cameras[0].Flags = r_data.Camera0_Flags;
@@ -1502,7 +1502,7 @@ HSaveError restore_game_data(Stream *in, SavegameVersion svg_version, const Pres
 	if (!err)
 		return err;
 
-	if (in->ReadInt32() != (int)(MAGICNUMBER + 1)) {
+	if (in->ReadInt32() != (int32)(MAGICNUMBER + 1)) {
 		return new SavegameError(kSvgErr_InconsistentFormat, "MAGICNUMBER not found before Audio Clips.");
 	}
 
@@ -1514,7 +1514,7 @@ HSaveError restore_game_data(Stream *in, SavegameVersion svg_version, const Pres
 	pl_set_file_handle(pluginFileHandle, in);
 	pl_run_plugin_hooks(AGSE_RESTOREGAME, pluginFileHandle);
 	pl_clear_file_handle();
-	if (in->ReadInt32() != (int)MAGICNUMBER)
+	if (in->ReadInt32() != (int32)MAGICNUMBER)
 		return new SavegameError(kSvgErr_InconsistentPlugin);
 
 	// save the new room music vol for later use
@@ -1947,264 +1947,264 @@ bool unserialize_audio_script_object(int index, const char *objectType, const ch
 //=============================================================================
 
 // int  (int audioType);
-RuntimeScriptValue Sc_Game_IsAudioPlaying(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_IsAudioPlaying(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(Game_IsAudioPlaying);
 }
 
 // void (int audioType, int volumeDrop)
-RuntimeScriptValue Sc_Game_SetAudioTypeSpeechVolumeDrop(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_SetAudioTypeSpeechVolumeDrop(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(Game_SetAudioTypeSpeechVolumeDrop);
 }
 
 // void (int audioType, int volume, int changeType)
-RuntimeScriptValue Sc_Game_SetAudioTypeVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_SetAudioTypeVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(Game_SetAudioTypeVolume);
 }
 
 // void (int audioType)
-RuntimeScriptValue Sc_Game_StopAudio(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_StopAudio(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(Game_StopAudio);
 }
 
 // int (const char *newFilename)
-RuntimeScriptValue Sc_Game_ChangeTranslation(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_ChangeTranslation(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(Game_ChangeTranslation, const char);
 }
 
 // int (const char *token)
-RuntimeScriptValue Sc_Game_DoOnceOnly(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_DoOnceOnly(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(Game_DoOnceOnly, const char);
 }
 
 // int (int red, int grn, int blu)
-RuntimeScriptValue Sc_Game_GetColorFromRGB(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetColorFromRGB(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT3(Game_GetColorFromRGB);
 }
 
 // int (int viewNumber, int loopNumber)
-RuntimeScriptValue Sc_Game_GetFrameCountForLoop(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetFrameCountForLoop(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(Game_GetFrameCountForLoop);
 }
 
 // const char* (int x, int y)
-RuntimeScriptValue Sc_Game_GetLocationName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetLocationName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ_PINT2(const char, myScriptStringImpl, Game_GetLocationName);
 }
 
 // int (int viewNumber)
-RuntimeScriptValue Sc_Game_GetLoopCountForView(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetLoopCountForView(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(Game_GetLoopCountForView);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetMODPattern(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetMODPattern(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetMODPattern);
 }
 
 // int (int viewNumber, int loopNumber)
-RuntimeScriptValue Sc_Game_GetRunNextSettingForLoop(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetRunNextSettingForLoop(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(Game_GetRunNextSettingForLoop);
 }
 
 // const char* (int slnum)
-RuntimeScriptValue Sc_Game_GetSaveSlotDescription(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetSaveSlotDescription(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ_PINT(const char, myScriptStringImpl, Game_GetSaveSlotDescription);
 }
 
 // ScriptViewFrame* (int viewNumber, int loopNumber, int frame)
-RuntimeScriptValue Sc_Game_GetViewFrame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetViewFrame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT3(ScriptViewFrame, Game_GetViewFrame);
 }
 
 // const char* (const char *msg)
-RuntimeScriptValue Sc_Game_InputBox(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_InputBox(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ_POBJ(const char, myScriptStringImpl, Game_InputBox, const char);
 }
 
 // int (const char *newFolder)
-RuntimeScriptValue Sc_Game_SetSaveGameDirectory(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_SetSaveGameDirectory(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(Game_SetSaveGameDirectory, const char);
 }
 
 // void (int evenAmbient);
-RuntimeScriptValue Sc_StopAllSounds(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StopAllSounds(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(StopAllSounds);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetCharacterCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetCharacterCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetCharacterCount);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetDialogCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetDialogCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetDialogCount);
 }
 
 // const char *()
-RuntimeScriptValue Sc_Game_GetFileName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetFileName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ(const char, myScriptStringImpl, Game_GetFileName);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetFontCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetFontCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetFontCount);
 }
 
 // const char* (int index)
-RuntimeScriptValue Sc_Game_GetGlobalMessages(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetGlobalMessages(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ_PINT(const char, myScriptStringImpl, Game_GetGlobalMessages);
 }
 
 // const char* (int index)
-RuntimeScriptValue Sc_Game_GetGlobalStrings(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetGlobalStrings(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ_PINT(const char, myScriptStringImpl, Game_GetGlobalStrings);
 }
 
 // void  (int index, char *newval);
-RuntimeScriptValue Sc_SetGlobalString(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGlobalString(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(SetGlobalString, const char);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetGUICount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetGUICount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetGUICount);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetIgnoreUserInputAfterTextTimeoutMs(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetIgnoreUserInputAfterTextTimeoutMs(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetIgnoreUserInputAfterTextTimeoutMs);
 }
 
 // void (int newValueMs)
-RuntimeScriptValue Sc_Game_SetIgnoreUserInputAfterTextTimeoutMs(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_SetIgnoreUserInputAfterTextTimeoutMs(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(Game_SetIgnoreUserInputAfterTextTimeoutMs);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetInSkippableCutscene(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetInSkippableCutscene(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetInSkippableCutscene);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetInventoryItemCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetInventoryItemCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetInventoryItemCount);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetMinimumTextDisplayTimeMs(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetMinimumTextDisplayTimeMs(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetMinimumTextDisplayTimeMs);
 }
 
 // void (int newTextMinTime)
-RuntimeScriptValue Sc_Game_SetMinimumTextDisplayTimeMs(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_SetMinimumTextDisplayTimeMs(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(Game_SetMinimumTextDisplayTimeMs);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetMouseCursorCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetMouseCursorCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetMouseCursorCount);
 }
 
 // const char *()
-RuntimeScriptValue Sc_Game_GetName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ(const char, myScriptStringImpl, Game_GetName);
 }
 
 // void (const char *newName)
-RuntimeScriptValue Sc_Game_SetName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_SetName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_POBJ(Game_SetName, const char);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetNormalFont(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetNormalFont(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetNormalFont);
 }
 
 // void  (int fontnum);
-RuntimeScriptValue Sc_SetNormalFont(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetNormalFont(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetNormalFont);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetSkippingCutscene(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetSkippingCutscene(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetSkippingCutscene);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetSpeechFont(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetSpeechFont(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetSpeechFont);
 }
 
 // void  (int fontnum);
-RuntimeScriptValue Sc_SetSpeechFont(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetSpeechFont(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetSpeechFont);
 }
 
 // int (int spriteNum)
-RuntimeScriptValue Sc_Game_GetSpriteWidth(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetSpriteWidth(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(Game_GetSpriteWidth);
 }
 
 // int (int spriteNum)
-RuntimeScriptValue Sc_Game_GetSpriteHeight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetSpriteHeight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(Game_GetSpriteHeight);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetTextReadingSpeed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetTextReadingSpeed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetTextReadingSpeed);
 }
 
 // void (int newTextSpeed)
-RuntimeScriptValue Sc_Game_SetTextReadingSpeed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_SetTextReadingSpeed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(Game_SetTextReadingSpeed);
 }
 
 // const char* ()
-RuntimeScriptValue Sc_Game_GetTranslationFilename(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetTranslationFilename(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ(const char, myScriptStringImpl, Game_GetTranslationFilename);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetUseNativeCoordinates(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetUseNativeCoordinates(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetUseNativeCoordinates);
 }
 
 // int ()
-RuntimeScriptValue Sc_Game_GetViewCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetViewCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetViewCount);
 }
 
-RuntimeScriptValue Sc_Game_GetAudioClipCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetAudioClipCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(game.audioClips.size());
 }
 
-RuntimeScriptValue Sc_Game_GetAudioClip(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetAudioClip(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT(ScriptAudioClip, ccDynamicAudioClip, Game_GetAudioClip);
 }
 
-RuntimeScriptValue Sc_Game_IsPluginLoaded(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_IsPluginLoaded(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_BOOL_OBJ(pl_is_plugin_loaded, const char);
 }
 
-RuntimeScriptValue Sc_Game_PlayVoiceClip(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_PlayVoiceClip(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_POBJ_PINT_PBOOL(ScriptAudioChannel, ccDynamicAudio, PlayVoiceClip, CharacterInfo);
 }
 
-RuntimeScriptValue Sc_Game_GetCamera(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetCamera(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO(ScriptCamera, Game_GetCamera);
 }
 
-RuntimeScriptValue Sc_Game_GetCameraCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetCameraCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Game_GetCameraCount);
 }
 
-RuntimeScriptValue Sc_Game_GetAnyCamera(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_GetAnyCamera(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT(ScriptCamera, Game_GetAnyCamera);
 }
 
-RuntimeScriptValue Sc_Game_SimulateKeyPress(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Game_SimulateKeyPress(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(Game_SimulateKeyPress);
 }
 
diff --git a/engines/ags/engine/ac/gamestate.cpp b/engines/ags/engine/ac/gamestate.cpp
index 00e17c3b18..3d89843686 100644
--- a/engines/ags/engine/ac/gamestate.cpp
+++ b/engines/ags/engine/ac/gamestate.cpp
@@ -234,14 +234,14 @@ PViewport GameState::CreateRoomViewport() {
 	viewport->SetRect(_mainViewport.GetRect());
 	ScriptViewport *scv = new ScriptViewport(index);
 	_roomViewports.push_back(viewport);
-	_scViewportRefs.push_back(std::make_pair(scv, (int)0));
+	_scViewportRefs.push_back(std::make_pair(scv, (int32_t)0));
 	_roomViewportsSorted.push_back(viewport);
 	_roomViewportZOrderChanged = true;
 	on_roomviewport_created(index);
 	return viewport;
 }
 
-ScriptViewport *GameState::RegisterRoomViewport(int index, int handle) {
+ScriptViewport *GameState::RegisterRoomViewport(int index, int32_t handle) {
 	if (index < 0 || (size_t)index >= _roomViewports.size())
 		return nullptr;
 	auto &scobj = _scViewportRefs[index];
@@ -291,12 +291,12 @@ PCamera GameState::CreateRoomCamera() {
 	camera->SetAt(0, 0);
 	camera->SetSize(_mainViewport.GetRect().GetSize());
 	ScriptCamera *scam = new ScriptCamera(index);
-	_scCameraRefs.push_back(std::make_pair(scam, (int)0));
+	_scCameraRefs.push_back(std::make_pair(scam, (int32_t)0));
 	_roomCameras.push_back(camera);
 	return camera;
 }
 
-ScriptCamera *GameState::RegisterRoomCamera(int index, int handle) {
+ScriptCamera *GameState::RegisterRoomCamera(int index, int32_t handle) {
 	if (index < 0 || (size_t)index >= _roomCameras.size())
 		return nullptr;
 	auto &scobj = _scCameraRefs[index];
@@ -848,7 +848,7 @@ HorAlignment ConvertLegacyScriptAlignment(LegacyScriptAlignment align) {
 // Reads legacy alignment type from the value set in script depending on the
 // current Script API level. This is made to make it possible to change
 // Alignment constants in the Script API and still support old version.
-HorAlignment ReadScriptAlignment(int align) {
+HorAlignment ReadScriptAlignment(int32_t align) {
 	return game.options[OPT_BASESCRIPTAPI] < kScriptAPI_v350 ?
 		ConvertLegacyScriptAlignment((LegacyScriptAlignment)align) :
 		(HorAlignment)align;
diff --git a/engines/ags/engine/ac/gamestate.h b/engines/ags/engine/ac/gamestate.h
index a24f61efeb..486dd2423e 100644
--- a/engines/ags/engine/ac/gamestate.h
+++ b/engines/ags/engine/ac/gamestate.h
@@ -73,7 +73,7 @@ struct GameState {
 	int  disabled_user_interface;  // >0 while in cutscene/etc
 	int  gscript_timer;    // obsolete
 	int  debug_mode;       // whether we're in debug mode
-	int globalvars[MAXGLOBALVARS];  // obsolete
+	int32_t globalvars[MAXGLOBALVARS];  // obsolete
 	int  messagetime;      // time left for auto-remove messages
 	int  usedinv;          // inventory item last used
 	int  inv_top, inv_numdisp, obsolete_inv_numorder, inv_numinline;
@@ -147,7 +147,7 @@ struct GameState {
 	int  speech_display_post_time_ms; // keep speech text/portrait on screen after text/voice has finished playing;
 	// no speech animation is supposed to be played at this time
 	int  dialog_options_highlight_color; // The colour used for highlighted (hovered over) text in dialog options
-	int reserved[GAME_STATE_RESERVED_INTS];  // make sure if a future version adds a var, it doesn't mess anything up
+	int32_t reserved[GAME_STATE_RESERVED_INTS];  // make sure if a future version adds a var, it doesn't mess anything up
 	// ** up to here is referenced in the script "game." object
 	long  randseed;    // random seed
 	int   player_on_region;    // player's current region
@@ -161,7 +161,7 @@ struct GameState {
 	short mboundx1, mboundx2, mboundy1, mboundy2;
 	int   fade_effect;
 	int   bg_frame_locked;
-	int globalscriptvars[MAXGSVALUES];
+	int32_t globalscriptvars[MAXGSVALUES];
 	int   cur_music_number, music_repeat;
 	int   music_master_volume;
 	int   digital_master_volume;
@@ -170,7 +170,7 @@ struct GameState {
 	int   entered_at_x, entered_at_y, entered_edge;
 	int   want_speech;
 	int   cant_skip_speech;
-	int script_timers[MAX_TIMERS];
+	int32_t script_timers[MAX_TIMERS];
 	int   sound_volume, speech_volume;
 	int   normal_font, speech_font;
 	char  key_skip_wait;
@@ -183,7 +183,7 @@ struct GameState {
 	short parsed_words[MAX_PARSED_WORDS];
 	char  bad_parsed_word[100];
 	int   raw_color;
-	int raw_modified[MAX_ROOM_BGFRAMES];
+	int32_t raw_modified[MAX_ROOM_BGFRAMES];
 	Shared::PBitmap raw_drawing_surface;
 	short filenumbers[MAXSAVEGAMES];
 	int   room_changes;
@@ -222,11 +222,11 @@ struct GameState {
 	int   gamma_adjustment;
 	short temporarily_turned_off_character;  // Hide Player Charactr ticked
 	short inv_backwards_compatibility;
-	int *gui_draw_order;
+	int32_t *gui_draw_order;
 	std::vector<AGS::Shared::String> do_once_tokens;
 	int   text_min_display_time_ms;
 	int   ignore_user_input_after_text_timeout_ms;
-	int   default_audio_type_volumes[MAX_AUDIO_TYPES];
+	int32_t   default_audio_type_volumes[MAX_AUDIO_TYPES];
 
 	// Dynamic custom property values for characters and items
 	std::vector<AGS::Shared::StringIMap> charProps;
@@ -308,7 +308,7 @@ struct GameState {
 	// Creates new room viewport
 	PViewport CreateRoomViewport();
 	// Register camera in the managed system; optionally links to existing handle
-	ScriptViewport *RegisterRoomViewport(int index, int handle = 0);
+	ScriptViewport *RegisterRoomViewport(int index, int32_t handle = 0);
 	// Deletes existing room viewport
 	void DeleteRoomViewport(int index);
 	// Get number of room viewports
@@ -316,7 +316,7 @@ struct GameState {
 	// Creates new room camera
 	PCamera CreateRoomCamera();
 	// Register camera in the managed system; optionally links to existing handle
-	ScriptCamera *RegisterRoomCamera(int index, int handle = 0);
+	ScriptCamera *RegisterRoomCamera(int index, int32_t handle = 0);
 	// Deletes existing room camera
 	void DeleteRoomCamera(int index);
 	// Get number of room cameras
@@ -382,8 +382,8 @@ private:
 	// Script viewports and cameras are references to real data export to
 	// user script. They became invalidated as the actual object gets
 	// destroyed, but are kept in memory to prevent script errors.
-	std::vector<std::pair<ScriptViewport *, int>> _scViewportRefs;
-	std::vector<std::pair<ScriptCamera *, int>> _scCameraRefs;
+	std::vector<std::pair<ScriptViewport *, int32_t>> _scViewportRefs;
+	std::vector<std::pair<ScriptCamera *, int32_t>> _scCameraRefs;
 
 	// Tells that the main viewport's position has changed since last game update
 	bool  _mainViewportHasChanged;
@@ -398,7 +398,7 @@ HorAlignment ConvertLegacyScriptAlignment(LegacyScriptAlignment align);
 // Reads legacy alignment type from the value set in script depending on the
 // current Script API level. This is made to make it possible to change
 // Alignment constants in the Script API and still support old version.
-HorAlignment ReadScriptAlignment(int align);
+HorAlignment ReadScriptAlignment(int32_t align);
 
 extern GameState play;
 
diff --git a/engines/ags/engine/ac/global_api.cpp b/engines/ags/engine/ac/global_api.cpp
index 725d1821b4..20fd5507a4 100644
--- a/engines/ags/engine/ac/global_api.cpp
+++ b/engines/ags/engine/ac/global_api.cpp
@@ -87,103 +87,103 @@ namespace AGS3 {
 extern ScriptString myScriptStringImpl;
 
 // void (char*texx, ...)
-RuntimeScriptValue Sc_sc_AbortGame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_AbortGame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(_sc_AbortGame, 1);
 	_sc_AbortGame(scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (int inum)
-RuntimeScriptValue Sc_add_inventory(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_add_inventory(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(add_inventory);
 }
 
 // void (int charid, int inum)
-RuntimeScriptValue Sc_AddInventoryToCharacter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AddInventoryToCharacter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(AddInventoryToCharacter);
 }
 
 // void (int guin, int objn, int view, int loop, int speed, int repeat)
-RuntimeScriptValue Sc_AnimateButton(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AnimateButton(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT6(AnimateButton);
 }
 
 // void  (int chh, int loopn, int sppd, int rept)
-RuntimeScriptValue Sc_scAnimateCharacter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_scAnimateCharacter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(scAnimateCharacter);
 }
 
 // void (int chh, int loopn, int sppd, int rept, int direction, int blocking)
-RuntimeScriptValue Sc_AnimateCharacterEx(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AnimateCharacterEx(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT6(AnimateCharacterEx);
 }
 
 // void (int obn,int loopn,int spdd,int rept)
-RuntimeScriptValue Sc_AnimateObject(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AnimateObject(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(AnimateObject);
 }
 
 // void (int obn,int loopn,int spdd,int rept, int direction, int blocking)
-RuntimeScriptValue Sc_AnimateObjectEx(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AnimateObjectEx(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT6(AnimateObjectEx);
 }
 
 // int (int cchar1,int cchar2)
-RuntimeScriptValue Sc_AreCharactersColliding(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AreCharactersColliding(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(AreCharactersColliding);
 }
 
 // int (int charid,int objid)
-RuntimeScriptValue Sc_AreCharObjColliding(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AreCharObjColliding(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(AreCharObjColliding);
 }
 
 // int (int obj1,int obj2)
-RuntimeScriptValue Sc_AreObjectsColliding(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AreObjectsColliding(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(AreObjectsColliding);
 }
 
 // int (int thing1, int thing2)
-RuntimeScriptValue Sc_AreThingsOverlapping(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_AreThingsOverlapping(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(AreThingsOverlapping);
 }
 
 // void  (int value)
-RuntimeScriptValue Sc_CallRoomScript(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_CallRoomScript(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(CallRoomScript);
 }
 
 // int (int cmdd,int datt)
-RuntimeScriptValue Sc_cd_manager(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_cd_manager(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(cd_manager);
 }
 
 // void  (int ifn)
-RuntimeScriptValue Sc_CentreGUI(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_CentreGUI(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(CentreGUI);
 }
 
 // void (int chaa,int vii)
-RuntimeScriptValue Sc_ChangeCharacterView(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ChangeCharacterView(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(ChangeCharacterView);
 }
 
-extern RuntimeScriptValue Sc_ChangeCursorGraphic(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_ChangeCursorGraphic(const RuntimeScriptValue *params, int32_t param_count);
 
-extern RuntimeScriptValue Sc_ChangeCursorHotspot(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_ChangeCursorHotspot(const RuntimeScriptValue *params, int32_t param_count);
 
 // void ()
-RuntimeScriptValue Sc_ClaimEvent(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ClaimEvent(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(ClaimEvent);
 }
 
 // int (int xx,int yy,int slott,int trans)
-RuntimeScriptValue Sc_CreateGraphicOverlay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_CreateGraphicOverlay(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT4(CreateGraphicOverlay);
 }
 
 // int (int xx,int yy,int wii,int fontid,int clr,char*texx, ...)
-RuntimeScriptValue Sc_CreateTextOverlay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_CreateTextOverlay(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(CreateTextOverlay, 6);
 	return RuntimeScriptValue().SetInt32(
 	           CreateTextOverlay(params[0].IValue, params[1].IValue, params[2].IValue,
@@ -191,1585 +191,1585 @@ RuntimeScriptValue Sc_CreateTextOverlay(const RuntimeScriptValue *params, int pa
 }
 
 // void (int strt,int eend)
-RuntimeScriptValue Sc_CyclePalette(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_CyclePalette(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(CyclePalette);
 }
 
 // void (int cmdd,int dataa)
-RuntimeScriptValue Sc_script_debug(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_script_debug(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(script_debug);
 }
 
 // void  (int slnum)
-RuntimeScriptValue Sc_DeleteSaveSlot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DeleteSaveSlot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(DeleteSaveSlot);
 }
 
 // void  (int gotSlot)
-RuntimeScriptValue Sc_free_dynamic_sprite(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_free_dynamic_sprite(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(free_dynamic_sprite);
 }
 
-extern RuntimeScriptValue Sc_disable_cursor_mode(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_disable_cursor_mode(const RuntimeScriptValue *params, int32_t param_count);
 
 // void (int alsoEffects)
-RuntimeScriptValue Sc_DisableGroundLevelAreas(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisableGroundLevelAreas(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(DisableGroundLevelAreas);
 }
 
 // void (int hsnum)
-RuntimeScriptValue Sc_DisableHotspot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisableHotspot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(DisableHotspot);
 }
 
 // void ()
-RuntimeScriptValue Sc_DisableInterface(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisableInterface(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(DisableInterface);
 }
 
 // void (int hsnum)
-RuntimeScriptValue Sc_DisableRegion(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisableRegion(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(DisableRegion);
 }
 
 // void (char*texx, ...)
-RuntimeScriptValue Sc_Display(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Display(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(Display, 1);
 	DisplaySimple(scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (int xxp,int yyp,int widd,char*texx, ...)
-RuntimeScriptValue Sc_DisplayAt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplayAt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(DisplayAt, 4);
 	DisplayAt(params[0].IValue, params[1].IValue, params[2].IValue, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void  (int ypos, char *texx)
-RuntimeScriptValue Sc_DisplayAtY(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplayAtY(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(DisplayAtY, const char);
 }
 
 // void (int msnum)
-RuntimeScriptValue Sc_DisplayMessage(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplayMessage(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(DisplayMessage);
 }
 
 // void (int msnum, int ypos)
-RuntimeScriptValue Sc_DisplayMessageAtY(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplayMessageAtY(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(DisplayMessageAtY);
 }
 
 // void (int ypos, int ttexcol, int backcol, char *title, int msgnum)
-RuntimeScriptValue Sc_DisplayMessageBar(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplayMessageBar(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3_POBJ_PINT(DisplayMessageBar, const char);
 }
 
 // void (int chid,char*texx, ...)
-RuntimeScriptValue Sc_sc_displayspeech(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_displayspeech(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(DisplayAt, 2);
 	__sc_displayspeech(params[0].IValue, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void  (int xx, int yy, int wii, int aschar, char*spch)
-RuntimeScriptValue Sc_DisplaySpeechAt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplaySpeechAt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4_POBJ(DisplaySpeechAt, const char);
 }
 
 // int (int charid,char*speel)
-RuntimeScriptValue Sc_DisplaySpeechBackground(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplaySpeechBackground(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT_POBJ(DisplaySpeechBackground, const char);
 }
 
 // void (int chid, const char*texx, ...)
-RuntimeScriptValue Sc_DisplayThought(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplayThought(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(DisplayThought, 2);
 	DisplayThought(params[0].IValue, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (int ypos, int ttexcol, int backcol, char *title, char*texx, ...)
-RuntimeScriptValue Sc_DisplayTopBar(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_DisplayTopBar(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(DisplayTopBar, 5);
 	DisplayTopBar(params[0].IValue, params[1].IValue, params[2].IValue, params[3].Ptr, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
-extern RuntimeScriptValue Sc_enable_cursor_mode(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_enable_cursor_mode(const RuntimeScriptValue *params, int32_t param_count);
 
 // void ()
-RuntimeScriptValue Sc_EnableGroundLevelAreas(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_EnableGroundLevelAreas(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(EnableGroundLevelAreas);
 }
 
 // void (int hsnum)
-RuntimeScriptValue Sc_EnableHotspot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_EnableHotspot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(EnableHotspot);
 }
 
 // void ()
-RuntimeScriptValue Sc_EnableInterface(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_EnableInterface(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(EnableInterface);
 }
 
 // void (int hsnum)
-RuntimeScriptValue Sc_EnableRegion(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_EnableRegion(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(EnableRegion);
 }
 
 // int  ()
-RuntimeScriptValue Sc_EndCutscene(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_EndCutscene(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(EndCutscene);
 }
 
 // void (int cha,int toface)
-RuntimeScriptValue Sc_FaceCharacter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FaceCharacter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(FaceCharacter);
 }
 
 // void (int cha, int xx, int yy)
-RuntimeScriptValue Sc_FaceLocation(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FaceLocation(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(FaceLocation);
 }
 
 // void (int sppd)
-RuntimeScriptValue Sc_FadeIn(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FadeIn(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(FadeIn);
 }
 
 // void (int spdd)
-RuntimeScriptValue Sc_my_fade_out(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_my_fade_out(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(my_fade_out);
 }
 
 // void (int handle)
-RuntimeScriptValue Sc_FileClose(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileClose(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(FileClose);
 }
 
 // int  (int handle)
-RuntimeScriptValue Sc_FileIsEOF(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileIsEOF(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(FileIsEOF);
 }
 
 // int (int handle)
-RuntimeScriptValue Sc_FileIsError(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileIsError(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(FileIsError);
 }
 
 // int (const char*fnmm, const char* cmode)
-RuntimeScriptValue Sc_FileOpenCMode(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileOpenCMode(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ2(FileOpenCMode, const char, const char);
 }
 
 // void (int handle,char*toread)
-RuntimeScriptValue Sc_FileRead(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileRead(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(FileRead, char);
 }
 
 // int (int handle)
-RuntimeScriptValue Sc_FileReadInt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileReadInt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(FileReadInt);
 }
 
 // char (int handle)
-RuntimeScriptValue Sc_FileReadRawChar(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileReadRawChar(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(FileReadRawChar);
 }
 
 // int (int handle)
-RuntimeScriptValue Sc_FileReadRawInt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileReadRawInt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(FileReadRawInt);
 }
 
 // void (int handle, const char *towrite)
-RuntimeScriptValue Sc_FileWrite(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileWrite(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(FileWrite, const char);
 }
 
 // void (int handle,int into)
-RuntimeScriptValue Sc_FileWriteInt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileWriteInt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(FileWriteInt);
 }
 
 // void (int handle, int chartoWrite)
-RuntimeScriptValue Sc_FileWriteRawChar(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileWriteRawChar(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(FileWriteRawChar);
 }
 
 // void (int handle, const char*towrite)
-RuntimeScriptValue Sc_FileWriteRawLine(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FileWriteRawLine(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(FileWriteRawLine, const char);
 }
 
 // int  (const char* GUIName)
-RuntimeScriptValue Sc_FindGUIID(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FindGUIID(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(FindGUIID, const char);
 }
 
 // void (int amount)
-RuntimeScriptValue Sc_FlipScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FlipScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(FlipScreen);
 }
 
 // int (SCRIPT_FLOAT(value), int roundDirection)
-RuntimeScriptValue Sc_FloatToInt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FloatToInt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PFLOAT_PINT(FloatToInt);
 }
 
 // void (int who, int tofollow)
-RuntimeScriptValue Sc_FollowCharacter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FollowCharacter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(FollowCharacter);
 }
 
 // void (int who, int tofollow, int distaway, int eagerness)
-RuntimeScriptValue Sc_FollowCharacterEx(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_FollowCharacterEx(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(FollowCharacterEx);
 }
 
 // int ()
-RuntimeScriptValue Sc_GetBackgroundFrame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetBackgroundFrame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetBackgroundFrame);
 }
 
 // int (int guin, int objn, int ptype)
-RuntimeScriptValue Sc_GetButtonPic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetButtonPic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT3(GetButtonPic);
 }
 
 // int  (int xx, int yy)
-RuntimeScriptValue Sc_GetCharIDAtScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetCharIDAtScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetCharIDAtScreen);
 }
 
 // int  (int cha, const char *property)
-RuntimeScriptValue Sc_GetCharacterProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetCharacterProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT_POBJ(GetCharacterProperty, const char);
 }
 
 // void  (int item, const char *property, char *bufer)
-RuntimeScriptValue Sc_GetCharacterPropertyText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetCharacterPropertyText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ2(GetCharacterPropertyText, const char, char);
 }
 
 // int ()
-RuntimeScriptValue Sc_GetCurrentMusic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetCurrentMusic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetCurrentMusic);
 }
 
-extern RuntimeScriptValue Sc_GetCursorMode(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_GetCursorMode(const RuntimeScriptValue *params, int32_t param_count);
 
 // int  (int dlg, int opt)
-RuntimeScriptValue Sc_GetDialogOption(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetDialogOption(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetDialogOption);
 }
 
 // int  (int opt)
-RuntimeScriptValue Sc_GetGameOption(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGameOption(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetGameOption);
 }
 
 // int  (int parm, int data1, int data2, int data3)
-RuntimeScriptValue Sc_GetGameParameter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGameParameter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT4(GetGameParameter);
 }
 
 // int ()
-RuntimeScriptValue Sc_GetGameSpeed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGameSpeed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetGameSpeed);
 }
 
 // int (int index)
-RuntimeScriptValue Sc_GetGlobalInt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGlobalInt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetGlobalInt);
 }
 
 // void  (int index, char *strval)
-RuntimeScriptValue Sc_GetGlobalString(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGlobalString(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(GetGlobalString, char);
 }
 
 // int  (const char *varName)
-RuntimeScriptValue Sc_GetGraphicalVariable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGraphicalVariable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(GetGraphicalVariable, const char);
 }
 
 // int  (int xx,int yy)
-RuntimeScriptValue Sc_GetGUIAt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGUIAt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetGUIAt);
 }
 
 // int  (int xx, int yy)
-RuntimeScriptValue Sc_GetGUIObjectAt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGUIObjectAt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetGUIObjectAt);
 }
 
 // int (int xxx,int yyy)
-RuntimeScriptValue Sc_GetHotspotIDAtScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetHotspotIDAtScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetHotspotIDAtScreen);
 }
 
 // void (int hotspot, char *buffer)
-RuntimeScriptValue Sc_GetHotspotName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetHotspotName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(GetHotspotName, char);
 }
 
 // int  (int hotspot)
-RuntimeScriptValue Sc_GetHotspotPointX(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetHotspotPointX(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetHotspotPointX);
 }
 
 // int  (int hotspot)
-RuntimeScriptValue Sc_GetHotspotPointY(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetHotspotPointY(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetHotspotPointY);
 }
 
 // int  (int hss, const char *property)
-RuntimeScriptValue Sc_GetHotspotProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetHotspotProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT_POBJ(GetHotspotProperty, const char);
 }
 
 // void  (int item, const char *property, char *bufer)
-RuntimeScriptValue Sc_GetHotspotPropertyText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetHotspotPropertyText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ2(GetHotspotPropertyText, const char, char);
 }
 
 // int  (int xxx, int yyy)
-RuntimeScriptValue Sc_GetInvAt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetInvAt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetInvAt);
 }
 
 // int (int indx)
-RuntimeScriptValue Sc_GetInvGraphic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetInvGraphic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetInvGraphic);
 }
 
 // void (int indx,char*buff)
-RuntimeScriptValue Sc_GetInvName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetInvName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(GetInvName, char);
 }
 
 // int  (int item, const char *property)
-RuntimeScriptValue Sc_GetInvProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetInvProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT_POBJ(GetInvProperty, const char);
 }
 
 // void  (int item, const char *property, char *bufer)
-RuntimeScriptValue Sc_GetInvPropertyText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetInvPropertyText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ2(GetInvPropertyText, const char, char);
 }
 
 // void (int xxx,int yyy,char*tempo)
-RuntimeScriptValue Sc_GetLocationName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetLocationName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2_POBJ(GetLocationName, char);
 }
 
 // int (int xxx,int yyy)
-RuntimeScriptValue Sc_GetLocationType(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetLocationType(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetLocationType);
 }
 
 // void  (int msg, char *buffer)
-RuntimeScriptValue Sc_GetMessageText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetMessageText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(GetMessageText, char);
 }
 
 // int  ()
-RuntimeScriptValue Sc_GetMIDIPosition(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetMIDIPosition(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetMIDIPosition);
 }
 
 // int  ()
-RuntimeScriptValue Sc_GetMP3PosMillis(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetMP3PosMillis(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetMP3PosMillis);
 }
 
 // int (int xx,int yy)
-RuntimeScriptValue Sc_GetObjectIDAtScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectIDAtScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetObjectIDAtScreen);
 }
 
 // int (int obn)
-RuntimeScriptValue Sc_GetObjectBaseline(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectBaseline(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetObjectBaseline);
 }
 
 // int (int obn)
-RuntimeScriptValue Sc_GetObjectGraphic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectGraphic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetObjectGraphic);
 }
 
 // void (int obj, char *buffer)
-RuntimeScriptValue Sc_GetObjectName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(GetObjectName, char);
 }
 
 // int  (int hss, const char *property)
-RuntimeScriptValue Sc_GetObjectProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT_POBJ(GetObjectProperty, const char);
 }
 
 // void  (int item, const char *property, char *bufer)
-RuntimeScriptValue Sc_GetObjectPropertyText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectPropertyText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ2(GetObjectPropertyText, const char, char);
 }
 
 // int  (int objj)
-RuntimeScriptValue Sc_GetObjectX(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectX(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetObjectX);
 }
 
 // int  (int objj)
-RuntimeScriptValue Sc_GetObjectY(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectY(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetObjectY);
 }
 
 // int ()
-RuntimeScriptValue Sc_GetPlayerCharacter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetPlayerCharacter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetPlayerCharacter);
 }
 
 // int  ()
-RuntimeScriptValue Sc_GetRawTime(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetRawTime(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetRawTime);
 }
 
 // int  (int xxx, int yyy)
-RuntimeScriptValue Sc_GetRegionIDAtRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetRegionIDAtRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetRegionIDAtRoom);
 }
 
 // void  (const char *property, char *bufer)
-RuntimeScriptValue Sc_GetRoomPropertyText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetRoomPropertyText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_POBJ2(GetRoomPropertyText, const char, char);
 }
 
 // int (int slnum,char*desbuf)
-RuntimeScriptValue Sc_GetSaveSlotDescription(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetSaveSlotDescription(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT_POBJ(GetSaveSlotDescription, char);
 }
 
 // int  (int x, int y)
-RuntimeScriptValue Sc_GetScalingAt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetScalingAt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetScalingAt);
 }
 
 // int (int guin,int objn)
-RuntimeScriptValue Sc_GetSliderValue(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetSliderValue(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetSliderValue);
 }
 
 // void (int guin, int objn, char*txbuf)
-RuntimeScriptValue Sc_GetTextBoxText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetTextBoxText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2_POBJ(GetTextBoxText, char);
 }
 
 // int (char *text, int fontnum, int width)
-RuntimeScriptValue Sc_GetTextHeight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetTextHeight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ_PINT2(GetTextHeight, const char);
 }
 
 // int (char *text, int fontnum)
-RuntimeScriptValue Sc_GetTextWidth(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetTextWidth(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ_PINT(GetTextWidth, const char);
 }
 
-RuntimeScriptValue Sc_GetFontHeight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetFontHeight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetFontHeight);
 }
 
-RuntimeScriptValue Sc_GetFontLineSpacing(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetFontLineSpacing(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(GetFontLineSpacing);
 }
 
 // int (int whatti)
-RuntimeScriptValue Sc_sc_GetTime(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_GetTime(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(sc_GetTime);
 }
 
 // char * (const char *text)
-RuntimeScriptValue Sc_get_translation(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_get_translation(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ_POBJ(const char, myScriptStringImpl, get_translation, const char);
 }
 
 // int  (char* buffer)
-RuntimeScriptValue Sc_GetTranslationName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetTranslationName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(GetTranslationName, char);
 }
 
 // int  ()
-RuntimeScriptValue Sc_GetViewportX(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetViewportX(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetViewportX);
 }
 
 // int  ()
-RuntimeScriptValue Sc_GetViewportY(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetViewportY(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetViewportY);
 }
 
-RuntimeScriptValue Sc_GetWalkableAreaAtRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetWalkableAreaAtRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetWalkableAreaAtRoom);
 }
 
 // int (int xxx,int yyy)
-RuntimeScriptValue Sc_GetWalkableAreaAtScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetWalkableAreaAtScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(GetWalkableAreaAtScreen);
 }
 
-RuntimeScriptValue Sc_GetDrawingSurfaceForWalkableArea(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetDrawingSurfaceForWalkableArea(const RuntimeScriptValue *params, int32_t param_count) {
 	ScriptDrawingSurface *ret_obj = Room_GetDrawingSurfaceForMask(kRoomAreaWalkable);
 	return RuntimeScriptValue().SetDynamicObject(ret_obj, ret_obj);
 }
 
-RuntimeScriptValue Sc_GetDrawingSurfaceForWalkbehind(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetDrawingSurfaceForWalkbehind(const RuntimeScriptValue *params, int32_t param_count) {
 	ScriptDrawingSurface *ret_obj = Room_GetDrawingSurfaceForMask(kRoomAreaWalkBehind);
 	return RuntimeScriptValue().SetDynamicObject(ret_obj, ret_obj);
 }
 
 // void (int amnt)
-RuntimeScriptValue Sc_GiveScore(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GiveScore(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(GiveScore);
 }
 
 // int (int roomnum)
-RuntimeScriptValue Sc_HasPlayerBeenInRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_HasPlayerBeenInRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(HasPlayerBeenInRoom);
 }
 
 // void  ()
-RuntimeScriptValue Sc_HideMouseCursor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_HideMouseCursor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(HideMouseCursor);
 }
 
 // void (const char*msg,char*bufr)
-RuntimeScriptValue Sc_sc_inputbox(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_inputbox(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_POBJ2(sc_inputbox, const char, char);
 }
 
 // void (int ifn)
-RuntimeScriptValue Sc_InterfaceOff(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InterfaceOff(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(InterfaceOff);
 }
 
 // void (int ifn)
-RuntimeScriptValue Sc_InterfaceOn(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InterfaceOn(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(InterfaceOn);
 }
 
 // FLOAT_RETURN_TYPE (int value)
-RuntimeScriptValue Sc_IntToFloat(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IntToFloat(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PINT(IntToFloat);
 }
 
 // void ()
-RuntimeScriptValue Sc_sc_invscreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_invscreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(sc_invscreen);
 }
 
-extern RuntimeScriptValue Sc_IsButtonDown(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_IsButtonDown(const RuntimeScriptValue *params, int32_t param_count);
 
 // int (int chan)
-RuntimeScriptValue Sc_IsChannelPlaying(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsChannelPlaying(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsChannelPlaying);
 }
 
 // int ()
-RuntimeScriptValue Sc_IsGamePaused(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsGamePaused(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(IsGamePaused);
 }
 
 // int  (int guinum)
-RuntimeScriptValue Sc_IsGUIOn(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsGUIOn(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsGUIOn);
 }
 
 // int  (int xx,int yy,int mood)
-RuntimeScriptValue Sc_IsInteractionAvailable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsInteractionAvailable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT3(IsInteractionAvailable);
 }
 
 // int  (int item, int mood)
-RuntimeScriptValue Sc_IsInventoryInteractionAvailable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsInventoryInteractionAvailable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(IsInventoryInteractionAvailable);
 }
 
 // int ()
-RuntimeScriptValue Sc_IsInterfaceEnabled(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsInterfaceEnabled(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(IsInterfaceEnabled);
 }
 
 // int  (int keycode)
-RuntimeScriptValue Sc_IsKeyPressed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsKeyPressed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsKeyPressed);
 }
 
 // int ()
-RuntimeScriptValue Sc_IsMusicPlaying(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsMusicPlaying(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(IsMusicPlaying);
 }
 
 // int  ()
-RuntimeScriptValue Sc_IsMusicVoxAvailable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsMusicVoxAvailable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(IsMusicVoxAvailable);
 }
 
 // int (int objj)
-RuntimeScriptValue Sc_IsObjectAnimating(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsObjectAnimating(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsObjectAnimating);
 }
 
 // int (int objj)
-RuntimeScriptValue Sc_IsObjectMoving(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsObjectMoving(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsObjectMoving);
 }
 
 // int  (int objj)
-RuntimeScriptValue Sc_IsObjectOn(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsObjectOn(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsObjectOn);
 }
 
 // int (int ovrid)
-RuntimeScriptValue Sc_IsOverlayValid(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsOverlayValid(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsOverlayValid);
 }
 
 // int ()
-RuntimeScriptValue Sc_IsSoundPlaying(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsSoundPlaying(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(IsSoundPlaying);
 }
 
 // int (int tnum)
-RuntimeScriptValue Sc_IsTimerExpired(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsTimerExpired(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsTimerExpired);
 }
 
 // int  ()
-RuntimeScriptValue Sc_IsTranslationAvailable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsTranslationAvailable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(IsTranslationAvailable);
 }
 
 // int ()
-RuntimeScriptValue Sc_IsVoxAvailable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsVoxAvailable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(IsVoxAvailable);
 }
 
 // void (int guin, int objn, const char*newitem)
-RuntimeScriptValue Sc_ListBoxAdd(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxAdd(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2_POBJ(ListBoxAdd, const char);
 }
 
 // void (int guin, int objn)
-RuntimeScriptValue Sc_ListBoxClear(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxClear(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(ListBoxClear);
 }
 
 // void  (int guin, int objn, const char*filemask)
-RuntimeScriptValue Sc_ListBoxDirList(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxDirList(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2_POBJ(ListBoxDirList, const char);
 }
 
 // char* (int guin, int objn, int item, char*buffer)
-RuntimeScriptValue Sc_ListBoxGetItemText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxGetItemText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT3_POBJ(char, myScriptStringImpl, ListBoxGetItemText, char);
 }
 
 // int (int guin, int objn)
-RuntimeScriptValue Sc_ListBoxGetNumItems(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxGetNumItems(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(ListBoxGetNumItems);
 }
 
 // int (int guin, int objn)
-RuntimeScriptValue Sc_ListBoxGetSelected(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxGetSelected(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(ListBoxGetSelected);
 }
 
 // void (int guin, int objn, int itemIndex)
-RuntimeScriptValue Sc_ListBoxRemove(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxRemove(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(ListBoxRemove);
 }
 
 // int  (int guin, int objn)
-RuntimeScriptValue Sc_ListBoxSaveGameList(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxSaveGameList(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(ListBoxSaveGameList);
 }
 
 // void (int guin, int objn, int newsel)
-RuntimeScriptValue Sc_ListBoxSetSelected(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxSetSelected(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(ListBoxSetSelected);
 }
 
 // void  (int guin, int objn, int item)
-RuntimeScriptValue Sc_ListBoxSetTopItem(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBoxSetTopItem(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(ListBoxSetTopItem);
 }
 
 // int (const char *filename)
-RuntimeScriptValue Sc_LoadImageFile(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_LoadImageFile(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(LoadImageFile, const char);
 }
 
 // int (int slnum, int width, int height)
-RuntimeScriptValue Sc_LoadSaveSlotScreenshot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_LoadSaveSlotScreenshot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT3(LoadSaveSlotScreenshot);
 }
 
 // void (int inum)
-RuntimeScriptValue Sc_lose_inventory(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_lose_inventory(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(lose_inventory);
 }
 
 // void (int charid, int inum)
-RuntimeScriptValue Sc_LoseInventoryFromCharacter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_LoseInventoryFromCharacter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(LoseInventoryFromCharacter);
 }
 
 // void (int obn)
-RuntimeScriptValue Sc_MergeObject(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MergeObject(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(MergeObject);
 }
 
 // void (int cc,int xx,int yy)
-RuntimeScriptValue Sc_MoveCharacter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveCharacter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(MoveCharacter);
 }
 
 // void (int chaa,int xx,int yy,int direct)
-RuntimeScriptValue Sc_MoveCharacterBlocking(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveCharacterBlocking(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(MoveCharacterBlocking);
 }
 
 // void (int cc,int xx, int yy)
-RuntimeScriptValue Sc_MoveCharacterDirect(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveCharacterDirect(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(MoveCharacterDirect);
 }
 
 // void  (int chac, int tox, int toy)
-RuntimeScriptValue Sc_MoveCharacterPath(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveCharacterPath(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(MoveCharacterPath);
 }
 
 // void (int cc,int xx, int yy)
-RuntimeScriptValue Sc_MoveCharacterStraight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveCharacterStraight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(MoveCharacterStraight);
 }
 
 // void (int chaa,int hotsp)
-RuntimeScriptValue Sc_MoveCharacterToHotspot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveCharacterToHotspot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(MoveCharacterToHotspot);
 }
 
 // void (int chaa,int obbj)
-RuntimeScriptValue Sc_MoveCharacterToObject(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveCharacterToObject(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(MoveCharacterToObject);
 }
 
 // void (int objj,int xx,int yy,int spp)
-RuntimeScriptValue Sc_MoveObject(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveObject(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(MoveObject);
 }
 
 // void (int objj,int xx,int yy,int spp)
-RuntimeScriptValue Sc_MoveObjectDirect(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveObjectDirect(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(MoveObjectDirect);
 }
 
 // void (int ovrid, int newx,int newy)
-RuntimeScriptValue Sc_MoveOverlay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveOverlay(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(MoveOverlay);
 }
 
 // void (int charid)
-RuntimeScriptValue Sc_MoveToWalkableArea(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_MoveToWalkableArea(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(MoveToWalkableArea);
 }
 
 // void (int nrnum)
-RuntimeScriptValue Sc_NewRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_NewRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(NewRoom);
 }
 
 // void (int nrnum,int newx,int newy)
-RuntimeScriptValue Sc_NewRoomEx(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_NewRoomEx(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(NewRoomEx);
 }
 
 // void (int charid, int nrnum, int newx, int newy)
-RuntimeScriptValue Sc_NewRoomNPC(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_NewRoomNPC(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(NewRoomNPC);
 }
 
 // void (int obn)
-RuntimeScriptValue Sc_ObjectOff(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ObjectOff(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(ObjectOff);
 }
 
 // void (int obn)
-RuntimeScriptValue Sc_ObjectOn(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ObjectOn(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(ObjectOn);
 }
 
-extern RuntimeScriptValue Sc_ParseText(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_ParseText(const RuntimeScriptValue *params, int32_t param_count);
 
 // void ()
-RuntimeScriptValue Sc_PauseGame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_PauseGame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(PauseGame);
 }
 
 // void  (int channel, int sndnum, int vol, int x, int y)
-RuntimeScriptValue Sc_PlayAmbientSound(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_PlayAmbientSound(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT5(PlayAmbientSound);
 }
 
 // void (int numb,int playflags)
-RuntimeScriptValue Sc_play_flc_file(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_play_flc_file(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(play_flc_file);
 }
 
 // void  (char *filename)
-RuntimeScriptValue Sc_PlayMP3File(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_PlayMP3File(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_POBJ(PlayMP3File, const char);
 }
 
 // void (int newmus)
-RuntimeScriptValue Sc_PlayMusicResetQueue(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_PlayMusicResetQueue(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(PlayMusicResetQueue);
 }
 
 // int (int musnum)
-RuntimeScriptValue Sc_PlayMusicQueued(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_PlayMusicQueued(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(PlayMusicQueued);
 }
 
 // void  (int mnum)
-RuntimeScriptValue Sc_PlaySilentMIDI(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_PlaySilentMIDI(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(PlaySilentMIDI);
 }
 
 // int (int val1)
-RuntimeScriptValue Sc_play_sound(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_play_sound(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(play_sound);
 }
 
 // int (int val1, int channel)
-RuntimeScriptValue Sc_PlaySoundEx(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_PlaySoundEx(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(PlaySoundEx);
 }
 
 // void (const char* name, int skip, int flags)
-RuntimeScriptValue Sc_scrPlayVideo(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_scrPlayVideo(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_POBJ_PINT2(scrPlayVideo, const char);
 }
 
 // void (int dialog)
-RuntimeScriptValue Sc_QuitGame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_QuitGame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(QuitGame);
 }
 
 // int (int upto)
-RuntimeScriptValue Sc_Rand(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Rand(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(__Rand);
 }
 
 // void  (int clr)
-RuntimeScriptValue Sc_RawClear(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawClear(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(RawClear);
 }
 
 // void  (int xx, int yy, int rad)
-RuntimeScriptValue Sc_RawDrawCircle(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawCircle(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(RawDrawCircle);
 }
 
 // void  (int frame, int translev)
-RuntimeScriptValue Sc_RawDrawFrameTransparent(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawFrameTransparent(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(RawDrawFrameTransparent);
 }
 
 // void (int xx, int yy, int slot)
-RuntimeScriptValue Sc_RawDrawImage(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawImage(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(RawDrawImage);
 }
 
 // void (int xx, int yy, int slot)
-RuntimeScriptValue Sc_RawDrawImageOffset(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawImageOffset(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(RawDrawImageOffset);
 }
 
 // void (int xx, int yy, int gotSlot, int width, int height)
-RuntimeScriptValue Sc_RawDrawImageResized(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawImageResized(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT5(RawDrawImageResized);
 }
 
 // void (int xx, int yy, int slot, int trans)
-RuntimeScriptValue Sc_RawDrawImageTransparent(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawImageTransparent(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(RawDrawImageTransparent);
 }
 
 // void  (int fromx, int fromy, int tox, int toy)
-RuntimeScriptValue Sc_RawDrawLine(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawLine(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(RawDrawLine);
 }
 
 // void (int x1, int y1, int x2, int y2)
-RuntimeScriptValue Sc_RawDrawRectangle(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawRectangle(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(RawDrawRectangle);
 }
 
 // void (int x1, int y1, int x2, int y2, int x3, int y3)
-RuntimeScriptValue Sc_RawDrawTriangle(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawDrawTriangle(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT6(RawDrawTriangle);
 }
 
 // void  (int xx, int yy, char*texx, ...)
-RuntimeScriptValue Sc_RawPrint(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawPrint(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(RawPrint, 3);
 	RawPrint(params[0].IValue, params[1].IValue, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void  (int xx, int yy, int wid, int font, int msgm)
-RuntimeScriptValue Sc_RawPrintMessageWrapped(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawPrintMessageWrapped(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT5(RawPrintMessageWrapped);
 }
 
 // void ()
-RuntimeScriptValue Sc_RawRestoreScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawRestoreScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(RawRestoreScreen);
 }
 
 // void (int red, int green, int blue, int opacity)
-RuntimeScriptValue Sc_RawRestoreScreenTinted(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawRestoreScreenTinted(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(RawRestoreScreenTinted);
 }
 
 // void  ()
-RuntimeScriptValue Sc_RawSaveScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawSaveScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(RawSaveScreen);
 }
 
 // void  (int clr)
-RuntimeScriptValue Sc_RawSetColor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawSetColor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(RawSetColor);
 }
 
 // void (int red, int grn, int blu)
-RuntimeScriptValue Sc_RawSetColorRGB(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RawSetColorRGB(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(RawSetColorRGB);
 }
 
-extern RuntimeScriptValue Sc_RefreshMouse(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_RefreshMouse(const RuntimeScriptValue *params, int32_t param_count);
 
 // void (int chat)
-RuntimeScriptValue Sc_ReleaseCharacterView(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ReleaseCharacterView(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(ReleaseCharacterView);
 }
 
 // void ()
-RuntimeScriptValue Sc_ReleaseViewport(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ReleaseViewport(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(ReleaseViewport);
 }
 
 // void (int obj)
-RuntimeScriptValue Sc_RemoveObjectTint(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RemoveObjectTint(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(RemoveObjectTint);
 }
 
 // void (int ovrid)
-RuntimeScriptValue Sc_RemoveOverlay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RemoveOverlay(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(RemoveOverlay);
 }
 
 // void (int areanum)
-RuntimeScriptValue Sc_RemoveWalkableArea(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RemoveWalkableArea(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(RemoveWalkableArea);
 }
 
 // void (int nrnum)
-RuntimeScriptValue Sc_ResetRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ResetRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(ResetRoom);
 }
 
 // void ()
-RuntimeScriptValue Sc_restart_game(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_restart_game(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(restart_game);
 }
 
 // void ()
-RuntimeScriptValue Sc_restore_game_dialog(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_restore_game_dialog(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(restore_game_dialog);
 }
 
 // void (int slnum)
-RuntimeScriptValue Sc_RestoreGameSlot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RestoreGameSlot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(RestoreGameSlot);
 }
 
 // void (int areanum)
-RuntimeScriptValue Sc_RestoreWalkableArea(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RestoreWalkableArea(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(RestoreWalkableArea);
 }
 
 // int  (char *newgame, unsigned int mode, int data)
-RuntimeScriptValue Sc_RunAGSGame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RunAGSGame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ_PINT2(RunAGSGame, const char);
 }
 
 // void  (int cc, int mood)
-RuntimeScriptValue Sc_RunCharacterInteraction(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RunCharacterInteraction(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(RunCharacterInteraction);
 }
 
 // void (int tum)
-RuntimeScriptValue Sc_RunDialog(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RunDialog(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(RunDialog);
 }
 
 // void  (int hotspothere, int mood)
-RuntimeScriptValue Sc_RunHotspotInteraction(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RunHotspotInteraction(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(RunHotspotInteraction);
 }
 
 // void  (int iit, int modd)
-RuntimeScriptValue Sc_RunInventoryInteraction(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RunInventoryInteraction(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(RunInventoryInteraction);
 }
 
 // void  (int aa, int mood)
-RuntimeScriptValue Sc_RunObjectInteraction(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RunObjectInteraction(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(RunObjectInteraction);
 }
 
 // void  (int regnum, int mood)
-RuntimeScriptValue Sc_RunRegionInteraction(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RunRegionInteraction(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(RunRegionInteraction);
 }
 
-extern RuntimeScriptValue Sc_Said(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_Said(const RuntimeScriptValue *params, int32_t param_count);
 
 // int  (char*buffer)
-RuntimeScriptValue Sc_SaidUnknownWord(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SaidUnknownWord(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(SaidUnknownWord, char);
 }
 
-extern RuntimeScriptValue Sc_SaveCursorForLocationChange(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SaveCursorForLocationChange(const RuntimeScriptValue *params, int32_t param_count);
 
 // void ()
-RuntimeScriptValue Sc_save_game_dialog(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_save_game_dialog(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(save_game_dialog);
 }
 
 // void (int slotn, const char*descript)
-RuntimeScriptValue Sc_save_game(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_save_game(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(save_game, const char);
 }
 
 // int (char*namm)
-RuntimeScriptValue Sc_SaveScreenShot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SaveScreenShot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(SaveScreenShot, const char);
 }
 
 // void  (int position)
-RuntimeScriptValue Sc_SeekMIDIPosition(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SeekMIDIPosition(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SeekMIDIPosition);
 }
 
 // void (int patnum)
-RuntimeScriptValue Sc_SeekMODPattern(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SeekMODPattern(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SeekMODPattern);
 }
 
 // void  (int posn)
-RuntimeScriptValue Sc_SeekMP3PosMillis(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SeekMP3PosMillis(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SeekMP3PosMillis);
 }
 
 // void (int iit)
-RuntimeScriptValue Sc_SetActiveInventory(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetActiveInventory(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetActiveInventory);
 }
 
 // void  (int red, int green, int blue, int opacity, int luminance)
-RuntimeScriptValue Sc_SetAmbientTint(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetAmbientTint(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT5(SetAmbientTint);
 }
 
-RuntimeScriptValue Sc_SetAmbientLightLevel(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetAmbientLightLevel(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetAmbientLightLevel);
 }
 
 // void (int area, int brightness)
-RuntimeScriptValue Sc_SetAreaLightLevel(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetAreaLightLevel(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetAreaLightLevel);
 }
 
 // void (int area, int min, int max)
-RuntimeScriptValue Sc_SetAreaScaling(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetAreaScaling(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetAreaScaling);
 }
 
 // void (int frnum)
-RuntimeScriptValue Sc_SetBackgroundFrame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetBackgroundFrame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetBackgroundFrame);
 }
 
 // void (int guin,int objn,int ptype,int slotn)
-RuntimeScriptValue Sc_SetButtonPic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetButtonPic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetButtonPic);
 }
 
 // void (int guin,int objn,char*newtx)
-RuntimeScriptValue Sc_SetButtonText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetButtonText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2_POBJ(SetButtonText, const char);
 }
 
 // void (int chan, int newvol)
-RuntimeScriptValue Sc_SetChannelVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetChannelVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetChannelVolume);
 }
 
 // void  (int obn, int basel)
-RuntimeScriptValue Sc_SetCharacterBaseline(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterBaseline(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetCharacterBaseline);
 }
 
 // void  (int cha, int clik)
-RuntimeScriptValue Sc_SetCharacterClickable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterClickable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetCharacterClickable);
 }
 
 // void (int chaa, int view, int loop, int frame)
-RuntimeScriptValue Sc_SetCharacterFrame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterFrame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetCharacterFrame);
 }
 
 // void (int who, int iview, int itime)
-RuntimeScriptValue Sc_SetCharacterIdle(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterIdle(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetCharacterIdle);
 }
 
 // void  (int who, int yesorno)
-RuntimeScriptValue Sc_SetCharacterIgnoreLight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterIgnoreLight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetCharacterIgnoreLight);
 }
 
 // void  (int cha, int clik)
-RuntimeScriptValue Sc_SetCharacterIgnoreWalkbehinds(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterIgnoreWalkbehinds(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetCharacterIgnoreWalkbehinds);
 }
 
 // void  (int who, int flag, int yesorno)
-RuntimeScriptValue Sc_SetCharacterProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetCharacterProperty);
 }
 
 // void  (int chaa, int vii, int intrv)
-RuntimeScriptValue Sc_SetCharacterBlinkView(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterBlinkView(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetCharacterBlinkView);
 }
 
 // void  (int chaa, int vii)
-RuntimeScriptValue Sc_SetCharacterSpeechView(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterSpeechView(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetCharacterSpeechView);
 }
 
 // void (int chaa,int nspeed)
-RuntimeScriptValue Sc_SetCharacterSpeed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterSpeed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetCharacterSpeed);
 }
 
 // void (int chaa, int xspeed, int yspeed)
-RuntimeScriptValue Sc_SetCharacterSpeedEx(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterSpeedEx(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetCharacterSpeedEx);
 }
 
 // void (int obn,int trans)
-RuntimeScriptValue Sc_SetCharacterTransparency(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterTransparency(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetCharacterTransparency);
 }
 
 // void (int chaa,int vii)
-RuntimeScriptValue Sc_SetCharacterView(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterView(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetCharacterView);
 }
 
 // void  (int chaa, int vii, int loop, int align)
-RuntimeScriptValue Sc_SetCharacterViewEx(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterViewEx(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetCharacterViewEx);
 }
 
 // void  (int chaa, int vii, int xoffs, int yoffs)
-RuntimeScriptValue Sc_SetCharacterViewOffset(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetCharacterViewOffset(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetCharacterViewOffset);
 }
 
-extern RuntimeScriptValue Sc_set_cursor_mode(const RuntimeScriptValue *params, int param_count);
-extern RuntimeScriptValue Sc_set_default_cursor(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_set_cursor_mode(const RuntimeScriptValue *params, int32_t param_count);
+extern RuntimeScriptValue Sc_set_default_cursor(const RuntimeScriptValue *params, int32_t param_count);
 
 // void (int dlg,int opt,int onoroff)
-RuntimeScriptValue Sc_SetDialogOption(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetDialogOption(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetDialogOption);
 }
 
 // void  (int newvol)
-RuntimeScriptValue Sc_SetDigitalMasterVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetDigitalMasterVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetDigitalMasterVolume);
 }
 
 // void (int red, int green, int blue)
-RuntimeScriptValue Sc_SetFadeColor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetFadeColor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetFadeColor);
 }
 
 // void  (int vii, int loop, int frame, int sound)
-RuntimeScriptValue Sc_SetFrameSound(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetFrameSound(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetFrameSound);
 }
 
 // int  (int opt, int setting)
-RuntimeScriptValue Sc_SetGameOption(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGameOption(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT2(SetGameOption);
 }
 
 // void (int newspd)
-RuntimeScriptValue Sc_SetGameSpeed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGameSpeed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetGameSpeed);
 }
 
 // void (int index,int valu)
-RuntimeScriptValue Sc_SetGlobalInt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGlobalInt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetGlobalInt);
 }
 
-extern RuntimeScriptValue Sc_SetGlobalString(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SetGlobalString(const RuntimeScriptValue *params, int32_t param_count);
 
 // void  (const char *varName, int p_value)
-RuntimeScriptValue Sc_SetGraphicalVariable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGraphicalVariable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_POBJ_PINT(SetGraphicalVariable, const char);
 }
 
 // void  (int guin, int slotn)
-RuntimeScriptValue Sc_SetGUIBackgroundPic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUIBackgroundPic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetGUIBackgroundPic);
 }
 
 // void (int guin, int clickable)
-RuntimeScriptValue Sc_SetGUIClickable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUIClickable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetGUIClickable);
 }
 
 // void (int guin, int objn, int enabled)
-RuntimeScriptValue Sc_SetGUIObjectEnabled(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUIObjectEnabled(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetGUIObjectEnabled);
 }
 
 // void (int guin, int objn, int xx, int yy)
-RuntimeScriptValue Sc_SetGUIObjectPosition(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUIObjectPosition(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetGUIObjectPosition);
 }
 
 // void (int ifn, int objn, int newwid, int newhit)
-RuntimeScriptValue Sc_SetGUIObjectSize(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUIObjectSize(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetGUIObjectSize);
 }
 
 // void (int ifn,int xx,int yy)
-RuntimeScriptValue Sc_SetGUIPosition(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUIPosition(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetGUIPosition);
 }
 
 // void  (int ifn, int widd, int hitt)
-RuntimeScriptValue Sc_SetGUISize(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUISize(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetGUISize);
 }
 
 // void (int ifn, int trans)
-RuntimeScriptValue Sc_SetGUITransparency(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUITransparency(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetGUITransparency);
 }
 
 // void (int guin, int z)
-RuntimeScriptValue Sc_SetGUIZOrder(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetGUIZOrder(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetGUIZOrder);
 }
 
 // void (int invi, const char *newName)
-RuntimeScriptValue Sc_SetInvItemName(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetInvItemName(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT_POBJ(SetInvItemName, const char);
 }
 
 // void (int invi, int piccy)
-RuntimeScriptValue Sc_set_inv_item_pic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_set_inv_item_pic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(set_inv_item_pic);
 }
 
 // void (int ww,int hh)
-RuntimeScriptValue Sc_SetInvDimensions(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetInvDimensions(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetInvDimensions);
 }
 
 // void (int guin,int objn, int colr)
-RuntimeScriptValue Sc_SetLabelColor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetLabelColor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetLabelColor);
 }
 
 // void (int guin,int objn, int fontnum)
-RuntimeScriptValue Sc_SetLabelFont(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetLabelFont(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetLabelFont);
 }
 
 // void (int guin,int objn,char*newtx)
-RuntimeScriptValue Sc_SetLabelText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetLabelText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2_POBJ(SetLabelText, const char);
 }
 
-extern RuntimeScriptValue Sc_SetMouseBounds(const RuntimeScriptValue *params, int param_count);
-extern RuntimeScriptValue Sc_set_mouse_cursor(const RuntimeScriptValue *params, int param_count);
-extern RuntimeScriptValue Sc_SetMousePosition(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SetMouseBounds(const RuntimeScriptValue *params, int32_t param_count);
+extern RuntimeScriptValue Sc_set_mouse_cursor(const RuntimeScriptValue *params, int32_t param_count);
+extern RuntimeScriptValue Sc_SetMousePosition(const RuntimeScriptValue *params, int32_t param_count);
 
 // void  (int mode)
-RuntimeScriptValue Sc_SetMultitasking(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetMultitasking(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetMultitasking);
 }
 
 // void (int newvol)
-RuntimeScriptValue Sc_SetMusicMasterVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetMusicMasterVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetMusicMasterVolume);
 }
 
 // void (int loopflag)
-RuntimeScriptValue Sc_SetMusicRepeat(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetMusicRepeat(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetMusicRepeat);
 }
 
 // void (int newvol)
-RuntimeScriptValue Sc_SetMusicVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetMusicVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetMusicVolume);
 }
 
-extern RuntimeScriptValue Sc_SetNextCursor(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SetNextCursor(const RuntimeScriptValue *params, int32_t param_count);
 
 // void (int newtrans)
-RuntimeScriptValue Sc_SetNextScreenTransition(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetNextScreenTransition(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetNextScreenTransition);
 }
 
-extern RuntimeScriptValue Sc_SetNormalFont(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SetNormalFont(const RuntimeScriptValue *params, int32_t param_count);
 
 // void  (int obn, int basel)
-RuntimeScriptValue Sc_SetObjectBaseline(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectBaseline(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetObjectBaseline);
 }
 
 // void  (int cha, int clik)
-RuntimeScriptValue Sc_SetObjectClickable(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectClickable(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetObjectClickable);
 }
 
 // void (int obn,int viw,int lop,int fra)
-RuntimeScriptValue Sc_SetObjectFrame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectFrame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetObjectFrame);
 }
 
 // void (int obn,int slott)
-RuntimeScriptValue Sc_SetObjectGraphic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectGraphic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetObjectGraphic);
 }
 
 // void  (int cha, int clik)
-RuntimeScriptValue Sc_SetObjectIgnoreWalkbehinds(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectIgnoreWalkbehinds(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetObjectIgnoreWalkbehinds);
 }
 
 // void (int objj, int tox, int toy)
-RuntimeScriptValue Sc_SetObjectPosition(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectPosition(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetObjectPosition);
 }
 
 // void (int obj, int red, int green, int blue, int opacity, int luminance)
-RuntimeScriptValue Sc_SetObjectTint(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectTint(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT6(SetObjectTint);
 }
 
 // void (int obn,int trans)
-RuntimeScriptValue Sc_SetObjectTransparency(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectTransparency(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetObjectTransparency);
 }
 
 // void (int obn,int vii)
-RuntimeScriptValue Sc_SetObjectView(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetObjectView(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetObjectView);
 }
 
 // void (int inndx,int rr,int gg,int bb)
-RuntimeScriptValue Sc_SetPalRGB(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetPalRGB(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetPalRGB);
 }
 
 // void (int newchar)
-RuntimeScriptValue Sc_SetPlayerCharacter(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetPlayerCharacter(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetPlayerCharacter);
 }
 
 // void  (int area, int red, int green, int blue, int amount)
-RuntimeScriptValue Sc_SetRegionTint(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetRegionTint(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT5(SetRegionTint);
 }
 
 // void ()
-RuntimeScriptValue Sc_SetRestartPoint(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetRestartPoint(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(SetRestartPoint);
 }
 
 // void (int newtrans)
-RuntimeScriptValue Sc_SetScreenTransition(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetScreenTransition(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetScreenTransition);
 }
 
 // void  (int newval)
-RuntimeScriptValue Sc_SetSkipSpeech(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetSkipSpeech(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_PARAM_COUNT(SetSkipSpeech, 1);
 	SetSkipSpeech((SkipSpeechStyle)params[0].IValue);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (int guin,int objn, int valn)
-RuntimeScriptValue Sc_SetSliderValue(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetSliderValue(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetSliderValue);
 }
 
 // void (int newvol)
-RuntimeScriptValue Sc_SetSoundVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetSoundVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetSoundVolume);
 }
 
-extern RuntimeScriptValue Sc_SetSpeechFont(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SetSpeechFont(const RuntimeScriptValue *params, int32_t param_count);
 
 // void  (int newstyle)
-RuntimeScriptValue Sc_SetSpeechStyle(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetSpeechStyle(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetSpeechStyle);
 }
 
 // void (int newvol)
-RuntimeScriptValue Sc_SetSpeechVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetSpeechVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetSpeechVolume);
 }
 
 // void (int chaa,int ncol)
-RuntimeScriptValue Sc_SetTalkingColor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetTalkingColor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetTalkingColor);
 }
 
 // void (int guin,int objn, int fontnum)
-RuntimeScriptValue Sc_SetTextBoxFont(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetTextBoxFont(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(SetTextBoxFont);
 }
 
 // void (int guin, int objn, char*txbuf)
-RuntimeScriptValue Sc_SetTextBoxText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetTextBoxText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2_POBJ(SetTextBoxText, const char);
 }
 
 // void (int ovrid,int xx,int yy,int wii,int fontid,int clr,char*texx,...)
-RuntimeScriptValue Sc_SetTextOverlay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetTextOverlay(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(SetTextOverlay, 7);
 	SetTextOverlay(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue,
 	               params[4].IValue, params[5].IValue, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void  (int guinum)
-RuntimeScriptValue Sc_SetTextWindowGUI(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetTextWindowGUI(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetTextWindowGUI);
 }
 
 // void (int tnum,int timeout)
-RuntimeScriptValue Sc_script_SetTimer(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_script_SetTimer(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(script_SetTimer);
 }
 
 // void (int offsx,int offsy)
-RuntimeScriptValue Sc_SetViewport(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetViewport(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetViewport);
 }
 
 // void  (int newmod)
-RuntimeScriptValue Sc_SetVoiceMode(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetVoiceMode(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SetVoiceMode);
 }
 
 // void (int wa,int bl)
-RuntimeScriptValue Sc_SetWalkBehindBase(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetWalkBehindBase(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetWalkBehindBase);
 }
 
 // void (int severe)
-RuntimeScriptValue Sc_ShakeScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ShakeScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(ShakeScreen);
 }
 
 // void  (int delay, int amount, int length)
-RuntimeScriptValue Sc_ShakeScreenBackground(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ShakeScreenBackground(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(ShakeScreenBackground);
 }
 
 // void  ()
-RuntimeScriptValue Sc_ShowMouseCursor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ShowMouseCursor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(ShowMouseCursor);
 }
 
-RuntimeScriptValue Sc_SkipCutscene(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SkipCutscene(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(SkipCutscene);
 }
 
 // void (int cc)
-RuntimeScriptValue Sc_SkipUntilCharacterStops(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SkipUntilCharacterStops(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(SkipUntilCharacterStops);
 }
 
 // void  (int skipwith)
-RuntimeScriptValue Sc_StartCutscene(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StartCutscene(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(StartCutscene);
 }
 
 // void  (int keyToStop)
-RuntimeScriptValue Sc_scStartRecording(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_scStartRecording(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(scStartRecording);
 }
 
 // void  (int channel)
-RuntimeScriptValue Sc_StopAmbientSound(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StopAmbientSound(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(StopAmbientSound);
 }
 
 // void  (int chid)
-RuntimeScriptValue Sc_stop_and_destroy_channel(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_stop_and_destroy_channel(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(stop_and_destroy_channel);
 }
 
 // void ()
-RuntimeScriptValue Sc_StopDialog(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StopDialog(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(StopDialog);
 }
 
 // void (int chaa)
-RuntimeScriptValue Sc_StopMoving(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StopMoving(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(StopMoving);
 }
 
 // void ()
-RuntimeScriptValue Sc_scr_StopMusic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_scr_StopMusic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(scr_StopMusic);
 }
 
 // void (int objj)
-RuntimeScriptValue Sc_StopObjectMoving(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StopObjectMoving(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(StopObjectMoving);
 }
 
 // void (char*s1,char*s2)
-RuntimeScriptValue Sc_sc_strcat(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_strcat(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_PARAM_COUNT(_sc_strcat, 2);
 	_sc_strcat((char *)params[0].Ptr, (const char *)params[1].Ptr);
 	// NOTE: tests with old (<= 2.60) AGS show that StrCat returned the second string
@@ -1777,111 +1777,111 @@ RuntimeScriptValue Sc_sc_strcat(const RuntimeScriptValue *params, int param_coun
 	return params[1];
 }
 
-RuntimeScriptValue Sc_stricmp(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_stricmp(const RuntimeScriptValue *params, int32_t param_count) {
 	// Calling C stdlib function ags_stricmp
 	API_SCALL_INT_POBJ2(ags_stricmp, const char, const char);
 }
 
-RuntimeScriptValue Sc_strcmp(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_strcmp(const RuntimeScriptValue *params, int32_t param_count) {
 	// Calling C stdlib function strcmp
 	API_SCALL_INT_POBJ2(strcmp, const char, const char);
 }
 
 // int  (const char *s1, const char *s2)
-RuntimeScriptValue Sc_StrContains(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StrContains(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ2(StrContains, const char, const char);
 }
 
 // void (char*s1, const char*s2);
-RuntimeScriptValue Sc_sc_strcpy(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_strcpy(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_PARAM_COUNT(_sc_strcpy, 2);
 	_sc_strcpy((char *)params[0].Ptr, (const char *)params[1].Ptr);
 	return params[0];
 }
 
 // void (char*destt, const char*texx, ...);
-RuntimeScriptValue Sc_sc_sprintf(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_sprintf(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(_sc_sprintf, 2);
 	_sc_strcpy(params[0].Ptr, scsf_buffer);
 	return params[0];
 }
 
 // int  (char *strin, int posn)
-RuntimeScriptValue Sc_StrGetCharAt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StrGetCharAt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ_PINT(StrGetCharAt, const char);
 }
 
 // int (const char*stino)
-RuntimeScriptValue Sc_StringToInt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StringToInt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(StringToInt, const char);
 }
 
-RuntimeScriptValue Sc_strlen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_strlen(const RuntimeScriptValue *params, int32_t param_count) {
 	// Calling C stdlib function strlen
 	API_SCALL_INT_POBJ(strlen, const char);
 }
 
 // void  (char *strin, int posn, int nchar)
-RuntimeScriptValue Sc_StrSetCharAt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StrSetCharAt(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_PARAM_COUNT(StrSetCharAt, 3);
 	StrSetCharAt((char *)params[0].Ptr, params[1].IValue, params[2].IValue);
 	return params[0];
 }
 
 // void  (char *desbuf)
-RuntimeScriptValue Sc_sc_strlower(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_strlower(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_PARAM_COUNT(_sc_strlower, 1);
 	_sc_strlower((char *)params[0].Ptr);
 	return params[0];
 }
 
 // void  (char *desbuf)
-RuntimeScriptValue Sc_sc_strupper(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_sc_strupper(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_PARAM_COUNT(_sc_strupper, 1);
 	_sc_strupper((char *)params[0].Ptr);
 	return params[0];
 }
 
 // void (int red, int grn, int blu)
-RuntimeScriptValue Sc_TintScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TintScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(TintScreen);
 }
 
 // void ()
-RuntimeScriptValue Sc_UnPauseGame(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_UnPauseGame(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(UnPauseGame);
 }
 
 // void ()
-RuntimeScriptValue Sc_update_invorder(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_update_invorder(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(update_invorder);
 }
 
 // void ()
-RuntimeScriptValue Sc_UpdatePalette(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_UpdatePalette(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(UpdatePalette);
 }
 
 // void (int nloops)
-RuntimeScriptValue Sc_scrWait(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_scrWait(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(scrWait);
 }
 
 // int (int nloops)
-RuntimeScriptValue Sc_WaitKey(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_WaitKey(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(WaitKey);
 }
 
-RuntimeScriptValue Sc_WaitMouse(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_WaitMouse(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(WaitMouse);
 }
 
 // int (int nloops)
-RuntimeScriptValue Sc_WaitMouseKey(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_WaitMouseKey(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(WaitMouseKey);
 }
 
-RuntimeScriptValue Sc_SkipWait(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SkipWait(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(SkipWait);
 }
 
diff --git a/engines/ags/engine/ac/global_character.cpp b/engines/ags/engine/ac/global_character.cpp
index f6eced8db5..99e40fd043 100644
--- a/engines/ags/engine/ac/global_character.cpp
+++ b/engines/ags/engine/ac/global_character.cpp
@@ -63,7 +63,7 @@ extern ScriptInvItem scrInv[MAX_INV];
 // defined in character unit
 extern CharacterExtras *charextra;
 extern CharacterInfo *playerchar;
-extern int _sc_PlayerCharPtr;
+extern int32_t _sc_PlayerCharPtr;
 extern CharacterInfo *playerchar;
 
 
diff --git a/engines/ags/engine/ac/global_file.cpp b/engines/ags/engine/ac/global_file.cpp
index 2958939e46..56eb016c02 100644
--- a/engines/ags/engine/ac/global_file.cpp
+++ b/engines/ags/engine/ac/global_file.cpp
@@ -37,7 +37,7 @@ namespace AGS3 {
 
 using namespace AGS::Shared;
 
-int FileOpenCMode(const char *fnmm, const char *cmode) {
+int32_t FileOpenCMode(const char *fnmm, const char *cmode) {
 	Shared::FileOpenMode open_mode;
 	Shared::FileWorkMode work_mode;
 	// NOTE: here we ignore the text-mode flag. AGS 2.62 did not let
@@ -52,7 +52,7 @@ int FileOpenCMode(const char *fnmm, const char *cmode) {
 }
 
 // Find a free file slot to use
-int FindFreeFileSlot() {
+int32_t FindFreeFileSlot() {
 	int useindx = 0;
 	for (; useindx < num_open_script_files; useindx++) {
 		if (valid_handles[useindx].stream == nullptr)
@@ -67,8 +67,8 @@ int FindFreeFileSlot() {
 	return useindx;
 }
 
-int FileOpen(const char *fnmm, Shared::FileOpenMode open_mode, Shared::FileWorkMode work_mode) {
-	int useindx = FindFreeFileSlot();
+int32_t FileOpen(const char *fnmm, Shared::FileOpenMode open_mode, Shared::FileWorkMode work_mode) {
+	int32_t useindx = FindFreeFileSlot();
 	if (useindx < 0)
 		return 0;
 
@@ -96,24 +96,24 @@ int FileOpen(const char *fnmm, Shared::FileOpenMode open_mode, Shared::FileWorkM
 	return valid_handles[useindx].handle;
 }
 
-void FileClose(int handle) {
+void FileClose(int32_t handle) {
 	ScriptFileHandle *sc_handle = check_valid_file_handle_int32(handle, "FileClose");
 	delete sc_handle->stream;
 	sc_handle->stream = nullptr;
 	sc_handle->handle = 0;
 }
-void FileWrite(int handle, const char *towrite) {
+void FileWrite(int32_t handle, const char *towrite) {
 	Stream *out = get_valid_file_stream_from_handle(handle, "FileWrite");
 	out->WriteInt32(strlen(towrite) + 1);
 	out->Write(towrite, strlen(towrite) + 1);
 }
-void FileWriteRawLine(int handle, const char *towrite) {
+void FileWriteRawLine(int32_t handle, const char *towrite) {
 	Stream *out = get_valid_file_stream_from_handle(handle, "FileWriteRawLine");
 	out->Write(towrite, strlen(towrite));
 	out->WriteInt8(13);
 	out->WriteInt8(10);
 }
-void FileRead(int handle, char *toread) {
+void FileRead(int32_t handle, char *toread) {
 	VALIDATE_STRING(toread);
 	Stream *in = get_valid_file_stream_from_handle(handle, "FileRead");
 	if (in->EOS()) {
@@ -124,7 +124,7 @@ void FileRead(int handle, char *toread) {
 	if ((lle >= 200) | (lle < 1)) quit("!FileRead: file was not written by FileWrite");
 	in->Read(toread, lle);
 }
-int FileIsEOF(int handle) {
+int FileIsEOF(int32_t handle) {
 	Stream *stream = get_valid_file_stream_from_handle(handle, "FileIsEOF");
 	if (stream->EOS())
 		return 1;
@@ -137,7 +137,7 @@ int FileIsEOF(int handle) {
 		return 1;
 	return 0;
 }
-int FileIsError(int handle) {
+int FileIsError(int32_t handle) {
 	Stream *stream = get_valid_file_stream_from_handle(handle, "FileIsError");
 
 	// TODO: stream errors
@@ -146,12 +146,12 @@ int FileIsError(int handle) {
 
 	return 0;
 }
-void FileWriteInt(int handle, int into) {
+void FileWriteInt(int32_t handle, int into) {
 	Stream *out = get_valid_file_stream_from_handle(handle, "FileWriteInt");
 	out->WriteInt8('I');
 	out->WriteInt32(into);
 }
-int FileReadInt(int handle) {
+int FileReadInt(int32_t handle) {
 	Stream *in = get_valid_file_stream_from_handle(handle, "FileReadInt");
 	if (in->EOS())
 		return -1;
@@ -159,19 +159,19 @@ int FileReadInt(int handle) {
 		quit("!FileReadInt: File read back in wrong order");
 	return in->ReadInt32();
 }
-char FileReadRawChar(int handle) {
+char FileReadRawChar(int32_t handle) {
 	Stream *in = get_valid_file_stream_from_handle(handle, "FileReadRawChar");
 	if (in->EOS())
 		return -1;
 	return in->ReadInt8();
 }
-int FileReadRawInt(int handle) {
+int FileReadRawInt(int32_t handle) {
 	Stream *in = get_valid_file_stream_from_handle(handle, "FileReadRawInt");
 	if (in->EOS())
 		return -1;
 	return in->ReadInt32();
 }
-void FileWriteRawChar(int handle, int chartoWrite) {
+void FileWriteRawChar(int32_t handle, int chartoWrite) {
 	Stream *out = get_valid_file_stream_from_handle(handle, "FileWriteRawChar");
 	if ((chartoWrite < 0) || (chartoWrite > 255))
 		quit("!FileWriteRawChar: can only write values 0-255");
diff --git a/engines/ags/engine/ac/global_file.h b/engines/ags/engine/ac/global_file.h
index 035b94875b..1392c5859b 100644
--- a/engines/ags/engine/ac/global_file.h
+++ b/engines/ags/engine/ac/global_file.h
@@ -34,20 +34,20 @@ class Stream;
 
 using namespace AGS; // FIXME later
 
-int FileOpen(const char *fnmm, Shared::FileOpenMode open_mode, Shared::FileWorkMode work_mode);
+int32_t FileOpen(const char *fnmm, Shared::FileOpenMode open_mode, Shared::FileWorkMode work_mode);
 // NOTE: FileOpenCMode is a backwards-compatible replacement for old-style global script function FileOpen
-int FileOpenCMode(const char *fnmm, const char *cmode);
-void  FileClose(int handle);
-void  FileWrite(int handle, const char *towrite);
-void  FileWriteRawLine(int handle, const char *towrite);
-void  FileRead(int handle, char *toread);
-int   FileIsEOF(int handle);
-int   FileIsError(int handle);
-void  FileWriteInt(int handle, int into);
-int   FileReadInt(int handle);
-char  FileReadRawChar(int handle);
-int   FileReadRawInt(int handle);
-void  FileWriteRawChar(int handle, int chartoWrite);
+int32_t FileOpenCMode(const char *fnmm, const char *cmode);
+void  FileClose(int32_t handle);
+void  FileWrite(int32_t handle, const char *towrite);
+void  FileWriteRawLine(int32_t handle, const char *towrite);
+void  FileRead(int32_t handle, char *toread);
+int   FileIsEOF(int32_t handle);
+int   FileIsError(int32_t handle);
+void  FileWriteInt(int32_t handle, int into);
+int   FileReadInt(int32_t handle);
+char  FileReadRawChar(int32_t handle);
+int   FileReadRawInt(int32_t handle);
+void  FileWriteRawChar(int32_t handle, int chartoWrite);
 
 } // namespace AGS3
 
diff --git a/engines/ags/engine/ac/gui.cpp b/engines/ags/engine/ac/gui.cpp
index 5ad91f2b11..d76d399ca6 100644
--- a/engines/ags/engine/ac/gui.cpp
+++ b/engines/ags/engine/ac/gui.cpp
@@ -690,183 +690,183 @@ void gui_on_mouse_down(const int guin, const int mbut) {
 //=============================================================================
 
 // void GUI_Centre(ScriptGUI *sgui)
-RuntimeScriptValue Sc_GUI_Centre(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_Centre(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptGUI, GUI_Centre);
 }
 
 // ScriptGUI *(int xx, int yy)
-RuntimeScriptValue Sc_GetGUIAtLocation(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGUIAtLocation(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(ScriptGUI, ccDynamicGUI, GetGUIAtLocation);
 }
 
 // void (ScriptGUI *tehgui, int xx, int yy)
-RuntimeScriptValue Sc_GUI_SetPosition(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetPosition(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptGUI, GUI_SetPosition);
 }
 
 // void (ScriptGUI *sgui, int widd, int hitt)
-RuntimeScriptValue Sc_GUI_SetSize(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetSize(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptGUI, GUI_SetSize);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetBackgroundGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetBackgroundGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetBackgroundGraphic);
 }
 
 // void (ScriptGUI *tehgui, int slotn)
-RuntimeScriptValue Sc_GUI_SetBackgroundGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetBackgroundGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetBackgroundGraphic);
 }
 
-RuntimeScriptValue Sc_GUI_GetBackgroundColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetBackgroundColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetBackgroundColor);
 }
 
-RuntimeScriptValue Sc_GUI_SetBackgroundColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetBackgroundColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetBackgroundColor);
 }
 
-RuntimeScriptValue Sc_GUI_GetBorderColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetBorderColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetBorderColor);
 }
 
-RuntimeScriptValue Sc_GUI_SetBorderColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetBorderColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetBorderColor);
 }
 
-RuntimeScriptValue Sc_GUI_GetTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetTextColor);
 }
 
-RuntimeScriptValue Sc_GUI_SetTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetTextColor);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetClickable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetClickable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetClickable);
 }
 
 // void (ScriptGUI *tehgui, int clickable)
-RuntimeScriptValue Sc_GUI_SetClickable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetClickable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetClickable);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetControlCount(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetControlCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetControlCount);
 }
 
 // GUIObject* (ScriptGUI *tehgui, int idx)
-RuntimeScriptValue Sc_GUI_GetiControls(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetiControls(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ_PINT(ScriptGUI, GUIObject, ccDynamicGUIObject, GUI_GetiControls);
 }
 
 // int (ScriptGUI *sgui)
-RuntimeScriptValue Sc_GUI_GetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetHeight);
 }
 
 // void (ScriptGUI *sgui, int newhit)
-RuntimeScriptValue Sc_GUI_SetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetHeight);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetID);
 }
 
-RuntimeScriptValue Sc_GUI_GetPopupYPos(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetPopupYPos(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetPopupYPos);
 }
 
-RuntimeScriptValue Sc_GUI_SetPopupYPos(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetPopupYPos(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetPopupYPos);
 }
 
-RuntimeScriptValue Sc_GUI_GetTextPadding(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetTextPadding(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetTextPadding);
 }
 
-RuntimeScriptValue Sc_GUI_SetTextPadding(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetTextPadding(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetTextPadding);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetTransparency(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetTransparency(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetTransparency);
 }
 
 // void (ScriptGUI *tehgui, int trans)
-RuntimeScriptValue Sc_GUI_SetTransparency(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetTransparency(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetTransparency);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetVisible(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetVisible(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetVisible);
 }
 
 // void (ScriptGUI *tehgui, int isvisible)
-RuntimeScriptValue Sc_GUI_SetVisible(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetVisible(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetVisible);
 }
 
 // int (ScriptGUI *sgui)
-RuntimeScriptValue Sc_GUI_GetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetWidth);
 }
 
 // void (ScriptGUI *sgui, int newwid)
-RuntimeScriptValue Sc_GUI_SetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetWidth);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetX);
 }
 
 // void (ScriptGUI *tehgui, int xx)
-RuntimeScriptValue Sc_GUI_SetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetX);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetY);
 }
 
 // void (ScriptGUI *tehgui, int yy)
-RuntimeScriptValue Sc_GUI_SetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetY);
 }
 
 // int (ScriptGUI *tehgui)
-RuntimeScriptValue Sc_GUI_GetZOrder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetZOrder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetZOrder);
 }
 
 // void (ScriptGUI *tehgui, int z)
-RuntimeScriptValue Sc_GUI_SetZOrder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_SetZOrder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_SetZOrder);
 }
 
-RuntimeScriptValue Sc_GUI_AsTextWindow(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_AsTextWindow(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(ScriptGUI, ScriptGUI, ccDynamicGUI, GUI_AsTextWindow);
 }
 
-RuntimeScriptValue Sc_GUI_GetPopupStyle(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_GetPopupStyle(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptGUI, GUI_GetPopupStyle);
 }
 
-RuntimeScriptValue Sc_GUI_Click(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_Click(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptGUI, GUI_Click);
 }
 
-RuntimeScriptValue Sc_GUI_ProcessClick(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUI_ProcessClick(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(GUI_ProcessClick);
 }
 
diff --git a/engines/ags/engine/ac/guicontrol.cpp b/engines/ags/engine/ac/guicontrol.cpp
index e3749b060a..e198f72c7d 100644
--- a/engines/ags/engine/ac/guicontrol.cpp
+++ b/engines/ags/engine/ac/guicontrol.cpp
@@ -242,145 +242,145 @@ void GUIControl_BringToFront(GUIObject *guio) {
 //=============================================================================
 
 // void (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_BringToFront(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_BringToFront(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(GUIObject, GUIControl_BringToFront);
 }
 
 // GUIObject *(int xx, int yy)
-RuntimeScriptValue Sc_GetGUIControlAtLocation(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetGUIControlAtLocation(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(GUIObject, ccDynamicGUIObject, GetGUIControlAtLocation);
 }
 
 // void (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_SendToBack(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SendToBack(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(GUIObject, GUIControl_SendToBack);
 }
 
 // void (GUIObject *guio, int xx, int yy)
-RuntimeScriptValue Sc_GUIControl_SetPosition(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetPosition(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(GUIObject, GUIControl_SetPosition);
 }
 
 // void (GUIObject *guio, int newwid, int newhit)
-RuntimeScriptValue Sc_GUIControl_SetSize(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetSize(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(GUIObject, GUIControl_SetSize);
 }
 
 // GUIButton* (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetAsButton(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetAsButton(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(GUIObject, GUIButton, ccDynamicGUI, GUIControl_GetAsButton);
 }
 
 // GUIInvWindow* (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetAsInvWindow(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetAsInvWindow(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(GUIObject, GUIInvWindow, ccDynamicGUI, GUIControl_GetAsInvWindow);
 }
 
 // GUILabel* (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetAsLabel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetAsLabel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(GUIObject, GUILabel, ccDynamicGUI, GUIControl_GetAsLabel);
 }
 
 // GUIListBox* (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetAsListBox(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetAsListBox(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(GUIObject, GUIListBox, ccDynamicGUI, GUIControl_GetAsListBox);
 }
 
 // GUISlider* (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetAsSlider(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetAsSlider(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(GUIObject, GUISlider, ccDynamicGUI, GUIControl_GetAsSlider);
 }
 
 // GUITextBox* (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetAsTextBox(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetAsTextBox(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(GUIObject, GUITextBox, ccDynamicGUI, GUIControl_GetAsTextBox);
 }
 
 // int (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetClickable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetClickable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetClickable);
 }
 
 // void (GUIObject *guio, int enabled)
-RuntimeScriptValue Sc_GUIControl_SetClickable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetClickable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIObject, GUIControl_SetClickable);
 }
 
 // int (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetEnabled(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetEnabled(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetEnabled);
 }
 
 // void (GUIObject *guio, int enabled)
-RuntimeScriptValue Sc_GUIControl_SetEnabled(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetEnabled(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIObject, GUIControl_SetEnabled);
 }
 
 // int (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetHeight);
 }
 
 // void (GUIObject *guio, int newhit)
-RuntimeScriptValue Sc_GUIControl_SetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIObject, GUIControl_SetHeight);
 }
 
 // int (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetID);
 }
 
 // ScriptGUI* (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetOwningGUI(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetOwningGUI(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(GUIObject, ScriptGUI, ccDynamicGUI, GUIControl_GetOwningGUI);
 }
 
 // int (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetVisible(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetVisible(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetVisible);
 }
 
 // void (GUIObject *guio, int visible)
-RuntimeScriptValue Sc_GUIControl_SetVisible(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetVisible(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIObject, GUIControl_SetVisible);
 }
 
 // int (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetWidth);
 }
 
 // void (GUIObject *guio, int newwid)
-RuntimeScriptValue Sc_GUIControl_SetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIObject, GUIControl_SetWidth);
 }
 
 // int (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetX);
 }
 
 // void (GUIObject *guio, int xx)
-RuntimeScriptValue Sc_GUIControl_SetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIObject, GUIControl_SetX);
 }
 
 // int (GUIObject *guio)
-RuntimeScriptValue Sc_GUIControl_GetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetY);
 }
 
 // void (GUIObject *guio, int yy)
-RuntimeScriptValue Sc_GUIControl_SetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIObject, GUIControl_SetY);
 }
 
-RuntimeScriptValue Sc_GUIControl_GetZOrder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_GetZOrder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIObject, GUIControl_GetZOrder);
 }
 
-RuntimeScriptValue Sc_GUIControl_SetZOrder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GUIControl_SetZOrder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIObject, GUIControl_SetZOrder);
 }
 
diff --git a/engines/ags/engine/ac/hotspot.cpp b/engines/ags/engine/ac/hotspot.cpp
index d6e7ee72d1..02f9189158 100644
--- a/engines/ags/engine/ac/hotspot.cpp
+++ b/engines/ags/engine/ac/hotspot.cpp
@@ -135,84 +135,84 @@ int get_hotspot_at(int xpp, int ypp) {
 
 extern ScriptString myScriptStringImpl;
 
-RuntimeScriptValue Sc_GetHotspotAtRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetHotspotAtRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(ScriptHotspot, ccDynamicHotspot, GetHotspotAtRoom);
 }
 
 // ScriptHotspot *(int xx, int yy)
-RuntimeScriptValue Sc_GetHotspotAtScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetHotspotAtScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(ScriptHotspot, ccDynamicHotspot, GetHotspotAtScreen);
 }
 
-RuntimeScriptValue Sc_Hotspot_GetDrawingSurface(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetDrawingSurface(const RuntimeScriptValue *params, int32_t param_count) {
 	ScriptDrawingSurface *ret_obj = Room_GetDrawingSurfaceForMask(kRoomAreaHotspot);
 	return RuntimeScriptValue().SetDynamicObject(ret_obj, ret_obj);
 }
 
 // void (ScriptHotspot *hss, char *buffer)
-RuntimeScriptValue Sc_Hotspot_GetName(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetName(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(ScriptHotspot, Hotspot_GetName, char);
 }
 
 // int  (ScriptHotspot *hss, const char *property)
-RuntimeScriptValue Sc_Hotspot_GetProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(ScriptHotspot, Hotspot_GetProperty, const char);
 }
 
 // void  (ScriptHotspot *hss, const char *property, char *bufer)
-RuntimeScriptValue Sc_Hotspot_GetPropertyText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetPropertyText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ2(ScriptHotspot, Hotspot_GetPropertyText, const char, char);
 }
 
 // const char* (ScriptHotspot *hss, const char *property)
-RuntimeScriptValue Sc_Hotspot_GetTextProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetTextProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_POBJ(ScriptHotspot, const char, myScriptStringImpl, Hotspot_GetTextProperty, const char);
 }
 
-RuntimeScriptValue Sc_Hotspot_SetProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_SetProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ_PINT(ScriptHotspot, Hotspot_SetProperty, const char);
 }
 
-RuntimeScriptValue Sc_Hotspot_SetTextProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_SetTextProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ2(ScriptHotspot, Hotspot_SetTextProperty, const char, const char);
 }
 
-RuntimeScriptValue Sc_Hotspot_IsInteractionAvailable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_IsInteractionAvailable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_PINT(ScriptHotspot, Hotspot_IsInteractionAvailable);
 }
 
 // void  (ScriptHotspot *hss, int mood)
-RuntimeScriptValue Sc_Hotspot_RunInteraction(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_RunInteraction(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptHotspot, Hotspot_RunInteraction);
 }
 
 // int (ScriptHotspot *hss)
-RuntimeScriptValue Sc_Hotspot_GetEnabled(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetEnabled(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptHotspot, Hotspot_GetEnabled);
 }
 
 // void (ScriptHotspot *hss, int newval)
-RuntimeScriptValue Sc_Hotspot_SetEnabled(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_SetEnabled(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptHotspot, Hotspot_SetEnabled);
 }
 
 // int (ScriptHotspot *hss)
-RuntimeScriptValue Sc_Hotspot_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptHotspot, Hotspot_GetID);
 }
 
 // const char* (ScriptHotspot *hss)
-RuntimeScriptValue Sc_Hotspot_GetName_New(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetName_New(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(ScriptHotspot, const char, myScriptStringImpl, Hotspot_GetName_New);
 }
 
 // int (ScriptHotspot *hss)
-RuntimeScriptValue Sc_Hotspot_GetWalkToX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetWalkToX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptHotspot, Hotspot_GetWalkToX);
 }
 
 // int (ScriptHotspot *hss)
-RuntimeScriptValue Sc_Hotspot_GetWalkToY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Hotspot_GetWalkToY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptHotspot, Hotspot_GetWalkToY);
 }
 
diff --git a/engines/ags/engine/ac/inventoryitem.cpp b/engines/ags/engine/ac/inventoryitem.cpp
index cd2ddd6891..8701a874d2 100644
--- a/engines/ags/engine/ac/inventoryitem.cpp
+++ b/engines/ags/engine/ac/inventoryitem.cpp
@@ -134,80 +134,80 @@ void set_inv_item_cursorpic(int invItemId, int piccy) {
 extern ScriptString myScriptStringImpl;
 
 // ScriptInvItem *(int xx, int yy)
-RuntimeScriptValue Sc_GetInvAtLocation(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetInvAtLocation(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(ScriptInvItem, ccDynamicInv, GetInvAtLocation);
 }
 
 // int (ScriptInvItem *iitem, int mood)
-RuntimeScriptValue Sc_InventoryItem_CheckInteractionAvailable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_CheckInteractionAvailable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT(ScriptInvItem, InventoryItem_CheckInteractionAvailable);
 }
 
 // void (ScriptInvItem *iitem, char *buff)
-RuntimeScriptValue Sc_InventoryItem_GetName(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_GetName(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(ScriptInvItem, InventoryItem_GetName, char);
 }
 
 // int (ScriptInvItem *scii, const char *property)
-RuntimeScriptValue Sc_InventoryItem_GetProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_GetProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(ScriptInvItem, InventoryItem_GetProperty, const char);
 }
 
 // void (ScriptInvItem *scii, const char *property, char *bufer)
-RuntimeScriptValue Sc_InventoryItem_GetPropertyText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_GetPropertyText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ2(ScriptInvItem, InventoryItem_GetPropertyText, const char, char);
 }
 
 // const char* (ScriptInvItem *scii, const char *property)
-RuntimeScriptValue Sc_InventoryItem_GetTextProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_GetTextProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_POBJ(ScriptInvItem, const char, myScriptStringImpl, InventoryItem_GetTextProperty, const char);
 }
 
-RuntimeScriptValue Sc_InventoryItem_SetProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_SetProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ_PINT(ScriptInvItem, InventoryItem_SetProperty, const char);
 }
 
-RuntimeScriptValue Sc_InventoryItem_SetTextProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_SetTextProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ2(ScriptInvItem, InventoryItem_SetTextProperty, const char, const char);
 }
 
 // void (ScriptInvItem *iitem, int mood)
-RuntimeScriptValue Sc_InventoryItem_RunInteraction(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_RunInteraction(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptInvItem, InventoryItem_RunInteraction);
 }
 
 // void (ScriptInvItem *scii, const char *newname)
-RuntimeScriptValue Sc_InventoryItem_SetName(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_SetName(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(ScriptInvItem, InventoryItem_SetName, const char);
 }
 
 // int (ScriptInvItem *iitem)
-RuntimeScriptValue Sc_InventoryItem_GetCursorGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_GetCursorGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptInvItem, InventoryItem_GetCursorGraphic);
 }
 
 // void (ScriptInvItem *iitem, int newSprite)
-RuntimeScriptValue Sc_InventoryItem_SetCursorGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_SetCursorGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptInvItem, InventoryItem_SetCursorGraphic);
 }
 
 // int (ScriptInvItem *iitem)
-RuntimeScriptValue Sc_InventoryItem_GetGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_GetGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptInvItem, InventoryItem_GetGraphic);
 }
 
 // void (ScriptInvItem *iitem, int piccy)
-RuntimeScriptValue Sc_InventoryItem_SetGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_SetGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptInvItem, InventoryItem_SetGraphic);
 }
 
 // int (ScriptInvItem *scii)
-RuntimeScriptValue Sc_InventoryItem_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptInvItem, InventoryItem_GetID);
 }
 
 // const char* (ScriptInvItem *invitem)
-RuntimeScriptValue Sc_InventoryItem_GetName_New(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InventoryItem_GetName_New(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(ScriptInvItem, const char, myScriptStringImpl, InventoryItem_GetName_New);
 }
 
diff --git a/engines/ags/engine/ac/invwindow.cpp b/engines/ags/engine/ac/invwindow.cpp
index c8ea65b2f4..a0a336d2e3 100644
--- a/engines/ags/engine/ac/invwindow.cpp
+++ b/engines/ags/engine/ac/invwindow.cpp
@@ -530,72 +530,72 @@ int invscreen() {
 //=============================================================================
 
 // void (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_ScrollDown(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_ScrollDown(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(GUIInvWindow, InvWindow_ScrollDown);
 }
 
 // void (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_ScrollUp(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_ScrollUp(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(GUIInvWindow, InvWindow_ScrollUp);
 }
 
 // CharacterInfo* (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_GetCharacterToUse(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_GetCharacterToUse(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(GUIInvWindow, CharacterInfo, ccDynamicCharacter, InvWindow_GetCharacterToUse);
 }
 
 // void (GUIInvWindow *guii, CharacterInfo *chaa)
-RuntimeScriptValue Sc_InvWindow_SetCharacterToUse(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_SetCharacterToUse(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(GUIInvWindow, InvWindow_SetCharacterToUse, CharacterInfo);
 }
 
 // ScriptInvItem* (GUIInvWindow *guii, int index)
-RuntimeScriptValue Sc_InvWindow_GetItemAtIndex(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_GetItemAtIndex(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ_PINT(GUIInvWindow, ScriptInvItem, ccDynamicInv, InvWindow_GetItemAtIndex);
 }
 
 // int (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_GetItemCount(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_GetItemCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIInvWindow, InvWindow_GetItemCount);
 }
 
 // int (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_GetItemHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_GetItemHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIInvWindow, InvWindow_GetItemHeight);
 }
 
 // void (GUIInvWindow *guii, int newhit)
-RuntimeScriptValue Sc_InvWindow_SetItemHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_SetItemHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIInvWindow, InvWindow_SetItemHeight);
 }
 
 // int (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_GetItemWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_GetItemWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIInvWindow, InvWindow_GetItemWidth);
 }
 
 // void (GUIInvWindow *guii, int newwidth)
-RuntimeScriptValue Sc_InvWindow_SetItemWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_SetItemWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIInvWindow, InvWindow_SetItemWidth);
 }
 
 // int (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_GetItemsPerRow(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_GetItemsPerRow(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIInvWindow, InvWindow_GetItemsPerRow);
 }
 
 // int (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_GetRowCount(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_GetRowCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIInvWindow, InvWindow_GetRowCount);
 }
 
 // int (GUIInvWindow *guii)
-RuntimeScriptValue Sc_InvWindow_GetTopItem(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_GetTopItem(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIInvWindow, InvWindow_GetTopItem);
 }
 
 // void (GUIInvWindow *guii, int topitem)
-RuntimeScriptValue Sc_InvWindow_SetTopItem(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_InvWindow_SetTopItem(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIInvWindow, InvWindow_SetTopItem);
 }
 
diff --git a/engines/ags/engine/ac/label.cpp b/engines/ags/engine/ac/label.cpp
index 4cb358fcd5..92876a3188 100644
--- a/engines/ags/engine/ac/label.cpp
+++ b/engines/ags/engine/ac/label.cpp
@@ -100,46 +100,46 @@ void Label_SetFont(GUILabel *guil, int fontnum) {
 extern ScriptString myScriptStringImpl;
 
 // void (GUILabel *labl, char *buffer)
-RuntimeScriptValue Sc_Label_GetText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_GetText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(GUILabel, Label_GetText, char);
 }
 
 // void (GUILabel *labl, const char *newtx)
-RuntimeScriptValue Sc_Label_SetText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_SetText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(GUILabel, Label_SetText, const char);
 }
 
-RuntimeScriptValue Sc_Label_GetTextAlignment(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_GetTextAlignment(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUILabel, Label_GetTextAlignment);
 }
 
-RuntimeScriptValue Sc_Label_SetTextAlignment(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_SetTextAlignment(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUILabel, Label_SetTextAlignment);
 }
 
 
 // int (GUILabel *labl)
-RuntimeScriptValue Sc_Label_GetFont(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_GetFont(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUILabel, Label_GetFont);
 }
 
 // void (GUILabel *guil, int fontnum)
-RuntimeScriptValue Sc_Label_SetFont(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_SetFont(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUILabel, Label_SetFont);
 }
 
 // const char* (GUILabel *labl)
-RuntimeScriptValue Sc_Label_GetText_New(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_GetText_New(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(GUILabel, const char, myScriptStringImpl, Label_GetText_New);
 }
 
 // int (GUILabel *labl)
-RuntimeScriptValue Sc_Label_GetColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_GetColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUILabel, Label_GetColor);
 }
 
 // void (GUILabel *labl, int colr)
-RuntimeScriptValue Sc_Label_SetColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Label_SetColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUILabel, Label_SetColor);
 }
 
diff --git a/engines/ags/engine/ac/lipsync.h b/engines/ags/engine/ac/lipsync.h
index 52adfc9d57..ec36cbed00 100644
--- a/engines/ags/engine/ac/lipsync.h
+++ b/engines/ags/engine/ac/lipsync.h
@@ -29,7 +29,7 @@ namespace AGS3 {
 
 struct SpeechLipSyncLine {
 	char  filename[14];
-	int *endtimeoffs;
+	int32_t *endtimeoffs;
 	short *frame;
 	short numPhonemes;
 };
diff --git a/engines/ags/engine/ac/listbox.cpp b/engines/ags/engine/ac/listbox.cpp
index 44eee62527..c24a6a2db4 100644
--- a/engines/ags/engine/ac/listbox.cpp
+++ b/engines/ags/engine/ac/listbox.cpp
@@ -382,179 +382,179 @@ GUIListBox *is_valid_listbox(int guin, int objn) {
 extern ScriptString myScriptStringImpl;
 
 // int (GUIListBox *lbb, const char *text)
-RuntimeScriptValue Sc_ListBox_AddItem(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_AddItem(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(GUIListBox, ListBox_AddItem, const char);
 }
 
 // void (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_Clear(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_Clear(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(GUIListBox, ListBox_Clear);
 }
 
 // void (GUIListBox *listbox, const char *filemask)
-RuntimeScriptValue Sc_ListBox_FillDirList(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_FillDirList(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(GUIListBox, ListBox_FillDirList, const char);
 }
 
 // int (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_FillSaveGameList(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_FillSaveGameList(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_FillSaveGameList);
 }
 
 // int (GUIListBox *listbox, int x, int y)
-RuntimeScriptValue Sc_ListBox_GetItemAtLocation(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetItemAtLocation(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT2(GUIListBox, ListBox_GetItemAtLocation);
 }
 
 // char *(GUIListBox *listbox, int index, char *buffer)
-RuntimeScriptValue Sc_ListBox_GetItemText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetItemText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ_PINT_POBJ(GUIListBox, char, myScriptStringImpl, ListBox_GetItemText, char);
 }
 
 // int (GUIListBox *lbb, int index, const char *text)
-RuntimeScriptValue Sc_ListBox_InsertItemAt(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_InsertItemAt(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT_POBJ(GUIListBox, ListBox_InsertItemAt, const char);
 }
 
 // void (GUIListBox *listbox, int itemIndex)
-RuntimeScriptValue Sc_ListBox_RemoveItem(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_RemoveItem(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_RemoveItem);
 }
 
 // void (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_ScrollDown(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_ScrollDown(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(GUIListBox, ListBox_ScrollDown);
 }
 
 // void (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_ScrollUp(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_ScrollUp(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(GUIListBox, ListBox_ScrollUp);
 }
 
 // void (GUIListBox *listbox, int index, const char *newtext)
-RuntimeScriptValue Sc_ListBox_SetItemText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetItemText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT_POBJ(GUIListBox, ListBox_SetItemText, const char);
 }
 
 // int (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_GetFont(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetFont(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetFont);
 }
 
 // void (GUIListBox *listbox, int newfont)
-RuntimeScriptValue Sc_ListBox_SetFont(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetFont(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetFont);
 }
 
-RuntimeScriptValue Sc_ListBox_GetShowBorder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetShowBorder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(GUIListBox, ListBox_GetShowBorder);
 }
 
-RuntimeScriptValue Sc_ListBox_SetShowBorder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetShowBorder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PBOOL(GUIListBox, ListBox_SetShowBorder);
 }
 
-RuntimeScriptValue Sc_ListBox_GetShowScrollArrows(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetShowScrollArrows(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(GUIListBox, ListBox_GetShowScrollArrows);
 }
 
-RuntimeScriptValue Sc_ListBox_SetShowScrollArrows(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetShowScrollArrows(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PBOOL(GUIListBox, ListBox_SetShowScrollArrows);
 }
 
 // int (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_GetHideBorder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetHideBorder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetHideBorder);
 }
 
 // void (GUIListBox *listbox, int newValue)
-RuntimeScriptValue Sc_ListBox_SetHideBorder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetHideBorder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetHideBorder);
 }
 
 // int (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_GetHideScrollArrows(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetHideScrollArrows(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetHideScrollArrows);
 }
 
 // void (GUIListBox *listbox, int newValue)
-RuntimeScriptValue Sc_ListBox_SetHideScrollArrows(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetHideScrollArrows(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetHideScrollArrows);
 }
 
 // int (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_GetItemCount(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetItemCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetItemCount);
 }
 
 // const char* (GUIListBox *listbox, int index)
-RuntimeScriptValue Sc_ListBox_GetItems(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetItems(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_PINT(GUIListBox, const char, myScriptStringImpl, ListBox_GetItems);
 }
 
 // int (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_GetRowCount(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetRowCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetRowCount);
 }
 
 // int (GUIListBox *listbox, int index)
-RuntimeScriptValue Sc_ListBox_GetSaveGameSlots(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetSaveGameSlots(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT(GUIListBox, ListBox_GetSaveGameSlots);
 }
 
-RuntimeScriptValue Sc_ListBox_GetSelectedBackColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetSelectedBackColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetSelectedBackColor);
 }
 
 // void (GUIListBox *guisl, int newsel)
-RuntimeScriptValue Sc_ListBox_SetSelectedBackColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetSelectedBackColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetSelectedBackColor);
 }
 
-RuntimeScriptValue Sc_ListBox_GetSelectedTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetSelectedTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetSelectedTextColor);
 }
 
 // void (GUIListBox *guisl, int newsel)
-RuntimeScriptValue Sc_ListBox_SetSelectedTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetSelectedTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetSelectedTextColor);
 }
 
-RuntimeScriptValue Sc_ListBox_GetTextAlignment(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetTextAlignment(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetTextAlignment);
 }
 
 // void (GUIListBox *guisl, int newsel)
-RuntimeScriptValue Sc_ListBox_SetTextAlignment(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetTextAlignment(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetTextAlignment);
 }
 
-RuntimeScriptValue Sc_ListBox_GetTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetTextColor);
 }
 
 // void (GUIListBox *guisl, int newsel)
-RuntimeScriptValue Sc_ListBox_SetTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetTextColor);
 }
 
 // int (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_GetSelectedIndex(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetSelectedIndex(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetSelectedIndex);
 }
 
 // void (GUIListBox *guisl, int newsel)
-RuntimeScriptValue Sc_ListBox_SetSelectedIndex(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetSelectedIndex(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetSelectedIndex);
 }
 
 // int (GUIListBox *listbox)
-RuntimeScriptValue Sc_ListBox_GetTopItem(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_GetTopItem(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUIListBox, ListBox_GetTopItem);
 }
 
 // void (GUIListBox *guisl, int item)
-RuntimeScriptValue Sc_ListBox_SetTopItem(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ListBox_SetTopItem(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUIListBox, ListBox_SetTopItem);
 }
 
diff --git a/engines/ags/engine/ac/math.cpp b/engines/ags/engine/ac/math.cpp
index 6fc8447405..2709b632cd 100644
--- a/engines/ags/engine/ac/math.cpp
+++ b/engines/ags/engine/ac/math.cpp
@@ -154,92 +154,92 @@ int __Rand(int upto) {
 //=============================================================================
 
 // float (float value)
-RuntimeScriptValue Sc_Math_ArcCos(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_ArcCos(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_ArcCos);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_ArcSin(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_ArcSin(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_ArcSin);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_ArcTan(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_ArcTan(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_ArcTan);
 }
 
 // float (SCRIPT_FLOAT(yval), SCRIPT_FLOAT(xval))
-RuntimeScriptValue Sc_Math_ArcTan2(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_ArcTan2(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT2(Math_ArcTan2);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Cos(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Cos(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Cos);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Cosh(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Cosh(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Cosh);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_DegreesToRadians(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_DegreesToRadians(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_DegreesToRadians);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Exp(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Exp(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Exp);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Log(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Log(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Log);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Log10(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Log10(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Log10);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_RadiansToDegrees(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_RadiansToDegrees(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_RadiansToDegrees);
 }
 
 // float (SCRIPT_FLOAT(base), SCRIPT_FLOAT(exp))
-RuntimeScriptValue Sc_Math_RaiseToPower(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_RaiseToPower(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT2(Math_RaiseToPower);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Sin(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Sin(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Sin);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Sinh(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Sinh(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Sinh);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Sqrt(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Sqrt(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Sqrt);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Tan(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Tan(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Tan);
 }
 
 // float (float value)
-RuntimeScriptValue Sc_Math_Tanh(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_Tanh(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT_PFLOAT(Math_Tanh);
 }
 
 // float ()
-RuntimeScriptValue Sc_Math_GetPi(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Math_GetPi(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT(Math_GetPi);
 }
 
diff --git a/engines/ags/engine/ac/mouse.cpp b/engines/ags/engine/ac/mouse.cpp
index 20472081a5..8d12af0650 100644
--- a/engines/ags/engine/ac/mouse.cpp
+++ b/engines/ags/engine/ac/mouse.cpp
@@ -460,123 +460,123 @@ int find_previous_enabled_cursor(int startwith) {
 //=============================================================================
 
 // void  (int curs, int newslot)
-RuntimeScriptValue Sc_ChangeCursorGraphic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ChangeCursorGraphic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(ChangeCursorGraphic);
 }
 
 // void  (int curs, int x, int y)
-RuntimeScriptValue Sc_ChangeCursorHotspot(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ChangeCursorHotspot(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(ChangeCursorHotspot);
 }
 
 // void (int curs, int newview)
-RuntimeScriptValue Sc_Mouse_ChangeModeView(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_ChangeModeView(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(Mouse_ChangeModeView);
 }
 
 // void (int modd)
-RuntimeScriptValue Sc_disable_cursor_mode(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_disable_cursor_mode(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(disable_cursor_mode);
 }
 
 // void (int modd)
-RuntimeScriptValue Sc_enable_cursor_mode(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_enable_cursor_mode(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(enable_cursor_mode);
 }
 
 // int (int curs)
-RuntimeScriptValue Sc_Mouse_GetModeGraphic(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_GetModeGraphic(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(Mouse_GetModeGraphic);
 }
 
 // int (int which)
-RuntimeScriptValue Sc_IsButtonDown(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsButtonDown(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsButtonDown);
 }
 
 // int (int which)
-RuntimeScriptValue Sc_IsModeEnabled(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_IsModeEnabled(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_PINT(IsModeEnabled);
 }
 
 // void ();
-RuntimeScriptValue Sc_SaveCursorForLocationChange(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SaveCursorForLocationChange(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(SaveCursorForLocationChange);
 }
 
 // void  ()
-RuntimeScriptValue Sc_SetNextCursor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetNextCursor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(SetNextCursor);
 }
 
 // void  ()
-RuntimeScriptValue Sc_SetPreviousCursor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetPreviousCursor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(SetPreviousCursor);
 }
 
 // void  (int x1, int y1, int x2, int y2)
-RuntimeScriptValue Sc_SetMouseBounds(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetMouseBounds(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT4(SetMouseBounds);
 }
 
 // void  (int newx, int newy)
-RuntimeScriptValue Sc_SetMousePosition(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_SetMousePosition(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT2(SetMousePosition);
 }
 
 // void ()
-RuntimeScriptValue Sc_RefreshMouse(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RefreshMouse(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(RefreshMouse);
 }
 
 // void ()
-RuntimeScriptValue Sc_set_default_cursor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_set_default_cursor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID(set_default_cursor);
 }
 
 // void (int newcurs)
-RuntimeScriptValue Sc_set_mouse_cursor(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_set_mouse_cursor(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(set_mouse_cursor);
 }
 
 // int ()
-RuntimeScriptValue Sc_GetCursorMode(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetCursorMode(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetCursorMode);
 }
 
 // void (int newmode)
-RuntimeScriptValue Sc_set_cursor_mode(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_set_cursor_mode(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(set_cursor_mode);
 }
 
 // int ()
-RuntimeScriptValue Sc_Mouse_GetVisible(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_GetVisible(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Mouse_GetVisible);
 }
 
 // void (int isOn)
-RuntimeScriptValue Sc_Mouse_SetVisible(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_SetVisible(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(Mouse_SetVisible);
 }
 
-RuntimeScriptValue Sc_Mouse_Click(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_Click(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(PluginSimulateMouseClick);
 }
 
-RuntimeScriptValue Sc_Mouse_GetControlEnabled(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_GetControlEnabled(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_BOOL(Mouse::IsControlEnabled);
 }
 
-RuntimeScriptValue Sc_Mouse_SetControlEnabled(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_SetControlEnabled(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PBOOL(Mouse_EnableControl);
 }
 
 
-RuntimeScriptValue Sc_Mouse_GetSpeed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_GetSpeed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_FLOAT(Mouse::GetSpeed);
 }
 
-RuntimeScriptValue Sc_Mouse_SetSpeed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Mouse_SetSpeed(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_VARIABLE_VALUE("Mouse::Speed");
 	Mouse::SetSpeed(params[0].FValue);
 	return RuntimeScriptValue();
diff --git a/engines/ags/engine/ac/movelist.cpp b/engines/ags/engine/ac/movelist.cpp
index 827d85438b..4393bfafbb 100644
--- a/engines/ags/engine/ac/movelist.cpp
+++ b/engines/ags/engine/ac/movelist.cpp
@@ -44,7 +44,7 @@ void MoveList::ReadFromFile_Legacy(Stream *in) {
 	direct = in->ReadInt8();
 }
 
-HSaveError MoveList::ReadFromFile(Stream *in, int cmp_ver) {
+HSaveError MoveList::ReadFromFile(Stream *in, int32_t cmp_ver) {
 	if (cmp_ver < 1) {
 		ReadFromFile_Legacy(in);
 		return HSaveError::None();
diff --git a/engines/ags/engine/ac/movelist.h b/engines/ags/engine/ac/movelist.h
index 6af2fd197a..e8cc8570b6 100644
--- a/engines/ags/engine/ac/movelist.h
+++ b/engines/ags/engine/ac/movelist.h
@@ -41,7 +41,7 @@ using namespace AGS; // FIXME later
 #define MAXNEEDSTAGES_LEGACY 40
 
 struct MoveList {
-	int pos[MAXNEEDSTAGES];
+	int32_t pos[MAXNEEDSTAGES];
 	int   numstage;
 	fixed xpermove[MAXNEEDSTAGES], ypermove[MAXNEEDSTAGES];
 	int   fromx, fromy;
@@ -51,7 +51,7 @@ struct MoveList {
 	char  direct;  // MoveCharDirect was used or not
 
 	void ReadFromFile_Legacy(Shared::Stream *in);
-	AGS::Engine::HSaveError ReadFromFile(Shared::Stream *in, int cmp_ver);
+	AGS::Engine::HSaveError ReadFromFile(Shared::Stream *in, int32_t cmp_ver);
 	void WriteToFile(Shared::Stream *out);
 };
 
diff --git a/engines/ags/engine/ac/object.cpp b/engines/ags/engine/ac/object.cpp
index e4a2f64b62..64871509e8 100644
--- a/engines/ags/engine/ac/object.cpp
+++ b/engines/ags/engine/ac/object.cpp
@@ -566,306 +566,306 @@ int check_click_on_object(int roomx, int roomy, int mood) {
 extern ScriptString myScriptStringImpl;
 
 // void (ScriptObject *objj, int loop, int delay, int repeat, int blocking, int direction)
-RuntimeScriptValue Sc_Object_Animate(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_Animate(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(ScriptObject, Object_Animate);
 }
 
-RuntimeScriptValue Sc_Object_AnimateFrom(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_AnimateFrom(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT6(ScriptObject, Object_AnimateFrom);
 }
 
 // int (ScriptObject *objj, ScriptObject *obj2)
-RuntimeScriptValue Sc_Object_IsCollidingWithObject(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_IsCollidingWithObject(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(ScriptObject, Object_IsCollidingWithObject, ScriptObject);
 }
 
 // void (ScriptObject *objj, char *buffer)
-RuntimeScriptValue Sc_Object_GetName(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetName(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(ScriptObject, Object_GetName, char);
 }
 
 // int (ScriptObject *objj, const char *property)
-RuntimeScriptValue Sc_Object_GetProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(ScriptObject, Object_GetProperty, const char);
 }
 
 // void (ScriptObject *objj, const char *property, char *bufer)
-RuntimeScriptValue Sc_Object_GetPropertyText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetPropertyText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ2(ScriptObject, Object_GetPropertyText, const char, char);
 }
 
 //const char* (ScriptObject *objj, const char *property)
-RuntimeScriptValue Sc_Object_GetTextProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetTextProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_POBJ(ScriptObject, const char, myScriptStringImpl, Object_GetTextProperty, const char);
 }
 
-RuntimeScriptValue Sc_Object_SetProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ_PINT(ScriptObject, Object_SetProperty, const char);
 }
 
-RuntimeScriptValue Sc_Object_SetTextProperty(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetTextProperty(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ2(ScriptObject, Object_SetTextProperty, const char, const char);
 }
 
 // void (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_MergeIntoBackground(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_MergeIntoBackground(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptObject, Object_MergeIntoBackground);
 }
 
-RuntimeScriptValue Sc_Object_IsInteractionAvailable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_IsInteractionAvailable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_PINT(ScriptObject, Object_IsInteractionAvailable);
 }
 
 // void (ScriptObject *objj, int x, int y, int speed, int blocking, int direct)
-RuntimeScriptValue Sc_Object_Move(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_Move(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(ScriptObject, Object_Move);
 }
 
 // void (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_RemoveTint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_RemoveTint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptObject, Object_RemoveTint);
 }
 
 // void (ScriptObject *objj, int mode)
-RuntimeScriptValue Sc_Object_RunInteraction(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_RunInteraction(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_RunInteraction);
 }
 
-RuntimeScriptValue Sc_Object_HasExplicitLight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_HasExplicitLight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(ScriptObject, Object_HasExplicitLight);
 }
 
-RuntimeScriptValue Sc_Object_HasExplicitTint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_HasExplicitTint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(ScriptObject, Object_HasExplicitTint);
 }
 
-RuntimeScriptValue Sc_Object_GetLightLevel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetLightLevel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetLightLevel);
 }
 
-RuntimeScriptValue Sc_Object_SetLightLevel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetLightLevel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetLightLevel);
 }
 
-RuntimeScriptValue Sc_Object_GetTintBlue(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetTintBlue(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetTintBlue);
 }
 
-RuntimeScriptValue Sc_Object_GetTintGreen(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetTintGreen(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetTintGreen);
 }
 
-RuntimeScriptValue Sc_Object_GetTintRed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetTintRed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetTintRed);
 }
 
-RuntimeScriptValue Sc_Object_GetTintSaturation(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetTintSaturation(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetTintSaturation);
 }
 
-RuntimeScriptValue Sc_Object_GetTintLuminance(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetTintLuminance(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetTintLuminance);
 }
 
 // void (ScriptObject *objj, int xx, int yy)
-RuntimeScriptValue Sc_Object_SetPosition(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetPosition(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptObject, Object_SetPosition);
 }
 
 // void (ScriptObject *objj, int view, int loop, int frame)
-RuntimeScriptValue Sc_Object_SetView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT3(ScriptObject, Object_SetView);
 }
 
 // void (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_StopAnimating(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_StopAnimating(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptObject, Object_StopAnimating);
 }
 
 // void (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_StopMoving(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_StopMoving(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptObject, Object_StopMoving);
 }
 
 // void (ScriptObject *objj, int red, int green, int blue, int saturation, int luminance)
-RuntimeScriptValue Sc_Object_Tint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_Tint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(ScriptObject, Object_Tint);
 }
 
-RuntimeScriptValue Sc_GetObjectAtRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectAtRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(ScriptObject, ccDynamicObject, GetObjectAtRoom);
 }
 
 // ScriptObject *(int xx, int yy)
-RuntimeScriptValue Sc_GetObjectAtScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetObjectAtScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(ScriptObject, ccDynamicObject, GetObjectAtScreen);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetAnimating(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetAnimating(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetAnimating);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetBaseline(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetBaseline(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetBaseline);
 }
 
 // void (ScriptObject *objj, int basel)
-RuntimeScriptValue Sc_Object_SetBaseline(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetBaseline(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetBaseline);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetBlockingHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetBlockingHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetBlockingHeight);
 }
 
 // void (ScriptObject *objj, int bhit)
-RuntimeScriptValue Sc_Object_SetBlockingHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetBlockingHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetBlockingHeight);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetBlockingWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetBlockingWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetBlockingWidth);
 }
 
 // void (ScriptObject *objj, int bwid)
-RuntimeScriptValue Sc_Object_SetBlockingWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetBlockingWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetBlockingWidth);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetClickable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetClickable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetClickable);
 }
 
 // void (ScriptObject *objj, int clik)
-RuntimeScriptValue Sc_Object_SetClickable(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetClickable(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetClickable);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetFrame(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetFrame(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetFrame);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetGraphic);
 }
 
 // void (ScriptObject *objj, int slott)
-RuntimeScriptValue Sc_Object_SetGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetGraphic);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetID);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetIgnoreScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetIgnoreScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetIgnoreScaling);
 }
 
 // void (ScriptObject *objj, int newval)
-RuntimeScriptValue Sc_Object_SetIgnoreScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetIgnoreScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetIgnoreScaling);
 }
 
 // int (ScriptObject *chaa)
-RuntimeScriptValue Sc_Object_GetIgnoreWalkbehinds(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetIgnoreWalkbehinds(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetIgnoreWalkbehinds);
 }
 
 // void (ScriptObject *chaa, int clik)
-RuntimeScriptValue Sc_Object_SetIgnoreWalkbehinds(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetIgnoreWalkbehinds(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetIgnoreWalkbehinds);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetLoop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetLoop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetLoop);
 }
 
-RuntimeScriptValue Sc_Object_SetManualScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetManualScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PBOOL(ScriptObject, Object_SetManualScaling);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetMoving(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetMoving(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetMoving);
 }
 
 // const char* (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetName_New(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetName_New(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(ScriptObject, const char, myScriptStringImpl, Object_GetName_New);
 }
 
-RuntimeScriptValue Sc_Object_GetScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetScaling);
 }
 
-RuntimeScriptValue Sc_Object_SetScaling(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetScaling(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetScaling);
 }
 
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetSolid(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetSolid(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetSolid);
 }
 
 // void (ScriptObject *objj, int solid)
-RuntimeScriptValue Sc_Object_SetSolid(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetSolid(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetSolid);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetTransparency(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetTransparency(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetTransparency);
 }
 
 // void (ScriptObject *objj, int trans)
-RuntimeScriptValue Sc_Object_SetTransparency(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetTransparency(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetTransparency);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetView);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetVisible(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetVisible(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetVisible);
 }
 
 // void (ScriptObject *objj, int onoroff)
-RuntimeScriptValue Sc_Object_SetVisible(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetVisible(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetVisible);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetX);
 }
 
 // void (ScriptObject *objj, int xx)
-RuntimeScriptValue Sc_Object_SetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetX);
 }
 
 // int (ScriptObject *objj)
-RuntimeScriptValue Sc_Object_GetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_GetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptObject, Object_GetY);
 }
 
 // void (ScriptObject *objj, int yy)
-RuntimeScriptValue Sc_Object_SetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Object_SetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptObject, Object_SetY);
 }
 
diff --git a/engines/ags/engine/ac/overlay.cpp b/engines/ags/engine/ac/overlay.cpp
index 253fbf725c..269bb5dc74 100644
--- a/engines/ags/engine/ac/overlay.cpp
+++ b/engines/ags/engine/ac/overlay.cpp
@@ -292,12 +292,12 @@ void recreate_overlay_ddbs() {
 //=============================================================================
 
 // ScriptOverlay* (int x, int y, int slot, int transparent)
-RuntimeScriptValue Sc_Overlay_CreateGraphical(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_CreateGraphical(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT4(ScriptOverlay, Overlay_CreateGraphical);
 }
 
 // ScriptOverlay* (int x, int y, int width, int font, int colour, const char* text, ...)
-RuntimeScriptValue Sc_Overlay_CreateTextual(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_CreateTextual(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(Overlay_CreateTextual, 6);
 	ScriptOverlay *overlay = Overlay_CreateTextual(params[0].IValue, params[1].IValue, params[2].IValue,
 		params[3].IValue, params[4].IValue, scsf_buffer);
@@ -305,39 +305,39 @@ RuntimeScriptValue Sc_Overlay_CreateTextual(const RuntimeScriptValue *params, in
 }
 
 // void (ScriptOverlay *scover, int wii, int fontid, int clr, char*texx, ...)
-RuntimeScriptValue Sc_Overlay_SetText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_SetText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_SCRIPT_SPRINTF(Overlay_SetText, 4);
 	Overlay_SetText((ScriptOverlay *)self, params[0].IValue, params[1].IValue, params[2].IValue, scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 // void (ScriptOverlay *sco)
-RuntimeScriptValue Sc_Overlay_Remove(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_Remove(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptOverlay, Overlay_Remove);
 }
 
 // int (ScriptOverlay *scover)
-RuntimeScriptValue Sc_Overlay_GetValid(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_GetValid(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptOverlay, Overlay_GetValid);
 }
 
 // int (ScriptOverlay *scover)
-RuntimeScriptValue Sc_Overlay_GetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_GetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptOverlay, Overlay_GetX);
 }
 
 // void (ScriptOverlay *scover, int newx)
-RuntimeScriptValue Sc_Overlay_SetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_SetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptOverlay, Overlay_SetX);
 }
 
 // int (ScriptOverlay *scover)
-RuntimeScriptValue Sc_Overlay_GetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_GetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptOverlay, Overlay_GetY);
 }
 
 // void (ScriptOverlay *scover, int newy)
-RuntimeScriptValue Sc_Overlay_SetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Overlay_SetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptOverlay, Overlay_SetY);
 }
 
diff --git a/engines/ags/engine/ac/parser.cpp b/engines/ags/engine/ac/parser.cpp
index 91b83af593..ec949675ad 100644
--- a/engines/ags/engine/ac/parser.cpp
+++ b/engines/ags/engine/ac/parser.cpp
@@ -309,22 +309,22 @@ int parse_sentence(const char *src_text, int *numwords, short *wordarray, short
 extern ScriptString myScriptStringImpl;
 
 // int (const char *wordToFind)
-RuntimeScriptValue Sc_Parser_FindWordID(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Parser_FindWordID(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(Parser_FindWordID, const char);
 }
 
 // void  (char*text)
-RuntimeScriptValue Sc_ParseText(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ParseText(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_POBJ(ParseText, /*const*/ char);
 }
 
 // const char* ()
-RuntimeScriptValue Sc_Parser_SaidUnknownWord(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Parser_SaidUnknownWord(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ(const char, myScriptStringImpl, Parser_SaidUnknownWord);
 }
 
 // int  (char*checkwords)
-RuntimeScriptValue Sc_Said(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Said(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(Said, /*const*/ char);
 }
 
diff --git a/engines/ags/engine/ac/region.cpp b/engines/ags/engine/ac/region.cpp
index 2f38da770e..22d628828e 100644
--- a/engines/ags/engine/ac/region.cpp
+++ b/engines/ags/engine/ac/region.cpp
@@ -141,84 +141,84 @@ void generate_light_table() {
 //=============================================================================
 
 // ScriptRegion *(int xx, int yy)
-RuntimeScriptValue Sc_GetRegionAtRoom(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetRegionAtRoom(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(ScriptRegion, ccDynamicRegion, GetRegionAtRoom);
 }
 
-RuntimeScriptValue Sc_GetRegionAtScreen(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_GetRegionAtScreen(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT2(ScriptRegion, ccDynamicRegion, GetRegionAtScreen);
 }
 
-RuntimeScriptValue Sc_Region_GetDrawingSurface(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetDrawingSurface(const RuntimeScriptValue *params, int32_t param_count) {
 	ScriptDrawingSurface *ret_obj = Room_GetDrawingSurfaceForMask(kRoomAreaRegion);
 	return RuntimeScriptValue().SetDynamicObject(ret_obj, ret_obj);
 }
 
-RuntimeScriptValue Sc_Region_Tint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_Tint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT5(ScriptRegion, Region_Tint);
 }
 
 // void (ScriptRegion *srr, int red, int green, int blue, int amount)
-RuntimeScriptValue Sc_Region_TintNoLum(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_TintNoLum(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(ScriptRegion, Region_TintNoLum);
 }
 
 // void (ScriptRegion *ssr, int mood)
-RuntimeScriptValue Sc_Region_RunInteraction(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_RunInteraction(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptRegion, Region_RunInteraction);
 }
 
 // int (ScriptRegion *ssr)
-RuntimeScriptValue Sc_Region_GetEnabled(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetEnabled(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetEnabled);
 }
 
 // void (ScriptRegion *ssr, int enable)
-RuntimeScriptValue Sc_Region_SetEnabled(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_SetEnabled(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptRegion, Region_SetEnabled);
 }
 
 // int (ScriptRegion *ssr)
-RuntimeScriptValue Sc_Region_GetID(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetID(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetID);
 }
 
 // int (ScriptRegion *ssr)
-RuntimeScriptValue Sc_Region_GetLightLevel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetLightLevel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetLightLevel);
 }
 
 // void (ScriptRegion *ssr, int brightness)
-RuntimeScriptValue Sc_Region_SetLightLevel(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_SetLightLevel(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptRegion, Region_SetLightLevel);
 }
 
 // int (ScriptRegion *srr)
-RuntimeScriptValue Sc_Region_GetTintEnabled(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetTintEnabled(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetTintEnabled);
 }
 
 // int (ScriptRegion *srr)
-RuntimeScriptValue Sc_Region_GetTintBlue(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetTintBlue(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetTintBlue);
 }
 
 // int (ScriptRegion *srr)
-RuntimeScriptValue Sc_Region_GetTintGreen(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetTintGreen(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetTintGreen);
 }
 
 // int (ScriptRegion *srr)
-RuntimeScriptValue Sc_Region_GetTintRed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetTintRed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetTintRed);
 }
 
 // int (ScriptRegion *srr)
-RuntimeScriptValue Sc_Region_GetTintSaturation(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetTintSaturation(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetTintSaturation);
 }
 
-RuntimeScriptValue Sc_Region_GetTintLuminance(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Region_GetTintLuminance(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptRegion, Region_GetTintLuminance);
 }
 
diff --git a/engines/ags/engine/ac/richgamemedia.cpp b/engines/ags/engine/ac/richgamemedia.cpp
index 08330f72b2..ae6852d3a3 100644
--- a/engines/ags/engine/ac/richgamemedia.cpp
+++ b/engines/ags/engine/ac/richgamemedia.cpp
@@ -35,10 +35,10 @@ void RICH_GAME_MEDIA_HEADER::ReadFromFile(Stream *in) {
 	dwThumbnailOffsetHigherDword = in->ReadInt32();
 	dwThumbnailSize = in->ReadInt32();
 	in->Read(guidGameId, 16);
-	in->ReadArrayOfInt16((int16 *)szGameName, RM_MAXLENGTH);
-	in->ReadArrayOfInt16((int16 *)szSaveName, RM_MAXLENGTH);
-	in->ReadArrayOfInt16((int16 *)szLevelName, RM_MAXLENGTH);
-	in->ReadArrayOfInt16((int16 *)szComments, RM_MAXLENGTH);
+	in->ReadArrayOfInt16((int16_t *)szGameName, RM_MAXLENGTH);
+	in->ReadArrayOfInt16((int16_t *)szSaveName, RM_MAXLENGTH);
+	in->ReadArrayOfInt16((int16_t *)szLevelName, RM_MAXLENGTH);
+	in->ReadArrayOfInt16((int16_t *)szComments, RM_MAXLENGTH);
 }
 
 void RICH_GAME_MEDIA_HEADER::WriteToFile(Stream *out) {
@@ -49,10 +49,10 @@ void RICH_GAME_MEDIA_HEADER::WriteToFile(Stream *out) {
 	out->WriteInt32(dwThumbnailOffsetHigherDword);
 	out->WriteInt32(dwThumbnailSize);
 	out->Write(guidGameId, 16);
-	out->WriteArrayOfInt16((int16 *)szGameName, RM_MAXLENGTH);
-	out->WriteArrayOfInt16((int16 *)szSaveName, RM_MAXLENGTH);
-	out->WriteArrayOfInt16((int16 *)szLevelName, RM_MAXLENGTH);
-	out->WriteArrayOfInt16((int16 *)szComments, RM_MAXLENGTH);
+	out->WriteArrayOfInt16((int16_t *)szGameName, RM_MAXLENGTH);
+	out->WriteArrayOfInt16((int16_t *)szSaveName, RM_MAXLENGTH);
+	out->WriteArrayOfInt16((int16_t *)szLevelName, RM_MAXLENGTH);
+	out->WriteArrayOfInt16((int16_t *)szComments, RM_MAXLENGTH);
 }
 
 void RICH_GAME_MEDIA_HEADER::setSaveName(const Common::String &saveName) {
diff --git a/engines/ags/engine/ac/room.cpp b/engines/ags/engine/ac/room.cpp
index 20c1222213..41ac25bceb 100644
--- a/engines/ags/engine/ac/room.cpp
+++ b/engines/ags/engine/ac/room.cpp
@@ -1084,8 +1084,8 @@ void convert_move_path_to_room_resolution(MoveList *ml) {
 	ml->lasty = mask_to_room_coord(ml->lasty);
 
 	for (int i = 0; i < ml->numstage; i++) {
-		uint16 lowPart = mask_to_room_coord(ml->pos[i] & 0x0000ffff);
-		uint16 highPart = mask_to_room_coord((ml->pos[i] >> 16) & 0x0000ffff);
+		uint16_t lowPart = mask_to_room_coord(ml->pos[i] & 0x0000ffff);
+		uint16_t highPart = mask_to_room_coord((ml->pos[i] >> 16) & 0x0000ffff);
 		ml->pos[i] = ((int)highPart << 16) | (lowPart & 0x0000ffff);
 	}
 
@@ -1107,81 +1107,81 @@ void convert_move_path_to_room_resolution(MoveList *ml) {
 extern ScriptString myScriptStringImpl;
 
 // ScriptDrawingSurface* (int backgroundNumber)
-RuntimeScriptValue Sc_Room_GetDrawingSurfaceForBackground(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetDrawingSurfaceForBackground(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT(ScriptDrawingSurface, Room_GetDrawingSurfaceForBackground);
 }
 
 // int (const char *property)
-RuntimeScriptValue Sc_Room_GetProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(Room_GetProperty, const char);
 }
 
 // const char* (const char *property)
-RuntimeScriptValue Sc_Room_GetTextProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetTextProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ_POBJ(const char, myScriptStringImpl, Room_GetTextProperty, const char);
 }
 
-RuntimeScriptValue Sc_Room_SetProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_SetProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_BOOL_POBJ_PINT(Room_SetProperty, const char);
 }
 
 // const char* (const char *property)
-RuntimeScriptValue Sc_Room_SetTextProperty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_SetTextProperty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_BOOL_POBJ2(Room_SetTextProperty, const char, const char);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetBottomEdge(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetBottomEdge(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetBottomEdge);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetColorDepth(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetColorDepth(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetColorDepth);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetHeight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetHeight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetHeight);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetLeftEdge(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetLeftEdge(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetLeftEdge);
 }
 
 // const char* (int index)
-RuntimeScriptValue Sc_Room_GetMessages(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetMessages(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ_PINT(const char, myScriptStringImpl, Room_GetMessages);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetMusicOnLoad(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetMusicOnLoad(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetMusicOnLoad);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetObjectCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetObjectCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetObjectCount);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetRightEdge(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetRightEdge(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetRightEdge);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetTopEdge(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetTopEdge(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetTopEdge);
 }
 
 // int ()
-RuntimeScriptValue Sc_Room_GetWidth(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Room_GetWidth(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Room_GetWidth);
 }
 
 // void (int xx,int yy,int mood)
-RuntimeScriptValue Sc_RoomProcessClick(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_RoomProcessClick(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT3(RoomProcessClick);
 }
 
diff --git a/engines/ags/engine/ac/room.h b/engines/ags/engine/ac/room.h
index 8bcff3f9cf..e90fda831c 100644
--- a/engines/ags/engine/ac/room.h
+++ b/engines/ags/engine/ac/room.h
@@ -44,7 +44,7 @@ int Room_GetMusicOnLoad();
 const char *Room_GetTextProperty(const char *property);
 int Room_GetProperty(const char *property);
 const char *Room_GetMessages(int index);
-RuntimeScriptValue Sc_Room_GetProperty(const RuntimeScriptValue *params, int param_count);
+RuntimeScriptValue Sc_Room_GetProperty(const RuntimeScriptValue *params, int32_t param_count);
 
 //=============================================================================
 
diff --git a/engines/ags/engine/ac/roomobject.cpp b/engines/ags/engine/ac/roomobject.cpp
index 9073b9f1f8..cc1ed9fbe4 100644
--- a/engines/ags/engine/ac/roomobject.cpp
+++ b/engines/ags/engine/ac/roomobject.cpp
@@ -158,7 +158,7 @@ void RoomObject::ReadFromFile(Stream *in) {
 	transparent = in->ReadInt32();
 
 	in->ReadArrayOfInt16(&tint_r, 15);
-	in->ReadArrayOfInt8((int8 *)&cycling, 4);
+	in->ReadArrayOfInt8((int8_t *)&cycling, 4);
 	in->ReadArrayOfInt16(&blocking_width, 2);
 }
 
@@ -168,7 +168,7 @@ void RoomObject::WriteToFile(Stream *out) const {
 	out->WriteInt32(transparent);
 
 	out->WriteArrayOfInt16(&tint_r, 15);
-	out->WriteArrayOfInt8((const int8 *)&cycling, 4);
+	out->WriteArrayOfInt8((const int8_t *)&cycling, 4);
 	out->WriteArrayOfInt16(&blocking_width, 2);
 }
 
diff --git a/engines/ags/engine/ac/roomobject.h b/engines/ags/engine/ac/roomobject.h
index bd26d495ec..d3398cc4de 100644
--- a/engines/ags/engine/ac/roomobject.h
+++ b/engines/ags/engine/ac/roomobject.h
@@ -38,8 +38,8 @@ using namespace AGS; // FIXME later
 
 // IMPORTANT: this struct is restricted by plugin API!
 struct RoomObject {
-	int x, y;
-	int transparent;    // current transparency setting
+	int32_t x, y;
+	int32_t transparent;    // current transparency setting
 	short tint_r, tint_g;   // specific object tint
 	short tint_b, tint_level;
 	short tint_light;
diff --git a/engines/ags/engine/ac/roomstatus.cpp b/engines/ags/engine/ac/roomstatus.cpp
index c19ffe029a..d24aff1fa8 100644
--- a/engines/ags/engine/ac/roomstatus.cpp
+++ b/engines/ags/engine/ac/roomstatus.cpp
@@ -86,8 +86,8 @@ void RoomStatus::ReadFromFile_v321(Stream *in) {
 		intrRegion[i].ReadFromSavedgame_v321(in);
 	}
 	intrRoom.ReadFromSavedgame_v321(in);
-	in->ReadArrayOfInt8((int8 *)hotspot_enabled, MAX_ROOM_HOTSPOTS);
-	in->ReadArrayOfInt8((int8 *)region_enabled, MAX_ROOM_REGIONS);
+	in->ReadArrayOfInt8((int8_t *)hotspot_enabled, MAX_ROOM_HOTSPOTS);
+	in->ReadArrayOfInt8((int8_t *)region_enabled, MAX_ROOM_REGIONS);
 	in->ReadArrayOfInt16(walkbehind_base, MAX_WALK_BEHINDS);
 	in->ReadArrayOfInt32(interactionVariableValues, MAX_GLOBAL_VARIABLES);
 
diff --git a/engines/ags/engine/ac/roomstatus.h b/engines/ags/engine/ac/roomstatus.h
index 0a67f1a772..3be1e11ee0 100644
--- a/engines/ags/engine/ac/roomstatus.h
+++ b/engines/ags/engine/ac/roomstatus.h
@@ -66,7 +66,7 @@ struct RoomStatus {
 	char  hotspot_enabled[MAX_ROOM_HOTSPOTS];
 	char  region_enabled[MAX_ROOM_REGIONS];
 	short walkbehind_base[MAX_WALK_BEHINDS];
-	int interactionVariableValues[MAX_GLOBAL_VARIABLES];
+	int32_t interactionVariableValues[MAX_GLOBAL_VARIABLES];
 
 	RoomStatus();
 	~RoomStatus();
diff --git a/engines/ags/engine/ac/route_finder_impl_legacy.cpp b/engines/ags/engine/ac/route_finder_impl_legacy.cpp
index 915e56b6a7..9b662526e3 100644
--- a/engines/ags/engine/ac/route_finder_impl_legacy.cpp
+++ b/engines/ags/engine/ac/route_finder_impl_legacy.cpp
@@ -182,7 +182,7 @@ static int is_route_possible(int fromx, int fromy, int tox, int toy, Bitmap *wss
 	}
 
 	for (ff = 0; ff < tempw->GetHeight(); ff++) {
-		const uint8 *tempw_scanline = tempw->GetScanLine(ff);
+		const uint8_t *tempw_scanline = tempw->GetScanLine(ff);
 		for (dd = 0; dd < tempw->GetWidth(); dd++) {
 			thisar = tempw_scanline[dd];
 			// count how high the area is at this point
@@ -201,7 +201,7 @@ static int is_route_possible(int fromx, int fromy, int tox, int toy, Bitmap *wss
 
 	for (dd = 0; dd < tempw->GetWidth(); dd++) {
 		for (ff = 0; ff < tempw->GetHeight(); ff++) {
-			uint8 *tempw_scanline = tempw->GetScanLineForWriting(ff);
+			uint8_t *tempw_scanline = tempw->GetScanLineForWriting(ff);
 			thisar = tempw_scanline[dd];
 			if (thisar > 0)
 				tempw_scanline[dd] = 1;
diff --git a/engines/ags/engine/ac/screen.cpp b/engines/ags/engine/ac/screen.cpp
index 3989c2a96c..06fc83fe55 100644
--- a/engines/ags/engine/ac/screen.cpp
+++ b/engines/ags/engine/ac/screen.cpp
@@ -161,39 +161,39 @@ ScriptUserObject *Screen_RoomToScreenPoint(int roomx, int roomy) {
 	return ScriptStructHelpers::CreatePoint(pt.X, pt.Y);
 }
 
-RuntimeScriptValue Sc_Screen_GetScreenHeight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_GetScreenHeight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Screen_GetScreenHeight);
 }
 
-RuntimeScriptValue Sc_Screen_GetScreenWidth(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_GetScreenWidth(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Screen_GetScreenWidth);
 }
 
-RuntimeScriptValue Sc_Screen_GetAutoSizeViewport(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_GetAutoSizeViewport(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_BOOL(Screen_GetAutoSizeViewport);
 }
 
-RuntimeScriptValue Sc_Screen_SetAutoSizeViewport(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_SetAutoSizeViewport(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PBOOL(Screen_SetAutoSizeViewport);
 }
 
-RuntimeScriptValue Sc_Screen_GetViewport(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_GetViewport(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO(ScriptViewport, Screen_GetViewport);
 }
 
-RuntimeScriptValue Sc_Screen_GetViewportCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_GetViewportCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(Screen_GetViewportCount);
 }
 
-RuntimeScriptValue Sc_Screen_GetAnyViewport(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_GetAnyViewport(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT(ScriptViewport, Screen_GetAnyViewport);
 }
 
-RuntimeScriptValue Sc_Screen_ScreenToRoomPoint(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_ScreenToRoomPoint(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT2(ScriptUserObject, Screen_ScreenToRoomPoint);
 }
 
-RuntimeScriptValue Sc_Screen_RoomToScreenPoint(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Screen_RoomToScreenPoint(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT2(ScriptUserObject, Screen_RoomToScreenPoint);
 }
 
diff --git a/engines/ags/engine/ac/screenoverlay.cpp b/engines/ags/engine/ac/screenoverlay.cpp
index 3134ac38f1..c4c133e67f 100644
--- a/engines/ags/engine/ac/screenoverlay.cpp
+++ b/engines/ags/engine/ac/screenoverlay.cpp
@@ -27,7 +27,7 @@ namespace AGS3 {
 
 using AGS::Shared::Stream;
 
-void ScreenOverlay::ReadFromFile(Stream *in, int cmp_ver) {
+void ScreenOverlay::ReadFromFile(Stream *in, int32_t cmp_ver) {
 	// Skipping bmp and pic pointer values
 	// TODO: find out if it's safe to just drop these pointers!! replace with unique_ptr?
 	bmp = nullptr;
diff --git a/engines/ags/engine/ac/screenoverlay.h b/engines/ags/engine/ac/screenoverlay.h
index d9fec98b5d..97787c34ba 100644
--- a/engines/ags/engine/ac/screenoverlay.h
+++ b/engines/ags/engine/ac/screenoverlay.h
@@ -56,7 +56,7 @@ struct ScreenOverlay {
 	bool hasSerializedBitmap = false;
 	int _offsetX = 0, _offsetY = 0;
 
-	void ReadFromFile(Shared::Stream *in, int cmp_ver);
+	void ReadFromFile(Shared::Stream *in, int32_t cmp_ver);
 	void WriteToFile(Shared::Stream *out) const;
 };
 
diff --git a/engines/ags/engine/ac/scriptcontainers.cpp b/engines/ags/engine/ac/scriptcontainers.cpp
index 4738cc0d51..0baa5ea971 100644
--- a/engines/ags/engine/ac/scriptcontainers.cpp
+++ b/engines/ags/engine/ac/scriptcontainers.cpp
@@ -71,15 +71,15 @@ ScriptDictBase *Dict_Create(bool sorted, bool case_sensitive) {
 
 // TODO: we need memory streams
 ScriptDictBase *Dict_Unserialize(int index, const char *serializedData, int dataSize) {
-	if (dataSize < (int)sizeof(int) * 2)
+	if (dataSize < (int)sizeof(int32_t) * 2)
 		quit("Dict_Unserialize: not enough data.");
 	const char *ptr = serializedData;
 	const int sorted = BBOp::Int32FromLE(*((const int *)ptr));
-	ptr += sizeof(int);
+	ptr += sizeof(int32_t);
 	const int cs = BBOp::Int32FromLE(*((const int *)ptr));
-	ptr += sizeof(int);
+	ptr += sizeof(int32_t);
 	ScriptDictBase *dic = Dict_CreateImpl(sorted != 0, cs != 0);
-	dic->Unserialize(index, ptr, dataSize -= sizeof(int) * 2);
+	dic->Unserialize(index, ptr, dataSize -= sizeof(int32_t) * 2);
 	return dic;
 }
 
@@ -134,47 +134,47 @@ void *Dict_GetValuesAsArray(ScriptDictBase *dic) {
 	return arr.second;
 }
 
-RuntimeScriptValue Sc_Dict_Create(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_Create(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PBOOL2(ScriptDictBase, Dict_Create);
 }
 
-RuntimeScriptValue Sc_Dict_Clear(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_Clear(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptDictBase, Dict_Clear);
 }
 
-RuntimeScriptValue Sc_Dict_Contains(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_Contains(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ(ScriptDictBase, Dict_Contains, const char);
 }
 
-RuntimeScriptValue Sc_Dict_Get(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_Get(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_POBJ(ScriptDictBase, const char, myScriptStringImpl, Dict_Get, const char);
 }
 
-RuntimeScriptValue Sc_Dict_Remove(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_Remove(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ(ScriptDictBase, Dict_Remove, const char);
 }
 
-RuntimeScriptValue Sc_Dict_Set(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_Set(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ2(ScriptDictBase, Dict_Set, const char, const char);
 }
 
-RuntimeScriptValue Sc_Dict_GetCompareStyle(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_GetCompareStyle(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDictBase, Dict_GetCompareStyle);
 }
 
-RuntimeScriptValue Sc_Dict_GetSortStyle(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_GetSortStyle(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDictBase, Dict_GetSortStyle);
 }
 
-RuntimeScriptValue Sc_Dict_GetItemCount(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_GetItemCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptDictBase, Dict_GetItemCount);
 }
 
-RuntimeScriptValue Sc_Dict_GetKeysAsArray(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_GetKeysAsArray(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(ScriptDictBase, void, globalDynamicArray, Dict_GetKeysAsArray);
 }
 
-RuntimeScriptValue Sc_Dict_GetValuesAsArray(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Dict_GetValuesAsArray(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(ScriptDictBase, void, globalDynamicArray, Dict_GetValuesAsArray);
 }
 
@@ -208,15 +208,15 @@ ScriptSetBase *Set_Create(bool sorted, bool case_sensitive) {
 
 // TODO: we need memory streams
 ScriptSetBase *Set_Unserialize(int index, const char *serializedData, int dataSize) {
-	if (dataSize < (int)sizeof(int) * 2)
+	if (dataSize < (int)sizeof(int32_t) * 2)
 		quit("Set_Unserialize: not enough data.");
 	const char *ptr = serializedData;
 	const int sorted = BBOp::Int32FromLE(*((const int *)ptr));
-	ptr += sizeof(int);
+	ptr += sizeof(int32_t);
 	const int cs = BBOp::Int32FromLE(*((const int *)ptr));
-	ptr += sizeof(int);
+	ptr += sizeof(int32_t);
 	ScriptSetBase *set = Set_CreateImpl(sorted != 0, cs != 0);
-	set->Unserialize(index, ptr, dataSize -= sizeof(int) * 2);
+	set->Unserialize(index, ptr, dataSize -= sizeof(int32_t) * 2);
 	return set;
 }
 
@@ -257,39 +257,39 @@ void *Set_GetItemsAsArray(ScriptSetBase *set) {
 	return arr.second;
 }
 
-RuntimeScriptValue Sc_Set_Create(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_Create(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PBOOL2(ScriptSetBase, Set_Create);
 }
 
-RuntimeScriptValue Sc_Set_Add(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_Add(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ(ScriptSetBase, Set_Add, const char);
 }
 
-RuntimeScriptValue Sc_Set_Clear(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_Clear(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptSetBase, Set_Clear);
 }
 
-RuntimeScriptValue Sc_Set_Contains(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_Contains(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ(ScriptSetBase, Set_Contains, const char);
 }
 
-RuntimeScriptValue Sc_Set_Remove(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_Remove(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL_POBJ(ScriptSetBase, Set_Remove, const char);
 }
 
-RuntimeScriptValue Sc_Set_GetCompareStyle(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_GetCompareStyle(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptSetBase, Set_GetCompareStyle);
 }
 
-RuntimeScriptValue Sc_Set_GetSortStyle(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_GetSortStyle(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptSetBase, Set_GetSortStyle);
 }
 
-RuntimeScriptValue Sc_Set_GetItemCount(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_GetItemCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptSetBase, Set_GetItemCount);
 }
 
-RuntimeScriptValue Sc_Set_GetItemAsArray(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Set_GetItemAsArray(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(ScriptSetBase, void, globalDynamicArray, Set_GetItemsAsArray);
 }
 
diff --git a/engines/ags/engine/ac/slider.cpp b/engines/ags/engine/ac/slider.cpp
index 81dcd51d8a..005570b2e3 100644
--- a/engines/ags/engine/ac/slider.cpp
+++ b/engines/ags/engine/ac/slider.cpp
@@ -123,62 +123,62 @@ void Slider_SetHandleOffset(GUISlider *guisl, int newOffset) {
 //=============================================================================
 
 // int (GUISlider *guisl)
-RuntimeScriptValue Sc_Slider_GetBackgroundGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_GetBackgroundGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUISlider, Slider_GetBackgroundGraphic);
 }
 
 // void (GUISlider *guisl, int newImage)
-RuntimeScriptValue Sc_Slider_SetBackgroundGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_SetBackgroundGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUISlider, Slider_SetBackgroundGraphic);
 }
 
 // int (GUISlider *guisl)
-RuntimeScriptValue Sc_Slider_GetHandleGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_GetHandleGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUISlider, Slider_GetHandleGraphic);
 }
 
 // void (GUISlider *guisl, int newImage)
-RuntimeScriptValue Sc_Slider_SetHandleGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_SetHandleGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUISlider, Slider_SetHandleGraphic);
 }
 
 // int (GUISlider *guisl)
-RuntimeScriptValue Sc_Slider_GetHandleOffset(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_GetHandleOffset(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUISlider, Slider_GetHandleOffset);
 }
 
 // void (GUISlider *guisl, int newOffset)
-RuntimeScriptValue Sc_Slider_SetHandleOffset(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_SetHandleOffset(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUISlider, Slider_SetHandleOffset);
 }
 
 // int (GUISlider *guisl)
-RuntimeScriptValue Sc_Slider_GetMax(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_GetMax(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUISlider, Slider_GetMax);
 }
 
 // void (GUISlider *guisl, int valn)
-RuntimeScriptValue Sc_Slider_SetMax(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_SetMax(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUISlider, Slider_SetMax);
 }
 
 // int (GUISlider *guisl)
-RuntimeScriptValue Sc_Slider_GetMin(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_GetMin(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUISlider, Slider_GetMin);
 }
 
 // void (GUISlider *guisl, int valn)
-RuntimeScriptValue Sc_Slider_SetMin(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_SetMin(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUISlider, Slider_SetMin);
 }
 
 // int (GUISlider *guisl)
-RuntimeScriptValue Sc_Slider_GetValue(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_GetValue(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUISlider, Slider_GetValue);
 }
 
 // void Slider_SetValue(GUISlider *guisl, int valn)
-RuntimeScriptValue Sc_Slider_SetValue(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Slider_SetValue(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUISlider, Slider_SetValue);
 }
 
diff --git a/engines/ags/engine/ac/speech.cpp b/engines/ags/engine/ac/speech.cpp
index cb8a35f14f..8164c12362 100644
--- a/engines/ags/engine/ac/speech.cpp
+++ b/engines/ags/engine/ac/speech.cpp
@@ -89,35 +89,35 @@ SkipSpeechStyle internal_skip_speech_to_user(int internal_val) {
 extern GameSetupStruct game;
 extern GameState play;
 
-RuntimeScriptValue Sc_Speech_GetAnimationStopTimeMargin(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetAnimationStopTimeMargin(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(play.close_mouth_speech_time);
 }
 
-RuntimeScriptValue Sc_Speech_SetAnimationStopTimeMargin(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetAnimationStopTimeMargin(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARSET_PINT(play.close_mouth_speech_time);
 }
 
-RuntimeScriptValue Sc_Speech_GetCustomPortraitPlacement(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetCustomPortraitPlacement(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(play.speech_portrait_placement);
 }
 
-RuntimeScriptValue Sc_Speech_SetCustomPortraitPlacement(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetCustomPortraitPlacement(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARSET_PINT(play.speech_portrait_placement);
 }
 
-RuntimeScriptValue Sc_Speech_GetDisplayPostTimeMs(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetDisplayPostTimeMs(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(play.speech_display_post_time_ms);
 }
 
-RuntimeScriptValue Sc_Speech_SetDisplayPostTimeMs(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetDisplayPostTimeMs(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARSET_PINT(play.speech_display_post_time_ms);
 }
 
-RuntimeScriptValue Sc_Speech_GetGlobalSpeechAnimationDelay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetGlobalSpeechAnimationDelay(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(play.talkanim_speed);
 }
 
-RuntimeScriptValue Sc_Speech_SetGlobalSpeechAnimationDelay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetGlobalSpeechAnimationDelay(const RuntimeScriptValue *params, int32_t param_count) {
 	if (game.options[OPT_GLOBALTALKANIMSPD] == 0) {
 		debug_script_warn("Speech.GlobalSpeechAnimationDelay cannot be set when global speech animation speed is not enabled; set Speech.UseGlobalSpeechAnimationDelay first!");
 		return RuntimeScriptValue();
@@ -125,71 +125,71 @@ RuntimeScriptValue Sc_Speech_SetGlobalSpeechAnimationDelay(const RuntimeScriptVa
 	API_VARSET_PINT(play.talkanim_speed);
 }
 
-RuntimeScriptValue Sc_Speech_GetPortraitXOffset(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetPortraitXOffset(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(play.speech_portrait_x);
 }
 
-RuntimeScriptValue Sc_Speech_SetPortraitXOffset(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetPortraitXOffset(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARSET_PINT(play.speech_portrait_x);
 }
 
-RuntimeScriptValue Sc_Speech_GetPortraitY(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetPortraitY(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(play.speech_portrait_y);
 }
 
-RuntimeScriptValue Sc_Speech_SetPortraitY(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetPortraitY(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARSET_PINT(play.speech_portrait_y);
 }
 
-RuntimeScriptValue Sc_Speech_GetStyle(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetStyle(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(game.options[OPT_SPEECHTYPE]);
 }
 
-extern RuntimeScriptValue Sc_SetSpeechStyle(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SetSpeechStyle(const RuntimeScriptValue *params, int32_t param_count);
 
-RuntimeScriptValue Sc_Speech_GetSkipKey(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetSkipKey(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(play.skip_speech_specific_key);
 }
 
-RuntimeScriptValue Sc_Speech_SetSkipKey(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetSkipKey(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARSET_PINT(play.skip_speech_specific_key);
 }
 
-RuntimeScriptValue Sc_Speech_GetSkipStyle(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetSkipStyle(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetSkipSpeech);
 }
 
-extern RuntimeScriptValue Sc_SetSkipSpeech(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SetSkipSpeech(const RuntimeScriptValue *params, int32_t param_count);
 
-RuntimeScriptValue Sc_Speech_GetTextAlignment(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetTextAlignment(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(play.speech_text_align);
 }
 
-RuntimeScriptValue Sc_Speech_SetTextAlignment_Old(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetTextAlignment_Old(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_VARIABLE_VALUE(play.speech_text_align);
 	play.speech_text_align = ReadScriptAlignment(params[0].IValue);
 	return RuntimeScriptValue();
 }
 
-RuntimeScriptValue Sc_Speech_SetTextAlignment(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetTextAlignment(const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_VARIABLE_VALUE(play.speech_text_align);
 	play.speech_text_align = (HorAlignment)params[0].IValue;
 	return RuntimeScriptValue();
 }
 
-RuntimeScriptValue Sc_Speech_GetUseGlobalSpeechAnimationDelay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetUseGlobalSpeechAnimationDelay(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARGET_INT(game.options[OPT_GLOBALTALKANIMSPD]);
 }
 
-RuntimeScriptValue Sc_Speech_SetUseGlobalSpeechAnimationDelay(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_SetUseGlobalSpeechAnimationDelay(const RuntimeScriptValue *params, int32_t param_count) {
 	API_VARSET_PINT(game.options[OPT_GLOBALTALKANIMSPD]);
 }
 
-RuntimeScriptValue Sc_Speech_GetVoiceMode(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Speech_GetVoiceMode(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(GetVoiceMode);
 }
 
-extern RuntimeScriptValue Sc_SetVoiceMode(const RuntimeScriptValue *params, int param_count);
+extern RuntimeScriptValue Sc_SetVoiceMode(const RuntimeScriptValue *params, int32_t param_count);
 
 void RegisterSpeechAPI(ScriptAPIVersion base_api, ScriptAPIVersion compat_api) {
 	ccAddExternalStaticFunction("Speech::get_AnimationStopTimeMargin", Sc_Speech_GetAnimationStopTimeMargin);
diff --git a/engines/ags/engine/ac/statobj/agsstaticobject.cpp b/engines/ags/engine/ac/statobj/agsstaticobject.cpp
index c7eb3eb075..4cc1f476cc 100644
--- a/engines/ags/engine/ac/statobj/agsstaticobject.cpp
+++ b/engines/ags/engine/ac/statobj/agsstaticobject.cpp
@@ -38,16 +38,16 @@ void AGSStaticObject::Read(const char *address, intptr_t offset, void *dest, int
 	memcpy(dest, address + offset, size);
 }
 
-uint8 AGSStaticObject::ReadInt8(const char *address, intptr_t offset) {
-	return *(const uint8 *)(address + offset);
+uint8_t AGSStaticObject::ReadInt8(const char *address, intptr_t offset) {
+	return *(const uint8_t *)(address + offset);
 }
 
-int16 AGSStaticObject::ReadInt16(const char *address, intptr_t offset) {
-	return *(const int16 *)(address + offset);
+int16_t AGSStaticObject::ReadInt16(const char *address, intptr_t offset) {
+	return *(const int16_t *)(address + offset);
 }
 
-int AGSStaticObject::ReadInt32(const char *address, intptr_t offset) {
-	return *(const int *)(address + offset);
+int32_t AGSStaticObject::ReadInt32(const char *address, intptr_t offset) {
+	return *(const int32_t *)(address + offset);
 }
 
 float AGSStaticObject::ReadFloat(const char *address, intptr_t offset) {
@@ -58,16 +58,16 @@ void AGSStaticObject::Write(const char *address, intptr_t offset, void *src, int
 	memcpy((void *)(const_cast<char *>(address) + offset), src, size);
 }
 
-void AGSStaticObject::WriteInt8(const char *address, intptr_t offset, uint8 val) {
-	*(uint8 *)(const_cast<char *>(address) + offset) = val;
+void AGSStaticObject::WriteInt8(const char *address, intptr_t offset, uint8_t val) {
+	*(uint8_t *)(const_cast<char *>(address) + offset) = val;
 }
 
-void AGSStaticObject::WriteInt16(const char *address, intptr_t offset, int16 val) {
-	*(int16 *)(const_cast<char *>(address) + offset) = val;
+void AGSStaticObject::WriteInt16(const char *address, intptr_t offset, int16_t val) {
+	*(int16_t *)(const_cast<char *>(address) + offset) = val;
 }
 
-void AGSStaticObject::WriteInt32(const char *address, intptr_t offset, int val) {
-	*(int *)(const_cast<char *>(address) + offset) = val;
+void AGSStaticObject::WriteInt32(const char *address, intptr_t offset, int32_t val) {
+	*(int32_t *)(const_cast<char *>(address) + offset) = val;
 }
 
 void AGSStaticObject::WriteFloat(const char *address, intptr_t offset, float val) {
@@ -75,15 +75,15 @@ void AGSStaticObject::WriteFloat(const char *address, intptr_t offset, float val
 }
 
 
-void StaticGame::WriteInt32(const char *address, intptr_t offset, int val) {
-	if (offset == 4 * sizeof(int)) {
+void StaticGame::WriteInt32(const char *address, intptr_t offset, int32_t val) {
+	if (offset == 4 * sizeof(int32_t)) {
 		// game.debug_mode
 		set_debug_mode(val != 0);
-	} else if (offset == 99 * sizeof(int) || offset == 112 * sizeof(int)) {
+	} else if (offset == 99 * sizeof(int32_t) || offset == 112 * sizeof(int32_t)) {
 		// game.text_align, game.speech_text_align
-		*(int *)(const_cast<char *>(address) + offset) = ReadScriptAlignment(val);
+		*(int32_t *)(const_cast<char *>(address) + offset) = ReadScriptAlignment(val);
 	} else {
-		*(int *)(const_cast<char *>(address) + offset) = val;
+		*(int32_t *)(const_cast<char *>(address) + offset) = val;
 	}
 }
 
diff --git a/engines/ags/engine/ac/statobj/agsstaticobject.h b/engines/ags/engine/ac/statobj/agsstaticobject.h
index 11d1555a61..d4e6e3c8d7 100644
--- a/engines/ags/engine/ac/statobj/agsstaticobject.h
+++ b/engines/ags/engine/ac/statobj/agsstaticobject.h
@@ -33,20 +33,20 @@ struct AGSStaticObject : public ICCStaticObject {
 	// Legacy support for reading and writing object values by their relative offset
 	const char *GetFieldPtr(const char *address, intptr_t offset) override;
 	void    Read(const char *address, intptr_t offset, void *dest, int size) override;
-	uint8 ReadInt8(const char *address, intptr_t offset) override;
-	int16 ReadInt16(const char *address, intptr_t offset) override;
-	int ReadInt32(const char *address, intptr_t offset) override;
+	uint8_t ReadInt8(const char *address, intptr_t offset) override;
+	int16_t ReadInt16(const char *address, intptr_t offset) override;
+	int32_t ReadInt32(const char *address, intptr_t offset) override;
 	float   ReadFloat(const char *address, intptr_t offset) override;
 	void    Write(const char *address, intptr_t offset, void *src, int size) override;
-	void    WriteInt8(const char *address, intptr_t offset, uint8 val) override;
-	void    WriteInt16(const char *address, intptr_t offset, int16 val) override;
-	void    WriteInt32(const char *address, intptr_t offset, int val) override;
+	void    WriteInt8(const char *address, intptr_t offset, uint8_t val) override;
+	void    WriteInt16(const char *address, intptr_t offset, int16_t val) override;
+	void    WriteInt32(const char *address, intptr_t offset, int32_t val) override;
 	void    WriteFloat(const char *address, intptr_t offset, float val) override;
 };
 
 // Wrapper around script's "Game" struct, managing access to its variables
 struct StaticGame : public AGSStaticObject {
-	void    WriteInt32(const char *address, intptr_t offset, int val) override;
+	void    WriteInt32(const char *address, intptr_t offset, int32_t val) override;
 };
 
 extern AGSStaticObject GlobalStaticManager;
diff --git a/engines/ags/engine/ac/statobj/staticarray.cpp b/engines/ags/engine/ac/statobj/staticarray.cpp
index d30b128d05..dd02d047cf 100644
--- a/engines/ags/engine/ac/statobj/staticarray.cpp
+++ b/engines/ags/engine/ac/statobj/staticarray.cpp
@@ -72,34 +72,34 @@ void StaticArray::Read(const char *address, intptr_t offset, void *dest, int siz
 	memcpy(dest, el_ptr + offset % _elemLegacySize, size);
 }
 
-uint8 StaticArray::ReadInt8(const char *address, intptr_t offset) {
+uint8_t StaticArray::ReadInt8(const char *address, intptr_t offset) {
 	const char *el_ptr = GetElementPtr(address, offset);
 	if (_staticMgr) {
 		return _staticMgr->ReadInt8(el_ptr, offset % _elemLegacySize);
 	} else if (_dynamicMgr) {
 		return _dynamicMgr->ReadInt8(el_ptr, offset % _elemLegacySize);
 	}
-	return *(const uint8 *)(el_ptr + offset % _elemLegacySize);
+	return *(const uint8_t *)(el_ptr + offset % _elemLegacySize);
 }
 
-int16 StaticArray::ReadInt16(const char *address, intptr_t offset) {
+int16_t StaticArray::ReadInt16(const char *address, intptr_t offset) {
 	const char *el_ptr = GetElementPtr(address, offset);
 	if (_staticMgr) {
 		return _staticMgr->ReadInt16(el_ptr, offset % _elemLegacySize);
 	} else if (_dynamicMgr) {
 		return _dynamicMgr->ReadInt16(el_ptr, offset % _elemLegacySize);
 	}
-	return *(const uint16 *)(el_ptr + offset % _elemLegacySize);
+	return *(const uint16_t *)(el_ptr + offset % _elemLegacySize);
 }
 
-int StaticArray::ReadInt32(const char *address, intptr_t offset) {
+int32_t StaticArray::ReadInt32(const char *address, intptr_t offset) {
 	const char *el_ptr = GetElementPtr(address, offset);
 	if (_staticMgr) {
 		return _staticMgr->ReadInt32(el_ptr, offset % _elemLegacySize);
 	} else if (_dynamicMgr) {
 		return _dynamicMgr->ReadInt32(el_ptr, offset % _elemLegacySize);
 	}
-	return *(const uint32 *)(el_ptr + offset % _elemLegacySize);
+	return *(const uint32_t *)(el_ptr + offset % _elemLegacySize);
 }
 
 float StaticArray::ReadFloat(const char *address, intptr_t offset) {
@@ -123,36 +123,36 @@ void StaticArray::Write(const char *address, intptr_t offset, void *src, int siz
 	}
 }
 
-void StaticArray::WriteInt8(const char *address, intptr_t offset, uint8 val) {
+void StaticArray::WriteInt8(const char *address, intptr_t offset, uint8_t val) {
 	const char *el_ptr = GetElementPtr(address, offset);
 	if (_staticMgr) {
 		return _staticMgr->WriteInt8(el_ptr, offset % _elemLegacySize, val);
 	} else if (_dynamicMgr) {
 		return _dynamicMgr->WriteInt8(el_ptr, offset % _elemLegacySize, val);
 	} else {
-		*(uint8 *)(const_cast<char *>(el_ptr) + offset % _elemLegacySize) = val;
+		*(uint8_t *)(const_cast<char *>(el_ptr) + offset % _elemLegacySize) = val;
 	}
 }
 
-void StaticArray::WriteInt16(const char *address, intptr_t offset, int16 val) {
+void StaticArray::WriteInt16(const char *address, intptr_t offset, int16_t val) {
 	const char *el_ptr = GetElementPtr(address, offset);
 	if (_staticMgr) {
 		return _staticMgr->WriteInt16(el_ptr, offset % _elemLegacySize, val);
 	} else if (_dynamicMgr) {
 		return _dynamicMgr->WriteInt16(el_ptr, offset % _elemLegacySize, val);
 	} else {
-		*(uint16 *)(const_cast<char *>(el_ptr) + offset % _elemLegacySize) = val;
+		*(uint16_t *)(const_cast<char *>(el_ptr) + offset % _elemLegacySize) = val;
 	}
 }
 
-void StaticArray::WriteInt32(const char *address, intptr_t offset, int val) {
+void StaticArray::WriteInt32(const char *address, intptr_t offset, int32_t val) {
 	const char *el_ptr = GetElementPtr(address, offset);
 	if (_staticMgr) {
 		return _staticMgr->WriteInt32(el_ptr, offset % _elemLegacySize, val);
 	} else if (_dynamicMgr) {
 		return _dynamicMgr->WriteInt32(el_ptr, offset % _elemLegacySize, val);
 	} else {
-		*(uint32 *)(const_cast<char *>(el_ptr) + offset % _elemLegacySize) = val;
+		*(uint32_t *)(const_cast<char *>(el_ptr) + offset % _elemLegacySize) = val;
 	}
 }
 
diff --git a/engines/ags/engine/ac/statobj/staticarray.h b/engines/ags/engine/ac/statobj/staticarray.h
index bc3ef2b3e5..eba2f1d741 100644
--- a/engines/ags/engine/ac/statobj/staticarray.h
+++ b/engines/ags/engine/ac/statobj/staticarray.h
@@ -49,14 +49,14 @@ public:
 
 	const char *GetFieldPtr(const char *address, intptr_t offset) override;
 	void    Read(const char *address, intptr_t offset, void *dest, int size) override;
-	uint8 ReadInt8(const char *address, intptr_t offset) override;
-	int16 ReadInt16(const char *address, intptr_t offset) override;
-	int ReadInt32(const char *address, intptr_t offset) override;
+	uint8_t ReadInt8(const char *address, intptr_t offset) override;
+	int16_t ReadInt16(const char *address, intptr_t offset) override;
+	int32_t ReadInt32(const char *address, intptr_t offset) override;
 	float   ReadFloat(const char *address, intptr_t offset) override;
 	void    Write(const char *address, intptr_t offset, void *src, int size) override;
-	void    WriteInt8(const char *address, intptr_t offset, uint8 val) override;
-	void    WriteInt16(const char *address, intptr_t offset, int16 val) override;
-	void    WriteInt32(const char *address, intptr_t offset, int val) override;
+	void    WriteInt8(const char *address, intptr_t offset, uint8_t val) override;
+	void    WriteInt16(const char *address, intptr_t offset, int16_t val) override;
+	void    WriteInt32(const char *address, intptr_t offset, int32_t val) override;
 	void    WriteFloat(const char *address, intptr_t offset, float val) override;
 
 private:
diff --git a/engines/ags/engine/ac/statobj/staticobject.h b/engines/ags/engine/ac/statobj/staticobject.h
index cd35af3482..e776837ae3 100644
--- a/engines/ags/engine/ac/statobj/staticobject.h
+++ b/engines/ags/engine/ac/statobj/staticobject.h
@@ -41,14 +41,14 @@ struct ICCStaticObject {
 	// Legacy support for reading and writing object values by their relative offset
 	virtual const char *GetFieldPtr(const char *address, intptr_t offset) = 0;
 	virtual void    Read(const char *address, intptr_t offset, void *dest, int size) = 0;
-	virtual uint8 ReadInt8(const char *address, intptr_t offset) = 0;
-	virtual int16 ReadInt16(const char *address, intptr_t offset) = 0;
-	virtual int ReadInt32(const char *address, intptr_t offset) = 0;
+	virtual uint8_t ReadInt8(const char *address, intptr_t offset) = 0;
+	virtual int16_t ReadInt16(const char *address, intptr_t offset) = 0;
+	virtual int32_t ReadInt32(const char *address, intptr_t offset) = 0;
 	virtual float   ReadFloat(const char *address, intptr_t offset) = 0;
 	virtual void    Write(const char *address, intptr_t offset, void *src, int size) = 0;
-	virtual void    WriteInt8(const char *address, intptr_t offset, uint8 val) = 0;
-	virtual void    WriteInt16(const char *address, intptr_t offset, int16 val) = 0;
-	virtual void    WriteInt32(const char *address, intptr_t offset, int val) = 0;
+	virtual void    WriteInt8(const char *address, intptr_t offset, uint8_t val) = 0;
+	virtual void    WriteInt16(const char *address, intptr_t offset, int16_t val) = 0;
+	virtual void    WriteInt32(const char *address, intptr_t offset, int32_t val) = 0;
 	virtual void    WriteFloat(const char *address, intptr_t offset, float val) = 0;
 };
 
diff --git a/engines/ags/engine/ac/string.cpp b/engines/ags/engine/ac/string.cpp
index 31d021e85b..d679db77ad 100644
--- a/engines/ags/engine/ac/string.cpp
+++ b/engines/ags/engine/ac/string.cpp
@@ -225,7 +225,7 @@ DynObjectRef CreateNewScriptStringObj(const char *fromText, bool reAllocate) {
 		str->text = const_cast<char *>(fromText);
 	}
 	void *obj_ptr = str->text;
-	int handle = ccRegisterManagedObject(obj_ptr, str);
+	int32_t handle = ccRegisterManagedObject(obj_ptr, str);
 	if (handle == 0) {
 		delete str;
 		return DynObjectRef(0, nullptr);
@@ -304,97 +304,97 @@ void my_strncpy(char *dest, const char *src, int len) {
 //=============================================================================
 
 // int (const char *thisString)
-RuntimeScriptValue Sc_String_IsNullOrEmpty(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_IsNullOrEmpty(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT_POBJ(String_IsNullOrEmpty, const char);
 }
 
 // const char* (const char *thisString, const char *extrabit)
-RuntimeScriptValue Sc_String_Append(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_Append(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_POBJ(const char, const char, myScriptStringImpl, String_Append, const char);
 }
 
 // const char* (const char *thisString, char extraOne)
-RuntimeScriptValue Sc_String_AppendChar(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_AppendChar(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_PINT(const char, const char, myScriptStringImpl, String_AppendChar);
 }
 
 // int (const char *thisString, const char *otherString, bool caseSensitive)
-RuntimeScriptValue Sc_String_CompareTo(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_CompareTo(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ_PBOOL(const char, String_CompareTo, const char);
 }
 
 // int  (const char *s1, const char *s2)
-RuntimeScriptValue Sc_StrContains(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StrContains(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ(const char, StrContains, const char);
 }
 
 // const char* (const char *srcString)
-RuntimeScriptValue Sc_String_Copy(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_Copy(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(const char, const char, myScriptStringImpl, String_Copy);
 }
 
 // int (const char *thisString, const char *checkForString, bool caseSensitive)
-RuntimeScriptValue Sc_String_EndsWith(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_EndsWith(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ_PBOOL(const char, String_EndsWith, const char);
 }
 
 // const char* (const char *texx, ...)
-RuntimeScriptValue Sc_String_Format(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_Format(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(String_Format, 1);
 	return RuntimeScriptValue().SetDynamicObject(const_cast<char *>(CreateNewScriptString(scsf_buffer)), &myScriptStringImpl);
 }
 
 // const char* (const char *thisString)
-RuntimeScriptValue Sc_String_LowerCase(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_LowerCase(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(const char, const char, myScriptStringImpl, String_LowerCase);
 }
 
 // const char* (const char *thisString, const char *lookForText, const char *replaceWithText, bool caseSensitive)
-RuntimeScriptValue Sc_String_Replace(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_Replace(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_POBJ2_PBOOL(const char, const char, myScriptStringImpl, String_Replace, const char, const char);
 }
 
 // const char* (const char *thisString, int index, char newChar)
-RuntimeScriptValue Sc_String_ReplaceCharAt(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_ReplaceCharAt(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_PINT2(const char, const char, myScriptStringImpl, String_ReplaceCharAt);
 }
 
 // int (const char *thisString, const char *checkForString, bool caseSensitive)
-RuntimeScriptValue Sc_String_StartsWith(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_StartsWith(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_POBJ_PBOOL(const char, String_StartsWith, const char);
 }
 
 // const char* (const char *thisString, int index, int length)
-RuntimeScriptValue Sc_String_Substring(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_Substring(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_PINT2(const char, const char, myScriptStringImpl, String_Substring);
 }
 
 // const char* (const char *thisString, int length)
-RuntimeScriptValue Sc_String_Truncate(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_Truncate(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ_PINT(const char, const char, myScriptStringImpl, String_Truncate);
 }
 
 // const char* (const char *thisString)
-RuntimeScriptValue Sc_String_UpperCase(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_UpperCase(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(const char, const char, myScriptStringImpl, String_UpperCase);
 }
 
 // FLOAT_RETURN_TYPE (const char *theString);
-RuntimeScriptValue Sc_StringToFloat(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StringToFloat(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_FLOAT(const char, StringToFloat);
 }
 
 // int (char*stino)
-RuntimeScriptValue Sc_StringToInt(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_StringToInt(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(const char, StringToInt);
 }
 
 // int (const char *texx, int index)
-RuntimeScriptValue Sc_String_GetChars(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_String_GetChars(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT_PINT(const char, String_GetChars);
 }
 
-RuntimeScriptValue Sc_strlen(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_strlen(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	ASSERT_SELF(strlen);
 	return RuntimeScriptValue().SetInt32(strlen((const char *)self));
 }
diff --git a/engines/ags/engine/ac/system.cpp b/engines/ags/engine/ac/system.cpp
index 3b38c3c8d8..a390118928 100644
--- a/engines/ags/engine/ac/system.cpp
+++ b/engines/ags/engine/ac/system.cpp
@@ -222,139 +222,139 @@ void System_SetRenderAtScreenResolution(int enable) {
 extern ScriptString myScriptStringImpl;
 
 // int ()
-RuntimeScriptValue Sc_System_GetAudioChannelCount(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetAudioChannelCount(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetAudioChannelCount);
 }
 
 // ScriptAudioChannel* (int index)
-RuntimeScriptValue Sc_System_GetAudioChannels(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetAudioChannels(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJ_PINT(ScriptAudioChannel, ccDynamicAudio, System_GetAudioChannels);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetCapsLock(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetCapsLock(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetCapsLock);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetColorDepth(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetColorDepth(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetColorDepth);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetGamma(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetGamma(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetGamma);
 }
 
 // void (int newValue)
-RuntimeScriptValue Sc_System_SetGamma(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_SetGamma(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(System_SetGamma);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetHardwareAcceleration(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetHardwareAcceleration(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetHardwareAcceleration);
 }
 
-RuntimeScriptValue Sc_System_GetHasInputFocus(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetHasInputFocus(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_BOOL(System_HasInputFocus);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetNumLock(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetNumLock(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetNumLock);
 }
 
 // void (int newValue)
-RuntimeScriptValue Sc_System_SetNumLock(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_SetNumLock(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(System_SetNumLock);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetOS(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetOS(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetOS);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetScreenHeight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetScreenHeight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetScreenHeight);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetScreenWidth(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetScreenWidth(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetScreenWidth);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetScrollLock(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetScrollLock(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetScrollLock);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetSupportsGammaControl(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetSupportsGammaControl(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetSupportsGammaControl);
 }
 
 // const char *()
-RuntimeScriptValue Sc_System_GetVersion(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetVersion(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ(const char, myScriptStringImpl, System_GetVersion);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetViewportHeight(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetViewportHeight(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetViewportHeight);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetViewportWidth(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetViewportWidth(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetViewportWidth);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetVolume);
 }
 
 // void (int newvol)
-RuntimeScriptValue Sc_System_SetVolume(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_SetVolume(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(System_SetVolume);
 }
 
 // int ()
-RuntimeScriptValue Sc_System_GetVsync(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetVsync(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetVsync);
 }
 
 // void (int newValue)
-RuntimeScriptValue Sc_System_SetVsync(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_SetVsync(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(System_SetVsync);
 }
 
-RuntimeScriptValue Sc_System_GetWindowed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetWindowed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetWindowed);
 }
 
-RuntimeScriptValue Sc_System_SetWindowed(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_SetWindowed(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(System_SetWindowed);
 }
 
 // const char *()
-RuntimeScriptValue Sc_System_GetRuntimeInfo(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetRuntimeInfo(const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_SCALL_OBJ(const char, myScriptStringImpl, System_GetRuntimeInfo);
 }
 
-RuntimeScriptValue Sc_System_GetRenderAtScreenResolution(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_GetRenderAtScreenResolution(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_INT(System_GetRenderAtScreenResolution);
 }
 
-RuntimeScriptValue Sc_System_SetRenderAtScreenResolution(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_SetRenderAtScreenResolution(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_VOID_PINT(System_SetRenderAtScreenResolution);
 }
 
-RuntimeScriptValue Sc_System_Log(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_System_Log(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_SCRIPT_SPRINTF(Sc_System_Log, 2);
 	Debug::Printf(kDbgGroup_Script, (MessageType)params[0].IValue, "%s", scsf_buffer);
-	return RuntimeScriptValue((int)0);
+	return RuntimeScriptValue((int32_t)0);
 }
 
 
diff --git a/engines/ags/engine/ac/textbox.cpp b/engines/ags/engine/ac/textbox.cpp
index e8cebb1db3..c8cea8558e 100644
--- a/engines/ags/engine/ac/textbox.cpp
+++ b/engines/ags/engine/ac/textbox.cpp
@@ -98,46 +98,46 @@ void TextBox_SetShowBorder(GUITextBox *guit, bool on) {
 extern ScriptString myScriptStringImpl;
 
 // void (GUITextBox *texbox, char *buffer)
-RuntimeScriptValue Sc_TextBox_GetText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_GetText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(GUITextBox, TextBox_GetText, char);
 }
 
 // void (GUITextBox *texbox, const char *newtex)
-RuntimeScriptValue Sc_TextBox_SetText(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_SetText(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(GUITextBox, TextBox_SetText, const char);
 }
 
 // int (GUITextBox *guit)
-RuntimeScriptValue Sc_TextBox_GetFont(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_GetFont(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUITextBox, TextBox_GetFont);
 }
 
 // void (GUITextBox *guit, int fontnum)
-RuntimeScriptValue Sc_TextBox_SetFont(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_SetFont(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUITextBox, TextBox_SetFont);
 }
 
-RuntimeScriptValue Sc_TextBox_GetShowBorder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_GetShowBorder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(GUITextBox, TextBox_GetShowBorder);
 }
 
 // void (GUITextBox *guit, int fontnum)
-RuntimeScriptValue Sc_TextBox_SetShowBorder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_SetShowBorder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PBOOL(GUITextBox, TextBox_SetShowBorder);
 }
 
 // const char* (GUITextBox *texbox)
-RuntimeScriptValue Sc_TextBox_GetText_New(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_GetText_New(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_CONST_OBJCALL_OBJ(GUITextBox, const char, myScriptStringImpl, TextBox_GetText_New);
 }
 
 // int (GUITextBox *guit)
-RuntimeScriptValue Sc_TextBox_GetTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_GetTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(GUITextBox, TextBox_GetTextColor);
 }
 
 // void (GUITextBox *guit, int colr)
-RuntimeScriptValue Sc_TextBox_SetTextColor(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_TextBox_SetTextColor(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(GUITextBox, TextBox_SetTextColor);
 }
 
diff --git a/engines/ags/engine/ac/viewframe.cpp b/engines/ags/engine/ac/viewframe.cpp
index a25da7cdd7..6faa57becc 100644
--- a/engines/ags/engine/ac/viewframe.cpp
+++ b/engines/ags/engine/ac/viewframe.cpp
@@ -183,56 +183,56 @@ void DrawViewFrame(Bitmap *ds, const ViewFrame *vframe, int x, int y, bool alpha
 //=============================================================================
 
 // int (ScriptViewFrame *svf)
-RuntimeScriptValue Sc_ViewFrame_GetFlipped(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_GetFlipped(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewFrame, ViewFrame_GetFlipped);
 }
 
 // int (ScriptViewFrame *svf)
-RuntimeScriptValue Sc_ViewFrame_GetFrame(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_GetFrame(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewFrame, ViewFrame_GetFrame);
 }
 // int (ScriptViewFrame *svf)
-RuntimeScriptValue Sc_ViewFrame_GetGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_GetGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewFrame, ViewFrame_GetGraphic);
 }
 
 // void (ScriptViewFrame *svf, int newPic)
-RuntimeScriptValue Sc_ViewFrame_SetGraphic(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_SetGraphic(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptViewFrame, ViewFrame_SetGraphic);
 }
 
 // ScriptAudioClip* (ScriptViewFrame *svf)
-RuntimeScriptValue Sc_ViewFrame_GetLinkedAudio(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_GetLinkedAudio(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJ(ScriptViewFrame, ScriptAudioClip, ccDynamicAudioClip, ViewFrame_GetLinkedAudio);
 }
 
 // void (ScriptViewFrame *svf, ScriptAudioClip* clip)
-RuntimeScriptValue Sc_ViewFrame_SetLinkedAudio(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_SetLinkedAudio(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(ScriptViewFrame, ViewFrame_SetLinkedAudio, ScriptAudioClip);
 }
 
 // int (ScriptViewFrame *svf)
-RuntimeScriptValue Sc_ViewFrame_GetLoop(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_GetLoop(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewFrame, ViewFrame_GetLoop);
 }
 
 // int (ScriptViewFrame *svf)
-RuntimeScriptValue Sc_ViewFrame_GetSound(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_GetSound(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewFrame, ViewFrame_GetSound);
 }
 
 // void (ScriptViewFrame *svf, int newSound)
-RuntimeScriptValue Sc_ViewFrame_SetSound(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_SetSound(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptViewFrame, ViewFrame_SetSound);
 }
 
 // int (ScriptViewFrame *svf)
-RuntimeScriptValue Sc_ViewFrame_GetSpeed(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_GetSpeed(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewFrame, ViewFrame_GetSpeed);
 }
 
 // int (ScriptViewFrame *svf)
-RuntimeScriptValue Sc_ViewFrame_GetView(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_ViewFrame_GetView(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewFrame, ViewFrame_GetView);
 }
 
diff --git a/engines/ags/engine/ac/viewport_script.cpp b/engines/ags/engine/ac/viewport_script.cpp
index c12795df6d..23edbfa232 100644
--- a/engines/ags/engine/ac/viewport_script.cpp
+++ b/engines/ags/engine/ac/viewport_script.cpp
@@ -170,59 +170,59 @@ void Camera_SetSize(ScriptCamera *scam, int width, int height) {
 	play.GetRoomCamera(scam->GetID())->SetSize(Size(width, height));
 }
 
-RuntimeScriptValue Sc_Camera_Create(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_Create(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO(ScriptCamera, Camera_Create);
 }
 
-RuntimeScriptValue Sc_Camera_Delete(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_Delete(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptCamera, Camera_Delete);
 }
 
-RuntimeScriptValue Sc_Camera_GetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_GetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptCamera, Camera_GetX);
 }
 
-RuntimeScriptValue Sc_Camera_SetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_SetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptCamera, Camera_SetX);
 }
 
-RuntimeScriptValue Sc_Camera_GetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_GetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptCamera, Camera_GetY);
 }
 
-RuntimeScriptValue Sc_Camera_SetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_SetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptCamera, Camera_SetY);
 }
 
-RuntimeScriptValue Sc_Camera_GetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_GetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptCamera, Camera_GetWidth);
 }
 
-RuntimeScriptValue Sc_Camera_SetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_SetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptCamera, Camera_SetWidth);
 }
 
-RuntimeScriptValue Sc_Camera_GetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_GetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptCamera, Camera_GetHeight);
 }
 
-RuntimeScriptValue Sc_Camera_SetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_SetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptCamera, Camera_SetHeight);
 }
 
-RuntimeScriptValue Sc_Camera_GetAutoTracking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_GetAutoTracking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(ScriptCamera, Camera_GetAutoTracking);
 }
 
-RuntimeScriptValue Sc_Camera_SetAutoTracking(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_SetAutoTracking(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PBOOL(ScriptCamera, Camera_SetAutoTracking);
 }
 
-RuntimeScriptValue Sc_Camera_SetAt(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_SetAt(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptCamera, Camera_SetAt);
 }
 
-RuntimeScriptValue Sc_Camera_SetSize(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Camera_SetSize(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT2(ScriptCamera, Camera_SetSize);
 }
 
@@ -436,83 +436,83 @@ ScriptUserObject *Viewport_RoomToScreenPoint(ScriptViewport *scv, int roomx, int
 	return ScriptStructHelpers::CreatePoint(pt.X, pt.Y);
 }
 
-RuntimeScriptValue Sc_Viewport_Create(const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_Create(const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO(ScriptViewport, Viewport_Create);
 }
 
-RuntimeScriptValue Sc_Viewport_Delete(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_Delete(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID(ScriptViewport, Viewport_Delete);
 }
 
-RuntimeScriptValue Sc_Viewport_GetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_GetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewport, Viewport_GetX);
 }
 
-RuntimeScriptValue Sc_Viewport_SetX(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_SetX(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptViewport, Viewport_SetX);
 }
 
-RuntimeScriptValue Sc_Viewport_GetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_GetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewport, Viewport_GetY);
 }
 
-RuntimeScriptValue Sc_Viewport_SetY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_SetY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptViewport, Viewport_SetY);
 }
 
-RuntimeScriptValue Sc_Viewport_GetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_GetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewport, Viewport_GetWidth);
 }
 
-RuntimeScriptValue Sc_Viewport_SetWidth(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_SetWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptViewport, Viewport_SetWidth);
 }
 
-RuntimeScriptValue Sc_Viewport_GetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_GetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewport, Viewport_GetHeight);
 }
 
-RuntimeScriptValue Sc_Viewport_SetHeight(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_SetHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptViewport, Viewport_SetHeight);
 }
 
-RuntimeScriptValue Sc_Viewport_GetCamera(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_GetCamera(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJAUTO(ScriptViewport, ScriptCamera, Viewport_GetCamera);
 }
 
-RuntimeScriptValue Sc_Viewport_SetCamera(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_SetCamera(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_POBJ(ScriptViewport, Viewport_SetCamera, ScriptCamera);
 }
 
-RuntimeScriptValue Sc_Viewport_GetVisible(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_GetVisible(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_BOOL(ScriptViewport, Viewport_GetVisible);
 }
 
-RuntimeScriptValue Sc_Viewport_SetVisible(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_SetVisible(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PBOOL(ScriptViewport, Viewport_SetVisible);
 }
 
-RuntimeScriptValue Sc_Viewport_GetZOrder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_GetZOrder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_INT(ScriptViewport, Viewport_GetZOrder);
 }
 
-RuntimeScriptValue Sc_Viewport_SetZOrder(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_SetZOrder(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT(ScriptViewport, Viewport_SetZOrder);
 }
 
-RuntimeScriptValue Sc_Viewport_GetAtScreenXY(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_GetAtScreenXY(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_SCALL_OBJAUTO_PINT2(ScriptViewport, Viewport_GetAtScreenXY);
 }
 
-RuntimeScriptValue Sc_Viewport_SetPosition(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_SetPosition(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_VOID_PINT4(ScriptViewport, Viewport_SetPosition);
 }
 
-RuntimeScriptValue Sc_Viewport_ScreenToRoomPoint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_ScreenToRoomPoint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJAUTO_PINT2_PBOOL(ScriptViewport, ScriptUserObject, Viewport_ScreenToRoomPoint);
 }
 
-RuntimeScriptValue Sc_Viewport_RoomToScreenPoint(void *self, const RuntimeScriptValue *params, int param_count) {
+RuntimeScriptValue Sc_Viewport_RoomToScreenPoint(void *self, const RuntimeScriptValue *params, int32_t param_count) {
 	API_OBJCALL_OBJAUTO_PINT2_PBOOL(ScriptViewport, ScriptUserObject, Viewport_RoomToScreenPoint);
 }
 
diff --git a/engines/ags/engine/ac/walkablearea.cpp b/engines/ags/engine/ac/walkablearea.cpp
index d1259d407e..f8a585a9bc 100644
--- a/engines/ags/engine/ac/walkablearea.cpp
+++ b/engines/ags/engine/ac/walkablearea.cpp
@@ -57,7 +57,7 @@ void redo_walkable_areas() {
 
 	int hh, ww;
 	for (hh = 0; hh < walkareabackup->GetHeight(); hh++) {
-		uint8 *walls_scanline = thisroom.WalkAreaMask->GetScanLineForWriting(hh);
+		uint8_t *walls_scanline = thisroom.WalkAreaMask->GetScanLineForWriting(hh);
 		for (ww = 0; ww < walkareabackup->GetWidth(); ww++) {
 			//      if (play.walkable_areas_on[_getpixel(thisroom.WalkAreaMask,ww,hh)]==0)
 			if (play.walkable_areas_on[walls_scanline[ww]] == 0)
diff --git a/engines/ags/engine/game/game_init.cpp b/engines/ags/engine/game/game_init.cpp
index 5813e7e6c9..7f33733c53 100644
--- a/engines/ags/engine/game/game_init.cpp
+++ b/engines/ags/engine/game/game_init.cpp
@@ -415,7 +415,7 @@ HGameInitError InitGameState(const LoadedGameEntities &ents, GameDataVersion dat
 		// labels are not clickable by default
 		guilabels[i].SetClickable(false);
 	}
-	play.gui_draw_order = (int *)calloc(game.numgui * sizeof(int), 1);
+	play.gui_draw_order = (int32_t *)calloc(game.numgui * sizeof(int32_t), 1);
 	update_gui_zorder();
 	calculate_reserved_channel_count();
 
diff --git a/engines/ags/engine/game/savegame_components.cpp b/engines/ags/engine/game/savegame_components.cpp
index b57a0239ac..6aa01c7457 100644
--- a/engines/ags/engine/game/savegame_components.cpp
+++ b/engines/ags/engine/game/savegame_components.cpp
@@ -290,7 +290,7 @@ void ReadViewportState(RestoredData &r_data, Stream *in) {
 	r_data.Viewports.push_back(view);
 }
 
-HSaveError ReadGameState(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadGameState(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	GameStateSvgVersion svg_ver = (GameStateSvgVersion)cmp_ver;
 	// Game base
@@ -394,7 +394,7 @@ HSaveError WriteAudio(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadAudio(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadAudio(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 
 	// Game content assertion
@@ -499,7 +499,7 @@ HSaveError WriteCharacters(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadCharacters(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadCharacters(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	if (!AssertGameContent(err, in->ReadInt32(), game.numcharacters, "Characters"))
 		return err;
@@ -525,7 +525,7 @@ HSaveError WriteDialogs(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadDialogs(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadDialogs(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	if (!AssertGameContent(err, in->ReadInt32(), game.numdialog, "Dialogs"))
 		return err;
@@ -580,7 +580,7 @@ HSaveError WriteGUI(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadGUI(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadGUI(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	const GuiSvgVersion svg_ver = (GuiSvgVersion)cmp_ver;
 	// GUI state
@@ -656,7 +656,7 @@ HSaveError WriteInventory(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadInventory(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadInventory(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	if (!AssertGameContent(err, in->ReadInt32(), game.numinvitems, "Inventory Items"))
 		return err;
@@ -677,7 +677,7 @@ HSaveError WriteMouseCursors(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadMouseCursors(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadMouseCursors(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	if (!AssertGameContent(err, in->ReadInt32(), game.numcursors, "Mouse Cursors"))
 		return err;
@@ -702,7 +702,7 @@ HSaveError WriteViews(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadViews(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadViews(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	if (!AssertGameContent(err, in->ReadInt32(), game.numviews, "Views"))
 		return err;
@@ -746,7 +746,7 @@ HSaveError WriteDynamicSprites(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadDynamicSprites(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadDynamicSprites(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	const int spr_count = in->ReadInt32();
 	// ensure the sprite set is at least large enough
@@ -771,7 +771,7 @@ HSaveError WriteOverlays(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadOverlays(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadOverlays(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	size_t over_count = in->ReadInt32();
 	for (size_t i = 0; i < over_count; ++i) {
@@ -797,7 +797,7 @@ HSaveError WriteDynamicSurfaces(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadDynamicSurfaces(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadDynamicSurfaces(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	if (!AssertCompatLimit(err, in->ReadInt32(), MAX_DYNAMIC_SURFACES, "Drawing Surfaces"))
 		return err;
@@ -829,7 +829,7 @@ HSaveError WriteScriptModules(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadScriptModules(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadScriptModules(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	// read the global script data segment
 	int data_len = in->ReadInt32();
@@ -872,7 +872,7 @@ HSaveError WriteRoomStates(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadRoomStates(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadRoomStates(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	int roomstat_count = in->ReadInt32();
 	for (; roomstat_count > 0; --roomstat_count) {
@@ -935,7 +935,7 @@ HSaveError WriteThisRoom(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadThisRoom(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadThisRoom(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	HSaveError err;
 	displayed_room = in->ReadInt32();
 	if (displayed_room < 0)
@@ -987,7 +987,7 @@ HSaveError WriteManagedPool(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadManagedPool(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadManagedPool(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	if (ccUnserializeAllObjects(in.get(), &ccUnserializer)) {
 		return new SavegameError(kSvgErr_GameObjectInitFailed,
 		                         String::FromFormat("Managed pool deserialization failed: %s", ccErrorString.GetCStr()));
@@ -1003,7 +1003,7 @@ HSaveError WritePluginData(PStream out) {
 	return HSaveError::None();
 }
 
-HSaveError ReadPluginData(PStream in, int cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
+HSaveError ReadPluginData(PStream in, int32_t cmp_ver, const PreservedParams &pp, RestoredData &r_data) {
 	auto pluginFileHandle = AGSE_RESTOREGAME;
 	pl_set_file_handle(pluginFileHandle, in.get());
 	pl_run_plugin_hooks(AGSE_RESTOREGAME, pluginFileHandle);
@@ -1015,10 +1015,10 @@ HSaveError ReadPluginData(PStream in, int cmp_ver, const PreservedParams &pp, Re
 // Description of a supported game state serialization component
 struct ComponentHandler {
 	String             Name;    // internal component's ID
-	int            Version; // current version to write and the highest supported version
-	int            LowestVersion; // lowest supported version that the engine can read
+	int32_t            Version; // current version to write and the highest supported version
+	int32_t            LowestVersion; // lowest supported version that the engine can read
 	HSaveError(*Serialize)(PStream);
-	HSaveError(*Unserialize)(PStream, int cmp_ver, const PreservedParams &, RestoredData &);
+	HSaveError(*Unserialize)(PStream, int32_t cmp_ver, const PreservedParams &, RestoredData &);
 };
 
 // Array of supported components
@@ -1165,7 +1165,7 @@ struct SvgCmpReadHelper {
 // The basic information about deserialized component, used for debugging purposes
 struct ComponentInfo {
 	String  Name;       // internal component's ID
-	int Version;    // data format version
+	int32_t Version;    // data format version
 	soff_t  Offset;     // offset at which an opening tag is located
 	soff_t  DataOffset; // offset at which component data begins
 	soff_t  DataSize;   // expected size of component data
@@ -1240,7 +1240,7 @@ HSaveError WriteComponent(PStream out, ComponentHandler &hdlr) {
 	HSaveError err = hdlr.Serialize(out);
 	soff_t end_pos = out->GetPosition();
 	out->Seek(ref_pos, kSeekBegin);
-	out->WriteInt64(end_pos - ref_pos - sizeof(int64)); // size of serialized component data
+	out->WriteInt64(end_pos - ref_pos - sizeof(int64_t)); // size of serialized component data
 	out->Seek(end_pos, kSeekBegin);
 	if (err)
 		WriteFormatTag(out, hdlr.Name, false);
diff --git a/engines/ags/engine/game/savegame_internal.h b/engines/ags/engine/game/savegame_internal.h
index dfcaaea0e3..cbd1d81847 100644
--- a/engines/ags/engine/game/savegame_internal.h
+++ b/engines/ags/engine/game/savegame_internal.h
@@ -81,10 +81,10 @@ struct RestoredData {
 	std::vector<ScriptData> ScriptModules;
 	// Room data (has to be be preserved until room is loaded)
 	PBitmap                 RoomBkgScene[MAX_ROOM_BGFRAMES];
-	int16                 RoomLightLevels[MAX_ROOM_REGIONS];
-	int                 RoomTintLevels[MAX_ROOM_REGIONS];
-	int16                 RoomZoomLevels1[MAX_WALK_AREAS + 1];
-	int16                 RoomZoomLevels2[MAX_WALK_AREAS + 1];
+	int16_t                 RoomLightLevels[MAX_ROOM_REGIONS];
+	int32_t                 RoomTintLevels[MAX_ROOM_REGIONS];
+	int16_t                 RoomZoomLevels1[MAX_WALK_AREAS + 1];
+	int16_t                 RoomZoomLevels2[MAX_WALK_AREAS + 1];
 	RoomVolumeMod           RoomVolume;
 	// Mouse cursor parameters
 	int                     CursorID;
@@ -130,7 +130,7 @@ struct RestoredData {
 	};
 	std::vector<ViewportData> Viewports;
 	std::vector<CameraData> Cameras;
-	int Camera0_Flags = 0; // flags for primary camera, when data is read in legacy order
+	int32_t Camera0_Flags = 0; // flags for primary camera, when data is read in legacy order
 
 	RestoredData();
 };
diff --git a/engines/ags/engine/gfx/gfx_util.cpp b/engines/ags/engine/gfx/gfx_util.cpp
index d6216c7a54..b1ad9e20d2 100644
--- a/engines/ags/engine/gfx/gfx_util.cpp
+++ b/engines/ags/engine/gfx/gfx_util.cpp
@@ -139,8 +139,8 @@ void DrawSpriteWithTransparency(Bitmap *ds, Bitmap *sprite, int x, int y, int al
 			color_t mask_color = hctemp.GetMaskColor();
 			for (int scan_y = 0; scan_y < hctemp.GetHeight(); ++scan_y) {
 				// we know this must be 1 bpp source and 2 bpp pixel destination
-				const uint8 *src_scanline = sprite->GetScanLine(scan_y);
-				uint16 *dst_scanline = (uint16 *)hctemp.GetScanLineForWriting(scan_y);
+				const uint8_t *src_scanline = sprite->GetScanLine(scan_y);
+				uint16_t *dst_scanline = (uint16_t *)hctemp.GetScanLineForWriting(scan_y);
 				for (int scan_x = 0; scan_x < hctemp.GetWidth(); ++scan_x) {
 					if (src_scanline[scan_x] == 0) {
 						dst_scanline[scan_x] = mask_color;
diff --git a/engines/ags/engine/gfx/gfxdefines.h b/engines/ags/engine/gfx/gfxdefines.h
index f6fe2eac57..0f2e2cf458 100644
--- a/engines/ags/engine/gfx/gfxdefines.h
+++ b/engines/ags/engine/gfx/gfxdefines.h
@@ -39,9 +39,9 @@ enum GlobalFlipType {
 
 // GraphicResolution struct determines image size and color depth
 struct GraphicResolution {
-	int Width;
-	int Height;
-	int ColorDepth;
+	int32_t Width;
+	int32_t Height;
+	int32_t ColorDepth;
 
 	GraphicResolution()
 		: Width(0)
@@ -49,7 +49,7 @@ struct GraphicResolution {
 		, ColorDepth(0) {
 	}
 
-	GraphicResolution(int width, int height, int color_depth) {
+	GraphicResolution(int32_t width, int32_t height, int32_t color_depth) {
 		Width = width;
 		Height = height;
 		ColorDepth = color_depth;
@@ -62,7 +62,7 @@ struct GraphicResolution {
 
 // DisplayMode struct provides extended description of display mode
 struct DisplayMode : public GraphicResolution {
-	int RefreshRate;
+	int32_t RefreshRate;
 	bool    Vsync;
 	bool    Windowed;
 
@@ -72,7 +72,7 @@ struct DisplayMode : public GraphicResolution {
 		, Windowed(false) {
 	}
 
-	DisplayMode(const GraphicResolution &res, bool windowed = false, int refresh = 0, bool vsync = false)
+	DisplayMode(const GraphicResolution &res, bool windowed = false, int32_t refresh = 0, bool vsync = false)
 		: GraphicResolution(res)
 		, RefreshRate(refresh)
 		, Vsync(vsync)
diff --git a/engines/ags/engine/gfx/gfxdriverbase.cpp b/engines/ags/engine/gfx/gfxdriverbase.cpp
index ec0d19db41..4b458a78b6 100644
--- a/engines/ags/engine/gfx/gfxdriverbase.cpp
+++ b/engines/ags/engine/gfx/gfxdriverbase.cpp
@@ -291,9 +291,9 @@ void VideoMemoryGraphicsDriver::BitmapToVideoMem(const Bitmap *bitmap, const boo
 	bool lastPixelWasTransparent = false;
 	for (int y = 0; y < tile->height; y++) {
 		lastPixelWasTransparent = false;
-		const uint8 *scanline_before = bitmap->GetScanLine(y + tile->y - 1);
-		const uint8 *scanline_at = bitmap->GetScanLine(y + tile->y);
-		const uint8 *scanline_after = bitmap->GetScanLine(y + tile->y + 1);
+		const uint8_t *scanline_before = bitmap->GetScanLine(y + tile->y - 1);
+		const uint8_t *scanline_at = bitmap->GetScanLine(y + tile->y);
+		const uint8_t *scanline_after = bitmap->GetScanLine(y + tile->y + 1);
 		unsigned int *memPtrLong = (unsigned int *)dst_ptr;
 
 		for (int x = 0; x < tile->width; x++) {
@@ -407,7 +407,7 @@ void VideoMemoryGraphicsDriver::BitmapToVideoMemOpaque(const Bitmap *bitmap, con
 	char *dst_ptr, const int dst_pitch) {
 	const int src_depth = bitmap->GetColorDepth();
 	for (int y = 0; y < tile->height; y++) {
-		const uint8 *scanline_at = bitmap->GetScanLine(y + tile->y);
+		const uint8_t *scanline_at = bitmap->GetScanLine(y + tile->y);
 		unsigned int *memPtrLong = (unsigned int *)dst_ptr;
 
 		for (int x = 0; x < tile->width; x++) {
diff --git a/engines/ags/engine/gui/gui_engine.cpp b/engines/ags/engine/gui/gui_engine.cpp
index 3a76b334fc..b248e3327a 100644
--- a/engines/ags/engine/gui/gui_engine.cpp
+++ b/engines/ags/engine/gui/gui_engine.cpp
@@ -80,7 +80,7 @@ bool GUIMain::HasAlphaChannel() const {
 // Engine-specific implementation split out of acgui.h
 //=============================================================================
 
-void check_font(int *fontnum) {
+void check_font(int32_t *fontnum) {
 	// do nothing
 }
 
diff --git a/engines/ags/engine/main/config.cpp b/engines/ags/engine/main/config.cpp
index 87c914b22f..b81713fc92 100644
--- a/engines/ags/engine/main/config.cpp
+++ b/engines/ags/engine/main/config.cpp
@@ -184,17 +184,17 @@ String make_scaling_option(const GameFrameSetup &frame_setup) {
 	return make_scaling_option(frame_setup.ScaleDef, frame_setup.ScaleFactor);
 }
 
-uint32 convert_scaling_to_fp(int scale_factor) {
+uint32_t convert_scaling_to_fp(int scale_factor) {
 	if (scale_factor >= 0)
 		return scale_factor <<= kShift;
 	else
 		return kUnit / abs(scale_factor);
 }
 
-int convert_fp_to_scaling(uint32 scaling) {
+int convert_fp_to_scaling(uint32_t scaling) {
 	if (scaling == 0)
 		return 0;
-	return scaling >= kUnit ? (scaling >> kShift) : -kUnit / (int)scaling;
+	return scaling >= kUnit ? (scaling >> kShift) : -kUnit / (int32_t)scaling;
 }
 
 void graphics_mode_get_defaults(bool windowed, ScreenSizeSetup &scsz_setup, GameFrameSetup &frame_setup) {
diff --git a/engines/ags/engine/main/config.h b/engines/ags/engine/main/config.h
index 496fecfbbe..75dabacf55 100644
--- a/engines/ags/engine/main/config.h
+++ b/engines/ags/engine/main/config.h
@@ -54,8 +54,8 @@ void parse_scaling_option(const String &scaling_option, FrameScaleDefinition &sc
 void parse_scaling_option(const String &scaling_option, GameFrameSetup &frame_setup);
 String make_scaling_option(FrameScaleDefinition scale_def, int scale_factor = 0);
 String make_scaling_option(const GameFrameSetup &frame_setup);
-uint32 convert_scaling_to_fp(int scale_factor);
-int convert_fp_to_scaling(uint32 scaling);
+uint32_t convert_scaling_to_fp(int scale_factor);
+int convert_fp_to_scaling(uint32_t scaling);
 // Fill in setup structs with default settings for the given mode (windowed or fullscreen)
 void graphics_mode_get_defaults(bool windowed, ScreenSizeSetup &scsz_setup, GameFrameSetup &frame_setup);
 
diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index f01a00f9e2..cf877f8f1d 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -344,7 +344,7 @@ void engine_locate_speech_pak() {
 					for (int ee = 0; ee < numLipLines; ee++) {
 						splipsync[ee].numPhonemes = speechsync->ReadInt16();
 						speechsync->Read(splipsync[ee].filename, 14);
-						splipsync[ee].endtimeoffs = (int *)malloc(splipsync[ee].numPhonemes * sizeof(int));
+						splipsync[ee].endtimeoffs = (int32_t *)malloc(splipsync[ee].numPhonemes * sizeof(int32_t));
 						speechsync->ReadArrayOfInt32(splipsync[ee].endtimeoffs, splipsync[ee].numPhonemes);
 						splipsync[ee].frame = (short *)malloc(splipsync[ee].numPhonemes * sizeof(short));
 						speechsync->ReadArrayOfInt16(splipsync[ee].frame, splipsync[ee].numPhonemes);
diff --git a/engines/ags/engine/main/graphics_mode.cpp b/engines/ags/engine/main/graphics_mode.cpp
index 53c68cf06e..90120f1326 100644
--- a/engines/ags/engine/main/graphics_mode.cpp
+++ b/engines/ags/engine/main/graphics_mode.cpp
@@ -141,7 +141,7 @@ bool graphics_mode_set_filter_any(const GfxFilterSetup &setup) {
 
 bool find_nearest_supported_mode(const IGfxModeList &modes, const Size &wanted_size, const int color_depth,
 	const Size *ratio_reference, const Size *upper_bound, DisplayMode &dm, int *mode_index) {
-	uint32 wanted_ratio = 0;
+	uint32_t wanted_ratio = 0;
 	if (ratio_reference && !ratio_reference->IsNull()) {
 		wanted_ratio = (ratio_reference->Height << kShift) / ratio_reference->Width;
 	}
@@ -162,7 +162,7 @@ bool find_nearest_supported_mode(const IGfxModeList &modes, const Size &wanted_s
 			continue;
 		}
 		if (wanted_ratio > 0) {
-			uint32 mode_ratio = (mode.Height << kShift) / mode.Width;
+			uint32_t mode_ratio = (mode.Height << kShift) / mode.Width;
 			if (mode_ratio != wanted_ratio) {
 				continue;
 			}
diff --git a/engines/ags/engine/main/graphics_mode.h b/engines/ags/engine/main/graphics_mode.h
index 442ca70716..0576b90f70 100644
--- a/engines/ags/engine/main/graphics_mode.h
+++ b/engines/ags/engine/main/graphics_mode.h
@@ -33,7 +33,7 @@ using AGS::Shared::String;
 using AGS::Engine::DisplayMode;
 
 Size get_desktop_size();
-String make_scaling_factor_string(uint32 scaling);
+String make_scaling_factor_string(uint32_t scaling);
 
 namespace AGS {
 namespace Engine {
diff --git a/engines/ags/engine/main/update.cpp b/engines/ags/engine/main/update.cpp
index 99e065aa50..65a67b5034 100644
--- a/engines/ags/engine/main/update.cpp
+++ b/engines/ags/engine/main/update.cpp
@@ -74,7 +74,7 @@ extern int numLipLines, curLipLine, curLipLinePhoneme;
 extern int is_text_overlay;
 extern IGraphicsDriver *gfxDriver;
 
-int do_movelist_move(int16 *mlnum, int *xx, int *yy) {
+int do_movelist_move(int16_t *mlnum, int32_t *xx, int32_t *yy) {
 	int need_to_fix_sprite = 0;
 	if (mlnum[0] < 1) quit("movelist_move: attempted to move on a non-exist movelist");
 	MoveList *cmls;
diff --git a/engines/ags/engine/main/update.h b/engines/ags/engine/main/update.h
index 1937879f9b..796441d645 100644
--- a/engines/ags/engine/main/update.h
+++ b/engines/ags/engine/main/update.h
@@ -27,7 +27,7 @@ namespace AGS3 {
 
 #define MAX_SHEEP 30    // sheep == follower
 
-extern int do_movelist_move(int16 *mlnum, int *xx, int *yy);
+extern int do_movelist_move(int16_t *mlnum, int32_t *xx, int32_t *yy);
 extern void update_stuff();
 
 } // namespace AGS3
diff --git a/engines/ags/engine/platform/base/agsplatformdriver.h b/engines/ags/engine/platform/base/agsplatformdriver.h
index a925fbaf3e..4f056c3341 100644
--- a/engines/ags/engine/platform/base/agsplatformdriver.h
+++ b/engines/ags/engine/platform/base/agsplatformdriver.h
@@ -154,7 +154,7 @@ struct AGSPlatformDriver
 	virtual void UnRegisterGameWithGameExplorer();
 	virtual int  ConvertKeycodeToScanCode(int keyCode);
 	// Adjust window size to ensure it is in the supported limits
-	virtual void ValidateWindowSize(int &x, int &y, bool borderless) const {
+	virtual void ValidateWindowSize(int32_t &x, int32_t &y, bool borderless) const {
 	}
 
 	virtual int  InitializeCDPlayer() = 0;  // return 0 on success
diff --git a/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp b/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp
index 37bdd95bd5..a53c0a328d 100644
--- a/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp
+++ b/engines/ags/engine/platform/windows/gfx/ali3dd3d.cpp
@@ -1010,7 +1010,7 @@ bool D3DGraphicsDriver::GetCopyOfScreenIntoBitmap(Bitmap *destination, bool at_n
 			error("IDirect3DSurface9::LockRect failed");
 		}
 
-		BitmapHelper::ReadPixelsFromMemory(destination, (uint8 *)lockedRect.pBits, lockedRect.Pitch);
+		BitmapHelper::ReadPixelsFromMemory(destination, (uint8_t *)lockedRect.pBits, lockedRect.Pitch);
 
 		surface->UnlockRect();
 		surface->Release();
diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index a4163bbafc..6a2a70a7cd 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -69,7 +69,7 @@ enum ScriptOpArgIsReg {
 };
 
 struct ScriptCommandInfo {
-	ScriptCommandInfo(int code, const char *cmdname, int arg_count, ScriptOpArgIsReg arg_is_reg) {
+	ScriptCommandInfo(int32_t code, const char *cmdname, int arg_count, ScriptOpArgIsReg arg_is_reg) {
 		Code        = code;
 		CmdName     = cmdname;
 		ArgCount    = arg_count;
@@ -78,7 +78,7 @@ struct ScriptCommandInfo {
 		ArgIsReg[2] = (arg_is_reg & kScOpArg3IsReg) != 0;
 	}
 
-	int             Code;
+	int32_t             Code;
 	const char          *CmdName;
 	int                 ArgCount;
 	bool                ArgIsReg[3];
@@ -275,7 +275,7 @@ void ccInstance::AbortAndDestroy() {
 		return -1; \
 	}
 
-int ccInstance::CallScriptFunction(const char *funcname, int numargs, const RuntimeScriptValue *params) {
+int ccInstance::CallScriptFunction(const char *funcname, int32_t numargs, const RuntimeScriptValue *params) {
 	ccError = 0;
 	currentline = 0;
 
@@ -294,7 +294,7 @@ int ccInstance::CallScriptFunction(const char *funcname, int numargs, const Runt
 		return -4;
 	}
 
-	int startat = -1;
+	int32_t startat = -1;
 	int k;
 	char mangledName[200];
 	snprintf(mangledName, 200, "%s$", funcname);
@@ -316,7 +316,7 @@ int ccInstance::CallScriptFunction(const char *funcname, int numargs, const Runt
 		// check for an exact match (if the script was compiled with
 		// an older version)
 		if ((match == 1) || (strcmp(thisExportName, funcname) == 0)) {
-			int etype = (instanceof->export_addr[k] >> 24L) & 0x000ff;
+			int32_t etype = (instanceof->export_addr[k] >> 24L) & 0x000ff;
 			if (etype != EXPORT_FUNCTION) {
 				cc_error("symbol is not a function");
 				return -1;
@@ -405,7 +405,7 @@ int ccInstance::CallScriptFunction(const char *funcname, int numargs, const Runt
 	currentline = line_number
 
 #define MAXNEST 50  // number of recursive function calls allowed
-int ccInstance::Run(int curpc) {
+int ccInstance::Run(int32_t curpc) {
 	pc = curpc;
 	returnValue = -1;
 
@@ -414,7 +414,7 @@ int ccInstance::Run(int curpc) {
 		return -1;
 	}
 
-	int thisbase[MAXNEST], funcstart[MAXNEST];
+	int32_t thisbase[MAXNEST], funcstart[MAXNEST];
 	int was_just_callas = -1;
 	int curnest = 0;
 	int loopIterations = 0;
@@ -480,13 +480,13 @@ int ccInstance::Run(int curpc) {
 					// originally commented -- CHECKME: could this be used in very old versions of AGS?
 					//      code[fixup] += (long)&code[0];
 					// This is a program counter value, presumably will be used as SCMD_CALL argument
-					codeOp.Args[i].SetInt32((int)codeInst->code[pc_at]);
+					codeOp.Args[i].SetInt32((int32_t)codeInst->code[pc_at]);
 					break;
 				case FIXUP_STRING:
 					codeOp.Args[i].SetStringLiteral(&codeInst->strings[0] + codeInst->code[pc_at]);
 					break;
 				case FIXUP_IMPORT: {
-					const ScriptImport *import = simp.getByIndex((int)codeInst->code[pc_at]);
+					const ScriptImport *import = simp.getByIndex((int32_t)codeInst->code[pc_at]);
 					if (import) {
 						codeOp.Args[i] = import->Value;
 					} else {
@@ -496,7 +496,7 @@ int ccInstance::Run(int curpc) {
 				}
 				break;
 				case FIXUP_STACK:
-					codeOp.Args[i] = GetStackPtrOffsetFw((int)codeInst->code[pc_at]);
+					codeOp.Args[i] = GetStackPtrOffsetFw((int32_t)codeInst->code[pc_at]);
 					break;
 				default:
 					cc_error("internal fixup type error: %d", fixup);
@@ -505,8 +505,8 @@ int ccInstance::Run(int curpc) {
 				/* End FixupArgument */
 				//=====================================================================
 			} else {
-				// should be a numeric literal (int or float)
-				codeOp.Args[i].SetInt32((int)codeInst->code[pc_at]);
+				// should be a numeric literal (int32 or float)
+				codeOp.Args[i].SetInt32((int32_t)codeInst->code[pc_at]);
 			}
 		}
 		/* End ReadOperation */
@@ -581,17 +581,17 @@ int ccInstance::Run(int curpc) {
 			// Take the data address from reg[MAR] and copy there arg1 bytes from arg2 address
 			//
 			// NOTE: since it reads directly from arg2 (which originally was
-			// long, or rather int due x32 build), written value may normally
+			// long, or rather int32 due x32 build), written value may normally
 			// be only up to 4 bytes large;
 			// I guess that's an obsolete way to do WRITE, WRITEW and WRITEB
 			switch (arg1.IValue) {
 			case sizeof(char):
 				registers[SREG_MAR].WriteByte(arg2.IValue);
 				break;
-			case sizeof(int16):
+			case sizeof(int16_t):
 				registers[SREG_MAR].WriteInt16(arg2.IValue);
 				break;
-			case sizeof(int):
+			case sizeof(int32_t):
 				// We do not know if this is math integer or some pointer, etc
 				registers[SREG_MAR].WriteValue(arg2);
 				break;
@@ -620,11 +620,11 @@ int ccInstance::Run(int curpc) {
 			reg1 = arg2;
 			break;
 		case SCMD_MEMREAD:
-			// Take the data address from reg[MAR] and copy int to reg[arg1]
+			// Take the data address from reg[MAR] and copy int32_t to reg[arg1]
 			reg1 = registers[SREG_MAR].ReadValue();
 			break;
 		case SCMD_MEMWRITE:
-			// Take the data address from reg[MAR] and copy there int from reg[arg1]
+			// Take the data address from reg[MAR] and copy there int32_t from reg[arg1]
 			registers[SREG_MAR].WriteValue(reg1);
 			break;
 		case SCMD_LOADSPOFFS:
@@ -733,7 +733,7 @@ int ccInstance::Run(int curpc) {
 			reg1.SetUInt8(registers[SREG_MAR].ReadByte());
 			break;
 		case SCMD_MEMREADW:
-			// Take the data address from reg[MAR] and copy int16 to reg[arg1]
+			// Take the data address from reg[MAR] and copy int16_t to reg[arg1]
 			reg1.SetInt16(registers[SREG_MAR].ReadInt16());
 			break;
 		case SCMD_MEMWRITEB:
@@ -741,7 +741,7 @@ int ccInstance::Run(int curpc) {
 			registers[SREG_MAR].WriteByte(reg1.IValue);
 			break;
 		case SCMD_MEMWRITEW:
-			// Take the data address from reg[MAR] and copy there int16 from reg[arg1]
+			// Take the data address from reg[MAR] and copy there int16_t from reg[arg1]
 			registers[SREG_MAR].WriteInt16(reg1.IValue);
 			break;
 		case SCMD_JZ:
@@ -793,10 +793,10 @@ int ccInstance::Run(int curpc) {
 			// TODO: test reg[MAR] type here;
 			// That might be dynamic object, but also a non-managed dynamic array, "allocated"
 			// on global or local memspace (buffer)
-			int upperBoundInBytes = *((int *)(registers[SREG_MAR].GetPtrWithOffset() - 4));
+			int32_t upperBoundInBytes = *((int32_t *)(registers[SREG_MAR].GetPtrWithOffset() - 4));
 			if ((reg1.IValue < 0) ||
 			        (reg1.IValue >= upperBoundInBytes)) {
-				int upperBound = *((int *)(registers[SREG_MAR].GetPtrWithOffset() - 8)) & (~ARRAY_MANAGED_TYPE_FLAG);
+				int32_t upperBound = *((int32_t *)(registers[SREG_MAR].GetPtrWithOffset() - 8)) & (~ARRAY_MANAGED_TYPE_FLAG);
 				if (upperBound <= 0) {
 					cc_error("!Array has an invalid size (%d) and cannot be accessed", upperBound);
 				} else {
@@ -813,7 +813,7 @@ int ccInstance::Run(int curpc) {
 		case SCMD_MEMREADPTR: {
 			ccError = 0;
 
-			int handle = registers[SREG_MAR].ReadInt32();
+			int32_t handle = registers[SREG_MAR].ReadInt32();
 			void *object;
 			ICCDynamicObject *manager;
 			ScriptValueType obj_type = ccGetObjectAddressAndManagerFromHandle(handle, object, manager);
@@ -830,7 +830,7 @@ int ccInstance::Run(int curpc) {
 		}
 		case SCMD_MEMWRITEPTR: {
 
-			int handle = registers[SREG_MAR].ReadInt32();
+			int32_t handle = registers[SREG_MAR].ReadInt32();
 			const char *address = nullptr;
 
 			if (reg1.Type == kScValStaticArray && reg1.StcArr->GetDynamicManager()) {
@@ -848,7 +848,7 @@ int ccInstance::Run(int curpc) {
 				return -1;
 			}
 
-			int newHandle = ccGetObjectHandleFromAddress(address);
+			int32_t newHandle = ccGetObjectHandleFromAddress(address);
 			if (newHandle == -1)
 				return -1;
 
@@ -877,7 +877,7 @@ int ccInstance::Run(int curpc) {
 				return -1;
 			}
 			// like memwriteptr, but doesn't attempt to free the old one
-			int newHandle = ccGetObjectHandleFromAddress(address);
+			int32_t newHandle = ccGetObjectHandleFromAddress(address);
 			if (newHandle == -1)
 				return -1;
 
@@ -886,13 +886,13 @@ int ccInstance::Run(int curpc) {
 			break;
 		}
 		case SCMD_MEMZEROPTR: {
-			int handle = registers[SREG_MAR].ReadInt32();
+			int32_t handle = registers[SREG_MAR].ReadInt32();
 			ccReleaseObjectReference(handle);
 			registers[SREG_MAR].WriteInt32(0);
 			break;
 		}
 		case SCMD_MEMZEROPTRND: {
-			int handle = registers[SREG_MAR].ReadInt32();
+			int32_t handle = registers[SREG_MAR].ReadInt32();
 
 			// don't do the Dispose check for the object being returned -- this is
 			// for returning a String (or other pointer) from a custom function.
@@ -948,7 +948,7 @@ int ccInstance::Run(int curpc) {
 			ccInstance *wasRunning = runningInst;
 
 			// extract the instance ID
-			int instId = codeOp.Instruction.InstanceId;
+			int32_t instId = codeOp.Instruction.InstanceId;
 			// determine the offset into the code of the instance we want
 			runningInst = loadedInstances[instId];
 			intptr_t callAddr = reg1.Ptr - (char *)&runningInst->code[0];
@@ -958,7 +958,7 @@ int ccInstance::Run(int curpc) {
 			}
 			callAddr /= sizeof(intptr_t); // size of ccScript::code elements
 
-			if (Run((int)callAddr))
+			if (Run((int32_t)callAddr))
 				return -1;
 
 			runningInst = wasRunning;
@@ -996,7 +996,7 @@ int ccInstance::Run(int curpc) {
 
 			if (reg1.Type == kScValPluginFunction) {
 				GlobalReturnValue.Invalidate();
-				int int_ret_val;
+				int32_t int_ret_val;
 				if (next_call_needs_object) {
 					RuntimeScriptValue obj_rval = registers[SREG_OP];
 					obj_rval.DirectPtrObj();
@@ -1104,9 +1104,9 @@ int ccInstance::Run(int curpc) {
 			break;
 		}
 		case SCMD_NEWUSEROBJECT: {
-			const int size = arg2.IValue;
+			const int32_t size = arg2.IValue;
 			if (size < 0) {
-				cc_error("Invalid size for user object; requested: %u (or %d), range: 0..%d", (uint32)size, size, INT_MAX);
+				cc_error("Invalid size for user object; requested: %u (or %d), range: 0..%d", (uint32_t)size, size, INT_MAX);
 				return -1;
 			}
 			ScriptUserObject *suo = ScriptUserObject::CreateManaged(size);
@@ -1373,8 +1373,8 @@ bool ccInstance::_Create(PScript scri, ccInstance *joined) {
 
 	// find the real address of the exports
 	for (i = 0; i < scri->numexports; i++) {
-		int etype = (scri->export_addr[i] >> 24L) & 0x000ff;
-		int eaddr = (scri->export_addr[i] & 0x00ffffff);
+		int32_t etype = (scri->export_addr[i] >> 24L) & 0x000ff;
+		int32_t eaddr = (scri->export_addr[i] & 0x00ffffff);
 		if (etype == EXPORT_FUNCTION) {
 			// NOTE: unfortunately, there seems to be no way to know if
 			// that's an extender function that expects object pointer
@@ -1493,14 +1493,14 @@ bool ccInstance::CreateGlobalVars(PScript scri) {
 		case FIXUP_GLOBALDATA:
 			// GLOBALDATA fixup takes relative address of global data element from code array;
 			// this is the address of actual data
-			glvar.ScAddress = (int)code[scri->fixups[i]];
+			glvar.ScAddress = (int32_t)code[scri->fixups[i]];
 			glvar.RValue.SetData(globaldata + glvar.ScAddress, 0);
 			break;
 		case FIXUP_DATADATA: {
 			// DATADATA fixup takes relative address of global data element from fixups array;
 			// this is the address of element, which stores address of actual data
 			glvar.ScAddress = scri->fixups[i];
-			int data_addr = BBOp::Int32FromLE(*(int *)&globaldata[glvar.ScAddress]);
+			int32_t data_addr = BBOp::Int32FromLE(*(int32_t *)&globaldata[glvar.ScAddress]);
 			if (glvar.ScAddress - data_addr != 200 /* size of old AGS string */) {
 				// CHECKME: probably replace with mere warning in the log?
 				cc_error("unexpected old-style string's alignment");
@@ -1520,8 +1520,8 @@ bool ccInstance::CreateGlobalVars(PScript scri) {
 
 	// Step Two: deduce global variables from exports
 	for (int i = 0; i < scri->numexports; ++i) {
-		int etype = (scri->export_addr[i] >> 24L) & 0x000ff;
-		int eaddr = (scri->export_addr[i] & 0x00ffffff);
+		int32_t etype = (scri->export_addr[i] >> 24L) & 0x000ff;
+		int32_t eaddr = (scri->export_addr[i] & 0x00ffffff);
 		if (etype == EXPORT_DATA) {
 			// NOTE: old-style strings could not be exported in AGS,
 			// no need to worry about these here
@@ -1551,7 +1551,7 @@ bool ccInstance::AddGlobalVar(const ScriptVariable &glvar) {
 	return true;
 }
 
-ScriptVariable *ccInstance::FindGlobalVar(int var_addr) {
+ScriptVariable *ccInstance::FindGlobalVar(int32_t var_addr) {
 	// NOTE: see comment for AddGlobalVar()
 	if (var_addr < 0 || var_addr >= globaldatasize) {
 		/*
@@ -1571,14 +1571,14 @@ bool ccInstance::CreateRuntimeCodeFixups(PScript scri) {
 			continue;
 		}
 
-		int fixup = scri->fixups[i];
+		int32_t fixup = scri->fixups[i];
 		code_fixups[fixup] = scri->fixuptypes[i];
 
 		switch (scri->fixuptypes[i]) {
 		case FIXUP_GLOBALDATA: {
-			ScriptVariable *gl_var = FindGlobalVar((int)code[fixup]);
+			ScriptVariable *gl_var = FindGlobalVar((int32_t)code[fixup]);
 			if (!gl_var) {
-				cc_error("cannot resolve global variable, key = %d", (int)code[fixup]);
+				cc_error("cannot resolve global variable, key = %d", (int32_t)code[fixup]);
 				return false;
 			}
 			code[fixup] = (intptr_t)gl_var;
@@ -1616,7 +1616,7 @@ bool ccInstance::CreateRuntimeCodeFixups(PScript scri) {
 }
 
 /*
-bool ccInstance::ReadOperation(ScriptOperation &op, int at_pc)
+bool ccInstance::ReadOperation(ScriptOperation &op, int32_t at_pc)
 {
     op.Instruction.Code         = code[at_pc];
     op.Instruction.InstanceId   = (op.Instruction.Code >> INSTANCE_ID_SHIFT) & INSTANCE_ID_MASK;
@@ -1644,8 +1644,8 @@ bool ccInstance::ReadOperation(ScriptOperation &op, int at_pc)
         }
         else
         {
-            // should be a numeric literal (int or float)
-            op.Args[i].SetInt32( (int)code[at_pc] );
+            // should be a numeric literal (int32 or float)
+            op.Args[i].SetInt32( (int32_t)code[at_pc] );
         }
     }
 
@@ -1667,14 +1667,14 @@ bool ccInstance::FixupArgument(intptr_t code_value, char fixup_type, RuntimeScri
         // originally commented -- CHECKME: could this be used in very old versions of AGS?
         //      code[fixup] += (long)&code[0];
         // This is a program counter value, presumably will be used as SCMD_CALL argument
-        argument.SetInt32((int)code_value);
+        argument.SetInt32((int32_t)code_value);
         break;
     case FIXUP_STRING:
         argument.SetStringLiteral(&strings[0] + code_value);
         break;
     case FIXUP_IMPORT:
         {
-            const ScriptImport *import = simp.getByIndex((int)code_value);
+            const ScriptImport *import = simp.getByIndex((int32_t)code_value);
             if (import)
             {
                 argument = import->Value;
@@ -1687,7 +1687,7 @@ bool ccInstance::FixupArgument(intptr_t code_value, char fixup_type, RuntimeScri
         }
         break;
     case FIXUP_STACK:
-        argument = GetStackPtrOffsetFw((int)code_value);
+        argument = GetStackPtrOffsetFw((int32_t)code_value);
         break;
     default:
         cc_error("internal fixup type error: %d", fixup_type);
@@ -1704,7 +1704,7 @@ void ccInstance::PushValueToStack(const RuntimeScriptValue &rval) {
 	registers[SREG_SP].RValue++;
 }
 
-void ccInstance::PushDataToStack(int num_bytes) {
+void ccInstance::PushDataToStack(int32_t num_bytes) {
 	if (registers[SREG_SP].RValue->IsValid()) {
 		cc_error("internal error: valid data beyond stack ptr");
 		return;
@@ -1727,7 +1727,7 @@ RuntimeScriptValue ccInstance::PopValueFromStack() {
 	return rval;
 }
 
-void ccInstance::PopValuesFromStack(int num_entries = 1) {
+void ccInstance::PopValuesFromStack(int32_t num_entries = 1) {
 	for (int i = 0; i < num_entries; ++i) {
 		// rewind stack ptr to the last valid value, decrement stack data ptr if needed and invalidate the stack tail
 		registers[SREG_SP].RValue--;
@@ -1738,8 +1738,8 @@ void ccInstance::PopValuesFromStack(int num_entries = 1) {
 	}
 }
 
-void ccInstance::PopDataFromStack(int num_bytes) {
-	int total_pop = 0;
+void ccInstance::PopDataFromStack(int32_t num_bytes) {
+	int32_t total_pop = 0;
 	while (total_pop < num_bytes && registers[SREG_SP].RValue > &stack[0]) {
 		// rewind stack ptr to the last valid value, decrement stack data ptr if needed and invalidate the stack tail
 		registers[SREG_SP].RValue--;
@@ -1757,8 +1757,8 @@ void ccInstance::PopDataFromStack(int num_bytes) {
 	}
 }
 
-RuntimeScriptValue ccInstance::GetStackPtrOffsetFw(int fw_offset) {
-	int total_off = 0;
+RuntimeScriptValue ccInstance::GetStackPtrOffsetFw(int32_t fw_offset) {
+	int32_t total_off = 0;
 	RuntimeScriptValue *stack_entry = &stack[0];
 	while (total_off < fw_offset && stack_entry - &stack[0] < CC_STACK_SIZE) {
 		if (stack_entry->Size > 0) {
@@ -1779,8 +1779,8 @@ RuntimeScriptValue ccInstance::GetStackPtrOffsetFw(int fw_offset) {
 	return stack_ptr;
 }
 
-RuntimeScriptValue ccInstance::GetStackPtrOffsetRw(int rw_offset) {
-	int total_off = 0;
+RuntimeScriptValue ccInstance::GetStackPtrOffsetRw(int32_t rw_offset) {
+	int32_t total_off = 0;
 	RuntimeScriptValue *stack_entry = registers[SREG_SP].RValue;
 	while (total_off < rw_offset && stack_entry >= &stack[0]) {
 		stack_entry--;
@@ -1814,7 +1814,7 @@ void ccInstance::PushToFuncCallStack(FunctionCallStack &func_callstack, const Ru
 	func_callstack.Count++;
 }
 
-void ccInstance::PopFromFuncCallStack(FunctionCallStack &func_callstack, int num_entries) {
+void ccInstance::PopFromFuncCallStack(FunctionCallStack &func_callstack, int32_t num_entries) {
 	if (func_callstack.Count == 0) {
 		cc_error("function callstack underflow");
 		return;
diff --git a/engines/ags/engine/script/cc_instance.h b/engines/ags/engine/script/cc_instance.h
index 4ef7baa153..176a5502de 100644
--- a/engines/ags/engine/script/cc_instance.h
+++ b/engines/ags/engine/script/cc_instance.h
@@ -45,7 +45,7 @@ using namespace AGS;
 #define INSTF_FREE          4
 #define INSTF_RUNNING       8   // set by main code to confirm script isn't stuck
 #define CC_STACK_SIZE       250
-#define CC_STACK_DATA_SIZE  (1000 * sizeof(int))
+#define CC_STACK_DATA_SIZE  (1000 * sizeof(int32_t))
 #define MAX_CALL_STACK      100
 
 // 256 because we use 8 bits to hold instance number
@@ -64,8 +64,8 @@ struct ScriptInstruction {
 		InstanceId = 0;
 	}
 
-	int Code;
-	int InstanceId;
+	int32_t Code;
+	int32_t InstanceId;
 };
 
 struct ScriptOperation {
@@ -83,7 +83,7 @@ struct ScriptVariable {
 		ScAddress = -1; // address = 0 is valid one, -1 means undefined
 	}
 
-	int             ScAddress;  // original 32-bit relative data address, written in compiled script;
+	int32_t             ScAddress;  // original 32-bit relative data address, written in compiled script;
 	// if we are to use Map or HashMap, this could be used as Key
 	RuntimeScriptValue  RValue;
 };
@@ -95,13 +95,13 @@ struct ScriptPosition {
 		: Line(0) {
 	}
 
-	ScriptPosition(const Shared::String &section, int line)
+	ScriptPosition(const Shared::String &section, int32_t line)
 		: Section(section)
 		, Line(line) {
 	}
 
 	Shared::String  Section;
-	int         Line;
+	int32_t         Line;
 };
 
 // Running instance of the script
@@ -111,18 +111,18 @@ public:
 	typedef std::unordered_map<int, ScriptVariable> ScVarMap;
 	typedef std::shared_ptr<ScVarMap>                   PScVarMap;
 public:
-	int flags;
+	int32_t flags;
 	PScVarMap globalvars;
 	char *globaldata;
-	int globaldatasize;
-	// Executed byte-code. Unlike ccScript's code array which is int, the one
+	int32_t globaldatasize;
+	// Executed byte-code. Unlike ccScript's code array which is int32_t, the one
 	// in ccInstance must be intptr_t to accomodate real pointers placed after
 	// performing fixups.
 	intptr_t *code;
 	ccInstance *runningInst;  // might point to another instance if in far call
-	int codesize;
+	int32_t codesize;
 	char *strings;
-	int stringssize;
+	int32_t stringssize;
 	RuntimeScriptValue *exports;
 	RuntimeScriptValue *stack;
 	int  num_stackentries;
@@ -130,18 +130,18 @@ public:
 	// TODO: probably change to dynamic array later
 	char *stackdata;    // for storing stack data of unknown type
 	char *stackdata_ptr;// works similar to original stack pointer, points to the next unused byte in stack data array
-	int stackdatasize; // conventional size of stack data in bytes
+	int32_t stackdatasize; // conventional size of stack data in bytes
 	//
 	RuntimeScriptValue registers[CC_NUM_REGISTERS];
-	int pc;                     // program counter
-	int line_number;            // source code line number
+	int32_t pc;                     // program counter
+	int32_t line_number;            // source code line number
 	PScript instanceof;
 	int  loadedInstanceId;
 	int  returnValue;
 
 	int  callStackSize;
-	int callStackLineNumber[MAX_CALL_STACK];
-	int callStackAddr[MAX_CALL_STACK];
+	int32_t callStackLineNumber[MAX_CALL_STACK];
+	int32_t callStackAddr[MAX_CALL_STACK];
 	ccInstance *callStackCodeInst[MAX_CALL_STACK];
 
 	// array of real import indexes used in script
@@ -167,9 +167,9 @@ public:
 	void    AbortAndDestroy();
 
 	// Call an exported function in the script
-	int     CallScriptFunction(const char *funcname, int num_params, const RuntimeScriptValue *params);
+	int     CallScriptFunction(const char *funcname, int32_t num_params, const RuntimeScriptValue *params);
 	// Begin executing script starting from the given bytecode index
-	int     Run(int curpc);
+	int     Run(int32_t curpc);
 
 	// Get the script's execution position and callstack as human-readable text
 	Shared::String GetCallStack(int maxLines);
@@ -189,9 +189,9 @@ protected:
 	bool    ResolveScriptImports(PScript scri);
 	bool    CreateGlobalVars(PScript scri);
 	bool    AddGlobalVar(const ScriptVariable &glvar);
-	ScriptVariable *FindGlobalVar(int var_addr);
+	ScriptVariable *FindGlobalVar(int32_t var_addr);
 	bool    CreateRuntimeCodeFixups(PScript scri);
-	//bool    ReadOperation(ScriptOperation &op, int at_pc);
+	//bool    ReadOperation(ScriptOperation &op, int32_t at_pc);
 
 	// Runtime fixups
 	//bool    FixupArgument(intptr_t code_value, char fixup_type, RuntimeScriptValue &argument);
@@ -200,23 +200,23 @@ protected:
 	// Push writes new value and increments stack ptr;
 	// stack ptr now points to the __next empty__ entry
 	void    PushValueToStack(const RuntimeScriptValue &rval);
-	void    PushDataToStack(int num_bytes);
+	void    PushDataToStack(int32_t num_bytes);
 	// Pop decrements stack ptr, returns last stored value and invalidates! stack tail;
 	// stack ptr now points to the __next empty__ entry




More information about the Scummvm-git-logs mailing list