Index: ram/tundsp.c
===================================================================
--- ram/tundsp.c	(revision 05806159f2593192d6ed2fca28358480a2383c67)
+++ ram/tundsp.c	(revision 8618599ab825088c720c202c6e50a52572282c0f)
@@ -21,32 +21,32 @@
 #define	TUN_VAL	100		/* default value for tunval in cents */
 
-extern	short	stcrow, stccol, cxval, cyval;
-
-extern	short	curtun;		/* current tuning table */
-extern	short	submenu;	/* submenu cursor switch */
-extern	short	tunmod;		/* tuning table modified */
-extern	short	tunval;		/* tuning table generator value */
-extern	short	ttcmdsv;	/* tuning table editing state variable */
-extern	short	tdnamsw;	/* tuning editor displaying typewriter */
-
-extern	short	oldtun[];	/* previous tuning table for undo */
-extern	short	tuntab[];	/* current tuning table */
-extern	short	tunlib[][128];	/* tuning table library */
-
-extern	short	panlkey[];	/* local key tunings */
-extern	short	lclkmap[];	/* local key to MIDI key map */
-
-extern	char	tuncurn[];	/* current tuning table name */
-extern	char	tunname[][32];	/* tuning table names */
-extern	char	sfdsp[];
-
-extern	unsigned	*obj0, *obj2;
-
-extern	char	bfs[];
-extern	char	*tdbxlb[];
-
-extern	short	tdbox[][8];
-
-extern	unsigned	*tunob;
+extern	int16_t	stcrow, stccol, cxval, cyval;
+
+extern	int16_t	curtun;		/* current tuning table */
+extern	int16_t	submenu;	/* submenu cursor switch */
+extern	int16_t	tunmod;		/* tuning table modified */
+extern	int16_t	tunval;		/* tuning table generator value */
+extern	int16_t	ttcmdsv;	/* tuning table editing state variable */
+extern	int16_t	tdnamsw;	/* tuning editor displaying typewriter */
+
+extern	int16_t	oldtun[];	/* previous tuning table for undo */
+extern	int16_t	tuntab[];	/* current tuning table */
+extern	int16_t	tunlib[][128];	/* tuning table library */
+
+extern	int16_t	panlkey[];	/* local key tunings */
+extern	int16_t	lclkmap[];	/* local key to MIDI key map */
+
+extern	int8_t	tuncurn[];	/* current tuning table name */
+extern	int8_t	tunname[][32];	/* tuning table names */
+extern	int8_t	sfdsp[];
+
+extern	uint16_t	*obj0, *obj2;
+
+extern	int8_t	bfs[];
+extern	int8_t	*tdbxlb[];
+
+extern	int16_t	tdbox[][8];
+
+extern	uint16_t	*tunob;
 
 extern	struct	octent	*tdoct;
@@ -56,5 +56,5 @@
 */
 
