commit b393641f6daf3979354d143631113b0a946cf867
Author: Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Tue Sep 8 14:20:11 2015 +0200
Commit: Fabian Greffrath <fabian@greffrath.com>
CommitDate: Tue Sep 8 14:20:11 2015 +0200
factor disk load indicator out into separate src/v_diskicon.[ch] files
---
src/Makefile.am | 1 +
src/doom/d_main.c | 5 +++--
src/i_video.c | 38 +++------------------------------
src/i_video.h | 5 -----
src/strife/d_main.c | 3 ++-
src/v_diskicon.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/v_diskicon.h | 39 ++++++++++++++++++++++++++++++++++
src/w_wad.c | 3 +--
src/w_wad.h | 8 -------
9 files changed, 110 insertions(+), 53 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 78ee3bae..384c15eb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -79,6 +79,7 @@ m_fixed.c m_fixed.h \
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 \
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index b5ce5bc3..ae4f11e6 100644
--- 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 @@ void D_Display (void)
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 @@ void D_DoomLoop (void)
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();
diff --git a/src/i_video.c b/src/i_video.c
index e1224eb3..61cfcdd8 100644
--- 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 @@ static const char shiftxform[] =
'{', '|', '}', '~', 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 boolean noblit;
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 @@ static void SetShowCursor(boolean show)
}
}
-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 @@ static boolean BlitArea(int x1, int y1, int x2, int y2)
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,15 +957,14 @@ void I_FinishUpdate (void)
if (disk_indicator == disk_on)
{
- I_BeginRead();
- disk_indicator = disk_dirty;
+ V_BeginRead();
}
else if (disk_indicator == disk_dirty)
{
disk_indicator = disk_off;
}
- // draw to screen
+ // draw to screen
BlitArea(0, 0, SCREENWIDTH, SCREENHEIGHT);
diff --git a/src/i_video.h b/src/i_video.h
index b8f015e6..49ccb607 100644
--- 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
diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index 0018e8ce..1fb808b7 100644
--- 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 @@ void D_DoomLoop (void)
I_InitGraphics();
}
- I_EnableLoadingDisk(SCREENWIDTH - LOADING_DISK_W, 0);
+ V_EnableLoadingDisk(SCREENWIDTH - LOADING_DISK_W, 0);
I_SetGrabMouseCallback(D_GrabMouseCallback);
V_RestoreBuffer();
diff --git a/src/v_diskicon.c b/src/v_diskicon.c
new file mode 100644
index 00000000..e2541dc0
--- /dev/null
+++ b/src/v_diskicon.c
@@ -0,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;
+}
diff --git a/src/v_diskicon.h b/src/v_diskicon.h
new file mode 100644
index 00000000..860c203c
--- /dev/null
+++ b/src/v_diskicon.h
@@ -0,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
diff --git a/src/w_wad.c b/src/w_wad.c
index 8831f0f1..bd2f83b3 100644
--- 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 @@ int W_LumpLength(lumpindex_t lump)
// 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;
diff --git a/src/w_wad.h b/src/w_wad.h
index 6a07c78f..06cf3951 100644
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -49,14 +49,6 @@ struct lumpinfo_s
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;