shithub: choc

Download patch

ref: 993baaf1029e1379aea6a6045fff97015f042cce
parent: 97888140d15254059c5520fba21ba2bfc6d0bf86
author: Fabian Greffrath <fabian@greffrath.com>
date: Thu Sep 3 05:25:22 EDT 2015

Pass a parameter to I_BeginRead() to force it to backup the background

Also, draw disk icon by means of V_DrawPatch(), thanks @jmtd.

--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1052,6 +1052,8 @@
     // and refresh all widgets
     ST_drawWidgets(true);
 
+    I_BeginRead(true);
+
 }
 
 void ST_diffDraw(void)
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -238,10 +238,11 @@
 
 static grabmouse_callback_t grabmouse_callback = NULL;
 
-// disk image data and background overwritten by the disk to be
-// restored by EndRead
+// disk image patch name (either STDISK or STCDROM) and
+// background overwritten by the disk to be restored by EndRead
 
-static byte *disk_image = NULL;
+static char *disk_name;
+static patch_t *disk;
 static byte *saved_background;
 static boolean window_focused;
 
@@ -395,14 +396,6 @@
 
 void I_EnableLoadingDisk(void)
 {
-    patch_t *disk;
-    byte *tmpbuf;
-    char *disk_name;
-    int y;
-    char buf[20];
-
-    SDL_VideoDriverName(buf, 15);
-
     if (M_CheckParm("-cdrom") > 0)
         disk_name = DEH_String("STCDROM");
     else
@@ -410,31 +403,7 @@
 
     disk = W_CacheLumpName(disk_name, PU_STATIC);
 
-    // Draw the patch into a temporary buffer
-
-    tmpbuf = Z_Malloc(SCREENWIDTH * (disk->height + 1), PU_STATIC, NULL);
-    V_UseBuffer(tmpbuf);
-
-    // Draw the disk to the screen:
-
-    V_DrawPatch(0, 0, disk);
-
-    disk_image = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL);
     saved_background = Z_Malloc(LOADING_DISK_W * LOADING_DISK_H, PU_STATIC, NULL);
-
-    for (y=0; y<LOADING_DISK_H; ++y) 
-    {
-        memcpy(disk_image + LOADING_DISK_W * y,
-               tmpbuf + SCREENWIDTH * y,
-               LOADING_DISK_W);
-    }
-
-    // All done - free the screen buffer and restore the normal 
-    // video buffer.
-
-    W_ReleaseLumpName(disk_name);
-    V_RestoreBuffer();
-    Z_Free(tmpbuf);
 }
 
 //
@@ -964,7 +933,7 @@
 
 static int readtic = 0;
 
-void I_BeginRead(void)
+void I_BeginRead(boolean force)
 {
     byte *screenloc = I_VideoBuffer
                     + (SCREENHEIGHT - LOADING_DISK_H) * SCREENWIDTH
@@ -971,26 +940,30 @@
                     + (SCREENWIDTH - LOADING_DISK_W);
     int y;
 
-    if (!initialized || disk_image == NULL)
+    if (!initialized || disk == NULL)
         return;
 
-    for (y=0; y<LOADING_DISK_H; ++y)
+    // save background if the disk isn't already drawn
+
+    if (!readtic || force)
     {
-        // save background if the disk isn't already drawn
-        if (!readtic)
+        for (y=0; y<LOADING_DISK_H; ++y)
         {
             memcpy(saved_background + y * LOADING_DISK_W,
                    screenloc,
                    LOADING_DISK_W);
+
+            screenloc += SCREENWIDTH;
         }
+    }
 
-        // copy the disk image in
-        memcpy(screenloc,
-               disk_image + y * LOADING_DISK_W,
-               LOADING_DISK_W);
+    // Draw the disk to the screen
 
-        screenloc += SCREENWIDTH;
-    }
+    V_DrawPatch(
+        SCREENWIDTH - LOADING_DISK_W,
+        SCREENHEIGHT - LOADING_DISK_H,
+        disk
+    );
 
     readtic = gametic;
 }
@@ -1075,7 +1048,7 @@
         }
         else
         {
-            I_BeginRead();
+            I_BeginRead(false);
         }
     }
 
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -109,7 +109,7 @@
 
 void I_ReadScreen (byte* scr);
 
-void I_BeginRead (void);
+void I_BeginRead (boolean force);
 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();
+    I_BeginRead(false);
 
     c = W_Read(l->wad_file, l->position, dest, l->size);