Index: ram/libdsp.c
===================================================================
--- ram/libdsp.c	(revision 599d89b3d3e576167c9066cfd2530b2824dc2bff)
+++ ram/libdsp.c	(revision 8618599ab825088c720c202c6e50a52572282c0f)
@@ -45,9 +45,9 @@
 #endif
 
-extern	short	lcancel(short lct);
-
-extern	long	ptsizer(void);
-extern	long	scsizer(void);
-extern	long	sqsizer(void);
+extern	int16_t	lcancel(int16_t lct);
+
+extern	int32_t	ptsizer(void);
+extern	int32_t	scsizer(void);
+extern	int32_t	sqsizer(void);
 
 /* 
@@ -57,34 +57,34 @@
 /* things defined elsewhere */
 
-extern	void	(*point)(short x, short y, short pen);
-
-extern	void	vbfill4(unsigned *obj, short obwidth, short xmin, short ymin, short xmax, short ymax, unsigned color);
-extern	void	tsplot4(int *obase, int nw, int fg, int row, int col, char *str, int pitch);
-extern	void	lseg(short x1, short y1, short x2, short y2, short t);
+extern	void	(*point)(int16_t x, int16_t y, int16_t pen);
+
+extern	void	vbfill4(uint16_t *obj, int16_t obwidth, int16_t xmin, int16_t ymin, int16_t xmax, int16_t ymax, uint16_t color);
+extern	void	tsplot4(int16_t *obase, int16_t nw, int16_t fg, int16_t row, int16_t col, int8_t *str, int16_t pitch);
+extern	void	lseg(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t t);
 extern	void	clrlsel(void);
 extern	void	_clsvol(void);
-extern	void	setgc(short xv, short yv);
-
-extern	int	errno;
-extern	int	_bpbin;
-
-extern	short	chtime;
-extern	short	cmtype;
-extern	short	cvtime;
-extern	short	cxval;
-extern	short	cyval;
-extern	short	sgcsw;
-extern	short	stccol;
-extern	short	stcrow;
-extern	short	submenu;
-extern	short	thcwval;
-extern	short	tvcwval;
-
-extern	unsigned	*obj0, *obj2;
-
-extern	char	*ldbxlb0[];
-extern	char	vtlin1[], vtlin2[], vtlin3[];
-
-extern	short	ldbox[][8];
+extern	void	setgc(int16_t xv, int16_t yv);
+
+extern	int16_t	errno;
+extern	int16_t	_bpbin;
+
+extern	int16_t	chtime;
+extern	int16_t	cmtype;
+extern	int16_t	cvtime;
+extern	int16_t	cxval;
+extern	int16_t	cyval;
+extern	int16_t	sgcsw;
+extern	int16_t	stccol;
+extern	int16_t	stcrow;
+extern	int16_t	submenu;
+extern	int16_t	thcwval;
+extern	int16_t	tvcwval;
+
+extern	uint16_t	*obj0, *obj2;
+
+extern	int8_t	*ldbxlb0[];
+extern	int8_t	vtlin1[], vtlin2[], vtlin3[];
+
+extern	int16_t	ldbox[][8];
 extern	struct	instdef	idefs[];
 
@@ -95,43 +95,43 @@
 */
 
