Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heretic: Adding A11Y Features: Weapon Flash Lighting & Sprite, Palette Changes, Invul Colormap, Extra Lighting #1258

Merged
merged 10 commits into from
Jan 13, 2025
5 changes: 5 additions & 0 deletions src/heretic/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,11 @@ void D_BindVariables(void)
M_BindIntVariable("screenblocks", &screenblocks);
M_BindIntVariable("snd_channels", &snd_Channels);
M_BindIntVariable("a11y_sector_lighting", &a11y_sector_lighting);
M_BindIntVariable("a11y_extra_lighting", &a11y_extra_lighting);
M_BindIntVariable("a11y_weapon_flash", &a11y_weapon_flash);
M_BindIntVariable("a11y_weapon_pspr", &a11y_weapon_pspr);
M_BindIntVariable("a11y_palette_changes", &a11y_palette_changes);
M_BindIntVariable("a11y_invul_colormap", &a11y_invul_colormap);
M_BindIntVariable("vanilla_savegame_limit", &vanilla_savegame_limit);
M_BindIntVariable("vanilla_demo_limit", &vanilla_demo_limit);
M_BindIntVariable("show_endoom", &show_endoom);
Expand Down
21 changes: 20 additions & 1 deletion src/heretic/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "r_local.h"
#include "tables.h"
#include "v_video.h" // [crispy] V_DrawFilledBox for HOM detector
#include "a11y.h" // [crispy] A11Y

int viewangleoffset;

Expand Down Expand Up @@ -913,6 +914,7 @@ void R_SetupFrame(player_t * player)
int tableAngle;
int tempCentery;
int pitch; // [crispy]
int tmpColormap; // [crispy] to overwrite colormap

//drawbsp = 1;
viewplayer = player;
Expand Down Expand Up @@ -966,7 +968,16 @@ void R_SetupFrame(player_t * player)
viewy += player->chickenPeck * finesine[tableAngle];
}

// [crispy] A11Y
if (a11y_weapon_flash)
{
extralight = player->extralight;
}
else
extralight = 0;
// [crispy] A11Y
extralight += a11y_extra_lighting;

