Index: ram/ptdkey.c
===================================================================
--- ram/ptdkey.c	(revision 7ecfb7b804af212fdc1cf5f5eebff4b5072b391b)
+++ ram/ptdkey.c	(revision 3ac8e1ba43940eb45fc50206a4aaaedeec234cf7)
@@ -267,5 +267,5 @@
 
 		if (spec EQ PA_OSC)
-			ptedata = ptedat1 + 4;
+			ptedata = (int16_t)ptedat1 + 4;
 		else
 			ptedata = dtabl9[ptedat1];
@@ -394,5 +394,5 @@
 
 						sprintf(buf2, "%02d", 1 + chan);
-						buf[0] = key + '0';
+						buf[0] = (int8_t)(key + '0');
 						UpdVid(7, n ? 25 : 12, buf2, PTDATR);
 					}
@@ -401,11 +401,11 @@
 
 					if (n)
-						ptestm = (ptestm & 0xE7FF) | (port << 11);
+						ptestm = (ptestm & 0xE7FF) | ((uint16_t)port << 11);
 					else
-						ptedef = (ptestm & 0xE7FF) | (port << 11);
+						ptedef = (ptestm & 0xE7FF) | ((uint16_t)port << 11);
 
 				} else {
 
-					buf[0] = key + '0';
+					buf[0] = (int8_t)(key + '0');
 				}
 
@@ -436,6 +436,6 @@
 			if (inrange(stccol, dsdecol[1][n][0], dsdecol[1][n][1])) {
 
-				ptdebuf[stccol] = key + '0';
-				buf[0] = key + '0';
+				ptdebuf[stccol] = (int8_t)(key + '0');
+				buf[0] = (int8_t)(key + '0');
 				buf[1] = '\0';
 
@@ -462,6 +462,6 @@
 					return;
 
-				ptdebuf[stccol] = key + '0';
-				buf[0] = key + '0';
+				ptdebuf[stccol] = (int8_t)(key + '0');
+				buf[0] = (int8_t)(key + '0');
 				buf[1] = '\0';
 
@@ -526,9 +526,9 @@
 							buf[0] = 'L';
 						else
-							buf[0] = key + '0';
+							buf[0] = (int8_t)(key + '0');
 
 					} else {
 
-						buf[0] = key + '0';
+						buf[0] = (int8_t)(key + '0');
 					}
 
