-play SW's intro through the screen job framework.

This commit is contained in:
Christoph Oelckers 2020-08-15 13:04:15 +02:00
parent 3f9cc1412c
commit 8595b9fa47
13 changed files with 146 additions and 367 deletions

View file

@ -69,23 +69,26 @@ void playlogos()
}
if (fileSystem.FindFile("logo.smk"))
if (!userConfig.nologo)
{
jobs[job++] = { PlayVideo("logo.smk", &logosound[0], 0) };
}
else
{
jobs[job++] = { Create<DBlackScreen>(1), []() { sndStartSample("THUNDER2", 128, -1); }};
jobs[job++] = { Create<DImageScreen>(2050) };
}
if (fileSystem.FindFile("gti.smk"))
{
jobs[job++] = { PlayVideo("gti.smk", &logosound[2], 0) };
}
else
{
jobs[job++] = { Create<DBlackScreen>(1), []() { sndStartSample("THUNDER2", 128, -1); }};
jobs[job++] = { Create<DImageScreen>(2052) };
if (fileSystem.FindFile("logo.smk"))
{
jobs[job++] = { PlayVideo("logo.smk", &logosound[0], 0) };
}
else
{
jobs[job++] = { Create<DBlackScreen>(1), []() { sndStartSample("THUNDER2", 128, -1); } };
jobs[job++] = { Create<DImageScreen>(2050) };
}
if (fileSystem.FindFile("gti.smk"))
{
jobs[job++] = { PlayVideo("gti.smk", &logosound[2], 0) };
}
else
{
jobs[job++] = { Create<DBlackScreen>(1), []() { sndStartSample("THUNDER2", 128, -1); } };
jobs[job++] = { Create<DImageScreen>(2052) };
}
}
jobs[job++] = { Create<DBlackScreen>(1), []() { sndPlaySpecialMusicOrNothing(MUS_INTRO); sndStartSample("THUNDER2", 128, -1); }};
jobs[job++] = { Create<DImageScreen>(2518, DScreenJob::fadein) };

View file

@ -151,7 +151,7 @@ public:
int delay = 20;
if (frameTicks)
{
if (curframe == 0) delay = frameTicks[0];
if (curframe == 1) delay = frameTicks[0];
else if (curframe < numframes - 1) delay = frameTicks[1];
else delay = frameTicks[2];
}

View file

@ -269,8 +269,13 @@ void Logo_d(const CompletionFunc &completion)
JobDesc jobs[3];
int job = 0;
if (VOLUMEALL) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } };
if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), nullptr };
if (!userConfig.nologo)
{
if (VOLUMEALL) jobs[job++] = { PlayVideo("logo.anm", logosound, logoframetimes), []() { S_PlaySpecialMusic(MUS_INTRO); } };
else jobs[job++] = { Create<DScreenJob>(), []() { S_PlaySpecialMusic(MUS_INTRO); } };
if (!isNam()) jobs[job++] = { Create<DDRealmsScreen>(), nullptr };
}
else S_PlaySpecialMusic(MUS_INTRO);
jobs[job++] = { Create<DTitleScreen>(), []() { S_PlaySound(NITEVISION_ONOFF, CHAN_AUTO, CHANF_UI); } };
RunScreenJob(jobs, job, completion, true, true);
}

View file

