shithub: duke3d

Download patch

ref: 7ffae16ab7bf670b6e0480c52b2f91eed291a26f
parent: d795e124e7a097d8ece2e2433729535b3b1bbee7
author: Fabien Sanglard <[email protected]>
date: Thu Dec 13 13:09:43 EST 2012

Removed int for int32_t.

--- a/Engine/src/a.c
+++ b/Engine/src/a.c
@@ -54,9 +54,9 @@
     uint32_t source;
     int32_t shade = _shade & 0xffffff00;
     int32_t count = _count + 1;
-    register unsigned char bits = machxbits_bl;
-    register unsigned char *lookup = (uint8_t *) machxbits_ecx;
-    register unsigned char *pal = (uint8_t *) pal_eax;
+    register uint8_t  bits = machxbits_bl;
+    register uint8_t  *lookup = (uint8_t *) machxbits_ecx;
+    register uint8_t  *pal = (uint8_t *) pal_eax;
     int32_t _asm1 = asm1;
     int32_t _asm2 = asm2;
 
@@ -146,8 +146,8 @@
 	    else i2 -= rmmach_ecx;
 	    ebp &= rmmach_esi;
 	    if ((i3&0xff) != 255) {
-		    i1 = ((i1&0xffffff00)|(((unsigned char *)i3)[rmmach_edx]));
-		    ((unsigned char *)rmach6b)[i6] = (i1&0xff);
+		    i1 = ((i1&0xffffff00)|(((uint8_t  *)i3)[rmmach_edx]));
+		    ((uint8_t  *)rmach6b)[i6] = (i1&0xff);
 	    }
 	    i2 -= ebp;
 	    i6--;
@@ -185,13 +185,13 @@
 int32_t vlineasm1(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6);
 
 /* #pragma aux prevlineasm1 parm [eax][ebx][ecx][edx][esi][edi] */