@@ -553,6 +553,6 @@
 				if (inrange(stccol, 36, 37)) {
 
-					ptdebuf[stccol] = key + '0';
-					buf[0] = key + '0';
+					ptdebuf[stccol] = (int8_t)(key + '0');
+					buf[0] = (int8_t)(key + '0');
 					buf[1] = '\0';
 
@@ -574,6 +574,6 @@
 						return;
 
-					ptdebuf[stccol] = key + '0';
-					buf[0] = key + '0';
+					ptdebuf[stccol] = (int8_t)(key + '0');
+					buf[0] = (int8_t)(key + '0');
 					buf[1] = '\0';
 
@@ -591,6 +591,6 @@
 						return;
 
-					ptdebuf[stccol] = key + 'A';
-					buf[0] = key + 'A';
+					ptdebuf[stccol] = (int8_t)(key + 'A');
+					buf[0] = (int8_t)(key + 'A');
 					buf[1] = '\0';
 
@@ -605,6 +605,6 @@
 				if (inrange(stccol, 32, 33)) {
 
-					ptdebuf[stccol] = key + '0';
-					buf[0] = key + '0';
+					ptdebuf[stccol] = (int8_t)(key + '0');
+					buf[0] = (int8_t)(key + '0');
 					buf[1] = '\0';
 
@@ -631,6 +631,6 @@
 						return;
 
-					ptdebuf[stccol] = key + '0';
-					buf[0] = key + '0';
+					ptdebuf[stccol] = (int8_t)(key + '0');
+					buf[0] = (int8_t)(key + '0');
 					buf[1] = '\0';
 
@@ -648,6 +648,6 @@
 						return;
 
-					ptdebuf[stccol] = key + '0';
-					buf[0] = key + '0';
+					ptdebuf[stccol] = (int8_t)(key + '0');
+					buf[0] = (int8_t)(key + '0');
 					buf[1] = '\0';
 
@@ -664,5 +664,5 @@
 				if (inrange(stccol, 39, 40)) {
 
-					vg = (ptesuba >> 8) & 0x00FF;
+					vg = (int16_t)(ptesuba >> 8) & 0x00FF;
 
 					if (stccol EQ 39) {
@@ -682,5 +682,5 @@
 
 							ptesuba = (ptesuba & 0x00FF) |
-								  (vg << 8);
+								  ((uint16_t)vg << 8);
 
 						} else {
@@ -707,9 +707,9 @@
 
 						ptesuba = (ptesuba & 0x00FF) |
-							  (vg << 8);
+							  ((uint16_t)vg << 8);
 					}
 
-					ptdebuf[stccol] = val;
-					buf[0] = val;
+					ptdebuf[stccol] = (int8_t)val;
+					buf[0] = (int8_t)val;
 					buf[1] = '\0';
 
@@ -752,5 +752,5 @@
 
 				if ((key EQ 0) OR (key EQ 1))
-					buf[0] = key + '0';
+					buf[0] = (int8_t)(key + '0');
 				else
 					return;
@@ -761,5 +761,5 @@
 			case 46:	/* 0..9 */
 
-				buf[0] = key + '0';
+				buf[0] = (int8_t)(key + '0');
 				break;
 
@@ -790,5 +790,5 @@
 				return;
 
-			buf[0] = key + '0';
+			buf[0] = (int8_t)(key + '0');
 			buf[1] = '\0';
 			ptdebuf[stccol] = buf[0];
@@ -859,5 +859,5 @@
 			case 46:
 
-				buf[0] = key + '0';
+				buf[0] = (int8_t)(key + '0');
 				break;
 
@@ -898,9 +898,9 @@
 					return;
 				else
-					buf[0] = key + '0';
+					buf[0] = (int8_t)(key + '0');
 
 			} else {
 
-				buf[0] = key + '0';
+				buf[0] = (int8_t)(key + '0');
 			}
 
@@ -924,5 +924,5 @@
 			case 44:
 
-				buf[0] = key +'0';
+				buf[0] = (int8_t)(key +'0');
 				break;
 
@@ -963,5 +963,5 @@
 			case 45:
 
-				buf[0] = key + '0';
+				buf[0] = (int8_t)(key + '0');
 				break;
 
@@ -996,5 +996,5 @@
 					return;
 
-				buf[0] = key + 'A';
+				buf[0] = (int8_t)(key + 'A');
 				break;
 
@@ -1016,5 +1016,5 @@
 			case 46:
 
-				buf[0] = key + '0';
+				buf[0] = (int8_t)(key + '0');
 				break;
 			}
@@ -1132,5 +1132,5 @@
 			case 44:
 
-				buf[0] = key + '0';
+				buf[0] = (int8_t)(key + '0');
 				break;
 
@@ -1157,5 +1157,5 @@
 				return;
 
-			buf[0] = key + '0';
+			buf[0] = (int8_t)(key + '0');
 			ptdebuf[stccol] = buf[0];
 			buf[1] = '\0';
@@ -1178,5 +1178,5 @@
 				return;
 
-			buf[0] = key + '0';
+			buf[0] = (int8_t)(key + '0');
 			buf[1] = '\0';
 			ptdebuf[stccol] = buf[0];
@@ -1200,5 +1200,5 @@
 				return;
 
-			buf[0] = key + '0';
+			buf[0] = (int8_t)(key + '0');
 			buf[1] = '\0';
 			ptdebuf[stccol] = buf[0];
@@ -1221,5 +1221,5 @@
 				return;
 
-			buf[0] = key + '0';
+			buf[0] = (int8_t)(key + '0');
 			buf[1] = '\0';
 			ptdebuf[stccol] = buf[0];
@@ -1242,5 +1242,5 @@
 				return;
 
-			buf[0] = key + '0';
+			buf[0] = (int8_t)(key + '0');
 			buf[1] = '\0';
 			ptdebuf[stccol] = buf[0];
@@ -1260,5 +1260,5 @@
 				return;
 
-			buf[0] = key + '0';
+			buf[0] = (int8_t)(key + '0');
 			buf[1] = '\0';
 			ptdebuf[stccol] = buf[0];
