Index: ram/ptselbx.c
===================================================================
--- ram/ptselbx.c	(revision 3ac8e1ba43940eb45fc50206a4aaaedeec234cf7)
+++ ram/ptselbx.c	(revision 572daa7c12f5c9498343313d6d5350492c787d9e)
@@ -111,5 +111,5 @@
 int16_t	fpuetab[]  = {      11,       1,          2,       3,       9 };
 
-int16_t	dfsttab[] = { 0x0000, 0x8000, 0x1100, 0x1180 };
+uint16_t	dfsttab[] = { 0x0000, 0x8000, 0x1100, 0x1180 };
 
 int16_t	defcols[] = {  2,  6,  7,  8};	/* def data entry columns */
@@ -459,5 +459,5 @@
 		}
 
-		stim = ltemp - 1;
+		stim = (int16_t)(ltemp - 1);
 
 		if (port EQ 2) {
@@ -480,11 +480,13 @@
 			}
 
-			chan = ltemp - 1;
+			chan = (int16_t)(ltemp - 1);
 		}
 
 		if (n)
-			ptestm = (ptestm & 0x8000) | (port << 11) | (chan << 7) | stim;
+			ptestm = (ptestm & 0x8000) | ((uint16_t)port << 11) |
+					((uint16_t)chan << 7) | (uint16_t)stim;
 		else
-			ptedef = (ptedef & 0x8000) | (port << 11) | (chan << 7) | stim;
+			ptedef = (ptedef & 0x8000) | ((uint16_t)port << 11) |
+					((uint16_t)chan << 7) | (uint16_t)stim;
 
 	} else if ((port EQ 2) AND (chan EQ 2)) {	/* Trig */
@@ -503,10 +505,10 @@
 		}
 
-		stim = ltemp - 1;
+		stim = (int16_t)(ltemp - 1);
 
 		if (n)
-			ptestm = 0x1100 | stim;
+			ptestm = 0x1100 | (uint16_t)stim;
 		else
-			ptedef = 0x1100 | stim;
+			ptedef = 0x1100 | (uint16_t)stim;
 
 	} else if ((port EQ 2) AND (chan EQ 3)) {	/* Pulse */
@@ -521,10 +523,10 @@
 		}
 
-		stim = ltemp - 1;
+		stim = (int16_t)(ltemp - 1);
 
 		if (n)
-			ptestm = 0x1180 | stim;
+			ptestm = 0x1180 | (uint16_t)stim;
 		else
-			ptedef = 0x1180 | stim;
+			ptedef = 0x1180 | (uint16_t)stim;
 
 	} else {
@@ -585,5 +587,5 @@
 		}
 
-		stim  = ltemp - 1;
+		stim  = (int16_t)(ltemp - 1);
 		ltemp = 0;
 		left  = 36;
@@ -599,5 +601,5 @@
 		}
 
-		chan = ltemp - 1;
+		chan = (int16_t)(ltemp - 1);
 
 		if (ptdebuf[34] EQ 'L') {
@@ -611,5 +613,5 @@
 		}
 
-		ptesuba = (port << 11) | (chan << 7) | stim;
+		ptesuba = ((uint16_t)port << 11) | ((uint16_t)chan << 7) | (uint16_t)stim;
 		break;
 
@@ -629,16 +631,16 @@
 		}
 
-		stim    = ltemp - 1;
-		ptesuba = 0x1100 | stim;
+		stim    = (int16_t)(ltemp - 1);
+		ptesuba = 0x1100 | (uint16_t)stim;
 		break;
 
 	case 2:		/* pulse */
 
-		ptesuba = ptdebuf[34] - '1';
+		ptesuba = (uint16_t)(ptdebuf[34] - '1');
 		break;
 
 	case 3:		/* led */
 
-		ptesuba = ptdebuf[32] - 'A';
+		ptesuba = (uint16_t)(ptdebuf[32] - 'A');
 		break;
 
@@ -658,5 +660,5 @@
 		}
 
-		ptesuba = ltemp - 1;
+		ptesuba = (uint16_t)(ltemp - 1);
 		break;
 
@@ -683,10 +685,10 @@
 
 		--stim;
-		ptesuba = stim << 8;
+		ptesuba = (uint16_t)stim << 8;
 		break;
 
 	case 8:		/* vlt */
 
-		ptesuba = ptdebuf[32] - '0';
+		ptesuba = (uint16_t)(ptdebuf[32] - '0');
 		break;
 
@@ -706,5 +708,5 @@
 
 		--stim;
-		ptesuba = (stim << 8) | (ptdebuf[32] - '0');
+		ptesuba = ((uint16_t)stim << 8) | (uint16_t)(ptdebuf[32] - '0');
 		break;
 
@@ -895,5 +897,5 @@
 				}
 
-				ptedat2 = i;
+				ptedat2 = (uint16_t)i;
 				epatch();	/* enter -- multiplier */
 				return(SUCCESS);
@@ -938,5 +940,5 @@
 					ltemp = -ltemp;
 