-static unsigned char mach3_al;
+static uint8_t  mach3_al;
 
 //FCS:  RENDER TOP AND BOTTOM COLUMN
 int32_t prevlineasm1(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
 {
-    unsigned char *source = (unsigned char *)i5;
-    unsigned char *dest = (unsigned char *)i6;
+    uint8_t  *source = (uint8_t  *)i5;
+    uint8_t  *dest = (uint8_t  *)i6;
 
 	
 
@@ -205,7 +205,7 @@
         //((uint32_t)i4) >>= mach3_al;
         i4 = ((uint32_t)i4) >> mach3_al;
 	    i4 = (i4&0xffffff00) | (source[i4]&0xff);
-	    *dest = ((unsigned char*)i2)[i4];
+	    *dest = ((uint8_t *)i2)[i4];
 	    return i1;
     } else {
 	    return vlineasm1(i1,i2,i3,i4,i5,i6);
@@ -213,7 +213,7 @@
 } /* prevlineasm1 */
 
 //FCS:Debug
-//extern unsigned char * get_framebuffer(void);
+//extern uint8_t  * get_framebuffer(void);
 
 /* #pragma aux vlineasm1 parm [eax][ebx][ecx][edx][esi][edi] */
 //FCS: This is used to draw wall border vertical lines
@@ -220,7 +220,7 @@
 int32_t vlineasm1(int32_t vince, int32_t palookupoffse, int32_t i3, int32_t vplce, int32_t bufplce, int32_t i6)
 {
     uint32_t temp;
-    unsigned char *dest = (unsigned char *)i6;
+    uint8_t  *dest = (uint8_t  *)i6;
 
     if (!RENDER_DRAW_WALL_BORDERS)
 		return vplce;
@@ -230,9 +230,9 @@
     {
 	    temp = ((unsigned)vplce) >> mach3_al;
         
-	    temp = ((unsigned char *)bufplce)[temp];
+	    temp = ((uint8_t  *)bufplce)[temp];
       
-        *dest = ((unsigned char*)palookupoffse)[temp];
+        *dest = ((uint8_t *)palookupoffse)[temp];
 	    vplce += vince;
 	    dest += fixchain;
 	    i3--;
@@ -241,7 +241,7 @@
 } /* vlineasm1 */
 
 /* #pragma aux setuptvlineasm parm [eax] */
-static unsigned char transmach3_al = 32;
+static uint8_t  transmach3_al = 32;
 void setuptvlineasm(int32_t i1)
 {
     transmach3_al = (i1 & 0x1f);
@@ -251,8 +251,8 @@
 static int transrev = 0;
 int32_t tvlineasm1(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
 {
-	unsigned char *source = (unsigned char *)i5;
-	unsigned char *dest = (unsigned char *)i6;
+	uint8_t  *source = (uint8_t  *)i5;
+	uint8_t  *dest = (uint8_t  *)i6;
 
 	i3++;
 	while (i3)
@@ -263,10 +263,10 @@
 		if (temp != 255)
 		{
 			unsigned short val;
-			val = ((unsigned char *)i2)[temp];
+			val = ((uint8_t  *)i2)[temp];
 			val |= ((*dest)<<8);
 			if (transrev) val = ((val>>8)|(val<<8));
-			*dest = ((unsigned char *)tmach)[val];
+			*dest = ((uint8_t  *)tmach)[val];
 		}
 		i4 += i1;
 		dest += fixchain;
@@ -276,7 +276,7 @@
 } /* tvlineasm1 */
 
 /* #pragma aux setuptvlineasm2 parm [eax][ebx][ecx] */
-static unsigned char tran2shr;
+static uint8_t  tran2shr;
 static uint32_t tran2pal_ebx;
 static uint32_t tran2pal_ecx;
 void setuptvlineasm2(int32_t i1, int32_t i2, int32_t i3)
@@ -304,37 +304,37 @@
 		i2 = ebp >> tran2shr;
 		i5 += tran2inca;
 		ebp += tran2incb;
-		i3 = ((unsigned char *)tran2bufa)[i1];
-		i4 = ((unsigned char *)tran2bufb)[i2];
+		i3 = ((uint8_t  *)tran2bufa)[i1];
+		i4 = ((uint8_t  *)tran2bufb)[i2];
 		if (i3 == 255) { // skipdraw1
 			if (i4 != 255) { // skipdraw3
 				unsigned short val;
-				val = ((unsigned char *)tran2pal_ecx)[i4];
-				val |= (((unsigned char *)i6)[tran2edi1]<<8);
+				val = ((uint8_t  *)tran2pal_ecx)[i4];
+				val |= (((uint8_t  *)i6)[tran2edi1]<<8);
 				if (transrev) val = ((val>>8)|(val<<8));
-				((unsigned char *)i6)[tran2edi1] =
-					((unsigned char *)tmach)[val];
+				((uint8_t  *)i6)[tran2edi1] =
+					((uint8_t  *)tmach)[val];
 			}
 		} else if (i4 == 255) { // skipdraw2
 			unsigned short val;
-			val = ((unsigned char *)tran2pal_ebx)[i3];
-			val |= (((unsigned char *)i6)[tran2edi]<<8);
+			val = ((uint8_t  *)tran2pal_ebx)[i3];
+			val |= (((uint8_t  *)i6)[tran2edi]<<8);
 			if (transrev) val = ((val>>8)|(val<<8));
-			((unsigned char *)i6)[tran2edi] =
-				((unsigned char *)tmach)[val];
+			((uint8_t  *)i6)[tran2edi] =
+				((uint8_t  *)tmach)[val];
 		} else {
-			unsigned short l = ((unsigned char *)i6)[tran2edi]<<8;
-			unsigned short r = ((unsigned char *)i6)[tran2edi1]<<8;
-			l |= ((unsigned char *)tran2pal_ebx)[i3];
-			r |= ((unsigned char *)tran2pal_ecx)[i4];
+			unsigned short l = ((uint8_t  *)i6)[tran2edi]<<8;
+			unsigned short r = ((uint8_t  *)i6)[tran2edi1]<<8;
+			l |= ((uint8_t  *)tran2pal_ebx)[i3];
+			r |= ((uint8_t  *)tran2pal_ecx)[i4];
 			if (transrev) {
 				l = ((l>>8)|(l<<8));
 				r = ((r>>8)|(r<<8));
 			}
-			((unsigned char *)i6)[tran2edi] =
-				((unsigned char *)tmach)[l];
-			((unsigned char *)i6)[tran2edi1] =
-				((unsigned char *)tmach)[r];
+			((uint8_t  *)i6)[tran2edi] =
+				((uint8_t  *)tmach)[l];
+			((uint8_t  *)i6)[tran2edi1] =
+				((uint8_t  *)tmach)[r];
 		}
 		i6 += fixchain;
 	} while (i6 > i6 - fixchain);
@@ -344,18 +344,18 @@
 
 
 /* #pragma aux mvlineasm1 parm [eax][ebx][ecx][edx][esi][edi] */
-static unsigned char machmv;
+static uint8_t  machmv;
 int32_t mvlineasm1(int32_t vince, int32_t palookupoffse, int32_t i3, int32_t vplce, int32_t bufplce, int32_t i6)
 {
     uint32_t temp;
-    unsigned char *dest = (unsigned char *)i6;
+    uint8_t  *dest = (uint8_t  *)i6;
 
 	// FIX_00087: 1024x768 mode being slow. Undone FIX_00070 and fixed font issue again
     for(;i3>=0;i3--)
     {
 	    temp = ((unsigned)vplce) >> machmv;
-	    temp = ((unsigned char *)bufplce)[temp];
-	    if (temp != 255) *dest = ((unsigned char*)palookupoffse)[temp];
+	    temp = ((uint8_t  *)bufplce)[temp];
+	    if (temp != 255) *dest = ((uint8_t *)palookupoffse)[temp];
 	    vplce += vince;
 	    dest += fixchain;
     }
@@ -381,7 +381,7 @@
 
     uint32_t temp[4];
     uint32_t index = (i2 + ylookup[i1]);
-    unsigned char *dest = (unsigned char*)(-ylookup[i1]);
+    uint8_t  *dest = (uint8_t *)(-ylookup[i1]);
 
     uint32_t vec_temp;
     int32_t vec_vplce;
@@ -389,10 +389,10 @@
     int32_t vec_bufplce;
     uint32_t vec_shifter;
 
-    unsigned char *pal0 = (unsigned char *) palookupoffse[0];
-    unsigned char *pal1 = (unsigned char *) palookupoffse[1];
-    unsigned char *pal2 = (unsigned char *) palookupoffse[2];
-    unsigned char *pal3 = (unsigned char *) palookupoffse[3];
+    uint8_t  *pal0 = (uint8_t  *) palookupoffse[0];
+    uint8_t  *pal1 = (uint8_t  *) palookupoffse[1];
+    uint8_t  *pal2 = (uint8_t  *) palookupoffse[2];
+    uint8_t  *pal3 = (uint8_t  *) palookupoffse[3];
 
     vec_shifter = vec_ld(0, mach_array);
     vec_vplce = vec_ld(0, vplce);
@@ -404,10 +404,10 @@
         vec_temp = ( uint32_t) vec_add(vec_bufplce, (vector signed int) vec_temp);
         vec_st(vec_temp, 0x00, temp);
         vec_vplce = vec_add(vec_vplce, vec_vince);
-	    dest[index] = pal0[*((unsigned char *) temp[0])];
-	    dest[index+1] = pal1[*((unsigned char *) temp[1])];
-	    dest[index+2] = pal2[*((unsigned char *) temp[2])];
-	    dest[index+3] = pal3[*((unsigned char *) temp[3])];
+	    dest[index] = pal0[*((uint8_t  *) temp[0])];
+	    dest[index+1] = pal1[*((uint8_t  *) temp[1])];
+	    dest[index+2] = pal2[*((uint8_t  *) temp[2])];
+	    dest[index+3] = pal3[*((uint8_t  *) temp[3])];
         dest += fixchain;
     } while (((unsigned)dest - fixchain) < ((unsigned)dest));
 
@@ -433,13 +433,13 @@
         int i;
         uint32_t temp;
         uint32_t index = (i2 + ylookup[i1]);
-        unsigned char *dest = (unsigned char*)(-ylookup[i1]);
+        uint8_t  *dest = (uint8_t *)(-ylookup[i1]);
         do {
             for (i = 0; i < 4; i++)
             {
         	    temp = ((unsigned)vplce[i]) >> mach3_al;
-        	    temp = (((unsigned char*)(bufplce[i]))[temp]);
-        	    dest[index+i] = ((unsigned char*)(palookupoffse[i]))[temp];
+        	    temp = (((uint8_t *)(bufplce[i]))[temp]);
+        	    dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
 	            vplce[i] += vince[i];
             }
             dest += fixchain;
@@ -459,15 +459,15 @@
     int i;
     uint32_t temp;
     uint32_t index = (i2 + ylookup[i1]);
-    unsigned char *dest = (unsigned char*)(-ylookup[i1]);
+    uint8_t  *dest = (uint8_t *)(-ylookup[i1]);
 
     do {
         for (i = 0; i < 4; i++)
         {
 	    temp = ((unsigned)vplce[i]) >> machmv;
-	    temp = (((unsigned char*)(bufplce[i]))[temp]);
+	    temp = (((uint8_t *)(bufplce[i]))[temp]);
 	    if (temp != 255)
-		    dest[index+i] = ((unsigned char*)(palookupoffse[i]))[temp];
+		    dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
 	    vplce[i] += vince[i];
         }
         dest += fixchain;
@@ -492,8 +492,8 @@
 /* #pragma aux spritevline parm [eax][ebx][ecx][edx][esi][edi] */
 void spritevline(int32_t i1, uint32_t i2, int32_t i3, uint32_t i4, int32_t i5, int32_t i6)
 {
-    unsigned char *source = (unsigned char *)i5;
-    unsigned char *dest = (unsigned char *)i6;
+    uint8_t  *source = (uint8_t  *)i5;
+    uint8_t  *dest = (uint8_t  *)i6;
 
 dumblabel1:
     i2 += smach_eax;
@@ -501,7 +501,7 @@
     if ((i2 - smach_eax) > i2) source += smach2_eax + 1;
     else source += smach2_eax;
 dumblabel2:
-    i1 = (i1&0xffffff00) | (((unsigned char *)spal_eax)[i1]&0xff);
+    i1 = (i1&0xffffff00) | (((uint8_t  *)spal_eax)[i1]&0xff);
     *dest = i1;
     dest += fixchain;
 
@@ -535,8 +535,8 @@
 /* #pragma aux mspritevline parm [eax][ebx][ecx][edx][esi][edi] */
 void mspritevline(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
 {
-    unsigned char *source = (unsigned char *)i5;
-    unsigned char *dest = (unsigned char *)i6;
+    uint8_t  *source = (uint8_t  *)i5;
+    uint8_t  *dest = (uint8_t  *)i6;
 
 msdumblabel1:
     i2 += smach_eax;
@@ -546,7 +546,7 @@
 msdumblabel2:
     if ((i1&0xff) != 255)
     {
-	    i1 = (i1&0xffffff00) | (((unsigned char *)spal_eax)[i1]&0xff);
+	    i1 = (i1&0xffffff00) | (((uint8_t  *)spal_eax)[i1]&0xff);
 	    *dest = i1;
     }
     dest += fixchain;
@@ -589,7 +589,7 @@
 			uint32_t adder = tsmach_eax2;
 			i4 += tsmach_ecx;
 			if (i4 < (i4 - tsmach_ecx)) adder = tsmach_eax3;
-			i1 = *((unsigned char *)i5);
+			i1 = *((uint8_t  *)i5);
 			i2 += tsmach_eax1;
 			if (i2 < (i2 - tsmach_eax1)) i5++;
 			i5 += adder;
@@ -597,11 +597,11 @@
 			if (i1 != 0xff)
 			{
 				unsigned short val;
-				val = ((unsigned char*)tspal)[i1];
-				val |= ((*((unsigned char *)i6))<<8);
+				val = ((uint8_t *)tspal)[i1];
+				val |= ((*((uint8_t  *)i6))<<8);
 				if (transrev) val = ((val>>8)|(val<<8));
-				i1 = ((unsigned char *)tmach)[val];
-				*((unsigned char *)i6) = (i1&0xff);
+				i1 = ((uint8_t  *)tmach)[val];
+				*((uint8_t  *)i6) = (i1&0xff);
 			}
 			i6 += fixchain;
 		}
@@ -624,8 +624,8 @@
 } /* mhline */
 
 /* #pragma aux mhlineskipmodify parm [eax][ebx][ecx][edx][esi][edi] */
-static unsigned char mshift_al = 26;
-static unsigned char mshift_bl = 6;
+static uint8_t  mshift_al = 26;
+static uint8_t  mshift_bl = 6;
 void mhlineskipmodify(int32_t i1, uint32_t i2, uint32_t i3, int32_t i4, int32_t i5, int32_t i6)
 {
     uint32_t ebx;
@@ -634,9 +634,9 @@
     {
 	    ebx = i2 >> mshift_al;
 	    ebx = shld (ebx, (unsigned)i5, mshift_bl);
-	    i1 = ((unsigned char *)mmach_eax)[ebx];
+	    i1 = ((uint8_t  *)mmach_eax)[ebx];
 	    if ((i1&0xff) != 0xff)
-		    *((unsigned char *)i6) = (((unsigned char*)mmach_asm3)[i1]);
+		    *((uint8_t  *)i6) = (((uint8_t *)mmach_asm3)[i1]);
 
 	    i2 += mmach_asm1;
 	    i5 += mmach_asm2;
@@ -669,8 +669,8 @@
 } /* thline */
 
 /* #pragma aux thlineskipmodify parm [eax][ebx][ecx][edx][esi][edi] */
-static unsigned char tshift_al = 26;
-static unsigned char tshift_bl = 6;
+static uint8_t  tshift_al = 26;
+static uint8_t  tshift_bl = 6;
 void thlineskipmodify(int32_t i1, uint32_t i2, uint32_t i3, int32_t i4, int32_t i5, int32_t i6)
 {
     uint32_t ebx;
@@ -679,13 +679,13 @@
     {
 	    ebx = i2 >> tshift_al;
 	    ebx = shld (ebx, (unsigned)i5, tshift_bl);
-	    i1 = ((unsigned char *)tmach_eax)[ebx];
+	    i1 = ((uint8_t  *)tmach_eax)[ebx];
 	    if ((i1&0xff) != 0xff)
 	    {
-		    unsigned short val = (((unsigned char*)tmach_asm3)[i1]);
-		    val |= (*((unsigned char *)i6)<<8);
+		    unsigned short val = (((uint8_t *)tmach_asm3)[i1]);
+		    val |= (*((uint8_t  *)i6)<<8);
 		    if (transrev) val = ((val>>8)|(val<<8));
-		    *((unsigned char *)i6) = (((unsigned char*)tmach)[val]);
+		    *((uint8_t  *)i6) = (((uint8_t *)tmach)[val]);
 	    }
 
 	    i2 += tmach_asm1;
@@ -707,8 +707,8 @@
 static int32_t slopemach_ebx;
 static int32_t slopemach_ecx;
 static int32_t slopemach_edx;
-static unsigned char slopemach_ah1;
-static unsigned char slopemach_ah2;
+static uint8_t  slopemach_ah1;
+static uint8_t  slopemach_ah2;
 static float asm2_f;
 typedef union { unsigned int i; float f; } bitwisef2i;
 void setupslopevlin(int32_t i1, int32_t i2, int32_t i3)
@@ -750,7 +750,7 @@
 	    // All this is calculating a fixed point approx. of 1/a
 	    c.f = a;
 	    fpuasm = eax = c.i;
-	    edx = (((long)eax) < 0) ? 0xffffffff : 0;
+	    edx = (((int32_t)eax) < 0) ? 0xffffffff : 0;
 	    eax = eax << 1;
 	    ecx = (eax>>24);	//  exponent
 	    eax = ((eax&0xffe000)>>11);
@@ -780,18 +780,18 @@
 		    ebx &= slopemach_edx;
 		    edi += eax;
 		    i1 += slopemach_ecx;
-		    edx = ((edx&0xffffff00)|((((unsigned char *)(ebx+edx))[slopemach_ebx])));
+		    edx = ((edx&0xffffff00)|((((uint8_t  *)(ebx+edx))[slopemach_ebx])));
 		    ebx = *((uint32_t*)i3); // register trickery
 		    i3 -= 4;
-		    eax = ((eax&0xffffff00)|(*((unsigned char *)(ebx+edx))));
+		    eax = ((eax&0xffffff00)|(*((uint8_t  *)(ebx+edx))));
 		    ebx = esi;
-		    *((unsigned char *)i1) = (eax&0xff);
+		    *((uint8_t  *)i1) = (eax&0xff);
 		    edx = edi;
 		    ecx = ((ecx&0xffffff00)|((ecx-1)&0xff));
 	    }
 	    ebx = asm4;
 	    ebx -= 8;	// BITSOFPRECISIONPOW
-    } while ((long)ebx > 0);
+    } while ((int32_t)ebx > 0);
 } /* slopevlin */
 
 /* #pragma aux settransnormal parm */
--- a/Engine/src/build.h
+++ b/Engine/src/build.h
@@ -70,11 +70,11 @@
 	short ceilingstat, floorstat;
 	short ceilingpicnum, ceilingheinum;
 	signed char ceilingshade;
-	unsigned char ceilingpal, ceilingxpanning, ceilingypanning;
+	uint8_t  ceilingpal, ceilingxpanning, ceilingypanning;
 	short floorpicnum, floorheinum;
 	signed char floorshade;
-	unsigned char floorpal, floorxpanning, floorypanning;
-	unsigned char visibility, filler;
+	uint8_t  floorpal, floorxpanning, floorypanning;
+	uint8_t  visibility, filler;
 	short lotag, hitag, extra;
 } sectortype;
 
@@ -128,8 +128,8 @@
 	int32_t x, y, z;
 	short cstat, picnum;
 	signed char shade;
-	unsigned char pal, clipdist, filler;
-	unsigned char xrepeat, yrepeat;
+	uint8_t  pal, clipdist, filler;
+	uint8_t  xrepeat, yrepeat;
 	signed char xoffset, yoffset;
 	short sectnum, statnum;
 	short ang, owner, xvel, yvel, zvel;
@@ -163,7 +163,7 @@
 EXTERN volatile int32_t totalclock;
 EXTERN int32_t numframes, randomseed;
 EXTERN short sintable[2048];
-EXTERN unsigned char palette[768];
+EXTERN uint8_t  palette[768];
 EXTERN short numpalookups;
 EXTERN char *palookup[MAXPALOOKUPS];
 EXTERN char parallaxtype, showinvisibility;
--- a/Engine/src/cache1d.c
+++ b/Engine/src/cache1d.c
@@ -36,7 +36,7 @@
  *   Step 1: Allocate a nice BIG buffer, like from 1MB-4MB and
  *           Call initcache(int32_t cachestart, int32_t cachesize) where
  *
- *              cachestart = (long)(pointer to start of BIG buffer)
+ *              cachestart = (int32_t )(pointer to start of BIG buffer)
  *              cachesize = length of BIG buffer
  *
  *   Step 2: Call allocache(int32_t *bufptr, int32_t bufsiz, char *lockptr)
@@ -63,9 +63,9 @@
 
 static int32_t cachesize = 0;
 int32_t cachecount = 0;
-unsigned char zerochar = 0;
+uint8_t  zerochar = 0;
 int32_t cachestart = 0, cacnum = 0, agecount = 0;
-typedef struct { int32_t *hand, leng; unsigned char *lock; } cactype;
+typedef struct { int32_t *hand, leng; uint8_t  *lock; } cactype;
 cactype cac[MAXCACHEOBJECTS];
 int32_t lockrecip[200];
 
@@ -86,7 +86,7 @@
 	cacnum = 1;
 }
 
-void allocache (int32_t *newhandle, int32_t newbytes, unsigned char *newlockptr)
+void allocache (int32_t *newhandle, int32_t newbytes, uint8_t  *newlockptr)
 {
 	int32_t i, z, zz, bestz=0, daval, bestval, besto=0, o1, o2, sucklen, suckz;
 
@@ -116,7 +116,7 @@
 		{
 			if (*cac[zz].lock == 0) continue;
 			if (*cac[zz].lock >= 200) { daval = 0x7fffffff; break; }
-			daval += (long) mulscale32(cac[zz].leng+65536,lockrecip[*cac[zz].lock]);
+			daval += (int32_t ) mulscale32(cac[zz].leng+65536,lockrecip[*cac[zz].lock]);
 			if (daval >= bestval) break;
 		}
 		if (daval < bestval)
@@ -169,7 +169,7 @@
 
 		/* Can't exit early, because invalid pointer might be same even though lock = 0 */
 	for(i=0;i<cacnum;i++)
-		if ((long)(*cac[i].hand) == (long)suckptr)
+		if ((int32_t )(*cac[i].hand) == (int32_t )suckptr)
 		{
 			if (*cac[i].lock) *cac[i].hand = 0;
 			cac[i].lock = &zerochar;
@@ -201,7 +201,7 @@
 	{
 		ch = (*cac[agecount].lock);
 		if (((ch-2)&255) < 198)
-			(*cac[agecount].lock) = (unsigned char) (ch-1);
+			(*cac[agecount].lock) = (uint8_t ) (ch-1);
 
 		agecount--; if (agecount < 0) agecount = cacnum-1;
 	}
@@ -229,7 +229,7 @@
 }
 
 #if (!defined USE_PHYSICSFS)
-unsigned char toupperlookup[256] =
+uint8_t  toupperlookup[256] =
 {
 	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
 	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
@@ -258,7 +258,7 @@
 char *groupfil_memory[MAXGROUPFILES]; // addresses of raw GRP files in memory
 int32_t groupefil_crc32[MAXGROUPFILES];
 
-unsigned char filegrp[MAXOPENFILES];
+uint8_t  filegrp[MAXOPENFILES];
 int32_t filepos[MAXOPENFILES];
 int32_t filehan[MAXOPENFILES] =
 {
@@ -376,7 +376,7 @@
 	groupfil_memory[numgroupfiles] = malloc(i);
 	while((j=read(groupfil[numgroupfiles], groupfil_memory[numgroupfiles], i)))
 	{
-		groupefil_crc32[numgroupfiles] = crc32_update((unsigned char*)groupfil_memory[numgroupfiles], j, groupefil_crc32[numgroupfiles]);
+		groupefil_crc32[numgroupfiles] = crc32_update((uint8_t *)groupfil_memory[numgroupfiles], j, groupefil_crc32[numgroupfiles]);
 	}
 
 	free(groupfil_memory[numgroupfiles]);  
@@ -494,7 +494,7 @@
     }
 }
 
-unsigned int crc32(unsigned char *buf, unsigned int length)
+unsigned int crc32(uint8_t  *buf, unsigned int length)
 {
 	unsigned int initial_crc;
 
@@ -502,7 +502,7 @@
 	return(crc32_update(buf, length, initial_crc));
 }
 
-unsigned int crc32_update(unsigned char *buf, unsigned int length, unsigned int crc_to_update)
+unsigned int crc32_update(uint8_t  *buf, unsigned int length, unsigned int crc_to_update)
 {
 	unsigned int crc32_table[256];
 
@@ -530,7 +530,7 @@
 
 unsigned short crc16(char *data_p, unsigned short length)
 {
-      unsigned char i;
+      uint8_t  i;
       unsigned int data;
       unsigned int crc = 0xffff;
 
@@ -583,7 +583,7 @@
     return(-1);
 #else
 	int32_t i, j, k, fil, newhandle;
-	unsigned char bad;
+	uint8_t  bad;
 	char *gfileptr;
 
 	newhandle = MAXOPENFILES-1;
@@ -623,7 +623,7 @@
 				}
 				if (bad) continue;
 
-				filegrp[newhandle] = (unsigned char) k;
+				filegrp[newhandle] = (uint8_t ) k;
 				filehan[newhandle] = i;
 				filepos[newhandle] = 0;
 				return(newhandle);
@@ -715,7 +715,7 @@
 
 	groupnum = filegrp[handle];
 
-	if (groupnum == 255) return((long)lseek(filehan[handle],offset,whence));
+	if (groupnum == 255) return((int32_t )lseek(filehan[handle],offset,whence));
 	if (groupfil[groupnum] != -1)
 	{
 		switch(whence)
@@ -737,7 +737,7 @@
 {
     struct stat stats;
     fstat(fd, &stats);
-    return (long)stats.st_size;
+    return (int32_t )stats.st_size;
 }
 #endif
 
@@ -776,7 +776,7 @@
 	/* Internal LZW variables */
 #define LZWSIZE 16384           /* Watch out for shorts! */
 static char *lzwbuf1, *lzwbuf4, *lzwbuf5;
-static unsigned char lzwbuflock[5];
+static uint8_t  lzwbuflock[5];
 static short *lzwbuf2, *lzwbuf3;
 
 void kdfread(void *buffer, size_t dasizeof, size_t count, int32_t fil)
@@ -796,21 +796,21 @@
 	if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; }
 	ptr = (char *)buffer;
 
-	kread(fil,&leng,2); kread(fil,lzwbuf5,(long)leng);
+	kread(fil,&leng,2); kread(fil,lzwbuf5,(int32_t )leng);
 	k = 0;
-	kgoal = uncompress(lzwbuf5,(long)leng,lzwbuf4);
+	kgoal = uncompress(lzwbuf5,(int32_t )leng,lzwbuf4);
 
-	copybufbyte(lzwbuf4,ptr,(long)dasizeof);
-	k += (long)dasizeof;
+	copybufbyte(lzwbuf4,ptr,(int32_t )dasizeof);
+	k += (int32_t )dasizeof;
 
 	for(i=1;i<count;i++)
 	{
 		if (k >= kgoal)
 		{
-			kread(fil,&leng,2); kread(fil,lzwbuf5,(long)leng);
-			k = 0; kgoal = uncompress(lzwbuf5,(long)leng,lzwbuf4);
+			kread(fil,&leng,2); kread(fil,lzwbuf5,(int32_t )leng);
+			k = 0; kgoal = uncompress(lzwbuf5,(int32_t )leng,lzwbuf4);
 		}
-		for(j=0;j<dasizeof;j++) ptr[j+dasizeof] = (unsigned char) ((ptr[j]+lzwbuf4[j+k])&255);
+		for(j=0;j<dasizeof;j++) ptr[j+dasizeof] = (uint8_t ) ((ptr[j]+lzwbuf4[j+k])&255);
 		k += dasizeof;
 		ptr += dasizeof;
 	}
@@ -834,20 +834,20 @@
 	if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; }
 	ptr = (char *)buffer;
 
-	fread(&leng,2,1,fil); fread(lzwbuf5,(long)leng,1,fil);
-	k = 0; kgoal = uncompress(lzwbuf5,(long)leng,lzwbuf4);
+	fread(&leng,2,1,fil); fread(lzwbuf5,(int32_t )leng,1,fil);
+	k = 0; kgoal = uncompress(lzwbuf5,(int32_t )leng,lzwbuf4);
 
-	copybufbyte(lzwbuf4,ptr,(long)dasizeof);
-	k += (long)dasizeof;
+	copybufbyte(lzwbuf4,ptr,(int32_t )dasizeof);
+	k += (int32_t )dasizeof;
 
 	for(i=1;i<count;i++)
 	{
 		if (k >= kgoal)
 		{
-			fread(&leng,2,1,fil); fread(lzwbuf5,(long)leng,1,fil);
-			k = 0; kgoal = uncompress(lzwbuf5,(long)leng,lzwbuf4);
+			fread(&leng,2,1,fil); fread(lzwbuf5,(int32_t )leng,1,fil);
+			k = 0; kgoal = uncompress(lzwbuf5,(int32_t )leng,lzwbuf4);
 		}
-		for(j=0;j<dasizeof;j++) ptr[j+dasizeof] = (unsigned char) ((ptr[j]+lzwbuf4[j+k])&255);
+		for(j=0;j<dasizeof;j++) ptr[j+dasizeof] = (uint8_t ) ((ptr[j]+lzwbuf4[j+k])&255);
 		k += dasizeof;
 		ptr += dasizeof;
 	}
@@ -870,23 +870,23 @@
 	if (dasizeof > LZWSIZE) { count *= dasizeof; dasizeof = 1; }
 	ptr = (char *)buffer;
 
-	copybufbyte(ptr,lzwbuf4,(long)dasizeof);
+	copybufbyte(ptr,lzwbuf4,(int32_t )dasizeof);
 	k = dasizeof;
 
 	if (k > LZWSIZE-dasizeof)
 	{
 		leng = (short)compress(lzwbuf4,k,lzwbuf5); k = 0;
-		fwrite(&leng,2,1,fil); fwrite(lzwbuf5,(long)leng,1,fil);
+		fwrite(&leng,2,1,fil); fwrite(lzwbuf5,(int32_t )leng,1,fil);
 	}
 
 	for(i=1;i<count;i++)
 	{
-		for(j=0;j<dasizeof;j++) lzwbuf4[j+k] = (unsigned char) ((ptr[j+dasizeof]-ptr[j])&255);
+		for(j=0;j<dasizeof;j++) lzwbuf4[j+k] = (uint8_t ) ((ptr[j+dasizeof]-ptr[j])&255);
 		k += dasizeof;
 		if (k > LZWSIZE-dasizeof)
 		{
 			leng = (short)compress(lzwbuf4,k,lzwbuf5); k = 0;
-			fwrite(&leng,2,1,fil); fwrite(lzwbuf5,(long)leng,1,fil);
+			fwrite(&leng,2,1,fil); fwrite(lzwbuf5,(int32_t )leng,1,fil);
 		}
 		ptr += dasizeof;
 	}
@@ -893,7 +893,7 @@
 	if (k > 0)
 	{
 		leng = (short)compress(lzwbuf4,k,lzwbuf5);
-		fwrite(&leng,2,1,fil); fwrite(lzwbuf5,(long)leng,1,fil);
+		fwrite(&leng,2,1,fil); fwrite(lzwbuf5,(int32_t )leng,1,fil);
 	}
 	lzwbuflock[0] = lzwbuflock[1] = lzwbuflock[2] = lzwbuflock[3] = lzwbuflock[4] = 1;
 }
@@ -967,11 +967,11 @@
 	short *shortptr;
 
 	shortptr = (short *)lzwinbuf;
-	strtot = (long)shortptr[1];
+	strtot = (int32_t )shortptr[1];
 	if (strtot == 0)
 	{
 		copybuf((void *)(FP_OFF(lzwinbuf)+4),(void *)(FP_OFF(lzwoutbuf)),((compleng-4)+3)>>2);
-		return((long)shortptr[0]); /* uncompleng */
+		return((int32_t )shortptr[0]); /* uncompleng */
 	}
 	for(i=255;i>=0;i--) { lzwbuf2[i] = (short) i; lzwbuf3[i] = (short) i; }
 	currstr = 256; bitcnt = (4<<3); outbytecnt = 0;
@@ -996,7 +996,7 @@
 		currstr++;
 		if (currstr > oneupnumbits) { numbits++; oneupnumbits <<= 1; }
 	} while (currstr < strtot);
-	return((long)shortptr[0]); /* uncompleng */
+	return((int32_t )shortptr[0]); /* uncompleng */
 }
 
 
--- a/Engine/src/cache1d.h
+++ b/Engine/src/cache1d.h
@@ -21,7 +21,7 @@
 #define MAXOPENFILES 64     /* Warning: Fix filehan if this is changed  */
 
 void initcache(int32_t dacachestart, int32_t dacachesize);
-void allocache (int32_t *newhandle, int32_t newbytes, unsigned char *newlockptr);
+void allocache (int32_t *newhandle, int32_t newbytes, uint8_t  *newlockptr);
 void suckcache (int32_t *suckptr);
 void agecache(void);
 void reportandexit(char *errormessage);
@@ -28,7 +28,7 @@
 int32_t initgroupfile(const char *filename);
 void uninitgroupfile(void);
 unsigned short crc16(char *data_p, unsigned short length);
-unsigned int crc32_update(unsigned char *buf, unsigned int length, unsigned int crc_to_update);
+unsigned int crc32_update(uint8_t  *buf, unsigned int length, unsigned int crc_to_update);
 int32_t kopen4load(const char *filename, int readfromGRP);
 int32_t kread(int32_t handle, void *buffer, int32_t leng);
 int kread8(int32_t handle, char *buffer);
--- a/Engine/src/display.h
+++ b/Engine/src/display.h
@@ -93,7 +93,7 @@
  * !!! can be made static again.  --ryan.
  * !!! (Actually, most of these extern declarations used to be static...rcg.)
  */
-extern unsigned char permanentlock;
+extern uint8_t  permanentlock;
 
 // defined in the game project:
 extern int32_t BFullScreen;  // defined in Game\src\config.c
@@ -130,7 +130,7 @@
 int setvesa(int32_t x, int32_t y);
 void uninitvesa(void);
 void setvmode(int mode);
-unsigned char readpixel(int32_t offset);
+uint8_t  readpixel(int32_t offset);
 void drawpixel(int32_t offset, Uint8 pixel);
 void drawpixels(int32_t offset, Uint16 pixels);
 void drawpixelses(int32_t offset, Uint32 pixelses);
@@ -146,7 +146,7 @@
 void readmousexy(short *x, short *y);
 void readmousebstatus(short *bstatus);
 void __interrupt __far keyhandler(void);
-unsigned char _readlastkeyhit(void);
+uint8_t  _readlastkeyhit(void);
 
 /* timer krap. */
 int inittimer(int);
--- a/Engine/src/enet/include/types.h
+++ b/Engine/src/enet/include/types.h
@@ -1,4 +1,4 @@
-/** 
+/**
  @file  types.h
  @brief type definitions for ENet
 */
--- a/Engine/src/engine.c
+++ b/Engine/src/engine.c
@@ -117,7 +117,7 @@
 static char globalpolytype;
 static short *dotp1[MAXYDIM], *dotp2[MAXYDIM];
 
-static unsigned char tempbuf[MAXWALLS];
+static uint8_t  tempbuf[MAXWALLS];
 
 int32_t ebpbak, espbak;
 int32_t slopalookup[16384];
@@ -126,7 +126,7 @@
  * !!! used to be static. If we ever put the original setgamemode() back, this
  * !!! can be made static again.  --ryan.
  */
-unsigned char permanentlock = 255;
+uint8_t  permanentlock = 255;
 int32_t artversion, mapversion;
 char *pic = NULL;
 char picsiz[MAXTILES], tilefilenum[MAXTILES];
@@ -261,7 +261,7 @@
 	int32_t sx, sy, z;
 	short a, picnum;
 	signed char dashade;
-	unsigned char dapalnum, dastat, pagesleft;
+	uint8_t  dapalnum, dastat, pagesleft;
 	int32_t cx1, cy1, cx2, cy2;
 } permfifotype;
 static permfifotype permfifo[MAXPERMS];
