shithub: choc

Download patch

ref: c70ac8af1e4c4ec821d4353d09bd16d2350f05bc
parent: 4cd845c7b04e360b94212abe16dfaa9cb76554c7
parent: 679c6753cb957a5cf8380450593da155224bc846
author: Simon Howard <fraggle+github@gmail.com>
date: Mon Jan 2 10:12:34 EST 2017

Merge pull request #749 from nukeykt/retailfix

strife: Add ASCII intro.

--- a/src/strife/Makefile.am
+++ b/src/strife/Makefile.am
@@ -1,4 +1,6 @@
-AM_CFLAGS = -I$(top_srcdir)/src @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@
+AM_CFLAGS=-I$(top_srcdir)/src                           \
+          -I$(top_srcdir)/textscreen                    \
+          @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@
 
 noinst_LIBRARIES=libstrife.a
 
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -34,6 +34,9 @@
 #include "doomfeatures.h"
 #include "sounds.h"
 
+#include "txt_main.h"
+#include "txt_io.h"
+
 #include "d_iwad.h"
 
 #include "z_zone.h"
@@ -144,6 +147,7 @@
 int             show_endoom = 1;
 int             show_diskicon = 1;
 int             graphical_startup = 1;
+static boolean  using_text_startup;
 
 // If true, startup has completed and the main game loop has started.
 
@@ -508,7 +512,6 @@
 
     if (!showintro)
     {
-        I_SetWindowTitle(gamedescription);
         I_InitGraphics();
     }
 
@@ -920,8 +923,27 @@
 }
 
 //      print title for every printed line
-char            title[128];
+static char title[128] = "";
 
+static void InitTitleString(void)
+{
+    switch (gameversion)
+    {
+    case exe_strife_1_2:
+        DEH_snprintf(title, sizeof(title), "                      "
+                                           "STRIFE:  Quest for the Sigil v1.2"
+                                           "                                  "
+                                           );
+        break;
+    case exe_strife_1_31:
+        DEH_snprintf(title, sizeof(title), "                      "
+                                           "STRIFE:  Quest for the Sigil v1.31"
+                                           "                                 "
+                                           );
+        break;
+    }
+}
+
 static boolean D_AddFile(char *filename)
 {
     wad_file_t *handle;
@@ -1080,6 +1102,85 @@
     I_Endoom(endoom);
 }
 
+//
+// D_GetCursorColumn
+//
+static int D_GetCursorColumn(void)
+{
+    int x, y;
+    TXT_GetXY(&x, &y);
+    return x;
+}
+
+//
+// D_GetCursorRow
+//
+static int D_GetCursorRow(void)
+{
+    int x, y;
+    TXT_GetXY(&x, &y);
+    return y;
+}
+
+//
+// D_SetCursorPosition
+//
+static void D_SetCursorPosition(int column, int row)
+{
+    TXT_GotoXY(column, row);
+}
+
+//
+// D_SetChar
+//
+static void D_SetChar(char c)
+{
+    int x, y;
+    // Backup position
+    TXT_GetXY(&x, &y);
+    TXT_PutChar(c);
+    // Restore position
+    TXT_GotoXY(x, y);
+}
+
+//
+// D_DrawText
+//
+static void D_DrawText(char *string, int bc, int fc)
+{
+    int column;
+    int row;
+    int i;
+
+    if (!using_text_startup)
+    {
+        return;
+    }
+
+    // Set text color
+    TXT_BGColor(bc, 0);
+    TXT_FGColor(fc);
+
+    // Get column position
+    column = D_GetCursorColumn();
+
+    // Get row position
+    row = D_GetCursorRow();
+
+    for (i = 0; i < strlen(string); i++)
+    {
+        // Set character
+        D_SetChar(string[i]);
+
+        // Check cursor position
+        if (++column >= 80)
+            column = 0;
+
+        // Set postition
+        D_SetCursorPosition(column, row);
+    }
+}
+
 //=============================================================================
 //
 // haleyjd: Chocolate Strife Specifics
