shithub: duke3d

Download patch

ref: d05dd072f746aeffb81e18dff76d07a29f8643b8
parent: 4c510b80e7330e4cb77b1b564483f1b5c3a2dd0f
author: unknown <fabien@fabien-PC.(none)>
date: Sat Dec 15 15:50:31 EST 2012

Fixed a bug introduced by the SlowDown tools

--- a/Engine/src/a.c
+++ b/Engine/src/a.c
@@ -9,7 +9,7 @@
 #include "build.h"
 #include "a.h"
 
-int pixelsAllowed;
+uint32_t pixelsAllowed = 10000000000;
 
 #define shrd(a,b,c) (((b)<<(32-(c))) | ((a)>>(c)))
 #define shld(a,b,c) (((b)>>(32-(c))) | ((a)<<(c)))
@@ -55,15 +55,15 @@
 
     while (count) {
 
-		if (pixelsAllowed <= 0)
-			return;
+		
+			
 
-		pixelsAllowed--;
 
 	    source = i5 >> shifter;
 	    source = shld(source,i4,bits);
 	    source = lookup[source];
-	    *dest = pal[shade|source];
+		if (pixelsAllowed-- > 0)
+			*dest = pal[shade|source];
 	    dest--;
 	    i5 -= _asm1;
 	    i4 -= _asm2;
@@ -97,11 +97,8 @@
     numPixels = i1;
     do {
 		
-		if (pixelsAllowed <= 0)
-			return;
+		
 
-		pixelsAllowed--;
-
 	    i3 = ((i3&0xffffff00)|(*((uint8_t *)i2)));
 	    i4 -= rmach_eax;
 	    ebp = (((i4+rmach_eax) < i4) ? -1 : 0);
@@ -110,7 +107,10 @@
 	    else i2 -= rmach_ecx;
 	    ebp &= rmach_esi;
 	    i1 = ((i1&0xffffff00)|(((uint8_t *)i3)[rmach_edx]));
-	    ((uint8_t *)rmach6b)[numPixels] = (i1&0xff);
+
+		if (pixelsAllowed-- > 0)
+			 ((uint8_t *)rmach6b)[numPixels] = (i1&0xff);
+
 	    i2 -= ebp;
 	    numPixels--;
     } while (numPixels);
@@ -142,11 +142,8 @@
     numPixels = i1;
     do {
 
-		if (pixelsAllowed <= 0)
-			return;
+	
 
-		pixelsAllowed--;
-
 	    i3 = ((i3&0xffffff00)|(*((uint8_t *)i2)));
 	    i4 -= rmmach_eax;
 	    ebp = (((i4+rmmach_eax) < i4) ? -1 : 0);
@@ -155,8 +152,11 @@
 	    else i2 -= rmmach_ecx;
 	    ebp &= rmmach_esi;
 	    if ((i3&0xff) != 255) {
-		    i1 = ((i1&0xffffff00)|(((uint8_t  *)i3)[rmmach_edx]));
-		    ((uint8_t  *)rmach6b)[numPixels] = (i1&0xff);
+			if (pixelsAllowed-- > 0)
+			{
+				i1 = ((i1&0xffffff00)|(((uint8_t  *)i3)[rmmach_edx]));
+				((uint8_t  *)rmach6b)[numPixels] = (i1&0xff);
+			}
 	    }
 	    i2 -= ebp;
 	    numPixels--;
@@ -186,17 +186,14 @@
     uint8_t  *source = (uint8_t  *)i5;
     uint8_t  *dest = (uint8_t  *)i6;
 
-	
-
     if (i3 == 0)
     {
 		if (!RENDER_DRAW_TOP_AND_BOTTOM_COLUMN)
 		return 0;
 
-		if (pixelsAllowed <= 0)
-			return;
+		
 
-		pixelsAllowed--;
+		
 
 	    i1 += i4;
         //FCS
@@ -203,7 +200,12 @@
         //((uint32_t)i4) >>= mach3_al;
         i4 = ((uint32_t)i4) >> mach3_al;
 	    i4 = (i4&0xffffff00) | (source[i4]&0xff);
-	    *dest = ((uint8_t *)i2)[i4];
+
+		if (pixelsAllowed-- > 0)
+			*dest = ((uint8_t *)i2)[i4];
+
+		
+
 	    return i1;
     } else {
 	    return vlineasm1(i1,i2,i3,i4,i5,i6);
@@ -223,18 +225,17 @@
     numPixels++;
     while (numPixels)
     {
-		if (pixelsAllowed <= 0)
-			return vplce;
+		
 
-		pixelsAllowed--;
 
-
 	    temp = ((unsigned)vplce) >> mach3_al;
         
 	    temp = ((uint8_t  *)bufplce)[temp];
       
-        *dest = ((uint8_t *)palookupoffse)[temp];
-	    vplce += vince;
+		if (pixelsAllowed-- > 0)
+			*dest = ((uint8_t *)palookupoffse)[temp];
+	    
+		vplce += vince;
 	    dest += fixchain;
 	    numPixels--;
     }
@@ -262,21 +263,16 @@
 		temp >>= transmach3_al;
 		temp = source[temp];
 
-		
-		if (pixelsAllowed <= 0)
-			return i4;
-
-		pixelsAllowed--;
-
-		
-
+	
 		if (temp != 255)
 		{
 			unsigned short val;
 			val = ((uint8_t  *)i2)[temp];
 			val |= ((*dest)<<8);
-			if (transrev) val = ((val>>8)|(val<<8));
-			*dest = ((uint8_t  *)tmach)[val];
+			if (transrev) 
+				val = ((val>>8)|(val<<8));
+			if (pixelsAllowed-- > 0)
+				*dest = ((uint8_t  *)tmach)[val];
 		}
 		i4 += i1;
 		dest += fixchain;
@@ -310,11 +306,7 @@
 	i6 -= asm2;
 
 	do {
-		if (pixelsAllowed <= 0)
-			return;
-
-		pixelsAllowed--;
-
+		
 		i1 = i5 >> tran2shr;
 		i2 = ebp >> tran2shr;
 		i5 += tran2inca;
@@ -326,17 +318,23 @@
 				unsigned short val;
 				val = ((uint8_t  *)tran2pal_ecx)[i4];
 				val |= (((uint8_t  *)i6)[tran2edi1]<<8);
-				if (transrev) val = ((val>>8)|(val<<8));
-				((uint8_t  *)i6)[tran2edi1] =
-					((uint8_t  *)tmach)[val];
+
+				if (transrev) 
+					val = ((val>>8)|(val<<8));
+
+				if (pixelsAllowed-- > 0)
+					((uint8_t  *)i6)[tran2edi1] = ((uint8_t  *)tmach)[val];
 			}
 		} else if (i4 == 255) { // skipdraw2
 			unsigned short val;
 			val = ((uint8_t  *)tran2pal_ebx)[i3];
 			val |= (((uint8_t  *)i6)[tran2edi]<<8);
-			if (transrev) val = ((val>>8)|(val<<8));
-			((uint8_t  *)i6)[tran2edi] =
-				((uint8_t  *)tmach)[val];
+
+			if (transrev) val = 
+				((val>>8)|(val<<8));
+
+			if (pixelsAllowed-- > 0)
+				((uint8_t  *)i6)[tran2edi] = ((uint8_t  *)tmach)[val];
 		} else {
 			unsigned short l = ((uint8_t  *)i6)[tran2edi]<<8;
 			unsigned short r = ((uint8_t  *)i6)[tran2edi1]<<8;
@@ -346,10 +344,12 @@
 				l = ((l>>8)|(l<<8));
 				r = ((r>>8)|(r<<8));
 			}
-			((uint8_t  *)i6)[tran2edi] =
-				((uint8_t  *)tmach)[l];
-			((uint8_t  *)i6)[tran2edi1] =
-				((uint8_t  *)tmach)[r];
+			if (pixelsAllowed-- > 0)
+			{
+				((uint8_t  *)i6)[tran2edi] =((uint8_t  *)tmach)[l];
+				((uint8_t  *)i6)[tran2edi1] =((uint8_t  *)tmach)[r];
+				pixelsAllowed--;
+			}
 		}
 		i6 += fixchain;
 	} while (i6 > i6 - fixchain);
