shithub: choc

Download patch

ref: b393641f6daf3979354d143631113b0a946cf867
parent: 2170e4e9e6d28d9615afd71fc2a37cf8cc3dd324
author: Fabian Greffrath <fabian@greffrath.com>
date: Tue Sep 8 10:20:11 EDT 2015

factor disk load indicator out into separate src/v_diskicon.[ch] files

--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -79,6 +79,7 @@
 sha1.c               sha1.h                \
 memio.c              memio.h               \
 tables.c             tables.h              \
+v_diskicon.c         v_diskicon.h          \
 v_video.c            v_video.h             \
                      v_patch.h             \
 w_checksum.c         w_checksum.h          \
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -40,6 +40,7 @@
 #include "w_main.h"
 #include "w_wad.h"
 #include "s_sound.h"
+#include "v_diskicon.h"
 #include "v_video.h"
 
 #include "f_finale.h"
@@ -216,7 +217,7 @@
 	    break;
 	if (automapactive)
 	    AM_Drawer ();
-	if (wipe || (viewheight != 200 && fullscreen) || disk_indicator == disk_dirty )
+	if (wipe || (viewheight != 200 && fullscreen) || disk_indicator == disk_dirty)
 	    redrawsbar = true;
 	if (inhelpscreensstate && !inhelpscreens)
 	    redrawsbar = true;              // just put away the help screen
@@ -429,7 +430,7 @@
     I_GraphicsCheckCommandLine();
     I_SetGrabMouseCallback(D_GrabMouseCallback);
     I_InitGraphics();
-    I_EnableLoadingDisk(SCREENWIDTH - LOADING_DISK_W, SCREENHEIGHT - LOADING_DISK_H);
+    V_EnableLoadingDisk(SCREENWIDTH - LOADING_DISK_W, SCREENHEIGHT - LOADING_DISK_H);
 
     V_RestoreBuffer();
     R_ExecuteSetViewSize();
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -44,6 +44,7 @@
 #include "m_config.h"
 #include "m_misc.h"
 #include "tables.h"
+#include "v_diskicon.h"
 #include "v_video.h"
 #include "w_wad.h"
 #include "z_zone.h"
@@ -90,10 +91,6 @@
     '{', '|', '}', '~', 127
 };
 
-
-static int loading_disk_xoffs = 0;
-static int loading_disk_yoffs = 0;
-
 // Non aspect ratio-corrected modes (direct multiples of 320x200)
 
 static screen_mode_t *screen_modes[] = {
@@ -237,10 +234,6 @@
 
 static grabmouse_callback_t grabmouse_callback = NULL;
 
-// disk image patch (either STDISK or STCDROM) and
-// background overwritten by the disk to be restored by EndRead
-
-static patch_t *disk;
 static boolean window_focused;
 
 // Empty mouse cursor
@@ -391,21 +384,6 @@
     }
 }
 
-void I_EnableLoadingDisk(int xoffs, int yoffs)
-{
-    char *disk_name;
-
-    loading_disk_xoffs = xoffs;
-    loading_disk_yoffs = yoffs;
-
-    if (M_CheckParm("-cdrom") > 0)
-        disk_name = DEH_String("STCDROM");
-    else
-        disk_name = DEH_String("STDISK");
-
-    disk = W_CacheLumpName(disk_name, PU_STATIC);
-}
-
 //
 // Translates the SDL key
 //
@@ -931,15 +909,6 @@
     return result;
 }
 
-void I_BeginRead(void)
-{
-    if (!initialized || disk == NULL)
-        return;
-
-    // Draw the disk to the screen
-    V_DrawPatch(loading_disk_xoffs, loading_disk_yoffs, disk);
-}
-
 //
 // I_FinishUpdate
 //
@@ -988,8 +957,7 @@
 
     if (disk_indicator == disk_on)
     {
-	I_BeginRead();
-	disk_indicator = disk_dirty;
+	V_BeginRead();
     }
     else if (disk_indicator == disk_dirty)
     {
@@ -996,7 +964,7 @@
 	disk_indicator = disk_off;
     }
 
