shithub: rott

Download patch

ref: 2866d5d0666715ecb66540ab5f5db4b0df3ed8ca
parent: e439b609c92d399fb6a959c3cb0f9fac0ac5b81f
author: LTCHIPS <ltchips994@gmail.com>
date: Fri May 4 17:22:25 EDT 2018

added zoom option

--- a/rott/Makefile
+++ b/rott/Makefile
@@ -29,7 +29,6 @@
 
 LDLIBS += $(shell sdl2-config --libs)
 LDLIBS += -lSDL2_mixer
-LDLIBS += -lSDL2_gfx
 LDLIBS += $(EXTRALDLIBS)
 
 OBJS :=
--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -1039,72 +1039,34 @@
 
 void CalcTics (void);
 
-void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time)
-{
-    STUB_FUNCTION;
+void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut)
+{   
+    //STUB_FUNCTION;
     
+/*
     printf("startAngle: %d \n", startAngle);
     printf("endAngle: %d \n", endAngle);
     printf("startScale: %d \n", startScale);
     printf("endScale: %d \n", endScale);
     printf("time: %d \n", time);
-    
-    
-/*
-    time = 26;
-    
-    startAngle = 0;
-    
-     angle = (startAngle>>16)&(2048-1);
-    
-    endAngle = (2048);
-    
-    //startScale = 2048;
 */
     
-    int tempStrtScale = startScale;
+    int angle = startAngle;
     
-    int tempEndScale = endScale;
+    float scalestep =(float)((endScale - startScale)/time);
     
-    startScale = tempEndScale;
     
-    endScale = tempStrtScale;
     
-    int angleStep = 1;//(endAngle - startAngle)/time;
-    
-    //endScale = 2048*8;
-
-    //angle=(startangle<<16);
-    
-    //angle = startangle<<16;
-    
-    int angle = startAngle;
-    
-    //scale = startscale>>16;
-    
-    //scale = startscale;
-
     int scale = startScale;
     
-    //float scale = (float)startScale;
-    
-    //float scalestep = 0.01;
-    
-    //int anglestep = (endAngle-startAngle)/(time);
-    //float scalestep = (float) ((endScale-startScale)/(time));
-    
-    
-    //anglestep = (endangle-startangle)<<16/time;
-    //scalestep = (endscale-startscale)<<6/time;
-    
     int anglestep = (endAngle - startAngle)/(time*6); //added *6 because it was rotating too effing fast
     
-    int scaleStepNumer = (endScale - startScale);
+    //float scalestep =(float)((endScale - startScale)/time);
     
-    float scalestep =((float)(abs(scaleStepNumer))/(time));
-    
+/*
     printf("anglestep: %d \n", anglestep);
     printf("scalestep: %f \n", scalestep);
+*/
     
     
     CalcTics();
@@ -1114,7 +1076,7 @@
     
     for (i=0; i<time; i+=tics)
     {
-        printf("tics: %d\n", tics);
+        //printf("tics: %d\n", tics);
         
         SDL_Texture * newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
     
@@ -1124,8 +1086,21 @@
         
         //int scaleShft = (scale)>>6;
         
-        float factor = ((float)(scale)/(endScale));
+        float factor;
         
+        
+        if (zoomInOrOut)
+        {
+            factor = ((float)(scale)/(endScale));
+            
+        }
+        else
+        {
+            factor = 1 - ((float)(scale)/(endScale));
+        }
+        
+        //printf("factor: %f \n", factor);
+        
         float width = iGLOBAL_SCREENWIDTH * factor;
         
         float height = iGLOBAL_SCREENHEIGHT * factor;
@@ -1134,10 +1109,11 @@
         
         output.h = height;
         
+/*
         printf("width: %d \n", output.w);
         printf("height: %d \n", output.h);
+*/
                
-        
         output.x = (iGLOBAL_SCREENWIDTH - output.w)/2;
         
         output.y = (iGLOBAL_SCREENHEIGHT - output.h)/2;
@@ -1146,174 +1122,16 @@
         
         SDL_RenderPresent(renderer);
         
-        scale+=(scalestep * tics);
-        angle+=(anglestep*tics);
-        
-        
         SDL_DestroyTexture(newTex);
         
-        CalcTics();
+        scale+=(scalestep);
+        angle+=(anglestep);
         
+        CalcTics();
     
     }
     
-    RenderSurface(); //render the image straight...yeah yeah i know that's cheating
+    //RenderSurface(); //render the image straight...yeah yeah i know that's cheating
 
-}
-
-
-
-
-
-void FlipPageRotoZoom (int angle, int scale )
-{   
-    printf("Angle: %d Scale: %d \n", angle, scale);
-    
-    //SDL_RenderSetIntegerScale(renderer, SDL_FALSE);
-    
-    if (StretchScreen) { //bna++
-        StretchMemPicture ();
-    } else {
-        DrawCenterAim ();
-    }
-    
-    //int zoomedSurfWidth = 0;
-    
-    //int zoomedSurfHeight = 0; 
-    
-    //SDL_SetRelativeMouseMode(SDL_FALSE);
-    
-    //rotozoomSurfaceSize(sdl_surface->w, sdl_surface->h, angle,zoom/100, &zoomedSurfWidth, &zoomedSurfHeight);
-    
-    //sdl_zoomed_surface = SDL_CreateRGBSurface(0,zoomedSurfWidth,zoomedSurfHeight,8,0,0,0,0);
-    
-    //SDL_SetSurfaceRLE(sdl_zoomed_surface, 1);
-    
-    //SDL_SetPaletteColors(sdl_zoomed_surface->format->palette, sdl_surface->format->palette->colors, 0, 256);
-    
-    //SDL_SetPixelFormatPalette(sdl_zoomed_surface->format, sdl_surface->format->palette);
-    
-    //memcpy(sdl_zoomed_surface->pixels, sdl_surface->pixels, sizeof(byte)*iGLOBAL_SCREENHEIGHT*iGLOBAL_SCREENWIDTH);
-    
-    //if (sdl_zoomed_surface == NULL)
-    //{
-        //Error("Out of memory for rotated surface \n");
-        //exit(1);
-    
-    //}
-    
-    //sdl_zoomed_surface = rotozoomSurface(sdl_surface, (double)angle, (double)(zoom/100), 0);
-    
-    SDL_Texture *newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
-    
-    if (newTex == NULL) 
-    {
-        Error("CreateTextureFromSurface failed: %s \n", SDL_GetError());
-        exit(1);
-    }
-   
-    
-    SDL_RenderClear(renderer);
-    
-    //SDL_RenderSetScale(renderer, (float)zoom/10, (float)zoom/10);
-    
-    //SDL_RenderSetLogicalSize(renderer, zoomedSurfWidth, zoomedSurfHeight);
-    
-    //SDL_RenderCopy(renderer, newTex, NULL, NULL);
-    
-    SDL_Point rotateAround;
-    
-/*
-    float scalex, scaley;
-    
-    
-    if(zoom > 0)
-    {
-        rotateAround.x = (int) ((iGLOBAL_SCREENWIDTH/2)*(scalex));
-        rotateAround.y = (int) ((iGLOBAL_SCREENHEIGHT/2)*(scaley));
-    }
-    else
-    {
-        rotateAround.x = iGLOBAL_SCREENWIDTH/2;
-        rotateAround.y = iGLOBAL_SCREENHEIGHT/2;
-    }
-*/
-    //SDL_RenderGetScale(renderer, &scalex, &scaley);
-
-    //rotateAround.x = (int) ((iGLOBAL_SCREENWIDTH/2)*(scalex));
-    //rotateAround.y = (int) ((iGLOBAL_SCREENHEIGHT/2)*(scaley));
-    
-    SDL_Rect dest;
-    
-    //SDL_RenderSetLogicalSize(renderer, dest.w, dest.h);
-    
-    if (scale > 0)
-    {
-        dest.w = (int) (iGLOBAL_SCREENWIDTH/scale);
-        dest.h = (int) (iGLOBAL_SCREENHEIGHT/scale);
-    }
-    else
-    {
-        dest.w = iGLOBAL_SCREENWIDTH;
-        dest.h = iGLOBAL_SCREENHEIGHT;
-        //dest.x = iGLOBAL_SCREENWIDTH - dest.w;
-        //dest.y = iGLOBAL_SCREENHEIGHT - dest.h;
-        
-    
-    }
-    
-    SDL_RenderSetLogicalSize(renderer, dest.w, dest.h);
-    
-    dest.x = 0;
-    dest.y = 0;
-/*
-    
-    	center.x = rect.w * 0.5;
-center.y = rect.h - ( rect.w * 0.5 );
-*/
-    
-    
-    
-    //SDL_RenderCopyEx(renderer, newTex, NULL, &dest, angle, &(SDL_Rect) {dest.w/2, dest.h/2} , SDL_FLIP_NONE);
-    
-    if(SDL_RenderCopyEx(renderer, newTex, NULL, &dest, angle, &(SDL_Rect) {dest.w/2, dest.h}, SDL_FLIP_NONE) == -1)
-    {
-        printf("SDL_RenderCopyEx failed: %s \n", SDL_GetError());
-        exit(1);
-    
-    
-    }
-    
-    
-    SDL_RenderPresent(renderer);
-    
-    SDL_DestroyTexture(newTex);
-    
-    //SDL_RenderSetLogicalSize(renderer, iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT);
-    
-    
-    //SDL_FreeSurface(sdl_zoomed_surface);
-    
-
-}
-
-void FreeSDLSurfaceZoom()
-{
-    
-    //SDL_RenderSetScale(renderer, 1, 1);
-/*
-    SDL_RenderSetLogicalSize(renderer, iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT);
-    
-    SDL_FreeSurface(sdl_zoomed_surface);
-*/
-    
-    //SDL_Rect orig;
-    //orig.w = iGLOBAL_SCREENWIDTH;
-    //orig.h = iGLOBAL_SCREENHEIGHT;
-    //orig.x = 0;
-    //orig.y = 0;
-            
-    
-    //SDL_RenderSetViewport(renderer, &orig);
 }
 
