Index: include/glcdefs.h
===================================================================
--- include/glcdefs.h	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ include/glcdefs.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -10,21 +10,21 @@
 #include "stdint.h"
 
-#define	G_INIT		(int8_t)0x40
-#define	G_MWRITE	(int8_t)0x42
-#define	G_MREAD		(int8_t)0x43
-#define	G_SETSAD	(int8_t)0x44
-#define	G_CRSWR		(int8_t)0x46
-#define	G_CRSRD		(int8_t)0x47
-#define	G_CRSMRT	(int8_t)0x4C
-#define	G_CRSMLT	(int8_t)0x4D
-#define	G_CRSMUP	(int8_t)0x4E
-#define	G_CRSMDN	(int8_t)0x4F
-#define	G_ERASE		(int8_t)0x52
-#define	G_SLEEP		(int8_t)0x53
-#define	G_DSPCTL	(int8_t)0x58
-#define	G_HSCRL		(int8_t)0x5A
-#define	G_OVRLAY	(int8_t)0x5B
-#define	G_CGRAM		(int8_t)0x5C
-#define	G_CRSFRM	(int8_t)0x5D
+#define	G_INIT		0x40
+#define	G_MWRITE	0x42
+#define	G_MREAD		0x43
+#define	G_SETSAD	0x44
+#define	G_CRSWR		0x46
+#define	G_CRSRD		0x47
+#define	G_CRSMRT	0x4C
+#define	G_CRSMLT	0x4D
+#define	G_CRSMUP	0x4E
+#define	G_CRSMDN	0x4F
+#define	G_ERASE		0x52
+#define	G_SLEEP		0x53
+#define	G_DSPCTL	0x58
+#define	G_HSCRL		0x5A
+#define	G_OVRLAY	0x5B
+#define	G_CGRAM		0x5C
+#define	G_CRSFRM	0x5D
 
 #define	LCD_WC		lcd_a1
@@ -33,6 +33,6 @@
 #define	LCD_RD		lcd_a1
 
-#define	G_PLANE1	(uint16_t)0x0000
-#define	G_PLANE2	(uint16_t)0x2000
+#define	G_PLANE1	0x0000
+#define	G_PLANE2	0x2000
 
 #define	G_OFF		0		/* off */
Index: include/instdsp.h
===================================================================
--- include/instdsp.h	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ include/instdsp.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -110,6 +110,6 @@
 
 	struct	pflent	*nextpf;	/* next entry pointer */
-	uint16_t	pftrig;		/* trigger number */
-	uint16_t	pfvpval;	/* voice / parameter number */
+	int16_t		pftrig;		/* trigger number */
+	int16_t		pfvpval;	/* voice / parameter number */
 	int32_t		d1reg;		/* D1 register contents */
 	int32_t		d2reg;		/* D2 register contents */
Index: include/objdefs.h
===================================================================
--- include/objdefs.h	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ include/objdefs.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -19,5 +19,5 @@
 	int32_t		F_Res1;		/* Reserved area #1 */
 	int32_t		F_Res2;		/* Reserved area #2 -- text origin */
-	uint16_t	F_Res3;		/* Reserved area #3 -- flag word */
+	int16_t		F_Res3;		/* Reserved area #3 -- flag word */
 
 					/* data origin - long */
@@ -25,6 +25,6 @@
 };
 
-#define	F_R_C	0x601A		/* Magic for contiguous file */
-#define	F_R_D	0x601B		/* Magic for discontiguous file */
+#define	F_R_C	0x601Au		/* Magic for contiguous file */
+#define	F_R_D	0x601Bu		/* Magic for discontiguous file */
 
 struct SYMBOL {			/* Symbol table entry -- 14 bytes */
@@ -35,10 +35,10 @@
 };
 