-extern	unsigned *librob;		/* display object pointer */
-
-extern	short	catin;			/* catalog read in flag */
-extern	short	lrasw;			/* append (TRUE) / replace (FALSE) score */
-extern	short	lorchl;			/* hi (TRUE) / lo (FALSE) orchestra */
-extern	short	ldrow;			/* fetch select row */
-extern	short	ldslot;			/* fetch select slot */
-extern	short	lselsw;			/* fetch select switch */
-extern	short	ldkind;			/* fetch file type */
-extern	short	lstrsw;			/* store state switch */
-extern	short	lasgsw;			/* assignments store switch */
-extern	short	lksel;			/* librarian key slot selector */
-extern	short	lorchsw;		/* hi orchestra (21 - 40) store switch */
-extern	short	lorclsw;		/* lo orchestra (01 - 20) store switch */
-extern	short	lpatsw;			/* patch store switch */
-extern	short	lscrsw;			/* score store switch */
-extern	short	lseqsw;			/* sequence store switch */
-extern	short	ltunsw;			/* tunings store switch */
-extern	short	lwavsw;			/* waveshapes store switch */
-extern	short	ldelsw;			/* delete switch */
-extern	short	lderrsw;		/* error message displayed switch */
-extern	short	ldidsiz;		/* getcat() did showsiz() switch */
-extern	short	lmwtype;		/* librarian message window type */
-extern	short	ltagged;		/* load tag update in progress flag */
-extern	short	ndisp;			/* display number currently up */
-
-extern	long	lcsum;			/* library checksum */
-extern	long	ndbytes;		/* bytes needed for storage */
-
-extern	char	*lmln22;		/* message window line 22 */
-extern	char	*lmln23;		/* message window line 23 */
-extern	char	*lmln24;		/* message window line 24 */
-
-extern	char	ldfile[9];		/* file name field */
-extern	char	ldcmnt[38];		/* comment field */
-extern	char	ldmsg1[65];		/* messsage build area 1 */
-extern	char	ldmsg2[65];		/* messsage build area 2 */
-extern	char	ldmsg3[65];		/* messsage build area 3 */
-extern	char	errbuf[65];		/* error message build area */
+extern	uint16_t *librob;		/* display object pointer */
+
+extern	int16_t	catin;			/* catalog read in flag */
+extern	int16_t	lrasw;			/* append (TRUE) / replace (FALSE) score */
+extern	int16_t	lorchl;			/* hi (TRUE) / lo (FALSE) orchestra */
+extern	int16_t	ldrow;			/* fetch select row */
+extern	int16_t	ldslot;			/* fetch select slot */
+extern	int16_t	lselsw;			/* fetch select switch */
+extern	int16_t	ldkind;			/* fetch file type */
+extern	int16_t	lstrsw;			/* store state switch */
+extern	int16_t	lasgsw;			/* assignments store switch */
+extern	int16_t	lksel;			/* librarian key slot selector */
+extern	int16_t	lorchsw;		/* hi orchestra (21 - 40) store switch */
+extern	int16_t	lorclsw;		/* lo orchestra (01 - 20) store switch */
+extern	int16_t	lpatsw;			/* patch store switch */
+extern	int16_t	lscrsw;			/* score store switch */
+extern	int16_t	lseqsw;			/* sequence store switch */
+extern	int16_t	ltunsw;			/* tunings store switch */
+extern	int16_t	lwavsw;			/* waveshapes store switch */
+extern	int16_t	ldelsw;			/* delete switch */
+extern	int16_t	lderrsw;		/* error message displayed switch */
+extern	int16_t	ldidsiz;		/* getcat() did showsiz() switch */
+extern	int16_t	lmwtype;		/* librarian message window type */
+extern	int16_t	ltagged;		/* load tag update in progress flag */
+extern	int16_t	ndisp;			/* display number currently up */
+
+extern	int32_t	lcsum;			/* library checksum */
+extern	int32_t	ndbytes;		/* bytes needed for storage */
+
+extern	int8_t	*lmln22;		/* message window line 22 */
+extern	int8_t	*lmln23;		/* message window line 23 */
+extern	int8_t	*lmln24;		/* message window line 24 */
+
+extern	int8_t	ldfile[9];		/* file name field */
+extern	int8_t	ldcmnt[38];		/* comment field */
+extern	int8_t	ldmsg1[65];		/* messsage build area 1 */
+extern	int8_t	ldmsg2[65];		/* messsage build area 2 */
+extern	int8_t	ldmsg3[65];		/* messsage build area 3 */
+extern	int8_t	errbuf[65];		/* error message build area */
 
 extern	struct	octent	*ldoct;		/* object control table pointer */
@@ -141,11 +141,11 @@
 /* forward references */
 
