From e4aa75977e5a2e7ace5e7742193cfef427adaa77 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 9 Nov 2008 16:39:12 +0000 Subject: Recreate Hexen graphical startup in SDL. Subversion-branch: /branches/raven-branch Subversion-revision: 1380 --- src/hexen/h2_main.c | 18 +++++-- src/hexen/st_start.c | 140 ++++++++++++++++++++++----------------------------- src/hexen/st_start.h | 3 ++ 3 files changed, 77 insertions(+), 84 deletions(-) (limited to 'src/hexen') diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c index 8a1622f8..f1d6ca90 100644 --- a/src/hexen/h2_main.c +++ b/src/hexen/h2_main.c @@ -159,6 +159,7 @@ void D_BindVariables(void) M_BindHereticControls(); M_BindHexenControls(); + M_BindVariable("graphical_startup", &graphical_startup); M_BindVariable("mouse_sensitivity", &mouseSensitivity); M_BindVariable("sfx_volume", &snd_MaxVolume); M_BindVariable("music_volume", &snd_MusicVolume); @@ -279,6 +280,8 @@ void D_DoomMain(void) HandleArgs(); + I_PrintStartupBanner("Hexen"); + ST_Message("MN_Init: Init menu system.\n"); MN_Init(); @@ -301,8 +304,6 @@ void D_DoomMain(void) ST_Message("ST_Init: Init startup screen.\n"); ST_Init(); - S_StartSongName("orb", true); - // Show version message now, so it's visible during R_Init() ST_Message("R_Init: Init Hexen refresh daemon"); R_Init(); @@ -330,6 +331,8 @@ void D_DoomMain(void) ST_Message("SB_Init: Loading patches.\n"); SB_Init(); + ST_Done(); + CheckRecordFrom(); p = M_CheckParm("-record"); @@ -490,9 +493,15 @@ static void ExecOptionPLAYDEMO(char **args, int tag) { char file[256]; - sprintf(file, "%s.lmp", args[1]); + strcpy(file, args[1]); + + if (strcasecmp(file + strlen(file) - 4, ".lmp") != 0) + { + strcat(file, ".lmp"); + } + W_AddFile(file); - ST_Message("Playing demo %s.lmp.\n", args[1]); + ST_Message("Playing demo %s.\n", file); } //========================================================================== @@ -820,6 +829,7 @@ static void CheckRecordFrom(void) G_LoadGame(atoi(myargv[p + 1])); G_DoLoadGame(); // Load the gameskill etc info from savegame G_RecordDemo(gameskill, 1, gameepisode, gamemap, myargv[p + 2]); + H2_GameLoop(); // Never returns } diff --git a/src/hexen/st_start.c b/src/hexen/st_start.c index f3dc2350..47e926e5 100644 --- a/src/hexen/st_start.c +++ b/src/hexen/st_start.c @@ -25,16 +25,14 @@ // HEADER FILES ------------------------------------------------------------ -#include -#include + #include -#ifndef O_BINARY -#define O_BINARY 0 -#endif +#include "config.h" #include "h2def.h" #include "i_system.h" +#include "i_videohr.h" #include "s_sound.h" #include "st_start.h" @@ -52,36 +50,16 @@ #define ST_NETNOTCH_HEIGHT 16 #define ST_MAX_NETNOTCHES 8 -// TYPES ------------------------------------------------------------------- - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- -extern void SetVideoModeHR(void); -extern void ClearScreenHR(void); -extern void SlamHR(char *buffer); -extern void SlamBlockHR(int x, int y, int w, int h, char *src); -extern void InitPaletteHR(void); -extern void SetPaletteHR(byte * palette); -extern void GetPaletteHR(byte * palette); -extern void FadeToPaletteHR(byte * palette); -extern void FadeToBlackHR(void); -extern void BlackPaletteHR(void); -extern void I_StartupReadKeys(void); - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- - -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -char *ST_LoadScreen(void); +byte *ST_LoadScreen(void); void ST_UpdateNotches(int notchPosition); void ST_UpdateNetNotches(int notchPosition); -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - // PRIVATE DATA DEFINITIONS ------------------------------------------------ -char *bitmap = NULL; +static const byte *bitmap = NULL; +int graphical_startup = 1; +static boolean using_graphical_startup; -char notchTable[] = { +static const byte notchTable[] = { // plane 0 0x00, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xC0, @@ -109,7 +87,7 @@ char notchTable[] = { // Red Network Progress notches -char netnotchTable[] = { +static const byte netnotchTable[] = { // plane 0 0x80, 0x50, 0xD0, 0xf0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xD0, 0xF0, 0xC0, 0x70, 0x50, 0x80, 0x60, @@ -146,36 +124,44 @@ char netnotchTable[] = { void ST_Init(void) { -#ifdef __WATCOMC__ - char *pal; - char *buffer; + byte *pal; + byte *buffer; + + using_graphical_startup = false; - if (!debugmode) + if (graphical_startup && !debugmode) { // Set 640x480x16 mode - SetVideoModeHR(); - ClearScreenHR(); - InitPaletteHR(); - BlackPaletteHR(); - - // Load graphic - buffer = ST_LoadScreen(); - pal = buffer; - bitmap = buffer + 16 * 3; - - SlamHR(bitmap); - FadeToPaletteHR(pal); - Z_Free(buffer); + if (I_SetVideoModeHR()) + { + I_SetWindowTitleHR("Hexen startup - " PACKAGE_STRING); + using_graphical_startup = true; + + S_StartSongName("orb", true); + + I_ClearScreenHR(); + I_InitPaletteHR(); + I_BlackPaletteHR(); + + // Load graphic + buffer = ST_LoadScreen(); + pal = buffer; + bitmap = buffer + 16 * 3; + + I_SlamHR(bitmap); + I_FadeToPaletteHR(pal); + Z_Free(buffer); + } } -#endif } - void ST_Done(void) { -#ifdef __WATCOMC__ - ClearScreenHR(); -#endif + if (using_graphical_startup) + { + I_ClearScreenHR(); + I_UnsetVideoModeHR(); + } } @@ -187,11 +173,9 @@ void ST_Done(void) void ST_UpdateNotches(int notchPosition) { -#ifdef __WATCOMC__ int x = ST_PROGRESS_X + notchPosition * ST_NOTCH_WIDTH; int y = ST_PROGRESS_Y; - SlamBlockHR(x, y, ST_NOTCH_WIDTH, ST_NOTCH_HEIGHT, notchTable); -#endif + I_SlamBlockHR(x, y, ST_NOTCH_WIDTH, ST_NOTCH_HEIGHT, notchTable); } @@ -203,11 +187,9 @@ void ST_UpdateNotches(int notchPosition) void ST_UpdateNetNotches(int notchPosition) { -#ifdef __WATCOMC__ int x = ST_NETPROGRESS_X + notchPosition * ST_NETNOTCH_WIDTH; int y = ST_NETPROGRESS_Y; - SlamBlockHR(x, y, ST_NETNOTCH_WIDTH, ST_NETNOTCH_HEIGHT, netnotchTable); -#endif + I_SlamBlockHR(x, y, ST_NETNOTCH_WIDTH, ST_NETNOTCH_HEIGHT, netnotchTable); } @@ -220,27 +202,24 @@ void ST_UpdateNetNotches(int notchPosition) void ST_Progress(void) { #ifdef __WATCOMC__ - static int notchPosition = 0; - // Check for ESC press -- during startup all events eaten here I_StartupReadKeys(); +#endif - if (debugmode) - { - printf("."); - } - else + if (using_graphical_startup) { + static int notchPosition = 0; + if (notchPosition < ST_MAX_NOTCHES) { ST_UpdateNotches(notchPosition); S_StartSound(NULL, SFX_STARTUP_TICK); + //I_Sleep(1000); notchPosition++; } } -#else + printf("."); -#endif } @@ -252,14 +231,12 @@ void ST_Progress(void) void ST_NetProgress(void) { -#ifdef __WATCOMC__ - static int netnotchPosition = 0; - if (debugmode) - { - printf("*"); - } - else + printf("*"); + + if (using_graphical_startup) { + static int netnotchPosition = 0; + if (netnotchPosition < ST_MAX_NETNOTCHES) { ST_UpdateNetNotches(netnotchPosition); @@ -267,7 +244,6 @@ void ST_NetProgress(void) netnotchPosition++; } } -#endif } @@ -278,7 +254,10 @@ void ST_NetProgress(void) //========================================================================== void ST_NetDone(void) { - S_StartSound(NULL, SFX_PICKUP_WEAPON); + if (using_graphical_startup) + { + S_StartSound(NULL, SFX_PICKUP_WEAPON); + } } @@ -344,14 +323,15 @@ void ST_RealMessage(char *message, ...) //========================================================================== -char *ST_LoadScreen(void) +byte *ST_LoadScreen(void) { int length, lump; - char *buffer; + byte *buffer; lump = W_GetNumForName("STARTUP"); length = W_LumpLength(lump); - buffer = (char *) Z_Malloc(length, PU_STATIC, NULL); + buffer = (byte *) Z_Malloc(length, PU_STATIC, NULL); W_ReadLump(lump, buffer); return (buffer); } + diff --git a/src/hexen/st_start.h b/src/hexen/st_start.h index 252d44c7..53cd85c9 100644 --- a/src/hexen/st_start.h +++ b/src/hexen/st_start.h @@ -39,3 +39,6 @@ extern void ST_NetProgress(void); extern void ST_NetDone(void); // PUBLIC DATA DECLARATIONS ------------------------------------------------ + +extern int graphical_startup; + -- cgit v1.2.3