@@ -597,7 +597,7 @@
 	r = horizlookup2[yp-globalhoriz+horizycent];
 	asm1 = globalx1*r;
 	asm2 = globaly2*r;
-	s = ((long)getpalookup((long)mulscale16(r,globvis),globalshade)<<8);
+	s = ((int32_t)getpalookup((int32_t)mulscale16(r,globvis),globalshade)<<8);
 
 	hlineasm4(xr-xl,0L,s,globalx2*r+globalypanning,globaly1*r+globalxpanning,
 		ylookup[yp]+xr+frameoffset);
@@ -626,7 +626,7 @@
 }
 
 
-static int animateoffs(short tilenum, short fakevar)
+static int animateoffs(int16_t tilenum, int16_t fakevar)
 {
 	int32_t i, k, offs;
 
@@ -680,7 +680,7 @@
 
 	globalshade = (long)sec->ceilingshade;
 	globvis = globalcisibility;
-	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 	globalorientation = (long)sec->ceilingstat;
 
 
@@ -848,7 +848,7 @@
 
 	globalshade = (long)sec->floorshade;
 	globvis = globalcisibility;
-	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 	globalorientation = (long)sec->floorstat;
 
 
@@ -1015,7 +1015,7 @@
  *  --ryan.
  */
 static void wallscan(int32_t x1, int32_t x2,
-                     short *uwal, short *dwal,
+                     int16_t *uwal, int16_t *dwal,
                      int32_t *swal, int32_t *lwal)
 {
 	int32_t i, x, xnice, ynice, fpalookup;
@@ -1299,7 +1299,7 @@
 		globalhoriz = mulscale16(globalhoriz-(ydimen>>1),parallaxyscale) + (ydimen>>1);
 	globvis = globalpisibility;
 	/* globalorientation = 0L; */
-	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 
 	if (dastat == 0)
 	{
@@ -1533,7 +1533,7 @@
 	asm1 = -(globalzd>>(16-BITSOFPRECISION));
 
 	globvis = globalvisibility;
-	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 	globvis = mulscale13(globvis,daz);
 	globvis = mulscale16(globvis,xdimscale);
 	j =(long) FP_OFF(palookup[globalpal]);
@@ -1935,7 +1935,7 @@
 					if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)(wallnum+16384));
 					globalshade = (long)wal->shade;
 					globvis = globalvisibility;
-					if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+					if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 					globalpal = (long)wal->pal;
 					globalyscale = (wal->yrepeat<<(globalshiftval-19));
 					if ((globalorientation&4) == 0)
@@ -2038,7 +2038,7 @@
 						globalpal = (long)wal->pal;
 					}
 					globvis = globalvisibility;
