shithub: rott

Download patch

ref: eb18f7f76ea7b4194588ca4993bb891323033d76
parent: b31dbda66878a93ba307ee9875fb41585f6d2edf
author: LTCHIPS <ltchips994@gmail.com>
date: Mon May 7 19:43:11 EDT 2018

started working on a new version of RotationFun

--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -1039,13 +1039,11 @@
 
 void CalcTics (void);
 
-
-
 //void DrawRotatedScreen(int cx, int cy, byte *destscreen, int angle, int scale, int masked)
 
 void DoScreenRotateScale(int w, int h, SDL_Texture * tex, int angle, float scale)
 {   
-    
+    printf("SCALE \n");
 /*
     printf("center x: %d \n", w);
     printf("center y: %d \n", h);
@@ -1067,9 +1065,9 @@
         printf("height: %d \n", output.h);
 */
                
-    output.x = (iGLOBAL_SCREENWIDTH - output.w)/2;
+    output.x = (iGLOBAL_SCREENWIDTH - output.w)>>1;
         
-    output.y = (iGLOBAL_SCREENHEIGHT - output.h)/2;
+    output.y = (iGLOBAL_SCREENHEIGHT - output.h)>>1;
         
     SDL_RenderCopyEx(renderer, tex, NULL, &output, angle, NULL, SDL_FLIP_NONE);
         
@@ -1076,6 +1074,11 @@
     SDL_RenderPresent(renderer);
 
 
+}
+
+SDL_Texture * GetMainSurfaceAsTexture(void)
+{
+    return SDL_CreateTextureFromSurface(renderer, sdl_surface);
 }
 
 
--- a/rott/rt_debug.c
+++ b/rott/rt_debug.c
@@ -1360,6 +1360,8 @@
 
 extern boolean ricochetingRocketsEnabled;
 
+void RotationFunSDL(void);
+
 void CheckCode (int which)
 {
     int pos = (LastLetter-1)&(MAXLETTERS-1);
@@ -1614,7 +1616,7 @@
 
         case ROTATIONFUN:
             ShutdownClientControls();
-            RotationFun();
+            RotationFunSDL();
             StartupClientControls();
             SetupScreen( true );
             break;
--- a/rott/rt_draw.c
+++ b/rott/rt_draw.c
@@ -3711,6 +3711,62 @@
 
 #endif
 
+void RotationFunSDL(void)
+{
+    int   angle;
+    float   scale;
+    int   x,y;
+    word  buttons;
+
+    //save off fastcounter
+
+
+    angle=0;
+    //scale=FINEANGLES;
+    scale=1.0;
+
+    //StartupRotateBuffer (0);
+
+    CalcTics();
+    CalcTics();
+    
+    SDL_Texture * currScreen = SDL_CreateTextureFromSurface((SDL_Renderer *) GetRenderer(), sdl_surface);
+    
+    while (!Keyboard[sc_Escape])
+    {
+        IN_UpdateKeyboard ();
+        printf("PRE SCALE \n");
+        
+        DoScreenRotateScale((int) ((float)iGLOBAL_SCREENWIDTH*scale), (int)((float)iGLOBAL_SCREENHEIGHT*scale), 
+                            currScreen, (int) angle, scale);
+        
+        printf("POST SCALE \n");
+        //DrawRotatedScreen(iGLOBAL_SCREENWIDTH/2,iGLOBAL_SCREENHEIGHT/2,(byte *)bufferofs,angle,scale,0);
+        //FlipPage();
+        CalcTics();
+        INL_GetMouseDelta(&x, &y);
+        buttons=IN_GetMouseButtons ();
+        angle=(angle-x)&(FINEANGLES-1);
+        if (buttons & (1 << 0))
+        {
+            if (scale>0)
+                scale-=0.01;
+        }
+        else if (buttons & (1 << 1))
+        {
+            scale+=0.01;
+        }
+    }
+    SDL_DestroyTexture(currScreen);
+    
+    CalcTics();
+    CalcTics();
+    Keyboard[sc_Escape]=0;
+
+    //ShutdownRotateBuffer ();
+}
+
+
 //******************************************************************************
 //
 // RotationFun
@@ -3737,6 +3793,7 @@
     while (!Keyboard[sc_Escape])
     {
         IN_UpdateKeyboard ();
+        
         DrawRotatedScreen(iGLOBAL_SCREENWIDTH/2,iGLOBAL_SCREENHEIGHT/2,(byte *)bufferofs,angle,scale,0);
         FlipPage();
         CalcTics();