Skip to content

Commit

Permalink
Merge remote-tracking branch 'eduke32/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendricks266 committed Aug 27, 2023
2 parents 26229c1 + c257d5a commit ccdd8a9
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 132 deletions.
74 changes: 37 additions & 37 deletions source/audiolib/src/opl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static int16_t OPL3_EnvelopeCalcExp(uint32_t level)
{
level = 0x1fff;
}
return (exprom[level & 0xff] << 1) >> (level >> 8);
return (exprom[level & 0xffu] << 1) >> (level >> 8);
}

static int16_t OPL3_EnvelopeCalcSin0(uint16_t phase, uint16_t envelope)
Expand All @@ -232,11 +232,11 @@ static int16_t OPL3_EnvelopeCalcSin0(uint16_t phase, uint16_t envelope)
}
if (phase & 0x100)
{
out = logsinrom[(phase & 0xff) ^ 0xff];
out = logsinrom[(phase & 0xffu) ^ 0xffu];
}
else
{
out = logsinrom[phase & 0xff];
out = logsinrom[phase & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3)) ^ neg;
}
Expand All @@ -251,11 +251,11 @@ static int16_t OPL3_EnvelopeCalcSin1(uint16_t phase, uint16_t envelope)
}
else if (phase & 0x100)
{
out = logsinrom[(phase & 0xff) ^ 0xff];
out = logsinrom[(phase & 0xffu) ^ 0xffu];
}
else
{
out = logsinrom[phase & 0xff];
out = logsinrom[phase & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3));
}
Expand All @@ -266,11 +266,11 @@ static int16_t OPL3_EnvelopeCalcSin2(uint16_t phase, uint16_t envelope)
phase &= 0x3ff;
if (phase & 0x100)
{
out = logsinrom[(phase & 0xff) ^ 0xff];
out = logsinrom[(phase & 0xffu) ^ 0xffu];
}
else
{
out = logsinrom[phase & 0xff];
out = logsinrom[phase & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3));
}
Expand All @@ -285,7 +285,7 @@ static int16_t OPL3_EnvelopeCalcSin3(uint16_t phase, uint16_t envelope)
}
else
{
out = logsinrom[phase & 0xff];
out = logsinrom[phase & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3));
}
Expand All @@ -305,11 +305,11 @@ static int16_t OPL3_EnvelopeCalcSin4(uint16_t phase, uint16_t envelope)
}
else if (phase & 0x80)
{
out = logsinrom[((phase ^ 0xff) << 1) & 0xff];
out = logsinrom[((phase ^ 0xffu) << 1u) & 0xffu];
}
else
{
out = logsinrom[(phase << 1) & 0xff];
out = logsinrom[(phase << 1u) & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3)) ^ neg;
}
Expand All @@ -324,11 +324,11 @@ static int16_t OPL3_EnvelopeCalcSin5(uint16_t phase, uint16_t envelope)
}
else if (phase & 0x80)
{
out = logsinrom[((phase ^ 0xff) << 1) & 0xff];
out = logsinrom[((phase ^ 0xffu) << 1u) & 0xffu];
}
else
{
out = logsinrom[(phase << 1) & 0xff];
out = logsinrom[(phase << 1u) & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3));
}
Expand Down Expand Up @@ -379,7 +379,7 @@ enum envelope_gen_num

