shithub: rott

Download patch

ref: 9c3a674adc0f2580b45ac82b7655317be800ae01
parent: 3f89128a141080e37c2637d3daae95d29a51ce73
author: LTCHIPS <ltchips994@gmail.com>
date: Fri May 18 20:31:19 EDT 2018

redid the rotate function, now it doesn't use those odd FINEANGLES vars

--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -1039,10 +1039,7 @@
 
 //void DrawRotatedScreen(int cx, int cy, byte *destscreen, int angle, int scale, int masked)
 
-extern int MinScreenWidth;
-extern int MinScreenHeight;
-
-void DoScreenRotateScale(int w, int h, SDL_Texture * tex, int angle, float scale)
+void DoScreenRotateScale(int w, int h, SDL_Texture * tex, float angle, float scale)
 {   
     
     SDL_RenderClear(renderer);
@@ -1053,10 +1050,10 @@
     
     output.h = abs((int)((float)h * scale));
     
-    if (output.w < MinScreenWidth)
-        output.w = MinScreenWidth;
-    if (output.h < MinScreenHeight)
-        output.h = MinScreenHeight;
+    //if (output.w < MinScreenWidth)
+        //output.w = MinScreenWidth;
+    //if (output.h < MinScreenHeight)
+        //output.h = MinScreenHeight;
                
     output.x = (iGLOBAL_SCREENWIDTH - output.w)>>1;
         
--- a/rott/modexlib.h
+++ b/rott/modexlib.h
@@ -139,7 +139,7 @@
 void  VL_CopyPlanarPage ( byte * src, byte * dest );
 void  VL_CopyPlanarPageToMemory ( byte * src, byte * dest );
 void  XFlipPage ( void );
-void  DoScreenRotateScale(int, int, SDL_Texture * , int, float);
+void DoScreenRotateScale(int w, int h, SDL_Texture * tex, float angle, float scale);
 void  WaitVBL( void );
 void  TurnOffTextCursor ( void );
 
--- a/rott/rt_draw.c
+++ b/rott/rt_draw.c
@@ -2729,7 +2729,10 @@
 ========================
 */
 
-void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, int option, boolean fadeOut);
+//void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, int option, boolean fadeOut);
+
+void RotateScreenScaleFloat(float startAngle, float endAngle, float startScale, float endScale, int time, boolean fadeOut, boolean drawPlayScreen);
+
 int playerview=0;
 void      ThreeDRefresh (void)
 {
@@ -2838,7 +2841,10 @@
         bufferofs-=screenofs;
         DrawPlayScreen (true);
         //void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time);
-        RotateScreen(0,FINEANGLES,FINEANGLES,FINEANGLES*8,(VBLCOUNTER*3)/4, 0, false);
+        
+        RotateScreenScaleFloat(0, 360, 0.01875, 1.0, (VBLCOUNTER*3)/4, false, true);
+
+        //RotateScreen(0,FINEANGLES,FINEANGLES,FINEANGLES*8,(VBLCOUNTER*3)/4, 0, false);
         //RotateBuffer(0,FINEANGLES,FINEANGLES*8,FINEANGLES,(VBLCOUNTER*3)/4);
         bufferofs+=screenofs;
         fizzlein = false;
@@ -3356,16 +3362,83 @@
 
 const SDL_Renderer * GetRenderer(void);
 
-void DoScreenRotateScale(int cx, int cy, SDL_Texture * tex, int angle, float scale);
+void DoScreenRotateScale(int cx, int cy, SDL_Texture * tex, float angle, float scale);
 
 void VL_FadeOutScaledScreen (int start, int end, int red, int green, int blue, int steps, float scale);
 
 
+void RotateScreenScaleFloat(float startAngle, float endAngle, float startScale, float endScale, int time, boolean fadeOut, boolean drawPlayScreen)
+{
+    DisableScreenStretch();
+    
+    //STUB_FUNCTION;
+    printf("ROTATE SCREEN FLOAT FUNC: \n");
+    printf("startAngle: %f \n", startAngle);
+    printf("endAngle: %f \n", endAngle);
+    printf("startScale: %f \n", startScale);
+    printf("endScale: %f \n", endScale);
+    printf("time: %d \n", time);
+    
+    float angle = startAngle;
+    
+    float scalestep = (endScale - startScale)/(time);
+    
+    float scale = startScale;
+    
+    float anglestep = (endAngle - startAngle)/(time);
+    
+    printf("anglestep: %f \n", anglestep);
+    printf("scalestep: %f \n", scalestep);
+    //printf("startingScale: %f \n", scale);
+    
+    CalcTics();
+    CalcTics();
+    
+    int i;
+    
+    SDL_Texture * newTex = SDL_CreateTextureFromSurface((SDL_Renderer *) GetRenderer(), sdl_surface);
+    
+    float factor;
+    
+    for (i=0; i<time; i+=tics)
+    {
+        factor = scale;
+        
+        //printf("factor: %f \n", factor);
+        
+        DoScreenRotateScale(iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT, newTex, angle, factor);
+        
+        scale+=(scalestep);
+        //if (angle < endAngle)
+        angle+=(anglestep);
+        
+        CalcTics();
+        
+        //printf("scaleDRAW: %f \n", scale);
+    
+    }
+    
+    //printf("factor: %f \n", factor);
+    
+    if(fadeOut == true)
+        VL_FadeOutScaledScreen (0, 255, 0,0,0,VBLCOUNTER>>1, endScale);
+    
+    //DoScreenRotateScale(iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT, newTex, 0, 1.0);
+    
+    SDL_DestroyTexture(newTex);
+    
+    
+    if(drawPlayScreen)
+        DrawPlayScreen(true);//repaint ammo and life stat
+    
+}
+
 //A note about option
 //When option is set to
 //    0: factor is set to equal scale value every time. This is good for starting from a small screen to eventually grow to a larger screen.
 //    1: factor is set to equal 1 + scale value. This is good for zooming into the screen.
 //    2: factor is set to equal 1 - scale value. This is good for zooming out from the screen.
+/*
 void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, int option, boolean fadeOut)
 {
     DisableScreenStretch();
@@ -3372,15 +3445,16 @@
     
     //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);
+    printf("ROTATE SCREEN FUNC: \n");
+    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);
     
     int angle = startAngle;
     
-    float scalestep = (float)((endScale/endScale) - ((float)startScale/(float)endScale))/((float)time);
+    float scalestep = (1.0 - ((float)startScale/(float)endScale))/((float)time);
     
     float scale = ((float)startScale/(float)endScale);
     
@@ -3389,11 +3463,11 @@
         scale = 1.0;
     }
     
-    int anglestep = (endAngle - startAngle)/(time*5.52); //added *6 because it was rotating too effing fast
+    int anglestep = (endAngle - startAngle)/(time*5.49); //added *6 because it was rotating too effing fast
     
     //printf("anglestep: %d \n", anglestep);
-    //printf("scalestep: %f \n", scalestep);
-    //printf("startingScale: %f \n", scale);
+    printf("scalestep: %f \n", scalestep);
+    printf("startingScale: %f \n", scale);
     
     CalcTics();
     CalcTics();
@@ -3441,8 +3515,11 @@
     //DoScreenRotateScale(iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT, newTex, 0, 1.0);
     
     SDL_DestroyTexture(newTex);
+    
+    DrawPlayScreen(true);//repaint ammo and life stat
 
 }
+*/
 
 
 //******************************************************************************
--- a/rott/rt_draw.h
+++ b/rott/rt_draw.h
@@ -112,6 +112,7 @@
 int   CalcHeight (void);
 void  DoLoadGameSequence( void );
 void RotateBuffer (int startangle, int endangle, int startscale, int endscale, int time);
+void RotateScreenScaleFloat(float startAngle, float endAngle, float startScale, float endScale, int time, boolean fadeOut, boolean drawPlayScreen);
 void ApogeeTitle (void);
 void DopefishTitle (void);
 void RotationFun (void);
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -4445,8 +4445,11 @@
 
 #define DEATHROTATE 6
 
-void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, int option, boolean fadeOut);
+//void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, int option, boolean fadeOut);
 