-void	ldpoint(short x, short y, short pen);
-
-/* 
-
-*/
-
-char	*ftypes[][3] = {	/* file types  (must match libdsp.h) */
+void	ldpoint(int16_t x, int16_t y, int16_t pen);
+
+/* 
+
+*/
+
+int8_t	*ftypes[][3] = {	/* file types  (must match libdsp.h) */
 
 	{"ASG", "Assignmnt", "Assignmnt"},	/* FT_ASG */
@@ -160,8 +160,8 @@
 };
 
-char	ld_em1[] = "No files stored on disk";
-char	ld_em2[] = " by this operation";
-
-short	lbrpal[16][3] = {	/* librarian color palette */
+int8_t	ld_em1[] = "No files stored on disk";
+int8_t	ld_em2[] = " by this operation";
+
+int16_t	lbrpal[16][3] = {	/* librarian color palette */
 
 	{0, 0, 0},	/* 0 */
@@ -196,7 +196,7 @@
 */
 
-short ftkind(short ns)
-{
-	register short i;
+int16_t ftkind(int16_t ns)
+{
+	register int16_t i;
 
 	for (i = 0; i < NFTYPES; i++)
@@ -216,8 +216,8 @@
 */
 
-char *fctstr(short ns, short just)
-{
-	static char fcbad[11];
-	register short i;
+int8_t *fctstr(int16_t ns, int16_t just)
+{
+	static int8_t fcbad[11];
+	register int16_t i;
 
 	for (i = 0; i < NFTYPES; i++)
@@ -239,5 +239,5 @@
 */
 
-short ocslot(short slot)
+int16_t ocslot(int16_t slot)
 {
 	if (memcmp(filecat[slot].fcsize, "000", 3)
@@ -254,5 +254,5 @@
 */
 
-short ldline(short cy)
+int16_t ldline(int16_t cy)
 {
 	if (cy > 292)
@@ -277,7 +277,7 @@
 */
 
-short lin2slt(short line)
-{
-	register short slot, row;
+int16_t lin2slt(int16_t line)
+{
+	register int16_t slot, row;
 
 	row = 0;
@@ -297,5 +297,5 @@
 */
 
-unsigned exp_c(unsigned c)
+uint16_t exp_c(uint16_t c)
 {
 	c &= 0x000F;		/* use low 4 bits as the basis */
@@ -316,5 +316,5 @@
 */
 
-void ldwmsg(char *line1, char *line2, char *line3, unsigned fgcolor, unsigned bgcolor)
+void ldwmsg(int8_t *line1, int8_t *line2, int8_t *line3, uint16_t fgcolor, uint16_t bgcolor)
 {
 	lderrsw = FALSE;		/* clear error switch */
@@ -336,13 +336,13 @@
 		ldbox[10][2], ldbox[10][3], bgcolor);
 
-	if ((char *)NULL NE line1)
+	if ((int8_t *)NULL NE line1)
 		tsplot4(librob, 64, fgcolor, ldbox[10][6], ldbox[10][7],
 			line1, 14);
 
-	if ((char *)NULL NE line2)
+	if ((int8_t *)NULL NE line2)
 		tsplot4(librob, 64, fgcolor, (ldbox[10][6] + 1), ldbox[10][7],
 			line2, 14);
 
-	if ((char *)NULL NE line3)
+	if ((int8_t *)NULL NE line3)
 		tsplot4(librob, 64, fgcolor, (ldbox[10][6] + 2), ldbox[10][7],
 			line3, 14);
@@ -359,7 +359,7 @@
 */
 
-long chksum(char *area, long len)
-{
-	register long cs, i;
+int32_t chksum(int8_t *area, int32_t len)
+{
+	register int32_t cs, i;
 
 	cs = 0L;
@@ -377,5 +377,5 @@
 */
 
-void makelh(short kind)
+void makelh(int16_t kind)
 {
 	memset(ldhead.l_csum, '?', 8);			/* checksum */
@@ -384,5 +384,5 @@
 	memcpy(ldhead.l_cmnt, ldcmnt, 37);		/* comment */
 
-	lcsum = chksum(ldhead.l_name, (long)(LH_LEN - 8));
+	lcsum = chksum(ldhead.l_name, (int32_t)(LH_LEN - 8));
 }
 
@@ -397,10 +397,10 @@
 */
 
-void ldbusy(char *msg)
+void ldbusy(int8_t *msg)
 {
 	if (ndisp NE 0)
 		return;
 
-	ldwmsg((char *)NULL, "    Busy - Please stand by", msg,
+	ldwmsg((int8_t *)NULL, "    Busy - Please stand by", msg,
 		ldbox[10][4], ldbox[10][5]);
 }
@@ -412,5 +412,5 @@
 */
 
-void noslot(int fctype)
+void noslot(int16_t fctype)
 {
 	sprintf(ldmsg1, " the %s file,", ftypes[fctype - 1][2]);
@@ -430,8 +430,8 @@
 */
 
-short wr_ec(FILE *fp, char *from, long len)
-{
-	register long count;
-	register char c;
+int16_t wr_ec(FILE *fp, int8_t *from, int32_t len)
+{
+	register int32_t count;
+	register int8_t c;
 	for (count = 0; count < len; count++) {
 
@@ -444,5 +444,5 @@
 
 			ldermsg("Disk may be full",
-				errbuf, (char *)NULL, LD_EMCF, LD_EMCB);
+				errbuf, (int8_t *)NULL, LD_EMCF, LD_EMCB);
 
 			fclose(fp);
@@ -470,8 +470,8 @@
 */
 
-short rd_ec(FILE *fp, char *to, long len)
-{
-	register long count;
-	register int c;
+int16_t rd_ec(FILE *fp, int8_t *to, int32_t len)
+{
+	register int32_t count;
+	register int16_t c;
 
 	for (count = 0; count < len; count++) {
@@ -484,5 +484,5 @@
 
 			ldermsg("Unexpected EOF",
-				errbuf, (char *)NULL, LD_EMCF, LD_EMCB);
+				errbuf, (int8_t *)NULL, LD_EMCF, LD_EMCB);
 
 			fclose(fp);
@@ -516,7 +516,7 @@
 */
 
-short srchcat(char extn[])
-{
-	register short fcslot;
+int16_t srchcat(int8_t extn[])
+{
+	register int16_t fcslot;
 
 	for (fcslot = 0; fcslot < FCMAX; fcslot++) {
@@ -539,6 +539,6 @@
 void clrcat(void)
 {
-	register short i;
-	char fcebuf[1 + sizeof (struct fcat)];
+	register int16_t i;
+	int8_t fcebuf[1 + sizeof (struct fcat)];
 
 	for (i = 0; i < FCMAX; i++) {
@@ -564,8 +564,8 @@
 */
 
-short clreq(long bytes)
-{
-	register short rclusts;
-	register long clmask;
+int16_t clreq(int32_t bytes)
+{
+	register int16_t rclusts;
+	register int32_t clmask;
 
 	clmask = _thebpb->clsizb - 1;
@@ -587,8 +587,8 @@
 */
 
-short spacerq(short kind)
-{
-	register short howmuch;
-	register long k;
+int16_t spacerq(int16_t kind)
+{
+	register int16_t howmuch;
+	register int32_t k;
 
 	k = 0L;
@@ -598,5 +598,5 @@
 	case FT_ASG:	/* Assignment file */
 
-		k = (sizeof (struct asgent) * (long)NASGLIB) + LH_LEN;
+		k = (sizeof (struct asgent) * (int32_t)NASGLIB) + LH_LEN;
 		break;
 
@@ -605,5 +605,5 @@
 	case FT_ORC:
 
-		k = ((OR_LEN1 + (2 * OR_LEN2)) * (long)NINORC) + LH_LEN;
+		k = ((OR_LEN1 + (2 * OR_LEN2)) * (int32_t)NINORC) + LH_LEN;
 		break;
 
@@ -630,5 +630,5 @@
 	case FT_WAV:	/* Waveshape file */
 
-		k = ((long)NUMWAVS * OR_LEN2) + LH_LEN;
+		k = ((int32_t)NUMWAVS * OR_LEN2) + LH_LEN;
 		break;
 
@@ -656,5 +656,5 @@
 */
 
-short ckstor(void)
+int16_t ckstor(void)
 {
 	if (lasgsw)			/* assignments */
@@ -695,5 +695,5 @@
 */
 
-short ckdups(void)
+int16_t ckdups(void)
 {
 	if (lasgsw)
@@ -747,7 +747,7 @@
 */
 
-int showsiz(void)
-{
-	register short dcap, drem, dused;
+int16_t showsiz(void)
+{
+	register int16_t dcap, drem, dused;
 
 	_bpbin = FALSE;		/* force disk to be read */
@@ -758,5 +758,5 @@
 
 		ldermsg("Disk not ready ?",
-			(char *)NULL, (char *)NULL,
+			(int8_t *)NULL, (int8_t *)NULL,
 			LD_EMCF, LD_EMCB);
 
@@ -785,8 +785,8 @@
 */
 
-short getcat(short msgsw)
+int16_t getcat(int16_t msgsw)
 {
 	register FILE *fp;
-	int	rc, fesize;
+	int16_t	rc, fesize;
 
 	ldidsiz = FALSE;		/* we didn't show the size (yet) */
@@ -837,5 +837,5 @@
 
 			ldermsg("File catalog is NULL",
-				(char *)NULL, (char *)NULL,
+				(int8_t *)NULL, (int8_t *)NULL,
 				LD_EMCF, LD_EMCB);
 
@@ -865,8 +865,8 @@
 */
 
-short putcat(void)
+int16_t putcat(void)
 {
 	register FILE *fp;
-	register int	i, rc, fesize;
+	register int16_t	i, rc, fesize;
 
 	for (i = 0; i < FCMAX; i++) {		/* clean up the catalog */
@@ -885,5 +885,5 @@
 
 		ldermsg("Unable to open catalog",
-				(char *)NULL, ldmsg2, LD_EMCF, LD_EMCB);
+				(int8_t *)NULL, ldmsg2, LD_EMCF, LD_EMCB);
 
 		return(FAILURE);
@@ -914,5 +914,5 @@
 
 			ldermsg("Disk may be full",
-				(char *)NULL, ldmsg2,
+				(int8_t *)NULL, ldmsg2,
 				LD_EMCF, LD_EMCB);
 		}
@@ -938,9 +938,9 @@
 */
 
-void dslslot(short slot, unsigned fg, short row)
-{
-	register unsigned color, chilon, chilorc;
-	short c;
-	char buf[40];
+void dslslot(int16_t slot, uint16_t fg, int16_t row)
+{
+	register uint16_t color, chilon, chilorc;
+	int16_t c;
+	int8_t buf[40];
 
 	if (ndisp NE 0)
@@ -992,8 +992,8 @@
 */
 
-short showcat(void)
-{
-	register short i, fcslot, fcrow, fcount;
-	register unsigned color;
+int16_t showcat(void)
+{
+	register int16_t i, fcslot, fcrow, fcount;
+	register uint16_t color;
 
 	if (ndisp NE 0)
@@ -1038,5 +1038,5 @@
 */
 
-short fcindex(void)
+int16_t fcindex(void)
 {
 	if (NOT lderrsw)
@@ -1108,7 +1108,7 @@
 */
 
-short getslot(void)
-{
-	register short i;
+int16_t getslot(void)
+{
+	register int16_t i;
 
 	for (i = 0; i < FCMAX; i++)
@@ -1125,7 +1125,7 @@
 */
 
-char *slotnam(unsigned slot, unsigned kind)
-{
-	static	char thename[13];
+int8_t *slotnam(uint16_t slot, uint16_t kind)
+{
+	static	int8_t thename[13];
 
 	sprintf(thename, "M7SLOT%02.2u.%-3.3s",
@@ -1145,8 +1145,8 @@
 */
 
-short wrtfile(short kind)
-{
-	register short slot, flspace, tkind;
-	char sizetmp[4];
+int16_t wrtfile(int16_t kind)
+{
+	register int16_t slot, flspace, tkind;
+	int8_t sizetmp[4];
 
 	slot = getslot();
@@ -1229,5 +1229,5 @@
 
 		ldermsg("bad wrtfile argument:",
-			ldmsg1, (char *)NULL, LD_EMCF, LD_EMCB);
+			ldmsg1, (int8_t *)NULL, LD_EMCF, LD_EMCB);
 
 		return(FAILURE);
@@ -1272,5 +1272,5 @@
 */
 
-short writem(void)
+int16_t writem(void)
 {
 	if (lasgsw)			/* Assignments */
@@ -1319,8 +1319,8 @@
 */
 
-short storit(void)
-{
-	register int weneed, i, slotnd, slothv;
-	int	rc, drem;
+int16_t storit(void)
+{
+	register int16_t weneed, i, slotnd, slothv;
+	int16_t	rc, drem;
 
 	/* make sure the file is named */
@@ -1491,5 +1491,5 @@
 void advlcur(void)
 {
-	register short newcol;
+	register int16_t newcol;
 
 	if (infield(stcrow, stccol, curfet))
@@ -1515,5 +1515,5 @@
 void bsplcur(void)
 {
-	register short newcol;
+	register int16_t newcol;
 
 	if (infield(stcrow, stccol, curfet))
@@ -1541,7 +1541,7 @@
 */
 
-void ldswin(short n)
-{
-	register short cx, cy;
+void ldswin(int16_t n)
+{
+	register int16_t cx, cy;
 
 	if (ndisp NE 0)
@@ -1695,5 +1695,5 @@
 void lwins(void)
 {
-	register short i;
+	register int16_t i;
 
 	for (i = 0; i < 11; i++)
@@ -1707,5 +1707,5 @@
 */
 
-void ldpoint(short x, short y, short pen)
+void ldpoint(int16_t x, int16_t y, int16_t pen)
 {
 	if (v_regs[5] & 0x0180)
