commit 10cdf908ff5b897322452503fecef6d5b28c5015
Author: Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Thu Sep 3 11:30:17 2015 +0200
Commit: Fabian Greffrath <fabian@greffrath.com>
CommitDate: Thu Sep 3 11:30:17 2015 +0200
factor out backing up of the background into its own function
---
src/doom/st_stuff.c | 2 +-
src/i_video.c | 37 ++++++++++++++++++++++++-------------
src/i_video.h | 3 ++-
src/w_wad.c | 2 +-
4 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c
index 309d6dce..146ec12d 100644
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1052,7 +1052,7 @@ void ST_doRefresh(void)
// and refresh all widgets
ST_drawWidgets(true);
- I_BeginRead(true);
+ I_PrepareRead();
}
diff --git a/src/i_video.c b/src/i_video.c
index 8cd69552..1602ba5f 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -238,10 +238,9 @@ static boolean noblit;
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 @@ static void SetShowCursor(boolean show)
void I_EnableLoadingDisk(void)
{
+ char *disk_name;
+
if (M_CheckParm("-cdrom") > 0)
disk_name = DEH_String("STCDROM");
else
@@ -933,28 +934,38 @@ static boolean BlitArea(int x1, int y1, int x2, int y2)
static int readtic = 0;
-void I_BeginRead(boolean force)
+void I_PrepareRead()
{
byte *screenloc = I_VideoBuffer
+ (SCREENHEIGHT - LOADING_DISK_H) * SCREENWIDTH
+ (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 @@ void I_FinishUpdate (void)
}
else
{
- I_BeginRead(false);
+ I_BeginRead();
}
}
diff --git a/src/i_video.h b/src/i_video.h
index 702c8d37..64fe3f9d 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -109,7 +109,8 @@ void I_FinishUpdate (void);
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);
diff --git a/src/w_wad.c b/src/w_wad.c
index 4761feac..5714134a 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -347,7 +347,7 @@ void W_ReadLump(lumpindex_t lump, void *dest)
l = lumpinfo[lump];
- I_BeginRead(false);
+ I_BeginRead();
c = W_Read(l->wad_file, l->position, dest, l->size);