From: sparky4 <sparky4@cock.li>
Date: Thu, 13 Apr 2017 16:26:32 +0000 (-0500)
Subject: p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I... 
X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=23c4d02d9d36e5c5aa030fa5d1413d1558fc8af0;p=16.git

p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I should remember what needs to be done soon][OpenVGMFile needs to be ported to 16_snd.c]going to port rest of code to borland c some time so we can use the core components of id engine here [going to add 16_us.c eventually but the debug system and CA_ PM_ and MM_ usage is priority now]older zcroll renamed to xcroll][zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM] MM_ShowMemory is quite buggy on real machines. i need to debug it and fix added a struct printer[gvar.mm is FUCKING HUGE 14402 bytes FAT\!]16_rf now compiles BT UNKNOWN ON WHAT IT DOSE\! text box creates a ghost because page 1 do not have bg info thus it is stored and saved.... wwww fizzfade being worked on
---

diff --git a/NO_NAME.GIF b/NO_NAME.GIF
new file mode 100755
index 00000000..a2bb4e90
Binary files /dev/null and b/NO_NAME.GIF differ
diff --git a/data/16.pal b/data/16.pal
index f05da004..2fbadd3e 100755
Binary files a/data/16.pal and b/data/16.pal differ
diff --git a/data/G.PAL b/data/G.PAL
index eb359e82..9e8a2ed5 100755
Binary files a/data/G.PAL and b/data/G.PAL differ
diff --git a/makefile b/makefile
index e8658adb..f8c1871e 100755
--- a/makefile
+++ b/makefile
@@ -250,7 +250,7 @@ testexec: $(EXEC) $(TESTEXEC2)
 # game and bakapi executables
 #
 16.exe:		16.$(OBJ) $(16LIB) gfx.lib $(DOSLIB)
-bakapi.exe:		bakapi.$(OBJ) gfx.lib $(DOSLIB) 16_wcpu.$(OBJ)
+bakapi.exe:		bakapi.$(OBJ) 16_vl.$(OBJ) 16_vl_1.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) $(DOSLIB) 16_wcpu.$(OBJ)# gfx.lib
 
 #
 # Test Executables!
diff --git a/src/0.c b/src/0.c
index fff125c4..b3548620 100755
--- a/src/0.c
+++ b/src/0.c
@@ -100,7 +100,7 @@ int main(int argc,char **argv)
 	VL_modexPalScramble(gvar.video.palette);
 
 	/* load color palette */
-	VL_LoadPalFile(bakapee2, &gvar.video.palette);
+	VL_LoadPalFile(bakapee2, &gvar.video.palette, &gvar);
 
 	/* preprocess the sprite to generate line offsets */
 	vrl_lineoffs = vrl1_vgax_genlineoffsets(vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));
diff --git a/src/bakapi.c b/src/bakapi.c
index 452bc717..3a9c7469 100755
--- a/src/bakapi.c
+++ b/src/bakapi.c
@@ -35,11 +35,14 @@ void
 main(int argc, char *argvar[])
 {
 	static global_game_variables_t gvar;
+	struct glob_game_vars	*ggvv;
 	char *a;
 	int i;
 	word panq=1, pand=0;
 	boolean panswitch=0;
 
+	ggvv=&gvar;
+
 	// allow changing default mode from command line
 	for (i=1;i < argc;) {
 		a = argvar[i++];
@@ -126,12 +129,23 @@ main(int argc, char *argvar[])
 
 	/* setup camera and screen~ */
 	gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
+	gvar.video.page[1] = modexNextPage(&gvar.video.page[0]);
 
 	//modexPalUpdate(bmp.palette); //____
 	//modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
 	//getch(); //____
 
 	VL_ShowPage(&gvar.video.page[0], 0, 0);
+	{
+		word w;
+		for(w=0;w<64000;w++)
+		{
+			ding(&gvar.video.page[1], &bakapee, 4);
+		}
+		if(!baka_FizzleFade (&gvar.video.page[1], &gvar.video.page[0], 70, true, &gvar))
+		modexprint(&gvar.video.page[0], gvar.video.page[0].sw/2, gvar.video.page[0].sh/2, 1, 0, 47, 0, 1, "bakapi ok");
+	}
+	while(!kbhit()){}
 
 // screen savers
 //#ifdef BOINK
@@ -148,8 +162,8 @@ main(int argc, char *argvar[])
 				}else c=getch();
 			}
 
-			if(!panswitch)	ding(&gvar.video.page[0], &bakapee, key);
-			else			ding(&gvar.video.page[0], &bakapee, 2);
+			if(!panswitch)	ding(&gvar.video.page[0], &bakapee, 2);
+			else			ding(&gvar.video.page[0], &bakapee, 9);
 			if(panswitch!=0)
 			{
 				//right movement
@@ -196,6 +210,24 @@ main(int argc, char *argvar[])
 						panq++;
 					} else { panq = 1; pand = 0; }
 				}
+				if((c==0x4d && pand == 0) || pand == 2)
+				{
+					if(pand == 0){ pand = 2; }
+					if(panq<=(TILEWH/(4)))
+					{
+						gvar.video.page[0].dx++;
+						VL_ShowPage(&gvar.video.page[0], 0, 0);
+						panq++;
+					} else { panq = 1; pand = 0; }
+				}
+				if(c==0x01+1)
+				{
+					VL_ShowPage(&gvar.video.page[0], 0, 0);
+				}
+				if(c==0x02+1)
+				{
+					VL_ShowPage(&gvar.video.page[1], 0, 0);
+				}
 				if(c==0x71 || c==0xb1 || c=='p')
 				{
 					//getch(); // eat keyboard input
@@ -279,6 +311,7 @@ pee:
 					key = c - '0';
 					VGAmodeX(vgamodex_mode, 0, &gvar);
 					gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
+					gvar.video.page[1] = modexNextPage(&gvar.video.page[1]);
 		// this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
 		// we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
 					VL_ShowPage(&gvar.video.page[0], 0, 0);
@@ -294,6 +327,7 @@ pee:
 				break;
 				default:
 					key=0;
+					clrscr();	//added to clear screen wwww
 				break;
 			}
 		}
diff --git a/src/bakapi.h b/src/bakapi.h
index cf9aa3fe..0795f6c7 100755
--- a/src/bakapi.h
+++ b/src/bakapi.h
@@ -19,9 +19,11 @@
  * Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
