ref: 489346a26021cce3fa2d3ea9bd62ba9d20b54f74
parent: eb18f7f76ea7b4194588ca4993bb891323033d76
author: LTCHIPS <ltchips994@gmail.com>
date: Wed May 9 13:48:38 EDT 2018
even more tweaks to rotation code
--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -800,7 +800,7 @@
void RenderSurface(void)
{
- SDL_Texture *newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
+ SDL_Texture * newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
if (newTex == NULL)
{
@@ -1035,15 +1035,15 @@
}
-extern int tics;
+//extern int tics;
-void CalcTics (void);
+//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("SCALE \n");
/*
printf("center x: %d \n", w);
printf("center y: %d \n", h);
@@ -1079,116 +1079,6 @@
SDL_Texture * GetMainSurfaceAsTexture(void)
{
return SDL_CreateTextureFromSurface(renderer, sdl_surface);
-}
-
-
-void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time)
-{
- //STUB_FUNCTION;
-
-/*
- if (startScale > endScale)
- {
- printf("STARTSCALE IS SMALLER THAN ENDSCALE!\n");
- //int tempStart = startScale;
- //int tempEnd = endScale;
- //startScale = endScale;
- endScale = startScale * endScale;
- }
-*/
-
-
- 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 - startScale)/time);
-
- if (startScale > endScale)
- scalestep = (float)((startScale - endScale)/time)*6; //added * 6 because it wasn't zooming in as much as OG ROTT did
-
-
-
- int scale = startScale;
-
- int anglestep = (endAngle - startAngle)/(time*6); //added *6 because it was rotating too effing fast
-
- //float scalestep =(float)((endScale - startScale)/time);
-
- printf("anglestep: %d \n", anglestep);
- printf("scalestep: %f \n", scalestep);
-
-
- CalcTics();
- CalcTics();
-
- int i;
-
- SDL_Texture * newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
-
- for (i=0; i<time; i+=tics)
- {
- //printf("tics: %d\n", tics);
-
- SDL_RenderClear(renderer);
-
- SDL_Rect output;
-
- float factor = 0;
-
- if (startScale > endScale)
- {
- factor = 1 + ((float)(scale)/(abs(startScale - endScale)));
- }
- else
- {
- factor = ((float)(scale)/(abs(startScale - endScale)));
-
- }
-
-
- printf("factor: %f \n", factor);
-
- float width = iGLOBAL_SCREENWIDTH * factor;
-
- float height = iGLOBAL_SCREENHEIGHT * factor;
-
- 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;
-
- SDL_RenderCopyEx(renderer, newTex, NULL, &output, angle, NULL, SDL_FLIP_NONE);
-
- SDL_RenderPresent(renderer);
-
-
-
- scale+=(scalestep);
- angle+=(anglestep);
-
- CalcTics();
-
- }
-
- SDL_DestroyTexture(newTex);
-
- //RenderSurface(); //render the image straight...yeah yeah i know that's cheating
-
}
const SDL_Renderer * GetRenderer(void)
--- a/rott/rt_draw.c
+++ b/rott/rt_draw.c
@@ -3426,7 +3426,7 @@
if (option == 0)
factor = scale;
if (option == 1)
- factor = 1 + scale*-1;
+ factor = abs(1 + (scale*-1.0));
if (option == 2)
factor = 1 - scale;
else
@@ -3436,9 +3436,9 @@
printf("factor: %f \n", factor);
- x = (int)((float) iGLOBAL_SCREENWIDTH * factor);
+ x = abs((int)((float) iGLOBAL_SCREENWIDTH * factor));
- y = (int)((float) (iGLOBAL_SCREENHEIGHT * factor));
+ y = abs((int)((float) (iGLOBAL_SCREENHEIGHT * factor)));
DoScreenRotateScale(x, y, newTex, angle, factor);
@@ -3479,9 +3479,6 @@
// SetTextMode ( );
c = FixedMulShift(scale,costable[angle],11);
s = FixedMulShift(scale,sintable[angle],11);
-
- printf("c: %d \n", c);
- printf("s: %d \n", s);
// c = c/2; //these values are to rotate degres or?
// s = s/2;
@@ -3735,12 +3732,12 @@
while (!Keyboard[sc_Escape])
{
IN_UpdateKeyboard ();
- printf("PRE SCALE \n");
+ //printf("PRE SCALE \n");
DoScreenRotateScale((int) ((float)iGLOBAL_SCREENWIDTH*scale), (int)((float)iGLOBAL_SCREENHEIGHT*scale),
currScreen, (int) angle, scale);
- printf("POST SCALE \n");
+ //printf("POST SCALE \n");
//DrawRotatedScreen(iGLOBAL_SCREENWIDTH/2,iGLOBAL_SCREENHEIGHT/2,(byte *)bufferofs,angle,scale,0);
//FlipPage();
CalcTics();
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -461,7 +461,7 @@
DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 16*hudRescaleFactor, iGLOBAL_SCREENWIDTH, 13*hudRescaleFactor, 10,10, shape );
- DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 29*hudRescaleFactor, iGLOBAL_SCREENWIDTH, 3*hudRescaleFactor, 10,10, shape );
+ //DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 29*hudRescaleFactor, iGLOBAL_SCREENWIDTH, 3*hudRescaleFactor, 10,10, shape );
//apparently the line below was causing segfaults on linux...
@@ -471,10 +471,10 @@
//enqueue(sdl_draw_obj_queue, shape);
- GameMemToScreen( shape, topBarCenterOffsetX, iGLOBAL_SCREENHEIGHT - 16, bufferofsonly ); //using topBarCenterOffsetX since bottbar dims == statbar dims
+ //GameMemToScreen( shape, topBarCenterOffsetX, iGLOBAL_SCREENHEIGHT - 16, bufferofsonly ); //using topBarCenterOffsetX since bottbar dims == statbar dims
}
- //GameMemToScreen( shape, topBarCenterOffsetX, iGLOBAL_SCREENHEIGHT - 16, bufferofsonly ); //using topBarCenterOffsetX since bottbar dims == statbar dims
+ GameMemToScreen( shape, topBarCenterOffsetX, iGLOBAL_SCREENHEIGHT - 16, bufferofsonly ); //using topBarCenterOffsetX since bottbar dims == statbar dims
//}
@@ -4674,7 +4674,7 @@
rng = RandomNumber ("Died",0);
- rng = 191;
+ //rng = 191;
//zooms in on screen
if (pstate->falling==true)
--- a/rott/rt_main.c
+++ b/rott/rt_main.c
@@ -2198,6 +2198,8 @@
}
ControlPanel( LastScan );
+
+
// set detail level
doublestep = 2 - DetailLevel;
--- a/rott/rt_menu.c
+++ b/rott/rt_menu.c
@@ -1907,7 +1907,6 @@
Keyboard[ sc_F9 ] = 0;
loadsavesound = true;
- CP_LoadGame( 1, 0 );
break;
case sc_F10:
@@ -5735,7 +5734,7 @@
{
case 0:
if (!sdl_fullscreen){
- SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
+ SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
sdl_fullscreen ^= 1;
borderWindow = 0;
borderlessWindow = 0;
--- a/rott/rt_vid.c
+++ b/rott/rt_vid.c
@@ -905,6 +905,52 @@
screenfaded = true;
}
+void VL_FadeOutScaledScreen (int start, int end, int red, int green, int blue, int steps, float scale)
+{
+ int i,j,orig,delta;
+ byte *origptr, *newptr;
+
+ if (screenfaded)
+ return;
+
+ WaitVBL ();
+ VL_GetPalette (&palette1[0][0]);
+ memcpy (palette2, palette1, 768);
+
+//
+// fade through intermediate frames
+//
+ for (i = 0; i < steps; i++)
+ {
+ origptr = &palette1[start][0];
+ newptr = &palette2[start][0];
+
+ for (j = start; j <= end; j++)
+ {
+ orig = *origptr++;
+ delta = red-orig;
+ *newptr++ = orig + delta * i / steps;
+ orig = *origptr++;
+ delta = green-orig;
+ *newptr++ = orig + delta * i / steps;
+ orig = *origptr++;
+ delta = blue-orig;
+ *newptr++ = orig + delta * i / steps;
+ }
+
+ WaitVBL ();
+ VL_SetPalette (&palette2[0][0]);
+ DoScreenRotateScale(iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT, (SDL_Texture *) GetMainSurfaceAsTexture(), 0, scale);
+ }
+
+//
+// final color
+//
+ VL_FillPalette (red,green,blue);
+
+ screenfaded = true;
+}
+
/*
=================