shithub: rott

Download patch

ref: eff3010a1034e1c33b21d9a72c1549624de22be2
parent: 5c8c5ead11772c1bceb6bab6dd5c4b5d6659a2fa
author: LTCHIPS <ltchips994@gmail.com>
date: Fri May 4 13:20:20 EDT 2018

sdl screen rotate scales properly now

--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -1039,38 +1039,73 @@
 
 void CalcTics (void);
 
-void DoScreenRotateZoom(int startAngle, int endAngle, float startScale, float endScale, int time)
+void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time)
 {
     STUB_FUNCTION;
     
     printf("startAngle: %d \n", startAngle);
     printf("endAngle: %d \n", endAngle);
-    printf("startScale: %.6f \n", startScale);
-    printf("endScale: %.6f \n", endScale);
+    printf("startScale: %d \n", startScale);
+    printf("endScale: %d \n", endScale);
     printf("time: %d \n", time);
     
     
-    int anglestep = (endAngle-startAngle)/time;
-    float scalestep = (float) ((endScale-startScale)/time);
+    time = 26;
+    
+    startAngle = 0;
+    
+    int angle = (startAngle>>16)&(2048-1);
+    
+    endAngle = (2048);
+    
+    startScale = 2048;
+    
+    int angleStep = (endAngle - startAngle)<<16/time;
+    
+    endScale = 2048*8;
 
     //angle=(startangle<<16);
     
     //angle = startangle<<16;
     
-    int angle = startAngle;
+    //int angle = startAngle<<16;
     
     //scale = startscale>>16;
     
     //scale = startscale;
 
-    float 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;
+    
+    int numerator = (endScale - startScale);
+    
+    float scalestep =((float)(abs(numerator))/time);
+    
+    printf("anglestep: %d \n", anglestep);
+    printf("scalestep: %f \n", scalestep);
+    
+    
     CalcTics();
+    CalcTics();
     
     int i;
     
     for (i=0; i<time; i+=tics)
     {
+        printf("tics: %d\n", tics);
+        
         SDL_Texture * newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
     
         SDL_RenderClear(renderer);
@@ -1077,10 +1112,20 @@
         
         SDL_Rect output;
         
-        output.w = iGLOBAL_SCREENWIDTH * scale;
+        //int scaleShft = (scale)>>6;
         
-        output.h = iGLOBAL_SCREENHEIGHT * scale;
+        float width = iGLOBAL_SCREENWIDTH * ((float)(scale)/(endScale));
         
+        float height = iGLOBAL_SCREENHEIGHT * ((float)(scale)/(endScale));
+        
+        output.w = width;
+        
+        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;
@@ -1089,11 +1134,14 @@
         
         SDL_RenderPresent(renderer);
         
-        scale+=(scalestep*tics);
+        scale+=(scalestep * tics);
         angle+=(anglestep*tics);
-        CalcTics();
         
+        
         SDL_DestroyTexture(newTex);
+        
+        CalcTics();
+        
     
     }
 
--- 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);
 int playerview=0;
 void      ThreeDRefresh (void)
 {
@@ -2837,7 +2837,9 @@
             ShutdownClientControls();
         bufferofs-=screenofs;
         DrawPlayScreen (true);
-        RotateBuffer(0,FINEANGLES,FINEANGLES*8,FINEANGLES,(VBLCOUNTER*3)/4);
+        //void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time);
+        RotateScreen(0,FINEANGLES,FINEANGLES*8,FINEANGLES,(VBLCOUNTER*3)/4);
+        //RotateBuffer(0,FINEANGLES,FINEANGLES*8,FINEANGLES,(VBLCOUNTER*3)/4);
         bufferofs+=screenofs;
         fizzlein = false;
         StartupClientControls();
@@ -3258,8 +3260,6 @@
 //
 //******************************************************************************
 
-void FlipPageRotoZoom(int angle, int zoom);
-
 void ScaleAndRotateBuffer (int startangle, int endangle, int startscale, int endscale, int time)
 {
     int anglestep;
@@ -3297,7 +3297,7 @@
     
     //scale = startscale;
 
-    scale=(startscale>>6);
+    scale=(startscale<<6);
 
     CalcTics();
     CalcTics();
@@ -3305,8 +3305,8 @@
     
     for (i=0; i<time; i+=tics)
     {   //zxcv
-        //DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,(angle>>16)&(FINEANGLES-1),scale>>6,0);
-        FlipPageRotoZoom(angle, scale);
+        DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,(angle>>16)&(FINEANGLES-1),scale>>6,0);
+        //FlipPageRotoZoom(angle, scale);
         
         //FlipPage();
         scale+=(scalestep*tics);
@@ -3347,8 +3347,6 @@
 
 extern boolean skipRotate;
 
-void DoScreenRotateZoom(int startAngle, int endAngle, float startScale, float endScale, int time);
-
 void RotateBuffer (int startangle, int endangle, int startscale, int endscale, int time)
 {   
     int savetics;
@@ -3357,19 +3355,31 @@
 
     savetics=GetFastTics();
     
-    printf("%d \n", startscale);
-    printf("%d \n", endscale);
 
-    //StartupRotateBuffer (0);
-    
-    DoScreenRotateZoom(startangle, endangle, startscale, endscale, time);
 
-    //ScaleAndRotateBuffer (startangle, endangle, startscale, endscale, time);
+    StartupRotateBuffer (0);
 
-    //ShutdownRotateBuffer ();
+    ScaleAndRotateBuffer (startangle, endangle, startscale, endscale, time);
 
+    ShutdownRotateBuffer ();
+
     // restore fast counter
     SetFastTics(savetics);
+}
+
+void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time);
+
+void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time)
+{
+    
+    printf("%f \n", startScale);
+    printf("%f \n", endScale);
+    
+
+    DoScreenRotateZoom(startAngle, endAngle, startScale, endScale, time);
+
+
+
 }