-
-#ifndef __BAKAPI_H_
-#define __BAKAPI_H_
+/*
+ * BAKAPEE!
+ */
+#ifndef __BAKAPI_H__
+#define __BAKAPI_H__
 
 #include "src/lib/bakapee.h"
 #include "src/lib/wcpu/16_wcpu.h"
@@ -29,4 +31,4 @@
 //project 16 testing define switch for veiwing the contents of the video memory --sparky4
 #define BOINK // what does this mean? --J.C.
 
-#endif /*__BAKAPI_H_*/
+#endif /*__BAKAPI_H__*/
diff --git a/src/exmmtest.c b/src/exmmtest.c
index 67343f1e..1a4cbe68 100755
--- a/src/exmmtest.c
+++ b/src/exmmtest.c
@@ -64,6 +64,8 @@
 
 ////////////////////////////////////////////////////////////////////////////
 //#ifdef __BORLANDC__
+void VL_Startup (global_game_variables_t *gvar){}
+void VL_Shutdown (global_game_variables_t *gvar){}
 void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
 {
 	printf("VGAmodeX dummy:\n	%Fp	%Fp	%Fp\n", &vq, &cmem, gv);
diff --git a/src/lib/16_tail.c b/src/lib/16_tail.c
index 638e7110..d664b28d 100755
--- a/src/lib/16_tail.c
+++ b/src/lib/16_tail.c
@@ -86,7 +86,7 @@ void Shutdown16(global_game_variables_t *gvar)
 	MM_Shutdown(gvar);
 #ifdef __WATCOMC__
 	if(gvar->video.VL_Started)
-		VGAmodeX(0, 1, gvar);
+		VL_Shutdown (gvar);//VGAmodeX(0, 1, gvar);
 #endif
 }
 
@@ -393,13 +393,13 @@ noxor:
 
 			if (rndval == 1)		// entire sequence has been completed
 			{
-//++++				VGABITMASK(255);
-//++++				VGAMAPMASK(15);
+				VGABITMASK(255);
+				VGAMAPMASK(15);
 				return;
 			}
 		}
 		frame++;
-//++++		while (TimeCount<frame){}	// don't go too fast
+		while (TimeCount<frame){}	// don't go too fast
 	} while (1);
 
 
diff --git a/src/lib/16_tail.h b/src/lib/16_tail.h
index 28864242..469c7a9f 100755
--- a/src/lib/16_tail.h
+++ b/src/lib/16_tail.h
@@ -84,6 +84,7 @@
 	if(gvar.in.inst->Keyboard[sc_P]){ modexpdump(&gvar.video.page[0]);					IN_UserInput(1, &gvar); } \
 	if(gvar.in.inst->Keyboard[sc_Y]){ dbg_delayanimation=!dbg_delayanimation;				IN_UserInput(1, &gvar); } \
 	if(gvar.in.inst->Keyboard[sc_Q]){ VL_modexPrintTextBox(&gvar);						IN_UserInput(1, &gvar); } \
+	if(gvar.in.inst->Keyboard[sc_W]){ VL_MemToScreen((byte __far *)&gvar, 64, 64, 16, 16, &gvar.video.ofs);	IN_UserInput(1, &gvar); } \
 	RFDEBUGFUNCTIONS
 //FIZZLEFADEFUNCTION
 
@@ -115,10 +116,10 @@
 	if(gvar.in.inst->Keyboard[sc_I]){ dbg_maptext=!dbg_maptext; IN_UserInput(1, &gvar); } \
 	if(gvar.in.inst->Keyboard[sc_PgDn]){ \
 		rotateR(gvar.video.palette, sizeof(gvar.video.palette)/sizeof(gvar.video.palette[0])); \
-		VL_UpdatePaletteWrite(&gvar.video.palette, 0);		IN_UserInput(1, &gvar); } \
+		VL_UpdatePaletteWrite(&gvar.video.palette, 0, &gvar);		IN_UserInput(1, &gvar); } \
 	if(gvar.in.inst->Keyboard[sc_PgUp]){ \
 		rotateL(gvar.video.palette, sizeof(gvar.video.palette)/sizeof(gvar.video.palette[0])); \
-		VL_UpdatePaletteWrite(&gvar.video.palette, 0);		IN_UserInput(1, &gvar); }
+		VL_UpdatePaletteWrite(&gvar.video.palette, 0, &gvar);		IN_UserInput(1, &gvar); }
 #ifdef __BORLANDC__
 #define PAL_WRITE_REG		   0x03C8   /* Color register, write address */
 #define PAL_DATA_REG			0x03C9   /* Color register, data port */
diff --git a/src/lib/16_tail_.c b/src/lib/16_tail_.c
index a21780c0..3ab26f0b 100755
--- a/src/lib/16_tail_.c
+++ b/src/lib/16_tail_.c
@@ -1,3 +1,28 @@
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
+ *
+ * This file is part of Project 16.
+ *
+ * Project 16 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Project 16 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+/*
+ * 16 tail library
+ */
+
 #include "src/lib/16_tail.h"
 
 void	TL_VidInit(global_game_variables_t *gvar)
@@ -38,7 +63,6 @@ void	TL_VidInit(global_game_variables_t *gvar)
 	// get old video mode
 	//in.h.ah = 0xf;
 	//int86(0x10, &in, &out);
-	if(!gvar->video.old_mode) gvar->video.old_mode = vgaGetMode();//out.h.al;
-	VL_LoadPalFileCore(gvar->video.palette);
+	if(!gvar->video.old_mode) gvar->video.old_mode = VL_vgaGetMode();//out.h.al;
 	gvar->video.VL_Initiated = 1;
 }
diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c
index 24e3342e..be84166c 100755
--- a/src/lib/16_vl.c
+++ b/src/lib/16_vl.c
@@ -30,10 +30,179 @@ byte far* VGA=(byte far*) 0xA0000000;   /* this points to video memory. */
 static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette);
 static byte tmppal[PAL_SIZE];
 
