ref: 665e472b460274c6109b6e51e586fef04aa34bf2
parent: cb4848b8daf84077e6b770900353389838a5a9a3
parent: b393641f6daf3979354d143631113b0a946cf867
author: Fabian Greffrath <fabian@greffrath.com>
date: Sun Nov 1 13:34:25 EST 2015
Merge pull request #634 from chocolate-doom/diskicon Diskicon
--- 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) )
+ 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();
+ 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
};
-
-#define LOADING_DISK_W 16
-#define LOADING_DISK_H 16
-
// Non aspect ratio-corrected modes (direct multiples of 320x200)
static screen_mode_t *screen_modes[] = {
@@ -237,11 +234,6 @@
static grabmouse_callback_t grabmouse_callback = NULL;
-// disk image data and background overwritten by the disk to be
-// restored by EndRead
-
-static byte *disk_image = NULL;
-static byte *saved_background;
static boolean window_focused;
// Empty mouse cursor
@@ -392,59 +384,6 @@
}
}
-void I_EnableLoadingDisk(void)
-{
- patch_t *disk;
- byte *tmpbuf;
- char *disk_name;
- int y;
- char buf[20];
-
- SDL_VideoDriverName(buf, 15);
-
- if (!strcmp(buf, "Quartz"))
- {
- // MacOS Quartz gives us pageflipped graphics that screw up the
- // display when we use the loading disk. Disable it.
- // This is a gross hack.
-
- return;
- }
-
- if (M_CheckParm("-cdrom") > 0)
- disk_name = DEH_String("STCDROM");
- else
- disk_name = DEH_String("STDISK");
-
- 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);
-}
-
//
// Translates the SDL key
//
@@ -970,81 +909,6 @@
return result;
}
-static void UpdateRect(int x1, int y1, int x2, int y2)
-{
- int x1_scaled, x2_scaled, y1_scaled, y2_scaled;
-
- // Do stretching and blitting
-
- if (BlitArea(x1, y1, x2, y2))
- {
- // Update the area
-
- x1_scaled = (x1 * screen_mode->width) / SCREENWIDTH;
- y1_scaled = (y1 * screen_mode->height) / SCREENHEIGHT;
- x2_scaled = (x2 * screen_mode->width) / SCREENWIDTH;
- y2_scaled = (y2 * screen_mode->height) / SCREENHEIGHT;
-
- SDL_UpdateRect(screen,
- x1_scaled, y1_scaled,
- x2_scaled - x1_scaled,
- y2_scaled - y1_scaled);
- }
-}
-
-void I_BeginRead(void)
-{
- byte *screenloc = I_VideoBuffer
- + (SCREENHEIGHT - LOADING_DISK_H) * SCREENWIDTH
- + (SCREENWIDTH - LOADING_DISK_W);
- int y;
-
- if (!initialized || disk_image == NULL)
- return;
-
- // save background and copy the disk image in
-
- for (y=0; y<LOADING_DISK_H; ++y)
- {
- memcpy(saved_background + y * LOADING_DISK_W,
- screenloc,
- LOADING_DISK_W);
- memcpy(screenloc,
- disk_image + y * LOADING_DISK_W,
- LOADING_DISK_W);
-
- screenloc += SCREENWIDTH;
- }
-
- UpdateRect(SCREENWIDTH - LOADING_DISK_W, SCREENHEIGHT - LOADING_DISK_H,
- SCREENWIDTH, SCREENHEIGHT);
-}
-
-void I_EndRead(void)
-{
- byte *screenloc = I_VideoBuffer
- + (SCREENHEIGHT - LOADING_DISK_H) * SCREENWIDTH
- + (SCREENWIDTH - LOADING_DISK_W);
- int y;
-
- if (!initialized || disk_image == NULL)
- return;
-
- // save background and copy the disk image in
-
- for (y=0; y<LOADING_DISK_H; ++y)
- {
- memcpy(screenloc,
- saved_background + y * LOADING_DISK_W,
- LOADING_DISK_W);
-
- screenloc += SCREENWIDTH;
- }
-
- UpdateRect(SCREENWIDTH - LOADING_DISK_W, SCREENHEIGHT - LOADING_DISK_H,
- SCREENWIDTH, SCREENHEIGHT);
-}
-
//
// I_FinishUpdate
//
@@ -1089,6 +953,15 @@
I_VideoBuffer[ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0xff;
for ( ; i<20*4 ; i+=4)
I_VideoBuffer[ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0;
+ }
+
+ if (disk_indicator == disk_on)
+ {
+ V_BeginRead();
+ }
+ else if (disk_indicator == disk_dirty)
+ {
+ disk_indicator = disk_off;
}
// draw to screen
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -110,7 +110,6 @@
void I_ReadScreen (byte* scr);
void I_BeginRead (void);
-void I_EndRead (void);
void I_SetWindowTitle(char *title);
@@ -135,7 +134,7 @@
// Enable the loading disk image displayed when reading from disk.
-void I_EnableLoadingDisk(void);
+void I_EnableLoadingDisk(int xoffs, int yoffs);
extern char *video_driver;
extern boolean screenvisible;
--- 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"
@@ -300,7 +301,7 @@
// see if the border needs to be updated to the screen
if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320)
{
- if (menuactive || menuactivestate || !viewactivestate)
+ if (menuactive || menuactivestate || !viewactivestate || disk_indicator == disk_dirty)
{
borderdrawcount = 3;
popupactivestate = false;
@@ -509,7 +510,7 @@
I_InitGraphics();
}
- I_EnableLoadingDisk();
+ 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"
@@ -347,7 +348,7 @@
l = lumpinfo[lump];
- I_BeginRead();
+ disk_indicator = disk_on;
c = W_Read(l->wad_file, l->position, dest, l->size);
@@ -356,8 +357,6 @@
I_Error("W_ReadLump: only read %i of %i on lump %i",
c, l->size, lump);
}
-
- I_EndRead();
}