-#define	S_Def	0x8000		/* Defined */
-#define	S_Equ	0x4000		/* Equated */
-#define	S_Glb	0x2000		/* Global */
-#define	S_Reg	0x1000		/* Equated register */
-#define	S_Ext	0x0800		/* External reference */
-#define	S_Data	0x0400		/* Data based relocatable */
-#define	S_Text	0x0200		/* Text based relocatable */
-#define	S_BSS	0x0100		/* BSS based relocatable */
+#define	S_Def	0x8000u		/* Defined */
+#define	S_Equ	0x4000u		/* Equated */
+#define	S_Glb	0x2000u		/* Global */
+#define	S_Reg	0x1000u		/* Equated register */
+#define	S_Ext	0x0800u		/* External reference */
+#define	S_Data	0x0400u		/* Data based relocatable */
+#define	S_Text	0x0200u		/* Text based relocatable */
+#define	S_BSS	0x0100u		/* BSS based relocatable */
Index: include/smdefs.h
===================================================================
--- include/smdefs.h	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ include/smdefs.h	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -14,6 +14,6 @@
 	struct	sment	*nxt;
 	struct	sment	*prv;
-	uint16_t	vp;
-	uint16_t	sm;
+	int16_t		vp;
+	int16_t		sm;
 };
 
Index: libsm/memset.c
===================================================================
--- libsm/memset.c	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ libsm/memset.c	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -11,7 +11,7 @@
 #include "ram.h"
 
