foxygit / doom Log in
commit 165b0bddfdbd55c07f86895bd14d6725bff9e61d
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Tue Sep 1 15:14:31 2015 +0200
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Tue Sep 1 15:14:31 2015 +0200

    Video: Show a disk icon if lumps have been read in the previous tic

    This restores the disk icon that is displayed in the bottom right
    corner of the screen whenever lumps are loaded. Instead of being drawn
    and probably overdrawn again within the same tic, the icon is now
    shown for at least one full tic. Also, the icon is not scaled to the
    screen in its own step anymore, but is merely projected into
    I_VideoBuffer and then scaled with the rest of the scren at the
    end of the respective tic.

    This closes #603 and lets us get rid up UpdateRect() entirely.
---
 src/i_video.c | 20 ++++++++++++++------
 src/w_wad.c   |  2 --
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index ec0fc58f..f60b5414 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -31,6 +31,7 @@
 #include "icon.c"

 #include "config.h"
+#include "d_loop.h"
 #include "deh_str.h"
 #include "doomtype.h"
 #include "doomkeys.h"
@@ -992,6 +993,8 @@ static void UpdateRect(int x1, int y1, int x2, int y2)
     }
 }

+static int readtic;
+
 void I_BeginRead(void)
 {
     byte *screenloc = I_VideoBuffer
@@ -1002,6 +1005,8 @@ void I_BeginRead(void)
     if (!initialized || disk_image == NULL)
         return;

+    readtic = gametic;
+
     // save background and copy the disk image in

     for (y=0; y<LOADING_DISK_H; ++y)
@@ -1015,9 +1020,6 @@ void I_BeginRead(void)

         screenloc += SCREENWIDTH;
     }
-
-    UpdateRect(SCREENWIDTH - LOADING_DISK_W, SCREENHEIGHT - LOADING_DISK_H,
-               SCREENWIDTH, SCREENHEIGHT);
 }

 void I_EndRead(void)
@@ -1030,6 +1032,8 @@ void I_EndRead(void)
     if (!initialized || disk_image == NULL)
         return;

+    readtic = 0;
+
     // save background and copy the disk image in

     for (y=0; y<LOADING_DISK_H; ++y)
@@ -1040,9 +1044,6 @@ void I_EndRead(void)

         screenloc += SCREENWIDTH;
     }
-
-    UpdateRect(SCREENWIDTH - LOADING_DISK_W, SCREENHEIGHT - LOADING_DISK_H,
-               SCREENWIDTH, SCREENHEIGHT);
 }

 //
@@ -1091,6 +1092,13 @@ 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 && gametic > readtic)
+    {
+        I_EndRead();
+    }
+
     // draw to screen

     BlitArea(0, 0, SCREENWIDTH, SCREENHEIGHT);
diff --git a/src/w_wad.c b/src/w_wad.c
index 32924dec..5714134a 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -356,8 +356,6 @@ void W_ReadLump(lumpindex_t lump, void *dest)
         I_Error("W_ReadLump: only read %i of %i on lump %i",
                 c, l->size, lump);
     }
-
-    I_EndRead();
 }