Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions prboom2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ set(COMMON_SRC
dsda/wad_stats.h
dsda/zipfile.c
dsda/zipfile.h
textscreen/doomkeys.h
textscreen/txt_main.h
textscreen/txt_sdl.c
textscreen/txt_sdl.h
textscreen/txt_utf8.c
textscreen/txt_utf8.h
textscreen/fonts/convert-font
textscreen/fonts/normal.h
textscreen/fonts/hauge-8x18-v1-6.png
textscreen/fonts/README
dstrings.c
dstrings.h
d_deh.c
Expand Down
1 change: 1 addition & 0 deletions prboom2/src/SDL/i_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ static void I_Quit (void)
{
M_SaveDefaults ();
dsda_DumpEndoom();
dsda_Shutdown();
}

//
Expand Down
17 changes: 16 additions & 1 deletion prboom2/src/SDL/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ SDL_Rect window_rect = { 0, 0, 0, 0 }; // Physical window
SDL_Rect renderer_rect = { 0, 0, 0, 0 }; // The window, but with HiDPI accounted
SDL_Rect viewport_rect = { 0, 0, 0, 0 }; // The renderer, but without the black bars

void *I_GetSDLWindow(void)
{
return sdl_window;
}

void *I_GetSDLRenderer(void)
{
return sdl_renderer;
}

////////////////////////////////////////////////////////////////////////////
// Input code
int leds_always_off = 0; // Expected by m_misc, not relevant
Expand Down Expand Up @@ -673,6 +683,11 @@ static void I_ShutdownSDL(void)
return;
}

void dsda_Shutdown(void)
{
I_AtExit(I_ShutdownSDL, true, "I_ShutdownSDL", exit_priority_normal);
}

void I_PreInitGraphics(void)
{
int p;
Expand All @@ -691,7 +706,7 @@ void I_PreInitGraphics(void)
I_Error("Could not initialize SDL [%s]", SDL_GetError());
}

I_AtExit(I_ShutdownSDL, true, "I_ShutdownSDL", exit_priority_normal);
// No longer call `I_ShutdownSDL()` here cuz we need window/renderer info for ENDOOM later on
}

// e6y: resolution limitation is removed
Expand Down
4 changes: 4 additions & 0 deletions prboom2/src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,10 @@ static void D_DoomMainSetup(void)
//e6y: some stuff from command-line should be initialised before ProcessDehFile()
e6y_InitCommandLine();

// Check arguments for demoplayback / demorecording
started_demo = dsda_Flag(dsda_arg_record) || dsda_Flag(dsda_arg_recordfromto) ||
dsda_Flag(dsda_arg_playdemo) || dsda_Flag(dsda_arg_timedemo) || dsda_Flag(dsda_arg_fastdemo);

D_AddFile(port_wad_file, source_auto_load);

