foxygit / doom Log in
commit 2f20195e2aa6f17fc30626a566b70dc218d46e22
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Oct 2 03:16:29 2005 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sun Oct 2 03:16:29 2005 +0000

    ENDOOM support using text mode emulation

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 147
---
 Makefile.am     |  2 +-
 configure.in    |  2 ++
 src/Makefile.am |  4 ++--
 src/i_system.c  | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/i_video.c   | 15 +++++++-----
 src/i_video.h   |  8 ++++++-
 6 files changed, 91 insertions(+), 12 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index ddb532d4..bab2f8c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,5 +15,5 @@ EXTRA_DIST=                             \
 MAINTAINERCLEANFILES =  $(AUX_DIST_GEN)

 docdir=$(prefix)/share/doc/@PACKAGE@
-SUBDIRS=src
+SUBDIRS=textscreen src

diff --git a/configure.in b/configure.in
index 5ccc78f5..863624ef 100644
--- a/configure.in
+++ b/configure.in
@@ -4,6 +4,7 @@ AC_CONFIG_AUX_DIR(autotools)
 orig_CFLAGS="$CFLAGS"

 AC_PROG_CC
+AC_PROG_RANLIB

 if test "$GCC" = "yes"
 then
@@ -46,6 +47,7 @@ AC_SUBST(ac_aux_dir)

 AC_OUTPUT([
 Makefile
+textscreen/Makefile
 src/Makefile
 src/chocolate-doom-res.rc
 ])
diff --git a/src/Makefile.am b/src/Makefile.am
index 15f7507c..622f5d2f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,8 +3,8 @@ bindir = $(prefix)/bin

 bin_PROGRAMS = chocolate-doom

-CFLAGS = @CFLAGS@ @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@ -Wall
-chocolate_doom_LDADD = @LDFLAGS@ @SDL_LIBS@ @SDLMIXER_LIBS@ @SDLNET_LIBS@
+AM_CFLAGS = -I../textscreen @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@ -Wall
+chocolate_doom_LDADD = @LDFLAGS@ @SDL_LIBS@ @SDLMIXER_LIBS@ @SDLNET_LIBS@ ../textscreen/libtextscreen.a

 SOURCE_FILES=\
 am_map.c    d_think.h   i_video.c   p_floor.c   p_tick.c    r_things.h	\
diff --git a/src/i_system.c b/src/i_system.c
index 054ce8b9..4e7df1d9 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: i_system.c 120 2005-09-22 13:13:47Z fraggle $
+// $Id: i_system.c 147 2005-10-02 03:16:29Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.11  2005/10/02 03:16:29  fraggle
+// ENDOOM support using text mode emulation
+//
 // Revision 1.10  2005/09/22 13:13:47  fraggle
 // Remove external statistics driver support (-statcopy):
 // nonfunctional on modern systems and never used.
@@ -60,7 +63,7 @@
 //-----------------------------------------------------------------------------

 static const char
-rcsid[] = "$Id: i_system.c 120 2005-09-22 13:13:47Z fraggle $";
+rcsid[] = "$Id: i_system.c 147 2005-10-02 03:16:29Z fraggle $";


 #include <stdlib.h>
@@ -79,8 +82,11 @@ rcsid[] = "$Id: i_system.c 120 2005-09-22 13:13:47Z fraggle $";
 #include "g_game.h"

 #include "i_system.h"
+#include "txt_main.h"


+#include "w_wad.h"
+#include "z_zone.h"


 int	mb_used = 6;
@@ -154,6 +160,66 @@ void I_Init (void)
     SDL_Init(SDL_INIT_TIMER);
 }