-					if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+					if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 					globalshiftval = (picsiz[globalpicnum]>>4);
 					if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++;
 					globalshiftval = 32-globalshiftval;
@@ -2128,7 +2128,7 @@
 			if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)(wallnum+16384));
 			globalshade = (long)wal->shade;
 			globvis = globalvisibility;
-			if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+			if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 			globalpal = (long)wal->pal;
 			globalshiftval = (picsiz[globalpicnum]>>4);
 			if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++;
@@ -3140,7 +3140,7 @@
 
 
 static void dorotatesprite (int32_t sx, int32_t sy, int32_t z, short a, short picnum,
-	signed char dashade, unsigned char dapalnum, char dastat, int32_t cx1,
+	signed char dashade, uint8_t  dapalnum, char dastat, int32_t cx1,
 	int32_t cy1, int32_t cx2, int32_t cy2)
 {
 	int32_t cosang, sinang, v, nextv, dax1, dax2, oy, bx, by, ny1, ny2;
@@ -3625,7 +3625,7 @@
 	if (waloff[tilenume] == 0)
 	{
 		walock[tilenume] = 199;
-		allocache(&waloff[tilenume],dasiz,(unsigned char *) &walock[tilenume]);
+		allocache(&waloff[tilenume],dasiz,(uint8_t  *) &walock[tilenume]);
 	}
 
 	if (artfilplc != tilefileoffs[tilenume])
@@ -3650,7 +3650,7 @@
 	dasiz = xsiz*ysiz;
 
 	walock[tilenume] = 255;
-	allocache(&waloff[tilenume],dasiz,(unsigned char *) &walock[tilenume]);
+	allocache(&waloff[tilenume],dasiz,(uint8_t  *) &walock[tilenume]);
 
 	tilesizx[tilenume] = xsiz;
 	tilesizy[tilenume] = ysiz;
@@ -3794,7 +3794,7 @@
 
 			/* Must store filenames to use cacheing system :( */
 		voxlock[voxindex][i] = 200;
-		allocache(&voxoff[voxindex][i],dasiz,(unsigned char *)&voxlock[voxindex][i]);
+		allocache(&voxoff[voxindex][i],dasiz,(uint8_t  *)&voxlock[voxindex][i]);
 		ptr = (char *)voxoff[voxindex][i];
 		kread(fil,ptr,dasiz);
 
@@ -3859,7 +3859,7 @@
 }
 
 