// [crispy] apply new yslope[] whenever "lookdir", "detailshift" or
// "screenblocks" change
tempCentery = viewheight / 2 + (pitch * (1 << crispy->hires)) *
Expand All @@ -982,7 +993,15 @@ void R_SetupFrame(player_t * player)
sscount = 0;
if (player->fixedcolormap)
{
fixedcolormap = colormaps + player->fixedcolormap
tmpColormap = player->fixedcolormap;
// [crispy] A11Y - overwrite to disable invul-colormap or torch flickering
if ((!a11y_invul_colormap && player->powers[pw_invulnerability]) ||
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is a bit confusing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first idea was to handle the disabling of the invul colormap and torch flickering directly within P_PlayerThink (p_user.c ), however I found that for the torch flickering, a M_Random call is involved. So I refrained from changing it there but instead did it right before the colormap is applied.

grafik

So assigning the colormap to 1 (stable "infrared") to either deactive the invul or to stablize the torch.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could add a comment or two to make clear what happens here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I added a few comments!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good, thank you very much!

(!a11y_weapon_flash && player->powers[pw_infrared] && !player->powers[pw_invulnerability]))
{
tmpColormap = 1; // [crispy] A11Y - static infrared map
}

fixedcolormap = colormaps + tmpColormap
* (NUMCOLORMAPS / 32) // [crispy] smooth diminishing lighting
* 256 /* * sizeof(lighttable_t)*/;
walllights = scalelightfixed;
Expand Down
32 changes: 18 additions & 14 deletions src/heretic/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "r_bmaps.h"
#include "r_local.h"
#include "v_trans.h" // [crispy] blending functions
#include "a11y.h" // [crispy] A11Y

typedef struct
{
Expand Down Expand Up @@ -949,7 +950,7 @@ void R_DrawPSprite(pspdef_t * psp, int psyoffset, int translucent) // [crispy] y
void R_DrawPlayerSprites(void)
{
int i, lightnum;
int tmpframe, offset, translucent = 0; // [crispy] temps for drawing translucent psrites
int tmpframe, offset, drawbase = 0; // [crispy] for drawing base frames
pspdef_t *psp;

//
Expand Down Expand Up @@ -977,11 +978,12 @@ void R_DrawPlayerSprites(void)
{
if (psp->state)
{
// [crispy] Draw offset base frame and translucent current frame
if (crispy->translucency & TRANSLUCENCY_ITEM &&
!(viewplayer->powers[pw_invisibility] > 4*32 || viewplayer->powers[pw_invisibility] & 8))
// [crispy] draw base frame for transparent or deactivated weapon flashes
if (!a11y_weapon_pspr ||
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, here you are using the translucent variable to "mark" the attack sprite?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the weaponsprites are disabled, the "translucent" variable would mark that a base-frame (idle with y-offset) was drawn instead and the real attack-frame can be discarded. In case the weaponsprites and transparency option is enabled, the variable would instead be used to draw a transparent attack-frame in addition to the base-frame.

Maybe renaming it would be helpful, just need to find a good name.. 😉

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a comment and a renaming of the translucent variable would be welcome. How about attackframe?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did an update, let me know if it was for better or worse. 😁

(crispy->translucency & TRANSLUCENCY_ITEM &&
!(viewplayer->powers[pw_invisibility] > 4*32 || viewplayer->powers[pw_invisibility] & 8)))
{
translucent = 1;
drawbase = 1;
tmpframe = psp->state->frame;

switch (psp->state->sprite)
Expand All @@ -996,7 +998,7 @@ void R_DrawPlayerSprites(void)
if (tmpframe == 3)
offset = spriteoffsets[SPR_GWND_F3].offset;
else
translucent = 0;
drawbase = 0;
break;
case SPR_BLSR:
if (tmpframe == 1)
Expand All @@ -1008,7 +1010,7 @@ void R_DrawPlayerSprites(void)
if (tmpframe == 3)
offset = spriteoffsets[SPR_BLSR_F3].offset;
else
translucent = 0;
drawbase = 0;
break;
case SPR_HROD:
if (tmpframe == 1)
Expand All @@ -1020,7 +1022,7 @@ void R_DrawPlayerSprites(void)
if (tmpframe == 6)
offset = spriteoffsets[SPR_HROD_F6].offset;
else
translucent = 0;
drawbase = 0;
break;
case SPR_PHNX:
if (tmpframe == 1)
Expand All @@ -1032,21 +1034,23 @@ void R_DrawPlayerSprites(void)
if (tmpframe == 3)
offset = spriteoffsets[SPR_PHNX_F3].offset;
else
translucent = 0;
drawbase = 0;
break;
default:
offset = 0x0;
translucent = 0;
drawbase = 0;
break;
}
if (translucent && psp->state->sprite != SPR_GAUN)
if (drawbase && psp->state->sprite != SPR_GAUN)
{
psp->state->frame = 0; // draw base frame
psp->state->frame = 0; // set base frame
R_DrawPSprite(psp, offset, 0);
psp->state->frame = tmpframe; // restore frame
psp->state->frame = tmpframe; // restore attack frame
}
}
R_DrawPSprite(psp, 0x0, translucent);
if (!a11y_weapon_pspr && drawbase)
continue; // [crispy] A11Y no weapon flash, use base instead
R_DrawPSprite(psp, 0x0, drawbase); // [crispy] translucent when base was drawn
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/heretic/sb_bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#ifdef CRISPY_TRUECOLOR
#include "v_trans.h" // [crispy] I_BlendDark()
#endif
#include "a11y.h" // [crispy] A11Y

// Types

Expand Down Expand Up @@ -816,7 +817,12 @@ void SB_PaletteFlash(void)

CPlayer = &players[consoleplayer];

if (CPlayer->damagecount)
// [crispy] A11Y
if (!a11y_palette_changes)
{
palette = 0;
}
else if (CPlayer->damagecount)
{
palette = (CPlayer->damagecount + 7) >> 3;
if (palette >= NUMREDPALS)
Expand Down
17 changes: 6 additions & 11 deletions src/setup/accessibility.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,10 @@ void AccessibilitySettings(TXT_UNCAST_ARG(widget), void *user_data)
TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);

if (gamemission == doom || gamemission == heretic)
{
TXT_AddWidget(window,
TXT_NewCheckBox("Flickering Sector Lighting",
&a11y_sector_lighting));
}

if (gamemission == doom)
{
TXT_AddWidgets(window,
TXT_NewCheckBox("Flickering Sector Lighting",
&a11y_sector_lighting),
TXT_NewCheckBox("Weapon Flash Lighting",
&a11y_weapon_flash),
TXT_NewCheckBox("Weapon Flash Sprite",
Expand All @@ -63,12 +58,12 @@ void AccessibilitySettings(TXT_UNCAST_ARG(widget), void *user_data)

TXT_SetTableColumns(window, 2);

if (gamemission == doom)
if (gamemission == doom || gamemission == heretic)
{
TXT_AddWidgets(window,
TXT_NewLabel("Extra Lighting"),
TXT_NewSpinControl(&a11y_extra_lighting, 0, 8),
NULL);
TXT_NewLabel("Extra Lighting"),
TXT_NewSpinControl(&a11y_extra_lighting, 0, 8),
NULL);
}

}
Expand Down
Loading