+//===========================================================================
+
+/*
+=======================
+=
+= VL_Startup
+=
+=======================
+*/
+
+void	VL_Startup (global_game_variables_t *gvar)
+{
+	__asm	cld;
+
+	VGAmodeX(1/*TODO other modes*/, 1, gvar);
+	VL_LoadPalFileCore(gvar->video.palette, gvar);
+	//Quit ("Improper video card!  If you really have a VGA card that I am not\ndetecting it!", gvar);
+}
+
+
+
+/*
+=======================
+=
+= VL_Shutdown
+=
+=======================
+*/
+
+void	VL_Shutdown (global_game_variables_t *gvar)
+{
+	VGAmodeX(0, 1, gvar);
+}
+
+/*
+=======================
+=
+= VL_SetVGAPlaneMode
+=
+=======================
+*/
+#if 0
+void	VL_SetVGAPlaneMode (global_game_variables_t *gvar)
+{
+	VL_vgaSetMode(VGA_256_COLOR_MODE);
+	VL_DePlaneVGA ();
+	VGAMAPMASK(15);
+	VL_SetLineWidth (40, &gvar->video.ofs);
+}
+#endif
+
+//===========================================================================
+
+/*
+=================
+=
+= VL_ClearVideo
+=
+= Fill the entire video buffer with a given color
+=
+=================
+*/
+
+void VL_ClearVideo (byte color)
+{
+	__asm {
+		mov	dx,GC_INDEX
+		mov	al,GC_MODE
+		out	dx,al
+		inc	dx
+		in	al,dx
+		and	al,0xfc				// write mode 0 to store directly to video
+		out	dx,al
+
+		mov	dx,SC_INDEX
+		mov	ax,SC_MAPMASK+15*256
+		out	dx,ax				// write through all four planes
+
+		mov	ax,SCREENSEG
+		mov	es,ax
+		mov	al,[color]
+		mov	ah,al
+		mov	cx,0x8000			// 0x8000 words, clearing 8 video bytes/word
+		xor	di,di
+		rep	stosw
+	}
+}
+
+/*
+=============================================================================
+
+			VGA REGISTER MANAGEMENT ROUTINES
+
+=============================================================================
+*/
+
+
+/*
+=================
+=
+= VL_DePlaneVGA
+=
+=================
+*/
+#if 0
+void VL_DePlaneVGA (void)
+{
+
+//
+// change CPU addressing to non linear mode
+//
+
+//
+// turn off chain 4 and odd/even
+//
+	outportb (SC_INDEX,SC_MEMMODE);
+	outportb (SC_INDEX+1,(inportb(SC_INDEX+1)&~8)|4);
+
+	outportb (SC_INDEX,SC_MAPMASK);		// leave this set throughought
+
+//
+// turn off odd/even and set write mode 0
+//
+	outportb (GC_INDEX,GC_MODE);
+	outportb (GC_INDEX+1,inportb(GC_INDEX+1)&~0x13);
+
+//
+// turn off chain
+//
+	outportb (GC_INDEX,GC_MISCELLANEOUS);
+	outportb (GC_INDEX+1,inportb(GC_INDEX+1)&~2);
+
+//
+// clear the entire buffer space, because int 10h only did 16 k / plane
+//
+	VL_ClearVideo (0);
+
+//
+// change CRTC scanning from doubleword to byte mode, allowing >64k scans
+//
+	outportb (CRTC_INDEX,CRTC_UNDERLINE);
+	outportb (CRTC_INDEX+1,inportb(CRTC_INDEX+1)&~0x40);
+
+	outportb (CRTC_INDEX,CRTC_MODE);
+	outportb (CRTC_INDEX+1,inportb(CRTC_INDEX+1)|0x40);
+}
+#endif
+//===========================================================================
+
+/*
+====================
+=
+= VL_SetSplitScreen
+=
+====================
+*/
+
+void VL_SetSplitScreen (int linenum)
+{
+	VL_WaitVBL (1);
+	linenum=linenum*2-1;
+	outportb (CRTC_INDEX,CRTC_LINECOMPARE);
+	outportb (CRTC_INDEX+1,linenum % 256);
+	outportb (CRTC_INDEX,CRTC_OVERFLOW);
+	outportb (CRTC_INDEX+1, 1+16*(linenum/256));
+	outportb (CRTC_INDEX,CRTC_MAXSCANLINE);
+	outportb (CRTC_INDEX+1,inportb(CRTC_INDEX+1) & (255-64));
+}
+
 /////////////////////////////////////////////////////////////////////////////
-//																														//
-// setvideo() - This function Manages the video modes												//
-//																														//
+//															//
+// setvideo() - This function Manages the video modes						//
+//															//
 /////////////////////////////////////////////////////////////////////////////
 void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
 {
@@ -60,22 +229,26 @@ void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
 			// get old video mode
 			//in.h.ah = 0xf;
 			//int86(0x10, &in, &out);
-			gv->video.old_mode = vgaGetMode();//out.h.al;
+			gv->video.old_mode = VL_vgaGetMode();//out.h.al;
 			// enter mode
 			modexEnter(vq, cmem, gv);
 		break;
 	}
 }
 
-static void
-vgaSetMode(byte mode)
+//---------------------------------------------------
+//
+// Use the bios to set the current video mode
+//
+
+/*static */void
+VL_vgaSetMode(byte mode)
 {
 	union REGS regs;
 
 	regs.h.ah = SET_MODE;
 	regs.h.al = mode;
 	int86(VIDEO_INT, &regs, &regs);
-  //int10_setmode(mode);
 }
 
 //---------------------------------------------------
@@ -83,8 +256,8 @@ vgaSetMode(byte mode)
 // Use the bios to get the current video mode
 //
 
-byte/*FIXME: why long? "long" is 32-bit datatype, VGA modes are 8-bit numbers. */
-vgaGetMode()
+byte
+VL_vgaGetMode(void)
 {
 	return int10_getmode();
 }
@@ -92,11 +265,11 @@ vgaGetMode()
 /* -========================= Entry  Points ==========================- */
 void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv)
 {
-	word i;
+	//word i;
 	struct vga_mode_params cm;
 	//int CRTParmCount;
 
-	vgaSetMode(VGA_256_COLOR_MODE);
+	VL_vgaSetMode(VGA_256_COLOR_MODE);
 	vga_enable_256color_modex();
 
 	update_state_from_vga();
@@ -158,27 +331,33 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv)
 	vga_state.vga_stride = cm.offset * 2;
 	vga_write_crtc_mode(&cm,0);
 
-	/* clear video memory */
+	// clear video memory //
 	switch (cmem)
 	{
-		case 1: {
-			/* clear video memory */
-			dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA;	  /* used for faster screen clearing */
+		case 1:
+		{
+#if 0
+			dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA;	  // used for faster screen clearing //
 			vga_write_sequencer(2/*map mask register*/,0xf/*all 4 planes*/);
 			for(i = 0;i < 0x4000; i++) ptr[i] = 0x0000; // 0x4000 x dword = 64KB
-			/* fix up the palette and everything */
-			modexPalBlack();	//reset the palette~
+			// fix up the palette and everything //
+			modexPalBlack();	//reset the palette~//
+#endif
+			//
+			// clear the entire buffer space, because int 10h only did 16 k / plane
+			//
+			VL_ClearVideo (0);
 		}
 		break;
 	}
-//	VL_SetLineWidth (cm.offset, &gv->video.ofs);
+	VL_SetLineWidth (cm.offset, &gv->video.ofs);
 	gv->video.VL_Started=1;
 }
 