@@ -368,19 +368,15 @@
 	// FIX_00087: 1024x768 mode being slow. Undone FIX_00070 and fixed font issue again
     for(;i3>=0;i3--)
     {
-		if (pixelsAllowed <= 0)
-			return vplce;
-
-		pixelsAllowed--;
-
-	    temp = ((unsigned)vplce) >> machmv;
+		temp = ((unsigned)vplce) >> machmv;
 	    temp = ((uint8_t  *)bufplce)[temp];
 
 	    if (temp != 255) 
 		{
+			if (pixelsAllowed-- > 0)
 			*dest = ((uint8_t *)palookupoffse)[temp];
-			pixelsAllowed--;
 		}
+
 	    vplce += vince;
 	    dest += fixchain;
     }
@@ -412,14 +408,11 @@
         do {
             for (i = 0; i < 4; i++)
             {
-				if (pixelsAllowed <= 0)
-			        return;
-
-		        pixelsAllowed--;
-
+				
         	    temp = ((unsigned)vplce[i]) >> mach3_al;
         	    temp = (((uint8_t *)(bufplce[i]))[temp]);
-        	    dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
+				if (pixelsAllowed-- > 0)
+        			dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
 	            vplce[i] += vince[i];
             }
             dest += fixchain;
@@ -448,15 +441,14 @@
 
         for (i = 0; i < 4; i++)
         {
-			if (pixelsAllowed == 0)
-			   continue;
-
-		    pixelsAllowed--;
-
+			
 	      temp = ((unsigned)vplce[i]) >> machmv;
 	      temp = (((uint8_t *)(bufplce[i]))[temp]);
 	      if (temp != 255)
-		      dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
+		  {
+			  if (pixelsAllowed-- > 0)
+				dest[index+i] = ((uint8_t *)(palookupoffse[i]))[temp];
+		  }
 	      vplce[i] += vince[i];
         }
         dest += fixchain;
@@ -496,11 +488,12 @@
 
 draw:
     i1 = (i1&0xffffff00) | (((uint8_t  *)spal_eax)[i1]&0xff);
-    *dest = i1;
 
-	if (pixelsAllowed <= 0) return;
-	pixelsAllowed--;
+	if (pixelsAllowed-- > 0)
+		*dest = i1;
 
+	
+
     dest += fixchain;
 
     i4 += smach_ecx;
@@ -509,7 +502,9 @@
     if (!((i4 - smach_ecx) > i4) && i4 != 0)
 	    goto setup;
 
-    if (i4 == 0) return;
+    if (i4 == 0) 
+		return;
+
     i2 += smach_eax;
     i1 = (i1&0xffffff00) | (*source&0xff);
 
@@ -552,12 +547,10 @@
     if ((i1&0xff) != 255)
     {
 	    i1 = (i1&0xffffff00) | (((uint8_t  *)spal_eax)[i1]&0xff);
-	    *dest = i1;
+		if (pixelsAllowed-- > 0)
+		  *dest = i1;
 
-		if (pixelsAllowed <= 0)
-			return;
-
-		pixelsAllowed--;
+	
     }
     dest += fixchain;
 
@@ -614,15 +607,14 @@
 					val = ((val>>8)|(val<<8));
 
 				i1 = ((uint8_t  *)tmach)[val];
-				*((uint8_t  *)i6) = (i1&0xff);
+
+				if (pixelsAllowed-- > 0)
+					*((uint8_t  *)i6) = (i1&0xff);
 			}
 			i6 += fixchain;
 		}
 
