shithub: rott

Download patch

ref: 08f210d26f692bb089505a8be7afc7556372a920
parent: 77cf26af2bff5a593a232ff0dcdeef35ad652f49
author: LTCHIPS <ltchips994@gmail.com>
date: Wed Mar 28 11:31:58 EDT 2018

Status Bar now streches w/o looking hideous

--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -62,7 +62,9 @@
 
 static SDL_Texture *sdl_texture = NULL;
 
+SDL_Surface *statusBarSurf = NULL;
 
+
 int    linewidth;
 //int    ylookup[MAXSCREENHEIGHT];
 int    ylookup[MAXSCREENHEIGHT];//just set to max res
@@ -473,6 +475,8 @@
     
     //sdl_surface = SDL_SetVideoMode (iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT, 8, flags);
     sdl_surface = SDL_CreateRGBSurface(0,iGLOBAL_SCREENWIDTH,iGLOBAL_SCREENHEIGHT,8,0,0,0,0);
+    
+    statusBarSurf = SDL_CreateRGBSurface(0, 320, 16, 8,0,0,0,0);
          
     SDL_SetSurfaceRLE(sdl_surface, 1);
                                         
@@ -716,7 +720,18 @@
 {
 }
 
+SDL_Texture* GetAreaTextrue(SDL_Rect rect, SDL_Renderer* renderer, SDL_Texture* source)
+{
+  SDL_Texture* result = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, rect.w, rect.h);          
+  SDL_SetRenderTarget(renderer, result);
+  SDL_RenderCopy(renderer, source, &rect, NULL);
+  // the folowing line should reset the target to default(the screen)
+  SDL_SetRenderTarget(renderer, NULL);  
+  // I also removed the RenderPresent funcion as it is not needed here      
+  return result;
+}
 
+
 /* C version of rt_vh_a.asm */
 
 void VH_UpdateScreen (void)
@@ -728,7 +743,19 @@
         DrawCenterAim ();
     }
     
-    //SDL_UpdateRect (SDL_GetVideoSurface (), 0, 0, 0, 0);
+    SDL_Rect statusBarRect;
+    
+    statusBarRect.w = 320;
+    statusBarRect.h = 16;
+    statusBarRect.x = (iGLOBAL_SCREENWIDTH - statusBarRect.w) >> 1;;
+    statusBarRect.y = 0;
+    
+    SDL_Rect statusBarRect2;
+    
+    statusBarRect2.w = 320<<1;
+    statusBarRect2.h = 16<<1;
+    statusBarRect2.x = (iGLOBAL_SCREENWIDTH - statusBarRect.w) >> 1;
+    statusBarRect2.y = 0;
     SDL_Texture *newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
     if (newTex == NULL) {
         Error("CreateTextureFromSurface failed: %s\n", SDL_GetError());
@@ -735,11 +762,16 @@
         exit(1);
     }
     
+    SDL_Texture * statusBar = GetAreaTextrue(statusBarRect, renderer, newTex);
+    
     SDL_RenderClear(renderer);
     SDL_RenderCopy(renderer, newTex, NULL, NULL);
+    SDL_RenderCopy(renderer, myTexPart, NULL, &statusBarRect2);
+    
     SDL_RenderPresent(renderer);
     
     SDL_DestroyTexture(newTex);
+    SDL_DestroyTexture(statusBar);
 }
 
 
@@ -767,12 +799,26 @@
     if (bufferofs > page3start)
         bufferofs = page1start;
 #else
+    
+    
     if (StretchScreen) { //bna++
         StretchMemPicture ();
     } else {
         DrawCenterAim ();
     }
+    SDL_Rect statusBarRect;
     
+    statusBarRect.w = 320;
+    statusBarRect.h = 16;
+    statusBarRect.x = (iGLOBAL_SCREENWIDTH - statusBarRect.w) >> 1;;
+    statusBarRect.y = 0;
+    
+    SDL_Rect statusBarRect2;
+    
+    statusBarRect2.w = 320<<1;
+    statusBarRect2.h = 16<<1;
+    statusBarRect2.x = (iGLOBAL_SCREENWIDTH - statusBarRect2.w) >> 1;
+    statusBarRect2.y = 0;
     SDL_Texture *newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
     if (newTex == NULL) {
         Error("CreateTextureFromSurface failed: %s\n", SDL_GetError());
@@ -779,11 +825,19 @@
         exit(1);
     }
     
+    SDL_Texture * statusBar = GetAreaTextrue(statusBarRect, renderer, newTex);
+
+
+    
     SDL_RenderClear(renderer);
     SDL_RenderCopy(renderer, newTex, NULL, NULL);
+    SDL_RenderCopy(renderer, statusBar, NULL, &statusBarRect2);
+    
     SDL_RenderPresent(renderer);
     
     SDL_DestroyTexture(newTex);
+    SDL_DestroyTexture(statusBar);
+    
     //SDL_UpdateRect (sdl_surface, 0, 0, 0, 0);s
 
 #endif