Compare commits

..
Author SHA1 Message Date
Alug d122f80d53 cache vid.height 2025-10-11 21:20:42 +02:00
indev ab4a4ae42f Update VHS effect for transposed drawing 2025-10-11 21:11:00 +03:00
Alug f9b6e94744 style fix 2025-10-11 17:35:22 +02:00
Alug 80bbf1c777 fix intermission background 2025-10-11 17:32:52 +02:00
Alug 9d18846134 move "newview sky" check before skyplane loop
saves us some pointless work going through all planes if we dont need to draw the sky
2025-10-10 23:37:13 +02:00
Alug 93c4278753 double kSpanTaskGranularity
seems to slightly speed up spans now
2025-10-10 23:32:35 +02:00
Alug 38c2648cce fix compiler warning 2025-10-10 23:03:40 +02:00
Alug 2a9bce9481 remove stride variable from column drawers
not needed since we increment per pixel now
also inlines the drawpixel stuff
2025-10-10 23:02:37 +02:00
Alug ad7c6b711f Merge branch 'Saturn-Next' into transposesoft 2025-10-10 22:42:07 +02:00
indev f2aafbb8f6 Fix V_FLIP handling for V_DrawStretchyFixedPatch 2025-10-10 23:32:23 +03:00
indev 4b125a3446 Fix POSTIMG_MIRROR and POSTIMG_FLIP (POSTIMG_MIRROR|POSTIMG_FLIP don't need to be changed) 2025-10-10 23:02:41 +03:00
Alug 5b3d6a4ff8 size_t deez 2025-10-10 22:02:46 +02:00
Alug 65b41cc59f merge I_ReadScreen loops
both did the same thing
2025-10-10 21:52:50 +02:00
Alug 5baaa3207d fix gif recording 2025-10-10 21:49:29 +02:00
Alug 5164628b6b fix wipes 2025-10-10 21:44:33 +02:00
Alug 8434c29d47 use the other titled span drawer loop + fix warnings
seems to be faster in this case
2025-10-10 21:38:35 +02:00
Alug e85d8d6185 fix most things
fix patch drawers mostly (V_FLIP seems broken)
fix VID_BlitLinearScreen
fix wöter ripples
fix screenshots

gif recording is still wonky, but atleast doesent draw complete garbage
wipes are still broken
flipcam and encore aswell
2025-10-10 21:22:01 +02:00
Alug f10470fadf WIP: transpose software renderer
so far, level renders correctly
some patches also render correctly
everything else is still broken
2025-10-10 20:18:19 +02:00
76 changed files with 2267 additions and 1372 deletions

No files matched your search

+13 -21
View File
@@ -69,7 +69,6 @@
# VALGRIND=1 - Enable Valgrind memory debugging support.
# PROFILEMODE=1 - Enable performance profiling (gprof).
# USEASAN=1 - Enable building with Address Sanitizer.
# USEUBSAN=1 - Enable building with Undefined Behavior Sanitizer.
# NOLIBBACKTRACE=1 - Disable using Libbacktrace for crashlog traces.
#
# General flags for building:
@@ -244,14 +243,10 @@ ifdef STATIC
libs+=-static
endif
ifneq (,$(filter $(CC) $(CXX),gcc g++))
opts+=-mno-ms-bitfields
endif
# build with profiling information
ifdef PROFILEMODE
opts+=-pg
libs+=-pg
LDFLAGS+=-pg
endif
ifdef DEBUGMODE
@@ -261,32 +256,29 @@ debug_opts=-DNDEBUG
opts+=-O3
ifdef USELTO
# compile with LTO
ifdef MINGW
opts+=-flto=auto -g
LDFLAGS+=-flto=auto -g
else
opts+=-flto=auto
libs+=-flto=auto
LDFLAGS+=-flto=auto
endif
endif
endif
ifdef USEASAN
# compile with asan
ifdef MINGW
opts+=-fsanitize=address -g
libs+=-fsanitize=address -g
else
opts+=-fsanitize=address
libs+=-fsanitize=address
endif
ifdef USEUBSAN
# compile with asan
opts+=-fsanitize=undefined
libs+=-fsanitize=undefined
endif
ifneq (,$(filter $(CC) $(CXX),clang clang++))
libs+=-fuse-ld=lld
endif
ifdef MINGW
# mingw needs this passed AFTER lto and the likes were passed
# otherwise libbacktrace may break
opts+=-g
libs+=-g
ifeq ($(CC),clang)
LDFLAGS+= -fuse-ld=lld
endif
# debug_opts also get passed to windres
+1 -1
View File
@@ -10,7 +10,7 @@
makedir:=$(makedir)/SDL
opts+=-DHAVE_SDL
opts+=-DDIRECTFULLSCREEN -DHAVE_SDL
sources+=$(call List,sdl/Sourcefile)
NOUPNP=1
+1 -3
View File
@@ -2,8 +2,6 @@
# Mingw, if you don't know, that's Win32/Win64
#
sources+=$(call List,win32/Sourcefile)
ifndef MINGW64
EXENAME?=srb2kart-saturn_32bit.exe
else
@@ -97,7 +95,7 @@ LIBBACKTRACE_libs:=-L$(lib)/lib/x86_64 -lbacktrace
$(eval $(call _set,LIBBACKTRACE))
else
lib:=../libs/drmingw
opts+=-I$(lib)/include -DHAVE_DRMINGW
opts+=-I$(lib)/include
libs+=-L$(lib)/lib/win32 -lmgwhelp -lexchndl
endif
+1 -1
View File
@@ -53,7 +53,7 @@ r_data.c
r_draw.c
r_fps.cpp
r_main.cpp
r_patch.cpp
r_patch.c
r_patchrotation.c
r_plane.cpp
r_segs.cpp
+1 -1
View File
@@ -785,7 +785,7 @@ static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc)
{
if (xx < 0 || yy < 0 || xx >= f_w || yy >= f_h)
return; // off the screen
am_buf[(yy*f_w) + xx] = cc;
am_buf[(xx*f_h) + yy] = cc;
}
//
+6 -7
View File
@@ -1913,14 +1913,13 @@ void CV_AddValue(consvar_t *var, INT32 increment)
max = (M_SecretUnlocked(SECRET_HARDSPEED) ? 3 : 2);
}
#ifdef PARANOIA
if (currentindice == -1 || max == 0)
I_Error("CV_AddValue: current value %d not found in possible value\n", var->value);
if (currentindice == -1)
I_Error("CV_AddValue: current value %d not found in possible value\n",
var->value);
#endif
if (max > 0)
{
newindice = (currentindice + increment + max) % max;
CV_Set(var, var->PossibleValue[newindice].strvalue);
}
newindice = (currentindice + increment + max) % max;
CV_Set(var, var->PossibleValue[newindice].strvalue);
}
}
else
+31
View File
@@ -69,9 +69,14 @@ static boolean consoleready; // console prompt is ready
INT32 con_destlines; // vid lines used by console at final position
static INT32 con_curlines; // vid lines currently used by console
INT32 con_clipviewtop; // (useless)
static UINT8 con_hudlines; // number of console heads up message lines
static UINT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines
INT32 con_clearlines; // top screen lines to refresh when view reduced
boolean con_hudupdate; // when messages scroll, we need a backgrnd refresh
// console text output
static char *con_line; // console text output current line
static size_t con_cx; // cursor position in current line
@@ -388,6 +393,9 @@ void CON_Init(void)
Lock_state();
//note: CON_Ticker should always execute at least once before D_Display()
con_clipviewtop = -1; // -1 does not clip
con_hudlines = atoi(cons_hudlines.defaultvalue);
Unlock_state();
@@ -719,6 +727,7 @@ void CON_ToggleOff(void)
con_curlines = 0;
CON_ClearHUD();
con_forcepic = 0;
con_clipviewtop = -1; // remove console clipping of view
I_SetTextInput(false);
@@ -770,6 +779,18 @@ void CON_Ticker(void)
}
}
// clip the view, so that the part under the console is not drawn
con_clipviewtop = -1;
if (cons_backpic.value) // clip only when using an opaque background
{
if (con_curlines > 0)
con_clipviewtop = con_curlines - viewwindowy - 1 - 10;
// NOTE: BIG HACK::SUBTRACT 10, SO THAT WATER DON'T COPY LINES OF THE CONSOLE
// WINDOW!!! (draw some more lines behind the bottom of the console)
if (con_clipviewtop < 0)
con_clipviewtop = -1; // maybe not necessary, provided it's < 0
}
// check if console ready for prompt
if (con_destlines >= minheight)
{
@@ -1079,6 +1100,9 @@ static void CON_Linefeed(void)
con_line = &con_buffer[(con_cy%con_totallines)*con_width];
memset(con_line, ' ', con_width);
// make sure the view borders are refreshed if hud messages scroll
con_hudupdate = true; // see HU_Erase()
}
// Outputs text into the console text buffer
@@ -1465,6 +1489,9 @@ static void CON_DrawHudlines(void)
//V_DrawCharacter(x, y, (p[c]&0xff) | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
y += charheight;
}
// top screen lines that might need clearing when view is reduced
con_clearlines = y; // this is handled by HU_Erase();
}
// draw the console background, text, and prompt if enough place
@@ -1482,6 +1509,10 @@ static void CON_DrawConsole(void)
if (con_curlines <= 0)
return;
//FIXME: refresh borders only when console bg is translucent
con_clearlines = con_curlines; // clear console draw from view borders
con_hudupdate = true; // always refresh while console is on
// draw console background
if (cons_backpic.value || con_forcepic)
{
+5
View File
@@ -30,9 +30,14 @@ extern boolean con_recalc;
extern boolean con_startup;
// top clip value for view render: do not draw part of view hidden by console
extern INT32 con_clipviewtop;
// 0 means console if off, or moving out
extern INT32 con_destlines;
extern INT32 con_clearlines; // lines of top of screen to refresh
extern boolean con_hudupdate; // hud messages have changed, need refresh
extern UINT32 con_scalefactor; // console text scale factor
extern consvar_t cons_backcolor, cons_menuhighlight;
+70 -56
View File
@@ -347,65 +347,11 @@ static void D_Renderview(void)
}
}
for (i = 0; i <= splitscreen; i++)
{
if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD)
{
viewssnum = i;
switch (i)
{
case 1:
if (splitscreen > 1)
{
viewwindowx = viewwidth;
viewwindowy = 0;
}
else
{
viewwindowx = 0;
viewwindowy = viewheight;
}
break;
case 2:
viewwindowx = 0;
viewwindowy = viewheight;
break;
case 3:
viewwindowx = viewwidth;
viewwindowy = viewheight;
break;
default: // Initialize for P1
viewwindowy = viewwindowx = 0;
objectsdrawn = 0;
break;
}
#ifdef HWRENDER
if (rendermode == render_opengl)
{
HWR_RenderPlayerView();
}
else if (rendermode == render_soft)
#endif
R_RenderPlayerView(&players[displayplayers[i]]);
}
if (rendermode == render_soft)
{
if (i == 0)
R_ApplyViewMorph();
V_DoPostProcessor(i, postimgparam[i]);
}
}
// Draw over the fourth screen so you don't have to stare at a HOM :V
if (splitscreen == 2)
{
// V_DrawPatchFill, but for the fourth screen only
patch_t *pat = W_CachePatchName("SRB2BACK", PU_PATCH);
patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE);
INT32 x, y, pw = SHORT(pat->width) * vid.dup, ph = SHORT(pat->height) * vid.dup;
for (x = vid.width>>1; x < vid.width; x += pw)
@@ -415,6 +361,65 @@ static void D_Renderview(void)
}
}
for (i = 0; i <= splitscreen; i++)
{
const boolean issplitscreen = (i > 0);
if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD)
{
viewssnum = i;
if (!issplitscreen) // Initialize for P1
{
viewwindowy = viewwindowx = 0;
objectsdrawn = 0;
}
#ifdef HWRENDER
if (rendermode == render_opengl)
{
HWR_RenderPlayerView();
R_RestoreLevelInterpolators();
continue;
}
#endif
if (issplitscreen) // Splitscreen-specific
{
switch (i)
{
case 1:
if (splitscreen > 1)
{
viewwindowx = viewwidth;
viewwindowy = 0;
}
else
{
viewwindowx = 0;
viewwindowy = viewheight;
}
break;
case 2:
viewwindowx = 0;
viewwindowy = viewheight;
break;
case 3:
viewwindowx = viewwidth;
viewwindowy = viewheight;
default:
break;
}
}
R_RenderPlayerView(&players[displayplayers[i]]);
}
if (!issplitscreen)
R_ApplyViewMorph();
V_DoPostProcessor(i, postimgparam[i]);
}
R_RestoreLevelInterpolators();
}
@@ -517,16 +522,19 @@ static boolean D_Display(void)
case GS_LEVEL:
if (!gametic)
break;
HU_Erase();
AM_Drawer();
break;
case GS_INTERMISSION:
Y_IntermissionDrawer();
HU_Erase();
HU_Drawer();
break;
case GS_VOTING:
Y_VoteDrawer();
HU_Erase();
HU_Drawer();
break;
@@ -541,6 +549,7 @@ static boolean D_Display(void)
case GS_CUTSCENE:
F_CutsceneDrawer();
HU_Erase();
HU_Drawer();
break;
@@ -550,6 +559,7 @@ static boolean D_Display(void)
case GS_EVALUATION:
F_GameEvaluationDrawer();
HU_Erase();
HU_Drawer();
break;
@@ -559,6 +569,7 @@ static boolean D_Display(void)
case GS_CREDITS:
F_CreditDrawer();
HU_Erase();
HU_Drawer();
break;
@@ -575,6 +586,7 @@ static boolean D_Display(void)
{
// I don't think HOM from nothing drawing is independent...
F_WaitingPlayersDrawer();
HU_Erase();
HU_Drawer();
}
case GS_TIMEATTACK:
@@ -597,7 +609,7 @@ static boolean D_Display(void)
{
if (rendermode == render_soft)
{
VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.width);
VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.height, vid.height);
}
lastdraw = false;
@@ -1913,7 +1925,9 @@ void D_SRB2Main(void)
G_LoadGameData();
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif
// set user default mode or mode set at cmdline
SCR_CheckDefaultMode();
+6 -4
View File
@@ -964,11 +964,10 @@ void D_RegisterClientCommands(void)
// g_input.c
CV_RegisterVar(&cv_controlperkey);
CV_RegisterVar(&cv_turnsmooth);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_turnsmooth[i]);
CV_RegisterVar(&cv_turnaxis[i]);
CV_RegisterVar(&cv_moveaxis[i]);
CV_RegisterVar(&cv_camturnaxis[i]);
@@ -985,8 +984,6 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_xdeadzone[i]);
CV_RegisterVar(&cv_ydeadzone[i]);
CV_RegisterVar(&cv_litesteer[i]);
CV_RegisterVar(&cv_usejoystick[i]);
CV_RegisterVar(&cv_joyscale[i]);
CV_RegisterVar(&cv_rumble[i]);
@@ -1994,6 +1991,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
}
else
SetPlayerSkinByNum(playernum, skin);
#ifdef HAVE_DISCORDRPC
if (playernum == consoleplayer)
DRPC_UpdatePresence();
#endif
}
void SendWeaponPref(void)
+1 -27
View File
@@ -49,27 +49,6 @@ discordRequest_t *discordRequestList = NULL;
static char self_ip[IP_SIZE+1];
/*--------------------------------------------------
* const char *DRPC_HideUsername(const char *input)
*
* See header file for description.
* --------------------------------------------------*/
const char *DRPC_HideUsername(const char *input)
{
static char buffer[5];
int i;
buffer[0] = input[0];
for (i = 1; i < 4; ++i)
{
buffer[i] = '.';
}
buffer[4] = '\0';
return buffer;
}
boolean drpc_init = false;
/*--------------------------------------------------
@@ -126,7 +105,7 @@ static void DRPC_HandleReady(const DiscordUser *user)
}
else
{
CONS_Printf("Discord: connected to %s (%s)\n", user->username, user->userId);
CONS_Printf("Discord: connected to %s#%s (%s)\n", user->username, user->discriminator, user->userId);
}
}
@@ -262,10 +241,8 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
newRequest->username = Z_Calloc(344, PU_STATIC, NULL);
snprintf(newRequest->username, 344, "%s", requestUser->username);
#if 0
newRequest->discriminator = Z_Calloc(8, PU_STATIC, NULL);
snprintf(newRequest->discriminator, 8, "%s", requestUser->discriminator);
#endif
newRequest->userID = Z_Calloc(32, PU_STATIC, NULL);
snprintf(newRequest->userID, 32, "%s", requestUser->userId);
@@ -331,9 +308,6 @@ void DRPC_RemoveRequest(discordRequest_t *removeRequest)
}
Z_Free(removeRequest->username);
#if 0
Z_Free(removeRequest->discriminator);
#endif
Z_Free(removeRequest->userID);
Z_Free(removeRequest);
}
-11
View File
@@ -29,9 +29,7 @@ extern struct discordInfo_s {
typedef struct discordRequest_s {
char *username; // Discord user name.
#if 0 // Good night, sweet prince...
char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar.
#endif
char *userID; // The ID of the Discord user, gets used with Discord_Respond()
// HAHAHA, no.
@@ -46,15 +44,6 @@ typedef struct discordRequest_s {
extern discordRequest_t *discordRequestList;
/*--------------------------------------------------
* const char *DRPC_HideUsername(const char *input);
*
* Handle usernames while cv_discordstreamer is activated.
* (The loss of discriminators is still a dumbass regression
* that I will never forgive the Discord developers for.)
* --------------------------------------------------*/
const char *DRPC_HideUsername(const char *input);
/*--------------------------------------------------
void DRPC_RemoveRequest(void);
+6
View File
@@ -90,6 +90,12 @@ extern FILE *logstream;
extern char logfilename[1024];
#endif
// not sure if this belongs here lul
// TODO: figure out whats preventing 32bit windows from working with libbacktrace
#if defined(_WIN32) && !defined(__MINGW64__)
#define HAVE_DRMINGW
#endif
#if defined (HAVE_LIBBACKTRACE)
#define CRASH_LOGFILE_NAME "srb2kart-crash-log.txt"
#elif defined (HAVE_DRMINGW)
+1
View File
@@ -43,6 +43,7 @@ extern "C" {
#define UINT64 uint64_t
#ifdef __APPLE_CC__
#define DIRECTFULLSCREEN 1
#define DEBUG_LOG
#define NOIPX
#endif
+10 -10
View File
@@ -249,16 +249,16 @@ static void F_DoWipe(fademask_t *fademask)
draw_linestart = scrypos[masky];
draw_lineend = scrypos[masky + 1];
relativepos = (draw_linestart * vid.width) + draw_rowstart;
draw_linestogo = draw_lineend - draw_linestart;
relativepos = (draw_rowstart * vid.height) + draw_linestart;
draw_linestogo = draw_rowend - draw_rowstart;
if (*mask == 0)
{
// shortcut - memcpy source to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_lineend-draw_linestart);
relativepos += vid.height;
}
}
else if (*mask == 10)
@@ -266,8 +266,8 @@ static void F_DoWipe(fademask_t *fademask)
// shortcut - memcpy target to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_lineend-draw_linestart);
relativepos += vid.height;
}
}
else
@@ -281,12 +281,12 @@ static void F_DoWipe(fademask_t *fademask)
w = w_base + relativepos;
s = s_base + relativepos;
e = e_base + relativepos;
draw_rowstogo = draw_rowend - draw_rowstart;
draw_rowstogo = draw_lineend - draw_linestart;
while (draw_rowstogo--)
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
relativepos += vid.width;
relativepos += vid.height;
}
// END DRAWING LOOP
}
@@ -314,7 +314,7 @@ void F_WipeStartScreen(void)
}
#endif
wipe_scr_start = vid.screens[3];
I_ReadScreen(wipe_scr_start, 1);
M_Memcpy(wipe_scr_start, vid.screens[0], vid.width*vid.height);
#endif
}
@@ -331,7 +331,7 @@ void F_WipeEndScreen(void)
}
#endif
wipe_scr_end = vid.screens[4];
I_ReadScreen(wipe_scr_end, 1);
M_Memcpy(wipe_scr_end, vid.screens[0], vid.width*vid.height);
V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start);
#endif
}
+2 -2
View File
@@ -44,7 +44,7 @@ consvar_t cv_addons_search_case = {"addons_search_case", "No", CV_SAVE, CV_YesNo
static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}};
consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
char menupath[MAXFILEPATH];
char menupath[1024];
size_t menupathindex[menudepth];
size_t menudepthleft = menudepth;
@@ -111,7 +111,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
int found = 0;
char *searchname;
int depthleft = maxsearchdepth;
char searchpath[MAXFILEPATH];
char searchpath[1024];
size_t *searchpathindex;
dirhandle = (DIR**)malloc(maxsearchdepth * sizeof(DIR*));
+1 -2
View File
@@ -34,8 +34,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
#define menudepth 20
#define MAXFILEPATH 1024
extern char menupath[MAXFILEPATH];
extern char menupath[1024];
extern size_t menupathindex[menudepth];
extern size_t menudepthleft;
+8 -21
View File
@@ -630,7 +630,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim)
ghostext[playernum].flags |= EZT_HIT;
ghostext[playernum].hits++;
ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, &ghostext[playernum].hitlist);
Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_STATIC, &ghostext[playernum].hitlist);
P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim);
}
@@ -3569,8 +3569,7 @@ void G_SaveDemo(void)
size_t i, strindex = 0;
boolean dash = true;
//for (i = 0; demo.titlename[i] && i < 127; i++) ?????
for (i = 0; i < 64 && demo.titlename[i]; i++)
for (i = 0; demo.titlename[i] && i < 127; i++)
{
if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') ||
(demo.titlename[i] >= '0' && demo.titlename[i] <= '9'))
@@ -3585,7 +3584,7 @@ void G_SaveDemo(void)
strindex++;
dash = false;
}
else if (strindex && !dash)
else if (!dash)
{
demo_slug[strindex] = '-';
strindex++;
@@ -3593,24 +3592,12 @@ void G_SaveDemo(void)
}
}
if (dash && strindex)
{
strindex--;
}
demo_slug[strindex] = '\0';
demo_slug[strindex] = 0;
if (dash) demo_slug[strindex-1] = 0;
if (demo_slug[0] != '\0')
{
// Slug is valid, write the chosen filename.
writepoint = strstr(demoname, "-");
if (!writepoint)
return;
writepoint++;
size_t flen = 128 - (writepoint - demoname) - 4;
snprintf(writepoint, flen, "%s.lmp", demo_slug);
}
writepoint = strstr(demoname, "-") + 1;
demo_slug[128 - (writepoint - demoname) - 4] = 0;
sprintf(writepoint, "%s.lmp", demo_slug);
}
length = *(UINT32 *)demoinfo_p;
+1 -1
View File
@@ -67,7 +67,7 @@ typedef enum {
} menudemotype_e;
typedef struct menudemo_s {
char filepath[1023 + 256]; // see M_PrepReplayList and sizeof menupath
char filepath[256];
menudemotype_e type;
char title[65]; // Null-terminated for string prints
+16 -23
View File
@@ -452,13 +452,6 @@ consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS] = {
{"joy4_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = {
{"litesteer", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"litesteer2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"litesteer3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"litesteer4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -1021,8 +1014,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
else
th = 0;
if (th < (cv_turnsmooth[forplayer].value * 3))
tspeed = cv_turnsmooth[forplayer].value == 2 ? 2 : 0; // slow turn
if (th < SLOWTURNTICS)
tspeed = cv_turnsmooth.value == 2 ? 2 : 0; // slow turn
else
tspeed = 1;
@@ -1031,32 +1024,30 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// let movement keys cancel each other out
if (turnright && !(turnleft))
{
cmd->angleturn -= angleturn[tspeed];
cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed]));
cmd->driftturn = (INT16)(cmd->driftturn - (angleturn[tspeed]));
side += sidemove[1];
}
else if (turnleft && !(turnright))
{
cmd->angleturn += angleturn[tspeed];
cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed]));
cmd->driftturn = (INT16)(cmd->driftturn + (angleturn[tspeed]));
side -= sidemove[1];
}
if (analogjoystickmove && axis != 0)
{
cmd->angleturn -= (axis * KART_FULLTURN) / JOYAXISRANGE;
side += (axis * sidemove[0]) / JOYAXISRANGE;
// JOYAXISRANGE should be 1023 (divide by 1024)
cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG!
cmd->driftturn = (INT16)(cmd->driftturn - (((axis * angleturn[1]) >> 10)));
side += ((axis * sidemove[0]) >> 10);
}
if (cv_mouseturn.value)
{
//THIS WORKS WTF????????
cmd->angleturn -= (mousex*(encoremode ? -1 : 1)*8);
}
// Digital users can input diagonal-back for shallow turns.
if (cv_litesteer[forplayer].value && InputDown(gc_aimbackward, ssplayer)
&& abs(cmd->angleturn) == KART_FULLTURN) // My keyboard hits 1024 but my keyboard only hits 1023, video games
{
cmd->angleturn /= 2;
cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8)));
cmd->driftturn = (INT16)(cmd->driftturn - ((mousex*(encoremode ? -1 : 1)*8)));
}
if (objectplacing) // SRB2Kart: spectators need special controls // not anymore huehuehue
@@ -1169,8 +1160,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
else if (cmd->angleturn < (-angleturn[1]))
cmd->angleturn = (-angleturn[1]);
// until here both are the very same
cmd->driftturn = cmd->angleturn;
if (cmd->driftturn > (angleturn[1]))
cmd->driftturn = (angleturn[1]);
else if (cmd->driftturn < (-angleturn[1]))
cmd->driftturn = (-angleturn[1]);
if (player->mo)
cmd->angleturn = K_GetKartTurnValue(player, cmd->angleturn);
+1 -2
View File
@@ -72,8 +72,6 @@ extern consvar_t cv_custom3axis[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_xdeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
// Hud offsets
@@ -155,6 +153,7 @@ typedef enum
// mouseaiming (looking up/down with the mouse or keyboard)
#define KB_LOOKSPEED (1<<25)
#define MAXPLMOVE (50)
#define SLOWTURNTICS (cv_turnsmooth.value * 3)
// build an internal map name MAPxx from map number
const char *G_BuildMapName(INT32 map);
+1 -7
View File
@@ -37,13 +37,7 @@ static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, "
consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS] = {
{"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing2", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing3", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
{"turnsmoothing4", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_turnsmooth = {"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static void G_ResetPlayerDeviceRumble(INT32 player);
static void rumble_off_handle(void);
+1 -2
View File
@@ -110,8 +110,7 @@ typedef enum
// mouse values are used once
extern consvar_t cv_mousesens, cv_mouseysens;
extern consvar_t cv_controlperkey;
extern consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_controlperkey, cv_turnsmooth;
extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
+1 -1
View File
@@ -804,7 +804,7 @@ static void HWR_PrecacheLevelSprites(void)
void HWR_PrecacheLevel(void)
{
if (gamestate != GS_LEVEL)
if (rendermode != render_opengl)
return;
// Precache flats.
+195 -1
View File
@@ -31,6 +31,11 @@
#include "../st_stuff.h"
#include <fcntl.h>
#include "../i_video.h" // for rendermode != render_glide
#ifndef O_BINARY
#define O_BINARY 0
#endif
typedef struct
{
@@ -53,6 +58,68 @@ static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111
static const float FLOATBASEVIDWIDTH = (float)BASEVIDWIDTH;
static const float FLOATBASEVIDHEIGHT = (float)BASEVIDHEIGHT;
//
// -----------------+
// HWR_DrawPatch : Draw a 'tile' graphic
// Notes : x,y : positions relative to the original Doom resolution
// : textes(console+score) + menus + status bar
// -----------------+
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option)
{
FOutVector v[4];
FBITFIELD flags;
GLPatch_t *hwrPatch;
// 3--2
// | /|
// |/ |
// 0--1
float sdup = FIXED_TO_FLOAT(vid.fdup)*2.0f;
float pdup = FIXED_TO_FLOAT(vid.fdup)*2.0f;
// make patch ready in hardware cache
HWR_GetPatch(gpatch);
hwrPatch = ((GLPatch_t *)gpatch->hardware);
switch (option & V_SCALEPATCHMASK)
{
case V_NOSCALEPATCH:
pdup = 2.0f;
break;
case V_SMALLSCALEPATCH:
pdup = 2.0f * FIXED_TO_FLOAT(vid.smalldup*FRACUNIT);
break;
case V_MEDSCALEPATCH:
pdup = 2.0f * FIXED_TO_FLOAT(vid.meddup*FRACUNIT);
break;
}
if (option & V_NOSCALESTART)
sdup = 2.0f;
v[0].x = v[3].x = (x*sdup-gpatch->leftoffset*pdup)/vid.width - 1;
v[2].x = v[1].x = (x*sdup+(gpatch->width - gpatch->leftoffset)*pdup)/vid.width - 1;
v[0].y = v[1].y = 1-(y*sdup-gpatch->topoffset*pdup)/vid.height;
v[2].y = v[3].y = 1-(y*sdup+(gpatch->height - gpatch->topoffset)*pdup)/vid.height;
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
v[0].s = v[3].s = 0.0f;
v[2].s = v[1].s = hwrPatch->max_s;
v[0].t = v[1].t = 0.0f;
v[2].t = v[3].t = hwrPatch->max_t;
flags = PF_Translucent|PF_NoDepthTest;
if (option & V_WRAPX)
flags |= PF_ForceWrapX;
if (option & V_WRAPY)
flags |= PF_ForceWrapY;
// clip it since it is used for bunny scroll in doom I
GL_DrawPolygon(NULL, v, 4, flags);
}
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags)
{
FOutVector v[4];
@@ -569,6 +636,133 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height)
}
// ==========================================================================
// R_DRAW.C STUFF
// ==========================================================================
// ------------------
// HWR_DrawViewBorder
// Fill the space around the view window with a Doom flat texture, draw the
// beveled edges.
// 'clearlines' is useful to clear the heads up messages, when the view
// window is reduced, it doesn't refresh all the view borders.
// ------------------
void HWR_DrawViewBorder(INT32 clearlines)
{
INT32 x, y;
INT32 top, side;
INT32 baseviewwidth, baseviewheight;
INT32 basewindowx, basewindowy;
patch_t *patch;
if (!clearlines)
clearlines = BASEVIDHEIGHT; // refresh all
// calc view size based on original game resolution
baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewwidth), vid.fdup)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7;
baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewheight), vid.fdup));
top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowy), vid.fdup));
side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowx), vid.fdup));
// top
HWR_DrawFlatFill(0, 0,
BASEVIDWIDTH, (top < clearlines ? top : clearlines),
st_borderpatchnum);
// left
if (top < clearlines)
HWR_DrawFlatFill(0, top, side,
(clearlines-top < baseviewheight ? clearlines-top : baseviewheight),
st_borderpatchnum);
// right
if (top < clearlines)
HWR_DrawFlatFill(side + baseviewwidth, top, side,
(clearlines-top < baseviewheight ? clearlines-top : baseviewheight),
st_borderpatchnum);
// bottom
if (top + baseviewheight < clearlines)
HWR_DrawFlatFill(0, top + baseviewheight,
BASEVIDWIDTH, BASEVIDHEIGHT, st_borderpatchnum);
//
// draw the view borders
//
basewindowx = (BASEVIDWIDTH - baseviewwidth)>>1;
if (baseviewwidth == BASEVIDWIDTH)
basewindowy = 0;
else
basewindowy = top;
// top edge
if (clearlines > basewindowy - 8)
{
patch = W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH);
for (x = 0; x < baseviewwidth; x += 8)
HWR_DrawPatch(patch, basewindowx + x, basewindowy - 8,
0);
}
// bottom edge
if (clearlines > basewindowy + baseviewheight)
{
patch = W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH);
for (x = 0; x < baseviewwidth; x += 8)
HWR_DrawPatch(patch, basewindowx + x,
basewindowy + baseviewheight, 0);
}
// left edge
if (clearlines > basewindowy)
{
patch = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH);
for (y = 0; y < baseviewheight && basewindowy + y < clearlines;
y += 8)
{
HWR_DrawPatch(patch, basewindowx - 8, basewindowy + y,
0);
}
}
// right edge
if (clearlines > basewindowy)
{
patch = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH);
for (y = 0; y < baseviewheight && basewindowy+y < clearlines;
y += 8)
{
HWR_DrawPatch(patch, basewindowx + baseviewwidth,
basewindowy + y, 0);
}
}
// Draw beveled corners.
if (clearlines > basewindowy - 8)
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TL],
PU_PATCH),
basewindowx - 8, basewindowy - 8, 0);
if (clearlines > basewindowy - 8)
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TR],
PU_PATCH),
basewindowx + baseviewwidth, basewindowy - 8, 0);
if (clearlines > basewindowy+baseviewheight)
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BL],
PU_PATCH),
basewindowx - 8, basewindowy + baseviewheight, 0);
if (clearlines > basewindowy + baseviewheight)
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BR],
PU_PATCH),
basewindowx + baseviewwidth,
basewindowy + baseviewheight, 0);
}
// ==========================================================================
// AM_MAP.C DRAWING STUFF
// ==========================================================================
@@ -974,7 +1168,7 @@ static inline boolean saveTGA(const char *file_name, void *buffer,
INT32 i;
UINT8 *buf8 = buffer;
fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666);
fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
if (fd < 0)
return false;
+70 -38
View File
@@ -65,6 +65,8 @@
// Globals
// ==========================================================================
#define ABS(x) ((x) < 0 ? -(x) : (x))
// false if shaders have not been initialized yet, or if shaders are not available
boolean gl_shadersavailable = false;
@@ -75,6 +77,11 @@ boolean gl_drawing_stencil = false;
static INT32 current_bsp_culling_distance = 0;
// base values set at SetViewSize
float gl_baseviewwindowy, gl_baseviewwindowx;
static float gl_viewwindowy, gl_viewwindowx; // top left corner of view window
float gl_viewwidth, gl_viewheight; // viewport clipping boundaries (screen coords)
FTransform atransform;
// Float variants of viewx, viewy, viewz, etc.
@@ -277,7 +284,6 @@ static void CV_glshaders_OnChange(void)
{
// can't do palette rendering without shaders, so update the state if needed
HWR_TogglePaletteRendering();
HWR_PrecacheLevel();
}
M_UpdateOGLMenu();
}
@@ -295,21 +301,18 @@ static void CV_gltextureformat_OnChange(void)
{
ONLY_IF_GL_LOADED
GL_SetSpecialState(HWD_SET_TEXTURE_FORMAT, cv_gltexturedepth.value);
HWR_PrecacheLevel();
}
static void CV_filtermode_OnChange(void)
{
ONLY_IF_GL_LOADED
GL_SetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
HWR_PrecacheLevel();
}
static void CV_anisotropic_OnChange(void)
{
ONLY_IF_GL_LOADED
GL_SetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);
HWR_PrecacheLevel();
}
static void CV_glpaletterendering_OnChange(void)
@@ -322,9 +325,7 @@ static void CV_glpaletterendering_OnChange(void)
{
HWR_CompileShaders();
HWR_TogglePaletteRendering();
HWR_PrecacheLevel();
}
M_UpdateOGLMenu();
}
@@ -3376,9 +3377,6 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
fixed_t slopez;
float offset = 0;
if (!spr->mobj)
return;
R_GetShadowZ(spr->mobj, &floorslope);
mobjfloor = HWR_OpaqueFloorAtPos(
@@ -3390,7 +3388,14 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
angle_t shadowdir;
// Set direction
shadowdir = localangle[viewssnum] + FixedAngle(cv_cam_rotate[viewssnum].value);
if (splitscreen && R_GetViewNumber() == 1)
shadowdir = localangle[1] + FixedAngle(cv_cam_rotate[1].value);
else if (splitscreen > 1 && R_GetViewNumber() == 2)
shadowdir = localangle[2] + FixedAngle(cv_cam_rotate[2].value);
else if (splitscreen > 2 && R_GetViewNumber() == 3)
shadowdir = localangle[3] + FixedAngle(cv_cam_rotate[3].value);
else
shadowdir = localangle[0] + FixedAngle(cv_cam_rotate[0].value);
// Find floorheight
floorheight = HWR_OpaqueFloorAtPos(
@@ -3402,17 +3407,18 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
// Don't draw it, then!
if (spr->mobj->z < floorheight)
return;
fixed_t floorz;
floorz = HWR_OpaqueFloorAtPos(
spr->mobj->x + P_ReturnThrustX(spr->mobj, shadowdir, spr->mobj->z - floorheight),
spr->mobj->y + P_ReturnThrustY(spr->mobj, shadowdir, spr->mobj->z - floorheight),
spr->mobj->z, spr->mobj->height);
// The shadow would be falling on a wall? Don't draw it, then.
// Would draw midair otherwise.
if (floorz < floorheight)
return;
else
{
fixed_t floorz;
floorz = HWR_OpaqueFloorAtPos(
spr->mobj->x + P_ReturnThrustX(spr->mobj, shadowdir, spr->mobj->z - floorheight),
spr->mobj->y + P_ReturnThrustY(spr->mobj, shadowdir, spr->mobj->z - floorheight),
spr->mobj->z, spr->mobj->height);
// The shadow would be falling on a wall? Don't draw it, then.
// Would draw midair otherwise.
if (floorz < floorheight)
return;
}
floorheight = FixedInt(spr->mobj->z - floorheight);
@@ -3422,11 +3428,12 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
floorheight = FixedInt(spr->mobj->z - mobjfloor);
// technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again
this_scale = FixedToFloat(spr->mobj->scale);
const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES);
const skin_t *moskin = K_GetMobjSkin(spr->mobj);
if (moskin && moskin->flags & SF_HIRES)
this_scale *= FixedToFloat(moskin->highresscale);
if (spr->mobj)
this_scale = FixedToFloat(spr->mobj->scale);
if (hires)
this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale);
// create the sprite billboard
//
@@ -4047,7 +4054,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
const precipmobj_t *sprmo = spr->precip;
if (UNLIKELY(!sprmo->subsector))
if (UNLIKELY(!sprmo || !sprmo->subsector))
return;
// cache sprite graphics
@@ -4328,7 +4335,7 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2)
const INT32 n1 = *(const INT32*)p1;
const INT32 n2 = *(const INT32*)p2;
return abs(drawnodes[n2].u.plane.fixedheight - viewz) - abs(drawnodes[n1].u.plane.fixedheight - viewz);
return ABS(drawnodes[n2].u.plane.fixedheight - viewz) - ABS(drawnodes[n1].u.plane.fixedheight - viewz);
}
//
@@ -5309,10 +5316,10 @@ static void HWR_DrawSkyBackground(void)
// -----------------+
static inline void HWR_ClearView(void)
{
GL_GClipRect(viewwindowx,
viewwindowy,
(viewwindowx + viewwidth),
(viewwindowy + viewheight),
GL_GClipRect((INT32)gl_viewwindowx,
(INT32)gl_viewwindowy,
(INT32)(gl_viewwindowx + gl_viewwidth),
(INT32)(gl_viewwindowy + gl_viewheight),
ZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
GL_ClearBuffer(false, true, true, NULL);
}
@@ -5322,6 +5329,19 @@ static inline void HWR_ClearView(void)
// -----------------+
void HWR_SetViewSize(void)
{
// setup view size
gl_viewwidth = (float)vid.width;
gl_viewheight = (float)vid.height;
if (splitscreen)
gl_viewheight /= 2;
if (splitscreen > 1)
gl_viewwidth /= 2;
gl_baseviewwindowy = 0;
gl_baseviewwindowx = 0;
GL_FlushScreenTextures();
}
@@ -5332,9 +5352,7 @@ static void HWR_SetTransformAiming(FTransform *trans)
if (cv_glshearing.value)
{
fixed_t fixedaiming = AIMINGTODY(aimingangle);
trans->viewaiming = FixedToFloat(fixedaiming) * ((float)vid.width / vid.height) / ((float)BASEVIDWIDTH / BASEVIDHEIGHT);
if (splitscreen == 1) // only for 2 player splitscreen
trans->viewaiming *= 2.125; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
trans->viewaiming = FixedToFloat(fixedaiming);
trans->shearing = true;
gl_aimingangle = 0;
}
@@ -5576,6 +5594,20 @@ extern "C" {
// ==========================================================================
static void HWR_RenderFrame(player_t *player, boolean skybox)
{
// set window position
gl_viewwindowx = gl_baseviewwindowx;
gl_viewwindowy = gl_baseviewwindowy;
if ((splitscreen == 1 && viewssnum == 1) || (splitscreen > 1 && viewssnum > 1))
{
gl_viewwindowy += gl_viewheight;
}
if (splitscreen > 1 && viewssnum & 1)
{
gl_viewwindowx += gl_viewwidth;
}
// check for new console commands.
NetUpdate();
@@ -5591,10 +5623,10 @@ static void HWR_RenderFrame(player_t *player, boolean skybox)
if (!skybox && cv_glrenderdistance.value)
{
GL_GClipRect(viewwindowx,
viewwindowy,
(viewwindowx + viewwidth),
(viewwindowy + viewheight),
GL_GClipRect((INT32)gl_viewwindowx,
(INT32)gl_viewwindowy,
(INT32)(gl_viewwindowx + gl_viewwidth),
(INT32)(gl_viewwindowy + gl_viewheight),
ZCLIP_PLANE, clipping_distances[cv_glrenderdistance.value - 1]);
current_bsp_culling_distance = bsp_culling_distances[cv_glrenderdistance.value - 1];
}
+6
View File
@@ -42,6 +42,10 @@ extern "C" {
void HWR_Startup(void);
void HWR_Shutdown(void);
extern float gl_viewwidth, gl_viewheight, gl_baseviewwindowx, gl_baseviewwindowy;
extern float gl_basewindowcenterx, gl_basewindowcentery;
extern unsigned msaa;
extern boolean a2c;
@@ -85,6 +89,7 @@ extern ps_metric_t ps_hw_batchdrawtime;
extern boolean gl_shadersavailable;
// hw_draw.c
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option);
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags);
void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
@@ -93,6 +98,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color);
void HWR_drawAMline(const fline_t *fl, INT32 color);
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength);
void HWR_DrawConsoleBack(UINT32 color, INT32 height);
void HWR_DrawViewBorder(INT32 clearlines);
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
UINT8 *HWR_GetScreenshot(INT32 scale);
+145
View File
@@ -114,6 +114,7 @@ void UnloadModel(model_t *model)
if (model->materials)
Z_Free(model->materials);
DeleteVBOs(model);
Z_Free(model);
}
@@ -193,6 +194,7 @@ model_t *LoadModel(const char *filename, int ztag)
strcpy(model->mdlFilename, filename);
Optimize(model);
GeneratePolygonNormals(model, ztag);
// Default material properties
for (i = 0 ; i < model->numMaterials; i++)
@@ -244,6 +246,13 @@ void GenerateVertexNormals(model_t *model)
M_Memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3);
/* if (!systemSucks)
{
memTag = Z_GetTag(frame->tangents);
float *newTangents = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag);
M_Memcpy(newTangents, frame->tangents, sizeof(float)*3*mesh->numTriangles*3);
}*/
for (k = 0; k < mesh->numVertices; k++)
{
float x, y, z;
@@ -279,15 +288,32 @@ void GenerateVertexNormals(model_t *model)
if (vCount > 1)
{
// Vector::Normalize(&normal);
newNormals[3 * k + 0] = (float)normal.x;
newNormals[3 * k + 1] = (float)normal.y;
newNormals[3 * k + 2] = (float)normal.z;
/* if (!systemSucks)
{
Vector::vector_t tangent;
Vector::Tangent(&normal, &tangent);
newTangents[3 * k + 0] = tangent.x;
newTangents[3 * k + 1] = tangent.y;
newTangents[3 * k + 2] = tangent.z;
}*/
}
}
oldNormals = frame->normals;
frame->normals = newNormals;
Z_Free(oldNormals);
/* if (!systemSucks)
{
float *oldTangents = frame->tangents;
frame->tangents = newTangents;
Z_Free(oldTangents);
}*/
}
}
}
@@ -378,11 +404,15 @@ void Optimize(model_t *model)
newMesh->numTriangles = numTriangles;
newMesh->numVertices = numTriangles * 3;
newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
// if (node->material->lightmap)
// newMesh->lightuvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0);
curFrame = &newMesh->frames[0];
curFrame->material = curMat;
curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
// if (!systemSucks)
// curFrame->tangents = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0);
@@ -406,6 +436,12 @@ void Optimize(model_t *model)
curMesh->uvs,
sizeof(float)*2*curMesh->numTriangles*3);
/* if (node->material->lightmap)
{
M_Memcpy(&newMesh->lightuvs[uvCount],
curMesh->lightuvs,
sizeof(float)*2*curMesh->numTriangles*3);
}*/
uvCount += 2*curMesh->numTriangles*3;
dest = (float*)newMesh->frames[0].vertices;
@@ -420,6 +456,15 @@ void Optimize(model_t *model)
src,
sizeof(float)*3*curMesh->numTriangles*3);
/* if (!systemSucks)
{
dest = (float*)newMesh->frames[0].tangents;
src = (float*)curMesh->frames[0].tangents;
M_Memcpy(&dest[vertCount],
src,
sizeof(float)*3*curMesh->numTriangles*3);
}*/
vertCount += 3 * curMesh->numTriangles * 3;
destByte = (char*)newMesh->frames[0].colors;
@@ -449,3 +494,103 @@ void Optimize(model_t *model)
model->meshes = newMeshes;
model->numMeshes = numMeshes;
}
void GeneratePolygonNormals(model_t *model, int ztag)
{
int i;
for (i = 0; i < model->numMeshes; i++)
{
int j;
mesh_t *mesh = &model->meshes[i];
if (!mesh->frames)
continue;
for (j = 0; j < mesh->numFrames; j++)
{
int k;
mdlframe_t *frame = &mesh->frames[j];
const float *vertices = frame->vertices;
vector_t *polyNormals;
frame->polyNormals = (vector_t*)Z_Malloc(sizeof(vector_t) * mesh->numTriangles, ztag, 0);
polyNormals = frame->polyNormals;
for (k = 0; k < mesh->numTriangles; k++)
{
/// TODO: normalize vectors
(void)vertices;
(void)polyNormals;
// Vector::Normal(vertices, polyNormals);
vertices += 3 * 3;
polyNormals++;
}
}
}
}
//
// Reload
//
// Reload VBOs
//
#if 0
static void Reload(void)
{
/* model_t *node;
for (node = modelHead; node; node = node->next)
{
int i;
for (i = 0; i < node->numMeshes; i++)
{
mesh_t *mesh = &node->meshes[i];
if (mesh->frames)
{
int j;
for (j = 0; j < mesh->numFrames; j++)
CreateVBO(mesh, &mesh->frames[j]);
}
else if (mesh->tinyframes)
{
int j;
for (j = 0; j < mesh->numFrames; j++)
CreateVBO(mesh, &mesh->tinyframes[j]);
}
}
}*/
}
#endif
void DeleteVBOs(model_t *model)
{
(void)model;
/* for (int i = 0; i < model->numMeshes; i++)
{
mesh_t *mesh = &model->meshes[i];
if (mesh->frames)
{
for (int j = 0; j < mesh->numFrames; j++)
{
mdlframe_t *frame = &mesh->frames[j];
if (!frame->vboID)
continue;
bglDeleteBuffers(1, &frame->vboID);
frame->vboID = 0;
}
}
else if (mesh->tinyframes)
{
for (int j = 0; j < mesh->numFrames; j++)
{
tinyframe_t *frame = &mesh->tinyframes[j];
if (!frame->vboID)
continue;
bglDeleteBuffers(1, &frame->vboID);
frame->vboID = 0;
}
}
}*/
}
+6
View File
@@ -28,6 +28,8 @@ typedef struct
float ambient[4], diffuse[4], specular[4], emissive[4];
float shininess;
boolean spheremap;
// Texture::texture_t *texture;
// Texture::texture_t *lightmap;
} material_t;
typedef struct
@@ -38,6 +40,7 @@ typedef struct
float *tangents;
char *colors;
unsigned int vboID;
vector_t *polyNormals;
} mdlframe_t;
typedef struct
@@ -67,6 +70,7 @@ typedef struct mesh_s
typedef struct tag_s
{
char name[64];
// matrix_t transform;
} tag_t;
typedef struct model_s
@@ -92,7 +96,9 @@ model_t *LoadModel(const char *filename, int ztag);
void UnloadModel(model_t *model);
void Optimize(model_t *model);
void GenerateVertexNormals(model_t *model);
void GeneratePolygonNormals(model_t *model, int ztag);
void CreateVBOTiny(mesh_t *mesh, tinyframe_t *frame);
void CreateVBO(mesh_t *mesh, mdlframe_t *frame);
void DeleteVBOs(model_t *model);
#endif
-3
View File
@@ -253,9 +253,6 @@ HMS_connect (const char *format, ...)
cc = curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)cv_masterserver_timeout.value);
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
cc = curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 30L);
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
cc = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
+70
View File
@@ -2391,6 +2391,76 @@ void HU_Drawer(void)
}
}
//======================================================================
// HUD MESSAGES CLEARING FROM SCREEN
//======================================================================
// Clear old messages from the borders around the view window
// (only for reduced view, refresh the borders when needed)
//
// startline: y coord to start clear,
// clearlines: how many lines to clear.
//
static INT32 oldclearlines;
void HU_Erase(void)
{
INT32 topline, bottomline;
INT32 y, yoffset;
#ifdef HWRENDER
// clear hud msgs on double buffer (OpenGL mode)
boolean secondframe;
static INT32 secondframelines;
#endif
if (con_clearlines == oldclearlines && !con_hudupdate && !chat_on)
return;
#ifdef HWRENDER
// clear the other frame in double-buffer modes
secondframe = (con_clearlines != oldclearlines);
if (secondframe)
secondframelines = oldclearlines;
#endif
// clear the message lines that go away, so use _oldclearlines_
bottomline = oldclearlines;
oldclearlines = con_clearlines;
if (chat_on && OLDCHAT)
if (bottomline < 8)
bottomline = 8; // only do it for consolechat. consolechat is gay.
if (automapactive || viewwindowx == 0) // hud msgs don't need to be cleared
return;
// software mode copies view border pattern & beveled edges from the backbuffer
if (rendermode == render_soft)
{
topline = 0;
for (y = topline, yoffset = y*vid.width; y < bottomline; y++, yoffset += vid.width)
{
if (y < viewwindowy || y >= viewwindowy + viewheight)
R_VideoErase(yoffset, vid.width); // erase entire line
else
{
R_VideoErase(yoffset, viewwindowx); // erase left border
// erase right border
R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx);
}
}
con_hudupdate = false; // if it was set..
}
#ifdef HWRENDER
else if (rendermode != render_none)
{
// refresh just what is needed from the view borders
HWR_DrawViewBorder(secondframelines);
con_hudupdate = secondframe;
}
#endif
}
//======================================================================
// IN-LEVEL MULTIPLAYER RANKINGS
//======================================================================
+1
View File
@@ -117,6 +117,7 @@ void HU_TickSongCredits(void);
void HU_DrawSongCredits(void);
void HU_Drawer(void);
char HU_dequeueChatChar(void);
void HU_Erase(void);
void HU_clearChatChars(void);
void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags); // Lat': Ping drawer for scoreboard.
//void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer);
+680
View File
@@ -0,0 +1,680 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2011-2018 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file i_addrinfo.c
/// \brief getaddr stubs, for lesser OSes
///
/// Some systems/SDKs, like PSL1GHT v2 does not have addrinfo functions
/// So a stub is needed
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#ifdef _WIN32
#ifdef USE_WINSOCK2
#include <ws2tcpip.h>
#else
#include <winsock.h>
#endif
#else
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#include "i_addrinfo.h"
/*
* This addrinfo stub have a testcases:
* To test the stub, use this command to compile the stub testcase:
* gcc -g -DTESTCASE -Dtest_stub -Wall -W i_addrinfo.c -o stub
* To test the real getaddrinfo API, use this command to get real one:
* gcc -g -DTESTCASE -Utest_stub -Wall -W i_addrinfo.c -o real
* For Win32,you need the WinSock library, version 1.1 or 2.2
* for 1.1, add -lwsock32
* i686-w64-mingw32-gcc -g -DTESTCASE -Dtest_stub -UUSE_WINSOCK2 -Wall -W i_addrinfo.c -o stub.exe -lwsock32
* for 2.2, add -DUSE_WINSOCK2 -lws2_32
* i686-w64-mingw32-gcc -g -DTESTCASE -Utest_stub -DUSE_WINSOCK2 -Wall -W i_addrinfo.c -o real.exe -lws2_32
*/
#ifndef I_getaddrinfo
#include <stdbool.h>
#ifdef _WIN32
// it seems windows doesn't define that... maybe some other OS? OS/2
static int inet_aton(const char *cp, struct in_addr *addr)
{
if( cp == NULL || addr == NULL )
{
return(0);
}
if (strcmp(cp, "255.255.255.225") == 0)
{
addr->s_addr = htonl(INADDR_BROADCAST);
return 0;
}
return (addr->s_addr = inet_addr(cp)) != htonl(INADDR_NONE);
}
#endif
#ifdef USE_WINSOCK2
static HMODULE ipv6dll = NULL;
typedef int (WSAAPI *p_getaddrinfo) (const char *, const char *,
const struct my_addrinfo *,
struct my_addrinfo **);
typedef void (WSAAPI *p_freeaddrinfo) (struct my_addrinfo *);
static p_getaddrinfo WS_getaddrinfo = NULL;
static p_freeaddrinfo WS_freeaddrinfo = NULL;
static HMODULE WS_getfunctions(HMODULE tmp)
{
if (tmp != NULL)
{
WS_getaddrinfo = (p_getaddrinfo)(LPVOID)GetProcAddress(tmp, "getaddrinfo");
if (WS_getaddrinfo == NULL)
return NULL;
WS_freeaddrinfo = (p_freeaddrinfo)(LPVOID)GetProcAddress(tmp, "freeaddrinfo");
if (WS_freeaddrinfo == NULL)
{
WS_getaddrinfo = NULL;
return NULL;
}
}
return tmp;
}
static void WS_addrinfosetup(void)
{
if (WS_getaddrinfo && WS_freeaddrinfo)
return; // already have the functions
// why not hold it into ipv6dll? becase we already link with ws2_32, silly!
if (WS_getfunctions(GetModuleHandleA("ws2_32.dll")) == NULL)
ipv6dll = WS_getfunctions(LoadLibraryA("wship6.dll"));
}
void WS_addrinfocleanup(void)
{
if (ipv6dll)
FreeLibrary(ipv6dll);
ipv6dll = NULL;
WS_getaddrinfo = NULL;
WS_freeaddrinfo = NULL;
}
#else
void WS_addrinfocleanup(void) {}
#endif
int I_getaddrinfo(const char *node, const char *service,
const struct my_addrinfo *hints,
struct my_addrinfo **res)
{
struct hostent *nodename = NULL;
bool hostlookup = true, passivemode = false;
int flags = 0;
int socktype = 0;
int sockport = 0;
struct my_addrinfo *ai;
struct sockaddr_in *addr;
struct in_addr ipv4;
size_t addrlen = 1;
size_t ailen = 1, i = 0, j;
size_t famsize = sizeof(struct sockaddr_in);
#ifdef USE_WINSOCK2
WS_addrinfosetup();
if (WS_getaddrinfo)
return WS_getaddrinfo(node, service, hints, res);
#endif
// param check
if (node == NULL && service == NULL)
return EAI_NONAME;
//note: testcase show NULL as res crashes libc
if (res == NULL)
return -1;
// check hints
if (hints)
{
// no support for IPv6
if (hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC)
return -1; //EAI_FAMILY
#ifdef AI_NUMERICHOST
// do not look up hostnames
if ((hints->ai_flags & AI_NUMERICHOST) == AI_NUMERICHOST)
{
hostlookup = false;
flags |= AI_NUMERICHOST;
}
#endif
#ifdef AI_PASSIVE
// return loopback or any address?
if ((hints->ai_flags & AI_PASSIVE) == AI_PASSIVE)
{
passivemode = true;
flags |= AI_PASSIVE;
}
#endif
// why no support for canon names? lazy
//AI_CANONNAME
// what kind of socket?
socktype = hints->ai_socktype;
}
else
{
#ifdef AI_V4MAPPED
flags |= AI_V4MAPPED;
#endif
#ifdef AI_ADDRCONFIG
flags |= AI_ADDRCONFIG;
#endif
}
// we need gethostbyname to convert numeric strings
if (node && hostlookup)
{
if (node == NULL)
return -1;
nodename = gethostbyname(node);
if (nodename == NULL)
{
if (inet_aton(node, &ipv4) != 0)
addrlen = 1;
else
return -1;
}
else while (nodename->h_addr_list[addrlen] != NULL)
addrlen++;
}
else if (node)
{
if (inet_aton(node, &ipv4) != 0)
addrlen = 1;
else if (!hostlookup)
return EAI_NONAME;
}
else
addrlen = 1;
if (service) //AI_NUMERICSERV
sockport = atoi(service);
if (socktype == 0)
ailen = addrlen*3;
else
ailen = addrlen;
ai = calloc(ailen, sizeof(struct my_addrinfo));
if (ai == NULL)
return -1;
else
*res = ai;
addr = calloc(ailen*2, famsize);
if (addr == NULL)
{
free(ai);
return -1;
}
else
ai->ai_addr = memset(addr, 0x00, ailen*ai->ai_addrlen);
for (i = 0; i < ailen; i++)
{
ai = *res+i;
ai->ai_flags = flags;
ai->ai_family = AF_INET;
ai->ai_socktype = socktype;
switch (ai->ai_socktype)
{
case SOCK_STREAM:
ai->ai_protocol = IPPROTO_TCP;
break;
case SOCK_DGRAM:
ai->ai_protocol = IPPROTO_UDP;
break;
default:
ai->ai_protocol = 0;
}
ai->ai_addrlen = famsize;
ai->ai_addr = (struct sockaddr *)&addr[i];
//ai_cannonname
ai->ai_next = ai+1;
}
ai->ai_next = NULL;
ai = *res;
for (i = 0, j = 0; i < ailen; i++, j++)
{
ai = *res+i;
addr[i].sin_port = htons((UINT16)sockport);
if (nodename)
{
memcpy(&addr[i].sin_addr, nodename->h_addr_list[j], ai->ai_addrlen);
addr[i].sin_family = nodename->h_addrtype;
}
else if (node)
{
memcpy(&addr[i].sin_addr, &ipv4, ai->ai_addrlen);
addr[i].sin_family = AF_INET;
}
else
{
if (passivemode)
addr[i].sin_addr.s_addr = htonl(INADDR_ANY);
else
addr[i].sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr[i].sin_family = AF_INET;
}
if (socktype == 0)
{
ai->ai_socktype = SOCK_STREAM;
ai->ai_protocol = IPPROTO_TCP;
memcpy(&addr[i+1], &addr[i], ai->ai_addrlen);
i++; ai++;
ai->ai_socktype = SOCK_DGRAM;
ai->ai_protocol = IPPROTO_UDP;
memcpy(&addr[i+1], &addr[i], ai->ai_addrlen);
i++; ai++;
ai->ai_socktype = SOCK_RAW;
ai->ai_protocol = IPPROTO_IP;
}
}
return 0;
}
#endif
#ifndef I_freeaddrinfo
void I_freeaddrinfo(struct my_addrinfo *res)
{
#ifdef USE_WINSOCK2
if (WS_freeaddrinfo)
{
WS_freeaddrinfo(res);
return;
}
#endif
if (!res)
return;
free(res->ai_addr);
free(res);
}
#endif
#ifdef TESTCASE
#include <stdio.h>
#ifdef USE_WINSOCK2
#define inet_ntop inet_ntopA
#define HAVE_NTOP
static const char* inet_ntopA(int af, const void *cp, char *buf, socklen_t len)
{
DWORD Dlen = len, AFlen = 0;
SOCKADDR_STORAGE any;
LPSOCKADDR anyp = (LPSOCKADDR)&any;
LPSOCKADDR_IN any4 = (LPSOCKADDR_IN)&any;
LPSOCKADDR_IN6 any6 = (LPSOCKADDR_IN6)&any;
if (!buf)
{
WSASetLastError(STATUS_INVALID_PARAMETER);
return NULL;
}
if (af != AF_INET && af != AF_INET6)
{
WSASetLastError(WSAEAFNOSUPPORT);
return NULL;
}
ZeroMemory(&any, sizeof(SOCKADDR_STORAGE));
any.ss_family = af;
switch (af)
{
case AF_INET:
{
CopyMemory(&any4->sin_addr, cp, sizeof(IN_ADDR));
AFlen = sizeof(SOCKADDR_IN);
break;
}
case AF_INET6:
{
CopyMemory(&any6->sin6_addr, cp, sizeof(IN6_ADDR));
AFlen = sizeof(SOCKADDR_IN6);
break;
}
}
if (WSAAddressToStringA(anyp, AFlen, NULL, buf, &Dlen) == SOCKET_ERROR)
return NULL;
return buf;
}
#elif defined (_WIN32)
// w32api, ws2tcpip.h, r1.12
static inline char* gai_strerror(int ecode)
{
static char message[1024+1];
DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS
| FORMAT_MESSAGE_MAX_WIDTH_MASK;
DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
FormatMessageA(dwFlags, NULL, ecode, dwLanguageId, message, 1024, NULL);
return message;
}
#else
#define HAVE_NTOP
#endif
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
static inline void printflags(int ai_flags)
{
printf("flags: %x(", ai_flags);
if (ai_flags == 0)
printf("NONE|");
#ifdef AI_PASSIVE
if ((ai_flags & AI_PASSIVE) == AI_PASSIVE)
printf("AI_PASSIVE|");
ai_flags &= ~AI_PASSIVE;
#endif
#ifdef AI_CANONNAME
if ((ai_flags & AI_CANONNAME) == AI_CANONNAME)
printf("AI_CANONNAME|");
ai_flags &= ~AI_CANONNAME;
#endif
#ifdef AI_NUMERICHOST
if ((ai_flags & AI_NUMERICHOST) == AI_NUMERICHOST)
printf("AI_NUMERICHOST|");
ai_flags &= ~AI_NUMERICHOST;
#endif
#ifdef AI_V4MAPPED
if ((ai_flags & AI_V4MAPPED) == AI_V4MAPPED)
printf("AI_V4MAPPED|");
ai_flags &= ~AI_V4MAPPED;
#endif
#ifdef AI_ALL
if ((ai_flags & AI_ALL) == AI_ALL)
printf("AI_ALL|");
ai_flags &= ~AI_ALL;
#endif
#ifdef AI_ADDRCONFIG
if ((ai_flags & AI_ADDRCONFIG) == AI_ADDRCONFIG)
printf("AI_ADDRCONFIG|");
ai_flags &= ~AI_ADDRCONFIG;
#endif
#ifdef AI_IDN
if ((ai_flags & AI_IDN) == AI_IDN)
printf("AI_IDN|");
ai_flags &= ~AI_IDN;
#endif
#ifdef AI_CANONIDN
if ((ai_flags & AI_CANONIDN) == AI_CANONIDN)
printf("AI_CANONIDN|");
ai_flags &= ~AI_CANONIDN;
#endif
#ifdef AI_IDN_ALLOW_UNASSIGNED
if ((ai_flags & AI_IDN_ALLOW_UNASSIGNED) == AI_IDN_ALLOW_UNASSIGNED)
printf("AI_IDN_ALLOW_UNASSIGNED|");
ai_flags &= ~AI_IDN_ALLOW_UNASSIGNED;
#endif
#ifdef AI_IDN_USE_STD3_ASCII_RULES
if ((ai_flags & AI_IDN_USE_STD3_ASCII_RULES) == AI_IDN_USE_STD3_ASCII_RULES)
printf("AI_IDN_USE_STD3_ASCII_RULES|");
ai_flags &= ~AI_PASSIVE;
#endif
#ifdef AI_NUMERICSERV
if ((ai_flags & AI_NUMERICSERV) == AI_NUMERICSERV)
printf("AI_NUMERICSERV|");
ai_flags &= ~AI_NUMERICSERV;
#endif
printf("%x", ai_flags);
printf(")\n");
}
static inline void printsocktype(int ai_socktype)
{
printf("socktype: %d(", ai_socktype);
switch (ai_socktype)
{
case 0:
printf("SOCK_ Woe32");
break;
case SOCK_STREAM:
printf("SOCK_STREAM");
break;
case SOCK_DGRAM:
printf("SOCK_DGRAM");
break;
case SOCK_RAW:
printf("SOCK_RAW");
break;
default:
printf("SOCK_ERROR\n");
exit(-1);
}
printf(")\n");
}
static inline void printprotocol(int ai_protocol)
{
printf("protocol: %d(", ai_protocol);
switch (ai_protocol)
{
case IPPROTO_IP:
printf("IPPROTO_IP");
break;
case IPPROTO_TCP:
printf("IPPROTO_TCP");
break;
case IPPROTO_UDP:
printf("IPPROTO_UDP");
break;
default:
printf("IPPROTO_ERROR\n");
exit(-1);
}
printf(")\n");
}
static inline void printaddr(int ai_family, const struct sockaddr *ai_addr)
{
char str[INET_ADDRSTRLEN+1] = "FAKE";
printf("family: %d(", ai_family);
switch (ai_family)
{
case AF_UNSPEC:
printf("AF_UNSPEC");
break;
case AF_INET:
printf("AF_INET");
break;
#ifdef AF_INET6
case AF_INET6:
printf("AF_INET6");
break;
#endif
default:
printf("AF_ERROR\n");
exit(-1);
}
printf(")\n");
if (ai_family == AF_INET && ai_addr)
{
const struct sockaddr_in *ip4 = (void *)ai_addr;
#ifdef HAVE_NTOP
inet_ntop(ai_family, &ip4->sin_addr, str, INET_ADDRSTRLEN);
#else
strncpy(str, inet_ntoa(ip4->sin_addr), INET_ADDRSTRLEN);
#endif
printf("port: %d\n", ntohs(ip4->sin_port));
}
printf("addr: %s\n", str);
}
void printaddrinfo(const struct my_addrinfo *data)
{
if(data == NULL)
{
printf("no data\n");
return;
}
else
printf("starting addrinfo dump\n");
while (data != NULL)
{
printflags(data->ai_flags);
printsocktype(data->ai_socktype);
printaddr(data->ai_family, data->ai_addr);
printprotocol(data->ai_protocol);
//addrlen
data = data->ai_next;
}
}
int main(int argc, char **argv)
{
struct my_addrinfo *res = NULL, hints;
int gaie;
(void)argc;
(void)argv;
memset(&hints, 0x00, sizeof(struct my_addrinfo));
hints.ai_family = AF_INET;
#ifdef _WIN32
{
#ifdef USE_WINSOCK2
const WORD VerNeed = MAKEWORD(2,2);
#else
const WORD VerNeed = MAKEWORD(1,1);
#endif
WSADATA WSAData;
WSAStartup(VerNeed, &WSAData);
}
#endif
printf("-----------------------------------------------------------\n");
#ifndef _WIN32 //NULL as res crashes Win32
gaie = I_getaddrinfo(NULL, NULL, &hints, NULL);
if (gaie != EAI_NONAME)
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
I_freeaddrinfo(res);
#endif
#if 0 //NULL as res crashes
gaie = I_getaddrinfo("localhost", "5029", NULL, NULL);
if (gaie == 0)
printf("NULL crashes: %s(%d)\n", gai_strerror(gaie), gaie);
I_freeaddrinfo(res);
#endif
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
//if (gaie != 0)
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
//if (gaie != 0)
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
//if (gaie != 0)
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
printf("-----------------------------------------------------------\n");
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
//if (gaie != 0)
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
//if (gaie != 0)
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
//if (gaie != 0)
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
printf("-----------------------------------------------------------\n");
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
//if (gaie != 0)
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
//if (gaie != 0)
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
//if (gaie != 0)
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
printf("-----------------------------------------------------------\n");
hints.ai_flags = AI_NUMERICHOST;
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
//if (gaie != 0)
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
//if (gaie != 0)
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
//if (gaie != 0)
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
printf("-----------------------------------------------------------\n");
gaie = I_getaddrinfo("127.0.0.1", NULL, &hints, &res);
//if (gaie != 0)
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo("127.0.0.1", "5029", &hints, &res);
//if (gaie != 0)
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
printf("-----------------------------------------------------------\n");
gaie = I_getaddrinfo("255.255.255.255", NULL, &hints, &res);
//if (gaie != 0)
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo("255.255.255.255", "5029", &hints, &res);
//if (gaie != 0)
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
printf("-----------------------------------------------------------\n");
hints.ai_flags = AI_PASSIVE;
gaie = I_getaddrinfo("0.0.0.0", NULL, &hints, &res);
//if (gaie != 0)
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
gaie = I_getaddrinfo("0.0.0.0", "5029", &hints, &res);
//if (gaie != 0)
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
printaddrinfo(res);
I_freeaddrinfo(res); res = NULL;
return 0;
}
#endif
+71
View File
@@ -0,0 +1,71 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2011-2018 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file i_addrinfo.h
/// \brief getaddrinfo stub
#ifndef __I_ADDRINFO__
#define __I_ADDRINFO__
#ifdef __GNUG__
#pragma interface
#endif
#ifndef AI_PASSIVE
#define AI_PASSIVE 0x01
#endif
#ifndef AI_NUMERICHOST
#define AI_NUMERICHOST 0x04
#endif
#ifndef AI_V4MAPPED
#define AI_V4MAPPED 0x08
#endif
#ifndef AI_ADDRCONFIG
#define AI_ADDRCONFIG 0x20
#endif
#ifdef _WIN32
#ifndef EAI_NONAME
#define EAI_NONAME WSAHOST_NOT_FOUND
#endif
#endif
#ifndef EAI_NONAME
#define EAI_NONAME -2
#endif
#ifdef _WIN32 // already use the stub for Win32
// w32api, ws2tcpip.h, r1.12
struct my_addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
size_t ai_addrlen;
char *ai_canonname;
struct sockaddr *ai_addr;
struct my_addrinfo *ai_next;
};
#else
#define my_addrinfo addrinfo
#endif
void WS_addrinfocleanup(void);
#ifndef my_addrinfo
void I_freeaddrinfo(struct my_addrinfo *res);
int I_getaddrinfo(const char *node, const char *service,
const struct my_addrinfo *hints,
struct my_addrinfo **res);
#elif !defined (test_stub)
#define I_getaddrinfo getaddrinfo
#define I_freeaddrinfo freeaddrinfo
#endif
#endif
+87 -44
View File
@@ -29,36 +29,42 @@
#ifdef _WIN32
#define USE_WINSOCK
#if defined (_WIN64) || defined (HAVE_IPV6)
#define USE_WINSOCK2
#else //_WIN64/HAVE_IPV6
#define USE_WINSOCK1
#endif
#endif //WIN32 OS
#ifdef USE_WINSOCK
#ifdef USE_WINSOCK2
#include <ws2tcpip.h>
#define addrinfo_t ADDRINFOA
#else
#define addrinfo_t struct addrinfo
#endif
#include "doomdef.h"
#ifndef USE_WINSOCK
#include <arpa/inet.h>
#ifdef __APPLE_CC__
#ifndef _BSD_SOCKLEN_T_
#define _BSD_SOCKLEN_T_
#endif //_BSD_SOCKLEN_T_
#endif //__APPLE_CC__
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/ioctl.h>
#endif //normal BSD API
#include <errno.h>
#include <time.h>
#ifdef USE_WINSOCK1
#include <winsock.h>
#else
#ifndef USE_WINSOCK
#include <arpa/inet.h>
#ifdef __APPLE_CC__
#ifndef _BSD_SOCKLEN_T_
#define _BSD_SOCKLEN_T_
#endif //_BSD_SOCKLEN_T_
#endif //__APPLE_CC__
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/ioctl.h>
#endif //normal BSD API
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
#include <sys/time.h>
#endif // UNIXCOMMON
#include <errno.h>
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
#include <sys/time.h>
#endif // UNIXCOMMON
#endif
#ifdef USE_WINSOCK
// some undefined under win32
@@ -146,6 +152,7 @@ static UINT8 UPNP_support = TRUE;
#define close closesocket
#endif
#include "i_addrinfo.h"
#define DEFAULTPORT "5029"
#if defined (USE_WINSOCK)
@@ -162,6 +169,10 @@ typedef unsigned long SOCKET_TYPE;
#define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12"
#ifdef USE_WINSOCK1
typedef int socklen_t;
#endif
typedef struct
{
mysockaddr_t address;
@@ -221,8 +232,9 @@ static char *get_WSAErrorStr(int e)
#define strerror get_WSAErrorStr
#endif
#ifdef USE_WINSOCK
#ifdef USE_WINSOCK2
#define inet_ntop inet_ntopA
#define HAVE_NTOP
static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len)
{
DWORD Dlen = len, AFlen = 0;
@@ -266,6 +278,8 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len
return NULL;
return buf;
}
#elif !defined (USE_WINSOCK1)
#define HAVE_NTOP
#endif
#ifdef HAVE_MINIUPNPC // based on old XChat patch
@@ -346,6 +360,7 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
static char s[64]; // 255.255.255.255:65535 or
// [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:65535
#ifdef HAVE_NTOP
#ifdef HAVE_IPV6
int v6 = (sk->any.sa_family == AF_INET6);
#else
@@ -383,7 +398,15 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
#endif
else if(sk->any.sa_family == AF_INET && sk->ip4.sin_port != 0)
strcat(s, va(":%d", ntohs(sk->ip4.sin_port)));
#else
if (sk->any.sa_family == AF_INET)
{
strcpy(s, inet_ntoa(sk->ip4.sin_addr));
if (sk->ip4.sin_port != 0) strcat(s, va(":%d", ntohs(sk->ip4.sin_port)));
}
else
sprintf(s, "Unknown type");
#endif
return s;
}
@@ -845,11 +868,15 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
#ifdef USE_WINSOCK
{ // Alam_GBC: disable the new UDP connection reset behavior for Win2k and up
#ifdef USE_WINSOCK2
DWORD dwBytesReturned = 0;
BOOL bfalse = FALSE;
rc = WSAIoctl(s, SIO_UDP_CONNRESET, &bfalse, sizeof(bfalse),
NULL, 0, &dwBytesReturned, NULL, NULL);
#else
unsigned long falseval = false;
rc = ioctl(s, SIO_UDP_CONNRESET, &falseval);
#endif
if (rc == -1)
{
e = errno;
@@ -1019,7 +1046,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
static boolean UDP_Socket(void)
{
size_t s;
addrinfo_t *ai, *runp, hints;
struct my_addrinfo *ai, *runp, hints;
int gaie;
#ifdef HAVE_IPV6
const INT32 b_ipv6 = M_CheckParm("-ipv6");
@@ -1048,7 +1075,7 @@ static boolean UDP_Socket(void)
{
while (M_IsNextParm())
{
gaie = getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
if (gaie == 0)
{
runp = ai;
@@ -1062,13 +1089,13 @@ static boolean UDP_Socket(void)
}
runp = runp->ai_next;
}
freeaddrinfo(ai);
I_freeaddrinfo(ai);
}
}
}
else
{
gaie = getaddrinfo("0.0.0.0", serv, &hints, &ai);
gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai);
if (gaie == 0)
{
runp = ai;
@@ -1089,7 +1116,7 @@ static boolean UDP_Socket(void)
}
runp = runp->ai_next;
}
freeaddrinfo(ai);
I_freeaddrinfo(ai);
}
}
@@ -1101,7 +1128,7 @@ static boolean UDP_Socket(void)
{
while (M_IsNextParm())
{
gaie = getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
if (gaie == 0)
{
runp = ai;
@@ -1115,13 +1142,13 @@ static boolean UDP_Socket(void)
}
runp = runp->ai_next;
}
freeaddrinfo(ai);
I_freeaddrinfo(ai);
}
}
}
else
{
gaie = getaddrinfo("::", serv, &hints, &ai);
gaie = I_getaddrinfo("::", serv, &hints, &ai);
if (gaie == 0)
{
runp = ai;
@@ -1135,7 +1162,7 @@ static boolean UDP_Socket(void)
}
runp = runp->ai_next;
}
freeaddrinfo(ai);
I_freeaddrinfo(ai);
}
}
}
@@ -1189,7 +1216,11 @@ boolean I_InitTcpDriver(void)
if (!init_tcp_driver)
{
#ifdef USE_WINSOCK
#ifdef USE_WINSOCK2
const WORD VerNeed = MAKEWORD(2,2);
#else
const WORD VerNeed = MAKEWORD(1,1);
#endif
WSADATA WSAData;
const int WSAresult = WSAStartup(VerNeed, &WSAData);
if (WSAresult != 0)
@@ -1216,14 +1247,21 @@ boolean I_InitTcpDriver(void)
if (WSAresult != WSAVERNOTSUPPORTED)
CONS_Debug(DBG_NETPLAY, "WinSock(TCP/IP) error: %s\n",WSError);
}
if (LOBYTE(WSAData.wVersion) != 2 ||
#ifdef USE_WINSOCK2
if(LOBYTE(WSAData.wVersion) != 2 ||
HIBYTE(WSAData.wVersion) != 2)
{
WSACleanup();
CONS_Debug(DBG_NETPLAY, "No WinSock(TCP/IP) 2.2 driver detected\n");
}
#else
if (LOBYTE(WSAData.wVersion) != 1 ||
HIBYTE(WSAData.wVersion) != 1)
{
WSACleanup();
CONS_Debug(DBG_NETPLAY, "No WinSock(TCP/IP) 1.1 driver detected\n");
}
#endif
CONS_Debug(DBG_NETPLAY, "WinSock description: %s\n",WSAData.szDescription);
CONS_Debug(DBG_NETPLAY, "WinSock System Status: %s\n",WSAData.szSystemStatus);
#endif
@@ -1263,6 +1301,7 @@ void I_ShutdownTcpDriver(void)
CONS_Printf("I_ShutdownTcpDriver: ");
#ifdef USE_WINSOCK
WS_addrinfocleanup();
WSACleanup();
#endif
CONS_Printf("shut down\n");
@@ -1271,24 +1310,24 @@ void I_ShutdownTcpDriver(void)
static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const char *port, boolean test)
{
addrinfo_t *ai = NULL, *runp, hints;
struct my_addrinfo *ai = NULL, *runp, hints;
int gaie;
size_t i;
if (!port || !port[0])
port = DEFAULTPORT;
memset(&hints, 0x00, sizeof (hints));
memset (&hints, 0x00, sizeof (hints));
hints.ai_flags = AI_ADDRCONFIG;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
gaie = getaddrinfo(address, port, &hints, &ai);
gaie = I_getaddrinfo(address, port, &hints, &ai);
if (gaie != 0)
{
freeaddrinfo(ai);
I_freeaddrinfo(ai);
return false;
}
@@ -1317,7 +1356,7 @@ static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const
if (runp != NULL)
memcpy(sin, runp->ai_addr, runp->ai_addrlen);
freeaddrinfo(ai);
I_freeaddrinfo(ai);
return (runp != NULL);
}
@@ -1515,7 +1554,7 @@ static boolean SOCK_SetUnbanTime(time_t timestamp)
static boolean SOCK_SetBanAddress(const char *address, const char *mask)
{
addrinfo_t *ai, *runp, hints;
struct my_addrinfo *ai, *runp, hints;
int gaie;
if (!address)
@@ -1527,7 +1566,7 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask)
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
gaie = getaddrinfo(address, "0", &hints, &ai);
gaie = I_getaddrinfo(address, "0", &hints, &ai);
if (gaie != 0)
return false;
@@ -1572,7 +1611,7 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask)
runp = runp->ai_next;
}
freeaddrinfo(ai);
I_freeaddrinfo(ai);
return true;
}
@@ -1621,6 +1660,8 @@ boolean I_InitTcpNetwork(void)
// FIXME: for dedicated server, numnodes needs to be set to 0 upon start
if (dedicated)
doomcom->numnodes = 0;
/* else if (M_IsNextParm())
doomcom->numnodes = (INT16)atoi(M_GetNextParm());*/
else
doomcom->numnodes = 1;
@@ -1705,3 +1746,5 @@ boolean I_InitTcpNetwork(void)
return ret;
}
#include "i_addrinfo.c"
+1 -1
View File
@@ -94,8 +94,8 @@ INT32 VID_SetMode(INT32 modenum);
\return name of video mode
*/
const char *VID_GetModeName(INT32 modenum);
void VID_PrepareModeList(void); /// note hack for SDL
void VID_PrepareModeList(void);
/** \brief can video system do fullscreen
*/
+1 -1
View File
@@ -4333,7 +4333,7 @@ static void K_drawInput(void)
target = 0;
else // turning of multiple strengths!
{
target = ((abs(cmd->driftturn) - 1)/200)+1; // was 125, do we need another toggle for this? Zzz...
target = ((abs(cmd->driftturn) - 1)/125)+1;
if (target > 4)
target = 4;
if (cmd->driftturn < 0)
+7 -21
View File
@@ -377,9 +377,7 @@ static int lib_pSpawnMobj(lua_State *L)
NOHUD
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
mobj_t *th = P_SpawnMobj(x, y, z, type);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
LUA_PushUserdata(L, P_SpawnMobj(x, y, z, type), META_MOBJ);
return 1;
}
@@ -405,9 +403,7 @@ static int lib_pSpawnMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
mobj_t *th = P_SpawnMissile(source, dest, type);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
LUA_PushUserdata(L, P_SpawnMissile(source, dest, type), META_MOBJ);
return 1;
}
@@ -424,9 +420,7 @@ static int lib_pSpawnXYZMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
mobj_t *th = P_SpawnXYZMissile(source, dest, type, x, y, z);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
LUA_PushUserdata(L, P_SpawnXYZMissile(source, dest, type, x, y, z), META_MOBJ);
return 1;
}
@@ -445,9 +439,7 @@ static int lib_pSpawnPointMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
mobj_t *th = P_SpawnPointMissile(source, xa, ya, za, type, x, y, z);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
LUA_PushUserdata(L, P_SpawnPointMissile(source, xa, ya, za, type, x, y, z), META_MOBJ);
return 1;
}
@@ -464,9 +456,7 @@ static int lib_pSpawnAlteredDirectionMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
mobj_t *th = P_SpawnAlteredDirectionMissile(source, type, x, y, z, shiftingAngle);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
LUA_PushUserdata(L, P_SpawnAlteredDirectionMissile(source, type, x, y, z, shiftingAngle), META_MOBJ);
return 1;
}
@@ -495,9 +485,7 @@ static int lib_pSPMAngle(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
mobj_t *th = P_SPMAngle(source, type, angle, allowaim, flags2);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
LUA_PushUserdata(L, P_SPMAngle(source, type, angle, allowaim, flags2), META_MOBJ);
return 1;
}
@@ -511,9 +499,7 @@ static int lib_pSpawnPlayerMissile(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t");
if (type >= NUMMOBJTYPES)
return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);
mobj_t *th = P_SpawnPlayerMissile(source, type, flags2);
th->islocal = !hook_important;
LUA_PushUserdata(L, th, META_MOBJ);
LUA_PushUserdata(L, P_SpawnPlayerMissile(source, type, flags2), META_MOBJ);
return 1;
}
-1
View File
@@ -109,7 +109,6 @@ ENUM (STRING_HOOK);
extern boolean hook_cmd_running; // This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd.
extern int hook_defrosting;
extern bool hook_important;
void LUA_HookVoid(int hook);
void LUA_HookHUD(int hook, huddrawlist_h drawlist);
+4 -26
View File
@@ -19,7 +19,6 @@
#include "b_bot.h"
#include "z_zone.h"
#include "m_perfstats.h"
#include "w_wad.h"
#include "lua_script.h"
#include "lua_libs.h"
@@ -40,20 +39,14 @@ LIST (stringHookNames, STRING_HOOK_LIST);
#undef LIST
typedef struct {
int id;
bool important;
} hookinfo_t;
typedef struct {
int numHooks;
hookinfo_t *ids;
int *ids;
} hook_t;
typedef struct {
int numGeneric;
int ref;
bool important;
} stringhook_t;
static hook_t hookIds[HOOK(MAX)];
@@ -63,8 +56,6 @@ static hook_t mobjHookIds[NUMMOBJTYPES][MOBJ_HOOK(MAX)];
// Lua tables are used to lookup string hook ids.
static stringhook_t stringHooks[STRING_HOOK(MAX)];
bool hook_important = true;
// This will be indexed by hook id, the value of which fetches the registry.
static int * hookRefs;
static int nextid;
@@ -118,11 +109,7 @@ static void get_table(lua_State *L)
FUNCINLINE static ATTRINLINE void add_hook_to_table(lua_State *L, int n)
{
lua_newtable(L);
lua_pushnumber(L, nextid);
lua_rawseti(L, -2, 1);
lua_pushboolean(L, wadfiles[numwadfiles-1]->important);
lua_rawseti(L, -2, 2);
lua_rawseti(L, -2, n);
}
@@ -193,8 +180,7 @@ FUNCINLINE static ATTRINLINE void add_hook(hook_t *map)
{
Z_Realloc(map->ids, (map->numHooks + 1) * sizeof *map->ids,
PU_STATIC, &map->ids);
map->ids[map->numHooks].important = wadfiles[numwadfiles-1]->important;
map->ids[map->numHooks++].id = nextid;
map->ids[map->numHooks++] = nextid;
}
FUNCINLINE static ATTRINLINE void add_mobj_hook(lua_State *L, int hook_type)
@@ -301,7 +287,6 @@ struct Hook_State {
const char * string;/* used to fetch table, ran first if set */
int top;/* index of last argument passed to hook */
int id;/* id to fetch ref */
boolean important;/* is this hook from local addon */
int values;/* num arguments passed to hook */
int results;/* num values returned by hook */
Hook_Callback results_handler;/* callback when hook successfully returns */
@@ -431,29 +416,22 @@ FUNCINLINE static ATTRINLINE void init_hook_call
hook->results_handler = results_handler;
}
FUNCINLINE static ATTRINLINE void get_hook(Hook_State *hook, const hookinfo_t *ids, int n)
FUNCINLINE static ATTRINLINE void get_hook(Hook_State *hook, const int *ids, int n)
{
hook->id = ids[n].id;
hook->important = ids[n].important;
hook->id = ids[n];
lua_getref(gL, hookRefs[hook->id]);
}
FUNCINLINE static ATTRINLINE void get_hook_from_table(Hook_State *hook, int n)
{
lua_rawgeti(gL, -1, n);
lua_rawgeti(gL, -1, 1);
hook->id = lua_tonumber(gL, -1);
lua_pop(gL, 1);
lua_rawgeti(gL, -2, 2);
hook->important = lua_toboolean(gL, -1);
lua_pop(gL, 2);
lua_getref(gL, hookRefs[hook->id]);
}
static int call_single_hook_no_copy(Hook_State *hook)
{
hook_important = hook->important;
if (lua_pcall(gL, hook->values, hook->results, EINDEX) == 0)
{
if (hook->results > 0)
+15 -59
View File
@@ -797,12 +797,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
mobj_t *mobj = *((mobj_t **)lua_touserdata(gL, myindex));
if (!mobj)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_MOBJ);
WRITEUINT32(*p, mobj->mobjnum);
}
@@ -812,12 +808,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
player_t *player = *((player_t **)lua_touserdata(gL, myindex));
if (!player)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_PLAYER);
WRITEUINT8(*p, player - players);
}
@@ -827,12 +819,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
mapthing_t *mapthing = *((mapthing_t **)lua_touserdata(gL, myindex));
if (!mapthing)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_MAPTHING);
WRITEUINT16(*p, mapthing - mapthings);
}
@@ -842,12 +830,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
vertex_t *vertex = *((vertex_t **)lua_touserdata(gL, myindex));
if (!vertex)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_VERTEX);
WRITEUINT16(*p, vertex - vertexes);
}
@@ -857,12 +841,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
line_t *line = *((line_t **)lua_touserdata(gL, myindex));
if (!line)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_LINE);
WRITEUINT16(*p, line - lines);
}
@@ -872,12 +852,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
side_t *side = *((side_t **)lua_touserdata(gL, myindex));
if (!side)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_SIDE);
WRITEUINT16(*p, side - sides);
}
@@ -887,12 +863,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
subsector_t *subsector = *((subsector_t **)lua_touserdata(gL, myindex));
if (!subsector)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_SUBSECTOR);
WRITEUINT16(*p, subsector - subsectors);
}
@@ -902,12 +874,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
sector_t *sector = *((sector_t **)lua_touserdata(gL, myindex));
if (!sector)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_SECTOR);
WRITEUINT16(*p, sector - sectors);
}
@@ -917,12 +885,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex));
if (!slope)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_SLOPE);
WRITEUINT16(*p, slope->id);
}
@@ -932,12 +896,8 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
{
mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex));
if (!header)
{
WRITEUINT8(*p, ARCH_NULL);
return 3;
}
else
{
else {
WRITEUINT8(*p, ARCH_MAPHEADER);
WRITEUINT16(*p, header - *mapheaderinfo);
}
@@ -1043,23 +1003,19 @@ static void ArchiveTables(UINT8 **p)
e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this.
if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
{
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i);
}
else if (e == 3) // nil key due to invalid userdata. NOT an error.
{
lua_pushvalue(gL, -2);
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -1), luaL_typename(gL, -1), i);
lua_pop(gL, 1);
continue;
}
// Write value
e = ArchiveValue(p, TABLESINDEX, -1);
if (e == 1)
{
n++; // the table contained a new table we'll have to archive. :(
}
else if (e == 2) // invalid value type
{
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1));
lua_pushvalue(gL, -2);
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -1), luaL_typename(gL, -1));
lua_pop(gL, 1);
}
lua_pop(gL, 1);
+2 -2
View File
@@ -92,7 +92,7 @@ void M_LoadEmotes(UINT16 wadnum)
if (emote_name.size() > MAXEMOTENAME)
{
CONS_Alert(CONS_WARNING, "EMOTES: Emote name is too long, truncating. (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
emote_name.resize(MAXEMOTENAME);
emote_name = emote_name.substr(0, MAXEMOTENAME);
}
emote = &emotes[emote_name];
@@ -139,7 +139,7 @@ void M_LoadEmotes(UINT16 wadnum)
if (framelumpname.size() > 8)
{
CONS_Alert(CONS_WARNING, "EMOTES: Frame %d name is too long. (file %s, line %d)", numframes, wadfiles[wadnum]->filename, linenum);
framelumpname.resize(8);
framelumpname = framelumpname.substr(0, 8);
}
std::strncpy(emote->frames[numframes], framelumpname.c_str(), framelumpname.size()+1);
+16 -19
View File
@@ -702,13 +702,7 @@ static void M_CheckStringItem(void)
// Just in case
memset(menu_text_input_buf, 0, sizeof menu_text_input_buf);
// special case: name input, cap it to prevent writing outside the textbox
// kinda ugly but itll work
if (cv == &cv_playername)
M_TextInputInit(&menuinput, menu_text_input_buf, MAXPLAYERNAME +1);
else
M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf);
M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf);
M_TextInputSetString(&menuinput, cv->string);
}
@@ -3113,7 +3107,7 @@ static void M_AddonsInternal(void)
break;
}
strlcpy(menupath, pathname, MAXFILEPATH);
strlcpy(menupath, pathname, 1024);
menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath) + 1;
if (menupath[menupathindex[menudepthleft]-2] != PATHSEP[0])
@@ -3226,9 +3220,9 @@ static void M_DrawTemperature(INT32 x, fixed_t t)
static char *M_AddonsHeaderPath(void)
{
UINT32 len;
static char header[MAXFILEPATH];
static char header[1024];
strlcpy(header, va("%s folder%s", cv_addons_option.string, menupath+menupathindex[menudepth-1]-1), MAXFILEPATH);
strlcpy(header, va("%s folder%s", cv_addons_option.string, menupath+menupathindex[menudepth-1]-1), 1024);
len = strlen(header);
if (len > 34)
{
@@ -3964,7 +3958,9 @@ static void PrepReplayList(boolean reset)
Lock_search_state();
Z_Free(demolist_all);
if (demolist_all)
Z_Free(demolist_all);
demolist_all = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL);
for (i = 0; i < sizedirmenu; i++)
@@ -3982,9 +3978,9 @@ static void PrepReplayList(boolean reset)
else
{
demolist_all[i].type = MD_NOTLOADED;
snprintf(demolist_all[i].filepath, sizeof(demolist_all[i].filepath),
// 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN).
"%s%.255s", menupath, dirmenu[i] + DIR_STRING);
// FIXME - do something with buffer sizes. menupath is 1024 chars but filepath is only
// 256. I'm not really sure what to do here but don't want to leave warnings...
snprintf(demolist_all[i].filepath, 255, "%.254s%s", menupath, dirmenu[i] + DIR_STRING);
sprintf(demolist_all[i].title, ".....");
}
}
@@ -4339,7 +4335,7 @@ static void DrawReplayHutReplayInfo(void)
static void M_DrawReplayHut(void)
{
INT32 x, y, cursory = 0;
INT32 i;
INT16 i;
INT16 replaylistitem = currentMenu->numitems-2;
boolean processed_one_this_frame = false;
const INT32 scaledviewheight = (vid.height/vid.dup);
@@ -4412,7 +4408,7 @@ static void M_DrawReplayHut(void)
V_DrawCenteredString(160, 100, V_ALLOWLOWERCASE, msg);
}
for (i = 0; i < (INT32)replayqueryfound; i++)
for (i = 0; i < (INT16)replayqueryfound; i++)
{
INT32 localy = y+i*10;
INT32 localx = x;
@@ -9446,8 +9442,9 @@ static void M_VideoModeMenu(INT32 choice)
memset(modedescs, 0, sizeof(modedescs));
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
VID_PrepareModeList(); // FIXME: hack
#endif
vidm_nummodes = 0;
vidm_selected = 0;
nummodes = VID_NumModes();
@@ -10338,9 +10335,9 @@ static const char *M_GetDiscordName(discordRequest_t *r)
return "";
if (cv_discordstreamer.value)
return DRPC_HideUsername(r->username);
return r->username;
return r->username;
return va("%s#%s", r->username, r->discriminator);
}
// (this goes in k_hud.c when merged into v2)
+5 -23
View File
@@ -645,20 +645,10 @@ static menuitem_t OP_ControlsMenu[] =
{IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30},
{IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40},
{IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 55},
{IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60},
{IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 75},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P1)", &cv_turnsmooth[0], 85},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P2)", &cv_turnsmooth[1], 95},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P3)", &cv_turnsmooth[2], 105},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P4)", &cv_turnsmooth[3], 115},
// i hate our menus sincerly
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P1)", &cv_litesteer[0], 135},
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P2)", &cv_litesteer[1], 145},
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P3)", &cv_litesteer[2], 155},
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P4)", &cv_litesteer[3], 165},
{IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90},
};
static const char* OP_ControlsTooltips[] =
@@ -669,15 +659,7 @@ static const char* OP_ControlsTooltips[] =
"Setup player 4 controls.",
"Options for mouse control.",
"Allowed amount of controls per key.",
"Turn smoothing for non-analog turning (Player 1).",
"Turn smoothing for non-analog turning (Player 2).",
"Turn smoothing for non-analog turning (Player 3).",
"Turn smoothing for non-analog turning (Player 4).",
"Hold DOWN on d-pad/keyboard for shallow turns (Player 1).",
"Hold DOWN on d-pad/keyboard for shallow turns (Player 2).",
"Hold DOWN on d-pad/keyboard for shallow turns (Player 3).",
"Hold DOWN on d-pad/keyboard for shallow turns (Player 4).",
"Turn smoothing for non-analog turning.",
};
static menuitem_t OP_AllControlsMenu[] =
@@ -2442,7 +2424,7 @@ menu_t OP_MainDef =
NULL
};
menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 40, 15, OP_ControlsTooltips);
menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30, OP_ControlsTooltips);
//WTF
menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips);
menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef);
+2 -2
View File
@@ -239,8 +239,8 @@ void M_TextInputClear(textinput_t *input)
void M_TextInputSetString(textinput_t *input, const char *c)
{
memset(input->buffer, 0, input->buffer_size);
strncpy(input->buffer, c, input->buffer_size);
input->cursor = input->select = input->length = strlen(input->buffer);
strcpy(input->buffer, c);
input->cursor = input->select = input->length = strlen(c);
}
static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emotes)
+1 -1
View File
@@ -11889,7 +11889,7 @@ void P_SpawnHoops(mapthing_t *mthing)
z += P_GetSectorFloorZAt(sec, x, y);
hoopcenter->z = z - hoopcenter->height/2;
hoopcenter->z -= hoopcenter->height/2;
P_UnsetThingPosition(hoopcenter);
hoopcenter->x = x;
+36 -36
View File
@@ -61,7 +61,7 @@ typedef enum
//
// P_ArchivePlayer
//
FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save)
static inline void P_ArchivePlayer(savebuffer_t *save)
{
const player_t *player = &players[consoleplayer];
INT32 pllives = player->lives;
@@ -85,7 +85,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save)
//
// P_UnArchivePlayer
//
FUNCINLINE static ATTRINLINE void P_UnArchivePlayer(savebuffer_t *save)
static inline void P_UnArchivePlayer(savebuffer_t *save)
{
savedata.skincolor = READUINT8(save->p);
savedata.skin = READUINT8(save->p);
@@ -1043,25 +1043,25 @@ typedef enum
tc_end
} specials_e;
FUNCINLINE static ATTRINLINE UINT32 SaveMobjnum(const mobj_t *mobj)
static inline UINT32 SaveMobjnum(const mobj_t *mobj)
{
if (mobj) return mobj->mobjnum;
return 0;
}
FUNCINLINE static ATTRINLINE UINT32 SaveSector(const sector_t *sector)
static inline UINT32 SaveSector(const sector_t *sector)
{
if (sector) return (UINT32)(sector - sectors);
return 0xFFFFFFFF;
}
FUNCINLINE static ATTRINLINE UINT32 SaveLine(const line_t *line)
static inline UINT32 SaveLine(const line_t *line)
{
if (line) return (UINT32)(line - lines);
return 0xFFFFFFFF;
}
FUNCINLINE static ATTRINLINE UINT32 SavePlayer(const player_t *player)
static inline UINT32 SavePlayer(const player_t *player)
{
if (player) return (UINT32)(player - players);
return 0xFFFFFFFF;
@@ -1476,7 +1476,7 @@ static void SaveElevatorThinker(savebuffer_t *save, const thinker_t *th, const U
//
// Saves a scroll_t thinker
//
FUNCINLINE static ATTRINLINE void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
static inline void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
{
const scroll_t *ht = (const void *)th;
WRITEUINT8(save->p, type);
@@ -1497,7 +1497,7 @@ FUNCINLINE static ATTRINLINE void SaveScrollThinker(savebuffer_t *save, const th
//
// Saves a friction_t thinker
//
FUNCINLINE static ATTRINLINE void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
static inline void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
{
const friction_t *ht = (const void *)th;
WRITEUINT8(save->p, type);
@@ -1513,7 +1513,7 @@ FUNCINLINE static ATTRINLINE void SaveFrictionThinker(savebuffer_t *save, const
//
// Saves a pusher_t thinker
//
FUNCINLINE static ATTRINLINE void SavePusherThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
static inline void SavePusherThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
{
const pusher_t *ht = (const void *)th;
WRITEUINT8(save->p, type);
@@ -1598,7 +1598,7 @@ static void SaveDisappearThinker(savebuffer_t *save, const thinker_t *th, const
//
// Saves a polyrotate_t thinker
//
FUNCINLINE static ATTRINLINE void SavePolyrotatetThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
static inline void SavePolyrotatetThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
{
const polyrotate_t *ht = (const void *)th;
WRITEUINT8(save->p, type);
@@ -1935,25 +1935,25 @@ mobj_t *P_FindNewPosition(UINT32 oldposition)
return NULL;
}
FUNCINLINE static ATTRINLINE mobj_t *LoadMobj(UINT32 mobjnum)
static inline mobj_t *LoadMobj(UINT32 mobjnum)
{
if (mobjnum == 0) return NULL;
return (mobj_t *)(size_t)mobjnum;
}
FUNCINLINE static ATTRINLINE sector_t *LoadSector(UINT32 sector)
static inline sector_t *LoadSector(UINT32 sector)
{
if (sector >= numsectors) return NULL;
return &sectors[sector];
}
FUNCINLINE static ATTRINLINE line_t *LoadLine(UINT32 line)
static inline line_t *LoadLine(UINT32 line)
{
if (line >= numlines) return NULL;
return &lines[line];
}
FUNCINLINE static ATTRINLINE player_t *LoadPlayer(UINT32 player)
static inline player_t *LoadPlayer(UINT32 player)
{
if (player >= MAXPLAYERS) return NULL;
return &players[player];
@@ -2529,7 +2529,7 @@ static void LoadScrollThinker(savebuffer_t *save, actionf_p1 thinker)
//
// Loads a friction_t from a save game
//
FUNCINLINE static ATTRINLINE void LoadFrictionThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadFrictionThinker(savebuffer_t *save, actionf_p1 thinker)
{
friction_t *ht = (friction_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -2576,7 +2576,7 @@ static void LoadPusherThinker(savebuffer_t *save, actionf_p1 thinker)
//
// Loads a laserthink_t from a save game
//
FUNCINLINE static ATTRINLINE void LoadLaserThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadLaserThinker(savebuffer_t *save, actionf_p1 thinker)
{
laserthink_t *ht = (laserthink_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -2621,7 +2621,7 @@ FUNCINLINE static ATTRINLINE void LoadLightlevelThinker(savebuffer_t *save, acti
//
// Loads a executor_t from a save game
//
FUNCINLINE static ATTRINLINE void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker)
{
executor_t *ht = (executor_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -2639,7 +2639,7 @@ FUNCINLINE static ATTRINLINE void LoadExecutorThinker(savebuffer_t *save, action
//
// Loads a disappear_t thinker
//
FUNCINLINE static ATTRINLINE void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker)
{
disappear_t *ht = (disappear_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -2660,7 +2660,7 @@ FUNCINLINE static ATTRINLINE void LoadDisappearThinker(savebuffer_t *save, actio
//
// Loads a polyrotate_t thinker
//
FUNCINLINE static ATTRINLINE void LoadPolyrotatetThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadPolyrotatetThinker(savebuffer_t *save, actionf_p1 thinker)
{
polyrotate_t *ht = (polyrotate_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -2720,7 +2720,7 @@ static void LoadPolymoveThinker(savebuffer_t *save, actionf_p1 thinker)
//
// Loads a polywaypoint_t thinker
//
FUNCINLINE static ATTRINLINE void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinker)
{
polywaypoint_t *ht = (polywaypoint_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -2776,7 +2776,7 @@ FUNCINLINE static ATTRINLINE void LoadPolywaypointThinker(savebuffer_t *save, ac
//
// loads a polyslidedoor_t thinker
//
FUNCINLINE static ATTRINLINE void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 thinker)
{
polyslidedoor_t *ht = (polyslidedoor_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -2814,7 +2814,7 @@ FUNCINLINE static ATTRINLINE void LoadPolyslidedoorThinker(savebuffer_t *save, a
//
// Loads a polyswingdoor_t thinker
//
FUNCINLINE static ATTRINLINE void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 thinker)
{
polyswingdoor_t *ht = (polyswingdoor_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -2847,7 +2847,7 @@ FUNCINLINE static ATTRINLINE void LoadPolyswingdoorThinker(savebuffer_t *save, a
//
// Loads a polydisplace_t thinker
//
FUNCINLINE static ATTRINLINE void LoadPolydisplaceThinker(savebuffer_t *save, actionf_p1 thinker)
static inline void LoadPolydisplaceThinker(savebuffer_t *save, actionf_p1 thinker)
{
polydisplace_t *ht = (polydisplace_t*)Z_LevelPoolMalloc(sizeof (*ht));
ht->thinker.alloctype = TAT_LEVELPOOL;
@@ -3115,7 +3115,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save)
#define PD_FLAGS 0x01
#define PD_TRANS 0x02
FUNCINLINE static ATTRINLINE void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po)
static inline void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po)
{
UINT8 diff = 0;
WRITEINT32(save->p, po->id);
@@ -3137,7 +3137,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePolyObj(savebuffer_t *save, polyobj_t
WRITEINT32(save->p, po->translucency);
}
FUNCINLINE static ATTRINLINE void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po)
static inline void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po)
{
INT32 id;
UINT32 angle;
@@ -3172,7 +3172,7 @@ FUNCINLINE static ATTRINLINE void P_UnArchivePolyObj(savebuffer_t *save, polyobj
Polyobj_MoveOnLoad(po, angle, x, y);
}
FUNCINLINE static ATTRINLINE void P_ArchivePolyObjects(savebuffer_t *save)
static inline void P_ArchivePolyObjects(savebuffer_t *save)
{
INT32 i;
@@ -3185,7 +3185,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePolyObjects(savebuffer_t *save)
P_ArchivePolyObj(save, &PolyObjects[i]);
}
FUNCINLINE static ATTRINLINE void P_UnArchivePolyObjects(savebuffer_t *save)
static inline void P_UnArchivePolyObjects(savebuffer_t *save)
{
INT32 i, numSavedPolys;
@@ -3203,7 +3203,7 @@ FUNCINLINE static ATTRINLINE void P_UnArchivePolyObjects(savebuffer_t *save)
//
// P_FinishMobjs
//
FUNCINLINE static ATTRINLINE void P_FinishMobjs(void)
static inline void P_FinishMobjs(void)
{
thinker_t *currentthinker;
mobj_t *mobj;
@@ -3220,7 +3220,7 @@ FUNCINLINE static ATTRINLINE void P_FinishMobjs(void)
}
}
FUNCINLINE static ATTRINLINE mobj_t *RelinkMobj(mobj_t **ptr)
static inline mobj_t *RelinkMobj(mobj_t **ptr)
{
UINT32 temp = (UINT32)(size_t)*ptr;
*ptr = NULL;
@@ -3269,7 +3269,7 @@ static void P_RelinkPointers(void)
//
// P_NetArchiveSpecials
//
FUNCINLINE static ATTRINLINE void P_NetArchiveSpecials(savebuffer_t *save)
static inline void P_NetArchiveSpecials(savebuffer_t *save)
{
size_t i, z;
@@ -3347,7 +3347,7 @@ static void P_NetUnArchiveSpecials(savebuffer_t *save)
// =======================================================================
// Misc
// =======================================================================
FUNCINLINE static ATTRINLINE void P_ArchiveMisc(savebuffer_t *save)
static inline void P_ArchiveMisc(savebuffer_t *save)
{
if (gamecomplete)
WRITEINT16(save->p, gamemap | 8192);
@@ -3360,7 +3360,7 @@ FUNCINLINE static ATTRINLINE void P_ArchiveMisc(savebuffer_t *save)
WRITESTRINGN(save->p, timeattackfolder, sizeof(timeattackfolder));
}
FUNCINLINE static ATTRINLINE void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride)
static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride)
{
char testname[sizeof(timeattackfolder)];
@@ -3531,8 +3531,7 @@ static void P_ReloadSaveLevelData(void)
ss->floorpic_angle = spawnss->floorpic_angle;
ss->ceilingpic_angle = spawnss->ceilingpic_angle;
ss->tag = spawnss->tag;
ss->firsttag = spawnss->firsttag;
ss->nexttag = spawnss->nexttag;
ss->firsttag = ss->nexttag = -1;
if (ss->ffloors)
{
@@ -3557,8 +3556,7 @@ static void P_ReloadSaveLevelData(void)
li->callcount = 0;
li->tag = spawnli->tag;
li->firsttag = spawnli->firsttag;
li->nexttag = spawnli->nexttag;
li->firsttag = li->nexttag = -1;
if (li->sidenum[0] != 0xffff)
{
@@ -3582,6 +3580,8 @@ static void P_ReloadSaveLevelData(void)
si->midtexture = spawnsi->midtexture;
}
}
P_InitTagLists();
}
FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, boolean reloading)
+3 -4
View File
@@ -1983,12 +1983,11 @@ static void P_LoadMapData(const virtres_t* virt)
P_LoadLinedefs(virtlinedefs->data);
P_LoadSidedefs(virtsidedefs->data);
P_LoadThings(virtthings->data);
P_InitTagLists(); // Create xref tables for tags
// Copy relevant map data for NetArchive purposes.
spawnsectors = Z_Malloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
spawnlines = Z_Malloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
spawnsides = Z_Malloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
spawnsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
spawnlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
spawnsides = Z_Calloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
memcpy(spawnsectors, sectors, numsectors * sizeof(*sectors));
memcpy(spawnlines, lines, numlines * sizeof(*lines));
+1
View File
@@ -5387,6 +5387,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
// set current weather
curWeather = mapheaderinfo[gamemap-1]->weather;
P_InitTagLists(); // Create xref tables for tags
P_SearchForDisableLinedefs(); // Disable linedefs are now allowed to disable *any* line
P_SpawnScrollers(); // Add generalized scrollers
+1 -1
View File
@@ -77,7 +77,7 @@ void R_ClearDrawSegs(void)
// CPhipps -
// Instead of clipsegs, let's try using an array with one entry for each column,
// indicating whether it's blocked by a solid wall yet or not.
UINT8 *solidcol = NULL;
UINT8 *solidcol;
void R_AllocClipSegMemory(void)
{
+8 -8
View File
@@ -90,21 +90,21 @@ INT32 numtextures = 0; // total number of textures found,
// size of following tables
texture_t **textures = NULL;
static UINT32 **texturecolumnofs = NULL; // column offset lookup table for each texture
UINT8 **texturecache = NULL; // graphics data for each generated full-size texture
static UINT32 **texturecolumnofs; // column offset lookup table for each texture
UINT8 **texturecache; // graphics data for each generated full-size texture
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
static INT32 *texturewidth = NULL;
static INT32 *texturewidth;
fixed_t *textureheight = NULL; // needed for texture pegging
fixed_t *textureheight; // needed for texture pegging
INT32 *texturetranslation = NULL;
INT32 *texturetranslation;
// needed for pre rendering
sprcache_t *spritecachedinfo = NULL;
sprcache_t *spritecachedinfo;
lighttable_t *colormaps = NULL;
UINT8 *encoremap = NULL;
lighttable_t *colormaps;
UINT8 *encoremap;
#ifdef HASINVERT
UINT8 invertmap[256];
#endif
+150 -107
View File
@@ -41,7 +41,8 @@
/** \brief view info
*/
INT32 viewwidth, viewheight, viewwindowx, viewwindowy;
INT32 linesize, viewwidth, viewheight, viewwindowx, viewwindowy;
UINT8 *renderscreen; // haleyjd
// =========================================================================
// COLUMN DRAWING CODE STUFF
@@ -488,92 +489,6 @@ void R_FlushTranslationColormapCache(void)
// in reality, the few routines that can work for either mode, are
// put here
enum columncontext_e columncontext = COLUMNCONTEXT_DIRECT;
enum ColumnFlushType
{
FLUSH_NONE = 0x0000,
FLUSH_OPAQUE = 0x0001,
FLUSH_TRANS = 0x0002,
FLUSH_COLORMAP = 0x0004,
FLUSH_COLORMAP_TRANS = 0x0008,
};
typedef struct drawcolumndata_temp_s
{
INT32 x;
INT32 yl[8], yh[8];
// e6y: resolution limitation is removed
UINT8 *buf;
INT32 startx;
ColumnFlushType type;
INT32 commontop, commonbot;
UINT8 *transmap;
// SoM 7-28-04: Fix the fuzz problem.
UINT8 *translation;
} drawcolumndata_temp_t;
drawcolumndata_temp_t temp_dc = {};
//
// Error functions that will abort if R_FlushColumns tries to flush
// columns without a column type.
//
FUNCNORETURN static ATTRNORETURN void R_FlushWholeError(void)
{
I_Error("R_FlushWholeColumns called without being initialized.\n");
}
FUNCNORETURN static ATTRNORETURN void R_FlushHTError(void)
{
I_Error("R_FlushHTColumns called without being initialized.\n");
}
FUNCNORETURN static ATTRNORETURN void R_QuadFlushError(void)
{
I_Error("R_FlushQuadColumn called without being initialized.\n");
}
static void (*R_FlushWholeColumns)(void) = R_FlushWholeError;
static void (*R_FlushHTColumns)(void) = R_FlushHTError;
static void (*R_FlushQuadColumn)(void) = R_QuadFlushError;
static void R_FlushColumns(void)
{
if (temp_dc.x != 8 || temp_dc.commontop >= temp_dc.commonbot)
R_FlushWholeColumns();
else
{
R_FlushHTColumns();
R_FlushQuadColumn();
}
temp_dc.x = 0;
}
//
// R_ResetColumnBuffer
//
// haleyjd 09/13/04: new function to call from main rendering loop
// which gets rid of the unnecessary reset of various variables during
// column drawing.
//
void R_ResetColumnBuffer(void)
{
// haleyjd 10/06/05: this must not be done if x == 0!
if (temp_dc.x)
{
R_FlushColumns();
}
temp_dc.type = FLUSH_NONE;
R_FlushWholeColumns = R_FlushWholeError;
R_FlushHTColumns = R_FlushHTError;
R_FlushQuadColumn = R_QuadFlushError;
}
/** \brief The R_InitViewBuffer function
Creates lookup tables for getting the framebuffer address
@@ -606,35 +521,40 @@ static void R_AllocViewMemory(void)
R_AllocVisSpriteMemory();
}
void R_InitViewBuffer(void)
void R_InitViewBuffer(INT32 width, INT32 height)
{
if (width > MAXVIDWIDTH)
width = MAXVIDWIDTH;
if (height > MAXVIDHEIGHT)
height = MAXVIDHEIGHT;
R_AllocViewMemory();
viewwindowx = 0;
viewwindowy = 0;
INT32 bufsize = (vid.width * 8) * sizeof(*temp_dc.buf);
linesize = vid.width; // killough 11/98
renderscreen = vid.screens[0]; // haleyjd 07/02/14
}
if (temp_dc.buf)
{
#if defined(__SSE__)
aligned_free(temp_dc.buf);
#else
Z_Free(temp_dc.buf);
#endif
}
/** \brief viewborder patches lump numbers
*/
lumpnum_t viewborderlump[8];
memset(&temp_dc, 0, sizeof(temp_dc));
/** \brief Store the lumpnumber of the viewborder patches
*/
#if defined(__SSE__)
while (bufsize & 15)
bufsize++;
temp_dc.buf = static_cast<UINT8*>(aligned_alloc(16, bufsize));
#else
temp_dc.buf = static_cast<UINT8*>(Z_Malloc(bufsize, PU_STATIC, NULL));
#endif
memset(temp_dc.buf, 0, bufsize);
void R_InitViewBorder(void)
{
viewborderlump[BRDR_T] = W_GetNumForName("brdr_t");
viewborderlump[BRDR_B] = W_GetNumForName("brdr_b");
viewborderlump[BRDR_L] = W_GetNumForName("brdr_l");
viewborderlump[BRDR_R] = W_GetNumForName("brdr_r");
viewborderlump[BRDR_TL] = W_GetNumForName("brdr_tl");
viewborderlump[BRDR_BL] = W_GetNumForName("brdr_bl");
viewborderlump[BRDR_TR] = W_GetNumForName("brdr_tr");
viewborderlump[BRDR_BR] = W_GetNumForName("brdr_br");
}
/** \brief The R_VideoErase function
@@ -658,6 +578,129 @@ void R_VideoErase(size_t ofs, INT32 count)
M_Memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count);
}
#if 0
/** \brief R_FillBackScreen
Fills the back screen with a pattern for variable screen sizes
Also draws a beveled edge.
*/
void R_FillBackScreen(void)
{
UINT8 *src, *dest;
patch_t *patch;
INT32 x, y, step, boff;
// quickfix, don't cache lumps in both modes
if (rendermode != render_soft)
return;
// draw pattern around the status bar too (when hires),
// so return only when in full-screen without status bar.
if (scaledviewwidth == vid.width && viewheight == vid.height)
return;
src = scr_borderpatch;
dest = vid.screens[1];
for (y = 0; y < vid.height; y++)
{
for (x = 0; x < vid.width/128; x++)
{
M_Memcpy (dest, src+((y&127)<<7), 128);
dest += 128;
}
if (vid.width&127)
{
M_Memcpy(dest, src+((y&127)<<7), vid.width&127);
dest += (vid.width&127);
}
}
// don't draw the borders when viewwidth is full vid.width.
if (scaledviewwidth == vid.width)
return;
step = 8;
boff = 8;
patch = W_CacheLumpNum(viewborderlump[BRDR_T], PU_CACHE);
for (x = 0; x < scaledviewwidth; x += step)
V_DrawPatch(viewwindowx + x, viewwindowy - boff, 1, patch);
patch = W_CacheLumpNum(viewborderlump[BRDR_B], PU_CACHE);
for (x = 0; x < scaledviewwidth; x += step)
V_DrawPatch(viewwindowx + x, viewwindowy + viewheight, 1, patch);
patch = W_CacheLumpNum(viewborderlump[BRDR_L], PU_CACHE);
for (y = 0; y < viewheight; y += step)
V_DrawPatch(viewwindowx - boff, viewwindowy + y, 1, patch);
patch = W_CacheLumpNum(viewborderlump[BRDR_R],PU_CACHE);
for (y = 0; y < viewheight; y += step)
V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + y, 1,
patch);
// Draw beveled corners.
V_DrawPatch(viewwindowx - boff, viewwindowy - boff, 1,
W_CacheLumpNum(viewborderlump[BRDR_TL], PU_CACHE));
V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy - boff, 1,
W_CacheLumpNum(viewborderlump[BRDR_TR], PU_CACHE));
V_DrawPatch(viewwindowx - boff, viewwindowy + viewheight, 1,
W_CacheLumpNum(viewborderlump[BRDR_BL], PU_CACHE));
V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + viewheight, 1,
W_CacheLumpNum(viewborderlump[BRDR_BR], PU_CACHE));
}
/** \brief The R_DrawViewBorder
Draws the border around the view
for different size windows?
*/
void R_DrawViewBorder(void)
{
INT32 top, side, ofs;
if (rendermode == render_none)
return;
#ifdef HWRENDER
if (rendermode != render_soft)
{
HWR_DrawViewBorder(0);
return;
}
else
#endif
#ifdef DEBUG
fprintf(stderr,"RDVB: vidwidth %d vidheight %d scaledviewwidth %d viewheight %d\n",
vid.width, vid.height, scaledviewwidth, viewheight);
#endif
if (scaledviewwidth == vid.width)
return;
top = (vid.height - viewheight)>>1;
side = (vid.width - scaledviewwidth)>>1;
// copy top and one line of left side
R_VideoErase(0, top*vid.width+side);
// copy one line of right side and bottom
ofs = (viewheight+top)*vid.width - side;
R_VideoErase(ofs, top*vid.width + side);
// copy sides using wraparound
ofs = top*vid.width + vid.width-side;
side <<= 1;
// simpler using our VID_Blit routine
VID_BlitLinearScreen(vid.screens[1] + ofs, vid.screens[0] + ofs, side, viewheight - 1,
vid.width, vid.width);
}
#endif
// ==========================================================================
// INCLUDE DRAWING CODE HERE
// ==========================================================================
+36 -25
View File
@@ -25,12 +25,15 @@ extern "C" {
// -------------------------------
// COMMON STUFF FOR 8bpp AND 16bpp
// -------------------------------
extern UINT8 *renderscreen;
extern INT32 linesize;
FUNCINLINE static ATTRINLINE UINT8 *R_Address(INT32 px, INT32 py)
{
return vid.screens[0] + (py + viewwindowy) * vid.width + (viewwindowx + px);
return renderscreen + (py + viewwindowy) + (viewwindowx + px) * vid.height;
}
typedef struct {
float x, y, z;
} floatv3_t;
@@ -99,16 +102,6 @@ extern floatv3_t *ds_su, *ds_sv, *ds_sz;
extern float focallengthf;
enum columncontext_e
{
COLUMNCONTEXT_DIRECT = 0,
COLUMNCONTEXT_FLUSH,
};
extern enum columncontext_e columncontext;
void R_SetColumnContext(enum columncontext_e _columncontext);
void R_ResetColumnBuffer(void);
typedef void (coldrawfunc_t)(drawcolumndata_t*);
typedef void (spandrawfunc_t)(drawspandata_t*);
@@ -159,11 +152,28 @@ extern spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX];
void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column);
// ------------------------------------------------
// r_draw.c
// ------------------------------------------------
/// \brief Top border
#define BRDR_T 0
/// \brief Bottom border
#define BRDR_B 1
/// \brief Left border
#define BRDR_L 2
/// \brief Right border
#define BRDR_R 3
/// \brief Topleft border
#define BRDR_TL 4
/// \brief Topright border
#define BRDR_TR 5
/// \brief Bottomleft border
#define BRDR_BL 6
/// \brief Bottomright border
#define BRDR_BR 7
// Custom player skin translation
extern lumpnum_t viewborderlump[8];
// ------------------------------------------------
// r_draw.c COMMON ROUTINES FOR BOTH 8bpp and 16bpp
// ------------------------------------------------
#define GTC_CACHE 1
#define GTC_MENUCACHE GTC_CACHE
@@ -209,9 +219,19 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel);
boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel);
void R_InitViewBuffer(void);
// Custom player skin translation
void R_InitViewBuffer(INT32 width, INT32 height);
void R_InitViewBorder(void);
void R_VideoErase(size_t ofs, INT32 count);
// Rendering function.
#if 0
void R_FillBackScreen(void);
// If the view size is not full screen, draws a border around it.
void R_DrawViewBorder(void);
#endif
#define TRANSPARENTPIXEL 247
// -----------------
@@ -230,15 +250,6 @@ void R_DrawTranslatedTranslucentColumn(drawcolumndata_t* dc);
void R_Draw2sMultiPatchColumn(drawcolumndata_t* dc);
void R_Draw2sMultiPatchTranslucentColumn(drawcolumndata_t* dc);
// column drawers which use buffered drawing with flush
void R_DrawColumn_Flush(drawcolumndata_t* dc);
void R_DrawTranslucentColumn_Flush(drawcolumndata_t* dc);
void R_DrawTranslatedColumn_Flush(drawcolumndata_t* dc);
void R_DrawColumnShadowed_Flush(drawcolumndata_t* dc);
void R_DrawTranslatedTranslucentColumn_Flush(drawcolumndata_t* dc);
void R_Draw2sMultiPatchColumn_Flush(drawcolumndata_t* dc);
void R_Draw2sMultiPatchTranslucentColumn_Flush(drawcolumndata_t* dc);
void R_DrawFogColumn(drawcolumndata_t* dc);
// span drawers
+21 -66
View File
@@ -21,8 +21,6 @@
// a has a constant z depth from top to bottom.
//
#include "r_draw_flush.cpp"
enum DrawColumnType
{
DC_BASIC = 0x0000,
@@ -30,12 +28,11 @@ enum DrawColumnType
DC_TRANSMAP = 0x0002,
DC_HOLES = 0x0004,
DC_LIGHTLIST = 0x0008,
DC_DIRECT = 0x0010, // draw our columns directly to screen!
};
template<DrawColumnType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetColumnTranslated(const drawcolumndata_t* dc, UINT8 col, const UINT8 * restrict colormap)
R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, const UINT8 * restrict colormap)
{
if constexpr (Type & DrawColumnType::DC_COLORMAP)
{
@@ -45,10 +42,9 @@ R_GetColumnTranslated(const drawcolumndata_t* dc, UINT8 col, const UINT8 * restr
return colormap[col];
}
// translucency is handled on flush side now!
template<DrawColumnType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetColumnTranslucent(const drawcolumndata_t* dc, UINT8 * restrict dest, UINT8 col, const UINT8 * restrict colormap)
R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * restrict dest, UINT8 col, const UINT8 * restrict colormap)
{
col = R_GetColumnTranslated<Type>(dc, col, colormap);
@@ -64,7 +60,7 @@ R_GetColumnTranslucent(const drawcolumndata_t* dc, UINT8 * restrict dest, UINT8
template<DrawColumnType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_DrawColumnPixel(const drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const UINT8 * restrict source, const UINT8 * restrict colormap)
R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const UINT8 * restrict source, const UINT8 * restrict colormap)
{
UINT8 col = source[bit];
@@ -76,7 +72,6 @@ R_DrawColumnPixel(const drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit,
}
}
// if we dont buffer our columns, we need to handle translucency again
return R_GetColumnTranslucent<Type>(dc, dest, col, colormap);
}
@@ -88,18 +83,8 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
{
INT32 count;
// leban 1/17/99:
// removed the + 1 here, adjusted the if test, and added an increment
// later. this helps a compiler pipeline a bit better. the x86
// assembler also does this.
count = dc->yh - dc->yl;
// leban 1/17/99:
// this case isn't executed too often. depending on how many instructions
// there are between here and the second if test below, this case could
// be moved down and might save instructions overall. since there are
// probably different wads that favor one way or the other, i'll leave
// this alone for now.
if (count < 0) // Zero length, column does not exceed a pixel.
{
return;
@@ -168,7 +153,6 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
}
R_DrawColumnTemplate<NewType>(&dc_copy);
if (solid)
{
dc_copy.yl = bheight;
@@ -202,9 +186,8 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
// killough 2/1/98: more performance tuning
intptr_t frac;
// Looks familiar.
const intptr_t fracstep = dc->iscale;
const intptr_t heightmask = dc->sourcelength-1; // CPhipps - specify type
const intptr_t heightmask = dc->sourcelength-1;
constexpr INT32 npow2min = -1;
const INT32 npow2max = dc->sourcelength;
@@ -212,27 +195,9 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
const lighttable_t * restrict colormap = dc->colormap;
// Framebuffer destination address.
// SoM: MAGIC
UINT8 * restrict dest;
UINT8 * restrict dest = R_Address(dc->x, dc->yl);
if constexpr (Type & DrawColumnType::DC_DIRECT)
dest = R_Address(dc->x, dc->yl);
else if constexpr ((Type & (DrawColumnType::DC_COLORMAP | DrawColumnType::DC_TRANSMAP))
== (DrawColumnType::DC_COLORMAP | DrawColumnType::DC_TRANSMAP))
dest = R_GetBufferColormapTrans(dc);
else if constexpr (Type & DrawColumnType::DC_TRANSMAP)
dest = R_GetBufferTrans(dc);
else if constexpr (Type & DrawColumnType::DC_COLORMAP)
dest = R_GetBufferColormap(dc);
else
dest = R_GetBufferOpaque(dc);
INT32 stride = 8; //SoM: Oh, Oh it's MAGIC! You know...
if constexpr (Type & DrawColumnType::DC_DIRECT)
stride = vid.width;
count++; // killough 1/99: minor tuning
count++;
// Determine scaling, which is the only mapping to be done.
frac = (dc->texturemid + FixedMul((dc->yl << FRACBITS) - centeryfrac, fracstep));
@@ -242,11 +207,10 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
case 255:
case 127:
{
while (count--)
while(count--)
{
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
dest += stride;
dest++;
frac += fracstep;
}
}
@@ -261,8 +225,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
while (--count >= 0)
{
*dest = R_DrawColumnPixel<Type>(dc, dest, frac>>FRACBITS, source, colormap);
dest += stride;
dest++;
frac += fracstep;
}
}
@@ -274,13 +237,11 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
while ((count -= 2) >= 0) // texture height is a power of 2 -- killough
{
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
dest += stride;
dest++;
frac += fracstep;
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
dest += stride;
dest++;
frac += fracstep;
}
@@ -312,13 +273,13 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix -- killough
// heightmask is the Tutti-Frutti fix
// -1 is the lower clamp bound because column posts have a "safe" byte before the real data
// and a few bytes after as well
*dest = R_DrawColumnPixel<Type>(dc, dest, CLAMP((frac >> FRACBITS), npow2min, npow2max), source, colormap);
dest += stride;
dest++;
#if __SIZEOF_POINTER__ < 8 // 64-bit systems have large enough numbers for this to be a non-issue
// Avoid overflow.
@@ -352,18 +313,13 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
R_DrawColumnTemplate<opt>(dc); \
}
#define DEFINE_COLUMN_COMBO(name, flags) \
DEFINE_COLUMN_FUNC(name, flags|DC_DIRECT) \
DEFINE_COLUMN_FUNC(name ## _Flush, flags)
DEFINE_COLUMN_COMBO(R_DrawColumn, DC_BASIC)
DEFINE_COLUMN_COMBO(R_DrawTranslucentColumn, DC_TRANSMAP)
DEFINE_COLUMN_COMBO(R_DrawTranslatedColumn, DC_COLORMAP)
DEFINE_COLUMN_COMBO(R_DrawColumnShadowed, DC_LIGHTLIST)
DEFINE_COLUMN_COMBO(R_DrawTranslatedTranslucentColumn, DC_COLORMAP|DC_TRANSMAP)
DEFINE_COLUMN_COMBO(R_Draw2sMultiPatchColumn, DC_HOLES)
DEFINE_COLUMN_COMBO(R_Draw2sMultiPatchTranslucentColumn, DC_HOLES|DC_TRANSMAP)
DEFINE_COLUMN_FUNC(R_DrawColumn, DC_BASIC)
DEFINE_COLUMN_FUNC(R_DrawTranslucentColumn, DC_TRANSMAP)
DEFINE_COLUMN_FUNC(R_DrawTranslatedColumn, DC_COLORMAP)
DEFINE_COLUMN_FUNC(R_DrawColumnShadowed, DC_LIGHTLIST)
DEFINE_COLUMN_FUNC(R_DrawTranslatedTranslucentColumn, DC_COLORMAP|DC_TRANSMAP)
DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchColumn, DC_HOLES)
DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchTranslucentColumn, DC_HOLES|DC_TRANSMAP)
/** \brief The R_DrawFogColumn function
Fog wall.
@@ -389,7 +345,6 @@ void R_DrawFogColumn(drawcolumndata_t* dc)
// Framebuffer destination address.
dest = R_Address(dc->x, dc->yl);
const INT32 stride = vid.width;
const lighttable_t * restrict colormap = dc->colormap;
// Determine scaling, which is the only mapping to be done.
@@ -397,6 +352,6 @@ void R_DrawFogColumn(drawcolumndata_t* dc)
{
// Simple. Apply the colormap to what's already on the screen.
*dest = colormap[*dest];
dest += stride;
dest++;
} while (count--);
}
-269
View File
@@ -1,269 +0,0 @@
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 2025 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
// Copyright (C) 1996 by id Software, Inc.
// Copyright (C) 1999 by Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
// Copyright (C) 1999-2000 by Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
// Copyright (C) Copyright 2005, 2006 by Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
// Copyright (C) 2013 by James Haley, Stephen McGranahan, et al.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file r_draw_flush.cpp
/// \brief Optimized quad column buffer code. By SoM.
/// \note no includes because this is included as part of r_draw.cpp
template<ColumnFlushType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetFlushPixelTranslated(const drawcolumndata_temp_t *t_dc, UINT8 col)
{
if constexpr (Type & (ColumnFlushType::FLUSH_COLORMAP | ColumnFlushType::FLUSH_COLORMAP_TRANS))
{
col = t_dc->translation[col];
}
return col;
}
template<ColumnFlushType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetFlushPixelTranslucent(const drawcolumndata_temp_t *t_dc, UINT8 * restrict dest, UINT8 col)
{
col = R_GetFlushPixelTranslated<Type>(t_dc, col);
if constexpr (Type & (ColumnFlushType::FLUSH_TRANS | ColumnFlushType::FLUSH_COLORMAP_TRANS))
{
// haleyjd 09/11/04: use temptranmap here
return *(t_dc->transmap + (col << 8) + (*dest));
}
else
{
return col;
}
}
template<ColumnFlushType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_DrawFlushPixel(const drawcolumndata_temp_t *t_dc, UINT8 * restrict dest, const UINT8 * restrict source)
{
UINT8 col = *source;
return R_GetFlushPixelTranslucent<Type>(t_dc, dest, col);
}
//
// R_FlushWhole
//
// Flushes the entire columns in the buffer, one at a time.
// This is used when a quad flush isn't possible.
//
template<ColumnFlushType Type>
static void R_FlushWhole(void)
{
UINT8 * restrict source;
UINT8 * restrict dest;
INT32 count, yl;
const INT32 stride = vid.width;
drawcolumndata_temp_t *t_dc = &temp_dc;
UINT8 *restrict buf = t_dc->buf;
while (--t_dc->x >= 0)
{
yl = t_dc->yl[t_dc->x];
source = &buf[t_dc->x + (yl << 3)];
dest = R_Address(t_dc->startx + t_dc->x, yl);
count = t_dc->yh[t_dc->x] - yl + 1;
while (--count >= 0)
{
*dest = R_DrawFlushPixel<Type>(t_dc, dest, source);
source += 8;
dest += stride;
}
}
}
//
// R_FlushHT
//
// Flushes the head and tail of columns in the buffer in
// preparation for a quad flush.
//
template<ColumnFlushType Type>
static void R_FlushHT(void)
{
UINT8 * restrict source;
UINT8 * restrict dest;
INT32 count, colnum = 0;
INT32 yl, yh;
const INT32 stride = vid.width;
const drawcolumndata_temp_t *t_dc = &temp_dc;
UINT8 *restrict buf = t_dc->buf;
while (colnum < 8)
{
yl = t_dc->yl[colnum];
yh = t_dc->yh[colnum];
// flush column head
if (yl < t_dc->commontop)
{
source = &buf[colnum + (yl << 3)];
dest = R_Address(t_dc->startx + colnum, yl);
count = t_dc->commontop - yl;
while (--count >= 0)
{
*dest = R_DrawFlushPixel<Type>(t_dc, dest, source);
source += 8;
dest += stride;
}
}
// flush column tail
if (yh > t_dc->commonbot)
{
source = &buf[colnum + ((t_dc->commonbot + 1) << 3)];
dest = R_Address(t_dc->startx + colnum, t_dc->commonbot + 1);
count = yh - t_dc->commonbot;
while (--count >= 0)
{
*dest = R_DrawFlushPixel<Type>(t_dc, dest, source);
source += 8;
dest += stride;
}
}
++colnum;
}
}
// Begin: Quad column flushing functions.
template<ColumnFlushType Type>
static void R_FlushQuad(void)
{
const INT32 stride = vid.width;
const drawcolumndata_temp_t *t_dc = &temp_dc;
INT32 count = t_dc->commonbot - t_dc->commontop + 1;
const UINT8 *restrict buf = t_dc->buf;
const UINT8 * restrict source = buf + (t_dc->commontop << 3);
UINT8 * restrict dest = R_Address(t_dc->startx, t_dc->commontop);
if constexpr (Type & ColumnFlushType::FLUSH_OPAQUE)
{
#if __SIZEOF_POINTER__ >= 8 // does not make much sense on 32bit targets
// 8 byte aligned copy -- make sure our dest ptr, source ptr AND stride are a multiple of 8!
if ((((uintptr_t)dest | (uintptr_t)source | stride) & 7) == 0)
{
const INT64 *source64 = reinterpret_cast<const INT64 *>(source);
INT64 *dest64 = reinterpret_cast<INT64 *>(dest);
const INT32 deststep = stride / 8;
while (--count >= 0)
{
*dest64 = *source64++;
dest64 += deststep;
}
}
else
#endif
{
while (--count >= 0)
{
dest[0] = source[0];
dest[1] = source[1];
dest[2] = source[2];
dest[3] = source[3];
dest[4] = source[4];
dest[5] = source[5];
dest[6] = source[6];
dest[7] = source[7];
source += 8;
dest += stride;
}
}
}
else
{
while (--count >= 0)
{
dest[0] = R_DrawFlushPixel<Type>(t_dc, &dest[0], &source[0]);
dest[1] = R_DrawFlushPixel<Type>(t_dc, &dest[1], &source[1]);
dest[2] = R_DrawFlushPixel<Type>(t_dc, &dest[2], &source[2]);
dest[3] = R_DrawFlushPixel<Type>(t_dc, &dest[3], &source[3]);
dest[4] = R_DrawFlushPixel<Type>(t_dc, &dest[4], &source[4]);
dest[5] = R_DrawFlushPixel<Type>(t_dc, &dest[5], &source[5]);
dest[6] = R_DrawFlushPixel<Type>(t_dc, &dest[6], &source[6]);
dest[7] = R_DrawFlushPixel<Type>(t_dc, &dest[7], &source[7]);
source += 8;
dest += stride;
}
}
}
// haleyjd 09/12/04: split up R_GetBuffer into various different
// functions to minimize the number of branches and take advantage
// of as much precalculated information as possible.
template<ColumnFlushType Type>
static UINT8 *R_GetBuffer(drawcolumndata_t *dc)
{
drawcolumndata_temp_t *t_dc = &temp_dc;
// haleyjd: reordered predicates
if (t_dc->x == 8 ||
(t_dc->x && (t_dc->type != Type || t_dc->x + t_dc->startx != dc->x)))
R_FlushColumns();
if (!t_dc->x)
{
++t_dc->x;
t_dc->startx = dc->x;
t_dc->yl[0] = t_dc->commontop = dc->yl;
t_dc->yh[0] = t_dc->commonbot = dc->yh;
t_dc->type = Type;
if constexpr (Type & (ColumnFlushType::FLUSH_TRANS | ColumnFlushType::FLUSH_COLORMAP_TRANS))
{
t_dc->transmap = dc->transmap;
}
if constexpr (Type & (ColumnFlushType::FLUSH_COLORMAP | ColumnFlushType::FLUSH_COLORMAP_TRANS))
{
t_dc->translation = dc->translation;
}
R_FlushWholeColumns = R_FlushWhole<Type>;
R_FlushHTColumns = R_FlushHT<Type>;
R_FlushQuadColumn = R_FlushQuad<Type>;
return &t_dc->buf[dc->yl << 3];
}
t_dc->yl[t_dc->x] = dc->yl;
t_dc->yh[t_dc->x] = dc->yh;
if (dc->yl > t_dc->commontop)
t_dc->commontop = dc->yl;
if (dc->yh < t_dc->commonbot)
t_dc->commonbot = dc->yh;
return &t_dc->buf[(dc->yl << 3) + t_dc->x++];
}
#define DEFINE_GETBUF_FUNC(name, flags) \
FUNCINLINE static ATTRINLINE UINT8 *name(drawcolumndata_t *dc) \
{ \
constexpr ColumnFlushType opt = static_cast<ColumnFlushType>(flags); \
return R_GetBuffer<opt>(dc); \
}
DEFINE_GETBUF_FUNC(R_GetBufferOpaque, FLUSH_OPAQUE)
DEFINE_GETBUF_FUNC(R_GetBufferTrans, FLUSH_TRANS)
DEFINE_GETBUF_FUNC(R_GetBufferColormap, FLUSH_COLORMAP)
DEFINE_GETBUF_FUNC(R_GetBufferColormapTrans, FLUSH_COLORMAP_TRANS)
+55 -56
View File
@@ -51,7 +51,7 @@ enum DrawSpanType
template<DrawSpanType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetSpanTranslated(const drawspandata_t* ds, UINT8 col)
R_GetSpanTranslated(drawspandata_t* ds, UINT8 col)
{
if constexpr (Type & DrawSpanType::DS_COLORMAP)
{
@@ -65,7 +65,7 @@ R_GetSpanTranslated(const drawspandata_t* ds, UINT8 col)
template<DrawSpanType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_GetSpanTranslucent(const drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col)
R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col)
{
col = colormap[R_GetSpanTranslated<Type>(ds, col)];
@@ -81,7 +81,7 @@ R_GetSpanTranslucent(const drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colorma
template<DrawSpanType Type>
FUNCINLINE static ATTRINLINE constexpr UINT8
R_DrawSpanPixel(const drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT32 bit, const UINT8 *source)
R_DrawSpanPixel(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT32 bit, const UINT8 *source)
{
UINT8 col = source[bit];
@@ -110,15 +110,17 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
UINT8 * restrict dsrc;
const UINT8 * restrict deststop = vid.screens[0] + vid.width * vid.height;
const UINT8 * restrict deststop = vid.screens[0] + vid.height *vid.width;
if (dest+8 > deststop)
if (dest > deststop)
{
return;
}
intptr_t count = (ds->x2 - ds->x1 + 1);
size_t i;
//size_t i;
const INT32 stride = vid.height;
xposition = ds->xfrac; yposition = ds->yfrac;
xstep = ds->xstep; ystep = ds->ystep;
@@ -143,14 +145,14 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
if constexpr (Type & DS_RIPPLE)
{
dsrc = vid.screens[1] + (ds->y + ds->bgofs) * vid.width + ds->x1;
dsrc = vid.screens[1] + (ds->y + ds->bgofs) + ds->x1 * vid.height;
}
else
{
dsrc = dest;
}
while (count >= 8)
/*while (count >= 8)
{
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
// have the uber complicated math to calculate it now, so that was a memory write we didn't
@@ -160,34 +162,26 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
{
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
if constexpr (Type & DS_RIPPLE)
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
else
dest[i] = R_DrawSpanPixel<Type>(ds, &dest[i], colormap, bit, source);
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
xposition += xstep;
yposition += ystep;
}
dest += 8;
if constexpr (Type & DS_RIPPLE)
dsrc += 8;
dsrc += 8;
count -= 8;
}
}*/
while (count-- && dest <= deststop)
{
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
if constexpr (Type & DS_RIPPLE)
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
else
*dest = R_DrawSpanPixel<Type>(ds, dest, colormap, bit, source);
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
dest++;
if constexpr (Type & DS_RIPPLE)
dsrc++;
dest += stride;
dsrc += stride;
xposition += xstep;
yposition += ystep;
@@ -246,26 +240,27 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
UINT32 stepu, stepv;
UINT32 bit;
INT32 x1 = ds->x1;
//INT32 x1 = ds->x1;
const INT32 nflatxshift = ds->nflatxshift;
const INT32 nflatyshift = ds->nflatyshift;
const INT32 nflatmask = ds->nflatmask;
const INT32 stride = vid.width;
const INT32 stride = vid.height;
local_for_thread std::vector<INT32> tiltlighting;
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx);
vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
R_GetTiltedLighting(tiltlighting, ds, iz, width, stride);
const UINT8 * restrict source = ds->source;
const UINT8 * restrict colormap = ds->colormap;
uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx);
vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx);
const UINT8 *source = ds->source;
const UINT8 *colormap = ds->colormap;
if constexpr (Type & DS_RIPPLE)
{
dsrc = vid.screens[1] + (ds->y + ds->bgofs) * stride + ds->x1;
dsrc = vid.screens[1] + (ds->y + ds->bgofs) + ds->x1 * stride;
}
else
{
@@ -317,22 +312,31 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
u = (INT64)(startu);
v = (INT64)(startv);
x1 = ds->x1;
//x1 = ds->x1;
for (i = 0; i < SPANSIZE; i++)
// not sure which one does a better job
for (i = SPANSIZE-1; i >= 0; i--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
dest += stride;
dsrc += stride;
u += stepu;
v += stepv;
}
/*for (i = 0; i < SPANSIZE; i++)
{
bit = (((v + stepv * i) >> nflatyshift) & nflatmask) | ((u + stepu * i) >> nflatxshift);
colormap = ds->planezlight[tiltlighting[x1 + i]] + (ds->colormap - colormaps);
if constexpr (Type & DS_RIPPLE)
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
else
dest[i] = R_DrawSpanPixel<Type>(ds, &dest[i], colormap, bit, source);
dest[i * stride] = R_DrawSpanPixel<Type>(ds, &dsrc[i * stride], colormap, bit, source);
}
ds->x1 += SPANSIZE;
dest += SPANSIZE;
if constexpr (Type & DS_RIPPLE)
dsrc += SPANSIZE;
dest += SPANSIZE * stride;
dsrc += SPANSIZE * stride;*/
startu = endu;
startv = endv;
width -= SPANSIZE;
@@ -346,10 +350,7 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
v = (INT64)(startv);
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
if constexpr (Type & DS_RIPPLE)
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
else
*dest = R_DrawSpanPixel<Type>(ds, dest, colormap, bit, source);
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
ds->x1++;
}
else
@@ -372,13 +373,9 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
{
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
if constexpr (Type & DS_RIPPLE)
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
else
*dest = R_DrawSpanPixel<Type>(ds, dest, colormap, bit, source);
dest++;
if constexpr (Type & DS_RIPPLE)
dsrc++;
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
dest += stride;
dsrc += stride;
ds->x1++;
u += stepu;
v += stepv;
@@ -410,26 +407,28 @@ DEFINE_SPAN_COMBO(R_DrawTranslucentWaterSpan, DS_TRANSMAP|DS_RIPPLE)
*/
void R_DrawFogSpan(drawspandata_t* ds)
{
INT32 count = ds->x2 - ds->x1 + 1;
const UINT8 * restrict colormap = ds->colormap;
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
while (count >= 4)
intptr_t count = ds->x2 - ds->x1 + 1;
const INT32 stride = vid.height;
/*while (count >= 4)
{
dest[0] = colormap[dest[0]];
dest[1] = colormap[dest[1]];
dest[2] = colormap[dest[2]];
dest[3] = colormap[dest[3]];
dest += 4;
dest += 4;
count -= 4;
}
}*/
while (count--)
{
*dest = colormap[*dest];
dest++;
dest += stride;
}
}
@@ -450,7 +449,7 @@ void R_DrawFogSpan_Tilted(drawspandata_t* ds)
{
UINT8 *colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[*dest];
dest++;
dest += stride;
}
while (--width >= 0);
}
+1 -1
View File
@@ -172,7 +172,7 @@ static vector3_t *R_LerpVector3(const vector3_t *from, const vector3_t *to, fixe
// recalc necessary stuff for mouseaiming
// slopes are already calculated for the full possible view (which is 4*viewheight).
// 18/08/18: (No it's actually 16*viewheight, thanks Lactozilla for finding this out)
void R_SetupFreelook(void)
static void R_SetupFreelook(void)
{
// clip it in the case we are looking a hardware 90 degrees full aiming
// (lmps, network and use F12...)
-1
View File
@@ -151,7 +151,6 @@ typedef struct levelinterpolator_s {
};
} levelinterpolator_t;
void R_SetupFreelook(void);
// Interpolates the current view variables (r_state.h) against the selected view context in R_SetViewContext
void R_InterpolateView(fixed_t frac, boolean forceinvalid);
// Special function just for software
+6 -12
View File
@@ -63,7 +63,7 @@ size_t loopcount;
fixed_t viewx, viewy, viewz;
angle_t viewangle, aimingangle, viewroll;
UINT8 viewssnum = 0;
UINT8 viewssnum;
fixed_t viewcos, viewsin;
boolean skyVisible;
boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible for each splitscreen player
@@ -88,7 +88,7 @@ INT32 viewangletox[FINEANGLES/2];
// The xtoviewangleangle[] table maps a screen pixel
// to the lowest viewangle that maps back to x ranges
// from clipangle to -clipangle.
angle_t *xtoviewangle = NULL;
angle_t *xtoviewangle;
lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
lighttable_t *scalelightfixed[MAXLIGHTSCALE];
@@ -960,8 +960,6 @@ void R_ExecuteSetViewSize(void)
}
}
R_SetupFreelook();
am_recalc = true;
}
@@ -1005,7 +1003,7 @@ static void R_InitViewMapping(void)
static void R_SetupViewBuffers(void)
{
R_CalcFov(cv_fov.value);
R_InitViewBuffer();
R_InitViewBuffer(viewwidth, viewheight);
R_InitViewMapping();
}
@@ -1025,6 +1023,8 @@ void R_Init(void)
//I_OutputMsg("\nR_InitData");
R_InitData();
//I_OutputMsg("\nR_InitViewBorder");
R_InitViewBorder();
R_SetViewSize(); // setsizeneeded is set true
// this is now done by SCR_Recalc() at the first mode set
@@ -1404,12 +1404,9 @@ void R_RenderPlayerView(player_t *player)
R_ClearPlanes();
R_ClearSprites();
R_SetColumnContext(COLUMNCONTEXT_FLUSH);
R_RenderViewpoint(&masks[nummasks - 1], false);
R_ClipSprites(drawsegs, NULL);
R_ResetColumnBuffer();
R_SetColumnContext(COLUMNCONTEXT_DIRECT);
R_DrawSkyPlanes(); // draw the fucker again to prevent some artifacts
R_DrawPlanes();
R_DrawMasked(masks, nummasks);
@@ -1444,7 +1441,6 @@ void R_RenderPlayerView(player_t *player)
// check for new console commands.
NetUpdate();
R_SetColumnContext(COLUMNCONTEXT_FLUSH);
ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0;
PS_START_TIMING(ps_bsptime);
R_RenderViewpoint(&masks[nummasks - 1], true);
@@ -1452,7 +1448,6 @@ void R_RenderPlayerView(player_t *player)
PS_START_TIMING(ps_sw_spritecliptime);
R_ClipSprites(drawsegs, NULL);
PS_STOP_TIMING(ps_sw_spritecliptime);
R_ResetColumnBuffer();
ps_numsprites.value.i = numvisiblesprites;
@@ -1489,14 +1484,12 @@ void R_RenderPlayerView(player_t *player)
R_RenderViewpoint(&masks[nummasks - 1], true);
R_ClipSprites(ds_p - (masks[nummasks - 1].drawsegs[1] - masks[nummasks - 1].drawsegs[0]), portal);
R_ResetColumnBuffer();
Portal_Remove(portal);
}
}
PS_STOP_TIMING(ps_sw_portaltime);
R_SetColumnContext(COLUMNCONTEXT_DIRECT);
PS_START_TIMING(ps_sw_planetime);
if (!skybox)
R_DrawSkyPlanes();
@@ -1507,6 +1500,7 @@ void R_RenderPlayerView(player_t *player)
PS_START_TIMING(ps_sw_maskedtime);
R_DrawMasked(masks, nummasks);
PS_STOP_TIMING(ps_sw_maskedtime);
free(masks);
// Check for new console commands.
+1 -1
View File
@@ -97,7 +97,7 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y,
// Try to quickly decide by looking at sign bits.
// also use a mask to avoid branch prediction
INT32 mask = (((node->dy ^ node->dx ^ x ^ y) < 0) ? -1 : 0);
INT32 mask = (node->dy ^ node->dx ^ x ^ y) >> 31;
return (mask & ((node->dy ^ x) < 0)) | // (left is negative)
(~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x)));
}
+25 -47
View File
@@ -19,7 +19,6 @@
#include "r_skins.h"
#include "z_zone.h"
#include "w_wad.h"
#include <vector>
#ifdef HWRENDER
#include "hardware/hw_glob.h"
@@ -38,7 +37,7 @@ static void R_ParseSpriteInfoFrame(spriteinfo_t *info)
UINT8 frameFrame = 0xFF;
INT16 frameXPivot = 0;
INT16 frameYPivot = 0;
rotaxis_t frameRotAxis = ROTAXIS_X;
rotaxis_t frameRotAxis = 0;
// Sprite identifier
sprinfoToken = M_GetToken(NULL);
@@ -159,14 +158,14 @@ static void R_ParseSpriteInfo(boolean spr2)
I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName);
if (!memcmp(newSpriteName,sprnames[i],4))
{
sprnum = static_cast<spritenum_t>(i);
sprnum = i;
break;
}
}
}
// allocate a spriteinfo
info = static_cast<spriteinfo_t*>(Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL));
info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL);
info->available = true;
// Left Curly Brace
@@ -330,7 +329,7 @@ void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps)
patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest)
{
patch_t *patch = static_cast<patch_t*>((dest == NULL) ? Z_Calloc(sizeof(patch_t), PU_PATCH, NULL) : dest);
patch_t *patch = (dest == NULL) ? Z_Calloc(sizeof(patch_t), PU_PATCH, NULL) : (patch_t *)(dest);
if (source)
{
@@ -342,7 +341,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest)
patch->height = SHORT(source->height);
patch->leftoffset = SHORT(source->leftoffset);
patch->topoffset = SHORT(source->topoffset);
patch->columnofs = static_cast<INT32*>(Z_Calloc(size, PU_PATCH_DATA, NULL));
patch->columnofs = Z_Calloc(size, PU_PATCH_DATA, NULL);
for (col = 0; col < source->width; col++)
{
@@ -358,7 +357,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest)
if (colsize <= 0)
I_Error("Patch_Create: no column data!");
patch->columns = static_cast<UINT8*>(Z_Calloc(colsize, PU_PATCH_DATA, NULL));
patch->columns = Z_Calloc(colsize, PU_PATCH_DATA, NULL);
M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize);
}
@@ -430,8 +429,8 @@ void *Patch_AllocateHardwarePatch(patch_t *patch)
{
if (!patch->hardware)
{
GLPatch_t *glPatch = static_cast<GLPatch_t*>(Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware));
glPatch->mipmap = static_cast<GLMipmap_t*>(Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &glPatch->mipmap));
GLPatch_t *glPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware);
glPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &glPatch->mipmap);
}
return (void *)(patch->hardware);
}
@@ -449,8 +448,7 @@ void *Patch_CreateGL(patch_t *patch)
}
#endif // HWRENDER
// 1 MB should be enough for most cases
static std::vector<UINT8> imgbuf(1024 * 1024);
static UINT8 *imgbuf = NULL;
//
// R_MaskedFlatToPatch
@@ -460,27 +458,17 @@ static std::vector<UINT8> imgbuf(1024 * 1024);
void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, INT16 topoffset, size_t *destsize)
{
INT16 x, y;
UINT8 *img, *imgptr;
UINT8 *img;
UINT8 *colpointers, *startofspan;
size_t size = 0;
if (!raw)
return NULL;
// Allocate a staging buffer with the maximum size needed for a patch of the same size as the input.
if (!imgbuf)
imgbuf = Z_Malloc(1<<26, PU_STATIC, NULL);
// round up to nearest multiple of 254-pixel posts, plus 1 more 254-pixel post for paranoia reasons
size_t maxcolumnsize = (2 + (height - 1) / 256) * 256;
// the patch header, and width columns of the max column size
size_t maxoutsize = maxcolumnsize * width + (8 + 4 * width);
// so, a 512x512 flat should maximally need 393,760 (384.53 KiB) bytes.
// quite a bit smaller than 64 megabytes, and much less annoying to the windows debug allocator!
while (imgbuf.size() < maxoutsize)
{
imgbuf.resize(imgbuf.size() * 2);
}
imgptr = imgbuf.data();
UINT8 *imgptr = imgbuf;
// Write image size and offset
WRITEINT16(imgptr, width);
@@ -500,7 +488,7 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I
startofspan = NULL;
// Write column pointer
WRITEINT32(colpointers, imgptr - imgbuf.data());
WRITEINT32(colpointers, imgptr - imgbuf);
// Write pixels
for (y = 0; y < height; y++)
@@ -569,9 +557,9 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I
WRITEUINT8(imgptr, 0xFF);
}
size = imgptr-imgbuf.data();
img = static_cast<UINT8*>(Z_Malloc(size, PU_STATIC, NULL));
memcpy(img, imgbuf.data(), size);
size = imgptr-imgbuf;
img = Z_Malloc(size, PU_STATIC, NULL);
memcpy(img, imgbuf, size);
if (destsize != NULL)
*destsize = size;
@@ -594,27 +582,17 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I
void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffset, INT16 topoffset, size_t *destsize)
{
INT16 x, y;
UINT8 *img, *imgptr;
UINT8 *img;
UINT8 *colpointers, *startofspan;
size_t size = 0;
if (!raw)
return NULL;
// Allocate a staging buffer with the maximum size needed for a patch of the same size as the input.
if (!imgbuf)
imgbuf = Z_Malloc(1<<26, PU_STATIC, NULL);
// round up to nearest multiple of 254-pixel posts, plus 1 more 254-pixel post for paranoia reasons
size_t maxcolumnsize = (2 + (height - 1) / 256) * 256;
// the patch header, and width columns of the max column size
size_t maxoutsize = maxcolumnsize * width + (8 + 4 * width);
// so, a 512x512 flat should maximally need 393,760 (384.53 KiB) bytes.
// quite a bit smaller than 64 megabytes, and much less annoying to the windows debug allocator!
while (imgbuf.size() < maxoutsize)
{
imgbuf.resize(imgbuf.size() * 2);
}
imgptr = imgbuf.data();
UINT8 *imgptr = imgbuf;
// Write image size and offset
WRITEINT16(imgptr, width);
@@ -634,7 +612,7 @@ void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffs
startofspan = NULL;
// Write column pointer
WRITEINT32(colpointers, imgptr - imgbuf.data());
WRITEINT32(colpointers, imgptr - imgbuf);
// Write pixels
for (y = 0; y < height; y++)
@@ -704,9 +682,9 @@ void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffs
WRITEUINT8(imgptr, 0xFF);
}
size = imgptr-imgbuf.data();
img = static_cast<UINT8*>(Z_Malloc(size, PU_STATIC, NULL));
memcpy(img, imgbuf.data(), size);
size = imgptr-imgbuf;
img = Z_Malloc(size, PU_STATIC, NULL);
memcpy(img, imgbuf, size);
if (destsize != NULL)
*destsize = size;
-8
View File
@@ -14,10 +14,6 @@
#ifndef __R_PATCH__
#define __R_PATCH__
#ifdef __cplusplus
extern "C" {
#endif
#include "r_defs.h"
// Structs
@@ -67,8 +63,4 @@ void *R_PixelsToPatch(UINT8 *raw, INT16 width, INT16 height, INT16 leftoffset, I
UINT16 R_GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip);
void R_PatchToPixels(patch_t *patch, UINT8 *dst); // Important: dst must have enough space for patch->width*patch->height pixels!
#ifdef __cplusplus
} // extern "C"
#endif
#endif // __R_PATCH__
@@ -15,7 +15,6 @@
#include "r_patchrotation.h"
#include "z_zone.h"
#include "w_wad.h"
#include <vector>
#ifdef ROTSPRITE
//
@@ -90,14 +89,14 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri
RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip);
}
return static_cast<patch_t*>(rotsprite->patches[idx]);
return rotsprite->patches[idx];
}
rotsprite_t *RotatedPatch_Create(INT32 numangles)
{
rotsprite_t *rotsprite = static_cast<rotsprite_t*>(Z_Calloc(sizeof(rotsprite_t), PU_STATIC, NULL));
rotsprite_t *rotsprite = Z_Calloc(sizeof(rotsprite_t), PU_STATIC, NULL);
rotsprite->angles = numangles;
rotsprite->patches = static_cast<void**>(Z_Calloc(rotsprite->angles * 2 * sizeof(void *), PU_STATIC, NULL));
rotsprite->patches = Z_Calloc(rotsprite->angles * 2 * sizeof(void *), PU_STATIC, NULL);
return rotsprite;
}
@@ -119,8 +118,30 @@ static void RotatedPatch_CalculateDimensions(
h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2)));
h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2)));
*newwidth = std::max(width, std::max(w1, w2));
*newheight = std::max(height, std::max(h1, h2));
*newwidth = max(width, max(w1, w2));
*newheight = max(height, max(h1, h2));
}
static void RotatedPatch_AllocImgBuf(UINT16 **buf, size_t size, size_t *capacity)
{
if (!*buf)
{
*buf = Z_Malloc(*capacity, PU_STATIC, NULL);
}
size_t allocsize = size * sizeof(UINT16);
// make sure our buffer always fits with what we need
if (allocsize > *capacity)
{
while (*capacity < allocsize)
*capacity *= 2;
Z_Free(*buf);
*buf = Z_Malloc(*capacity, PU_STATIC, NULL);
}
//CONS_Printf("RotatedPatch_AllocBuf: Allocated %.2f KB\n", *capacity / 1024.0);
}
void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip)
@@ -128,10 +149,10 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
UINT32 i;
patch_t *rotated;
static std::vector<UINT16> rawdst(1024 * 1024), rawconv(1024 * 1024); // 1 MB should be enough for most cases
static UINT16 *rawdst = NULL, *rawconv = NULL;
UINT16 *rawout;
size_t size;
static size_t dst_capacity = (1024 * 1024), conv_capacity = (1024 * 1024); // 1 MB should be enough for most cases
INT32 bflip = (flip != 0x00);
INT32 width = patch->width;
@@ -185,10 +206,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
if (!size)
size = (width * height);
while (rawdst.size() < size)
{
rawdst.resize(rawdst.size() * 2);
}
RotatedPatch_AllocImgBuf(&rawdst, size, &dst_capacity);
for (i = 0; i < size; i++)
rawdst[i] = 0xFF00;
@@ -232,11 +250,11 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
size = (width * height);
rawconv.resize(size);
memset(rawconv.data(), 0, size * sizeof(UINT16));
RotatedPatch_AllocImgBuf(&rawconv, size, &conv_capacity);
memset(rawconv, 0, conv_capacity * sizeof(UINT16));
src = &rawdst[(miny * newwidth) + minx];
dest = rawconv.data();
dest = rawconv;
dy = height;
while (dy--)
@@ -249,14 +267,14 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
ox -= minx;
oy -= miny;
rawout = rawconv.data();
rawout = rawconv;
}
else
{
width = newwidth;
height = newheight;
rawout = rawdst.data();
rawout = rawdst;
}
// make patch
+41 -33
View File
@@ -46,15 +46,15 @@
// good night sweet prince
//#define SHITPLANESPARENCY
visplane_t *visplanes[MAXVISPLANES] = {};
visplane_t *visplanes[MAXVISPLANES];
static visplane_t *freetail;
static visplane_t **freehead = &freetail;
visplane_t *floorplane = NULL;
visplane_t *ceilingplane = NULL;
visplane_t *floorplane;
visplane_t *ceilingplane;
visffloor_t visffloor[MAXFFLOORS] = {};
INT32 numffloors = 0;
visffloor_t visffloor[MAXFFLOORS];
INT32 numffloors;
//SoM: 3/23/2000: Boom visplane hashing routine.
#define visplane_hash(picnum,lightlevel,height) \
@@ -65,8 +65,8 @@ INT32 numffloors = 0;
// floorclip starts out SCREENHEIGHT
// ceilingclip starts out -1
//
INT16 *floorclip = NULL, *ceilingclip = NULL;
fixed_t *frontscale = NULL;
INT16 *floorclip, *ceilingclip;
fixed_t *frontscale;
//
// spanstart holds the start of a plane span
@@ -81,13 +81,13 @@ static INT32 *spanstart;
// (this is to calculate yslopes only when really needed)
// (when mouselookin', yslope is moving into yslopetab)
// Check R_SetupFrame, R_SetViewSize for more...
fixed_t *yslopetab = NULL;
fixed_t *yslope = NULL;
fixed_t *yslopetab;
fixed_t *yslope;
fixed_t basexscale = 0, baseyscale = 0;
fixed_t basexscale, baseyscale;
static INT16 *ffloor_f_clip = NULL;
static INT16 *ffloor_c_clip = NULL;
static INT16 *ffloor_f_clip;
static INT16 *ffloor_c_clip;
static void R_SetTiltedSpan(drawspandata_t* ds, INT32 span);
static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff);
@@ -616,20 +616,23 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop)
//
static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(drawspandata_t*), INT32, INT32, INT32, boolean), spandrawfunc_t* localspanfunc, drawspandata_t* ds, INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2, boolean allow_parallel)
{
const INT32 vidheight = vid.height;
// Alam: from r_splats's R_RenderFloorSplat
if (t1 >= viewheight) t1 = viewheight-1;
if (b1 >= viewheight) b1 = viewheight-1;
if (t2 >= viewheight) t2 = viewheight-1;
if (b2 >= viewheight) b2 = viewheight-1;
if (x-1 >= viewwidth) x = viewwidth;
if (t1 >= vidheight) t1 = vidheight-1;
if (b1 >= vidheight) b1 = vidheight-1;
if (t2 >= vidheight) t2 = vidheight-1;
if (b2 >= vidheight) b2 = vidheight-1;
if (x-1 >= vid.width) x = vid.width;
#ifdef HAVE_THREADS
// We want to draw N spans per subtask to ensure the work is
// coarse enough to not be too slow due to task scheduling overhead.
// To safely do this, we need to copy part of spanstart to a local.
// This is essentially loop unrolling across threads.
constexpr const int kSpanTaskGranularity = 8;
constexpr const int kSpanTaskGranularity = 16;
drawspandata_t ds_copy = *ds;
while (t1 < t2 && t1 <= b1)
{
INT32 spanstartcopy[kSpanTaskGranularity] = {0};
@@ -714,10 +717,13 @@ void R_DrawPlanes(void)
visplane_t *pl;
INT32 i;
drawspandata_t ds = {};
#ifdef HAVE_THREADS
srb2::ThreadPool::Sema tp_sema;
#endif
R_UpdatePlaneRipple(&ds);
#ifdef HAVE_THREADS
srb2::ThreadPool::Sema tp_sema;
srb2::g_main_threadpool->begin_sema();
#endif
for (i = 0; i < MAXVISPLANES; i++, pl++)
@@ -737,7 +743,7 @@ void R_DrawPlanes(void)
#endif
}
static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), boolean allow_parallel);
static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel);
void R_DrawSkyPlanes(void)
{
@@ -772,7 +778,7 @@ void R_DrawSkyPlanes(void)
#endif
}
static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), boolean allow_parallel)
static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), boolean allow_parallel)
{
INT32 x;
@@ -782,7 +788,7 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*),
drawcolumndata_t dc = {};
const INT32 texture = texturetranslation[skytexture];
// Reset column drawer function (note: couldn't we just call colfuncs[BASEDRAWFUNC] directly?)
// Reset column drawer function (note: couldn't we just call walldrawerfunc directly?)
// (that is, unless we'll need to switch drawers in future for some reason)
R_SetColumnFunc(BASEDRAWFUNC);
@@ -808,12 +814,12 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*),
R_CheckTextureCache(texture);
#ifdef HAVE_THREADS
// Tune concurrency granularity here to maximize throughput
// The cheaper colfunc is, the more coarse the task should be
constexpr const int kSkyPlaneMacroColumns = 8;
while (x <= pl->maxx)
{
// Tune concurrency granularity here to maximize throughput
// The cheaper colfunc is, the more coarse the task should be
constexpr const int kSkyPlaneMacroColumns = 8;
auto thunk = [=]() mutable -> void {
for (int i = 0; i < kSkyPlaneMacroColumns && i + x <= pl->maxx; i++)
{
@@ -832,7 +838,7 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*),
dc.x = x + i;
dc.source = R_GetColumn(texture, -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
skycolfunc(&dc);
colfunc2(&dc);
}
};
@@ -866,9 +872,10 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*),
dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
dc.x = x;
dc.source =
R_GetColumn(texturetranslation[skytexture], -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
R_GetColumn(texturetranslation[skytexture],
-angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
skycolfunc(&dc);
colfunc2(&dc);
}
#endif
}
@@ -1150,13 +1157,14 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
}
}
offset = (scry*vid.width) + scrx;
//offset = (scry*vid.width) + scrx;
offset = (scrx*vid.height) + scry;
// No idea if this works
VID_BlitLinearScreen(vid.screens[0] + offset,
vid.screens[1] + (top*vid.width), // intentionally not +offset
VID_BlitLinearScreen(renderscreen + offset,
vid.screens[1] + top, // intentionally not +offset
viewwidth, bottom-top,
vid.width, vid.width);
vid.height, vid.height);
}
}
}
+8 -5
View File
@@ -26,6 +26,7 @@
#include "p_local.h" // Camera...
#include "p_setup.h"
#include "p_slopes.h"
#include "console.h" // con_clipviewtop
#include "screen.h"
#include "core/memory.h"
@@ -627,6 +628,8 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
sector_t tempsec;
INT32 templight;
INT32 i, p;
fixed_t bottombounds = viewheight << FRACBITS;
fixed_t topbounds = (con_clipviewtop - 1) << FRACBITS;
fixed_t offsetvalue = 0;
lightlist_t *light;
r_lightlist_t *rlight;
@@ -933,7 +936,7 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
bottom_frac += bottom_step;
// SoM: If column is out of range, why bother with it??
if (windowbottom < 0 || windowtop > (viewheight << FRACBITS))
if (windowbottom < topbounds || windowtop > bottombounds)
{
if (dc->numlights)
{
@@ -2236,7 +2239,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz;
highcutslope = std::min(worldtopslope, worldhighslope) + viewz;
auto check_fof_offscreen = [&](ffloor_t* rover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope)
auto check_fof_offscreen = [&](INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope)
{
return ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= bottom + viewz
&& P_GetFFloorTopZAt (rover, segright.x, segright.y) <= bottomslope + viewz)
@@ -2376,7 +2379,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
continue;
// Oy vey.
if (check_fof_offscreen(rover, worldbottom, worldbottomslope, worldtop, worldtopslope))
if (check_fof_offscreen(worldbottom, worldbottomslope, worldtop, worldtopslope))
continue;
ds_p->thicksides[i] = rover;
@@ -2394,10 +2397,10 @@ void R_StoreWallRange(INT32 start, INT32 stop)
continue;
// Oy vey.
if (check_fof_offscreen(rover, worldbottom, worldbottomslope, worldtop, worldtopslope))
if (check_fof_offscreen(worldbottom, worldbottomslope, worldtop, worldtopslope))
continue;
if (check_fof_offscreen(rover, worldlow, worldlowslope, worldhigh, worldhighslope))
if (check_fof_offscreen(worldlow, worldlowslope, worldhigh, worldhighslope))
continue;
ds_p->thicksides[i] = rover;
-8
View File
@@ -35,8 +35,6 @@
CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2];
#include "discord.h"
INT32 numskins = 0;
INT32 numallskins = 0;
INT32 numlocalskins = 0;
@@ -330,14 +328,8 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
if (player->mo)
P_SetScale(player->mo, player->mo->scale);
// for replays: We have changed our skin mid-game; let the game know so it can do the same in the replay!
demo_extradata[playernum] |= DXD_SKIN;
#ifdef HAVE_DISCORDRPC
if (player - players == consoleplayer)
DRPC_UpdatePresence();
#endif
return;
}
+24 -17
View File
@@ -43,6 +43,13 @@
#define MINZ (FRACUNIT*16)
#define BASEYCENTER (BASEVIDHEIGHT/2)
typedef struct
{
INT32 x1, x2;
INT32 column;
INT32 topclip, bottomclip;
} maskdraw_t;
//
// Sprite rotation 0 is facing the viewer,
// rotation 1 is one angle turn CLOCKWISE around the axis.
@@ -53,8 +60,8 @@
static lighttable_t **spritelights;
// constant arrays used for psprite clipping and initializing clipping
INT16 *negonearray = NULL;
INT16 *screenheightarray = NULL;
INT16 *negonearray;
INT16 *screenheightarray;
//
// INITIALIZATION FUNCTIONS
@@ -532,8 +539,8 @@ void R_ClearSprites(void)
visspritecount = numvisiblesprites = clippedvissprites = 0;
}
static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0};
static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0};
static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS];
static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS];
static void R_AllocVisSpriteChunkMemory(UINT32 chunk)
{
@@ -567,16 +574,16 @@ static vissprite_t overflowsprite;
static vissprite_t *R_GetVisSprite(UINT32 num)
{
UINT32 chunk = num >> VISSPRITECHUNKBITS;
UINT32 chunk = num >> VISSPRITECHUNKBITS;
// Allocate chunk if necessary
if (!visspritechunks[chunk])
{
Z_Malloc(sizeof(vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &visspritechunks[chunk]);
R_AllocVisSpriteChunkMemory(chunk);
}
// Allocate chunk if necessary
if (!visspritechunks[chunk])
{
Z_Malloc(sizeof(vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &visspritechunks[chunk]);
R_AllocVisSpriteChunkMemory(chunk);
}
return visspritechunks[chunk] + (num & VISSPRITEINDEXMASK);
return visspritechunks[chunk] + (num & VISSPRITEINDEXMASK);
}
static vissprite_t *R_NewVisSprite(void)
@@ -593,8 +600,8 @@ static vissprite_t *R_NewVisSprite(void)
// Masked means: partly transparent, i.e. stored
// in posts/runs of opaque pixels.
//
INT16 *mfloorclip = NULL;
INT16 *mceilingclip = NULL;
INT16 *mfloorclip;
INT16 *mceilingclip;
fixed_t spryscale = 0, sprtopscreen = 0, sprbotscreen = 0;
fixed_t windowtop = 0, windowbottom = 0;
@@ -723,6 +730,7 @@ static void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column)
dc->texturemid = basetexturemid;
}
// Based off of R_GetLinedefTransTable
transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap)
{
@@ -2510,6 +2518,8 @@ void R_InitDrawNodes(void)
// R_DrawSprite
//
//Fab : 26-04-98:
// NOTE : uses con_clipviewtop, so that when console is on,
// don't draw the part of sprites hidden under the console
static void R_DrawSprite(vissprite_t *spr)
{
mfloorclip = spr->clipbot;
@@ -3056,9 +3066,6 @@ void R_DrawMasked(maskcount_t* masks, INT32 nummasks)
heads = static_cast<drawnode_t*>(calloc(nummasks, sizeof(drawnode_t)));
if (!heads)
I_Error("R_DrawMasked: No more free memory\n");
for (i = 0; i < nummasks; i++)
{
heads[i].next = heads[i].prev = &heads[i];
+15 -35
View File
@@ -80,7 +80,11 @@ consvar_t cv_accuratefps = {"fpssampling", "1", CV_SAVE, accuratefps_cons_t, NUL
// SCREEN VARIABLES
// =========================================================================
static void SCR_SetDrawFuncs(enum columncontext_e _columncontext)
UINT8 *scr_borderpatch; // flat used to fill the reduced view borders set at ST_Init()
// =========================================================================
static void SCR_SetDrawFuncs(void)
{
//
// setup the right draw routines
@@ -99,27 +103,13 @@ static void SCR_SetDrawFuncs(enum columncontext_e _columncontext)
spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan;
spanfuncs[SPANDRAWFUNC_TILTEDFOG] = R_DrawFogSpan_Tilted;
if (_columncontext == COLUMNCONTEXT_FLUSH)
{
colfuncs[BASEDRAWFUNC] = R_DrawColumn_Flush;
colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_Flush;
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn_Flush;
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed_Flush;
colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn_Flush;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_Flush;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn_Flush;
}
else
{
colfuncs[BASEDRAWFUNC] = R_DrawColumn;
colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn;
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn;
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed;
colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn;
}
colfuncs[BASEDRAWFUNC] = R_DrawColumn;
colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn;
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn;
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed;
colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn;
colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn;
R_SetColumnFunc(BASEDRAWFUNC);
@@ -141,23 +131,12 @@ void SCR_SetMode(void)
V_SetPalette(0);
SCR_SetDrawFuncs(COLUMNCONTEXT_DIRECT);
SCR_SetDrawFuncs();
// set the apprpriate drawer for the sky (tall or INT16)
setmodeneeded = 0;
}
// used to switch between column buffering and drawing them directly to screen
// our sky "plane" drawer cannot handle the buffer system due to multithreading
// (that would require alot of extra complexity for smth with massive diminishing results)
// Our masked drawing step draws things in a very particular order, which results in alot of flushing to screen
// effectively adding massive overhead due to excessive flushing, so we draw our masked thing directly to screen instead
void R_SetColumnContext(enum columncontext_e _columncontext)
{
columncontext = _columncontext;
SCR_SetDrawFuncs(_columncontext); // set our column drawers
}
void R_SetColumnFunc(size_t id)
{
I_Assert(id < COLDRAWFUNC_MAX);
@@ -319,6 +298,7 @@ void SCR_SetDefaultMode(void)
// Change fullscreen on/off according to cv_fullscreen
void SCR_ChangeFullscreen(void)
{
#ifdef DIRECTFULLSCREEN
I_SetBorderlessWindow(); // Running this here so we can have borderless window at startup
// allow_fullscreen is set by VID_PrepareModeList
@@ -331,8 +311,8 @@ void SCR_ChangeFullscreen(void)
VID_PrepareModeList();
setmodeneeded = VID_GetModeForSize(vid.width, vid.height) + 1;
}
return;
#endif
}
boolean SCR_IsAspectCorrect(INT32 width, INT32 height)
+2 -1
View File
@@ -84,6 +84,8 @@ enum
extern viddef_t vid;
extern INT32 setmodeneeded; // mode number to set if needed, or 0
extern UINT8 *scr_borderpatch; // patch used to fill the view borders
extern consvar_t cv_scr_width, cv_scr_height, cv_renderview, cv_frameskip, cv_fullscreen, cv_vhseffect, cv_shittyscreen;
extern consvar_t cv_parallelsoftware;
extern consvar_t cv_paralleldrawmasked;
@@ -94,7 +96,6 @@ extern consvar_t cv_vidwait;
extern consvar_t cv_votebgscaling;
//void R_SetColumnContext(enum columncontext_e _columncontext); // declared in r_draw!
void R_SetColumnFunc(size_t id);
void R_SetSpanFunc(size_t id);
boolean R_CheckColumnFunc(size_t id);
+2 -2
View File
@@ -45,7 +45,7 @@ MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c
# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
# SUBTRACT RSC /x
@@ -72,7 +72,7 @@ LINK32=link.exe
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c
# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
+2 -2
View File
@@ -6,9 +6,9 @@
<ItemDefinitionGroup>
<ClCompile>
<!-- x86/x64 defines: has specific libraries that ARM does not -->
<PreprocessorDefinitions Condition="'$(Platform)' == 'Win32' OR '$(Platform)' == 'x64'">HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)' == 'Win32' OR '$(Platform)' == 'x64'">HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<!-- ARM defines -->
<PreprocessorDefinitions Condition="'$(Platform)' != 'Win32' AND '$(Platform)' != 'x64'">USE_WGL_SWAP;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)' != 'Win32' AND '$(Platform)' != 'x64'">USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
+18 -10
View File
@@ -1304,7 +1304,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
SDL_DestroyTexture(texture);
}
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height);
texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, height, width);
}
}
@@ -1339,6 +1339,7 @@ void I_UpdateNoBlit(void)
// I_FinishUpdate
//
static SDL_Rect src_rect = { 0, 0, 0, 0 };
static SDL_Rect dst_rect = { 0, 0, 0, 0 };
void I_FinishUpdate(void)
{
@@ -1368,13 +1369,13 @@ void I_FinishUpdate(void)
void *pixels;
int pitch;
SDL_LockTexture(texture, NULL, &pixels, &pitch);
int step = pitch / 4 - vid.width;
int step = pitch / 4 - vid.height;
UINT32 *restrict dst = pixels;
UINT8 *restrict src = vid.screens[0];
UINT32 *restrict palette = localPalette;
for (INT32 y = 0; y < vid.height; y++)
for (INT32 y = 0; y < vid.width; y++)
{
UINT8 *restrict end = src + vid.width;
UINT8 *restrict end = src + vid.height;
do *dst++ = palette[*src++];
while (src < end);
dst += step;
@@ -1382,7 +1383,8 @@ void I_FinishUpdate(void)
SDL_UnlockTexture(texture);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, &src_rect, NULL);
//SDL_RenderCopy(renderer, texture, &src_rect, NULL);
SDL_RenderCopyEx(renderer, texture, NULL, &dst_rect, 90.0, NULL, SDL_FLIP_VERTICAL);
SDL_RenderPresent(renderer);
}
#ifdef HWRENDER
@@ -1413,18 +1415,17 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale)
{
if (rendermode != render_soft)
I_Error("I_ReadScreen: called while in non-software mode");
else if (scale == 1)
VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.width, vid.width);
else
{
UINT8 * restrict source = vid.screens[0];
uintptr_t w = vid.width/scale*scale, h = vid.height/scale*scale;
// size_t saves a lea + movsxd over INT32. mind your types!
// uintptr_t is even better since it's guaranteed to be the size of a pointer
for (uintptr_t y = 0; y < h; y += scale)
for (uintptr_t x = 0; x < w; x += scale)
*scr++ = source[y*vid.width + x];
*scr++ = source[x*vid.height + y];
}
}
@@ -1562,8 +1563,15 @@ INT32 VID_SetMode(INT32 modeNum)
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
src_rect.w = vid.width;
src_rect.h = vid.height;
src_rect.w = vid.height;
src_rect.h = vid.width;
dst_rect.x = (vid.width - vid.height) / 2;
dst_rect.y = (vid.height - vid.width) / 2;
dst_rect.w = vid.height;
dst_rect.h = vid.width;
refresh_rate = VID_GetRefreshRate();
+6 -2
View File
@@ -219,6 +219,10 @@ void ST_UnloadGraphics(void)
void ST_LoadGraphics(void)
{
// SRB2 border patch
//st_borderpatchnum = W_GetNumForName("GFZFLR01");
//scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX);
// the original Doom uses 'STF' as base name for all face graphics
// Graue 04-08-2004: face/name graphics are now indexed by skins
// but load them in R_AddSkins, that gets called
@@ -790,7 +794,7 @@ void ST_Drawer(void)
LUA_HUD_DrawList(luahuddrawlist_game[i]);
// draw Midnight Channel's overlay ontop
if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff.
if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff.
ST_MayonakaStatic();
}
@@ -798,7 +802,7 @@ void ST_Drawer(void)
if (timeinmap < 15)
{
if (timeinmap <= 5)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 120); // Pure white on first few frames, to hide SRB2's awful level load artifacts
V_DrawFill(0,0,BASEVIDWIDTH,BASEVIDHEIGHT,120); // Pure white on first few frames, to hide SRB2's awful level load artifacts
else
V_DrawFadeScreen(120, 15-timeinmap); // Then gradually fade out from there
}
+199 -151
View File
@@ -614,9 +614,9 @@ static void CV_constextsize_OnChange(void)
// --------------------------------------------------------------------------
void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes)
{
if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)width)
if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)height)
{
size_t i = srcrowbytes * height;
size_t i = srcrowbytes * width;
#if defined(__SSE__)
while (i >= 16)
{
@@ -631,9 +631,9 @@ void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr,
}
else
{
while (height--)
while (width--)
{
M_Memcpy(destptr, srcptr, width);
M_Memcpy(destptr, srcptr, height);
destptr += destrowbytes;
srcptr += srcrowbytes;
@@ -663,7 +663,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
fixed_t col, ofs, colfrac, rowfrac, fdup, vdup;
INT32 dup;
const column_t *column;
UINT8 *desttop, *dest, *deststart, *destend;
UINT8 *desttop, *dest/*, *deststart, *destend*/;
const UINT8 *source, *deststop;
fixed_t pwidth; // patch width
fixed_t offx = 0; // x offset
@@ -791,13 +791,10 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
if (!desttop)
return;
deststop = desttop + vid.width * vid.height;
if (scrn & V_NOSCALESTART)
{
x >>= FRACBITS;
y >>= FRACBITS;
desttop += (y*vid.width) + x;
}
else
{
@@ -843,9 +840,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
y += (vid.height - (BASEVIDHEIGHT * dup)) / 2;
}
}
desttop += (y*vid.width) + x;
}
desttop += (x*vid.height) + y;
if (pscale != FRACUNIT) // scale width properly
{
@@ -857,29 +853,29 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
else
pwidth = patch->width * dup;
deststart = desttop;
destend = desttop + pwidth;
//deststart = desttop;
//destend = desttop + pwidth*vid.height;
const INT32 stride = vid.width;
for (col = 0; (col>>FRACBITS) < patch->width; col += colfrac, ++offx, desttop++)
for (col = 0; (col>>FRACBITS) < patch->width; col += colfrac, ++offx, desttop += vid.height)
{
INT32 topdelta, prevdelta = -1;
if (scrn & V_FLIP) // offx is measured from right edge instead of left
{
if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
break;
if (x+pwidth-offx >= stride) // don't draw off the right of the screen (WRAP PREVENTION)
if (x+pwidth-offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
continue;
}
else
{
if (x+offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
continue;
if (x+offx >= stride) // don't draw off the right of the screen (WRAP PREVENTION)
if (x+offx >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
break;
}
column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS]));
INT32 realcol = (scrn & V_FLIP) ? ((patch->width-(col>>FRACBITS)-1)<<FRACBITS) : col;
column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[realcol>>FRACBITS]));
switch (patchdrawtype)
{
@@ -892,15 +888,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = source[ofs>>FRACBITS];
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -915,15 +912,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = *(v_colormap + source[ofs>>FRACBITS]);
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -938,15 +936,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff));
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -961,15 +960,16 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup))*stride;
dest += FixedInt(FixedMul(topdelta<<FRACBITS,vdup));
for (ofs = 0; dest < deststop && (ofs>>FRACBITS) < column->length; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + ((x + offx)*vid.height);
deststop = col_start + vid.height;
for (ofs = 0; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = *(v_translevel + (((*(v_colormap + source[ofs>>FRACBITS]))<<8)&0xff00) + (*dest&0xff));
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -1039,13 +1039,10 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
if (!desttop)
return;
deststop = desttop + vid.width * vid.height;
if (scrn & V_NOSCALESTART)
{
x >>= FRACBITS;
y >>= FRACBITS;
desttop += (y*vid.width) + x;
}
else
{
@@ -1079,20 +1076,18 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
y += (vid.height - (BASEVIDHEIGHT * vid.dup)) / 2;
}
}
desttop += (y*vid.width) + x;
}
const INT32 stride = vid.width;
desttop += (y*vid.width) + x;
for (col = sx<<FRACBITS; (col>>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++)
for (col = sx<<FRACBITS; (col>>FRACBITS) < patch->width && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop += vid.height)
{
INT32 topdelta, prevdelta = -1;
if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION)
continue;
if (x >= stride) // don't draw off the right of the screen (WRAP PREVENTION)
if (x >= vid.width) // don't draw off the right of the screen (WRAP PREVENTION)
break;
column = (const column_t *)((const UINT8 *)(patch->columns) + (patch->columnofs[col>>FRACBITS]));
@@ -1110,17 +1105,20 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
dest = desttop;
if (topdelta-sy > 0)
{
dest += FixedInt(FixedMul((topdelta-sy)<<FRACBITS,fdup))*stride;
dest += FixedInt(FixedMul((topdelta-sy)<<FRACBITS,fdup));
ofs = 0;
}
else
ofs = (sy-topdelta)<<FRACBITS;
for (; dest < deststop && (ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + (x*vid.height);
deststop = col_start + vid.height;
for (; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = source[ofs>>FRACBITS];
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -1137,17 +1135,20 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_
dest = desttop;
if (topdelta-sy > 0)
{
dest += FixedInt(FixedMul((topdelta-sy)<<FRACBITS,fdup))*stride;
dest += FixedInt(FixedMul((topdelta-sy)<<FRACBITS,fdup));
ofs = 0;
}
else
ofs = (sy-topdelta)<<FRACBITS;
for (; dest < deststop && (ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac)
UINT8 *col_start = vid.screens[0] + (x*vid.height);
deststop = col_start + vid.height;
for (; dest < deststop && (size_t)(ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac)
{
if (dest >= vid.screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION)
if (dest >= col_start) // don't draw off the top of the screen (CRASH PREVENTION)
*dest = *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff));
dest += stride;
dest++;
}
column = (const column_t *)((const UINT8 *)column + column->length + 4);
}
@@ -1189,8 +1190,8 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const
I_Error("Bad V_DrawBlock");
#endif
dest = vid.screens[scrn] + y*vid.width + x;
deststop = vid.screens[scrn] + vid.width * vid.height;
dest = vid.screens[scrn] + x*vid.height + y;
deststop = vid.screens[scrn] + vid.height * vid.width;
while (height--)
{
@@ -1209,7 +1210,7 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const
// alug: now with translucency support X)
void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
{
UINT8 *dest;
UINT8 *dest, *desttop;
const UINT8 *deststop;
UINT32 alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT);
@@ -1285,8 +1286,8 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
if (y + h > vid.height)
h = vid.height-y;
dest = vid.screens[0] + y*vid.width + x;
deststop = vid.screens[0] + vid.width * vid.height;
dest = desttop = vid.screens[0] + x*vid.height + y;
deststop = vid.screens[0] + vid.height * vid.width;
if (alphalevel)
{
@@ -1312,16 +1313,31 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
if (alphalevel)
{
const UINT8 *fadetable = ((UINT8 *)transtables + ((alphalevel-1)<<FF_TRANSSHIFT) + (c*256));
for (;(--h >= 0) && dest < deststop; dest += vid.width)
for (;(--h >= 0) && desttop < deststop; desttop++)
{
for (x = 0; x < w; x++)
dest[x] = fadetable[dest[x]];
dest = desttop;
UINT8 *row_end = dest + (w * vid.height);
while (dest < row_end)
{
*dest = fadetable[*dest];
dest += vid.height;
}
}
}
else
{
for (;(--h >= 0) && dest < deststop; dest += vid.width)
memset(dest, c, w);
for (;(--h >= 0) && desttop < deststop; desttop++)
{
dest = desttop;
UINT8 *row_end = dest + (w * vid.height);
while (dest < row_end)
{
*dest = c;
dest += vid.height;
}
}
}
}
@@ -1367,8 +1383,8 @@ static UINT32 V_GetHWConsBackColor(void)
void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
{
UINT8 *dest;
INT32 u, v;
UINT8 *dest, *desttop;
INT32 v;
UINT32 alphalevel = 0;
if (rendermode == render_none)
@@ -1435,7 +1451,7 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
if (y + h > vid.height)
h = vid.height-y;
dest = vid.screens[0] + y*vid.width + x;
dest = desttop = vid.screens[0] + x*vid.height + y;
if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT)))
{
@@ -1460,11 +1476,14 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
if (!alphalevel)
{
for (v = 0; v < h; v++, dest += vid.width)
for (v = 0; v < h; v++, desttop++)
{
for (u = 0; u < w; u++)
dest = desttop;
UINT8 *row_end = dest + w*vid.height;
while (dest < row_end)
{
dest[u] = consolebgmap[dest[u]];
*dest = consolebgmap[*dest];
dest += vid.height;
}
}
}
@@ -1475,11 +1494,14 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
w = clip(w,vid.width);
h = clip(h,vid.height);
#undef clip
for (v = 0; v < h; v++, dest += vid.width)
for (v = 0; v < h; v++, desttop++)
{
for (u = 0; u < w; u++)
dest = desttop;
UINT8 *row_end = dest + w*vid.height;
while (dest < row_end)
{
dest[u] = fadetable[consolebgmap[dest[u]]];
*dest = fadetable[consolebgmap[*dest]];
dest += vid.height;
}
}
}
@@ -1494,7 +1516,8 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
//
void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c)
{
UINT8 *dest;
UINT8 *dest, *desttop;
const UINT8 *deststop;
INT32 w, h, wait = 0;
@@ -1569,19 +1592,28 @@ void V_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 c)
if (h > w)
h = w;
dest = vid.screens[0] + y*vid.width + x;
deststop = vid.screens[0] + vid.width * vid.height;
dest = desttop = vid.screens[0] + x*vid.height + y;
deststop = vid.screens[0] + vid.height * vid.width;
c &= 255;
for (;(--h >= 0) && dest < deststop; dest += vid.width)
for (;(--h >= 0) && desttop < deststop; desttop++)
{
memset(dest, c, w);
dest = desttop;
UINT8 *row_end = dest + (w * vid.height);
while (dest < row_end)
{
*dest = c;
dest += vid.height;
}
if (wait)
wait--;
else
w--;
}
}
//
@@ -1592,7 +1624,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
INT32 u, v;
fixed_t dx, dy, xfrac, yfrac;
const UINT8 *src, *deststop;
UINT8 *flat, *dest;
UINT8 *flat, *dest, *desttop;
size_t size, lflatsize, flatshift;
#ifdef HWRENDER
@@ -1639,7 +1671,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
flat = W_CacheLumpNum(flatnum, PU_CACHE);
dest = vid.screens[0] + y*vid.dup*vid.width + x*vid.dup;
dest = desttop = vid.screens[0] + y*vid.dup*vid.width + x*vid.dup;
deststop = vid.screens[0] + vid.width * vid.height;
// from V_DrawScaledPatch
@@ -1663,15 +1695,18 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum)
dy = FixedDiv(FRACUNIT, vid.dup<<(FRACBITS-2));
yfrac = 0;
for (v = 0; v < h; v++, dest += vid.width)
for (v = 0; v < h; v++, desttop++)
{
xfrac = 0;
src = flat + (((yfrac>>FRACBITS) & (lflatsize - 1)) << flatshift);
dest = desttop;
for (u = 0; u < w; u++)
{
if (&dest[u] > deststop)
if (dest > deststop)
return;
dest[u] = src[(xfrac>>FRACBITS)&(lflatsize-1)];
*dest = src[(xfrac>>FRACBITS)&(lflatsize-1)];
dest += vid.height;
xfrac += dx;
}
yfrac += dy;
@@ -1743,7 +1778,7 @@ void V_DrawVhsEffect(boolean rewind)
UINT8 *buf = vid.screens[0], *tmp = vid.screens[4];
UINT16 y;
UINT32 x, pos = 0;
INT32 x;
UINT8 *normalmapstart = ((UINT8 *)transtables + (8<<FF_TRANSSHIFT|(19<<8)));
#ifdef HQ_VHS
@@ -1777,32 +1812,40 @@ void V_DrawVhsEffect(boolean rewind)
}
#endif
for (y = 0; y < vid.height; y+=2)
// Since we go through columns now instead of rows, we need to keep same random offset values for each row
// Don't need a random value for each row, just a bunch of values to cycle through will do
#define ROWOFFSLEN 128
SINT8 rowoffs[ROWOFFSLEN];
for (y = 0; y < ROWOFFSLEN; y++)
rowoffs[y] = M_RandomKey(vid.dup<<1);
for (x = 0; x < vid.width; ++x)
{
thismapstart = normalmapstart;
offs = 0;
if (y >= uby && y < uby+barsize)
for (y = 0; y < vid.height; y++)
{
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs += updistort * 2.0f * min(y-uby, uby+barsize-y) / barsize;
}
offs = rowoffs[y/2 % ROWOFFSLEN];
if (y >= dby && y < dby+barsize)
{
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs -= downdistort * 2.0f * min(y-dby, dby+barsize-y) / barsize;
}
thismapstart = normalmapstart;
offs += M_RandomKey(vid.dup<<1);
if (y >= uby && y < uby+barsize)
{
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs += updistort * 2.0f * min(y-uby, uby+barsize-y) / barsize;
}
// lazy way to avoid crashes
if ((y == 0 && offs < 0) || (y >= vid.height-2 && offs > 0))
offs = 0;
if (y >= dby && y < dby+barsize)
{
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs -= downdistort * 2.0f * min(y-dby, dby+barsize-y) / barsize;
}
for (x = min(pos+(size_t)vid.width*2, (size_t)vid.width*vid.height); pos < x; pos++)
{
tmp[pos] = thismapstart[buf[pos+offs]];
INT32 pos = x*vid.height + y;
INT32 offspos = pos + offs*vid.height;
if (offspos < 0 || offspos > vid.width*vid.height)
offspos = pos;
tmp[pos] = thismapstart[buf[offspos]];
#ifdef HQ_VHS
tmp[pos] = tmapstart[buf[pos]<<8 | tmp[pos]];
#endif
@@ -1810,6 +1853,7 @@ void V_DrawVhsEffect(boolean rewind)
}
memcpy(buf, tmp, vid.width*vid.height);
#undef ROWOFFSLEN
}
//
@@ -1837,7 +1881,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
: ((color & 0xFF00) // Color is not palette index?
? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade.
: ((UINT8 *)transtables + ((9-strength)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade.
const UINT8 *deststop = vid.screens[0] + vid.width * vid.height;
const UINT8 *deststop = vid.screens[0] + vid.height * vid.width;
UINT8 *buf = vid.screens[0];
// heavily simplified -- we don't need to know x or y
@@ -1849,7 +1893,7 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
// Simple translucency with one color, over a set number of lines starting from the top.
void V_DrawFadeConsBack(INT32 plines)
{
UINT8 *deststop, *buf;
UINT8 *deststop, *dest, *desttop;
#ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode == render_opengl)
@@ -1862,9 +1906,18 @@ void V_DrawFadeConsBack(INT32 plines)
// heavily simplified -- we don't need to know x or y position,
// just the stop position
deststop = vid.screens[0] + vid.width * min(plines, vid.height);
for (buf = vid.screens[0]; buf < deststop; ++buf)
*buf = consolebgmap[*buf];
dest = desttop = vid.screens[0];
deststop = vid.screens[0] + min(plines, vid.height);
for (; desttop < deststop; desttop++)
{
dest = desttop;
UINT8 *row_end = dest + (vid.width * vid.height);
while (dest < row_end)
{
*dest = consolebgmap[*dest];
dest += vid.height;
}
}
}
// Gets string colormap, used for 0x80 color codes
@@ -3094,9 +3147,6 @@ INT32 V_SubStringWidth(const char *string, INT32 length, INT32 option)
INT32 spacewidth = 4, charwidth = 0;
ssize_t i;
if (!string)
return 0;
if (length < 0)
length = strlen(string);
@@ -3139,9 +3189,6 @@ INT32 V_SmallSubStringWidth(const char *string, INT32 length, INT32 option)
INT32 spacewidth = 2, charwidth = 0;
ssize_t i;
if (!string)
return 0;
if (length < 0)
length = strlen(string);
@@ -3182,14 +3229,9 @@ INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option)
{
INT32 c, w = 0;
INT32 spacewidth = 2, charwidth = 0;
boolean lowercase;
boolean lowercase = (option & V_ALLOWLOWERCASE);
ssize_t i;
if (!string)
return 0;
lowercase = (option & V_ALLOWLOWERCASE);
if (length < 0)
length = strlen(string);
@@ -3244,9 +3286,6 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option)
INT32 spacewidth = 4, charwidth = 0;
INT32 i;
if (!string)
return 0;
switch (option & V_SPACINGMASK)
{
case V_MONOSPACE:
@@ -3613,7 +3652,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
if (thiscam->postimg & POSTIMG_WATER)
{
INT32 y;
INT32 y, x;
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic
angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK;
INT32 newpix;
@@ -3623,7 +3662,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
for (y = yoffset; y < yoffset+viewheight; y++)
{
sine = (FINESINE(disStart)*5)>>FRACBITS;
newpix = abs(sine);
/*newpix = abs(sine);
if (sine < 0)
{
@@ -3646,7 +3685,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)];
newpix--;
}
}
}*/
/*
Unoptimized version
@@ -3662,6 +3701,18 @@ void V_DoPostProcessor(INT32 view, INT32 param)
tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}*/
for (x = 0; x < vid.width; x++)
{
newpix = (x + sine);
if (newpix < 0)
newpix = 0;
else if (newpix >= vid.width)
newpix = vid.width-1;
tmpscr[y + x*vid.height] = srcscr[y+newpix*vid.height]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]);
}
disStart += 22;//the offset into the displacement map, increment each game loop
disStart &= FINEMASK; //clip it to FINEMASK
}
@@ -3672,7 +3723,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
}
else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave
{
INT32 y;
INT32 y, x;
// Make sure table is built
if (heatshifter == NULL || lastheight != viewheight)
@@ -3697,11 +3748,12 @@ void V_DoPostProcessor(INT32 view, INT32 param)
if (heatshifter[heatindex[view]++])
{
// Shift this row of pixels to the right by 2
tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset];
M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup);
tmpscr[y] = srcscr[y];
for (x = vid.dup; x < vid.width; x++)
tmpscr[y+x*vid.height] = srcscr[y+(x-vid.dup)*vid.height];
}
else
M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
else for (x = 0; x < vid.width; x++)
tmpscr[y+x*vid.height] = srcscr[y+x*vid.height];
heatindex[view] %= viewheight;
}
@@ -3733,10 +3785,11 @@ void V_DoPostProcessor(INT32 view, INT32 param)
if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down
{
INT32 y, y2;
INT32 x, y, y2;
for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--)
M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
for (x = xoffset; x < xoffset+viewwidth; x++)
for (y = yoffset, y2 = yoffset+(viewheight-1); y < yoffset+viewheight; y++, y2--)
tmpscr[x*vid.height + y2] = srcscr[x*vid.height + y];
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
@@ -3744,11 +3797,10 @@ void V_DoPostProcessor(INT32 view, INT32 param)
}
else if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) // Flip the screen on the x axis
{
INT32 y, x, x2;
INT32 x, x2;
for (y = yoffset; y < yoffset+viewheight; y++)
for (x = xoffset, x2 = xoffset+(viewwidth-1); x < xoffset+viewwidth; x++, x2--)
tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x];
for (x = xoffset, x2 = xoffset+viewwidth - 1; x < xoffset+viewwidth; x++, x2--)
M_Memcpy(&tmpscr[(x2*vid.height)+yoffset], &srcscr[(x*vid.height)+yoffset], viewheight);
UINT8 *tmp = tmpscr;
tmpscr = srcscr;
@@ -3768,7 +3820,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
}
VID_BlitLinearScreen(srcscr+vid.width*yoffset+xoffset, tmpscr+vid.width*yoffset+xoffset,
viewwidth, viewheight, vid.width, vid.width);
viewwidth, viewheight, vid.height, vid.height);
#endif
}
@@ -3824,19 +3876,15 @@ UINT8 GetColorLUTDirect(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b)
void V_Init(void)
{
INT32 i;
INT32 screensize = vid.width * vid.height;
INT32 screensize = vid.height * vid.width;
for (i = 0; i < NUMSCREENS; i++)
{
if (vid.screens[i])
{
#if defined(__SSE__)
aligned_free(vid.screens[i]);
aligned_free(vid.screens[i]);
#else
free(vid.screens[i]);
free(vid.screens[i]);
#endif
}
vid.screens[i] = NULL;
}
-1
View File
@@ -1 +0,0 @@
win_dbg.c
+1 -1
View File
@@ -450,7 +450,7 @@ void Y_IntermissionDrawer(void)
else
{
if (rendermode == render_soft)
VID_BlitLinearScreen(vid.screens[1], vid.screens[0], vid.width, vid.height, vid.width, vid.width);
VID_BlitLinearScreen(vid.screens[1], vid.screens[0], vid.width, vid.height, vid.height, vid.height);
#ifdef HWRENDER
else if (rendermode == render_opengl)
HWR_DrawIntermissionBG();