shithub: choc

Download patch

ref: 7a29515569b6543c31b1fc0b2ef4875ab75708b6
parent: b3f6b7715c613aa96a7192d8385a6af471b3fc2f
author: Fabian Greffrath <fabian@greffrath.com>
date: Sat Sep 5 07:51:40 EDT 2015

get entirely rid of background saving and restoring

--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -182,10 +182,17 @@
     boolean			done;
     boolean			wipe;
     boolean			redrawsbar;
+    static boolean force_redrawsbar = false;
 
     if (nodrawers)
 	return;                    // for comparative timing / profiling
 		
+    if (force_redrawsbar)
+    {
+	redrawsbar = true;
+	force_redrawsbar = false;
+    }
+    else
     redrawsbar = false;
     
     // change the view size if needed
@@ -303,6 +310,11 @@
     // normal update
     if (!wipe)
     {
+	if (disk_indicator)
+	{
+	    force_redrawsbar = true;
+	}
+
 	I_FinishUpdate ();              // page flip or blit buffer
 	return;
     }
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1052,8 +1052,6 @@
     // and refresh all widgets
     ST_drawWidgets(true);
 
-    I_PrepareRead();
-
 }
 
 void ST_diffDraw(void)
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -31,7 +31,6 @@
 #include "icon.c"
 
 #include "config.h"
-#include "d_loop.h"
 #include "deh_str.h"
 #include "doomtype.h"
 #include "doomkeys.h"
@@ -242,7 +241,6 @@
 // background overwritten by the disk to be restored by EndRead
 
 static patch_t *disk;
-static byte *saved_background;
 static boolean window_focused;
 
 // Empty mouse cursor
@@ -406,8 +404,6 @@
         disk_name = DEH_String("STDISK");
 
     disk = W_CacheLumpName(disk_name, PU_STATIC);
-
-    saved_background = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL);
 }
 
 //
@@ -935,72 +931,15 @@
     return result;
 }
 
-static int readtic = 0;
-
-void I_PrepareRead(void)
-{
-    byte *screenloc = I_VideoBuffer
-                    + loading_disk_yoffs * SCREENWIDTH
-                    + loading_disk_xoffs;
-    int y;
-
-    if (!initialized || saved_background == NULL)
-        return;
-
-    // save background
-
-    for (y=0; y<LOADING_DISK_H; ++y)
-    {
-        memcpy(saved_background + y * LOADING_DISK_W,
-               screenloc,
-               LOADING_DISK_W);
-
-        screenloc += SCREENWIDTH;
-    }
-}
-
 void I_BeginRead(void)
 {
     if (!initialized || disk == NULL)
         return;
 
-    // save background if the disk isn't already drawn
-
-    if (!readtic)
-    {
-        I_PrepareRead();
-    }
-
     // Draw the disk to the screen
     V_DrawPatch(loading_disk_xoffs, loading_disk_yoffs, disk);
-
-    readtic = gametic;
 }
 
-void I_EndRead(void)
-{
-    byte *screenloc = I_VideoBuffer
-                    + loading_disk_yoffs * SCREENWIDTH
-                    + loading_disk_xoffs;
-    int y;
-
-    if (!initialized || saved_background == NULL)
-        return;
-
-    // restore background from beneath disk indicator
-
-    for (y=0; y<LOADING_DISK_H; ++y)
-    {
-        memcpy(screenloc,
-               saved_background + y * LOADING_DISK_W,
-               LOADING_DISK_W);
-
-        screenloc += SCREENWIDTH;
-    }
-
-    readtic = 0;
-}
-
 //
 // I_FinishUpdate
 //
@@ -1047,18 +986,10 @@
 	    I_VideoBuffer[ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0;
     }
 
-    // show a disk icon if lumps have been read in the previous tic
-
-    if (readtic)
+    if (disk_indicator)
     {
-        if (gametic > readtic)
-        {
-            I_EndRead();
-        }
-        else
-        {
-            I_BeginRead();
-        }
+	I_BeginRead();
+	disk_indicator = false;
     }
 
     // draw to screen
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -114,9 +114,7 @@
 
 void I_ReadScreen (byte* scr);
 
-void I_PrepareRead (void);
 void I_BeginRead (void);
-void I_EndRead (void);
 
 void I_SetWindowTitle(char *title);
 
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -335,6 +335,8 @@
 // Loads the lump into the given buffer,
 //  which must be >= W_LumpLength().
 //
+boolean disk_indicator = false;
+
 void W_ReadLump(lumpindex_t lump, void *dest)
 {
     int c;
@@ -347,7 +349,7 @@
 
     l = lumpinfo[lump];
 
-    I_BeginRead();
+    disk_indicator = true;
 
     c = W_Read(l->wad_file, l->position, dest, l->size);
 
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -52,6 +52,7 @@
 
 extern lumpinfo_t **lumpinfo;
 extern unsigned int numlumps;
+extern boolean disk_indicator;
 
 wad_file_t *W_AddFile(char *filename);
 void W_Reload(void);