-void
-modexLeave() {
-	/* VGAmodeX restores original mode and palette */
-	vgaSetMode(TEXT_MODE);
+void modexLeave(void)
+{
+	// VGAmodeX restores original mode and palette
+	VL_vgaSetMode(TEXT_MODE);
 }
 
 page_t
@@ -644,14 +823,15 @@ fadePalette(sbyte fade, sbyte start, word iter, byte *palette) {
 }
 
 
-/* save and load */
-void
-modexPalSave(byte *palette) {
+// save and load
+void modexPalSave(byte *palette)
+{
 	int  i;
 
-	outp(PAL_READ_REG, 0);	  /* start at palette entry 0 */
-	for(i=0; i<PAL_SIZE; i++) {
-	palette[i] = inp(PAL_DATA_REG); /* read the palette data */
+	outp(PAL_READ_REG, 0);			// start at palette entry 0
+	for(i=0; i<PAL_SIZE; i++)
+	{
+		palette[i] = inp(PAL_DATA_REG);	// read the palette data
 	}
 }
 
@@ -696,18 +876,18 @@ modexLoadPalFile(byte *filename, byte *palette) {
 	fclose(file);
 }
 
-void VL_LoadPalFile(const char *filename, byte *palette)
+void VL_LoadPalFile(const char *filename, byte *palette, global_game_variables_t *gvar)
 {
-	VL_LoadPalFilewithoffset(filename, palette, 8);
-	VL_LoadPalFileCore(palette);
+	VL_LoadPalFilewithoffset(filename, palette, 8, gvar);
+//	VL_LoadPalFileCore(palette);
 }
 
-void VL_LoadPalFileCore(byte *palette)
+void VL_LoadPalFileCore(byte *palette, global_game_variables_t *gvar)
 {
-	VL_LoadPalFilewithoffset("data/16.pal", palette, 0);
+	VL_LoadPalFilewithoffset("data/16.pal", palette, 0, gvar);
 }
 
-void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o)
+void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o, global_game_variables_t *gvar)
 {
 	int fd;
 
@@ -716,15 +896,24 @@ void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o)
 		read(fd,palette,	PAL_SIZE);
 		close(fd);
 
-		VL_UpdatePaletteWrite(palette, o);
+		VL_UpdatePaletteWrite(palette, o, gvar);
 	}
 }
 
-void VL_UpdatePaletteWrite(byte *palette, word o)
+void VL_UpdatePaletteWrite(byte *palette, word o, global_game_variables_t *gvar)
 {
 	word i;
 	vga_palette_lseek(/*1+*/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);
+	//for (i=o;i < 256-o;i++)
+	for (i=0;i < 256-o;i++)
+		vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2);
+
+	VL_PaletteSync(gvar);
+}
+
+void VL_PaletteSync(global_game_variables_t *gvar)
+{
+	modexPalSave(&gvar->video.palette);
 }
 
 void
@@ -1035,7 +1224,7 @@ void modexpdump(page_t *pee)
 		}
 	}
 }
-
+#if 0
 /////////////////////////////////////////////////////////////////////////////
 //																		 //
 // cls() - This clears the screen to the specified color, on the VGA or on //
@@ -1050,7 +1239,7 @@ void modexcls(page_t *page, byte color, byte *Where)
 	//_fmemset(VGA, color, 16000);
 	_fmemset(Where, color, page->stridew*page->height);
 }
-
+#endif
 //
 // pattern filler from joncampbell123's code
 //
diff --git a/src/lib/16_vl.h b/src/lib/16_vl.h
index 3cfa4347..a152cc35 100755
--- a/src/lib/16_vl.h
+++ b/src/lib/16_vl.h
@@ -151,21 +151,27 @@ extern byte far*  VGA;  /* The VGA Memory */
 //
 // VGA hardware routines
 //
-
-void VGAMAPMASK(byte x);
-void VGAWRITEMODE(byte x);
-void VGAREADMAP(byte x);
+void	VGAWRITEMODE(byte x),
+	VGAMAPMASK(byte x),
+	VGAREADMAP(byte x),
+	VGABITMASK(byte x);
 
 #define VW_Hlin(x,z,y,c,q)	VL_Hlin(x,y,(z)-(x)+1,c,q)
 #define VW_Vlin(y,z,x,c,q)	VL_Vlin(x,y,(z)-(y)+1,c,q)
 
 /* -============================ Functions =============================- */
 /* mode switching, page, and plane functions */
-void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv);
-void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv);
-byte vgaGetMode();
+void	VL_Startup (global_game_variables_t *gvar),
+	VL_Shutdown (global_game_variables_t *gvar),
+	VL_SetVGAPlaneMode (global_game_variables_t *gvar),
+	VL_ClearVideo (byte color),
+	VL_DePlaneVGA (),
+	VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv),
+	modexEnter(sword vq, boolean cmem, global_game_variables_t *gv);
+void VL_vgaSetMode(byte mode);
+byte VL_vgaGetMode(void);
 extern void TL_VidInit(global_game_variables_t *gvar);
-void modexLeave();
+void modexLeave(void);
 void modexsetBaseXMode();
 page_t modexDefaultPage(page_t *p);
 page_t modexNextPage(page_t *p);
@@ -192,10 +198,11 @@ void modexFlashOff(word fade, byte *palette);
 void modexPalSave(byte *palette);
 //byte *modexNewPal();
 void modexLoadPalFile(char *filename, byte *palette);
-void VL_LoadPalFile(const char *filename, byte *palette);
-void VL_LoadPalFileCore(byte *palette);
-void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o);
-void VL_UpdatePaletteWrite(byte *palette, word o);
+void VL_LoadPalFile(const char *filename, byte *palette, global_game_variables_t *gvar);
+void VL_LoadPalFileCore(byte *palette, global_game_variables_t *gvar);
+void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o, global_game_variables_t *gvar);
+void VL_UpdatePaletteWrite(byte *palette, word o, global_game_variables_t *gvar);
+void VL_PaletteSync(global_game_variables_t *gvar);
 void modexSavePalFile(char *filename, byte *palette);
 #define MenuFadeIn()	VL_FadeIn(0,255,&gamepal,10)
 
