Skip to content

Commit

Permalink
Generate weapon silhouettes for alt HUD based on pickup sprites
Browse files Browse the repository at this point in the history
Still need to position vertically, and stop being drawn off right edge, but it's a start.
  • Loading branch information
bradharding committed Aug 27, 2024
1 parent d3cc2dd commit 3413403
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 64 deletions.
Binary file removed res/DRHUDWP0.png
Binary file not shown.
Binary file modified res/DRHUDWP1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed res/DRHUDWP2.png
Binary file not shown.
Binary file removed res/DRHUDWP3.png
Binary file not shown.
Binary file removed res/DRHUDWP4.png
Binary file not shown.
Binary file removed res/DRHUDWP5.png
Binary file not shown.
Binary file removed res/DRHUDWP6.png
Binary file not shown.
Binary file removed res/DRHUDWP7.png
Binary file not shown.
Binary file removed res/DRHUDWP8.png
Binary file not shown.
Binary file removed res/DRHUDWPA.png
Binary file not shown.
Binary file removed res/DRHUDWPB.png
Binary file not shown.
Binary file modified res/doomretro.wad
Binary file not shown.
9 changes: 9 additions & 0 deletions src/d_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// fists
{
/* name */ "fists",
/* weaponthing */ MT_NULL,
/* ammotype */ am_noammo,
/* ammoname */ "",
/* ammoplural */ "",
Expand All @@ -68,6 +69,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// pistol
{
/* name */ "pistol",
/* weaponthing */ MT_NULL,
/* ammotype */ am_clip,
/* ammoname */ "bullet",
/* ammoplural */ "bullets",
Expand All @@ -93,6 +95,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// shotgun
{
/* name */ original_mobjinfo[MT_SHOTGUN].name1,
/* weaponthing */ MT_SHOTGUN,
/* ammotype */ am_shell,
/* ammoname */ "shell",
/* ammoplural */ "shells",
Expand All @@ -118,6 +121,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// chaingun
{
/* name */ original_mobjinfo[MT_CHAINGUN].name1,
/* weaponthing */ MT_CHAINGUN,
/* ammotype */ am_clip,
/* ammoname */ "bullet",
/* ammoplural */ "bullets",
Expand All @@ -143,6 +147,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// rocket launcher
{
/* name */ original_mobjinfo[MT_MISC27].name1,
/* weaponthing */ MT_MISC27,
/* ammotype */ am_misl,
/* ammoname */ "rocket",
/* ammoplural */ "rockets",
Expand All @@ -168,6 +173,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// plasma rifle
{
/* name */ original_mobjinfo[MT_MISC28].name1,
/* weaponthing */ MT_MISC28,
/* ammotype */ am_cell,
/* ammoname */ "cell",
/* ammoplural */ "cells",
Expand All @@ -193,6 +199,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// BFG-9000
{
/* name */ original_mobjinfo[MT_MISC25].name1,
/* weaponthing */ MT_MISC25,
/* ammotype */ am_cell,
/* ammoname */ "cell",
/* ammoplural */ "cells",
Expand All @@ -218,6 +225,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// chainsaw
{
/* name */ original_mobjinfo[MT_MISC26].name1,
/* weaponthing */ MT_MISC26,
/* ammotype */ am_noammo,
/* ammoname */ "",
/* ammoplural */ "",
Expand All @@ -243,6 +251,7 @@ weaponinfo_t weaponinfo[NUMWEAPONS] =
// super shotgun
{
/* name */ original_mobjinfo[MT_SUPERSHOTGUN].name1,
/* weaponthing */ MT_SUPERSHOTGUN,
/* ammotype */ am_shell,
/* ammoname */ "shell",
/* ammoplural */ "shells",
Expand Down
2 changes: 2 additions & 0 deletions src/d_items.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum
typedef struct
{
char *name;
int weaponthing;
ammotype_t ammotype;
char ammoname[255];
char ammoplural[255];
Expand All @@ -81,6 +82,7 @@ typedef struct
int flags; // MBF21
char key;
bool altered;
patch_t *weaponpatch;
patch_t *ammopatch;
} weaponinfo_t;

Expand Down
80 changes: 16 additions & 64 deletions src/hu_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void A_Lower(mobj_t *actor, player_t *player, pspdef_t *psp);
static void (*hudfunc)(int, int, patch_t *, const byte *);
static void (*hudnumfunc)(int, int, patch_t *, const byte *);
static void (*hudnumfunc2)(int, int, patch_t *, const byte *);
static void (*hudweaponfunc)(int, int, patch_t *, const byte *);

static void (*althudfunc)(int, int, patch_t *, int, int, const byte *);
void (*althudtextfunc)(int, int, byte *, patch_t *, bool, int, int, const byte *);
Expand Down Expand Up @@ -143,6 +144,7 @@ void HU_SetTranslucency(void)
hudfunc = &V_DrawTranslucentHUDPatch;
hudnumfunc = &V_DrawTranslucentHUDNumberPatch;
hudnumfunc2 = &V_DrawTranslucentHighlightedHUDNumberPatch;
hudweaponfunc = &V_DrawTranslucentHUDWeaponPatch;
althudfunc = &V_DrawTranslucentAltHUDPatch;
althudtextfunc = &V_DrawTranslucentAltHUDText;
fillrectfunc = &V_FillSoftTransRect;
Expand All @@ -154,6 +156,7 @@ void HU_SetTranslucency(void)
hudfunc = &V_DrawHUDPatch;
hudnumfunc = &V_DrawHUDPatch;
hudnumfunc2 = &V_DrawHighlightedHUDNumberPatch;
hudweaponfunc = &V_DrawHUDWeaponPatch;
althudfunc = &V_DrawAltHUDPatch;
althudtextfunc = &V_DrawAltHUDText;
fillrectfunc = &V_FillRect;
Expand Down Expand Up @@ -735,25 +738,6 @@ static altkeypic_t altkeypics[NUMCARDS] =
{ RED2, NULL, NULL }
};

typedef struct
{
int offset;
patch_t *patch;
} altweapon_t;

static altweapon_t altweapons[NUMWEAPONS] =
{
{ 0, NULL },
{ 6, NULL },
{ 8, NULL },
{ 3, NULL },
{ 3, NULL },
{ 3, NULL },
{ -15, NULL },
{ -3, NULL },
{ 8, NULL }
};

static patch_t *altnumpatch[10];
static patch_t *altnumpatch2[10];
static patch_t *altminuspatch;
Expand Down Expand Up @@ -829,56 +813,24 @@ static void HU_AltInit(void)
altkeypics[it_redskull].patch = altskullpatch;
altkeypics[it_redskull].tinttab = tinttab60;

if (chex || FREEDOOM || hacx || REKKR)
weaponschanged = true;
else
for (int i = 0, numweapons = NUMWEAPONS - (gamemode != commercial); i < numweapons; i++)
{
if (!BTSX && !eviternity)
for (int i = 0; i < NUMWEAPONS; i++)
if (*weaponinfo[i].spritename)
{
const int lump = W_CheckNumForName(weaponinfo[i].spritename);

if (lump >= 0
&& lumpinfo[lump]->wadfile->type == PWAD
&& !M_StringEndsWith(lumpinfo[i]->wadfile->path, DOOMRETRO_RESOURCEWAD)
&& !fixspriteoffsets)
{
weaponschanged = true;
break;
}
}
const int weaponthing = weaponinfo[i].weaponthing;

if (weaponschanged)
for (int i = 0; i < NUMWEAPONS; i++)
{
M_snprintf(buffer, sizeof(buffer), "DRHUDWP%i", i);

if (W_GetNumLumps(buffer) > 1)
{
weaponschanged = false;
break;
}
}

if (!weaponschanged)
if (weaponthing == MT_NULL)
weaponinfo[i].weaponpatch = NULL;
else
{
for (int i = 0; i < NUMWEAPONS; i++)
{
M_snprintf(buffer, sizeof(buffer), "DRHUDWP%i", i);
altweapons[i].patch = W_CacheLumpName(buffer);
}
state_t *state = &states[mobjinfo[weaponthing].spawnstate];

if (ID1)
{
altweapons[wp_plasma].patch = W_CacheLumpName("DRHUDWPA");
altweapons[wp_plasma].offset = 0;
altweapons[wp_bfg].patch = W_CacheLumpName("DRHUDWPB");
altweapons[wp_bfg].offset = 1;
}
weaponinfo[i].weaponpatch = W_CacheLumpNum(firstspritelump
+ sprites[state->sprite].spriteframes[state->frame].lump[0]);
}
}

if (!weaponinfo[wp_pistol].weaponpatch)
weaponinfo[wp_pistol].weaponpatch = W_CacheLumpName("DRHUDWP1");

gray = nearestcolors[GRAY1];
darkgray = nearestcolors[DARKGRAY1];
}
Expand Down Expand Up @@ -1312,8 +1264,8 @@ static void HU_DrawAltHUD(void)
else
althudfunc(ALTHUD_RIGHT_X, ALTHUD_Y + 13, altrightpatch, WHITE, color, tinttab60);

if ((patch = altweapons[weapon].patch))
althudfunc(ALTHUD_RIGHT_X + 108, ALTHUD_Y + altweapons[weapon].offset, patch, WHITE, color, tinttab60);
if ((patch = weaponinfo[weapon].weaponpatch))
hudweaponfunc(ALTHUD_RIGHT_X + 108, ALTHUD_Y, patch, tinttab60);

for (int i = 1; i <= NUMCARDS; i++)
for (int j = 0; j < NUMCARDS; j++)
Expand Down
54 changes: 54 additions & 0 deletions src/v_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,60 @@ void V_DrawTranslucentHUDNumberPatch(int x, int y, patch_t *patch, const byte *t
}
}

void V_DrawHUDWeaponPatch(int x, int y, patch_t *patch, const byte *tinttab)
{
const int width = SHORT(patch->width);
byte *desttop = &screens[0][y * SCREENWIDTH + x + width];

for (int col = 0; col < width; col++, desttop--)
{
column_t *column = (column_t *)((byte *)patch + LONG(patch->columnoffset[col]));

// step through the posts in a column
while (column->topdelta != 0xFF)
{
byte *dest = &desttop[column->topdelta * SCREENWIDTH];
const byte length = column->length;
byte count = length;

while (count-- > 0)
{
*dest = nearestwhite;
dest += SCREENWIDTH;
}

column = (column_t *)((byte *)column + length + 4);
}
}
}

void V_DrawTranslucentHUDWeaponPatch(int x, int y, patch_t *patch, const byte *tinttab)
{
const int width = SHORT(patch->width);
byte *desttop = &screens[0][y * SCREENWIDTH + x + width];

for (int col = 0; col < width; col++, desttop--)
{
column_t *column = (column_t *)((byte *)patch + LONG(patch->columnoffset[col]));

// step through the posts in a column
while (column->topdelta != 0xFF)
{
byte *dest = &desttop[column->topdelta * SCREENWIDTH];
const byte length = column->length;
byte count = length;

while (count-- > 0)
{
*dest = tinttab[(nearestwhite << 8) + *dest];
dest += SCREENWIDTH;
}

column = (column_t *)((byte *)column + length + 4);
}
}
}

void V_DrawAltHUDPatch(int x, int y, patch_t *patch, int from, int to, const byte *tinttab)
{
byte *desttop = &screens[0][y * SCREENWIDTH + x];
Expand Down
2 changes: 2 additions & 0 deletions src/v_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ void V_DrawHUDPatch(int x, int y, patch_t *patch, const byte *tinttab);
void V_DrawHighlightedHUDNumberPatch(int x, int y, patch_t *patch, const byte *tinttab);
void V_DrawTranslucentHUDPatch(int x, int y, patch_t *patch, const byte *tinttab);
void V_DrawTranslucentHUDNumberPatch(int x, int y, patch_t *patch, const byte *tinttab);
void V_DrawHUDWeaponPatch(int x, int y, patch_t *patch, const byte *tinttab);
void V_DrawTranslucentHUDWeaponPatch(int x, int y, patch_t *patch, const byte *tinttab);
void V_DrawTranslucentHighlightedHUDNumberPatch(int x, int y, patch_t *patch, const byte *tinttab);
void V_DrawAltHUDPatch(int x, int y, patch_t *patch, int from, int to, const byte *tinttab);
void V_DrawTranslucentAltHUDPatch(int x, int y, patch_t *patch, int from, int to, const byte *tinttab);
Expand Down

0 comments on commit 3413403

Please sign in to comment.