foxygit / doom Log in
commit 7a29515569b6543c31b1fc0b2ef4875ab75708b6
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Sat Sep 5 11:51:40 2015 +0200
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Sat Sep 5 11:51:40 2015 +0200

    get entirely rid of background saving and restoring
---
 src/doom/d_main.c   | 12 +++++++++
 src/doom/st_stuff.c |  2 --
 src/i_video.c       | 75 +++--------------------------------------------------
 src/i_video.h       |  2 --
 src/w_wad.c         |  4 ++-
 src/w_wad.h         |  1 +
 6 files changed, 19 insertions(+), 77 deletions(-)

diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index c62f039a..48241d3c 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -182,10 +182,17 @@ void D_Display (void)
     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 @@ void D_Display (void)
     // normal update
     if (!wipe)
     {
+	if (disk_indicator)
+	{
+	    force_redrawsbar = true;
+	}
+
 	I_FinishUpdate ();              // page flip or blit buffer
 	return;
     }
diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c
index 146ec12d..72c1797f 100644
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1052,8 +1052,6 @@ void ST_doRefresh(void)
     // and refresh all widgets
     ST_drawWidgets(true);

-    I_PrepareRead();
-
 }

 void ST_diffDraw(void)
diff --git a/src/i_video.c b/src/i_video.c
index ddc9a7df..48a0594b 100644
--- 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 @@ static grabmouse_callback_t grabmouse_callback = NULL;
 // 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 @@ void I_EnableLoadingDisk(int xoffs, int yoffs)
         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,70 +931,13 @@ static boolean BlitArea(int x1, int y1, int x2, int y2)
     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;
 }

 //
@@ -1047,18 +986,10 @@ void I_FinishUpdate (void)
 	    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
diff --git a/src/i_video.h b/src/i_video.h
index 4b24d12e..b8f015e6 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -114,9 +114,7 @@ void I_FinishUpdate (void);

 void I_ReadScreen (byte* scr);

-void I_PrepareRead (void);
 void I_BeginRead (void);
-void I_EndRead (void);

 void I_SetWindowTitle(char *title);

diff --git a/src/w_wad.c b/src/w_wad.c
index 5714134a..21c9c0bd 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -335,6 +335,8 @@ int W_LumpLength(lumpindex_t lump)
 // 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 @@ void W_ReadLump(lumpindex_t lump, void *dest)

     l = lumpinfo[lump];

-    I_BeginRead();
+    disk_indicator = true;

     c = W_Read(l->wad_file, l->position, dest, l->size);

diff --git a/src/w_wad.h b/src/w_wad.h
index 06cf3951..03bae344 100644
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -52,6 +52,7 @@ struct lumpinfo_s

 extern lumpinfo_t **lumpinfo;
 extern unsigned int numlumps;
+extern boolean disk_indicator;

 wad_file_t *W_AddFile(char *filename);
 void W_Reload(void);