@@ -211,6 +218,7 @@ void VL_Plot (int x, int y, int color, ofs_t *ofs);
 void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs);
 void VL_Vlin (int x, int y, int height, int color, ofs_t *ofs);
 void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs);
+void VL_MemToScreen (byte far *source, int width, int height, int x, int y, ofs_t *ofs);
 void modexputPixel(page_t *page, int x, int y, byte color);
 byte modexgetPixel(page_t *page, int x, int y);
 
@@ -245,7 +253,6 @@ void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col,
 void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str);
 void VL_modexPrintTextBox(global_game_variables_t *gvar);
 void modexpdump(page_t *pee);
-void modexcls(page_t *page, byte color, byte *Where);
 void VL_PatternDraw(video_t *video, word pn, boolean sw, boolean allsw);
 void modexWaitBorder();
 void modexWaitBorder_start();
diff --git a/src/lib/16_vl_1.c b/src/lib/16_vl_1.c
index 31c9f38e..7332d5fb 100755
--- a/src/lib/16_vl_1.c
+++ b/src/lib/16_vl_1.c
@@ -3,19 +3,19 @@
  *
  * This file is part of Project 16.
  *
- * Project 16 is free software; you can redistribute it and/or modify
+ * Project 16 is free software; you can redistribute it and/or	modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
- * Project 16 is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * Project 16 is distributed in	the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without	even the implied warranty of
+ * MERCHANTABILITY or	FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for	more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
- * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * write to the Free Software Foundation, Inc., 51 Franklin	Street,
  * Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
@@ -46,7 +46,7 @@ void	VL_SetScreen (unsigned int crtc, int pelpan)
 
 		mov	dx,STATUS_REGISTER_1
 
-	// wait for a display signal to make sure the raster isn't in the middle
+	// wait for	a display signal to make sure the raster isn't in	the middle
 	// of a sync
 
 #ifdef __BORLANDC__