@@ -1167,11 +1268,20 @@
 
 static void D_InitIntroSequence(void)
 {
+    byte *textScreen;
+    char string[80];
+
+    if (devparm || !graphical_startup || testcontrols)
+    {
+        using_text_startup = false;
+        showintro = false;
+        return;
+    }
+
     if(showintro)
     {
         // In vanilla Strife, Mode 13h was initialized directly in D_DoomMain.
         // We have to be a little more courteous of the low-level code here.
-        I_SetWindowTitle(gamedescription);
         I_SetGrabMouseCallback(D_StartupGrabCallback);
         I_InitGraphics();
         V_RestoreBuffer(); // make the V_ routines work
@@ -1188,22 +1298,62 @@
 
         // Draw the background
         D_IntroBackground();
+
+        using_text_startup = false;
     }
-    /*
-    // STRIFE-FIXME: This was actually displayed on a special textmode
-    // screen with ANSI color codes... would require use of textlib to
-    // emulate properly...
     else
     {
-        puts(DEH_String("Conversation ON"));
-        puts(DEH_String("Rogue Entertainment"));
-        puts(DEH_String("and"));
-        puts(DEH_String("Velocity Games"));
-        puts(DEH_String("present"));
-        puts(DEH_String("S T R I F E"));
-        puts(DEH_String("Loading..."));
+        if (!TXT_Init())
+        {
+            using_text_startup = false;
+            return;
+        }
+
+        I_InitWindowTitle();
+        I_InitWindowIcon();
+
+        // Clear screen
+        textScreen = TXT_GetScreenData();
+        memset(textScreen, 0, 4000);
+
+        using_text_startup = true;
+
+        // Print title
+
+        D_SetCursorPosition(0, 0);
+        D_DrawText(title, TXT_COLOR_GREEN, TXT_COLOR_BLACK);
+
+        DEH_snprintf(string, sizeof(string), "Rogue Entertainment");
+        D_SetCursorPosition(40 - strlen(string) / 2, 5);
+        D_DrawText(string, TXT_COLOR_BLUE, TXT_COLOR_GREEN);
+
+        DEH_snprintf(string, sizeof(string), "and");
+        D_SetCursorPosition(40 - strlen(string) / 2, 7);
+        D_DrawText(string, TXT_COLOR_BLUE, TXT_COLOR_GREEN);
+
+        DEH_snprintf(string, sizeof(string), "Velocity Games");
+        D_SetCursorPosition(40 - strlen(string) / 2, 9);
+        D_DrawText(string, TXT_COLOR_BLUE, TXT_COLOR_GREEN);
+
+        DEH_snprintf(string, sizeof(string), "present");
+        D_SetCursorPosition(40 - strlen(string) / 2, 11);
+        D_DrawText(string, TXT_COLOR_BLUE, TXT_COLOR_GREEN);
+
+        DEH_snprintf(string, sizeof(string), "S T R I F E");
+        D_SetCursorPosition(40 - strlen(string) / 2, 14);
+        D_DrawText(string, TXT_COLOR_BLUE, TXT_COLOR_GREEN);
+
+        DEH_snprintf(string, sizeof(string), "Loading...");
+        D_SetCursorPosition(40 - strlen(string) / 2, 17);
+        D_DrawText(string, TXT_COLOR_BLUE, TXT_COLOR_GREEN);
+
+        DEH_snprintf(string, sizeof(string),
+                    "[                                                  ]");
+        D_SetCursorPosition(14, 18);
+        D_DrawText(string, TXT_COLOR_BLUE, TXT_COLOR_GREEN);
+
+        TXT_UpdateScreen();
     }
-    */
 }
 
 //