-		if (pixelsAllowed <= 0)
-			return;
-
-		pixelsAllowed--;
+		
 	}
 } 
 
@@ -653,18 +645,17 @@
 	    ebx = i2 >> mshift_al;
 	    ebx = shld (ebx, (unsigned)i5, mshift_bl);
 	    i1 = ((uint8_t  *)mmach_eax)[ebx];
-	    if ((i1&0xff) != 0xff)
-		    *((uint8_t  *)i6) = (((uint8_t *)mmach_asm3)[i1]);
 
+		if (pixelsAllowed-- > 0)
+			if ((i1&0xff) != 0xff)
+				*((uint8_t  *)i6) = (((uint8_t *)mmach_asm3)[i1]);
+
 	    i2 += mmach_asm1;
 	    i5 += mmach_asm2;
 	    i6++;
 	    counter--;
 
-		if (pixelsAllowed <= 0)
-			return;
-
-		pixelsAllowed--;
+		
     }
 }
 
@@ -706,8 +697,12 @@
 	    {
 		    unsigned short val = (((uint8_t *)tmach_asm3)[i1]);
 		    val |= (*((uint8_t  *)i6)<<8);
-		    if (transrev) val = ((val>>8)|(val<<8));
-		    *((uint8_t  *)i6) = (((uint8_t *)tmach)[val]);
+
+		    if (transrev) 
+				val = ((val>>8)|(val<<8));
+
+			if (pixelsAllowed-- > 0)
+			 *((uint8_t  *)i6) = (((uint8_t *)tmach)[val]);
 	    }
 
 	    i2 += tmach_asm1;
@@ -715,10 +710,7 @@
 	    i6++;
 	    counter--;
 
-		if (pixelsAllowed <= 0)
-			return;
-
-		pixelsAllowed--;
+		
     }
 } 
 