@ -189,7 +189,12 @@ void Logo_r(const CompletionFunc& completion)
JobDesc jobs[3];
int job = 0;
if (!isRRRA())
if (userConfig.nologo)
{
completion(false);
return;
}
else if (!isRRRA())
{
jobs[job++] = { PlayVideo("rr_intro.anm", introsound, framespeed), nullptr };
jobs[job++] = { PlayVideo("redneck.anm", rednecksound, framespeed), nullptr };

View file

@ -1,5 +1,6 @@
set( PCH_SOURCES
src/2d.cpp
src/actor.cpp
src/ai.cpp
src/anim.cpp

95
source/sw/src/2d.cpp Normal file
View file

@ -0,0 +1,95 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 1997, 2005 - 3D Realms Entertainment
This file is part of Shadow Warrior version 1.2
Shadow Warrior 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Original Source: 1997 - Frank Maddin and Jim Norwood
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "screenjob.h"
#include "game.h"
#include "sounds.h"
#include "v_draw.h"
#include "network.h"
#include "gamecontrol.h"
BEGIN_SW_NS
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
class DSWDRealmsScreen : public DScreenJob
{
public:
DSWDRealmsScreen() : DScreenJob(fadein | fadeout) {}
int Frame(uint64_t clock, bool skiprequest) override
{
const uint64_t duration = 5'000'000'000;
const auto tex = tileGetTexture(THREED_REALMS_PIC, true);
const int translation = TRANSLATION(Translation_BasePalettes, DREALMSPAL);
twod->ClearScreen();
DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE);
return skiprequest ? -1 : clock < duration ? 1 : 0;
}
};
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void Logo(const CompletionFunc& completion)
{
StopSound();
PlayTheme();
static const AnimSound logosound[] =
{
{ 1, DIGI_NOMESSWITHWANG },
{ 5, DIGI_INTRO_SLASH },
{ 15, DIGI_INTRO_WHIRL },
{ -1, -1 }
};
static const int logoframetimes[] = { 360, 8, 128 };
if (!AutoNet && !userConfig.nologo)
{
JobDesc jobs[3];
int job = 0;
jobs[job++] = { Create<DSWDRealmsScreen>() };
jobs[job++] = { PlayVideo("sw.anm", logosound, logoframetimes)};
RunScreenJob(jobs, job, completion, true, true);
}
else completion(false);
}
END_SW_NS

View file

@ -43,6 +43,8 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "../glbackend/glbackend.h"
#include "v_2ddrawer.h"
#include "animtexture.h"
#include "screenjob.h"
#include "raze_music.h"
BEGIN_SW_NS
@ -66,29 +68,6 @@ const char *ANIMname[] =
#define ANIM_TILE(num) (MAXTILES-11 + (num))
void AnimShareIntro(int frame, int numframes)
{
int zero=0;
if (frame == numframes-1)
ototalclock += 120;
else if (frame == 1)
{
PlaySound(DIGI_NOMESSWITHWANG, v3df_none, CHAN_BODY, CHANF_UI);
ototalclock += 120*3;
}
else
ototalclock += 8;
if (frame == 5)
{
PlaySound(DIGI_INTRO_SLASH, v3df_none, CHAN_BODY, CHANF_UI);
}
else if (frame == 15)
{
PlaySound(DIGI_INTRO_WHIRL, v3df_none, CHAN_BODY, CHANF_UI);
}
}
void AnimSerp(int frame, int numframes)
{
@ -306,7 +285,7 @@ playanm(short anim_num)
switch (ANIMnum)
{
case ANIM_INTRO:
AnimShareIntro(i, numframes);
//AnimShareIntro(i, numframes);
break;
case ANIM_SERP:
AnimSerp(i, numframes);

View file

@ -432,14 +432,6 @@ void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp perso
default:
{
TotalKillable++;
#if DEBUG
extern SWBOOL DebugSecret;
if (DebugSecret)
{
sprintf(ds,"COUNTED: spnum %d, pic %d, x %d, y %d",SpriteNum,sp->picnum,sp->x,sp->y);
DebugWriteString(ds);
}
#endif
}
break;

View file

@ -126,7 +126,6 @@ extern int sw_snd_scratch;
#define STAT_SCREEN_PIC 5114
#define TITLE_PIC 2324
#define THREED_REALMS_PIC 2325
#define TITLE_ROT_FLAGS (RS_TOPLEFT|ROTATE_SPRITE_SCREEN_CLIP|ROTATE_SPRITE_NON_MASK)
#define PAL_SIZE (256*3)
@ -149,7 +148,6 @@ int DemoTextYstart = 0;
int Follow_posx=0,Follow_posy=0;
SWBOOL NoMeters = FALSE;
short IntroAnimCount = 0;
short PlayingLevel = -1;
SWBOOL GraphicsMode = FALSE;
char CacheLastLevel[32] = "";
@ -271,7 +269,6 @@ int krandcount;
void BOT_DeleteAllBots(void);
void BotPlayerInsert(PLAYERp pp);
void SybexScreen(void);
void PlayTheme(void);
void MenuLevel(void);
void StatScreen(PLAYERp mpp);
void InitRunLevel(void);
@ -282,11 +279,11 @@ static FILE *debug_fout = NULL;
// Transitioning helper.
int SyncScreenJob(JobDesc *jobs, int count)
void Logo(const CompletionFunc& completion);
int SyncScreenJob()
{
bool abort = false;
RunScreenJob(jobs, count, [&](bool) { abort = true; });
while (!abort)
while (gamestate == GS_INTERMISSION || gamestate == GS_INTRO)
{
handleevents();
updatePauseStatus();
@ -298,84 +295,13 @@ int SyncScreenJob(JobDesc *jobs, int count)
RunScreenJobFrame(); // This handles continuation through its completion callback.
videoNextPage();
}
gamestate = GS_LEVEL;
return 0;
}
void DebugWriteString(char *string)
{
#if BETA || !DEBUG
return;
#endif
if (!debug_fout)
{
if ((debug_fout = fopen("dbg.foo", "ab+")) == NULL)
return;
}
fprintf(debug_fout, "%s\n", string);
//fclose(debug_fout);
//debug_fout = NULL;
fflush(debug_fout);
}
void DebugWriteLoc(char *fname, int line)
{
#if BETA || !DEBUG
return;
#endif
if (!debug_fout)
{
if ((debug_fout = fopen("dbg.foo", "ab+")) == NULL)
return;
}
fprintf(debug_fout, "%s, %d\n", fname, line);
//fclose(debug_fout);
//debug_fout = NULL;
fflush(debug_fout);
}
void Mono_Print(char *str)
{
MONO_PRINT(str);
}
extern SWBOOL DrawScreen;
#if RANDOM_DEBUG
FILE *fout_err;
SWBOOL RandomPrint;
int krand1(char *file, unsigned line)
{
ASSERT(!DrawScreen);
if (RandomPrint && !Prediction)
{
extern uint32_t MoveThingsCount;
sprintf(ds,"mtc %d, %s, line %d, %d",MoveThingsCount,file,line,randomseed);
DebugWriteString(ds);
}
randomseed = ((randomseed * 21 + 1) & 65535);
return randomseed;
}
int krand2()
{
ASSERT(!DrawScreen);
randomseed = ((randomseed * 21 + 1) & 65535);
return randomseed;
}
#else
int krand1(void)
{
ASSERT(!DrawScreen);
@ -384,8 +310,6 @@ int krand1(void)
return randomseed;
}
#endif
int PointOnLine(int x, int y, int x1, int y1, int x2, int y2)
{
// the closer to 0 the closer to the line the point is
@ -560,12 +484,6 @@ void AnimateCacheCursor(void)
static int firstnet = 0; // JBF
typedef enum basepal_ {
BASEPAL = 0,
DREALMSPAL,
} basepal_t;
void SW_InitMultiPsky(void)
{
// default
@ -580,9 +498,6 @@ bool InitGame()
//void *ReserveMem=NULL;
int i;
DSPRINTF(ds,"InitGame...");
MONO_PRINT(ds);
engineInit();
InitAutoNet();
@ -895,7 +810,6 @@ InitLevel(void)
InitNewGame();
LoadingLevelScreen();
MONO_PRINT("LoadintLevelScreen");
if (!DemoMode && !DemoInitOnce)
DemoPlaySetup();
@ -965,21 +879,6 @@ InitLevel(void)
// reset NewGame
NewGame = FALSE;
DSPRINTF(ds,"End of InitLevel...");
MONO_PRINT(ds);
#if 0
#if DEBUG
if (!cansee(43594, -92986, 0x3fffffff, 290,
43180, -91707, 0x3fffffff, 290))
{
DSPRINTF(ds,"cansee failed");
MONO_PRINT(ds);
}
#endif
#endif
}
@ -1042,8 +941,6 @@ TerminateLevel(void)
{
if (*sectu)
{
////DSPRINTF(ds,"Sect User Free %d",sectu-SectUser);
//MONO_PRINT(ds);
FreeMem(*sectu);
*sectu = NULL;
}
@ -1184,61 +1081,6 @@ void PlayTheme()
{
// start music at logo
PlaySong(nullptr, ThemeSongs[0], ThemeTrack[0]);
DSPRINTF(ds,"After music stuff...");
MONO_PRINT(ds);
}
void LogoLevel(void)
{
int fin;
if (userConfig.nologo) return;
DSPRINTF(ds,"LogoLevel...");
MONO_PRINT(ds);
MONO_PRINT(ds);
//FadeOut(0, 0);
ready2send = 0;
totalclock = 0;
ototalclock = 0;
DSPRINTF(ds,"About to display 3drealms pic...");
MONO_PRINT(ds);
//FadeIn(0, 3);
inputState.ClearAllInput();
while (TRUE)
{
twod->ClearScreen();
rotatesprite(0, 0, RS_SCALE, 0, THREED_REALMS_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1, nullptr, DREALMSPAL);
videoNextPage();
handleevents();
// limits checks to max of 40 times a second
if (totalclock >= ototalclock + synctics)
{
ototalclock += synctics;
}
if (totalclock > 5*120 || inputState.CheckAllInput())
{
inputState.ClearAllInput();
break;
}
}
twod->ClearScreen();
videoNextPage();
// put up a blank screen while loading
DSPRINTF(ds,"End of LogoLevel...");
MONO_PRINT(ds);
}
void CreditsLevel(void)
@ -1352,14 +1194,6 @@ void DrawLoadLevelScreen(void)
short PlayerQuitMenuLevel = -1;
void IntroAnimLevel(void)
{
if (userConfig.nologo) return;
DSPRINTF(ds,"IntroAnimLevel");
MONO_PRINT(ds);
playanm(0);
}
void MenuLevel(void)
{
short w,h;
@ -1997,32 +1831,12 @@ void StatScreen(PLAYERp mpp)
void GameIntro(void)
{
DSPRINTF(ds,"GameIntro...");
MONO_PRINT(ds);
if (DemoPlaying)
return;
// this could probably be taken out and you could select skill level
// from menu to start the game
if (!CommEnabled && UserMapName[0])
if (DemoPlaying || (!CommEnabled && UserMapName[0]))
return;
Level = 1;
PlayTheme();
if (!AutoNet)
{
LogoLevel();
//CreditsLevel();
IntroAnimLevel();
IntroAnimCount = 0;
}
Logo([](bool) { gamestate = GS_LEVEL; });
SyncScreenJob();
MenuLevel();
}
@ -2030,8 +1844,6 @@ void Control()
{
InitGame();
MONO_PRINT("InitGame done");
//MNU_InitMenus();
InGame = TRUE;
GameIntro();
@ -2162,7 +1974,6 @@ void InitRunLevel(void)
SavePlayClock = PlayClock;
InitTimingVars();
PlayClock = SavePlayClock;
MONO_PRINT("Done with InitRunLevel");
return;
}
@ -2210,7 +2021,6 @@ void InitRunLevel(void)
// everything has been inited at least once for RECORD
DemoInitOnce = TRUE;
//DebugWriteLoc(__FILE__, __LINE__);
waitforeverybody();
CheckVersion(GameVersion);
@ -2885,13 +2695,6 @@ getinput(SW_PACKET *loc, SWBOOL tied)
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
{
vel += keymove;
//DSPRINTF(ds,"vel key %d",vel);
//DebugWriteString(ds);
}
else
{
//DSPRINTF(ds,"vel %d",vel);
//DebugWriteString(ds);
}
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
@ -3490,37 +3293,6 @@ SHOWSPRITE:
}
#if RANDOM_DEBUG
int RandomRange(int range, char *file, unsigned line)
{
uint32_t rand_num;
uint32_t value;
extern FILE *fout_err;
extern uint32_t MoveThingsCount;
if (RandomPrint && !Prediction)
{
sprintf(ds,"mtc %d, %s, line %d, %d",MoveThingsCount,file,line,randomseed);
DebugWriteString(ds);
}
if (range <= 0)
return 0;
rand_num = krand2();
if (rand_num == 65535U)
rand_num--;
// shift values to give more precision
value = (rand_num << 14) / ((65535UL << 14) / range);
if (value >= range)
value = range - 1;
return value;
}
#else
int RandomRange(int range)
{
uint32_t rand_num;
@ -3542,7 +3314,6 @@ int RandomRange(int range)
return value;
}
#endif
int StdRandomRange(int range)
{

View file

@ -117,6 +117,12 @@ enum GameFunction_t
NUM_ACTIONS
};
enum
{
DREALMSPAL = 1,
THREED_REALMS_PIC = 2325,
};
//#define SW_SHAREWARE 1 // This determines whether game is shareware compile or not!
extern char isShareware;
#define SW_SHAREWARE (isShareware)
@ -141,28 +147,6 @@ void _Assert(const char *expr, const char *strFile, unsigned uLine);
#define ASSERT(f) do { } while (0)
#endif
#if DEBUG
void HeapCheck(char *, int);
#define HEAP_CHECK() HeapCheck(__FILE__, __LINE__)
void dsprintf(char *, char *, ...);
#define DSPRINTF dsprintf
void PokeStringMono(uint8_t Attr, uint8_t* String);
#if 1
// !JIM! Frank, I redirect this for me you'll want to set this back for you
extern int DispMono;
#define MONO_PRINT(str) if (DispMono) PokeStringMono(/*MDA_NORMAL*/ 0, str)
#else
void adduserquote(const char *daquote);
extern int DispMono;
#define MONO_PRINT(str) if (DispMono) Printf(str); // Put it in my userquote stuff!
//#define MONO_PRINT(str) if (DispMono) printf(str);
#endif
#define RANDOM_DEBUG 1 // Set this to 1 for network testing.
#else
#define MONO_PRINT(str)
void dsprintf_null(char *str, const char *format, ...);
@ -171,22 +155,13 @@ void dsprintf_null(char *str, const char *format, ...);
#define HEAP_CHECK()
#define RANDOM_DEBUG 0
#endif
#if RANDOM_DEBUG
int RandomRange(int, char *, unsigned);
int krand1(char *, unsigned);
#define RANDOM_P2(pwr_of_2) (MOD_P2(krand1(__FILE__,__LINE__),(pwr_of_2)))
#define RANDOM_RANGE(range) (RandomRange(range,__FILE__,__LINE__))
#define RANDOM() (krand1(__FILE__,__LINE__))
#else
int RandomRange(int);
int krand1(void);
#define RANDOM_P2(pwr_of_2) (MOD_P2(krand1(),(pwr_of_2)))
#define RANDOM_RANGE(range) (RandomRange(range))
#define RANDOM() (krand1())
#endif
#define PRINT(line,str) DebugPrint(line,str)
@ -2428,6 +2403,7 @@ void ScaleSectorObject(SECTOR_OBJECTp sop); // morph.c
void MorphTornado(SECTOR_OBJECTp sop); // morph.c
void MorphFloor(SECTOR_OBJECTp sop); // morph.c
void ScaleRandomPoint(SECTOR_OBJECTp sop,short k,short ang,int x,int y,int *dx,int *dy); // morph.c
void PlayTheme(void);
void CopySectorMatch(short match); // copysect.c

View file

@ -484,11 +484,7 @@ void InventoryKeys(PLAYERp pp)
inv_hotkey -= 1;
////DSPRINTF(ds,"inv_hotkey %d",inv_hotkey);
//MONO_PRINT(ds);
// switches you to this inventory item
//PlayerUpdateInventory(pp, inv_hotkey);
pp->InventoryNum = inv_hotkey;
if (InventoryData[pp->InventoryNum].Init && !TEST(pp->Flags, PF_CLIMBING))
@ -497,16 +493,7 @@ void InventoryKeys(PLAYERp pp)
{
InventoryUse(pp);
}
#if 0
else
{
sprintf(ds,"No %s",InventoryData[pp->InventoryNum].Name);
PutStringInfo(pp,ds); // DONT have message
}
#endif
}
//PlayerUpdateInventory(pp, pp->InventoryNum);
}
}
else

View file

@ -580,17 +580,6 @@ waitforeverybody(void)
else if (NetBroadcastMode)
netbroadcastpacket(tempbuf, size);
#if 0
for (i = connecthead; i >= 0; i = connectpoint2[i])
{
if (i != myconnectindex)
{
DSPRINTF(ds,"Ready packet sent to %d", i);
DebugWriteString(ds);
}
}
#endif
Player[myconnectindex].playerreadyflag++;
while (TRUE)
@ -614,14 +603,6 @@ waitforeverybody(void)
}
#if 0
for (i = connecthead; i >= 0; i = connectpoint2[i])
{
DSPRINTF(ds,"myindex %d, myready %d, Player %d, Ready %d", myconnectindex, Player[myconnectindex].playerreadyflag, i, Player[i].playerreadyflag);
DebugWriteString(ds);
}
#endif
for (i = connecthead; i >= 0; i = connectpoint2[i])
{
if (Player[i].playerreadyflag < Player[myconnectindex].playerreadyflag)
@ -716,9 +697,6 @@ SWBOOL MyCommPlayerQuit(void)
screenpeek = connecthead;
}
DSPRINTF(ds,"MyCommPlayerQuit %d", quit_player_index);
DebugWriteString(ds);
if (i == connecthead)
connecthead = connectpoint2[connecthead];
else
@ -765,9 +743,6 @@ SWBOOL MenuCommPlayerQuit(short quit_player)
screenpeek = connecthead;
}
DSPRINTF(ds,"MenuPlayerQuit %d", quit_player);
DebugWriteString(ds);
if (i == connecthead)
connecthead = connectpoint2[connecthead];
else

View file

@ -5000,16 +5000,6 @@ void UpdateSinglePlayKills(short SpriteNum)
// single play and coop kill count
if (gNet.MultiGameType != MULTI_GAME_COMMBAT)
{
#if DEBUG
extern SWBOOL DebugSecret;
if (DebugSecret)
{
SPRITEp sp = &sprite[SpriteNum];
sprintf(ds,"KILLED: spnum %d, pic %d, x %d, y %d",SpriteNum,sp->picnum,sp->x,sp->y);
DebugWriteString(ds);
}
#endif
ASSERT(User[SpriteNum]);
if (TEST(User[SpriteNum]->Flags, SPR_SUICIDE))