shithub: choc

Download patch

ref: 10cdf908ff5b897322452503fecef6d5b28c5015
parent: 993baaf1029e1379aea6a6045fff97015f042cce
author: Fabian Greffrath <fabian@greffrath.com>
date: Thu Sep 3 07:30:17 EDT 2015

factor out backing up of the background into its own function

--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1052,7 +1052,7 @@
     // and refresh all widgets
     ST_drawWidgets(true);
 
-    I_BeginRead(true);
+    I_PrepareRead();
 
 }
 
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -238,10 +238,9 @@
 
 static grabmouse_callback_t grabmouse_callback = NULL;
 
-// disk image patch name (either STDISK or STCDROM) and
+// disk image patch (either STDISK or STCDROM) and
 // background overwritten by the disk to be restored by EndRead
 
-static char *disk_name;
 static patch_t *disk;
 static byte *saved_background;
 static boolean window_focused;
@@ -396,6 +395,8 @@
 
 void I_EnableLoadingDisk(void)
 {
+    char *disk_name;
+
     if (M_CheckParm("-cdrom") > 0)
         disk_name = DEH_String("STCDROM");
     else
@@ -933,7 +934,7 @@
 
 static int readtic = 0;
 
-void I_BeginRead(boolean force)
+void I_PrepareRead()
 {
     byte *screenloc = I_VideoBuffer
                     + (SCREENHEIGHT - LOADING_DISK_H) * SCREENWIDTH
@@ -940,21 +941,31 @@
                     + (SCREENWIDTH - LOADING_DISK_W);
     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()
+{
     if (!initialized || disk == NULL)
         return;
 
     // save background if the disk isn't already drawn
 
-    if (!readtic || force)
+    if (!readtic)
     {
-        for (y=0; y<LOADING_DISK_H; ++y)
-        {
-            memcpy(saved_background + y * LOADING_DISK_W,
-                   screenloc,
-                   LOADING_DISK_W);
-
-            screenloc += SCREENWIDTH;
-        }
+        I_PrepareRead();
     }
 
     // Draw the disk to the screen
@@ -1048,7 +1059,7 @@
         }
         else
         {
-            I_BeginRead(false);
+            I_BeginRead();
         }
     }
 
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -109,7 +109,8 @@
 
 void I_ReadScreen (byte* scr);
 
-void I_BeginRead (boolean force);
+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
@@ -347,7 +347,7 @@
 
     l = lumpinfo[lump];
 
-    I_BeginRead(false);
+    I_BeginRead();
 
     c = W_Read(l->wad_file, l->position, dest, l->size);