@@ -1216,41 +1366,62 @@
 {
     int laserpos;
     int robotpos;
+    int i;
 
-    if(!showintro)
-        return;
+    if (showintro)
+    {
+        D_IntroBackground(); // haleyjd: refresh the background
 
-    D_IntroBackground(); // haleyjd: refresh the background
+        // Laser position
+        laserpos = (200 * introprogress / MAXINTROPROGRESS) + 60;
 
-    // Laser position
-    laserpos = (200 * introprogress / MAXINTROPROGRESS) + 60;
+        // BUG: (?) Due to this clip, the laser never even comes close to
+        // touching the peasant; confirmed with vanilla. This MAY have been
+        // intentional, for effect, however, since no death frames are shown 
+        // either... kind of a black-out death.
+        if (laserpos > 200)
+            laserpos = 200;
 
-    // BUG: (?) Due to this clip, the laser never even comes close to
-    // touching the peasant; confirmed with vanilla. This MAY have been
-    // intentional, for effect, however, since no death frames are shown 
-    // either... kind of a black-out death.
-    if(laserpos > 200)
-        laserpos = 200;
+        // Draw the laser
+        // Blitted 16 bytes for 16 rows starting at 705280 + laserpos
+        // (705280 - 0xA0000) / 320 == 156
+        V_DrawBlock(laserpos, 156, 16, 16, rawgfx_startlz[laserpos % 2]);
 
-    // Draw the laser
-    // Blitted 16 bytes for 16 rows starting at 705280 + laserpos
-    // (705280 - 0xA0000) / 320 == 156
-    V_DrawBlock(laserpos, 156, 16, 16, rawgfx_startlz[laserpos % 2]);
+        // Robot position
+        robotpos = laserpos % 5 - 2;
 
-    // Robot position
-    robotpos = laserpos % 5 - 2;
+        // Draw the robot
+        // Blitted 48 bytes for 48 rows starting at 699534 + (320*robotpos)
+        // 699534 - 0xA0000 == 44174, which % 320 == 14, / 320 == 138
+        V_DrawBlock(14, 138 + robotpos, 48, 48, rawgfx_startbot);
 
-    // Draw the robot
-    // Blitted 48 bytes for 48 rows starting at 699534 + (320*robotpos)
-    // 699534 - 0xA0000 == 44174, which % 320 == 14, / 320 == 138
-    V_DrawBlock(14, 138 + robotpos, 48, 48, rawgfx_startbot);
+        // Draw the peasant
+        // Blitted 32 bytes for 64 rows starting at 699142
+        // 699142 - 0xA0000 == 43782, which % 320 == 262, / 320 == 136
+        V_DrawBlock(262, 136, 32, 64, rawgfx_startp[laserpos % 4]);
 
-    // Draw the peasant
-    // Blitted 32 bytes for 64 rows starting at 699142
-    // 699142 - 0xA0000 == 43782, which % 320 == 262, / 320 == 136
-    V_DrawBlock(262, 136, 32, 64, rawgfx_startp[laserpos % 4]);
+        I_FinishUpdate();
+    }
+    else if (using_text_startup)
+    {
+        // Laser position
+        laserpos = 50 * introprogress / MAXINTROPROGRESS;
 
-    I_FinishUpdate();
+        if (laserpos > 50)
+        {
+            laserpos = 50;
+        }
+
+        for (i = 0; i < laserpos; i++)
+        {
+            D_SetCursorPosition(15 + i, 18);
+            D_DrawText("#", TXT_COLOR_GREEN, TXT_COLOR_BLUE);
+        }
+
+        I_Sleep(10);
+
+        TXT_UpdateScreen();
+    }
 }
 
 //
@@ -1539,11 +1710,6 @@
     D_BindVariables();
     M_LoadDefaults();
 
-    if (!graphical_startup)
-    {
-        showintro = false;
-    }
-
     // Save configuration at exit.
     I_AtExit(M_SaveDefaults, false);
 
@@ -1657,7 +1823,9 @@
     
     D_IdentifyVersion();
     InitGameVersion();
+    InitTitleString();
     D_SetGameDescription();
+    I_SetWindowTitle(gamedescription);
     savegamedir = M_GetSaveGameDir("strife1.wad");
 
     // fraggle 20130405: I_InitTimer is needed here for the netgame
@@ -1983,6 +2151,11 @@
             G_InitNew (startskill, startmap);
         else
             D_StartTitle ();                // start up intro loop
+    }
+
+    if (using_text_startup)
+    {
+        TXT_Shutdown();
     }
 
     D_DoomLoop ();  // never returns