-void drawline256 (int32_t x1, int32_t y1, int32_t x2, int32_t y2, unsigned char col)
+void drawline256 (int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t  col)
 {
 	int32_t dx, dy, i, j, p, inc, plc, daend;
 
@@ -3987,7 +3987,7 @@
 void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz,
                    int32_t tilenume2, int32_t sx2, int32_t sy2)
 {
-	unsigned char *ptr1, *ptr2, dat;
+	uint8_t  *ptr1, *ptr2, dat;
 	int32_t xsiz1, ysiz1, xsiz2, ysiz2, i, j, x1, y1, x2, y2;
 
 	xsiz1 = tilesizx[tilenume1]; ysiz1 = tilesizy[tilenume1];
@@ -4007,8 +4007,8 @@
 				y2 = sy2+j;
 				if ((x2 >= 0) && (y2 >= 0) && (x2 < xsiz2) && (y2 < ysiz2))
 				{
-					ptr1 = (unsigned char *) (waloff[tilenume1] + x1*ysiz1 + y1);
-					ptr2 = (unsigned char *) (waloff[tilenume2] + x2*ysiz2 + y2);
+					ptr1 = (uint8_t  *) (waloff[tilenume1] + x1*ysiz1 + y1);
+					ptr2 = (uint8_t  *) (waloff[tilenume2] + x2*ysiz2 + y2);
 					dat = *ptr1;
 					if (dat != 255)
 						*ptr2 = *ptr1;
@@ -4051,7 +4051,7 @@
 	if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,(short)(thewall[z]+16384));
 	globalshade = (long)wal->shade;
 	globvis = globalvisibility;
-	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+	if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 	globalpal = (long)wal->pal;
 	globalshiftval = (picsiz[globalpicnum]>>4);
 	if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++;
@@ -4182,8 +4182,8 @@
 
 #ifdef SUPERBUILD
 static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasprang,
-		  int32_t daxscale, int32_t dayscale, unsigned char daindex,
-		  signed char dashade, unsigned char dapal, int32_t *daumost, int32_t *dadmost)
+		  int32_t daxscale, int32_t dayscale, uint8_t  daindex,
+		  signed char dashade, uint8_t  dapal, int32_t *daumost, int32_t *dadmost)
 {
 	int32_t i, j, k, x, y, syoff, ggxstart, ggystart, nxoff;
 	int32_t cosang, sinang, sprcosang, sprsinang, backx, backy, gxinc, gyinc;
@@ -4580,7 +4580,7 @@
 		globalxpanning = 0L;
 		globalypanning = 0L;
 		globvis = globalvisibility;
-		if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+		if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 		globalshiftval = (picsiz[globalpicnum]>>4);
 		if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++;
 		globalshiftval = 32-globalshiftval;
@@ -4723,7 +4723,7 @@
 		globalxpanning = 0L;
 		globalypanning = 0L;
 		globvis = globalvisibility;
-		if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+		if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 		globalshiftval = (picsiz[globalpicnum]>>4);
 		if (pow2long[globalshiftval] != tilesizy[globalpicnum]) globalshiftval++;
 		globalshiftval = 32-globalshiftval;
@@ -5132,7 +5132,7 @@
 		globalbufplc = waloff[globalpicnum];
 
 		globvis = mulscale16(globalhisibility,viewingrange);
-		if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+		if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 
 		x = picsiz[globalpicnum]; y = ((x>>4)&15); x &= 15;
 		if (pow2long[x] != xspan)
@@ -5227,7 +5227,7 @@
 		tspr->z -= ((yoff*tspr->yrepeat)<<2);
 
 		globvis = globalvisibility;
-		if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+		if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 
 		if ((searchit >= 1) && (yp > (4<<8)) && (searchy >= lwall[searchx]) && (searchy < swall[searchx]))
 		{
@@ -7608,7 +7608,7 @@
 }
 
 
-void setbrightness(char dabrightness, unsigned char *dapal)
+void setbrightness(char dabrightness, uint8_t  *dapal)
 {
 	int32_t i, j, k;
 
@@ -8025,7 +8025,7 @@
 			globalbufplc = waloff[globalpicnum];
 			globalshade = max(min(sec->floorshade,numpalookups-1),0);
 			globvis = globalhisibility;
-			if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+			if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 			globalpolytype = 0;
 			if ((globalorientation&64) == 0)
 			{
@@ -8164,7 +8164,7 @@
 			globalshade = max(min(globalshade+spr->shade+6,numpalookups-1),0);
 			asm3 = (long) FP_OFF(palookup[spr->pal]+(globalshade<<8));
 			globvis = globalhisibility;
-			if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((unsigned char)(sec->visibility+16)));
+			if (sec->visibility != 0) globvis = mulscale4(globvis,(long)((uint8_t )(sec->visibility+16)));
 			globalpolytype = ((spr->cstat&2)>>1)+1;
 
 				/* relative alignment stuff */
@@ -8264,7 +8264,7 @@
 }
 
 
-unsigned char getpixel(int32_t x, int32_t y)
+uint8_t  getpixel(int32_t x, int32_t y)
 {
 	return(readpixel(ylookup[y]+x+frameplace));
 }
@@ -8323,7 +8323,7 @@
 void squarerotatetile(short tilenume)
 {
 	int32_t i, j, k, xsiz, ysiz;
-	unsigned char *ptr1, *ptr2;
+	uint8_t  *ptr1, *ptr2;
 
 	xsiz = tilesizx[tilenume]; ysiz = tilesizy[tilenume];
 
@@ -8333,7 +8333,7 @@
 		k = (xsiz<<1);
 		for(i=xsiz-1;i>=0;i--)
 		{
-			ptr1 = (unsigned char *) (waloff[tilenume]+i*(xsiz+1));
+			ptr1 = (uint8_t  *) (waloff[tilenume]+i*(xsiz+1));
             ptr2 = ptr1;
 			if ((i&1) != 0) { ptr1--; ptr2 -= xsiz; swapchar(ptr1,ptr2); }
 			for(j=(i>>1)-1;j>=0;j--)
--- a/Engine/src/engine.h
+++ b/Engine/src/engine.h
@@ -71,8 +71,8 @@
 int saveboard(char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz,
                          short *daang, short *dacursectnum);
 void plotpixel(int32_t x, int32_t y, char col);
-unsigned char getpixel(int32_t x, int32_t y);
-void setbrightness(char dabrightness, unsigned char *dapal);
+uint8_t  getpixel(int32_t x, int32_t y);
+void setbrightness(char dabrightness, uint8_t  *dapal);
 int screencapture(char *filename, char inverseit);
 void getmousevalues(short *mousx, short *mousy, short *bstatus);
 int clipmove (int32_t *x, int32_t *y, int32_t *z, short *sectnum, int32_t xvect,
@@ -113,7 +113,7 @@
                int32_t x3, int32_t y3, int32_t x4, int32_t y4, int32_t *intx,
                int32_t *inty, int32_t *intz);
 int allocatepermanenttile(short tilenume, int32_t xsiz, int32_t ysiz);
-void drawline256 (int32_t x1, int32_t y1, int32_t x2, int32_t y2, unsigned char col);
+void drawline256 (int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t  col);
 void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz,
                    int32_t tilenume2, int32_t sx2, int32_t sy2);
 int nextsectorneighborz(short sectnum, int32_t thez,
--- a/Engine/src/engine_protos.h
+++ b/Engine/src/engine_protos.h
@@ -87,7 +87,7 @@
 
 /* cache1d.c */
 extern void initcache(int32_t dacachestart, int32_t dacachesize);
-extern void allocache(int32_t *newhandle, int32_t newbytes, unsigned char *newlockptr);
+extern void allocache(int32_t *newhandle, int32_t newbytes, uint8_t  *newlockptr);
 extern void suckcache(int32_t *suckptr);
 extern void agecache(void);
 extern void reportandexit(char *errormessage);
@@ -107,7 +107,7 @@
 /* sdl_driver.c */
 extern int using_opengl(void);
 extern void _handle_events(void);
-extern unsigned char _readlastkeyhit(void);
+extern uint8_t  _readlastkeyhit(void);
 extern int mprotect_align(const void *addr, size_t len, int prot);
 extern void unprotect_ASM_pages(void);
 extern void _platform_init(int argc, char **argv, const char *title, const char *icon);
@@ -125,8 +125,8 @@
 extern void readmousebstatus(short *bstatus);
 extern void _updateScreenRect(int32_t x, int32_t y, int32_t w, int32_t h);
 extern void _nextpage(void);
-extern unsigned char readpixel(int32_t offset);
-extern void drawpixel(int32_t offset, unsigned char pixel);
+extern uint8_t  readpixel(int32_t offset);
+extern void drawpixel(int32_t offset, uint8_t  pixel);
 extern void drawpixels(int32_t offset, unsigned short pixels);
 extern void drawpixelses(int32_t offset, unsigned int pixelses);
 extern void setcolor16(int col);
@@ -197,7 +197,7 @@
 extern int loadpics(char *filename, char* gamedir);
 extern void qloadkvx(int32_t voxindex, char *filename);
 extern int clipinsidebox(int32_t x, int32_t y, short wallnum, int32_t walldist);
-extern void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, unsigned char col);
+extern void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t  col);
 extern int inside(int32_t x, int32_t y, short sectnum);
 extern int getangle(int32_t xvect, int32_t yvect);
 extern int ksqrt(int32_t num);
@@ -242,12 +242,12 @@
 extern void flushperms(void);
 extern void rotatesprite(int32_t sx, int32_t sy, int32_t z, short a, short picnum, signed char dashade, char dapalnum, char dastat, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2);
 extern void makepalookup(int32_t palnum, char *remapbuf, signed char r, signed char g, signed char b, char dastat);
-extern void setbrightness(char dabrightness, unsigned char *dapal);
+extern void setbrightness(char dabrightness, uint8_t  *dapal);
 extern void drawmapview(int32_t dax, int32_t day, int32_t zoome, short ang);
 extern void clearview(int32_t dacol);
 extern void clearallviews(int32_t dacol);
 extern void plotpixel(int32_t x, int32_t y, char col);
-extern unsigned char getpixel(int32_t x, int32_t y);
+extern uint8_t  getpixel(int32_t x, int32_t y);
 extern void setviewtotile(short tilenume, int32_t xsiz, int32_t ysiz);
 extern void setviewback(void);
 extern void squarerotatetile(short tilenume);
--- a/Engine/src/icon.h
+++ b/Engine/src/icon.h
@@ -1,4 +1,4 @@
-unsigned char iconBMP[]=
+uint8_t  iconBMP[]=
  {
   0x42,0x4d,0x36,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x04,0x00,
   0x00,0x28,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
--- a/Engine/src/pragmas.h
+++ b/Engine/src/pragmas.h
@@ -10,13 +10,13 @@
 
 #include "platform.h" //for __int64
 
-static __inline void swapchar(unsigned char *p1, unsigned char *p2)
-{ unsigned char tmp = *p1; *p1 = *p2; *p2 = tmp; }
+static __inline void swapchar(uint8_t  *p1, uint8_t  *p2)
+{ uint8_t  tmp = *p1; *p1 = *p2; *p2 = tmp; }
 static __inline void swapshort(short *p1, short *p2)
 { short tmp = *p1; *p1 = *p2; *p2 = tmp; }
 static __inline void swaplong(int32_t *p1, int32_t *p2)
 { int32_t tmp = *p1; *p1 = *p2; *p2 = tmp; }
-static __inline void swapchar2(unsigned char *p1, unsigned char *p2, int xsiz)
+static __inline void swapchar2(uint8_t  *p1, uint8_t  *p2, int xsiz)
 {
     swapchar(p1, p2);
     swapchar(p1 + 1, p2 + xsiz);
--- a/Engine/src/sdl_driver.c
+++ b/Engine/src/sdl_driver.c
@@ -337,7 +337,7 @@
 static short mouse_buttons = 0;
 static unsigned int lastkey = 0;
 /* so we can make use of setcolor16()... - DDOI */
-static unsigned char drawpixel_color=0;
+static uint8_t  drawpixel_color=0;
 
 static unsigned int scancodes[SDLK_LAST];
 
@@ -612,7 +612,7 @@
     //	clearallviews(0L);
     //} /* if */
 
-	setbrightness((char) curbrightness, (unsigned char *) &palette[0]);
+	setbrightness((char) curbrightness, (uint8_t  *) &palette[0]);
 
 	if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); }
 } /* init_new_res_vars */