+//
+// Displays the text mode ending screen after the game quits
+//
+
+void I_Endoom(void)
+{
+    unsigned char *endoom_data;
+    unsigned char *screendata;
+    unsigned int start_ms;
+    boolean waiting;
+    SDL_Event ev;
+
+    endoom_data = W_CacheLumpName("ENDOOM", PU_STATIC);
+
+    // Set up text mode screen
+
+    TXT_Init();
+
+    // Make sure the new window has the right title and icon
+
+    I_SetWindowCaption();
+    I_SetWindowIcon();
+
+    // Write the data to the screen memory
+
+    screendata = TXT_GetScreenData();
+    memcpy(screendata, endoom_data, 4000);
+
+    TXT_UpdateScreen();
+
+    // Wait for 10 seconds, or until a keypress or mouse click
+
+    waiting = true;
+    start_ms = I_GetTime();
+
+    while (waiting && I_GetTime() < start_ms + 10000)
+    {
+        if (!SDL_PollEvent(&ev))
+        {
+            I_Sleep(100);
+            continue;
+        }
+
+        switch (ev.type)
+        {
+            case SDL_MOUSEBUTTONDOWN:
+            case SDL_KEYDOWN:
+                waiting = false;
+                break;
+
+            default:
+                break;
+        }
+    }
+
+    // Shut down text mode screen
+
+    TXT_Shutdown();
+}
+
 //
 // I_Quit
 //
@@ -164,6 +230,7 @@ void I_Quit (void)
     I_ShutdownMusic();
     M_SaveDefaults ();
     I_ShutdownGraphics();
+    I_Endoom();
     exit(0);
 }

@@ -216,3 +283,4 @@ void I_Error (char *error, ...)

     exit(-1);
 }
+
diff --git a/src/i_video.c b/src/i_video.c
index c811ac32..46e53731 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: i_video.c 145 2005-10-02 03:03:40Z fraggle $
+// $Id: i_video.c 147 2005-10-02 03:16:29Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.35  2005/10/02 03:16:29  fraggle
+// ENDOOM support using text mode emulation
+//
 // Revision 1.34  2005/10/02 03:03:40  fraggle
 // Make sure loading disk is only shown if the display is initialised
 //
@@ -144,7 +147,7 @@
 //-----------------------------------------------------------------------------

 static const char
-rcsid[] = "$Id: i_video.c 145 2005-10-02 03:03:40Z fraggle $";
+rcsid[] = "$Id: i_video.c 147 2005-10-02 03:16:29Z fraggle $";

 #include <SDL.h>
 #include <ctype.h>
@@ -743,7 +746,7 @@ void I_SetPalette (byte *doompalette)
 // Set the window caption
 //

-static void SetCaption(void)
+void I_SetWindowCaption(void)
 {
     char *buf;

@@ -758,7 +761,7 @@ static void SetCaption(void)

 // Set the application icon

-static void SetIcon(void)
+void I_SetWindowIcon(void)
 {
     SDL_Surface *surface;

@@ -846,8 +849,8 @@ void I_InitGraphics(void)

     // Setup title and icon

-    SetCaption();
-    SetIcon();
+    I_SetWindowCaption();
+    I_SetWindowIcon();

     UpdateFocus();
     UpdateGrab();
diff --git a/src/i_video.h b/src/i_video.h
index b45ab857..3be10b4b 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: i_video.h 110 2005-09-17 20:25:56Z fraggle $
+// $Id: i_video.h 147 2005-10-02 03:16:29Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -57,6 +57,9 @@ void I_ReadScreen (byte* scr);
 void I_BeginRead (void);
 void I_EndRead (void);

+void I_SetWindowCaption(void);
+void I_SetWindowIcon(void);
+
 extern boolean screenvisible;
 extern int screenmultiply;
 extern boolean fullscreen;
@@ -67,6 +70,9 @@ extern float mouse_acceleration;
 //-----------------------------------------------------------------------------
 //
 // $Log$
+// Revision 1.8  2005/10/02 03:16:29  fraggle
+// ENDOOM support using text mode emulation
+//
 // Revision 1.7  2005/09/17 20:25:56  fraggle
 // Set the default values for variables in their initialisers.  Remove the
 // "defaultvalue" parameter and associated code from the configuration