diff --git a/src/doomdef.h b/src/doomdef.h index df68f4899..5161318c9 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -149,8 +149,8 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Galaxy - Saturn v5 " -#define VERSIONSTRINGW L"Galaxy - Saturn v5" +#define VERSIONSTRING "Saturn v5.3 " +#define VERSIONSTRINGW L"Saturn v5.3" // Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates! // And change CMakeLists.txt (not src/, but in root), for CMake users! // AND appveyor.yml, for the build bots! diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 793c3f26c..971dd67fd 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -498,7 +498,7 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) if (!pat->mipmap) break; - // No colormap mipmap either. + // No colormap mipmaps either. if (!pat->mipmap->nextcolormap) break; diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 4356139aa..4146fa1da 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -36,6 +36,8 @@ typedef struct gr_vissprite_s //lumpnum_t patchlumpnum; float spritexscale, spriteyscale; float spritexoffset, spriteyoffset; + UINT32 renderflags; + UINT8 rotateflags; GLPatch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 26fd29222..96104d20b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4954,6 +4954,7 @@ void HWR_ProjectSprite(mobj_t *thing) spritexscale = FIXED_TO_FLOAT(interp.spritexscale); spriteyscale = FIXED_TO_FLOAT(interp.spriteyscale); + // transform the origin point tr_x = FIXED_TO_FLOAT(interp.x) - gr_viewx; tr_y = FIXED_TO_FLOAT(interp.y) - gr_viewy; @@ -5080,8 +5081,7 @@ void HWR_ProjectSprite(mobj_t *thing) spr_height = rotsprite->height << FRACBITS; spr_offset = rotsprite->leftoffset << FRACBITS; spr_topoffset = rotsprite->topoffset << FRACBITS; - spr_topoffset += FEETADJUST; - + spr_topoffset += FEETADJUST; // flip -> rotate, not rotate -> flip flip = 0; } diff --git a/src/k_kart.c b/src/k_kart.c index 8364ced70..8e498ed84 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6228,19 +6228,19 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } if (cv_gravstretch.value > 13107) - K_StretchPlayerGravity(player); + K_StretchPlayerGravity(player); else { - player->mo->spritexscale = player->mo->realxscale; - player->mo->spriteyscale = player->mo->realyscale; + player->mo->spritexscale = player->mo->realxscale; + player->mo->spriteyscale = player->mo->realyscale; } boolean usedist = false; if (cv_sloperolldist.value > 0) - usedist = true; + usedist = true; if (cv_sloperoll.value == 1) - K_RollPlayerBySlopes(player, usedist); + K_RollPlayerBySlopes(player, usedist); else - player->mo->sloperoll = FixedAngle(0); + player->mo->sloperoll = FixedAngle(0); // Quick Turning diff --git a/src/p_mobj.c b/src/p_mobj.c index 5f3cc3b0f..8d923b30f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9558,7 +9558,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->scalespeed = mapobjectscale/12; } - // Rendering-related things + // Sprite rendering mobj->realxscale = mobj->realyscale = mobj->scale; mobj->spritexscale = mobj->realxscale; mobj->spriteyscale = mobj->realyscale; @@ -10015,12 +10015,12 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) mobj->scalespeed = mapobjectscale/12; } - // Rendering-related things - mobj->spritexscale = mobj->spriteyscale = mobj->scale; + // Sprite rendering + mobj->realxscale = mobj->realyscale = mobj->scale; + mobj->spritexscale = mobj->realxscale; + mobj->spriteyscale = mobj->realyscale; mobj->spritexoffset = mobj->spriteyoffset = 0; - - P_SetScale(mobj, mobj->destscale); - + // set subsector and/or block links P_SetThingPosition(mobj); I_Assert(mobj->subsector != NULL); diff --git a/src/p_mobj.h b/src/p_mobj.h index 6360d21b8..872c9dd5e 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -283,9 +283,9 @@ typedef struct mobj_s // More drawing info: to determine current sprite. angle_t angle; // orientation - angle_t rollangle; angle_t old_angle; // orientation interpolation - angle_t old_angle2; + angle_t old_angle2; + angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h UINT16 anim_duration; // for FF_ANIMATE states @@ -420,9 +420,9 @@ typedef struct precipmobj_s // More drawing info: to determine current sprite. angle_t angle; // orientation - angle_t rollangle; angle_t old_angle; // orientation interpolation angle_t old_angle2; + angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h UINT16 anim_duration; // for FF_ANIMATE states diff --git a/src/r_defs.h b/src/r_defs.h index b2d2e5e5a..559e3646b 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -646,12 +646,8 @@ typedef enum typedef struct { INT32 angles; - void **patches; //2.2.9 system + void **patches; } rotsprite_t; -#endif/*ROTSPRITE*/ - -#if defined(_MSC_VER) -#pragma pack(1) #endif // Patches. @@ -667,12 +663,29 @@ typedef struct INT16 leftoffset; // pixels to the left of origin INT16 topoffset; // pixels below the origin INT32 columnofs[8]; // only [width] used + UINT8 *columns; // Software column data // the [0] is &columnofs[width] + void *hardware; // OpenGL patch, allocated whenever necessary + #ifdef ROTSPRITE rotsprite_t *rotated; // Rotated patches #endif -} ATTRPACK patch_t; +} patch_t; + +#if defined(_MSC_VER) +#pragma pack(1) +#endif + +typedef struct +{ + INT16 width; // bounding box size + INT16 height; + INT16 leftoffset; // pixels to the left of origin + INT16 topoffset; // pixels below the origin + INT32 columnofs[8]; // only [width] used + // the [0] is &columnofs[width] +} ATTRPACK softwarepatch_t; #ifdef _MSC_VER #pragma warning(disable : 4200) diff --git a/src/r_fps.c b/src/r_fps.c index 46cb4a63e..805554a09 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -295,12 +295,12 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); - + // Sprite offsets are not interpolated until we have a way to interpolate them explicitly in Lua. // It seems existing mods visually break more often than not if it is interpolated. out->spritexoffset = mobj->spritexoffset; out->spriteyoffset = mobj->spriteyoffset; - + out->subsector = R_PointInSubsector(out->x, out->y); if (mobj->player) @@ -356,7 +356,7 @@ static void AddInterpolator(levelinterpolator_t* interpolator) { levelinterpolators_size *= 2; } - + levelinterpolators = Z_ReallocAlign( (void*) levelinterpolators, sizeof(levelinterpolator_t*) * levelinterpolators_size, @@ -604,7 +604,7 @@ void R_RestoreLevelInterpolators(void) for (i = 0; i < levelinterpolators_len; i++) { levelinterpolator_t *interp = levelinterpolators[i]; - + switch (interp->type) { case LVLINTERP_SectorPlane: @@ -659,7 +659,7 @@ void R_DestroyLevelInterpolators(thinker_t *thinker) for (i = 0; i < levelinterpolators_len; i++) { levelinterpolator_t *interp = levelinterpolators[i]; - + if (interp->thinker == thinker) { // Swap the tail of the level interpolators to this spot diff --git a/src/r_main.c b/src/r_main.c index f639ab0ea..9a73b14a7 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1066,6 +1066,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) INT32 side, i; size_t nodenum; subsector_t *ret; + seg_t *seg; // single subsector is a special case if (numnodes == 0) diff --git a/src/r_patch.c b/src/r_patch.c index fac05b664..881ca41de 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -48,8 +48,8 @@ boolean R_CheckIfPatch(lumpnum_t lump) patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); - width = SHORT(patch->width); - height = SHORT(patch->height); + width = patch->width; + height = patch->height; result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4)); @@ -996,12 +996,10 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle } - ox = (newwidth / 2) + (leftoffset - xpivot); oy = (newheight / 2) + (patch->topoffset - ypivot); - width = (maxx - minx); - height = (maxy - miny); - + width = (maxx+1 - minx); + height = (maxy+1 - miny); if ((unsigned)(width * height) > size) { diff --git a/src/r_things.c b/src/r_things.c index ec3cf24cb..19cecc30a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -140,7 +140,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch if (maxframe ==(size_t)-1 || frame > maxframe) maxframe = frame; - + // rotsprite #ifdef ROTSPRITE for (r = 0; r < 16; r++) @@ -682,8 +682,10 @@ static vissprite_t *R_GetVisSprite(UINT32 num) static vissprite_t *R_NewVisSprite(void) { - if (visspritecount == MAXVISSPRITES) + if (visspritecount == MAXVISSPRITES) { + //CONS_Alert(CONS_ERROR, M_GetText("R_NewVisSprite: too many vissprites requested (maximum is %i)\n"), MAXVISSPRITES); return &overflowsprite; + } return R_GetVisSprite(visspritecount++); } @@ -827,9 +829,7 @@ static void R_DrawVisSprite(vissprite_t *vis) { column_t *column; void (*localcolfunc)(column_t *); -//#ifdef RANGECHECK INT32 texturecolumn; -//#endif INT32 pwidth; fixed_t frac; patch_t *patch = vis->patch; @@ -946,7 +946,7 @@ static void R_DrawVisSprite(vissprite_t *vis) if (!(vis->scalestep)) { sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - sprtopscreen += vis->shear.tan * vis->shear.offset; + //sprtopscreen += vis->shear.tan * vis->shear.offset; dc_iscale = FixedDiv(FRACUNIT, vis->scale); } @@ -961,8 +961,8 @@ static void R_DrawVisSprite(vissprite_t *vis) if (vis->x2 >= vid.width) vis->x2 = vid.width-1; - - lengthcol = patch->height; + + lengthcol = SHORT(patch->height); #if 1 // Something is occasionally setting 1px-wide sprites whose frac is exactly the width of the sprite, causing crashes due to @@ -979,7 +979,7 @@ static void R_DrawVisSprite(vissprite_t *vis) fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); if (vis->scalestep) // currently papersprites only { - + #ifndef RANGECHECK if ((frac>>FRACBITS) < 0 || (frac>>FRACBITS) >= SHORT(patch->width)) // if this doesn't work i'm removing papersprites break; @@ -1350,7 +1350,7 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) this_scale = FixedMul(this_scale, ((skin_t *)thing->skin)->highresscale); - + spr_width = spritecachedinfo[lump].width; spr_height = spritecachedinfo[lump].height; spr_offset = spritecachedinfo[lump].offset; @@ -1360,11 +1360,12 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->player) { - sliptiderollangle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), ((cv_sliptideroll.value == 1) ? thing->player->sliproll*(thing->player->sliptidemem) : 0)); + sliptiderollangle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), ((cv_sloperoll.value == 1) ? thing->player->sliproll*(thing->player->sliptidemem) : 0)); } else sliptiderollangle = 0; + if ((thing->rollangle)||(thing->sloperoll)||sliptiderollangle) { if (thing->player) rollsum = (thing->rollangle) + (thing->sloperoll) + sliptiderollangle; @@ -1373,7 +1374,7 @@ static void R_ProjectSprite(mobj_t *thing) rollangle = R_GetRollAngle(rollsum); rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); - + if (rotsprite != NULL) { spr_width = rotsprite->width << FRACBITS; @@ -1381,7 +1382,7 @@ static void R_ProjectSprite(mobj_t *thing) spr_offset = rotsprite->leftoffset << FRACBITS; spr_topoffset = rotsprite->topoffset << FRACBITS; spr_topoffset += FEETADJUST; - + // flip -> rotate, not rotate -> flip flip = 0; } @@ -1409,7 +1410,7 @@ static void R_ProjectSprite(mobj_t *thing) spr_offset += interp.spritexoffset * flipoffset; spr_topoffset += interp.spriteyoffset * flipoffset; } - + if (flip) offset = spr_offset - spr_width; else @@ -1471,6 +1472,7 @@ static void R_ProjectSprite(mobj_t *thing) scalestep = (yscale2 - yscale)/(x2 - x1); scalestep = scalestep ? scalestep : 1; + // The following two are alternate sorting methods which might be more applicable in some circumstances. TODO - maybe enable via MF2? // sortscale = max(yscale, yscale2); @@ -1546,19 +1548,22 @@ static void R_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { + fixed_t top = gzt; + fixed_t bottom = interp.z; + if (viewz < sectors[phs].floorheight ? - thing->z >= sectors[heightsec].floorheight : - gzt < sectors[heightsec].floorheight) + bottom >= sectors[heightsec].floorheight : + top < sectors[heightsec].floorheight) return; if (viewz > sectors[phs].ceilingheight ? - gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - thing->z >= sectors[heightsec].ceilingheight) + top < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : + bottom >= sectors[heightsec].ceilingheight) return; } // store information in a vissprite vis = R_NewVisSprite(); - //vis->renderflags = thing->renderflags; + vis->renderflags = thing->renderflags; vis->heightsec = heightsec; //SoM: 3/17/2000 vis->mobjflags = thing->flags; vis->scale = yscale; //<x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - + vis->sector = thing->subsector->sector; vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS); vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS); @@ -1629,7 +1634,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->thingscale = interp.scale; //Fab: lumppat is the lump number of the patch to use, this is different - // than lumpid for sprites-in-pwad : the graphics are patched + // than lumpid for sprites-in-pwad : the graphics are patched #ifdef ROTSPRITE if (rotsprite != NULL) vis->patch = rotsprite; @@ -2678,14 +2683,14 @@ void R_ClipSprites(void) // e6y: ~13% of speed improvement on sunder.wad map10 if (ds->x1 < cx) { - drawsegs_xranges[1].items[drawsegs_xranges[1].count] = + drawsegs_xranges[1].items[drawsegs_xranges[1].count] = drawsegs_xranges[0].items[drawsegs_xranges[0].count]; drawsegs_xranges[1].count++; } if (ds->x2 >= cx) { - drawsegs_xranges[2].items[drawsegs_xranges[2].count] = + drawsegs_xranges[2].items[drawsegs_xranges[2].count] = drawsegs_xranges[0].items[drawsegs_xranges[0].count]; drawsegs_xranges[2].count++; } @@ -3013,7 +3018,7 @@ static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what //return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==); - + switch (cv_skinselectgridsort.value) { case SKINMENUSORT_REALNAME: @@ -3397,7 +3402,7 @@ next_token: } sortSkinGrid(); - + return; } diff --git a/src/r_things.h b/src/r_things.h index 6396b5237..22c975daa 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -120,7 +120,7 @@ typedef struct vissprite_s struct vissprite_s *prev; struct vissprite_s *next; - mobj_t *mobj; // for easy access4 + mobj_t *mobj; // for easy access INT32 x1, x2; @@ -130,6 +130,7 @@ typedef struct vissprite_s fixed_t startfrac; // horizontal position of x1 fixed_t xscale, scale; // projected horizontal and vertical scales + fixed_t thingscale; // the object's scale fixed_t sortscale; // sortscale only differs from scale for flat sprites fixed_t scalestep; // only for flat sprites, 0 otherwise fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle @@ -165,6 +166,7 @@ typedef struct vissprite_s spritecut_e cut; UINT32 renderflags; + UINT8 rotateflags; fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; @@ -176,8 +178,6 @@ typedef struct vissprite_s boolean vflip; // Flip vertically boolean isScaled; INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing - - fixed_t thingscale; } vissprite_t; extern UINT32 visspritecount; diff --git a/src/screen.c b/src/screen.c index fd97e2ca0..1dfabf3fd 100644 --- a/src/screen.c +++ b/src/screen.c @@ -240,9 +240,9 @@ void SCR_Startup(void) vid.fdupx = FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT); vid.fdupy = FixedDiv(vid.height*FRACUNIT, BASEVIDHEIGHT*FRACUNIT); -#ifdef HWRENDER - if (rendermode != render_opengl && rendermode != render_none) // This was just placing it incorrectly at non aspect correct resolutions in opengl -#endif +//#ifdef HWRENDER + //if (rendermode != render_opengl && rendermode != render_none) // This was just placing it incorrectly at non aspect correct resolutions in opengl +//#endif vid.fdupx = vid.fdupy = (vid.fdupx < vid.fdupy ? vid.fdupx : vid.fdupy); vid.meddupx = (UINT8)(vid.dupx >> 1) + 1; diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index f871851dc..a29484c98 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -101,6 +101,7 @@ static UINT32 fading_timer; static UINT32 fading_duration; static INT32 fading_id; static void (*fading_callback)(void); +static boolean fading_do_callback; #ifdef HAVE_LIBGME static Music_Emu *gme; @@ -119,6 +120,7 @@ static void var_cleanup(void) is_fading = false; fading_callback = NULL; + fading_do_callback = false; internal_volume = 100; } @@ -215,6 +217,13 @@ void I_ShutdownSound(void) void I_UpdateSound(void) { + if (fading_do_callback) + { + if (fading_callback) + (*fading_callback)(); + fading_callback = NULL; + fading_do_callback = false; + } } /// ------------------------ @@ -539,9 +548,8 @@ static UINT32 get_adjusted_position(UINT32 position) static void do_fading_callback(void) { - if (fading_callback) - (*fading_callback)(); - fading_callback = NULL; + // TODO: Should I use a mutex here or something? + fading_do_callback = true; } /// ------------------------ diff --git a/src/v_video.c b/src/v_video.c index 17b50aaf1..2bf2f8e37 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -347,7 +347,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca //if (rendermode != render_soft && !con_startup) // Why? if (rendermode == render_opengl) { - HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap);; + HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap); return; } #endif diff --git a/src/win32/Makefile.cfg b/src/win32/Makefile.cfg index a5ca89817..4ce989015 100644 --- a/src/win32/Makefile.cfg +++ b/src/win32/Makefile.cfg @@ -169,6 +169,10 @@ endif LIBS+=-ldiscord-rpc endif +ifndef MINGW64 + LDFLAGS+=-Wl,--large-address-aware +endif + # disable dynamicbase if under msys2 ifdef MSYSTEM LDFLAGS+=-Wl,--disable-dynamicbase