@@ -1002,7 +1002,7 @@
 } /* _joystick_button */
 
 
-unsigned char _readlastkeyhit(void)
+uint8_t  _readlastkeyhit(void)
 {
     return(lastkey);
 } /* _readlastkeyhit */
@@ -1910,7 +1910,7 @@
 } /* readmousebstatus */
 
 
-static unsigned char mirrorcolor = 0;
+static uint8_t  mirrorcolor = 0;
 
 void _updateScreenRect(int32_t x, int32_t y, int32_t w, int32_t h)
 {
@@ -1963,14 +1963,14 @@
 } /* _nextpage */
 
 
-unsigned char readpixel(int32_t offset)
+uint8_t  readpixel(int32_t offset)
 {
-    return( *((unsigned char *) offset) );
+    return( *((uint8_t  *) offset) );
 } /* readpixel */
 
-void drawpixel(int32_t offset, unsigned char pixel)
+void drawpixel(int32_t offset, uint8_t  pixel)
 {
-    *((unsigned char *) offset) = pixel;
+    *((uint8_t  *) offset) = pixel;
 } /* drawpixel */
 
 
--- a/Game/src/config.c
+++ b/Game/src/config.c
@@ -857,7 +857,7 @@
 	// FIX_00016: Build in Keyboard/mouse setup. Mouse now faster.
 	for(i=0; i<MAXMOUSEBUTTONS; i++)
 	{
-		sprintf((char*)tempbuf, "MouseButton%ld", i);
+		sprintf((char*)tempbuf, "MouseButton%d", i);
 		SCRIPT_PutString(scripthandle, "Controls", (char*)tempbuf, 
 			(MouseMapping[i]!=-1)?CONFIG_FunctionNumToName(MouseMapping[i]):"");
 	}