--- a/rott/rt_draw.c
+++ b/rott/rt_draw.c
@@ -2729,7 +2729,7 @@
 ========================
 */
 
-void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time);
+void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut);
 int playerview=0;
 void      ThreeDRefresh (void)
 {
@@ -2838,7 +2838,7 @@
         bufferofs-=screenofs;
         DrawPlayScreen (true);
         //void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time);
-        RotateScreen(0,FINEANGLES,FINEANGLES*8,FINEANGLES,(VBLCOUNTER*3)/4);
+        RotateScreen(0,FINEANGLES,FINEANGLES,FINEANGLES*8,(VBLCOUNTER*3)/4, true);
         //RotateBuffer(0,FINEANGLES,FINEANGLES*8,FINEANGLES,(VBLCOUNTER*3)/4);
         bufferofs+=screenofs;
         fizzlein = false;
@@ -3306,15 +3306,14 @@
     for (i=0; i<time; i+=tics)
     {   //zxcv
         DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,(angle>>16)&(FINEANGLES-1),scale>>6,0);
-        //FlipPageRotoZoom(angle, scale);
         
-        //FlipPage();
+        FlipPage();
         scale+=(scalestep*tics);
         angle+=(anglestep*tics);
         CalcTics();
     }
     
-    FreeSDLSurfaceZoom();
+    //FreeSDLSurfaceZoom();
 
     SDL_SetRelativeMouseMode(SDL_TRUE);
     