+//void RotateScreenScaleFloat(float startAngle, float endAngle, float startScale, float endScale, int time, boolean fadeOut, boolean drawPlayScreen);
+
+
 extern boolean dopefish;
 void Died (void)
 {
@@ -4679,9 +4682,11 @@
         //zooms in on screen
         if (pstate->falling==true)
         {
-            printf("doing death 0 rotate \n");
+            //printf("doing death 0 rotate \n");
             //RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
-            RotateScreen (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), 1, true);
+            //RotateScreen (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), 1, true);
+            RotateScreenScaleFloat(0, 0, 1.0, 64.0, (VBLCOUNTER*(1+slowrate)), true, false);
+            
             SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
             pstate->falling=false;
         }
@@ -4688,25 +4693,27 @@
         //zooms out w/o spinning
         else if (rng < 64)
         {
-            printf("doing death 1 rotate \n");
+            //printf("doing death 1 rotate \n");
             //RotateBuffer (0, 0, (FINEANGLES>>6), (FINEANGLES), (VBLCOUNTER*(2+slowrate)));
-            RotateScreen (0, 0, (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(2+slowrate)), 2, true);
+            //RotateScreen (0, 0, (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(2+slowrate)), 2, true);
+            RotateScreenScaleFloat(0, 0, 1.0, 0.01875, (VBLCOUNTER*(2+slowrate)), true, false);
         
         }
         //zooms in on screen
         else if (rng < 128)
         {
-            printf("doing death 2 rotate \n");
+            //printf("doing death 2 rotate \n");
             //RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
-            RotateScreen(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), 1, true);
-            
+            //RotateScreen(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), 1, true);
+            RotateScreenScaleFloat(0, 0, 1.0, 64.0, (VBLCOUNTER*(1+slowrate)), true, false);
+
         }
         //zooms out with spinning
         else if (rng < 192)
         {
-            printf("doing death 3 rotate \n");
+            //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)), 2, true);
+            RotateScreenScaleFloat(0, (360.0*3), 1.0, 0.01875, (VBLCOUNTER*(3+slowrate)), true, false);
         }
         //fade to red
         else{
@@ -4737,29 +4744,37 @@
 
         SD_Play (SD_GAMEOVERSND);
         rng=RandomNumber("Died",0);
+        
+        //rng = 63;
         if (rng<64)
         {
-            printf("GAME OVER SEQUENCE 1 \n");
+            //printf("GAME OVER SEQUENCE 1 \n");
             //RotateBuffer(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
-            RotateScreen(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2, true);
+            //RotateScreen(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2, true);
+            
+            RotateScreenScaleFloat(0, 360, 1.0, 0.01875, (VBLCOUNTER*(3+slowrate)), true, false);
+            
         }
         else if (rng<128)
         {
-            printf("GAME OVER SEQUENCE 2 \n");
+            //printf("GAME OVER SEQUENCE 2 \n");
             VL_FadeToColor (VBLCOUNTER*3, 255, 255, 255);
             VL_FadeOut (0, 255, 0,0,0,VBLCOUNTER>>1);
         }
         else if (rng<192)
         {
-            printf("GAME OVER SEQUENCE 3 \n");
+            //printf("GAME OVER SEQUENCE 3 \n");
             //RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
-            RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2, true);
+            //RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2, true);
+            RotateScreenScaleFloat(0, 360*2, 1.0, 0.01875, (VBLCOUNTER*(3+slowrate)), true, false);
         }
         else
         {
-            printf("GAME OVER SEQUENCE 4 \n");
+            //printf("GAME OVER SEQUENCE 4 \n");
             //RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
-            RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2, true);
+            //RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2, true);
+            RotateScreenScaleFloat(0, 360*2, 1.0, 0.01875, (VBLCOUNTER*(3+slowrate)), true, false);
+            
         }
         screenfaded=false;
 
--- a/rott/winrott.c
+++ b/rott/winrott.c
@@ -11,9 +11,6 @@
 int iGLOBAL_SCREENBWIDE ;
 int iG_SCREENWIDTH;// default screen width in bytes
 
-int MinScreenWidth;
-int MinScreenHeight;
-
 int iGLOBAL_HEALTH_X;
 int iGLOBAL_HEALTH_Y;
 int iGLOBAL_AMMO_X;
@@ -67,9 +64,9 @@
     
     dTopYZANGLELIMIT = (44*FINEANGLES/360);;
     
-    MinScreenWidth =  ((float)iGLOBAL_SCREENWIDTH * 0.01875);
+    //MinScreenWidth =  ((float)iGLOBAL_SCREENWIDTH * 0.01875);
     
-    MinScreenHeight = ((float)iGLOBAL_SCREENHEIGHT * 0.02);
+    //MinScreenHeight = ((float)iGLOBAL_SCREENHEIGHT * 0.02);
     
 }