@@ -864,7 +864,7 @@
 
 	for (i=0;i<MAXMOUSEAXES*2;i++)
 	{
-		sprintf((char*)tempbuf, "MouseDigitalAxes%ld_%ld", i>>1, i&1);
+		sprintf((char*)tempbuf, "MouseDigitalAxes%ld_%d", i>>1, i&1);
 		SCRIPT_PutString(scripthandle, "Controls", (char*)tempbuf, 
 			(MouseDigitalAxeMapping[i>>1][i&1]!=-1)?CONFIG_FunctionNumToName(MouseDigitalAxeMapping[i>>1][i&1]):"");
 	}
--- a/Game/src/duke3d.h
+++ b/Game/src/duke3d.h
@@ -83,8 +83,8 @@
 //  FIX_00022: Automatically recognize the shareware grp (v1.3) + full version (1.3d) +
 //             atomic (1.4/1.5 grp) and the con files version (either 1.3 or 1.4) (JonoF's idea)
 
-extern unsigned char conVersion;
-extern unsigned char grpVersion;
+extern uint8_t  conVersion;
+extern uint8_t  grpVersion;
 extern int32_t groupefil_crc32[MAXGROUPFILES];
 
 #define RANCID_ID 1
@@ -509,7 +509,7 @@
 	char fakeplayer;
 };
 
-extern unsigned char tempbuf[2048], packbuf[576];
+extern uint8_t  tempbuf[2048], packbuf[576];
 
 extern int32_t gc,max_player_health,max_armour_amount,max_ammo_amount[MAX_WEAPONS];
 
@@ -684,7 +684,7 @@
 
 extern int32_t myaimmode, myaimstat, omyaimstat;
 
-extern unsigned char nHostForceDisableAutoaim;
+extern uint8_t  nHostForceDisableAutoaim;
 
 #endif  // include-once header.
 
--- a/Game/src/dukeunix.h
+++ b/Game/src/dukeunix.h
@@ -49,10 +49,10 @@
 
 struct dosdate_t
 {
-    unsigned char day;
-    unsigned char month;
+    uint8_t  day;
+    uint8_t  month;
     unsigned int year;
-    unsigned char dayofweek;
+    uint8_t  dayofweek;
 };
 
 void _dos_getdate(struct dosdate_t *date);
@@ -65,7 +65,7 @@
 #define max(x, y) ((x) > (y) ? (x) : (y))
 #endif
 
-#define FP_OFF(x) ((long) (x))
+#define FP_OFF(x) ((int32_t) (x))
 
 #ifndef strcmpi
 #define strcmpi(x, y) strcasecmp(x, y)
--- a/Game/src/dukewin.h
+++ b/Game/src/dukewin.h
@@ -38,10 +38,10 @@
 
 struct dosdate_t
 {
-    unsigned char day;
-    unsigned char month;
+    uint8_t  day;
+    uint8_t  month;
     unsigned int year;
-    unsigned char dayofweek;
+    uint8_t  dayofweek;
 };
 
 void _dos_getdate(struct dosdate_t *date);
@@ -57,7 +57,7 @@
 #ifdef FP_OFF
 #undef FP_OFF
 #endif
-#define FP_OFF(x) ((long) (x))
+#define FP_OFF(x) ((int32_t) (x))
 
 // 64 megs should be enough for anybody.  :)  --ryan.
 #define Z_AvailHeap() ((64 * 1024) * 1024)
--- a/Game/src/dummy_audiolib.c
+++ b/Game/src/dummy_audiolib.c
@@ -132,7 +132,7 @@
 	return 0;
 }
 
-int MUSIC_PlaySong(unsigned char *song, int loopflag)
+int MUSIC_PlaySong(uint8_t  *song, int loopflag)
 {
 	return 0;
 }
@@ -185,7 +185,7 @@
 {
 }
 
-void MUSIC_RegisterTimbreBank(unsigned char *timbres)
+void MUSIC_RegisterTimbreBank(uint8_t  *timbres)
 {
 }
 
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -77,7 +77,7 @@
 char playerswhenstarted;
 char qe,cp;
 
-unsigned char nHostForceDisableAutoaim = 0;
+uint8_t  nHostForceDisableAutoaim = 0;
 
 // Game play speed
 int g_iTickRate = 120;
@@ -422,7 +422,7 @@
 	return(id);
 }
 
-char *grpVersion2char(unsigned char grp_to_identify)
+char *grpVersion2char(uint8_t  grp_to_identify)
 {
 	char *id;
 
--- a/Game/src/gamedef.c
+++ b/Game/src/gamedef.c
@@ -757,7 +757,7 @@
 
 				kread(fp,(char *)textptr,j);
 				kclose(fp);
-				ud.conCRC[0] = crc32_update((unsigned char *)textptr, j, ud.conCRC[0]);
+				ud.conCRC[0] = crc32_update((uint8_t  *)textptr, j, ud.conCRC[0]);
 
 				do
 					done = parsecommand(readfromGRP);
@@ -1574,7 +1574,7 @@
         kread(fp,(char *)textptr,fs);
         kclose(fp);
 		ud.conCRC[0]=0;
-		ud.conCRC[0] = crc32_update((unsigned char *)textptr, fs, ud.conCRC[0]);
+		ud.conCRC[0] = crc32_update((uint8_t  *)textptr, fs, ud.conCRC[0]);
     }
 
 #ifdef PLATFORM_UNIX
--- a/Game/src/global.c
+++ b/Game/src/global.c
@@ -46,8 +46,8 @@
 		{ 0,							"HACK/UNKNOWN  ", 0}
 	};
 
-unsigned char conVersion = 13;
-unsigned char grpVersion = 0;
+uint8_t  conVersion = 13;
+uint8_t  grpVersion = 0;
 
 // FIX_00015: Backward compliance with older demos (down to demos v27, 28, 116 and 117 only)
 
@@ -91,7 +91,7 @@
 
 char fta_quotes[NUMOFFIRSTTIMEACTIVE][64];
 
-unsigned char tempbuf[2048], packbuf[576];
+uint8_t  tempbuf[2048], packbuf[576];
 
 char buf[80];
 
--- a/Game/src/midi/databuf.h
+++ b/Game/src/midi/databuf.h
@@ -27,7 +27,7 @@
 #include <fstream>
 #include <iomanip>
 
-typedef unsigned char uint8;
+typedef uint8_t  uint8;
 typedef unsigned short uint16;
 typedef uint32_t uint32;
 
@@ -74,8 +74,8 @@
 protected:
 	/* const solely so that no-one accidentally modifies it.
 		data is being passed 'non-const' anyway */
-	const unsigned char *buf;
-	unsigned char *buf_ptr;
+	const uint8_t  *buf;
+	uint8_t  *buf_ptr;
 	sint32 size;
 public:
 	BufferDataSource(char *data, unsigned int len)
@@ -82,7 +82,7 @@
 	{
 		// data can be NULL if len is also 0
 //		assert(data!=0 || len==0);
-		buf = buf_ptr = reinterpret_cast<unsigned char*>(data);
+		buf = buf_ptr = reinterpret_cast<uint8_t *>(data);
 		size = len;
 	};
 	
@@ -90,7 +90,7 @@
 	{
 		// data can be NULL if len is also 0
 		//assert(data!=0 || len==0);
-		buf = buf_ptr = reinterpret_cast<unsigned char*>(data);
+		buf = buf_ptr = reinterpret_cast<uint8_t *>(data);
 		size = len;
 	};
 	
@@ -98,54 +98,54 @@
 	
 	virtual unsigned int read1() 
 	{ 
-		unsigned char b0;
-		b0 = static_cast<unsigned char>(*buf_ptr++);
+		uint8_t  b0;
+		b0 = static_cast<uint8_t >(*buf_ptr++);
 		return (b0);
 	};
 	
 	virtual uint16 read2()
 	{
-		unsigned char b0, b1;
-		b0 = static_cast<unsigned char>(*buf_ptr++);
-		b1 = static_cast<unsigned char>(*buf_ptr++);
+		uint8_t  b0, b1;
+		b0 = static_cast<uint8_t >(*buf_ptr++);
+		b1 = static_cast<uint8_t >(*buf_ptr++);
 		return (b0 | (b1 << 8));
 	};
 	
 	virtual uint16 read2high()
 	{
-		unsigned char b0, b1;
-		b1 = static_cast<unsigned char>(*buf_ptr++);
-		b0 = static_cast<unsigned char>(*buf_ptr++);
+		uint8_t  b0, b1;
+		b1 = static_cast<uint8_t >(*buf_ptr++);
+		b0 = static_cast<uint8_t >(*buf_ptr++);
 		return (b0 | (b1 << 8));
 	};
 	
 	virtual uint32 read4()
 	{
-		unsigned char b0, b1, b2, b3;
-		b0 = static_cast<unsigned char>(*buf_ptr++);
-		b1 = static_cast<unsigned char>(*buf_ptr++);
-		b2 = static_cast<unsigned char>(*buf_ptr++);
-		b3 = static_cast<unsigned char>(*buf_ptr++);
+		uint8_t  b0, b1, b2, b3;
+		b0 = static_cast<uint8_t >(*buf_ptr++);
+		b1 = static_cast<uint8_t >(*buf_ptr++);
+		b2 = static_cast<uint8_t >(*buf_ptr++);
+		b3 = static_cast<uint8_t >(*buf_ptr++);
 		return (b0 | (b1<<8) | (b2<<16) | (b3<<24));
 	};
 	
 	virtual uint32 read4high()
 	{
-		unsigned char b0, b1, b2, b3;
-		b3 = static_cast<unsigned char>(*buf_ptr++);
-		b2 = static_cast<unsigned char>(*buf_ptr++);
-		b1 = static_cast<unsigned char>(*buf_ptr++);
-		b0 = static_cast<unsigned char>(*buf_ptr++);
+		uint8_t  b0, b1, b2, b3;
+		b3 = static_cast<uint8_t >(*buf_ptr++);
+		b2 = static_cast<uint8_t >(*buf_ptr++);
+		b1 = static_cast<uint8_t >(*buf_ptr++);
+		b0 = static_cast<uint8_t >(*buf_ptr++);
 		return (b0 | (b1<<8) | (b2<<16) | (b3<<24));
 	};
 	
 	virtual float readf()
 	{
-		unsigned char b0, b1, b2, b3;
-		b0 = static_cast<unsigned char>(*buf_ptr++);
-		b1 = static_cast<unsigned char>(*buf_ptr++);
-		b2 = static_cast<unsigned char>(*buf_ptr++);
-		b3 = static_cast<unsigned char>(*buf_ptr++);
+		uint8_t  b0, b1, b2, b3;
+		b0 = static_cast<uint8_t >(*buf_ptr++);
+		b1 = static_cast<uint8_t >(*buf_ptr++);
+		b2 = static_cast<uint8_t >(*buf_ptr++);
+		b3 = static_cast<uint8_t >(*buf_ptr++);
 		uint_float	uif;
 		uif.i = (b0 | (b1<<8) | (b2<<16) | (b3<<24));
 		return uif.f;
@@ -206,7 +206,7 @@
 		buf_ptr += len;
 	};
 	