@@ -813,14 +805,14 @@
 		    i3 -= 4;
 		    eax = ((eax&0xffffff00)|(*((uint8_t  *)(ebx+edx))));
 		    ebx = esi;
-		    *((uint8_t  *)i1) = (eax&0xff);
+
+			if (pixelsAllowed-- > 0)
+				*((uint8_t  *)i1) = (eax&0xff);
+
 		    edx = edi;
 		    ecx = ((ecx&0xffffff00)|((ecx-1)&0xff));
 
-			if (pixelsAllowed <= 0)
-			return;
-
-			pixelsAllowed--;
+			
 	    }
 	    ebx = asm4;
 	    ebx -= 8;	// BITSOFPRECISIONPOW
--- a/Engine/src/display.h
+++ b/Engine/src/display.h
@@ -136,7 +136,7 @@
 void drawpixelses(int32_t offset, Uint32 pixelses);
 void drawpixel16(int32_t offset);
 void fillscreen16 (int32_t input1, int32_t input2, int32_t input3);
-void limitrate(void);
+
 void setactivepage(int32_t dapagenum);
 void clear2dscreen(void);
 void _updateScreenRect(int32_t x, int32_t y, int32_t w, int32_t h);
--- a/Engine/src/engine.c
+++ b/Engine/src/engine.c
@@ -2538,6 +2538,12 @@
     int32_t i, j, z, cz, fz, closest;
     short *shortptr1, *shortptr2;
 
+	// When visualizing the rendering process, part of the screen
+	// are not updated: In order to avoid the "ghost effect", we
+	// clear the framebuffer to black.
+	if (CLEAR_FRAMEBUFFER)
+		clear2dscreen();
+
 	pixelRenderable+=10;
 	if (pixelRenderable >= MAX_PIXEL_RENDERERED)
 		pixelRenderable =  0 ;
--- a/Engine/src/engine_protos.h
+++ b/Engine/src/engine_protos.h
@@ -76,7 +76,7 @@
 extern void _idle(void);
 extern void *_getVideoBase(void);
 extern void setactivepage(int32_t dapagenum);
-extern void limitrate(void);
+
 extern int inittimer(int);
 extern void uninittimer(void);
 extern void initkeys(void);
--- a/Engine/src/sdl_driver.c
+++ b/Engine/src/sdl_driver.c
@@ -1915,12 +1915,6 @@
 		// FIX_00085: Optimized Video driver. FPS increases by +20%.
         // SDL_Flip(surface);
 		SDL_UpdateRect(surface, 0, 0, 0, 0);
-
-		// When visualizing the rendering process, part of the screen
-		// are not updated: In order to avoid the "ghost effect", we
-		// clear the framebuffer to black.
-		if (CLEAR_FRAMEBUFFER)
-			SDL_FillRect(surface,0,0);
     }
 
 #ifdef USE_OPENGL
@@ -2279,17 +2273,6 @@
 	/* !!! Is this really still needed? - DDOI */
     /*fprintf(stderr, "%s, line %d; setactivepage(): STUB.\n", __FILE__, __LINE__);*/
 } /* setactivepage */
-
-void limitrate(void)
-{
-    /* this is a no-op in SDL. It was for buggy VGA cards in DOS. */
-} /* limitrate */
-
-
-
-
-
-
 
 //-------------------------------------------------------------------------------------------------
 //  TIMER
--- a/Game/src/duke3d.h
+++ b/Game/src/duke3d.h
@@ -127,8 +127,8 @@
 
 #define SCREENSHOTPATH "screenshots"
 
-// #define ONELEVELDEMO
 
+
 // #define TEN
 // #define BETA
 
@@ -306,8 +306,6 @@
 #define T4  hittype[i].temp_data[3]
 #define T5  hittype[i].temp_data[4]
 #define T6  hittype[i].temp_data[5]
-
-#define ESCESCAPE if(KB_KeyPressed( sc_Escape ) ) gameexit(" ");
 
 #define IFWITHIN(B,E) if((PN)>=(B) && (PN)<=(E))
 #define KILLIT(KX) {deletesprite(KX);goto BOLT;}
--- a/Game/src/funct.h
+++ b/Game/src/funct.h
@@ -372,8 +372,7 @@
 extern void FTA(short q,struct player_struct *p, int mode);
 //#line "game.c" 1668
 extern void showtwoscreens(void );