@@ -121,7 +121,7 @@ SetScreen_setcrtc:
 	__asm {
 #endif
 	// set CRTC start
-	// for some reason, my XT's EGA card doesn't like word outs to the CRTC index...
+	// for	some reason, my XT's EGA card doesn't like word outs to the CRTC index...
 
 		mov	cx,[crtc]
 		mov	dx,CRTC_INDEX
@@ -141,7 +141,7 @@ SetScreen_setcrtc:
 	// set horizontal panning
 
 		mov	dx,ATR_INDEX
-//		mov	al,ATR_PELPAN or 20h
+//		mov	al,ATR_PELPAN or	20h
 		out	dx,al
 		jmp	SetScreen_done
 		mov	al,[BYTE PTR pelpan]		//pel pan value
@@ -164,7 +164,7 @@ SetScreen_done:
 =
 = VL_SetLineWidth
 =
-= Line witdh is in WORDS, 40 words is normal width for vgaplanegr
+= Line witdh is in	WORDS, 40 words is normal width for	vgaplanegr
 =
 ====================
 */
@@ -185,7 +185,7 @@ void VL_SetLineWidth (unsigned width, ofs_t *ofs)
 
 	offset = 0;
 
-	for (i=0;i<MAXSCANLINES;i++)
+	for	(i=0;i<MAXSCANLINES;i++)
 	{
 		ofs->ylookup[i]=offset;
 		offset += ofs->linewidth;
@@ -216,7 +216,7 @@ void VL_FillPalette (int red, int green, int blue)
 	int	i;
 
 	outportb (PAL_WRITE_REG,0);
-	for (i=0;i<256;i++)
+	for	(i=0;i<256;i++)
 	{
 		outportb (PAL_DATA_REG,red);
 		outportb (PAL_DATA_REG,green);
@@ -280,7 +280,7 @@ void VL_SetPalette (byte far *palette, video_t *v)
 	fastpalette=v->fastpalette;
 
 //	outportb (PAL_WRITE_REG,0);
-//	for (i=0;i<768;i++)
+//	for	(i=0;i<768;i++)
 //		outportb(PAL_DATA_REG,*palette++);
 
 	__asm {
@@ -293,14 +293,14 @@ void VL_SetPalette (byte far *palette, video_t *v)
 		test	[ss:fastpalette],1
 		jz	slowset
 //
-// set palette fast for cards that can take it
+// set palette fast for	cards that can take it
 //
 		//mov	cx,768
 		//rep outsb
 		//jmp	done
 
 //
-// set palette slowly for some video cards
+// set palette slowly for	some video cards
 //
 #ifdef __BORLANDC__
 	}
@@ -356,7 +356,7 @@ void VL_GetPalette (byte far *palette)
 	int	i;
 
 	outportb (PAL_READ_REG,0);
-	for (i=0;i<768;i++)
+	for	(i=0;i<768;i++)
 		*palette++ = inportb(PAL_DATA_REG);
 }
 
@@ -368,7 +368,7 @@ void VL_GetPalette (byte far *palette)
 =
 = VL_FadeOut
 =
-= Fades the current palette to the given color in the given number of steps
+= Fades the current palette to the given color	in	the given number of steps
 =
 =================
 */
@@ -385,11 +385,11 @@ void VL_FadeOut (int start, int end, int red, int green, int blue, int steps, vi
 //
 // fade through intermediate frames
 //
-	for (i=0;i<steps;i++)
+	for	(i=0;i<steps;i++)
 	{
 		origptr = &v->palette1[start][0];
 		newptr = &v->palette2[start][0];
-		for (j=start;j<=end;j++)
+		for	(j=start;j<=end;j++)
 		{
 			orig = *origptr++;
 			delta = red-orig;
@@ -437,9 +437,9 @@ void VL_FadeIn (int start, int end, byte far *palette, int steps, video_t *v)
 //
 // fade through intermediate frames
 //
-	for (i=0;i<steps;i++)
+	for	(i=0;i<steps;i++)
 	{
-		for (j=start;j<=end;j++)
+		for	(j=start;j<=end;j++)
 		{
 			delta = palette[j]-v->palette1[0][j];
 			v->palette2[0][j] = v->palette1[0][j] + delta * i / steps;
@@ -463,7 +463,7 @@ void VL_FadeIn (int start, int end, byte far *palette, int steps, video_t *v)
 =
 = VL_TestPaletteSet
 =
-= Sets the palette with outsb, then reads it in and compares
+= Sets the palette with outsb, then reads it in	and	compares
 = If it compares ok, fastpalette is set to true.
 =
 =================
@@ -473,7 +473,7 @@ void VL_TestPaletteSet (video_t *v)
 {
 	int	i;
 
-	for (i=0;i<768;i++)
+	for	(i=0;i<768;i++)
 		v->palette1[0][i] = i;
 
 	v->fastpalette = true;
@@ -522,7 +522,7 @@ void VL_Plot (int x, int y, int color, ofs_t *ofs)
 =================
 */
 
-void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs)
+void VL_Hlin	(unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs)
 {
 	unsigned		xbyte;
 	byte			far *dest;
@@ -540,7 +540,7 @@ void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs
 
 	if (midbytes<0)
 	{
-	// all in one byte
+	// all in	one byte
 		VGAMAPMASK(leftmask&rightmask);
 		*dest = color;
 		VGAMAPMASK(15);
@@ -569,7 +569,7 @@ void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs
 =================
 */
 
-void VL_Vlin (int x, int y, int height, int color, ofs_t *ofs)
+void VL_Vlin	(int x, int y, int height, int color, ofs_t *ofs)
 {
 	byte	far *dest,mask;
 	VCLIPDEF
@@ -614,7 +614,7 @@ void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)
 
 	if (midbytes<0)
 	{
-	// all in one byte
+	// all in	one byte
 		VGAMAPMASK(leftmask&rightmask);
 		while (height--)
 		{
@@ -643,13 +643,48 @@ void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)
 	VGAMAPMASK(15);
 }
 
+//==========================================================================
+
+/*
+=================
+=
+= VL_MemToScreen
+=
+= Draws a block of data to the screen.
+=
+=================
+*/
+
+void VL_MemToScreen (byte far *source, int width, int height, int x, int y, ofs_t *ofs)
+{
+	byte    far *screen,far *dest,mask;
+	int		plane;
+
+	width>>=2;
+	dest = MK_FP(SCREENSEG,ofs->bufferofs+ofs->ylookup[y]+(x>>2) );
+	mask = 1 << (x&3);
+
+	for	(plane = 0; plane<4; plane++)
+	{
+		VGAMAPMASK(mask);
+		mask <<= 1;
+		if (mask == 16)
+			mask = 1;
+
+		screen = dest;
+		for	(y=0;y<height;y++,screen+=ofs->linewidth,source+=width)
+			_fmemcpy (screen,source,width);
+	}
+}
+
+//==========================================================================
 
 /*
 ==============
 
  VL_WaitVBL			******** NEW *********
 
- Wait for the vertical retrace (returns before the actual vertical sync)
+ Wait for	the vertical retrace (returns before the actual vertical sync)
 
 ==============
 */
@@ -670,7 +705,7 @@ void VL_WaitVBL(word num)
 
 		mov	cx,[num]
 	//
-	// wait for a display signal to make sure the raster isn't in the middle
+	// wait for	a display signal to make sure the raster isn't in	the middle
 	// of a sync
 	//
 #ifdef __BORLANDC__
@@ -703,23 +738,49 @@ void VL_WaitVBL(word num)
 }
 
 //===========================================================================
+#if 0
+#define VGAWRITEMODE(x) asm{
+		cli
+		mov	dx,GC_INDEX
+		mov	al,GC_MODE
+		out	dx,al
+		inc	dx
+		in	al,dx
+		and	al,252
+		or	al,x
+		out	dx,al
+		sti
+}
 
-void VGAMAPMASK(byte x)
-{
-	__asm {
-//		cli
+#define VGAMAPMASK(x) asm{
+		cli
 		mov	dx,SC_INDEX
 		mov	al,SC_MAPMASK
 		mov	ah,x
 		out	dx,ax
-//		sti
-	}
+		sti
 }
 
+#define VGAREADMAP(x) asm{
+		cli
+		mov	dx,GC_INDEX
+		mov	al,GC_READMAP
+		mov	ah,x
+		out	dx,ax
+		sti
+}
+
+#define EGABITMASK(x) asm{
+		mov	dx,GC_INDEX
+		mov	ax,GC_BITMASK+256*x
+		out	dx,ax
+		sti
+}
+#endif
 void VGAWRITEMODE(byte x)
 {
 	__asm {
-//		cli
+		cli
 		mov	dx,GC_INDEX
 		mov	al,GC_MODE
 		out	dx,al
@@ -728,19 +789,42 @@ void VGAWRITEMODE(byte x)
 		and	al,252
 		or	al,x
 		out	dx,al
-//		sti
+		sti
+	}
+}
+
+void VGAMAPMASK(byte x)
+{
+	__asm {
+		cli
+		mov	dx,SC_INDEX
+		mov	al,SC_MAPMASK
+		mov	ah,x
+		out	dx,ax
+		sti
 	}
 }
 
 void VGAREADMAP(byte x)
 {
 	__asm {
-//		cli
+		cli
 		mov	dx,GC_INDEX
 		mov	al,GC_READMAP
 		mov	ah,x
 		out	dx,ax
-//		sti
+		sti
+	}
+}
+
+void VGABITMASK(byte x)
+{
+	word q = 256*x;
+	__asm {
+		mov	dx,GC_INDEX
+		mov	ax,GC_BITMASK+q
+		out	dx,ax
+		sti
 	}
 }
 
diff --git a/src/lib/bakapee.c b/src/lib/bakapee.c
index 389a8159..cf1dd904 100755
--- a/src/lib/bakapee.c
+++ b/src/lib/bakapee.c
@@ -22,6 +22,225 @@
 
 #include "src/lib/bakapee.h"
 
+struct glob_game_vars	*ggvv;
+//static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */
+char global_temp_status_text[512];
+char global_temp_status_text2[512];
+
+//==========================================================================
+
+/*
+===================
+=
+= FizzleFade
+=
+= returns true if aborted
+=
+===================
+*/
+
+//extern	ControlInfo	c;
+#define PIXPOSX			gvar->video.page[0].sw/2
+#define PIXPOSY			gvar->video.page[0].sh/2
+
+boolean baka_FizzleFade (page_t *source, page_t *dest, unsigned frames, boolean abortable, global_game_variables_t *gvar)
+{
+	dword		p,pixperframe;
+	unsigned	drawofs,pagedelta;
+	byte 		mask,maskb[8] = {1,2,4,8};
+	unsigned	x,y,frame		,esorig;
+	dword		rndval;
+//	word TimeCount = *clockw;
+	word screenseg = SCREENSEG;
+
+	pagedelta = (word)dest->sw*dest->sh;//(word)(source->data - dest->data);//(dest->data - source->data)
+	rndval = 1;	esorig = 0;
+	x = y = dest->dx;
+	pixperframe = 76800/(dword)frames;
+
+//	IN_StartAck ();
+
+//	VL_ShowPage(dest, 1, 0);
+//	VL_ShowPage(source, 1, 0);
+
+//	modexClearRegion(dest, 0, 0, (dest->width), (dest->height), 12);
+	modexClearRegion(source, 0, 0, (source->width), (source->height), 64);
+
+	__asm {
+		mov	[esorig],es
+	}
+//	TimeCount=
+	frame=0;
+	do	// while (1)
+	{
+sprintf(global_temp_status_text, "%u", frame);
+modexprint(dest, PIXPOSX, PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);
+		if (abortable && kbhit())//IN_CheckAck () )
+			return true;
+
+		__asm {
+			mov	es,[screenseg]
+		}
+
+		for (p=0;p<pixperframe;p++)
+		{
+			__asm {
+				//
+				// seperate random value into x/y pair
+				//
+				mov	ax,[WORD PTR rndval]
+				mov	dx,[WORD PTR rndval+2]
+				mov	bx,ax
+				dec	bl
+				mov	[BYTE PTR y],bl			// low 8 bits - 1 = y xoordinate
+				mov	bx,ax
+				mov	cx,dx
+				mov	[BYTE PTR x],ah			// next 9 bits = x xoordinate
+				mov	[BYTE PTR x+1],dl
+				//
+				// advance to next random element
+				//
+				shr	dx,1
+				rcr	ax,1
+				jnc	noxor
+				xor	dx,0x0001
+				xor	ax,0x2000
+#ifdef __BORLANDC__
+			}
+#endif
+noxor:
+#ifdef __BORLANDC__
+			__asm {
+#endif
+				mov	[WORD PTR rndval],ax
+				mov	[WORD PTR rndval+2],dx
+			}
+
+			if (x>dest->sw || y>dest->sh)
+				continue;
+			drawofs = (word)(source->data)+gvar->video.ofs.ylookup[y] + (x>>2);
+sprintf(global_temp_status_text, "draw - %Fp", drawofs);
+modexprint(dest, PIXPOSX, 16+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);
+sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);
+modexprint(dest, PIXPOSX, 24+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);
+sprintf(global_temp_status_text, "srce - %Fp", source->data);
+modexprint(dest, PIXPOSX, 32+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);
+sprintf(global_temp_status_text, "dest - %Fp", dest->data);
+modexprint(dest, PIXPOSX, 40+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);
+
+			//
+			// copy one pixel
+			//
+			mask = x&3;
+			VGAREADMAP(mask);
+			mask = maskb[mask];
+			VGAMAPMASK(mask);
+
+			__asm {
+				mov	di,[drawofs]
+				mov	al,[es:di]
+				add	di,[pagedelta]
+				mov	[es:di],al
+			}
+
+			if (rndval == 1)		// entire sequence has been completed
+				return false;
+		}
+		frame++;
+//--		while (TimeCount<frame){}//;		// don't go too fast
+	} while (1);
+	__asm {
+		mov	es,[esorig]
+	}
+	return false;
+}
+#if 0
+boolean baka_FizzleFade (unsigned source, unsigned dest, unsigned width,unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)
+{
+	int			pixperframe;
+	unsigned	drawofs,pagedelta;
+	byte 		mask,maskb[8] = {1,2,4,8};
+	unsigned	x,y,p,frame;
+	dword		rndval;
+	word TimeCount = *clockw;
+	word screenseg = SCREENSEG;
+
+	pagedelta = dest-source;
+	rndval = 1;
+	x = y = 0;
+	pixperframe = 64000/frames;
+
+	VGAmodeX(0, 0, gvar);
+//	IN_StartAck ();
+//	VL_ShowPage((page_t *)dest, 1, 0);
+	VGAmodeX(1, 0, gvar);
+
+	TimeCount=frame=0;
+	do	// while (1)
+	{
+		if (abortable && !kbhit())//IN_CheckAck () )
+			return true;
+
+		__asm {
+			mov	es,[screenseg]
+		}
+
+		for (p=0;p<pixperframe;p++)
+		{
+			__asm {
+				//
+				// seperate random value into x/y pair
+				//
+					mov	ax,[WORD PTR rndval]
+					mov	dx,[WORD PTR rndval+2]
+					mov	bx,ax
+					dec	bl
+					mov	[BYTE PTR y],bl			// low 8 bits - 1 = y xoordinate
+					mov	bx,ax
+					mov	cx,dx
+					mov	[BYTE PTR x],ah			// next 9 bits = x xoordinate
+					mov	[BYTE PTR x+1],dl
+				//
+				// advance to next random element
+				//
+					shr	dx,1
+					rcr	ax,1
+					jnc	noxor
+					xor	dx,0x0001
+					xor	ax,0x2000
+noxor:
+					mov	[WORD PTR rndval],ax
+					mov	[WORD PTR rndval+2],dx
+			}
+
+			if (x>width || y>height)
+				continue;
+			drawofs = source+gvar->video.ofs.ylookup[y] + (x>>2);
+
+			//
+			// copy one pixel
+			//
+			mask = x&3;
+			VGAREADMAP(mask);
+			mask = maskb[mask];
+			VGAMAPMASK(mask);
+
+			__asm {
+				mov	di,[drawofs]
+				mov	al,[es:di]
+				add	di,[pagedelta]
+				mov	[es:di],al
+			}
+
+			if (rndval == 1)		// entire sequence has been completed
+				return false;
+		}
+		frame++;
+//		while (TimeCount<frame){}//;		// don't go too fast
+	} while (1);
+	return false;
+}
+#endif
 /* clrstdin() clear any leftover chars tha may be in stdin stream */
 void clrstdin()
 {
@@ -34,7 +253,8 @@ void colortest(page_t *page, bakapee_t *pee)
 {
 	//if(pee->coor < 256)
 	//{
-		modexcls(page, pee->coor, VGA);
+//		modexcls(page, pee->coor, VGA);
+		VL_ClearVideo (pee->coor);
 		pee->coor++;
 	//}else pee->coor = 0;
 }
@@ -44,7 +264,8 @@ void colorz(page_t *page, bakapee_t *pee)
 {
 	if(pee->coor <= pee->hgq)
 	{
-		modexcls(page, pee->coor, VGA);
+//		modexcls(page, pee->coor, VGA);
+		VL_ClearVideo (pee->coor);
 		pee->coor++;
 	}else pee->coor = pee->lgq;
 }
@@ -297,11 +518,9 @@ void ding(page_t *page, bakapee_t *pee, word q)
 			modexprint(page, page->sw/2, page->sh/2, 1, 0, 47, 0, 1, "bakapi");
 		break;
 		case 9:
-			if(pee->coor <= pee->hgq)
-			{
-				ssd(page, pee, q);
-				pee->coor++;
-			}else pee->coor = pee->lgq;
+			//baka_FizzleFade (ggvv->video.ofs.bufferofs, ggvv->video.ofs.displayofs, page->sw, page->sh, false, ggvv);
+//			modexprint(page, page->sw/2, page->sh/2, 1, 0, 47, 0, 1, "bakapi start");
+//			if(!baka_FizzleFade ((unsigned)page, (unsigned)page, page->width, page->height, 70, false, ggvv))
 		break;
 		case 10:
 			ssd(page, pee, q); /*printf("%d\n", pee->coor);*/
diff --git a/src/lib/bakapee.h b/src/lib/bakapee.h
index 06c5e705..08af061b 100755
--- a/src/lib/bakapee.h
+++ b/src/lib/bakapee.h
@@ -41,6 +41,7 @@ typedef struct {
 	word bonk,lgq,hgq;
 } bakapee_t;
 
+boolean baka_FizzleFade (page_t *source, page_t *dest, unsigned frames, boolean abortable, global_game_variables_t *gvar);
 void clrstdin();
 void colortest(page_t *page, bakapee_t *pee);
 void colorz(page_t *page, bakapee_t *pee);
diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c
index 94338ab7..4e9577bb 100755
--- a/src/lib/scroll16.c
+++ b/src/lib/scroll16.c
@@ -877,7 +877,7 @@ void shinku(global_game_variables_t *gv)
 				gv->video.page[/*!*/(gv->video.p)].dx,
 				gv->video.page[/*!*/(gv->video.p)].dy,
 				96, 16);
-			modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, 1, col, 1, bgcol, global_temp_status_text);
+			modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, 1, col, bgcol, 1, global_temp_status_text);
 //0000printf("dx=%u	dy=%u\n", gv->video.page[/*!*/(gv->video.p)].dx, gv->video.page[/*!*/(gv->video.p)].dy);
 		}
 #endif
diff --git a/src/palettel.c b/src/palettel.c
index 6b6840a7..3fdcf5a5 100755
--- a/src/palettel.c
+++ b/src/palettel.c
@@ -20,12 +20,13 @@
  *
  */
 #include "src/lib/16_vl.h"
-void main(int argc, char *argv[]) {
+void main(int argc, char *argv[])
+{
 	static global_game_variables_t gvar; word i;	char bakapee[64] = "data/16.pal";
 	if(argv[1]) strcpy(bakapee, argv[1]);// modexPalSave(&gvar.video.dpal); modexFadeOff(4, &gvar.video.dpal); modexPalBlack();
 
 	TL_VidInit(&gvar);	VGAmodeX(1, 0, &gvar);
-	VL_LoadPalFile(bakapee, &gvar.video.palette);		//modexLoadPalFile(bakapee, &(gvar.video.palette));
+	VL_LoadPalFile(bakapee, &gvar.video.palette, &gvar);		//modexLoadPalFile(bakapee, &(gvar.video.palette));
 	gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);// modexFadeOn(4, &gvar.video.palette);
 	VL_ShowPage(&gvar.video.page[0], 1, 0);
 	modexpdump(&gvar.video.page[0]);
diff --git a/src/vidtest.c b/src/vidtest.c
index 94f27493..69d0ec3a 100755
--- a/src/vidtest.c
+++ b/src/vidtest.c
@@ -107,7 +107,7 @@ void main(int argc, char *argv[])
 	modexPalBlack();
 
 	/* load our palette */
-	VL_LoadPalFile("data/16.pal", &gvar.video.palette);
+	VL_LoadPalFile("data/16.pal", &gvar.video.palette, &gvar);
 	bmp1.offset=(paloffset/3);
 	VL_palette(&bmp1, &gvar.video.palette, &paloffset, 0, 0, &gvar);
 
diff --git a/src/vrstest.c b/src/vrstest.c
index 3a59112d..517d2c82 100755
--- a/src/vrstest.c
+++ b/src/vrstest.c
@@ -122,7 +122,7 @@ void main()
 	/*modexLoadPalFile("data/spri/chikyuu.pal", &pal);
 	modexPalUpdate(pal);*/
 	//modexClearRegion(&gvar.video.page[0], 0, 0, gvar.video.page[0].width, gvar.video.page[0].height, 2);
-	VL_LoadPalFile("data/spri/chikyuu.pal", &gvar.video.palette);
+	VL_LoadPalFile("data/spri/chikyuu.pal", &gvar.video.palette, &gvar);
 	for (i = 0; i < 10; i++){
 		enti.spri.delay = 1;
 
diff --git a/src/xcroll.c b/src/xcroll.c
index 1b42f8f0..7b97a9af 100755
--- a/src/xcroll.c
+++ b/src/xcroll.c
@@ -108,7 +108,8 @@ void main(int argc, char *argv[])
 	modexPalBlack();
 #endif
 
-	VGAmodeX(1/*bakapee*/, 1, &gvar);
+	//--VGAmodeX(1/*bakapee*/, 1, &gvar);
+	VL_Startup(&gvar);
 
 	/* load color palette */
 	/*ptmp.offset=(paloffset/3);
@@ -118,7 +119,7 @@ void main(int argc, char *argv[])
 	//printf("1:	%d\n", paloffset);
 	map.tiles->data->offset=(paloffset/3);
 	modexPalUpdate(map.tiles->data, &paloffset, 0, 0);*/
-	VL_LoadPalFile(bakapee1p, &gvar.video.palette);
+	VL_LoadPalFile(bakapee1p, &gvar.video.palette, &gvar);
 	//VL_LoadPalFile("data/default.pal", &gvar.video.palette);
 
 #ifdef FADE
@@ -216,7 +217,7 @@ void main(int argc, char *argv[])
 			}
 			//read_vrs(&gvar, bakapee1, gvar.player[0].enti.spri->spritesheet);
 			VRS_ReadVRS(bakapee1, &gvar.player[0].enti, &gvar);
-			VL_LoadPalFile(bakapee1p, &gvar.video.palette);
+			VL_LoadPalFile(bakapee1p, &gvar.video.palette, &gvar);
 		}//JK
 #ifdef FADE
 		if(gvar.in.inst->Keyboard[10]){ modexPalOverscan(rand()%56); modexPalUpdate(gvar.video.dpal); IN_UserInput(1, &gvar); }