raze/source/common/startscreen/endoom.cpp
Simon 7c37bad4ac Squashed commit of the following:
commit 57ebeb79e2
Author: Simon <simonbrown77@googlemail.com>
Date:   Thu Feb 16 22:07:38 2023 +0000

    Fixed issue with FrameSetup being called in the wrong place

    this seemed to limit the correctly submitted frames to 60 fps!

commit 16299b3f8a
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Feb 14 20:51:03 2023 +0000

    Get floor height offset correct for each game

commit fa74cf0559
Author: Simon <simonbrown77@googlemail.com>
Date:   Tue Feb 14 20:37:29 2023 +0000

    Clean exit on Pico & Quest

    and gold tier patron credit screen

commit deb2c35988
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Feb 13 22:22:29 2023 +0000

    Number of small changed

    - Hide crosshair if it isn't needed
    - Don't draw black bar when drawing FPS counter
    - added roll in to the weapon sprite
    - If drawing full screen mode always use orthographic projection

commit f1a165add7
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Feb 13 21:44:42 2023 +0000

    FInal changes to get MV rendering correctly

commit 936f079db8
Merge: 06a99dbaf f8c1f49e6
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Feb 13 11:29:23 2023 +0000

    Merge branch 'multiview' into direct-eye-buffers

commit 06a99dbafb
Author: Simon <simonbrown77@googlemail.com>
Date:   Mon Feb 13 11:26:44 2023 +0000

    Implementation using no additional frame buffers

commit f8c1f49e6f
Author: Simon <simonbrown77@googlemail.com>
Date:   Sun Feb 12 11:19:27 2023 +0000

    Failed attempt at multiview
2023-02-16 22:09:25 +00:00

180 lines
5.2 KiB
C++

/*
** endoom.cpp
** Handles the startup screen.
**
**---------------------------------------------------------------------------
** Copyright 2006-2007 Randy Heit
** Copyright 2006-2022 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
// HEADER FILES ------------------------------------------------------------
#include "startscreen.h"
#include "cmdlib.h"
#include "i_system.h"
#include "gstrings.h"
#include "filesystem.h"
#include "m_argv.h"
#include "engineerrors.h"
#include "s_music.h"
#include "printf.h"
#include "startupinfo.h"
#include "i_interface.h"
#include "texturemanager.h"
#include "c_cvars.h"
#include "i_time.h"
#include "g_input.h"
#include "d_eventbase.h"
// MACROS ------------------------------------------------------------------
// How many ms elapse between blinking text flips. On a standard VGA
// adapter, the characters are on for 16 frames and then off for another 16.
// The number here therefore corresponds roughly to the blink rate on a
// 60 Hz display.
#define BLINK_PERIOD 267
// TYPES -------------------------------------------------------------------
// PUBLIC DATA DEFINITIONS -------------------------------------------------
CUSTOM_CVAR(Int, showendoom, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{
if (self < 0) self = 0;
else if (self > 2) self=2;
}
// PRIVATE DATA DEFINITIONS ------------------------------------------------
// CODE --------------------------------------------------------------------
class FEndoomScreen : public FStartScreen
{
uint64_t lastUpdateTime;
bool blinkstate = false;
bool blinking = true;
uint8_t endoom_screen[4000];
public:
FEndoomScreen(int);
void Update();
};
//==========================================================================
//
// FHereticStartScreen Constructor
//
// Shows the Heretic startup screen. If the screen doesn't appear to be
// valid, it returns a failure code in hr.
//
// The loading screen is an 80x25 text screen with character data and
// attributes intermixed, which means it must be exactly 4000 bytes long.
//
//==========================================================================
FEndoomScreen::FEndoomScreen(int loading_lump)
: FStartScreen(0)
{
fileSystem.ReadFile(loading_lump, endoom_screen);
// Draw the loading screen to a bitmap.
StartupBitmap.Create(80 * 8, 26 * 16); // line 26 is for our own 'press any key to quit' message.
DrawTextScreen(StartupBitmap, endoom_screen);
ClearBlock(StartupBitmap, {0, 0, 0, 255}, 0, 25*16, 640, 16);
DrawString(StartupBitmap, 0, 25, GStrings("TXT_QUITENDOOM"), { 128, 128, 128 ,255}, { 0, 0, 0, 255});
lastUpdateTime = I_msTime();
// Does this screen need blinking?
for (int i = 0; i < 80*25; ++i)
{
if (endoom_screen[1+i*2] & 0x80)
{
blinking = true;
break;
}
}
}
void FEndoomScreen::Update()
{
if (blinking && I_msTime() > lastUpdateTime + BLINK_PERIOD)
{
lastUpdateTime = I_msTime();
UpdateTextBlink (StartupBitmap, endoom_screen, blinkstate);
blinkstate = !blinkstate;
StartupTexture->CleanHardwareData();
Render(true);
}
}
//==========================================================================
//
// ST_Endoom
//
// Shows an ENDOOM text screen
//
//==========================================================================
int RunEndoom()
{
if (showendoom == 0 || endoomName.Len() == 0)
{
return 0;
}
int endoom_lump = fileSystem.CheckNumForFullName (endoomName, true);
if (endoom_lump < 0 || fileSystem.FileLength (endoom_lump) != 4000)
{
return 0;
}
if (fileSystem.GetFileContainer(endoom_lump) == fileSystem.GetMaxIwadNum() && showendoom == 2)
{
// showendoom==2 means to show only lumps from PWADs.
return 0;
}
S_StopMusic(true);
auto endoom = new FEndoomScreen(endoom_lump);
endoom->Render(true);
return 0;
}
[[noreturn]]
void ST_Endoom()
{
int code = RunEndoom();
throw CExitEvent(code);
}