-//#line "game.c" 1691
-extern void binscreen(void );
+
 //#line "game.c" 1705
 extern void gameexit(char  *t);
 //#line "game.c" 1752
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -2335,14 +2335,25 @@
 	    ps[myconnectindex].palette = palette;
 	    for(i=0;i<64;i+=7) palto(0,0,0,i);
 	    KB_FlushKeyboardQueue();
+
 	    rotatesprite(0,0,65536L,0,3291,0,0,2+8+16+64, 0,0,xdim-1,ydim-1);
-	    nextpage(); for(i=63;i>0;i-=7) palto(0,0,0,i);
+
+	    nextpage(); 
+		for(i=63;i>0;i-=7) palto(0,0,0,i);
+
 	    while( !KB_KeyWaiting() ); // getpackets(); // Net already off. Trying to get packets here makes sporadic crash..
 	
-	    for(i=0;i<64;i+=7) palto(0,0,0,i);
+	    for(i=0;i<64;i+=7) 
+			palto(0,0,0,i);
+
 	    KB_FlushKeyboardQueue();
+
 	    rotatesprite(0,0,65536L,0,3290,0,0,2+8+16+64, 0,0,xdim-1,ydim-1);
-	    nextpage(); for(i=63;i>0;i-=7) palto(0,0,0,i);
+	    nextpage(); 
+		
+		for(i=63;i>0;i-=7) 
+			palto(0,0,0,i);
+
 	    while( !KB_KeyWaiting() ); // getpackets();
 	}
 	else if(PLUTOPAK)
@@ -2350,33 +2361,27 @@
 		setview(0,0,xdim-1,ydim-1);
 	    flushperms();
 	    ps[myconnectindex].palette = palette;
-	    for(i=0;i<64;i+=7) palto(0,0,0,i);
+
+	    for(i=0;i<64;i+=7) 
+			palto(0,0,0,i);
+
 	    KB_FlushKeyboardQueue();
+
 	    clearview(0L);
 	    rotatesprite(0,0,65536L,0,TENSCREEN,0,0,2+8+16+64, 0,0,xdim-1,ydim-1);
-	    nextpage(); for(i=63;i>0;i-=7) palto(0,0,0,i);
+	    nextpage();
+
+		for(i=63;i>0;i-=7) 
+			palto(0,0,0,i);
+
 	    totalclock = 0;
-	    while( !KB_KeyWaiting() /*&& totalclock < 2400*/); // getpackets();
-	// re-added --mk. This makes nice souvenirs!
+
+	    while( !KB_KeyWaiting() ); 
+	
 	}
 }
 
