Port minimap headlight

Created by Chearii originally for Saturn
This commit is contained in:
NepDisk 2025-08-22 22:42:46 -04:00
parent a00dc2df90
commit 8ae23099d1
4 changed files with 123 additions and 16 deletions

View file

@ -627,7 +627,8 @@ consvar_t cv_pingmeasurement = CVAR_INIT ("pingmeasurement", "Frames", CV_SAVE,
consvar_t cv_showlapemblem = CVAR_INIT ("showlapemblem", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_showminimapnames = CVAR_INIT ("showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_showminimapangle = CVAR_INIT ("showminimapangle", "On", CV_SAVE, CV_OnOff, NULL);
static CV_PossibleValue_t minimapdot_cons_t[] = {{0, "Off"}, {1, "Dot"}, {2, "Headlight"}, {0, NULL}};
consvar_t cv_showminimapangle = CVAR_INIT ("showminimapangle", "Dot", CV_SAVE, minimapdot_cons_t, NULL);
consvar_t cv_minihead = CVAR_INIT ("smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_showviewpointtext = CVAR_INIT ("showviewpointtext", "On", CV_SAVE, CV_OnOff, NULL);

View file

@ -3384,7 +3384,7 @@ static void K_drawKartNameTags(void)
V_ClearClipRect();
}
static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap)
static inline void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap)
{
// amnum xpos & ypos are the icon's speed around the HUD.
// The number being divided by is for how fast it moves.
@ -3427,6 +3427,32 @@ static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32
V_DrawFixedPatch(amxpos, amypos, scale, flags, icon, colormap);
}
static void K_drawKartMinimapHeadlight(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, angle_t ang, UINT8 *colormap)
{
// amnum xpos & ypos are the icon's speed around the HUD.
// The number being divided by is for how fast it moves.
// The higher the number, the slower it moves.
// am xpos & ypos are the icon's starting position. Withouht
// it, they wouldn't 'spawn' on the top-right side of the HUD.
fixed_t amnumxpos, amnumypos;
INT32 amxpos, amypos;
fixed_t scale = FRACUNIT;
patch_t *icon = W_CachePatchNameRotated("MMAPHDLT", R_GetRollAngle(ang), PU_PATCH);
amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x);
amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y);
if (encoremode)
amnumxpos = -amnumxpos;
amxpos = amnumxpos + ((hudx + (SHORT(minimapinfo.minimap_pic->width)-48)/2)<<FRACBITS);
amypos = amnumypos + ((hudy + (SHORT(minimapinfo.minimap_pic->height)-24)/2)<<FRACBITS);
V_DrawFixedPatch(amxpos, amypos, scale, flags|V_ADD, icon, colormap);
}
static void K_drawKartMinimapNametag(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, player_t *player)
{
// amnum xpos & ypos are the icon's speed around the HUD.
@ -3471,7 +3497,7 @@ static void K_drawKartMinimapNametag(fixed_t objx, fixed_t objy, INT32 hudx, INT
V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags|chatcolor, player_name);
}
static void K_drawKartMinimapDot(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, UINT8 color, UINT8 size)
static inline void K_drawKartMinimapDot(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, UINT8 color, UINT8 size)
{
fixed_t amnumxpos, amnumypos;
INT32 amxpos, amypos;
@ -3934,6 +3960,35 @@ static void K_drawKartMinimap(void)
interpx = R_InterpolateFixed(mobj->old_x, mobj->x);
interpy = R_InterpolateFixed(mobj->old_y, mobj->y);
if (!nocontest)
{
if (cv_showminimapangle.value == 1)
{
K_drawKartMinimapIcon(
interpx,
interpy,
x + FixedMul(FCOS(ang), ICON_DOT_RADIUS),
y - FixedMul(FSIN(ang), ICON_DOT_RADIUS),
splitflags,
kp_minimapdot,
colormap
);
}
else if (cv_showminimapangle.value == 2)
{
K_drawKartMinimapHeadlight(
interpx,
interpy,
x,
y,
splitflags,
ang,
colormap
);
}
}
K_drawKartMinimapIcon(interpx, interpy, x, y, splitflags, workingPic, colormap);
// Target reticule
@ -3943,19 +3998,6 @@ static void K_drawKartMinimap(void)
K_drawKartMinimapIcon(interpx, interpy, x, y, splitflags, kp_wantedreticle, NULL);
}
if (!nocontest)
{
K_drawKartMinimapIcon(
interpx,
interpy,
x + FixedMul(FCOS(ang), ICON_DOT_RADIUS),
y - FixedMul(FSIN(ang), ICON_DOT_RADIUS),
splitflags,
kp_minimapdot,
colormap
);
}
K_drawKartMinimapNametag(interpx, interpy, x, y, splitflags, mobj->player);
}
}