-	virtual void seek(unsigned int pos) { buf_ptr = const_cast<unsigned char *>(buf)+pos; };
+	virtual void seek(unsigned int pos) { buf_ptr = const_cast<uint8_t  *>(buf)+pos; };
 	
 	virtual void skip(int pos) { buf_ptr += pos; };
 	
@@ -214,7 +214,7 @@
 	
 	virtual unsigned int getPos() { return (buf_ptr-buf); };
 	
-	unsigned char *getPtr() { return buf_ptr; };
+	uint8_t  *getPtr() { return buf_ptr; };
 };
 
 
--- a/Game/src/midi/win_midiout.cpp
+++ b/Game/src/midi/win_midiout.cpp
@@ -65,14 +65,14 @@
 #define W32MO_THREAD_COM_EXIT			-1
 
 const unsigned short Windows_MidiOut::centre_value = 0x2000;
-const unsigned char Windows_MidiOut::fine_value = centre_value & 127;
-const unsigned char Windows_MidiOut::coarse_value = centre_value >> 7;
+const uint8_t  Windows_MidiOut::fine_value = centre_value & 127;
+const uint8_t  Windows_MidiOut::coarse_value = centre_value >> 7;
 const unsigned short Windows_MidiOut::combined_value = (coarse_value << 8) | fine_value;
 
 #define MUSIC_STATUS_IDLE    0
 #define MUSIC_STATUS_PLAYING 1
 
-unsigned char nMusicState = MUSIC_STATUS_IDLE;
+uint8_t  nMusicState = MUSIC_STATUS_IDLE;
 
 Mix_Music *music;
 
@@ -1053,7 +1053,7 @@
 } // MUSIC_StopSong
 
 
-int MUSIC_PlaySong(unsigned char *song, int loopflag)
+int MUSIC_PlaySong(uint8_t  *song, int loopflag)
 {
     //SDL_RWops *rw;
 
@@ -1206,7 +1206,7 @@
 
 		kread( fp, MusicPtr, l);
 		kclose( fp );
-		MUSIC_PlaySong( (unsigned char*)MusicPtr, MUSIC_LoopSong );
+		MUSIC_PlaySong( (uint8_t *)MusicPtr, MUSIC_LoopSong );
 	}
 }
 
@@ -1280,7 +1280,7 @@
 } // MUSIC_RerouteMidiChannel
 
 
-void MUSIC_RegisterTimbreBank(unsigned char *timbres)
+void MUSIC_RegisterTimbreBank(uint8_t  *timbres)
 {
     musdebug("STUB ... MUSIC_RegisterTimbreBank().\n");
 } // MUSIC_RegisterTimbreBank
--- a/Game/src/midi/win_midiout.h
+++ b/Game/src/midi/win_midiout.h
@@ -74,8 +74,8 @@
 	};
 
 	static const unsigned short	centre_value;
-	static const unsigned char	fine_value;
-	static const unsigned char	coarse_value;
+	static const uint8_t 	fine_value;
+	static const uint8_t 	coarse_value;
 	static const unsigned short	combined_value;
 
 	signed int	dev_num;
--- a/Game/src/midi/xmidi.cpp
+++ b/Game/src/midi/xmidi.cpp
@@ -882,7 +882,7 @@
 	}
 
 	//std::cout << "Max Polyphony: " << notes.GetMaxPolyphony() << std::endl;
-	static const unsigned char tempo_buf[5] = { 0x51, 0x03, 0x07, 0xA1, 0x20 };
+	static const uint8_t  tempo_buf[5] = { 0x51, 0x03, 0x07, 0xA1, 0x20 };
 	BufferDataSource ds((char *)tempo_buf, 5);
 	current = list;
 	ConvertSystemMessage (0, 0xFF,&ds);
@@ -901,7 +901,7 @@
 // ConvertSystemMessage is used for SysEx events and Meta events
 // ConvertEvent is used for everything else
 
-int XMIDI::ConvertEvent (const int time, unsigned char status, DataSource *source, const int size, first_state &fs)
+int XMIDI::ConvertEvent (const int time, uint8_t  status, DataSource *source, const int size, first_state &fs)
 {
 	int	data;
 
@@ -1030,7 +1030,7 @@
 	return 2;
 }
 
-int XMIDI::ConvertNote (const int time, const unsigned char status, DataSource *source, const int size)
+int XMIDI::ConvertNote (const int time, const uint8_t  status, DataSource *source, const int size)
 {
 	uint32	delta = 0;
 	int	data;
@@ -1071,7 +1071,7 @@
 }
 
 // Simple routine to convert system messages
-int XMIDI::ConvertSystemMessage (const int time, const unsigned char status, DataSource *source)
+int XMIDI::ConvertSystemMessage (const int time, const uint8_t  status, DataSource *source)
 {
 	int i=0;
 	
@@ -1093,7 +1093,7 @@
 		return i;
 	}
 	
-	current->buffer = Malloc<unsigned char>(current->len);
+	current->buffer = Malloc<uint8_t >(current->len);
 
 	source->read (reinterpret_cast<char *>(current->buffer), current->len);
 
@@ -1265,7 +1265,7 @@
 		ApplyFirstState(fs, chan_mask);
 
 		// Add tempo
-		static const unsigned char tempo_buf[5] = { 0x51, 0x03, 0x07, 0xA1, 0x20 };
+		static const uint8_t  tempo_buf[5] = { 0x51, 0x03, 0x07, 0xA1, 0x20 };
 		BufferDataSource ds((char *)tempo_buf, 5);
 		current = list;
 		ConvertSystemMessage (0, 0xFF,&ds);
@@ -1649,7 +1649,7 @@
 	int lasttime = 0;
 	midi_event	*event;
 	uint32	delta;
-	unsigned char	last_status = 0;
+	uint8_t 	last_status = 0;
 	uint32 	i = 8;
 	uint32 	j;
 	uint32	size_pos=0;
--- a/Game/src/midi/xmidi.h
+++ b/Game/src/midi/xmidi.h
@@ -74,12 +74,12 @@
 struct midi_event
 {
 	int				time;
-	unsigned char	status;
+	uint8_t 	status;
 
-	unsigned char	data[2];
+	uint8_t 	data[2];
 
 	uint32			len;		// Length of SysEx Data
-	unsigned char	*buffer;	// SysEx Data
+	uint8_t 	*buffer;	// SysEx Data
 	int				duration;	// Duration of note (120 Hz)
 	midi_event		*next_note;	// The next note on the stack
 	uint32			note_time;	// Time note stops playing (6000th of second)
@@ -292,9 +292,9 @@
 	void AdjustTimings(uint32 ppqn);	// This is used by Midi's ONLY!
 	void ApplyFirstState(first_state &fs, int chan_mask);
 
-	int ConvertNote (const int time, const unsigned char status, DataSource *source, const int size);
-	int ConvertEvent (const int time, unsigned char status, DataSource *source, const int size, first_state& fs);
-	int ConvertSystemMessage (const int time, const unsigned char status, DataSource *source);
+	int ConvertNote (const int time, const uint8_t  status, DataSource *source, const int size);
+	int ConvertEvent (const int time, uint8_t  status, DataSource *source, const int size, first_state& fs);
+	int ConvertSystemMessage (const int time, const uint8_t  status, DataSource *source);
 
 	int ConvertFiletoList (DataSource *source, const bool is_xmi, first_state& fs);
 
--- a/Game/src/player.c
+++ b/Game/src/player.c
@@ -314,7 +314,7 @@
 {
     short sect, hitsect, hitspr, hitwall, l, sa, p, j, k, scount;
     int32_t sx, sy, sz, vel, zvel, hitx, hity, hitz, x, oldzvel, dal;
-    unsigned char sizx,sizy;
+    uint8_t  sizx,sizy;
     spritetype *s;
 
     s = &sprite[i];
--- a/Game/src/sounds.c
+++ b/Game/src/sounds.c
@@ -305,7 +305,7 @@
 
     Sound[num].lock = 200;
 
-    allocache((int32_t *)&Sound[num].ptr,l,(unsigned char *)&Sound[num].lock);
+    allocache((int32_t *)&Sound[num].ptr,l,(uint8_t  *)&Sound[num].lock);
     kread( fp, Sound[num].ptr , l);
     kclose( fp );
     return 1;
--- a/Game/src/types.h
+++ b/Game/src/types.h
@@ -40,7 +40,7 @@
 //
 //***************************************************************************
 
-typedef unsigned char           uint8;
+typedef uint8_t            uint8;
 typedef uint8                   byte;
 typedef signed char             int8;