-   // draw to screen
+    // draw to screen
 
     BlitArea(0, 0, SCREENWIDTH, SCREENHEIGHT);
 
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -35,11 +35,6 @@
 
 #define SCREENHEIGHT_4_3 240
 
-// Dimensions of the flashing "loading" disk icon
-
-#define LOADING_DISK_W 16
-#define LOADING_DISK_H 16
-
 #define MAX_MOUSE_BUTTONS 8
 
 typedef struct
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -40,6 +40,7 @@
 #include "w_main.h"
 #include "w_wad.h"
 #include "s_sound.h"
+#include "v_diskicon.h"
 #include "v_video.h"
 
 #include "f_finale.h"
@@ -509,7 +510,7 @@
         I_InitGraphics();
     }
 
-    I_EnableLoadingDisk(SCREENWIDTH - LOADING_DISK_W, 0);
+    V_EnableLoadingDisk(SCREENWIDTH - LOADING_DISK_W, 0);
     I_SetGrabMouseCallback(D_GrabMouseCallback);
 
     V_RestoreBuffer();
--- /dev/null
+++ b/src/v_diskicon.c
@@ -1,0 +1,61 @@
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 2005-2014 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// DESCRIPTION:
+//	Disk load indicator.
+//
+
+#include "doomtype.h"
+#include "deh_str.h"
+#include "m_argv.h"
+#include "v_video.h"
+#include "w_wad.h"
+#include "z_zone.h"
+
+#include "v_diskicon.h"
+
+// disk image patch (either STDISK or STCDROM)
+
+static patch_t *disk;
+
+static int loading_disk_xoffs = 0;
+static int loading_disk_yoffs = 0;
+
+disk_indicator_e disk_indicator = false;
+
+void V_EnableLoadingDisk(int xoffs, int yoffs)
+{
+    char *disk_name;
+
+    loading_disk_xoffs = xoffs;
+    loading_disk_yoffs = yoffs;
+
+    if (M_CheckParm("-cdrom") > 0)
+        disk_name = DEH_String("STCDROM");
+    else
+        disk_name = DEH_String("STDISK");
+
+    disk = W_CacheLumpName(disk_name, PU_STATIC);
+}
+
+void V_BeginRead(void)
+{
+    if (disk == NULL)
+        return;
+
+    // Draw the disk to the screen
+    V_DrawPatch(loading_disk_xoffs, loading_disk_yoffs, disk);
+
+    disk_indicator = disk_dirty;
+}
--- /dev/null
+++ b/src/v_diskicon.h
@@ -1,0 +1,39 @@
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 2005-2014 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// DESCRIPTION:
+//	Disk load indicator.
+//
+
+#ifndef __V_DISKICON__
+#define __V_DISKICON__
+
+// Dimensions of the flashing "loading" disk icon
+
+#define LOADING_DISK_W 16
+#define LOADING_DISK_H 16
+
+typedef enum
+{
+    disk_off,
+    disk_on,
+    disk_dirty
+} disk_indicator_e;
+
+extern disk_indicator_e disk_indicator;
+
+extern void V_EnableLoadingDisk (int xoffs, int yoffs);
+extern void V_BeginRead (void);
+
+#endif
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -30,6 +30,7 @@
 #include "i_system.h"
 #include "i_video.h"
 #include "m_misc.h"
+#include "v_diskicon.h"
 #include "z_zone.h"
 
 #include "w_wad.h"
@@ -335,8 +336,6 @@
 // Loads the lump into the given buffer,
 //  which must be >= W_LumpLength().
 //
-disk_indicator_e disk_indicator = false;
-
 void W_ReadLump(lumpindex_t lump, void *dest)
 {
     int c;
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -49,14 +49,6 @@
     lumpindex_t next;
 };
 
-typedef enum
-{
-    disk_off,
-    disk_on,
-    disk_dirty
-} disk_indicator_e;
-
-extern disk_indicator_e disk_indicator;
 
 extern lumpinfo_t **lumpinfo;
 extern unsigned int numlumps;