[chocolate-doom] 27/83: Loading disk

Jonathan Dowland jmtd at moszumanska.debian.org
Mon Jan 30 15:06:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

jmtd pushed a commit to annotated tag chocolate-doom-0.0.1
in repository chocolate-doom.

commit 636dc9bb6ba074a9c863d4d9d0a3e3b704b20f4e
Author: Simon Howard <fraggle at gmail.com>
Date:   Thu Aug 4 01:13:46 2005 +0000

    Loading disk
    
    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 33
---
 src/i_video.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 src/w_wad.c   |  11 ++++---
 2 files changed, 102 insertions(+), 11 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index baa4fb4..28ced01 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: i_video.c 31 2005-08-03 22:19:52Z fraggle $
+// $Id: i_video.c 33 2005-08-04 01:13:46Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.10  2005/08/04 01:13:46  fraggle
+// Loading disk
+//
 // Revision 1.9  2005/08/03 22:19:52  fraggle
 // Set some flags to fix palette and improve performance
 //
@@ -59,15 +62,17 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: i_video.c 31 2005-08-03 22:19:52Z fraggle $";
+rcsid[] = "$Id: i_video.c 33 2005-08-04 01:13:46Z fraggle $";
 
 #include <ctype.h>
 #include <SDL.h>
 
+#include "z_zone.h"
 #include "doomstat.h"
 #include "i_system.h"
 #include "v_video.h"
 #include "m_argv.h"
+#include "m_swap.h"
 #include "d_main.h"
 
 #include "doomdef.h"
@@ -85,7 +90,90 @@ boolean		grabMouse;
 // replace each 320x200 pixel with multiply*multiply pixels.
 // According to Dave Taylor, it still is a bonehead thing
 // to use ....
-static int	multiply=2;
+static int	multiply=1;
+
+// disk image data and background overwritten by the disk to be
+// restored by EndRead
+
+static byte *disk_image = NULL;
+static int disk_image_w, disk_image_h;
+static byte *saved_background;
+
+void I_BeginRead(void)
+{
+    int y;
+
+    if (disk_image == NULL)
+        return;
+
+    // save background and copy the disk image in
+
+    for (y=0; y<disk_image_h; ++y)
+    {
+        byte *screenloc = 
+               screens[0] 
+                 + (SCREENHEIGHT - 1 - disk_image_h + y) * SCREENWIDTH
+                 + (SCREENWIDTH - 1 - disk_image_w);
+
+        memcpy(saved_background + y * disk_image_w,
+               screenloc,
+               disk_image_w);
+        memcpy(screenloc, disk_image + y * disk_image_w, disk_image_w);
+    }
+
+    SDL_UpdateRect(screen, 
+                   screen->w - disk_image_w, screen->h - disk_image_h, 
+                   disk_image_w, disk_image_h);
+}
+
+void I_EndRead(void)
+{
+    int y;
+
+    if (disk_image == NULL)
+        return;
+
+    // save background and copy the disk image in
+
+    for (y=0; y<disk_image_h; ++y)
+    {
+        byte *screenloc = 
+               screens[0] 
+                 + (SCREENHEIGHT - 1 - disk_image_h + y) * SCREENWIDTH
+                 + (SCREENWIDTH - 1 - disk_image_w);
+
+        memcpy(screenloc, saved_background + y * disk_image_w, disk_image_w);
+    }
+
+    SDL_UpdateRect(screen, 
+                   screen->w - disk_image_w, screen->h - disk_image_h, 
+                   disk_image_w, disk_image_h);
+}
+
+static void LoadDiskImage(void)
+{
+    patch_t *disk;
+    int y;
+
+    disk = (patch_t *) W_CacheLumpName("STDISK", PU_STATIC);
+
+    V_DrawPatch(0, 0, 0, disk);
+    disk_image_w = SHORT(disk->width);
+    disk_image_h = SHORT(disk->height);
+    printf("%i, %i\n", disk_image_w, disk_image_h);
+
+    disk_image = Z_Malloc(disk_image_w * disk_image_h, PU_STATIC, NULL);
+    saved_background = Z_Malloc(disk_image_w * disk_image_h, PU_STATIC, NULL);
+
+    for (y=0; y<disk_image_h; ++y) 
+    {
+        memcpy(disk_image + disk_image_w * y,
+               screens[0] + SCREENWIDTH * y,
+               disk_image_w);
+    }
+
+    Z_Free(disk);
+}
 
 //
 // Translates the SDL key
@@ -500,7 +588,7 @@ void I_FinishUpdate (void)
 
     // draw to screen
     
-    SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
+    SDL_Flip(screen);
 }
 
 
@@ -532,14 +620,13 @@ void I_SetPalette (byte* palette)
 }
 
 
-
 void I_InitGraphics(void)
 {
     int flags = 0;
 
     SDL_Init(SDL_INIT_VIDEO);
 
-    flags |= SDL_SWSURFACE | SDL_HWPALETTE;
+    flags |= SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF;
     flags |= SDL_FULLSCREEN;
 
     screen = SDL_SetVideoMode(SCREENWIDTH*multiply, SCREENHEIGHT*multiply, 8, flags);
@@ -557,8 +644,9 @@ void I_InitGraphics(void)
     SDL_EnableUNICODE(1);
     SDL_ShowCursor(0);
     SDL_WM_GrabInput(SDL_GRAB_ON);
-}
 
+    LoadDiskImage();
+}
 
 unsigned	exptable[256];
 
diff --git a/src/w_wad.c b/src/w_wad.c
index 18f8fed..8415fbd 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: w_wad.c 15 2005-07-23 18:50:34Z fraggle $
+// $Id: w_wad.c 33 2005-08-04 01:13:46Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.4  2005/08/04 01:13:46  fraggle
+// Loading disk
+//
 // Revision 1.3  2005/07/23 18:50:34  fraggle
 // Use standard C file functions for WAD code
 //
@@ -39,7 +42,7 @@
 
 
 static const char
-rcsid[] = "$Id: w_wad.c 15 2005-07-23 18:50:34Z fraggle $";
+rcsid[] = "$Id: w_wad.c 33 2005-08-04 01:13:46Z fraggle $";
 
 
 #include <stdio.h>
@@ -453,7 +456,7 @@ W_ReadLump
 
     l = lumpinfo+lump;
 	
-    // ??? I_BeginRead ();
+    I_BeginRead ();
 	
     if (l->handle == NULL)
     {
@@ -474,7 +477,7 @@ W_ReadLump
     if (l->handle == NULL)
 	fclose (handle);
 		
-    // ??? I_EndRead ();
+    I_EndRead ();
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/chocolate-doom.git



More information about the Pkg-games-commits mailing list