-void binscreen(void)
-{
-#ifdef PLATFORM_DOS
-    int32_t fil;
-	if (VOLUMEONE)
-	    fil = kopen4load("dukesw.bin",1);
-	else
-	    fil = kopen4load("duke3d.bin",1);
 
-	if(fil == -1) return;
-    kread(fil,(uint8_t  *)0xb8000,4000);
-    kclose(fil);
-#endif
-}
-
-
 void gameexit(char  *msg)
 {
     short i;
@@ -2415,15 +2420,6 @@
     if(playerswhenstarted > 1)
         uninitmultiplayers();  /* deinits network transport. */
 
-#ifdef ONELEVELDEMO
-    doorders();
-    // DDOI
-    //t = "You have been playing a ONE LEVEL demo of Duke Nukem 3D.";
-    strncpy(t, "You have been playing a ONE LEVEL demo of Duke Nukem 3D.", 256);
-    t[255] = 0;
-    // DDOI
-#endif
-
 // CTW - MODIFICATION
 /*  if( *t != 0 && *(t+1) != 'V' && *(t+1) != 'Y' && playonten == 0 )
         showtwoscreens();*/
@@ -2439,7 +2435,7 @@
     if(*t != 0)
     {
         setvmode(0x3);
-        binscreen();
+        
 // CTW - MODIFICATION
 /*      if(playonten == 0)
         {
@@ -3114,11 +3110,16 @@
 
  for(j=0;j<MAXSPRITES;j++)
  {
-  if(
-     sprite[j].picnum==1 &&
-     sprite[j].lotag==k &&
-     sprite[j].hitag==sprite[floor1].hitag
-    ) {floor2=j; ok++; break;}
+	  if(
+		 sprite[j].picnum==1 &&
+		 sprite[j].lotag==k &&
+		 sprite[j].hitag==sprite[floor1].hitag
+		) 
+	  {
+		  floor2=j; 
+		  ok++; 
+		  break;
+	  }
  }
 
 // if(ok==2) { Message("no floor2",RED); return; }
@@ -3213,9 +3214,6 @@
 
     p = &ps[snum];
 
-//    if(screencapt == 0 && (p->gm&MODE_MENU) && ( (current_menu/100) == 3 ) || (current_menu >= 1000 && current_menu < 2999 ) )
-  //      return;
-
     if(pub > 0)
     {
         if(ud.screen_size > 8) drawbackground();
@@ -6260,10 +6258,6 @@
 
                     case 2:  // dnscotty###
                     case 10: // skill#
-#ifdef ONELEVELDEMO
-    ps[myconnectindex].cheat_phase = 0;
-    break;
-#endif
 
                         if(k == 2)
                         {
@@ -7471,22 +7465,10 @@
         }
 }
 
-/*
-void cacheicon(void)
-{
-    if(cachecount > 0)
-    {
-        if( (ps[myconnectindex].gm&MODE_MENU) == 0 )
-            rotatesprite((320-7)<<16,(200-23)<<16,32768L,0,SPINNINGNUKEICON,0,0,2,windowx1,windowy1,windowx2,windowy2);
-        cachecount = 0;
-    }
-}
-       */
-
 void Logo(void)
 {
     short i,soundanm;
-
+	
     soundanm = 0;
 
     ready2send = 0;
@@ -7504,11 +7486,13 @@
 
 	if(ud.showcinematics && numplayers < 2)
 	{
+		////This plays the explosion from the nuclear sign at the beginning.
 		if(!VOLUMEONE)
 		{
 		    if(!KB_KeyWaiting() && nomorelogohack == 0)
 		    {
 		        getpackets();
+				
 		        playanm("logo.anm",5);
 		        palto(0,0,0,63);
 		        KB_FlushKeyboardQueue();
@@ -7518,20 +7502,30 @@
 		    nextpage();
 		}
 		
+		//MIDI start here
 		playmusic(&env_music_fn[0][0]);
 		
-	    for(i=0;i<64;i+=7) palto(0,0,0,i);
+	    for(i=0;i<64;i+=7) 
+			palto(0,0,0,i);
+
 	    ps[myconnectindex].palette = drealms;
+
 	    palto(0,0,0,63);
 	    rotatesprite(0,0,65536L,0,DREALMS,0,0,2+8+16+64, 0,0,xdim-1,ydim-1);
-	    nextpage(); for(i=63;i>0;i-=7) palto(0,0,0,i);
+	    nextpage(); 
+		for(i=63;i>0;i-=7) 
+			palto(0,0,0,i);
+
+
 	    totalclock = 0;
 	    while( totalclock < (120*7) && !KB_KeyWaiting() )
 	        getpackets();
 	
-	    for(i=0;i<64;i+=7) palto(0,0,0,i);
+	    for(i=0;i<64;i+=7) 
+			palto(0,0,0,i);
 	    clearview(0L);
 	    nextpage();
+
 	
 	    ps[myconnectindex].palette = titlepal;
 	    flushperms();
@@ -7541,6 +7535,7 @@
 	    for(i=63;i>0;i-=7) palto(0,0,0,i);
 	    totalclock = 0;
 	
+
 	    while(totalclock < (860+120) && !KB_KeyWaiting())
 	    {
 	        rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1);
@@ -7573,6 +7568,7 @@
 	
 			if(PLUTOPAK) // FIX_00064: Cinematics explosions were not right for 1.3/1.3d grp.
 			{
+				
 				if( totalclock >= 280 && totalclock < 395 )
 				{
 					rotatesprite(160<<16,(151)<<16,(410-totalclock)<<12,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1);
@@ -7667,9 +7663,6 @@
     CONSOLE_Term();
 }
 
-static uint8_t  todd[] = "Duke Nukem 3D(tm) Copyright 1989, 1996 Todd Replogle and 3D Realms Entertainment";
-static uint8_t  trees[] = "I want to make a game with trees";
-static uint8_t  sixteen[] = "16 Possible Dukes";
 
 /*
 ===================
@@ -8152,7 +8145,7 @@
 	int32 iScriptHandle;
 	int32_t filehandle;
 
-	uint8_t  HEAD[2048], HEAD2[2048], HEADA[2048];
+	
 	uint8_t  kbdKey;
 	uint8_t  *exe;
 
@@ -8289,53 +8282,11 @@
 
     copyprotect();
 
-    setvmode(0x03);
+    //setvmode(0x03);
 
-// This is needed for the icculus.org ported Build Engine.
-#if !PLATFORM_DOS
-    //get the config entry for fullscreen
 
-
-	// Are we trying to load a mod?
-	if(game_dir[0] != '\0')
-	{
-		//FILE *fp = NULL;
-		uint8_t  setupfilename[128];
-
-	   //Yes
-		sprintf(setupfilename, "%s\\%s", game_dir, SETUPFILENAME);	
-		iScriptHandle = SCRIPT_Load(setupfilename);
-	}else
-	{
-		iScriptHandle = SCRIPT_Load(SETUPFILENAME);
-	}
-
-    if(iScriptHandle != -1)
-    {
-		SCRIPT_GetNumber(iScriptHandle, "Screen Setup", "Fullscreen",&BFullScreen);
-        SCRIPT_Free(iScriptHandle);
-        iScriptHandle = -1;
-    }
-
     _platform_init(argc, argv, "Duke Nukem 3D", "Duke3D");
-#endif
 
-	
-
-    todd[0] = 'T';
-    sixteen[0] = 'D';
-    trees[0] = 'I';
-
-	sprintf(HEAD, "   Duke Nukem 3D Shareware v1.3\n");
-
-	if(PLUTOPAK)
-	sprintf(HEAD2, "   Duke Nukem 3D v1.4/1.5 Atomic Edition\n");
-	else
-	sprintf(HEAD2, "   Duke Nukem 3D Full Version 1.3d\n");
-
-	sprintf(HEADA, "   Duke Nukem 3D AUSSIE Shareware v1.3\n");
-	sprintf(HEADA, "   Duke Nukem 3D AUSSIE Full Version\n");
-
     totalmemory = Z_AvailHeap();
 
     if(memorycheckoveride == 0)
@@ -8352,28 +8303,8 @@
     else
         printf("Using %ld bytes for heap.\n",totalmemory);
 
-#ifndef ONELEVELDEMO
-// CTW - REMOVED
-/*  if(movesperpacket == 4)
-        TENtext();*/
-// CTW END - REMOVED
-#endif
-
     RegisterShutdownFunction( ShutDown );
 
-#ifdef ONELEVELDEMO
-    puts("DUKE NUKEM 3D SINGLE-LEVEL PROMOTIONAL EDITION\n");
-    puts("This single-level promotional edition of Duke Nukem 3D (tm) may not be");
-    puts("distributed domestically (North America) by any publication other than");
-    puts("Computer Gaming World, a Ziff-Davis publication.  It is a promotional");
-    puts("version, licensed for a single month's run, and may not be redistributed");
-    puts("by any online service, BBS, commercial publisher, magazine or distributor.");
-    puts("International distribution rights are reserved.\n");
-    puts("Please read LICENSE.DOC for further information about this special version.");
-    puts("NOTE: DUKE NUKEM 3D CONTAINS MATURE CONTENT.\n");
-    puts("Press any key to continue.");
-    getch();
-#endif
 
     Startup();
 
@@ -8427,21 +8358,13 @@
     ud.last_level = -1;
 
    RTS_Init(ud.rtsname);
-   if(numlumps) printf("Using .RTS file:%s\n",ud.rtsname);
+   if(numlumps) 
+	   printf("Using .RTS file:%s\n",ud.rtsname);
 
    if (CONTROL_JoystickEnabled)
-       CONTROL_CenterJoystick
-          (
-          CenterCenter,
-          UpperLeft,
-          LowerRight,
-          CenterThrottle,
-          CenterRudder
-          );
-
-        puts("Loading palette/lookups.");
-
-
+       CONTROL_CenterJoystick(CenterCenter,UpperLeft,LowerRight,CenterThrottle,CenterRudder);
+        
+   puts("Loading palette/lookups.");
     if( setgamemode(ScreenMode,ScreenWidth,ScreenHeight) < 0 )
     {
         printf("\nVESA driver for ( %i * %i ) not found/supported!\n",xdim,ydim);
@@ -8451,14 +8374,15 @@
         setgamemode(ScreenMode,ScreenWidth,ScreenHeight);
     }
 
-        printf("genspriteremaps()\n");
 
+    printf("genspriteremaps()\n");
     genspriteremaps();
 
 
     setbrightness(ud.brightness>>2,&ps[myconnectindex].palette[0]);
 
-    ESCESCAPE;
+    if(KB_KeyPressed( sc_Escape ) ) 
+		gameexit(" ");
 
     FX_StopAllSounds();
     clearsoundlocks();
@@ -8477,7 +8401,7 @@
             ud.warp_on = 0;
     }
 
-    //getpackets();
+    
 
     MAIN_LOOP_RESTART:
 
@@ -8616,9 +8540,6 @@
 
             if( ps[myconnectindex].gm&MODE_EOL )
             {
-#ifdef ONELEVELDEMO
-                gameexit(" ");
-#endif
                 closedemowrite();
 
                 ready2send = 0;
--- a/Game/src/menues.c
+++ b/Game/src/menues.c
@@ -4177,23 +4177,13 @@
     int i;
     uint8_t  temparray[768];
 
-    for(i=0;i<768;i+=3)
+    for(i=0;i<(256*3);i+=3)
     {
-        temparray[i  ] =
-            ps[myconnectindex].palette[i+0]+((((long)r-(long)ps[myconnectindex].palette[i+0])*(long)(e&127))>>6);
-        temparray[i+1] =
-            ps[myconnectindex].palette[i+1]+((((long)g-(long)ps[myconnectindex].palette[i+1])*(long)(e&127))>>6);
-        temparray[i+2] =
-            ps[myconnectindex].palette[i+2]+((((long)b-(long)ps[myconnectindex].palette[i+2])*(long)(e&127))>>6);
+        temparray[i  ] =ps[myconnectindex].palette[i+0]+((((long)r-(long)ps[myconnectindex].palette[i+0])*(long)(e&127))>>6);
+        temparray[i+1] =ps[myconnectindex].palette[i+1]+((((long)g-(long)ps[myconnectindex].palette[i+1])*(long)(e&127))>>6);
+        temparray[i+2] =ps[myconnectindex].palette[i+2]+((((long)b-(long)ps[myconnectindex].palette[i+2])*(long)(e&127))>>6);
     }
 
-// CTW - MODIFICATION
-/*  if( (e&128) == 0 )
-        if ((vidoption != 1) || (vgacompatible == 1)) limitrate();*/
-    if( (e&128) == 0 )
-        if ((ScreenMode != 1) || (vgacompatible == 1)) limitrate();
-// CTW END - MODIFICATION
-
     setbrightness(ud.brightness>>2,temparray);
 }
 
@@ -4626,12 +4616,10 @@
 int32_t lastanimhack=0;
 void playanm(char  *fn,uint8_t  t)
 {
-        uint8_t  *animbuf, *palptr;
+    uint8_t  *animbuf, *palptr;
     int32_t i, j, k, length=0, numframes=0;
     int32 handle=-1;
 
-//    return;
-
     if(t != 7 && t != 9 && t != 10 && t != 11)
         KB_FlushKeyboardQueue();
 
@@ -4641,10 +4629,13 @@
         goto ENDOFANIMLOOP;
     }
 
-        handle = TCkopen4load(fn,0);
-        if(handle == -1) return;
-        length = kfilelength(handle);
+    handle = TCkopen4load(fn,0);
 
+    if(handle == -1) 
+		return;
+
+    length = kfilelength(handle);
+
     walock[MAXTILES-3-t] = 219+t;
 
     if(anim == 0 || lastanimhack != (MAXTILES-3-t))
@@ -4657,28 +4648,28 @@
     tilesizx[MAXTILES-3-t] = 200;
     tilesizy[MAXTILES-3-t] = 320;
 
-        kread(handle,animbuf,length);
-        kclose(handle);
+    kread(handle,animbuf,length);
+    kclose(handle);
 
-        ANIM_LoadAnim (animbuf);
-        numframes = ANIM_NumFrames();
+    ANIM_LoadAnim (animbuf);
+    numframes = ANIM_NumFrames();
 
-        palptr = ANIM_GetPalette();
-        for(i=0;i<256;i++)
-        {
-                j = (i<<2); k = j-i;
-                tempbuf[j+0] = (palptr[k+2]>>2);
-                tempbuf[j+1] = (palptr[k+1]>>2);
-                tempbuf[j+2] = (palptr[k+0]>>2);
-                tempbuf[j+3] = 0;
-        }
+    palptr = ANIM_GetPalette();
+    for(i=0;i<256;i++)
+    {
+            j = (i<<2); k = j-i;
+            tempbuf[j+0] = (palptr[k+2]>>2);
+            tempbuf[j+1] = (palptr[k+1]>>2);
+            tempbuf[j+2] = (palptr[k+0]>>2);
+            tempbuf[j+3] = 0;
+    }
 
-        VBE_setPalette(0L,256L,tempbuf);
+    VBE_setPalette(0L,256L,tempbuf);
 
     ototalclock = totalclock + 10;
 
-        for(i=1;i<numframes;i++)
-        {
+    for(i=1;i<numframes;i++)
+    {
        while(totalclock < ototalclock)
        {
           if( KB_KeyWaiting() )