@@ -3367,16 +3366,19 @@
     SetFastTics(savetics);
 }
 
-void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time);
+void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut);
 
-void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time)
+void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut)
 {
+    DisableScreenStretch();
     
-    printf("%f \n", startScale);
-    printf("%f \n", endScale);
+    //printf("%d \n", startScale);
+    //printf("%d \n", endScale);
     
+//RotateScreen(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
 
-    DoScreenRotateZoom(startAngle, endAngle, startScale, endScale, time);
+    //DoScreenRotateZoom(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+3)));
+    DoScreenRotateZoom(startAngle, endAngle, startScale, endScale, time, zoomInOrOut);
 
 
 
@@ -3660,9 +3662,8 @@
     while (!Keyboard[sc_Escape])
     {
         IN_UpdateKeyboard ();
-        //DrawRotatedScreen(iGLOBAL_SCREENWIDTH/2,iGLOBAL_SCREENHEIGHT/2,(byte *)bufferofs,angle,scale,0);
-        FlipPageRotoZoom(angle, scale);
-        //FlipPage();
+        DrawRotatedScreen(iGLOBAL_SCREENWIDTH/2,iGLOBAL_SCREENHEIGHT/2,(byte *)bufferofs,angle,scale,0);
+        FlipPage();
         CalcTics();
         INL_GetMouseDelta(&x, &y);
         buttons=IN_GetMouseButtons ();
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -4445,6 +4445,8 @@
 
 #define DEATHROTATE 6
 
+void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut);
+
 extern boolean dopefish;
 void Died (void)
 {
@@ -4671,22 +4673,40 @@
         int rng;
 
         rng = RandomNumber ("Died",0);
-
+                
+        //zooms in on screen
         if (pstate->falling==true)
         {
-            RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
+            printf("doing death 0 rotate \n");
+            //RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
+            RotateScreen (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), true);
             SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
             pstate->falling=false;
         }
-
+        //zooms out w/o spinning
         else if (rng < 64)
-            RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(2+slowrate)));
+        {
+            printf("doing death 1 rotate \n");
+            //RotateBuffer (0, 0, (FINEANGLES>>6), (FINEANGLES), (VBLCOUNTER*(2+slowrate)));
+            RotateScreen (0, 0, (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(2+slowrate)), false);
+        
+        }
+        //zooms in on screen
         else if (rng < 128)
         {
-            RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
+            printf("doing death 2 rotate \n");
+            //RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
+            RotateScreen(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), true);
+            
         }
+        //zooms out with spinning
         else if (rng < 192)
-            RotateBuffer(0, (FINEANGLES*4), (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(3+slowrate)));
+        {
+            printf("doing death 3 rotate \n");
+            //RotateBuffer(0, (FINEANGLES*4), (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(3+slowrate)));
+            RotateScreen(0, (FINEANGLES*4), (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(3+slowrate)), false);
+        }
+        //fade to red
         else
             VL_FadeToColor (VBLCOUNTER*2, 100, 0, 0);
 
@@ -4714,13 +4734,16 @@
         SD_Play (SD_GAMEOVERSND);
         rng=RandomNumber("Died",0);
         if (rng<64)
-            RotateBuffer(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+            //RotateBuffer(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+            RotateScreen(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), false);
         else if (rng<128)
             VL_FadeToColor (VBLCOUNTER*3, 255, 255, 255);
         else if (rng<192)
-            RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+            //RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+            RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), false);
         else
-            RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+            //RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
+            RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), false);
 
         screenfaded=false;