-void *memset(void *vp, int8_t c, int16_t n)
+void *memset(void *vp, uint8_t c, int16_t n)
 {
-	int8_t *cp = vp;
+	uint8_t *cp = vp;
 
 	while (--n >= 0)
Index: libsm/memset.x
===================================================================
--- libsm/memset.x	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ libsm/memset.x	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -15,3 +15,3 @@
 */
 
-extern	void		*memset(void *vp, int8_t c, int16_t n);
+extern	void		*memset(void *vp, uint8_t c, int16_t n);
Index: libsm/memsetw.c
===================================================================
--- libsm/memsetw.c	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ libsm/memsetw.c	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -11,7 +11,7 @@
 #include "ram.h"
 
-void *memsetw(void *vp, int16_t s, int16_t n)
+void *memsetw(void *vp, uint16_t s, int16_t n)
 {
-	int16_t *sp = vp;
+	uint16_t *sp = vp;
 
 	while (--n >= 0)
Index: libsm/memsetw.x
===================================================================
--- libsm/memsetw.x	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ libsm/memsetw.x	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -15,3 +15,3 @@
 */
 
-extern	void		*memsetw(void *vp, int16_t s, int16_t n);
+extern	void		*memsetw(void *vp, uint16_t s, int16_t n);
Index: vlib/glcinit.c
===================================================================
--- vlib/glcinit.c	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ vlib/glcinit.c	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -9,14 +9,10 @@
 		Initializes the GLC.
 
-	unsigned
 	GLCcrc(row, col)
-	unsigned row, col;
 
 		Positions the GLC cursor at ('row', 'col') preparatory
 		to writing text.  Returns the calculated cursor address.
 
-	unsigned
 	GLCcxy(x, y)
-	unsigned x, y;
 
 		Positions the GLC cursor at ('x', 'y') preparatory to
@@ -26,5 +22,4 @@
 
 	GLCwrts(s)
-	char *s;
 
 		Writes the character string pointed to by 's' at the
@@ -34,6 +29,4 @@
 
 	GLCtext(row, col, s)
-	unsigned row, col;
-	char *s;
 
 		Sets the GLC cursor to ('row', 'col'), then writes the
@@ -43,10 +36,8 @@
 
 	GLCdisp(dsp, crs, blk1, blk2, blk3)
-	short dsp, crs, blk1, blk2, blk3;
 
 		Sets the overall display, cursor and block status values.
 
 	GLCcurs(crs)
-	short crs;
 
 		Turns the cursor on or off.
@@ -56,18 +47,18 @@
 #include "ram.h"
 
-uint16_t	lcdbase;	/* LCD graphics base address */
-uint16_t	lcdbit;		/* LCD graphics pixel bit mask */
-uint16_t	lcdcol;		/* LCD text column */
-uint16_t	lcdctl1;	/* LCD display control -- command */
-uint16_t	lcdctl2;	/* LCD display control -- data */
-uint16_t	lcdcurs;	/* LCD graphics pixel byte address */
-uint16_t	lcdrow;		/* LCD text row */
-uint16_t	lcdx;		/* LCD graphics x */
-uint16_t	lcdy;		/* LCD graphics y */
+int32_t		lcdbase;	/* LCD graphics base address */
+int16_t		lcdbit;		/* LCD graphics pixel bit mask */
+int16_t		lcdcol;		/* LCD text column */
+int16_t		lcdctl1;	/* LCD display control -- command */
+int16_t		lcdctl2;	/* LCD display control -- data */
+int32_t		lcdcurs;	/* LCD graphics pixel byte address */
+int16_t		lcdrow;		/* LCD text row */
+int16_t		lcdx;		/* LCD graphics x */
+int16_t		lcdy;		/* LCD graphics y */
 
 /* GLC initialization values */
 
-int8_t glc_is1[] = { 0x12, 0x05, 0x07, 0x54, 0x58, 0x3F, 0x55, 0x00 };
-int8_t glc_is2[] = { 0x00, 0x00, 0x3F, 0x00, 0x20, 0x3F, 0x00, 0x00 };
+uint8_t glc_is1[] = { 0x12, 0x05, 0x07, 0x54, 0x58, 0x3F, 0x55, 0x00 };
+uint8_t glc_is2[] = { 0x00, 0x00, 0x3F, 0x00, 0x20, 0x3F, 0x00, 0x00 };
 
 /*
@@ -88,6 +79,6 @@
 	lcdctl2 = val;
 
-	LCD_WC = lcdctl1;
-	LCD_WD = lcdctl2;
+	LCD_WC = (uint8_t)lcdctl1;
+	LCD_WD = (uint8_t)lcdctl2;
 
 }
@@ -103,6 +94,6 @@
 	lcdctl2 = (crs & 3) | (lcdctl2 & ~3);
 
-	LCD_WC = lcdctl1;
-	LCD_WD = lcdctl2;
+	LCD_WC = (uint8_t)lcdctl1;
+	LCD_WD = (uint8_t)lcdctl2;
 }
 
@@ -118,5 +109,5 @@
 	register int16_t	i;
 	register int32_t ic;
-	register int8_t *gp;
+	register uint8_t *gp;
 
 	lcdbase = G_PLANE2;	/* set defaults for graphics variables */
@@ -135,5 +126,5 @@
 
 	for (i = 0; i < 8; i++)
-		LCD_WD= *gp++;
+		LCD_WD = *gp++;
 
 	LCD_WC = G_SETSAD;	/* setup scroll registers */
@@ -184,13 +175,13 @@
 */
 
-uint16_t GLCcrc(uint16_t row, uint16_t col)
-{
-	uint16_t curad;
+int16_t GLCcrc(int16_t row, int16_t col)
+{
+	int16_t curad;
 
 	curad = col + (row * 85);	/* calculate cursor location */
 
 	LCD_WC = G_CRSWR;		/* send cursor address to GLC */
-	LCD_WD = curad & 0xFF;
-	LCD_WD = (curad >> 8) & 0xFF;
+	LCD_WD = (uint8_t)(curad & 0xFF);
+	LCD_WD = (uint8_t)((curad >> 8) & 0xFF);
 
 	lcdrow = row;			/* set text cursor variables */
@@ -210,7 +201,7 @@
 */
 
-uint16_t GLCcxy(uint16_t x, uint16_t y)
-{
-	register uint16_t curad, xby6;
+int16_t GLCcxy(int16_t x, int16_t y)
+{
+	register int32_t curad, xby6;
 
 	/* calculate cursor address */
@@ -223,6 +214,6 @@
 
 	LCD_WC = G_CRSWR;
-	LCD_WD = curad & 0xFF;
-	LCD_WD = (curad >> 8) & 0xFF;
+	LCD_WD = (uint8_t)(curad & 0xFF);
+	LCD_WD = (uint8_t)((curad >> 8) & 0xFF);
 
 	/* set graphics variables */
@@ -256,5 +247,5 @@
 	while (*s) {		/* write string to GLC */
 
-		LCD_WD = *s++;
+		LCD_WD = (uint8_t)*s++;
 		lcdcol++;	/* keep column variable up to date */
 	}
@@ -271,13 +262,13 @@
 */
 
-void GLCtext(uint16_t row, uint16_t col, int8_t *s)
-{
-	register uint16_t curad;
+void GLCtext(int16_t row, int16_t col, int8_t *s)
+{
+	register int16_t curad;
 
 	curad = col + (row * 85);	/* calculate cursor address */
 
 	LCD_WC = G_CRSWR;		/* send cursor address to GLC */
-	LCD_WD = curad & 0xFF;
-	LCD_WD = (curad >> 8) & 0xFF;
+	LCD_WD = (uint8_t)(curad & 0xFF);
+	LCD_WD = (uint8_t)((curad >> 8) & 0xFF);
 
 	lcdrow = row;			/* set GLC text cursor variables */
@@ -290,5 +281,5 @@
 	while (*s) {			/* write string to GLC */
 
-		LCD_WD = *s++;
+		LCD_WD = (uint8_t)*s++;
 		lcdcol++;		/* keep cursor column up to date */
 	}
Index: vlib/glcinit.x
===================================================================
--- vlib/glcinit.x	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ vlib/glcinit.x	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -15,15 +15,15 @@
 */
 
-extern	int8_t		glc_is1[];
-extern	int8_t		glc_is2[];
-extern	uint16_t	lcdbase;
-extern	uint16_t	lcdbit;
-extern	uint16_t	lcdcol;
-extern	uint16_t	lcdctl1;
-extern	uint16_t	lcdctl2;
-extern	uint16_t	lcdcurs;
-extern	uint16_t	lcdrow;
-extern	uint16_t	lcdx;
-extern	uint16_t	lcdy;
+extern	uint8_t		glc_is1[];
+extern	uint8_t		glc_is2[];
+extern	int32_t		lcdbase;
+extern	int16_t		lcdbit;
+extern	int16_t		lcdcol;
+extern	int16_t		lcdctl1;
+extern	int16_t		lcdctl2;
+extern	int32_t		lcdcurs;
+extern	int16_t		lcdrow;
+extern	int16_t		lcdx;
+extern	int16_t		lcdy;
 
 /*
@@ -33,9 +33,9 @@
 */
 
-extern	uint16_t	GLCcrc(uint16_t row, uint16_t col);
+extern	int16_t		GLCcrc(int16_t row, int16_t col);
 extern	void		GLCcurs(int16_t crs);
-extern	uint16_t	GLCcxy(uint16_t x, uint16_t y);
+extern	int16_t		GLCcxy(int16_t x, int16_t y);
 extern	void		GLCdisp(int16_t dsp, int16_t crs, int16_t blk1, int16_t blk2, int16_t blk3);
 extern	void		GLCinit(void);
-extern	void		GLCtext(uint16_t row, uint16_t col, int8_t *s);
+extern	void		GLCtext(int16_t row, int16_t col, int8_t *s);
 extern	void		GLCwrts(int8_t *s);
Index: vlib/vhinit.c
===================================================================
--- vlib/vhinit.c	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ vlib/vhinit.c	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -18,5 +18,5 @@
 #include "ram.h"
 
-#define	VREG(h,v)	((h<<10)|v)
+#define	VREG(h, v)	(h * 1024u + v)
 
 struct octent	v_obtab[16];	/* object control table */
@@ -29,5 +29,5 @@
 /* initialized variables */
 
-int16_t	vr_data[] = {
+uint16_t	vr_data[] = {
 
 	0x825B,		/* R0  -- Mode word 0 */
Index: vlib/vhinit.x
===================================================================
--- vlib/vhinit.x	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ vlib/vhinit.x	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -20,5 +20,5 @@
 extern	int16_t		v_obpri;
 extern	struct	octent	v_obtab[16];
-extern	int16_t		vr_data[];
+extern	uint16_t	vr_data[];
 
 /*
Index: vlib/vmput.c
===================================================================
--- vlib/vmput.c	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ vlib/vmput.c	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -23,9 +23,9 @@
 	tr = row;
 
-	while (cp = *ms++) {
+	while ((cp = *ms++)) {
 
 		tc = col;
 
-		while (c = *cp++)
+		while ((c = *cp++))
 			vputc(obase, tr, tc++, c, ma);
 
@@ -49,10 +49,10 @@
 	tr = row;
 
-	while (cp = *ms++) {
+	while ((cp = *ms++)) {
 
 		tc = col;
 		tm = *ma++;
 
-		while (c = *cp++)
+		while ((c = *cp++))
 			vputc(obase, tr, tc++, c, *tm++);
 
Index: vlib/vobjfns.c
===================================================================
--- vlib/vobjfns.c	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ vlib/vobjfns.c	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -6,16 +6,12 @@
 
 	SelObj(obj)
-	int obj;
 
 		Select 'obj' as the current working object.
 
 	SetPri(obj, pri)
-	int obj, pri;
 
 		Display object 'obj' with priority 'pri'.
 
 	SetObj(obj, type, bank, base, xpix, ypix, x0, y0, flags, pri)
-	int obj, type, bank, xpix, ypix, x0, y0, flags, pri;
-	unsigned int *base;
 
 		Setup object 'obj' of type 'type' at 'base' in bank 'bank'
@@ -27,6 +23,4 @@
 
 	CpyObj(from, to, w, h, sw)
-	unsigned int *from, *to;
-	int w, h, sw;
 
 		Copy a 'w'-word by 'h'-line object from 'from' to 'to' with
@@ -51,4 +45,6 @@
 #include "ram.h"
 
+typedef		void	(**intvec)(void);
+
 int16_t		wsize;		/* object width calculated by SetObj() */
 int16_t		vi_dis;		/* disable use of VIint */
@@ -96,9 +92,9 @@
 
 	op = &v_obtab[obj];		/* point at the object table */
-	op->opri = pri;			/* set the priority */
+	op->opri = (int8_t)pri;		/* set the priority */
 
 	v_odtab[pri][0] = op->odtw0 | V_BLA;	/* start object as blanked */
 	v_odtab[pri][1] = op->odtw1;
-	v_odtab[pri][2] = ((int32_t)op->obase >> 1) & 0xFFFF;
+	v_odtab[pri][2] = (uint16_t)(((int32_t)op->obase >> 1) & 0xFFFF);
 
 	objon(pri, op->objy, op->ysize);	/* enable access table bits */
@@ -111,5 +107,5 @@
 	vi_ctl |= (1u << pri);			/* set unblank bit */
 
-	if (*((int32_t *)0x000064) NE &VIint)	/* make sure VI vector is set */
+	if (*(intvec)0x000064 NE &VIint)	/* make sure VI vector is set */
 		BIOS(B_SETV, 25, VIint);
 
@@ -142,5 +138,5 @@
 	op->objy = y0;
 	op->obase = base;
-	op->opri = pri;
+	op->opri = (int8_t)pri;
 	op->obank = bank & 3;
 
Index: vlib/vputs.c
===================================================================
--- vlib/vputs.c	(revision 09d13458eaf73781ea49a7ff93d5b5297fa74f9b)
+++ vlib/vputs.c	(revision bf89cfbcf78fe3cb5c96d5d735872139aa14889a)
@@ -27,5 +27,5 @@
 	int16_t	c;
 
-	while (c = *str++) {
+	while ((c = *str++)) {
 
 		vputc(obase, row, col, c, attr);
@@ -54,5 +54,5 @@
 	int16_t	c;
 
-	while (c = *str++) {
+	while ((c = *str++)) {
 
 		vputc(obase, row, col, c, *attr++);
