ref: fafb43915bdf355ed6abb4ca26a76daf1ae4625d
parent: b6499d0a18497fdd23c6188b54d4191f3b670f40
author: LTCHIPS <ltchips994@gmail.com>
date: Tue May 1 15:35:44 EDT 2018
getting somewhere with screen rotate rewrite...
--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -1047,29 +1047,35 @@
DrawCenterAim ();
}
- int zoomedSurfWidth = 0;
+ //int zoomedSurfWidth = 0;
- int zoomedSurfHeight = 0;
+ //int zoomedSurfHeight = 0;
- SDL_SetRelativeMouseMode(SDL_FALSE);
+ //SDL_SetRelativeMouseMode(SDL_FALSE);
- //SDL_Surface * temp = SDL_ConvertSurfaceFormat(sdl_surface, SDL_PIXELFORMAT_ABGR32,0);
+ //rotozoomSurfaceSize(sdl_surface->w, sdl_surface->h, angle,zoom/100, &zoomedSurfWidth, &zoomedSurfHeight);
- rotozoomSurfaceSize(sdl_surface->w, sdl_surface->h, 0, 2, &zoomedSurfWidth, &zoomedSurfHeight);
+ //sdl_zoomed_surface = SDL_CreateRGBSurface(0,zoomedSurfWidth,zoomedSurfHeight,8,0,0,0,0);
- sdl_zoomed_surface = SDL_CreateRGBSurface(0,zoomedSurfWidth,zoomedSurfHeight,8,0,0,0,0);
+ //SDL_SetSurfaceRLE(sdl_zoomed_surface, 1);
- if (sdl_zoomed_surface == NULL)
- {
- Error("Out of memory for rotated surface");
- exit(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);
- sdl_zoomed_surface = rotozoomSurface(sdl_surface, 0, 2, 0);
+ //memcpy(sdl_zoomed_surface->pixels, sdl_surface->pixels, sizeof(byte)*iGLOBAL_SCREENHEIGHT*iGLOBAL_SCREENWIDTH);
- SDL_Texture *newTex = SDL_CreateTextureFromSurface(renderer, sdl_zoomed_surface);
+ //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());
@@ -1079,34 +1085,43 @@
SDL_RenderClear(renderer);
- SDL_RenderCopyEx(renderer, newTex, NULL, NULL, angle, NULL, SDL_FLIP_NONE);
+ SDL_RenderSetScale(renderer, (float)zoom/100, (float)zoom/100);
-/*
- if (!StretchScreen && hudRescaleFactor > 1 && doRescaling)
- {
- if(SHOW_TOP_STATUS_BAR())
- RescaleAreaOfTexture(renderer, newTex, (SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, 0, 320, 16},
- (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320 * hudRescaleFactor)) >> 1, 0, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Status Bar
- if(SHOW_BOTTOM_STATUS_BAR())
- RescaleAreaOfTexture(renderer, newTex,(SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, iGLOBAL_SCREENHEIGHT - 16, 320, 16},
- (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320* hudRescaleFactor)) >> 1, iGLOBAL_SCREENHEIGHT - 16*hudRescaleFactor, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Bottom Bar
-
- }
-*/
+ //SDL_RenderSetLogicalSize(renderer, zoomedSurfWidth, zoomedSurfHeight);
+ //SDL_RenderCopy(renderer, newTex, NULL, NULL);
+
+ SDL_RenderCopyEx(renderer, newTex, NULL, NULL, angle, NULL, SDL_FLIP_NONE);
+
SDL_RenderPresent(renderer);
SDL_DestroyTexture(newTex);
- SDL_SetRelativeMouseMode(SDL_TRUE);
+ //SDL_RenderSetLogicalSize(renderer, iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT);
- //RenderSurface();
+
+ //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
@@ -3293,16 +3293,18 @@
angle = startangle;
- scale = startscale;
+ scale = startscale>>16;
//scale=(startscale<<6);
CalcTics();
CalcTics();
+ SDL_SetRelativeMouseMode(SDL_FALSE);
+
for (i=0; i<time; i+=tics)
{ //zxcv
//DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,(angle>>16)&(FINEANGLES-1),scale>>6,0);
- FlipPageRotoZoom(angle,scale );
+ FlipPageRotoZoom((angle), scale);
//FlipPage();
scale+=(scalestep*tics);
@@ -3312,6 +3314,8 @@
FreeSDLSurfaceZoom();
+ SDL_SetRelativeMouseMode(SDL_TRUE);
+
DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,endangle&(FINEANGLES-1),endscale,0);
//FlipPage();
DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,endangle&(FINEANGLES-1),endscale,0);
@@ -3398,10 +3402,15 @@
xst = (((-cx)*s)+((328)<<16))-(cy*c);
xct = (((-cx)*c)+((397)<<16)+(1<<18)-(1<<16))+(cy*s);
}//328 397
- else if ((iGLOBAL_SCREENWIDTH >= 1024 )&&(masked == false)) {
+ else if ((iGLOBAL_SCREENWIDTH == 1024 )&&(masked == false)) {
xst = (((-cx)*s)+((410)<<16))-(cy*c);// 1024/768=1.3333
xct = (((-cx)*c)+((500)<<16)+(1<<18)-(1<<16))+(cy*s);
}//388 397
+ else if ((iGLOBAL_SCREENWIDTH >= 1152) && (masked == false))
+ {
+ xst = (((-cx)*s)+((432)<<16))-(cy*c);
+ xct = (((-cx)*c)+((576)<<16)+(1<<18)-(1<<16))+(cy*s);
+ }
mr_xstep=s;
mr_ystep=c;
@@ -3632,8 +3641,9 @@
while (!Keyboard[sc_Escape])
{
IN_UpdateKeyboard ();
- DrawRotatedScreen(160,100,(byte *)bufferofs,angle,scale,0);
- FlipPage();
+ //DrawRotatedScreen(iGLOBAL_SCREENWIDTH/2,iGLOBAL_SCREENHEIGHT/2,(byte *)bufferofs,angle,scale,0);
+ FlipPageRotoZoom(angle, scale);
+ //FlipPage();
CalcTics();
INL_GetMouseDelta(&x, &y);
buttons=IN_GetMouseButtons ();
@@ -6098,7 +6108,7 @@
*/
while (count--) {
eax = edx >> 16;
- if (eax < (256*(iGLOBAL_SCREENWIDTH/320)) && (ecx >> 16) < (512*((iGLOBAL_SCREENWIDTH/320 + iGLOBAL_SCREENHEIGHT/200)<<1))) {
+ if (eax < (256*4) && (ecx >> 16) < (512*4)) {
eax = (eax << 10) | ((ecx << 6) >> (32-10));
} else {
eax = 0;