-short	tunpal[16][3] = {	/* color palette */
+int16_t	tunpal[16][3] = {	/* color palette */
 
 	{0, 0, 0},	/* 0 */
@@ -77,7 +77,7 @@
 
 			/*   12345678901234567890123456789012	*/
-static	char	dfltnam[] = "Local 3rds + MIDI 12 tone scale ";
-
-char	*tdlabl[] = {
+static	int8_t	dfltnam[] = "Local 3rds + MIDI 12 tone scale ";
+
+int8_t	*tdlabl[] = {
 
 	"C", "#", "D", "#", "E", "F", "#", "G",
@@ -96,5 +96,5 @@
 */
 
-void gettun(short n)
+void gettun(int16_t n)
 {
 	memcpyw(tuntab, tunlib[n], 128);
@@ -110,5 +110,5 @@
 */
 
-void puttun(short n)
+void puttun(int16_t n)
 {
 	memcpyw(tunlib[n], tuntab, 128);
@@ -127,7 +127,7 @@
 */
 
-void inittt(short n)
-{
-	register short i;
+void inittt(int16_t n)
+{
+	register int16_t i;
 
 	for (i = 0; i < 128; i++)
@@ -150,5 +150,5 @@
 void inittl(void)
 {
-	register short i;
+	register int16_t i;
 
 	for (i = 0; i < NTUNS; i++)
@@ -170,8 +170,8 @@
 */
 
-void tt_trcp(short start, short finish, short dest)
-{
-	register short i;
-	register long v;
+void tt_trcp(int16_t start, int16_t finish, int16_t dest)
+{
+	register int16_t i;
+	register int32_t v;
 
 	memcpyw(oldtun, tuntab, 128);	/* preserve old table for undo */
@@ -183,12 +183,12 @@
 			/* reverse copy */
 
-			v = oldtun[i] + (long)tunval;	/* transpose */
-
-			if (v GT (long)PITCHMAX)	/* limit */
-				v = (long)PITCHMAX;
-			else if (v LT (long)PITCHMIN)
-				v = (long)PITCHMIN;
-
-			tuntab[dest++] = (short)v;	/* store the value */
+			v = oldtun[i] + (int32_t)tunval;	/* transpose */
+
+			if (v GT (int32_t)PITCHMAX)	/* limit */
+				v = (int32_t)PITCHMAX;
+			else if (v LT (int32_t)PITCHMIN)
+				v = (int32_t)PITCHMIN;
+
+			tuntab[dest++] = (int16_t)v;	/* store the value */
 		}
 
@@ -199,12 +199,12 @@
 			/* forward copy */
 
-			v = oldtun[i] + (long)tunval;	/* transpose */
-
-			if (v GT (long)PITCHMAX)	/* limit */
-				v = (long)PITCHMAX;
-			else if (v LT (long)PITCHMIN)
-				v = (long)PITCHMIN;
-
-			tuntab[dest++] = (short)v;	/* store the value */
+			v = oldtun[i] + (int32_t)tunval;	/* transpose */
+
+			if (v GT (int32_t)PITCHMAX)	/* limit */
+				v = (int32_t)PITCHMAX;
+			else if (v LT (int32_t)PITCHMIN)
+				v = (int32_t)PITCHMIN;
+
+			tuntab[dest++] = (int16_t)v;	/* store the value */
 		}
 	}
@@ -223,8 +223,8 @@
 */
 
-short tt_intp(short from, short to)
-{
-	register short i, j, k, n;
-	register long t;
+int16_t tt_intp(int16_t from, int16_t to)
+{
+	register int16_t i, j, k, n;
+	register int32_t t;
 
 	memcpyw(oldtun, tuntab, 128);	/* preserve old table for undo */
@@ -243,10 +243,10 @@
 
 	k = tuntab[from];
-	t = (((long)tuntab[to] - (long)k) << 16) / n;
+	t = (((int32_t)tuntab[to] - (int32_t)k) << 16) / n;
 	j = 1 + from;
 	n--;
 
 	for (i = 0; i < n ; i++)
-		tuntab[j++] = (short)((t * (1 + i)) >> 16) + k;
+		tuntab[j++] = (int16_t)((t * (1 + i)) >> 16) + k;
 
 	tunmod = TRUE;
@@ -263,8 +263,8 @@
 */
 
-short tt_incr(short from, short to)
-{
-	register short i;
-	register long v;
+int16_t tt_incr(int16_t from, int16_t to)
+{
+	register int16_t i;
+	register int32_t v;
 
 	memcpyw(oldtun, tuntab, 128);	/* preserve old table for undo */
@@ -278,5 +278,5 @@
 	}
 
-	v = (long)oldtun[from];		/* initial value */
+	v = (int32_t)oldtun[from];		/* initial value */
 
 	if (from++ EQ to)		/* interval has to be at least 1 */
@@ -285,12 +285,12 @@
 	for (i = from; i LE to; i++) {
 
-		v += (long)tunval;		/* increment */
-
-		if (v GT (long)PITCHMAX)	/* limit */
-			v = (long)PITCHMAX;
-		else if (v LT (long)PITCHMIN)
-			v = (long)PITCHMIN;
-
-		tuntab[i] = (short)v;		/* store the value */
+		v += (int32_t)tunval;		/* increment */
+
+		if (v GT (int32_t)PITCHMAX)	/* limit */
+			v = (int32_t)PITCHMAX;
+		else if (v LT (int32_t)PITCHMIN)
+			v = (int32_t)PITCHMIN;
+
+		tuntab[i] = (int16_t)v;		/* store the value */
 	}
 
@@ -309,7 +309,7 @@
 */
 
-void td_trcp(short mode)
-{
-	register unsigned cx;
+void td_trcp(int16_t mode)
+{
+	register uint16_t cx;
 
 	cx = exp_c(mode ? TDSELD : tdbox[6][4]);
@@ -325,7 +325,7 @@
 */
 
-void td_incr(short mode)
-{
-	register unsigned cx;
+void td_incr(int16_t mode)
+{
+	register uint16_t cx;
 
 	cx = exp_c(mode ? TDSELD : tdbox[6][4]);
@@ -340,7 +340,7 @@
 */
 
-void td_intp(short mode)
-{
-	register unsigned cx;
+void td_intp(int16_t mode)
+{
+	register uint16_t cx;
 
 	cx = exp_c(mode ? TDSELD : tdbox[6][4]);
@@ -361,5 +361,5 @@
 void advtcur(void)
 {
-	register short newcol;
+	register int16_t newcol;
 
 	if (infield(stcrow, stccol, curfet))
@@ -385,5 +385,5 @@
 void bsptcur(void)
 {
-	register short newcol;
+	register int16_t newcol;
 
 	if (infield(stcrow, stccol, curfet))
@@ -411,7 +411,7 @@
 */
 
-void dsttval(short row, short col, short val, unsigned fg, unsigned bg)
-{
-	register unsigned cfg, cbg;
+void dsttval(int16_t row, int16_t col, int16_t val, uint16_t fg, uint16_t bg)
+{
+	register uint16_t cfg, cbg;
 
 	cfg = exp_c(fg);
@@ -441,8 +441,8 @@
 */
 
-void tdswin(short n)
-{
-	register short cx, i, tv;
-	char ts;
+void tdswin(int16_t n)
+{
+	register int16_t cx, i, tv;
+	int8_t ts;
 
 	cx = exp_c(tdbox[n][5]);
@@ -589,5 +589,5 @@
 void twins(void)
 {
-	register short i;
+	register int16_t i;
 
 	for (i = 0; i < 8; i++)