HandlePlayback(); // must come before autoload: may detect iwad in footer
Expand Down
2 changes: 2 additions & 0 deletions prboom2/src/doomdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ typedef enum {
#define ORIG_FRICTION_FACTOR 2048 // original value
#define FRICTION_FLY 0xeb00

extern dboolean started_demo;

extern dboolean raven;

// heretic
Expand Down
8 changes: 8 additions & 0 deletions prboom2/src/dsda/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,14 @@ dsda_config_t dsda_config[dsda_config_count] = {
"invert_analog_look", dsda_config_invert_analog_look,
CONF_BOOL(0),
},
[dsda_config_show_endoom] = {
"show_endoom", dsda_config_show_endoom,
dsda_config_int, 0, 2, { 2 }
},
[dsda_config_export_endoom] = {
"export_endoom", dsda_config_export_endoom,
CONF_BOOL(0),
},
[dsda_config_ansi_endoom] = {
"ansi_endoom", dsda_config_ansi_endoom,
dsda_config_int, 0, 2, { 0 }
Expand Down
2 changes: 2 additions & 0 deletions prboom2/src/dsda/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ typedef enum {
dsda_config_analog_look_acceleration,
dsda_config_swap_analogs,
dsda_config_invert_analog_look,
dsda_config_show_endoom,
dsda_config_export_endoom,
dsda_config_ansi_endoom,
dsda_config_quit_sounds,
dsda_config_announce_map,
Expand Down
100 changes: 96 additions & 4 deletions prboom2/src/dsda/endoom.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@

#include "doomdef.h"
#include "doomtype.h"
#include "i_video.h"
#include "lprintf.h"
#include "w_wad.h"

#include "dsda/configuration.h"
#include "textscreen/txt_main.h"

#include "endoom.h"

#define ENDOOM_W 80
#define ENDOOM_H 25

static const char* cp437_to_utf8[256] = {
" ",
"\xe2\x98\xba",
Expand Down Expand Up @@ -309,8 +314,14 @@ typedef enum {
format_utf8,
} output_format_t;

typedef enum {
endoom_window,
endoom_terminal,
} endoom_export_t;

static byte* endoom;
static output_format_t output_format;
static endoom_export_t endoom_export;

#ifdef _WIN32
static HANDLE hConsole;
Expand Down Expand Up @@ -341,12 +352,24 @@ static void RestoreOldMode(void) {
}
#endif

int is_opengl = false;

void dsda_CacheEndoom(void) {
int lump;
int show_endoom;
int pwad_only;

output_format = dsda_IntConfig(dsda_config_ansi_endoom);

if (!output_format)
show_endoom = dsda_IntConfig(dsda_config_show_endoom);

if (V_IsOpenGLMode())
is_opengl = true;

if (started_demo)
return;

if (show_endoom==0)
return;

if (hexen)
Expand All @@ -360,15 +383,33 @@ void dsda_CacheEndoom(void) {
lump = W_CheckNumForName("ENDOOM");
}

if (lump == LUMP_NOT_FOUND || W_LumpLength(lump) != 4000)
pwad_only = (show_endoom==2 && !W_PWADLumpNumExists(lump) && W_PWADMapExists());

if (lump == LUMP_NOT_FOUND || W_LumpLength(lump) != 4000 || pwad_only)
return;

endoom = Z_Malloc(4000);
memcpy(endoom, W_LumpByNum(lump), 4000);
}

void dsda_DumpEndoom(void) {
if (endoom) {
endoom_export = dsda_IntConfig(dsda_config_export_endoom);

if (endoom)
{
if (endoom_export)
dsda_TerminalEndoom();
else
dsda_WindowEndoom();
}
}

//
// DSDA Terminal ENDOOM
//

void dsda_TerminalEndoom(void)
{
int i;
const char* color_lookup[] = {
"0", "4", "2", "6", "1", "5", "3", "7",
Expand Down Expand Up @@ -414,5 +455,56 @@ void dsda_DumpEndoom(void) {
#ifdef _WIN32
RestoreOldMode();
#endif
}
}


//
// Window ENDOOM
//

void dsda_WindowEndoom(void)
{
unsigned char *screendata;
int y;
int indent;

// Set up text mode screen

TXT_PreInit(I_GetSDLWindow(), I_GetSDLRenderer(), is_opengl);

if (!TXT_Init())
{
lprintf(LO_ERROR, "Failed to initialize libtextscreen");
return;
}

// Write the data to the screen memory

screendata = TXT_GetScreenData();

indent = (ENDOOM_W - TXT_SCREEN_W) / 2;

for (y = 0; y < TXT_SCREEN_H; ++y)
{
memcpy(screendata + (y * TXT_SCREEN_W * 2),
endoom + (y * ENDOOM_W + indent) * 2, TXT_SCREEN_W * 2);
}

// Wait for a keypress

while (true)
{
TXT_UpdateScreen();

if (TXT_GetChar() > 0)
{
break;
}

TXT_Sleep(0);
}

// Shut down text mode screen

TXT_Shutdown();
}
2 changes: 2 additions & 0 deletions prboom2/src/dsda/endoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@

void dsda_CacheEndoom(void);
void dsda_DumpEndoom(void);
void dsda_TerminalEndoom(void);
void dsda_WindowEndoom(void);
1 change: 1 addition & 0 deletions prboom2/src/dsda/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ int g_menu_font_spacing;

const char* g_skyflatname;

dboolean started_demo = false;
dboolean hexen = false;
dboolean heretic = false;
dboolean raven = false;
Expand Down
4 changes: 4 additions & 0 deletions prboom2/src/i_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void I_InitGraphics (void);
void I_UpdateVideoMode(void);
void I_ShutdownGraphics(void);

void *I_GetSDLWindow(void);
void *I_GetSDLRenderer(void);
void dsda_Shutdown(void);

/* Takes full 8 bit values. */
void I_SetPalette(int pal); /* CPhipps - pass down palette number */

Expand Down
4 changes: 4 additions & 0 deletions prboom2/src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3286,13 +3286,17 @@ setup_menu_t gen_controller_settings[] = {
FINAL_ENTRY
};

static const char* endoom_list[] = { "Off", "On", "Smart", NULL };

setup_menu_t gen_misc_settings[] = {
{ "Death Use Action", S_CHOICE, m_conf, G2_X, dsda_config_death_use_action, 0, death_use_strings },
{ "Boom Weapon Auto Switch", S_YESNO, m_conf, G2_X, dsda_config_switch_when_ammo_runs_out },
{ "Auto Switch Weapon on Pickup", S_YESNO, m_conf, G2_X, dsda_config_switch_weapon_on_pickup },
{ "Enable Cheat Code Entry", S_YESNO, m_conf, G2_X, dsda_config_cheat_codes },
{ "Skip Quit Prompt", S_YESNO, m_conf, G2_X, dsda_config_skip_quit_prompt },
EMPTY_LINE,
{ "Endoom Screen", S_CHOICE, m_conf, G2_X, dsda_config_show_endoom, 0, endoom_list },
EMPTY_LINE,
TITLE("Rewind", G2_X),
{ "Rewind Interval (s)", S_NUM, m_conf, G2_X, dsda_config_auto_key_frame_interval },
{ "Rewind Depth", S_NUM, m_conf, G2_X, dsda_config_auto_key_frame_depth },
Expand Down
2 changes: 2 additions & 0 deletions prboom2/src/m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ cfg_def_t cfg_defs[] =
MIGRATED_SETTING(dsda_config_demo_smoothturnsfactor),
MIGRATED_SETTING(dsda_config_screenshot_dir),
MIGRATED_SETTING(dsda_config_startup_delay_ms),
MIGRATED_SETTING(dsda_config_show_endoom),
MIGRATED_SETTING(dsda_config_export_endoom),
MIGRATED_SETTING(dsda_config_ansi_endoom),
MIGRATED_SETTING(dsda_config_quit_sounds),
MIGRATED_SETTING(dsda_config_announce_map),
Expand Down
Loading
Loading