-				ptedat2 = ltemp << 5;
+				ptedat2 = (uint16_t)(ltemp << 5);
 				epatch();	/* enter -- value */
 				return(SUCCESS);
@@ -959,5 +961,5 @@
 					ltemp = -ltemp;
 
-				ptedat2 = ltemp << 1;
+				ptedat2 = (uint16_t)(ltemp << 1);
 				epatch();	/* enter -- interval */
 				return(SUCCESS);
@@ -965,6 +967,6 @@
 			case 5:		/* ratio -- 9/9 */
 
-				ptedat2 = ndvals[ptdebuf[42] - '0'] -
-					  ndvals[ptdebuf[44] - '0'];
+				ptedat2 = (uint16_t)(ndvals[ptdebuf[42] - '0'] -
+						ndvals[ptdebuf[44] - '0']);
 
 				epatch();	/* enter -- ratio */
@@ -983,5 +985,5 @@
 				}
 
-				ptedat2 = ltemp << 1;
+				ptedat2 = (uint16_t)(ltemp << 1);
 				epatch();	/* enter -- frequency */
 				return(SUCCESS);
@@ -997,5 +999,5 @@
 				}
 
-				ptedat2 = cents;
+				ptedat2 = (uint16_t)cents;
 				epatch();	/* enter - pitch */
 				return(SUCCESS);
@@ -1038,5 +1040,5 @@
 				}
 
-				ptedat2 = ltemp;
+				ptedat2 = (uint16_t)ltemp;
 				epatch();	/* enter -- register | value */
 				return(SUCCESS);
@@ -1049,5 +1051,5 @@
 					ltemp = (ltemp * 10) + (ptdebuf[i] - '0');
 
-				ptedat1 = ltemp;
+				ptedat1 = (uint16_t)ltemp;
 				epatch();	/* enter  -- sequence line */
 				return(SUCCESS);
@@ -1062,5 +1064,5 @@
 						ltemp = (ltemp << 2) | (ptdebuf[i] - '0');
 
-					ptedat1 = ltemp << 8;
+					ptedat1 = (uint16_t)(ltemp << 8);
 
 				} else {
@@ -1069,5 +1071,5 @@
 						ltemp = (ltemp << 2) | (ptdebuf[i] - '0');
 
-					ptedat1 = ltemp << 10;
+					ptedat1 = (uint16_t)(ltemp << 10);
 				}
 
@@ -1087,5 +1089,5 @@
 				}
 
-				ptedat1 = ltemp;
+				ptedat1 = (uint16_t)ltemp;
 				epatch();	/* enter -- instrument number */
 				return(SUCCESS);
@@ -1102,5 +1104,5 @@
 				}
 
-				ptedat1 = ltemp;
+				ptedat1 = (uint16_t)ltemp;
 				epatch();	/* enter -- waveshape number */
 				return(SUCCESS);
@@ -1117,5 +1119,5 @@
 				}
 
-				ptedat1 = ltemp;
+				ptedat1 = (uint16_t)ltemp;
 				epatch();	/* enter -- configuration number */
 				return(SUCCESS);
@@ -1123,5 +1125,5 @@
 			case 18:	/* tuning table number */
 
-				ptedat1 = ptdebuf[42] - '0';
+				ptedat1 = (uint16_t)(ptdebuf[42] - '0');
 				epatch();	/* enter -- tuning table number */
 				return(SUCCESS);
@@ -1210,5 +1212,5 @@
 				ptbflag = TRUE;
 
-				ptedat2 = datasrc[box - 36];
+				ptedat2 = (uint16_t)datasrc[box - 36];
 
 				strcpy(&ptdebuf[42], smdata[ptedat2]);
@@ -1235,5 +1237,5 @@
 				ptedest = destfmt[i];
 				ptedata = datafmt[i];
-				ptespec = ptt;
+				ptespec = (uint16_t)ptt;
 				ptesuba = 0x0000;
 				ptedat1 = 0x0000;
@@ -1243,8 +1245,8 @@
 
 					if (ptd & 1)
-						ptedat1 = desdat1[i];
+						ptedat1 = (uint16_t)desdat1[i];
 
 					if (ptd & 2)
-						ptedat2 = desdat2[i];
+						ptedat2 = (uint16_t)desdat2[i];
 				}
 
@@ -1271,6 +1273,6 @@
 				ptbflag = TRUE;
 
-				ptedat1 = omtabl[i];
-				ptedat2 = omdtab[i];
+				ptedat1 = (uint16_t)omtabl[i];
+				ptedat2 = (uint16_t)omdtab[i];
 
 				ptedata = omftab[i];
@@ -1304,6 +1306,6 @@
 			ptbflag = TRUE;
 
-			ptedat1 = i;
-			ptedat2 = fpudtab[i];
+			ptedat1 = (uint16_t)i;
+			ptedat2 = (uint16_t)fpudtab[i];
 
 			ptedata = fpuetab[i];
