Skip to content

Commit

Permalink
Don't show ENDOOM after playing lump or recording demo
Browse files Browse the repository at this point in the history
- Also extract ENDOOM type
  • Loading branch information
andrikpowell committed Jul 25, 2024
1 parent ae49307 commit 078845b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 61 deletions.
131 changes: 71 additions & 60 deletions prboom2/src/dsda/endoom.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

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

Expand Down Expand Up @@ -355,12 +356,17 @@ static void RestoreOldMode(void) {
void dsda_CacheEndoom(void) {
int lump;
int show_endoom;
dboolean demo_check = 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);

output_format = dsda_IntConfig(dsda_config_ansi_endoom);
if (output_format == format_null)
dsda_UpdateIntConfig(dsda_config_ansi_endoom,1,true);
show_endoom = dsda_IntConfig(nyan_config_show_endoom);

if (demo_check > 0)
return;

if (show_endoom==0)
return;

Expand All @@ -383,77 +389,82 @@ void dsda_CacheEndoom(void) {
}

void dsda_DumpEndoom(void) {
int show_endoom;
endoom_type = dsda_IntConfig(nyan_config_type_endoom);
show_endoom = dsda_IntConfig(nyan_config_show_endoom);

if(show_endoom > 0)
if(endoom)
{
if (endoom && endoom_type == 1)
{
int i;
const char* color_lookup[] = {
"0", "4", "2", "6", "1", "5", "3", "7",
"0;1", "4;1", "2;1", "6;1", "1;1", "5;1", "3;1", "7;1",
};

#ifdef _WIN32
EnableVTMode();
#endif

for (i = 0; i < 2000; ++i) {
byte character;
byte data;
const char *foreground;
const char *background;
const char *blink;

character = endoom[i * 2];
data = endoom[i * 2 + 1];
foreground = color_lookup[data & 0x0f];
background = color_lookup[(data >> 4) & 0x07];
blink = ((data >> 7) & 0x01) ? "5" : "25";

if (!character)
character = ' ';

if (output_format == format_utf8)
lprintf(LO_INFO, "\033[3%sm\033[4%sm\033[%sm%s\033[0m",
foreground, background, blink, cp437_to_utf8[character]);
else
lprintf(LO_INFO, "\033[3%sm\033[4%sm\033[%sm%c\033[0m",
foreground, background, blink, character);

if ((i + 1) % 80 == 0)
lprintf(LO_INFO, "\n");
}

lprintf(LO_INFO, "\n");
if (endoom_type == 1)
dsda_TerminalEndoom();
else if (endoom_type == 0)
dsda_WindowEndoom();
}
}

Z_Free(endoom);
endoom = NULL;
//
// DSDA Terminal ENDOOM
//

#ifdef _WIN32
RestoreOldMode();
lprintf(LO_INFO, "Press any key to quit...");
while (true)
{
if (getch() > 0)
break;
}
#endif
}
else if (endoom && endoom_type == 0)
dsda_FullEndoom();
}
void dsda_TerminalEndoom(void)
{
int i;
const char* color_lookup[] = {
"0", "4", "2", "6", "1", "5", "3", "7",
"0;1", "4;1", "2;1", "6;1", "1;1", "5;1", "3;1", "7;1",
};

#ifdef _WIN32
EnableVTMode();
#endif

for (i = 0; i < 2000; ++i) {
byte character;
byte data;
const char *foreground;
const char *background;
const char *blink;

character = endoom[i * 2];
data = endoom[i * 2 + 1];
foreground = color_lookup[data & 0x0f];
background = color_lookup[(data >> 4) & 0x07];
blink = ((data >> 7) & 0x01) ? "5" : "25";

if (!character)
character = ' ';

if (output_format == format_utf8)
lprintf(LO_INFO, "\033[3%sm\033[4%sm\033[%sm%s\033[0m",
foreground, background, blink, cp437_to_utf8[character]);
else
lprintf(LO_INFO, "\033[3%sm\033[4%sm\033[%sm%c\033[0m",
foreground, background, blink, character);

if ((i + 1) % 80 == 0)
lprintf(LO_INFO, "\n");
}

lprintf(LO_INFO, "\n");

Z_Free(endoom);
endoom = NULL;

#ifdef _WIN32
RestoreOldMode();
lprintf(LO_INFO, "Press any key to quit...");
while (true)
{
if (getch() > 0)
break;
}
#endif
}


//
// Full Screen ENDOOM
// PrBoom+ Window ENDOOM
//

void dsda_FullEndoom(void)
void dsda_WindowEndoom(void)
{
unsigned char *screendata;
int y;
Expand Down
3 changes: 2 additions & 1 deletion prboom2/src/dsda/endoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@

void dsda_CacheEndoom(void);
void dsda_DumpEndoom(void);
void dsda_FullEndoom(void);
void dsda_TerminalEndoom(void);
void dsda_WindowEndoom(void);

0 comments on commit 078845b

Please sign in to comment.