static void OPL3_EnvelopeUpdateKSL(opl3_slot *slot)
{
int16_t ksl = (kslrom[slot->channel->f_num >> 6] << 2)
int16_t ksl = (kslrom[slot->channel->f_num >> 6u] << 2)
- ((0x08 - slot->channel->block) << 5);
if (ksl < 0)
{
Expand Down Expand Up @@ -465,7 +465,7 @@ static void OPL3_EnvelopeCalc(opl3_slot *slot)
}
else
{
shift = (rate_hi & 0x03) + eg_incstep[rate_lo][slot->chip->timer & 0x03];
shift = (rate_hi & 0x03) + eg_incstep[rate_lo][slot->chip->timer & 0x03u];
if (shift & 0x04)
{
shift = 0x03;
Expand Down Expand Up @@ -1001,7 +1001,7 @@ static void OPL3_ChannelWriteD0(opl3_channel* channel, uint8_t data)
{
if (channel->chip->stereoext)
{
channel->leftpan = panpot_lut[data ^ 0xff];
channel->leftpan = panpot_lut[data ^ 0xffu];
channel->rightpan = panpot_lut[data];
}
}
Expand Down Expand Up @@ -1069,12 +1069,12 @@ static void OPL3_ChannelSet4Op(opl3_chip *chip, uint8_t data)
if ((data >> bit) & 0x01)
{
chip->channel[chnum].chtype = ch_4op;
chip->channel[chnum + 3].chtype = ch_4op2;
chip->channel[chnum + 3u].chtype = ch_4op2;
}
else
{
chip->channel[chnum].chtype = ch_2op;
chip->channel[chnum + 3].chtype = ch_2op;
chip->channel[chnum + 3u].chtype = ch_2op;
}
}
}
Expand Down Expand Up @@ -1279,16 +1279,16 @@ void OPL3_Reset(opl3_chip *chip, uint32_t samplerate)
channel = &chip->channel[channum];
local_ch_slot = ch_slot[channum];
channel->slots[0] = &chip->slot[local_ch_slot];
channel->slots[1] = &chip->slot[local_ch_slot + 3];
channel->slots[1] = &chip->slot[local_ch_slot + 3u];
chip->slot[local_ch_slot].channel = channel;
chip->slot[local_ch_slot + 3].channel = channel;
chip->slot[local_ch_slot + 3u].channel = channel;
if ((channum % 9) < 3)
{
channel->pair = &chip->channel[channum + 3];
channel->pair = &chip->channel[channum + 3u];
}
else if ((channum % 9) < 6)
{
channel->pair = &chip->channel[channum - 3];
channel->pair = &chip->channel[channum - 3u];
}
channel->chip = chip;
channel->out[0] = &chip->zeromod;
Expand Down Expand Up @@ -1357,43 +1357,43 @@ void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v)
break;
case 0x20:
case 0x30:
if (ad_slot[regm & 0x1f] >= 0)
if (ad_slot[regm & 0x1fu] >= 0)
{
OPL3_SlotWrite20(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
OPL3_SlotWrite20(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0x40:
case 0x50:
if (ad_slot[regm & 0x1f] >= 0)
if (ad_slot[regm & 0x1fu] >= 0)
{
OPL3_SlotWrite40(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
OPL3_SlotWrite40(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0x60:
case 0x70:
if (ad_slot[regm & 0x1f] >= 0)
if (ad_slot[regm & 0x1fu] >= 0)
{
OPL3_SlotWrite60(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
OPL3_SlotWrite60(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0x80:
case 0x90:
if (ad_slot[regm & 0x1f] >= 0)
if (ad_slot[regm & 0x1fu] >= 0)
{
OPL3_SlotWrite80(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
OPL3_SlotWrite80(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0xe0:
case 0xf0:
if (ad_slot[regm & 0x1f] >= 0)
if (ad_slot[regm & 0x1fu] >= 0)
{
OPL3_SlotWriteE0(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
OPL3_SlotWriteE0(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0xa0:
if ((regm & 0x0f) < 9)
{
OPL3_ChannelWriteA0(&chip->channel[9 * high + (regm & 0x0f)], v);
OPL3_ChannelWriteA0(&chip->channel[9u * high + (regm & 0x0fu)], v);
}
break;
case 0xb0:
Expand All @@ -1405,28 +1405,28 @@ void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v)
}
else if ((regm & 0x0f) < 9)
{
OPL3_ChannelWriteB0(&chip->channel[9 * high + (regm & 0x0f)], v);
OPL3_ChannelWriteB0(&chip->channel[9u * high + (regm & 0x0fu)], v);
if (v & 0x20)
{
OPL3_ChannelKeyOn(&chip->channel[9 * high + (regm & 0x0f)]);
OPL3_ChannelKeyOn(&chip->channel[9u * high + (regm & 0x0fu)]);
}
else
{
OPL3_ChannelKeyOff(&chip->channel[9 * high + (regm & 0x0f)]);
OPL3_ChannelKeyOff(&chip->channel[9u * high + (regm & 0x0fu)]);
}
}
break;
case 0xc0:
if ((regm & 0x0f) < 9)
{
OPL3_ChannelWriteC0(&chip->channel[9 * high + (regm & 0x0f)], v);
OPL3_ChannelWriteC0(&chip->channel[9u * high + (regm & 0x0fu)], v);
}
break;
#if OPL_ENABLE_STEREOEXT
case 0xd0:
if ((regm & 0x0f) < 9)
{
OPL3_ChannelWriteD0(&chip->channel[9 * high + (regm & 0x0f)], v);
OPL3_ChannelWriteD0(&chip->channel[9u * high + (regm & 0x0fu)], v);
}
break;
#endif
Expand Down
5 changes: 4 additions & 1 deletion source/build/include/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,12 @@ enum {
ROTATESPRITE_FULL16 = 2048,
RS_LERP = 4096,
RS_FORCELERP = 8192,
RS_NOPOSLERP = 16384,
RS_NOZOOMLERP = 32768,
RS_NOANGLERP = 65536,

// ROTATESPRITE_MAX-1 is the mask of all externally available orientation bits
ROTATESPRITE_MAX = 16384,
ROTATESPRITE_MAX = 131072,

RS_CENTERORIGIN = (1<<30),
};
Expand Down
36 changes: 20 additions & 16 deletions source/build/src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7802,17 +7802,28 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t

sm0 = { goal, goal, picnum, (int16_t)(dastat & ~RS_TRANS_MASK), clock };

auto lerpWouldLookDerp = [&](void)
bool const lerpWouldLookDerp = !(dastat & RS_LERP) || sm.clock == 0 || clock - sm.clock > 4
|| (!(dastat & RS_FORCELERP) && (sm.flags != (dastat & ~RS_TRANS_MASK) || (tilesiz[picnum] != tilesiz[sm.picnum]
&& (unsigned)(picnum - sm.picnum)))) || klabs(a - sm.goal.a) == 1024;

if (clock - sm.clock >= 4 || sm0.goal != sm.goal)
{
return !(dastat & RS_LERP) || sm.clock == 0 || clock - sm.clock > 4
|| (!(dastat & RS_FORCELERP) && (sm.flags != (dastat & ~RS_TRANS_MASK) || (tilesiz[picnum] != tilesiz[sm.picnum]
&& (unsigned)(picnum - sm.picnum)))) || klabs(a - sm.goal.a) == 1024;
};
sm.lerp = sm.goal;
sm.goal = sm0.goal;
sm.clock = sm0.clock;
}

if (lerpWouldLookDerp())
if (lerpWouldLookDerp)
sm.lerp = sm.goal = sm0.goal;
else
{
if (dastat & RS_NOPOSLERP)
sm.lerp.xy = sm.goal.xy = sm0.goal.xy;
if (dastat & RS_NOZOOMLERP)
sm.lerp.z = sm.goal.z = sm0.goal.z;
if (dastat & RS_NOANGLERP)
sm.lerp.a = sm.goal.a = sm0.goal.a;

sm0.lerp = { sm.goal.x - mulscale16(65536-rotatespritesmoothratio, sm.goal.x - sm.lerp.x),
sm.goal.y - mulscale16(65536-rotatespritesmoothratio, sm.goal.y - sm.lerp.y),
sm.goal.z - mulscale16(65536-rotatespritesmoothratio, sm.goal.z - sm.lerp.z),
Expand All @@ -7822,13 +7833,6 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
sm.picnum = sm0.picnum;
sm.flags = sm0.flags;

if (clock - sm.clock > 1 || sm0.goal != sm.goal)
{
sm.lerp = sm.goal;
sm.goal = sm0.goal;
sm.clock = sm0.clock;
}

if (r_rotatespriteinterp)
{
sx = sm0.lerp.x;
Expand All @@ -7838,6 +7842,9 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
}
}

if (daalpha == 255) // No sense trying to draw something invisible.
return;

//============================================================================= //POLYMOST BEGINS
#ifdef USE_OPENGL
if (videoGetRenderMode() >= REND_POLYMOST && in3dmode())
Expand Down Expand Up @@ -7961,9 +7968,6 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
// Alpha handling
if (!(dastat&RS_TRANS1) && daalpha > 0)
{
if (daalpha == 255)
return;

if (numalphatabs != 0)
{
if (falpha_to_blend((float)daalpha / 255.0f, &dastat, &dablend, RS_TRANS1, RS_TRANS2))
Expand Down
4 changes: 1 addition & 3 deletions source/build/src/polymer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5966,8 +5966,7 @@ static void polymer_addplanelight(_prplane* plane, int16_t lighti)

static FORCE_INLINE void polymer_deleteplanelight(_prplane *const plane, int16_t const lighti)
{
int i = plane->lightcount - 1;
do
for (int i = plane->lightcount - 1; i >= 0; --i)
{
if (plane->lights[i] == lighti)
{
Expand All @@ -5976,7 +5975,6 @@ static FORCE_INLINE void polymer_deleteplanelight(_prplane *const plane, int16_t
return;
}
}
while (--i >= 0);
}

static int polymer_planeinlight(_prplane const &plane, _prlight const &light)
Expand Down
2 changes: 1 addition & 1 deletion source/build/src/screentext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static inline void AddCoordsFromRotation(vec2_t *coords, const vec2_t *unitDirec
// screentext
vec2_t screentextRender(ScreenText_t const & data)
{
if (data.text == NULL)
if (data.text == NULL || data.zoom <= 0)
return {};

glyph_t const * text = data.text;
Expand Down
4 changes: 2 additions & 2 deletions source/build/src/smmalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ void Allocator::CreateThreadCache(CacheWarmupOptions warmupOptions, std::initial
void Allocator::DestroyThreadCache()
{
#if __SANITIZE_ADDRESS__ == 1
auto buf = this->pBuffer.get();
ASAN_UNPOISON_MEMORY_REGION(buf, this->pBufferEnd - buf);
auto buf = this->pBuffer.get();
ASAN_UNPOISON_MEMORY_REGION(buf, this->pBufferEnd - buf);
#endif
for (size_t i = 0; i < SMM_MAX_BUCKET_COUNT; i++)
{
Expand Down
Loading

0 comments on commit ccdd8a9

Please sign in to comment.