View file

@ -64,6 +64,7 @@
#include "i_system.h"
#include "lua_script.h"
#include "g_game.h" // G_MapNumber
#include "r_patchrotation.h"
#include "k_terrain.h"
@ -990,6 +991,10 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup, wadco
Z_Calloc(numlumps * sizeof (*wadfile->lumpcache), PU_STATIC, &wadfile->lumpcache);
Z_Calloc(numlumps * sizeof (*wadfile->patchcache), PU_STATIC, &wadfile->patchcache);
#ifdef ROTSPRITE
Z_Calloc(numlumps * sizeof (*wadfile->rotcache), PU_STATIC, &wadfile->rotcache);
#endif
//
// add the wadfile
//
@ -2161,6 +2166,22 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag)
return W_CachePatchNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag);
}
#ifdef ROTSPRITE
// Caches a rotsprite for patch rotation.
void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum)
{
lumpcache_t *rotcache = wadfiles[wadnum]->rotcache;
if (!rotcache[lumpnum])
{
rotsprite_t *rspr = RotatedPatch_Create(ROTANGLES);
Z_SetUser(rspr, (void **)(&rotcache[lumpnum]));
}
return (void *)(rotcache[lumpnum]);
}
#endif // ROTSPRITE
void W_UnlockCachedPatch(void *patch)
{
if (!patch)
@ -2187,6 +2208,45 @@ void *W_CachePatchName(const char *name, INT32 tag)
return W_CachePatchNum(num, tag);
}
#ifdef ROTSPRITE
// Caches a patch, and if needed, rotates said patch.
void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag)
{
lumpnum_t num;
patch_t *ptr;
rotsprite_t *rspr;
INT32 idx = rotationangle;
num = W_CheckNumForName(name);
if (num == LUMPERROR)
num = W_GetNumForName("MISSING");
// No rotation? No need to do any of this nonsense.
if (rotationangle < 1 || rotationangle >= ROTANGLES)
return W_CachePatchNum(num, tag);
rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num));
if (rspr->patches[idx] == NULL)
{
INT32 xpivot = 0, ypivot = 0;
ptr = W_CachePatchNum(num, PU_PATCH);
// >y pivot centered
// >x pivot not centered
// Why?
xpivot = ptr->width / 2;
ypivot = ptr->height / 2;
RotatedPatch_DoRotation(rspr, ptr, rotationangle, xpivot, ypivot, false);
}
return rspr->patches[idx];
}
#endif
void *W_CachePatchLongName(const char *name, INT32 tag)
{
lumpnum_t num;

View file

@ -123,6 +123,7 @@ struct wadfile_t
lumpinfo_t *lumpinfo;
lumpcache_t *lumpcache;
lumpcache_t *patchcache;
lumpcache_t *rotcache;
UINT16 numlumps; // this wad's number of resources
FILE *handle;
UINT32 filesize; // for network
@ -218,6 +219,9 @@ void *W_CachePatchLongName(const char *name, INT32 tag);
// Returns either a Software patch, or an OpenGL patch.
// Performs any necessary conversions from PNG images.
void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag);
#ifdef ROTSPRITE
void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag);
#endif
void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag);
// Returns a Software patch.