Index: ram/librw.c
===================================================================
--- ram/librw.c	(revision 05806159f2593192d6ed2fca28358480a2383c67)
+++ ram/librw.c	(revision 7258c6ac4de2518c5430095742a27be7af0c89d7)
@@ -42,16 +42,16 @@
 #endif
 
-extern	char	*slotnam(unsigned slot, unsigned kind);
-
-extern	long	chksum(char *area, long len);
-
-extern	short	ldslot, lderrsw, lrasw;
-extern	short	tunlib[][128];
-
-extern	long	lcsum, schksum, sntlreq;
-
-extern	char	tunname[][32];
-extern	char	ldfile[9];
-extern	char	ldcmnt[38];
+extern	int8_t	*slotnam(uint16_t slot, uint16_t kind);
+
+extern	int32_t	chksum(int8_t *area, int32_t len);
+
+extern	int16_t	ldslot, lderrsw, lrasw;
+extern	int16_t	tunlib[][128];
+
+extern	int32_t	lcsum, schksum, sntlreq;
+
+extern	int8_t	tunname[][32];
+extern	int8_t	ldfile[9];
+extern	int8_t	ldcmnt[38];
 
 extern	struct	mlibhdr	ldhead;
@@ -71,9 +71,9 @@
 */
 
-short wrt_asg(short slot)
-{
-	register FILE *fp;
-	register int	i;
-	char cstemp[8];
+int16_t wrt_asg(int16_t slot)
+{
+	register FILE *fp;
+	register int16_t	i;
+	int8_t cstemp[8];
 
 	preio();	/* kill LCD backlight */
@@ -84,5 +84,5 @@
 
 		ldermsg("Couldn't create a file",
-			" for the assignments", (char *)NULL,
+			" for the assignments", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -95,5 +95,5 @@
 
 	for (i = 0; i < NASGLIB; i++)
-		lcsum += chksum(&asgtab[i + 1], (long)(sizeof (struct asgent)));
+		lcsum += chksum(&asgtab[i + 1], (int32_t)(sizeof (struct asgent)));
 
 	sprintf(cstemp, "%08.8lX", lcsum);
@@ -108,5 +108,5 @@
 
 */
-	if (wr_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (wr_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		streset();
@@ -116,5 +116,5 @@
 	for (i = 0; i < NASGLIB; i++) {
 
-		if (wr_ec(fp, &asgtab[i + 1], (long)(sizeof (struct asgent)))) {
+		if (wr_ec(fp, &asgtab[i + 1], (int32_t)(sizeof (struct asgent)))) {
 
 			streset();
@@ -138,8 +138,8 @@
 */
 
-short get_asg(void)
-{
-	register FILE *fp;
-	register int	i;
+int16_t get_asg(void)
+{
+	register FILE *fp;
+	register int16_t	i;
 
 	preio();	/* kill LCD backlight */
@@ -150,5 +150,5 @@
 
 		ldermsg("Couldn't open the file",
-			" for the assignments", (char *)NULL,
+			" for the assignments", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -166,5 +166,5 @@
 
 */
-	if (rd_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (rd_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		clrlsel();
@@ -180,5 +180,5 @@
 	for (i = 0; i < NASGLIB; i++) {
 
-		if (rd_ec(fp, &asgtab[i + 1], (long)(sizeof (struct asgent)))) {
+		if (rd_ec(fp, &asgtab[i + 1], (int32_t)(sizeof (struct asgent)))) {
 
 			clrlsel();
@@ -203,10 +203,10 @@
 */
 
-short wrt_orc(short slot, short lorh)
-{
-	register FILE *fp;
-	register int	i;
+int16_t wrt_orc(int16_t slot, int16_t lorh)
+{
+	register FILE *fp;
+	register int16_t	i;
 	register struct instdef *ip;
-	char cstemp[8];
+	int8_t cstemp[8];
 
 	if (lorh)
@@ -222,5 +222,5 @@
 
 		ldermsg("Couldn't create a file",
-			" for the orchestra", (char *)NULL,
+			" for the orchestra", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -236,7 +236,7 @@
 		ip = &idefs[i + 1 + (lorh ? NINORC : 0)];
 
-		lcsum += chksum(ip, (long)OR_LEN1);
-		lcsum += chksum(ip->idhwvao, (long)OR_LEN2);
-		lcsum += chksum(ip->idhwvbo, (long)OR_LEN2);
+		lcsum += chksum(ip, (int32_t)OR_LEN1);
+		lcsum += chksum(ip->idhwvao, (int32_t)OR_LEN2);
+		lcsum += chksum(ip->idhwvbo, (int32_t)OR_LEN2);
 	}
 
@@ -252,5 +252,5 @@
 
 */
-	if (wr_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (wr_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		streset();
@@ -262,5 +262,5 @@
 		ip = &idefs[i + 1 + (lorh ? NINORC : 0)];
 
-		if (wr_ec(fp, ip, (long)OR_LEN1)) {		/* functions */
+		if (wr_ec(fp, ip, (int32_t)OR_LEN1)) {		/* functions */
 
 			streset();
@@ -268,5 +268,5 @@
 		}
 
-		if (wr_ec(fp, ip->idhwvao, (long)OR_LEN2)) {	/* WS A */
+		if (wr_ec(fp, ip->idhwvao, (int32_t)OR_LEN2)) {	/* WS A */
 
 			streset();
@@ -274,5 +274,5 @@
 		}
 
-		if (wr_ec(fp, ip->idhwvbo, (long)OR_LEN2)) {	/* WS B */
+		if (wr_ec(fp, ip->idhwvbo, (int32_t)OR_LEN2)) {	/* WS B */
 
 			streset();
@@ -296,8 +296,8 @@
 */
 
-short get_orc(short lorh, short kind)
-{
-	register FILE *fp;
-	register int	i;
+int16_t get_orc(int16_t lorh, int16_t kind)
+{
+	register FILE *fp;
+	register int16_t	i;
 	register struct instdef *ip;
 
@@ -314,5 +314,5 @@
 
 		ldermsg("Couldn't open the file",
-			" for the orchestra", (char *)NULL,
+			" for the orchestra", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -330,5 +330,5 @@
 
 */
-	if (rd_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (rd_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		clrlsel();
@@ -346,5 +346,5 @@
 		ip = &idefs[i + 1 + (lorh ? NINORC : 0)];
 
-		if (rd_ec(fp, ip, (long)OR_LEN1)) {		/* functions */
+		if (rd_ec(fp, ip, (int32_t)OR_LEN1)) {		/* functions */
 
 			clrlsel();
@@ -352,5 +352,5 @@
 		}
 
-		if (rd_ec(fp, ip->idhwvao, (long)OR_LEN2)) {	/* WS A */
+		if (rd_ec(fp, ip->idhwvao, (int32_t)OR_LEN2)) {	/* WS A */
 
 			clrlsel();
@@ -358,5 +358,5 @@
 		}
 
-		if (rd_ec(fp, ip->idhwvbo, (long)OR_LEN2)) {	/* WS B */
+		if (rd_ec(fp, ip->idhwvbo, (int32_t)OR_LEN2)) {	/* WS B */
 
 			clrlsel();
@@ -386,9 +386,9 @@
 */
 
-short wrt_tun(short slot)
-{
-	register FILE *fp;
-	register int	i;
-	char cstemp[8];
+int16_t wrt_tun(int16_t slot)
+{
+	register FILE *fp;
+	register int16_t	i;
+	int8_t cstemp[8];
 
 	preio();	/* kill LCD backlight */
@@ -399,5 +399,5 @@
 
 		ldermsg("Couldn't create a file",
-			" for the tunings", (char *)NULL,
+			" for the tunings", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -426,5 +426,5 @@
 
 */
-	if (wr_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (wr_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		streset();
@@ -462,8 +462,8 @@
 */
 
-short get_tun(void)
-{
-	register FILE *fp;
-	register int	i;
+int16_t get_tun(void)
+{
+	register FILE *fp;
+	register int16_t	i;
 
 	preio();	/* kill LCD backlight */
@@ -474,5 +474,5 @@
 
 		ldermsg("Couldn't open the file",
-			" for the tunings", (char *)NULL,
+			" for the tunings", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -490,5 +490,5 @@
 
 */
-	if (rd_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (rd_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		clrlsel();
@@ -533,8 +533,8 @@
 */
 
-short wrt_pat(short slot)
-{
-	register FILE *fp;
-	char cstemp[8];
+int16_t wrt_pat(int16_t slot)
+{
+	register FILE *fp;
+	int8_t cstemp[8];
 
 	preio();	/* kill LCD backlight */
@@ -545,5 +545,5 @@
 
 		ldermsg("Couldn't create a file",
-			" for the patches", (char *)NULL,
+			" for the patches", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -566,5 +566,5 @@
 
 */
-	if (wr_ec(fp, &ldhead, (long)LH_LEN)) {		/* header */
+	if (wr_ec(fp, &ldhead, (int32_t)LH_LEN)) {		/* header */
 
 		streset();
@@ -593,5 +593,5 @@
 */
 
-short get_pat(void)
+int16_t get_pat(void)
 {
 	register FILE *fp;
@@ -604,5 +604,5 @@
 
 		ldermsg("Couldn't open the file",
-			" for the patches", (char *)NULL,
+			" for the patches", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -620,5 +620,5 @@
 
 */
-	if (rd_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (rd_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		clrlsel();
@@ -656,10 +656,10 @@
 */
 
-short wrt_scr(short slot)
-{
-	register FILE *fp;
-	register int	i;
-	long tnb;
-	char cstemp[8];
+int16_t wrt_scr(int16_t slot)
+{
+	register FILE *fp;
+	register int16_t	i;
+	int32_t tnb;
+	int8_t cstemp[8];
 
 	preio();	/* kill LCD backlight */
@@ -670,5 +670,5 @@
 
 		ldermsg("Couldn't create a file",
-			" for the scores", (char *)NULL,
+			" for the scores", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -693,5 +693,5 @@
 
 */
-	if (wr_ec(fp, &ldhead, (long)LH_LEN)) {		/* header */
+	if (wr_ec(fp, &ldhead, (int32_t)LH_LEN)) {		/* header */
 
 		streset();
@@ -729,9 +729,9 @@
 */
 
-short get_scr(void)
-{
-	register FILE *fp;
-	register int	i;
-	long tnl;
+int16_t get_scr(void)
+{
+	register FILE *fp;
+	register int16_t	i;
+	int32_t tnl;
 
 	preio();	/* kill LCD backlight */
@@ -742,5 +742,5 @@
 
 		ldermsg("Couldn't open the file",
-			" for the scores", (char *)NULL,
+			" for the scores", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -758,5 +758,5 @@
 
 */
-	if (rd_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (rd_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		clrlsel();
@@ -812,8 +812,8 @@
 */
 
-short wrt_seq(short slot)
-{
-	register FILE *fp;
-	char cstemp[8];
+int16_t wrt_seq(int16_t slot)
+{
+	register FILE *fp;
+	int8_t cstemp[8];
 
 	preio();	/* kill LCD backlight */
@@ -824,5 +824,5 @@
 
 		ldermsg("Couldn't create a file",
-			" for the sequences", (char *)NULL,
+			" for the sequences", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -845,5 +845,5 @@
 
 */
-	if (wr_ec(fp, &ldhead, (long)LH_LEN)) {		/* header */
+	if (wr_ec(fp, &ldhead, (int32_t)LH_LEN)) {		/* header */
 
 		streset();
@@ -872,5 +872,5 @@
 */
 
-short get_seq(void)
+int16_t get_seq(void)
 {
 	register FILE *fp;
@@ -883,5 +883,5 @@
 
 		ldermsg("Couldn't open the file",
-			" for the sequences", (char *)NULL,
+			" for the sequences", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -899,5 +899,5 @@
 
 */
-	if (rd_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (rd_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		clrlsel();
@@ -934,9 +934,9 @@
 */
 
-short wrt_wav(short slot)
-{
-	register FILE *fp;
-	register int	i;
-	char cstemp[8];
+int16_t wrt_wav(int16_t slot)
+{
+	register FILE *fp;
+	register int16_t	i;
+	int8_t cstemp[8];
 	register struct wstbl *wp;
 
@@ -948,5 +948,5 @@
 
 		ldermsg("Couldn't create a file",
-			" for the waveshapes", (char *)NULL,
+			" for the waveshapes", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -962,6 +962,6 @@
 		wp = &wslib[i];
 
-		lcsum += chksum(wp->offset, (long)(NUMWPNT * 2));
-		lcsum += chksum(wp->harmon, (long)(NUMHARM * 2));
+		lcsum += chksum(wp->offset, (int32_t)(NUMWPNT * 2));
+		lcsum += chksum(wp->harmon, (int32_t)(NUMHARM * 2));
 	}
 
@@ -977,5 +977,5 @@
 
 */
-	if (wr_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (wr_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		streset();
@@ -987,5 +987,5 @@
 		wp = &wslib[i];
 
-		if (wr_ec(fp, wp->offset, (long)(NUMWPNT * 2))) {
+		if (wr_ec(fp, wp->offset, (int32_t)(NUMWPNT * 2))) {
 
 			streset();
@@ -993,5 +993,5 @@
 		}
 
-		if (wr_ec(fp, wp->harmon, (long)(NUMHARM * 2))) {
+		if (wr_ec(fp, wp->harmon, (int32_t)(NUMHARM * 2))) {
 
 			streset();
@@ -1015,8 +1015,8 @@
 */
 
-short get_wav(void)
-{
-	register FILE *fp;
-	register int	i;
+int16_t get_wav(void)
+{
+	register FILE *fp;
+	register int16_t	i;
 	register struct wstbl *wp;
 
@@ -1028,5 +1028,5 @@
 
 		ldermsg("Couldn't open the file",
-			" for the waveshapes", (char *)NULL,
+			" for the waveshapes", (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -1044,5 +1044,5 @@
 
 */
-	if (rd_ec(fp, &ldhead, (long)LH_LEN)) {			/* header */
+	if (rd_ec(fp, &ldhead, (int32_t)LH_LEN)) {			/* header */
 
 		clrlsel();
@@ -1060,5 +1060,5 @@
 		wp = &wslib[i];
 
-		if (rd_ec(fp, wp->offset, (long)(NUMWPNT * 2))) {
+		if (rd_ec(fp, wp->offset, (int32_t)(NUMWPNT * 2))) {
 
 			clrlsel();
@@ -1066,5 +1066,5 @@
 		}
 
-		if (rd_ec(fp, wp->harmon, (long)(NUMHARM * 2))) {
+		if (rd_ec(fp, wp->harmon, (int32_t)(NUMHARM * 2))) {
 
 			clrlsel();
