From c7ae7cd0460c247860178af759be514bf514e02f Mon Sep 17 00:00:00 2001
From: sparky4 <sparky4@cock.li>
Date: Tue, 14 Feb 2017 11:47:34 -0600
Subject: [PATCH] wwww reverted because zcroll broke

---
 src/lib/16_vl.c    | 17 +++--------------
 src/lib/16_vlpal.c | 12 ++++++------
 2 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c
index 881239de..71c5667d 100755
--- a/src/lib/16_vl.c
+++ b/src/lib/16_vl.c
@@ -689,18 +689,7 @@ modexLoadPalFile(byte *filename, byte **palette) {
 
 void VL_LoadPalFile(const char *filename, byte *palette)
 {
-	int fd;
-
-	fd = open(filename,O_RDONLY|O_BINARY);
-	if (fd >= 0) {
-		word i;
-
-		read(fd,palette,	PAL_SIZE);
-		close(fd);
-
-		vga_palette_lseek(0);
-		for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2);
-	}
+	VL_LoadPalFilewithoffset(filename, palette, 0);
 }
 
 void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o)
@@ -714,8 +703,8 @@ void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o)
 		read(fd,palette,	PAL_SIZE);
 		close(fd);
 
-		vga_palette_lseek(o);
-		for (i=o;i < 256-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2);
+		vga_palette_lseek(1+o);
+		for (i=o;i < 255-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2);
 	}
 }
 
diff --git a/src/lib/16_vlpal.c b/src/lib/16_vlpal.c
index 2f155f03..3a809828 100755
--- a/src/lib/16_vlpal.c
+++ b/src/lib/16_vlpal.c
@@ -32,7 +32,7 @@ void modexchkcolor(imgtestpal_t *bmp, word *q, word *a, word *aa, word *z, word
 		modexPalSave(pal);
 		CHKCOLDBGOUT1
 		//check palette for dups
-		for(; (*z)<PAL_SIZE; (*z)+=3)
+		for(; (*z)<PAL_SIZE-3; (*z)+=3)
 		{
 			CHKCOLDBGOUT2
 			//if((*z)%3==0)
@@ -99,7 +99,7 @@ VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset)
 	word w=0;
 	word q=0;
 	word qq=0;
-	static word a[PAL_SIZE];	//palette array of change values!
+	static word a[PAL_SIZE-3];	//palette array of change values!
 	word z=0, aq=0, aa=0, pp=0;
 
 	//modexWaitBorder();
@@ -107,7 +107,7 @@ VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset)
 	if((*i)==0)
 	{
 		memset(a, -1, sizeof(a));
-		outp(PAL_WRITE_REG, 0);  /* start at the beginning of palette */
+		outp(PAL_WRITE_REG, 1);  /* start at the beginning of palette */
 	}
 	else if(qp==0)
 	{
@@ -122,11 +122,11 @@ VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset)
 		printf("qq: %02d\n", (qq));//
 		printf("	  (*i)-q=%02d\n", (*i)-q);//
 #endif
-		outp(PAL_WRITE_REG, qq);  /* start at the beginning of palette */
+		outp(PAL_WRITE_REG, qq);
 	}
-	if((*i)<PAL_SIZE && w==0)
+	if((*i)<PAL_SIZE-3 && w==0)
 	{
-		for(; (*i)<PAL_SIZE; (*i)++)
+		for(; (*i)<PAL_SIZE-3; (*i)++)
 		{
 			//if(i%3==0 && (p[i+5]==p[i+4] && p[i+4]==p[i+3] && p[i+3]==p[i+2] && p[i+2]==p[i+1] && p[i+1]==p[i] && p[i+5]==p[i]))
 //____		  if((qp>0)&&((*i)-q)%3==0 && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) outp(PAL_DATA_REG, p[(*i)-q]); else
-- 
2.39.5