SPU2: Cleanup spu2.

Constants, initializations, casts, switch cases not handling default case, unused functions.
This commit is contained in:
lightningterror 2023-05-11 21:00:51 +02:00
parent 38480d3aed
commit ad4e95cb78
24 changed files with 102 additions and 119 deletions

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -17,7 +17,7 @@
#include "Global.h"
#include "common/Assertions.h"
static const s32 ADSR_MAX_VOL = 0x7fffffff;
static constexpr s32 ADSR_MAX_VOL = 0x7fffffff;
static const int InvExpOffsets[] = {0, 4, 6, 8, 9, 10, 11, 12};
static u32 PsxRates[160];
@ -27,7 +27,7 @@ void InitADSR() // INIT ADSR
{
for (int i = 0; i < (32 + 128); i++)
{
int shift = (i - 32) >> 2;
const int shift = (i - 32) >> 2;
s64 rate = (i & 3) + 4;
if (shift < 0)
rate >>= -shift;
@ -74,7 +74,7 @@ bool V_ADSR::Calculate()
case 2: // decay
{
u32 off = InvExpOffsets[(Value >> 28) & 7];
const u32 off = InvExpOffsets[(Value >> 28) & 7];
Value -= PsxRates[((DecayRate ^ 0x1f) * 4) - 0x18 + off + 32];
// calculate sustain level as a factor of the ADSR maximum volume.
@ -100,7 +100,7 @@ bool V_ADSR::Calculate()
{
if (SustainMode & 4) // exponential
{
u32 off = InvExpOffsets[(Value >> 28) & 7];
const u32 off = InvExpOffsets[(Value >> 28) & 7];
Value -= PsxRates[(SustainRate ^ 0x7f) - 0x1b + off + 32];
}
else // linear
@ -138,7 +138,7 @@ bool V_ADSR::Calculate()
case 5: // release
if (ReleaseMode) // exponential
{
u32 off = InvExpOffsets[(Value >> 28) & 7];
const u32 off = InvExpOffsets[(Value >> 28) & 7];
Value -= PsxRates[((ReleaseRate ^ 0x1f) * 4) - 0x18 + off + 32];
}
else
@ -194,7 +194,7 @@ void V_VolumeSlide::Update()
if (Mode & VOLFLAG_EXPONENTIAL)
{
u32 off = InvExpOffsets[(value >> 28) & 7];
const u32 off = InvExpOffsets[(value >> 28) & 7];
value -= PsxRates[(Increment ^ 0x7f) - 0x1b + off + 32];
}
else

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -527,7 +527,7 @@ void V_Core::DoDMAwrite(u16* pMem, u32 size)
ActiveTSA = TSA & 0xfffff;
bool adma_enable = ((AutoDMACtrl & (Index + 1)) == (Index + 1));
const bool adma_enable = ((AutoDMACtrl & (Index + 1)) == (Index + 1));
if (adma_enable)
{

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -68,57 +68,57 @@ extern void ResetDplIIDecoder()
void ProcessDplIISample32(const StereoOut16& src, Stereo51Out32DplII* s)
{
float IL = src.Left / (float)(1 << 16);
float IR = src.Right / (float)(1 << 16);
const float IL = src.Left / static_cast<float>(1 << 16);
const float IR = src.Right / static_cast<float>(1 << 16);
// Calculate center channel and LFE
float C = (IL + IR) * 0.5f;
float SUB = C; // no need to lowpass, the speaker amplifier should take care of it
const float C = (IL + IR) * 0.5f;
const float SUB = C; // no need to lowpass, the speaker amplifier should take care of it
float L = IL - C; // Effective L/R data
float R = IR - C;
// Peak L/R
float PL = std::abs(L);
float PR = std::abs(R);
const float PL = std::abs(L);
const float PR = std::abs(R);
AccL += (PL - AccL) * 0.1f;
AccR += (PR - AccR) * 0.1f;
// Calculate power balance
float Balance = (AccR - AccL); // -1 .. 1
const float Balance = (AccR - AccL); // -1 .. 1
// If the power levels are different, then the audio is meant for the front speakers
float Frontness = std::abs(Balance);
float Rearness = 1 - Frontness; // And the other way around
const float Frontness = std::abs(Balance);
const float Rearness = 1 - Frontness; // And the other way around
// Equalize the power levels for L/R
float B = std::min(0.9f, std::max(-0.9f, Balance));
const float B = std::min(0.9f, std::max(-0.9f, Balance));
float VL = L / (1 - B); // if B>0, it means R>L, so increase L, else decrease L
float VR = R / (1 + B); // vice-versa
const float VL = L / (1 - B); // if B>0, it means R>L, so increase L, else decrease L
const float VR = R / (1 + B); // vice-versa
// 1.73+1.22 = 2.94; 2.94 = 0.34 = 0.9996; Close enough.
// The range for VL/VR is approximately 0..1,
// But in the cases where VL/VR are > 0.5, Rearness is 0 so it should never overflow.
const float RearScale = 0.34f * 2;
constexpr float RearScale = 0.34f * 2;
float SL = (VR * 1.73f - VL * 1.22f) * RearScale * Rearness;
float SR = (VR * 1.22f - VL * 1.73f) * RearScale * Rearness;
const float SL = (VR * 1.73f - VL * 1.22f) * RearScale * Rearness;
const float SR = (VR * 1.22f - VL * 1.73f) * RearScale * Rearness;
// Possible experiment: Play with stereo expension levels on rear
// Adjust the volume of the front speakers based on what we calculated above
L *= Frontness;
R *= Frontness;
s32 CX = (s32)(C * AddCLR);
const s32 CX = static_cast<s32>(C * AddCLR);
s->Left = (s32)(L * GainL) + CX;
s->Right = (s32)(R * GainR) + CX;
s->Center = (s32)(C * GainC);
s->LFE = (s32)(SUB * GainLFE);
s->LeftBack = (s32)(SL * GainSL);
s->RightBack = (s32)(SR * GainSR);
s->Left = static_cast<s32>(L * GainL) + CX;
s->Right = static_cast<s32>(R * GainR) + CX;
s->Center = static_cast<s32>(C * GainC);
s->LFE = static_cast<s32>(SUB * GainLFE);
s->LeftBack = static_cast<s32>(SL * GainSL);
s->RightBack = static_cast<s32>(SR * GainSR);
}
void ProcessDplIISample16(const StereoOut16& src, Stereo51Out16DplII* s)
@ -136,25 +136,25 @@ void ProcessDplIISample16(const StereoOut16& src, Stereo51Out16DplII* s)
void ProcessDplSample32(const StereoOut16& src, Stereo51Out32Dpl* s)
{
float ValL = src.Left / (float)(1 << 16);
float ValR = src.Right / (float)(1 << 16);
const float ValL = src.Left / static_cast<float>(1 << 16);
const float ValR = src.Right / static_cast<float>(1 << 16);
float C = (ValL + ValR) * 0.5f; //+15.8
float S = (ValL - ValR) * 0.5f;
const float C = (ValL + ValR) * 0.5f; //+15.8
const float S = (ValL - ValR) * 0.5f;
float L = ValL - C; //+15.8
float R = ValR - C;
const float L = ValL - C; //+15.8
const float R = ValR - C;
float SUB = C;
const float SUB = C;
s32 CX = (s32)(C * AddCLR); // +15.16
const s32 CX = static_cast<s32>(C * AddCLR); // +15.16
s->Left = (s32)(L * GainL) + CX; // +15.16 = +31, can grow to +32 if (GainL + AddCLR)>255
s->Right = (s32)(R * GainR) + CX;
s->Center = (s32)(C * GainC); // +15.16 = +31
s->LFE = (s32)(SUB * GainLFE);
s->LeftBack = (s32)(S * GainSL);
s->RightBack = (s32)(S * GainSR);
s->Left = static_cast<s32>(L * GainL) + CX; // +15.16 = +31, can grow to +32 if (GainL + AddCLR)>255
s->Right = static_cast<s32>(R * GainR) + CX;
s->Center = static_cast<s32>(C * GainC); // +15.16 = +31
s->LFE = static_cast<s32>(SUB * GainLFE);
s->LeftBack = static_cast<s32>(S * GainSL);
s->RightBack = static_cast<s32>(S * GainSR);
}
void ProcessDplSample16(const StereoOut16& src, Stereo51Out16Dpl* s)

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2021 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -43,7 +43,7 @@ static const s32 tbl_XA_Factor[16][2] =
//
static __forceinline s32 MulShr32(s32 srcval, s32 mulval)
{
return (s64)srcval * mulval >> 32;
return static_cast<s64>(srcval) * mulval >> 32;
}
__forceinline s32 clamp_mix(s32 x)

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -35,7 +35,7 @@ StereoOut32 V_Core::ReadInput_HiFi()
if (SPU2::IsRunningPSXMode() && SPU2::MsgToConsole())
SPU2::ConLog("ReadInput_HiFi!!!!!\n");
u16 ReadIndex = (OutPos * 2) & 0x1FF;
const u16 ReadIndex = (OutPos * 2) & 0x1FF;
StereoOut32 retval(
(s32&)(*GetMemPtr(0x2000 + (Index << 10) + ReadIndex)),

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -562,12 +562,12 @@ float SndBuffer::GetStatusPct()
// These params were tested to show good respond and stability, on all audio systems (dsound, wav, port audio, xaudio2),
// even at extreme small latency of 50ms which can handle 50%-100% variations without audible glitches.
int targetIPS = 750;
constexpr int targetIPS = 750;
//Additional performance note: since MAX_STRETCH_AVERAGE_LEN = 128 (or any power of 2), the '%' below
//could be replaced with a faster '&'. The compiler is highly likely to do it since all the values are unsigned.
#define AVERAGING_BUFFER_SIZE 256U
unsigned int AVERAGING_WINDOW = 50.0 * targetIPS / 750;
unsigned int AVERAGING_WINDOW = 50 * targetIPS / 750;
#define STRETCHER_RESET_THRESHOLD 5
@ -954,8 +954,8 @@ static void ConvertPacketToInt(StereoOut16* dst, const float* src, uint size)
fv1 = _mm_mul_ps(fv1, FLOAT_TO_S16_V);
fv2 = _mm_mul_ps(fv2, FLOAT_TO_S16_V);
__m128i iv1 = _mm_cvtps_epi32(fv1);
__m128i iv2 = _mm_cvtps_epi32(fv2);
const __m128i iv1 = _mm_cvtps_epi32(fv1);
const __m128i iv2 = _mm_cvtps_epi32(fv2);
__m128i iv = _mm_packs_epi32(iv1, iv2);
_mm_store_si128(reinterpret_cast<__m128i*>(dst), iv);

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2021 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -139,7 +139,7 @@ public:
bool Init() override
{
#ifdef _WIN32
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
const HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
m_COMInitializedByUs = SUCCEEDED(hr);
if (FAILED(hr) && hr != RPC_E_CHANGED_MODE)
{
@ -162,9 +162,6 @@ public:
switch (EmuConfig.SPU2.SpeakerConfiguration) // speakers = (numSpeakers + 1) *2; ?
{
case 0:
channels = 2;
break; // Stereo
case 1:
channels = 4;
break; // Quadrafonic
@ -176,7 +173,7 @@ public:
break; // Surround 7.1
default:
channels = 2;
break;
break; // Stereo
}
cubeb_channel_layout layout = CUBEB_LAYOUT_UNDEFINED;
@ -209,10 +206,6 @@ public:
case 7:
switch (EmuConfig.SPU2.DplDecodingLevel)
{
case 0:
Console.WriteLn("(Cubeb) 5.1 speaker expansion enabled.");
ActualReader = std::make_unique<ConvertedSampleReader<Stereo51Out16>>(&writtenSoFar); //"normal" stereo upmix
break;
case 1:
Console.WriteLn("(Cubeb) 5.1 speaker expansion with basic ProLogic dematrixing enabled.");
ActualReader = std::make_unique<ConvertedSampleReader<Stereo51Out16Dpl>>(&writtenSoFar); // basic Dpl decoder without rear stereo balancing
@ -221,6 +214,10 @@ public:
Console.WriteLn("(Cubeb) 5.1 speaker expansion with experimental ProLogicII dematrixing enabled.");
ActualReader = std::make_unique<ConvertedSampleReader<Stereo51Out16DplII>>(&writtenSoFar); //gigas PLII
break;
default:
Console.WriteLn("(Cubeb) 5.1 speaker expansion enabled.");
ActualReader = std::make_unique<ConvertedSampleReader<Stereo51Out16>>(&writtenSoFar); //"normal" stereo upmix
break;
}
channels = 6; // we do not support 7.0 or 6.2 configurations, downgrade to 5.1
layout = CUBEB_LAYOUT_3F2_LFE;

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -242,9 +242,6 @@ public:
// speakers = (numSpeakers + 1) *2; ?
switch (EmuConfig.SPU2.SpeakerConfiguration)
{
case 0: // Stereo
speakers = 2;
break;
case 1: // Quadrafonic
speakers = 4;
break;
@ -254,7 +251,7 @@ public:
case 3: // Surround 7.1
speakers = 8;
break;
default:
default: // Stereo
speakers = 2;
break;
}
@ -289,10 +286,6 @@ public:
case 7:
switch (EmuConfig.SPU2.DplDecodingLevel)
{
case 0: // "normal" stereo upmix
Console.WriteLn("* SPU2 > 5.1 speaker expansion enabled.");
m_voiceContext = std::make_unique<StreamingVoice<Stereo51Out16>>();
break;
case 1: // basic Dpl decoder without rear stereo balancing
Console.WriteLn("* SPU2 > 5.1 speaker expansion with basic ProLogic dematrixing enabled.");
m_voiceContext = std::make_unique<StreamingVoice<Stereo51Out16Dpl>>();
@ -301,6 +294,10 @@ public:
Console.WriteLn("* SPU2 > 5.1 speaker expansion with experimental ProLogicII dematrixing enabled.");
m_voiceContext = std::make_unique<StreamingVoice<Stereo51Out16DplII>>();
break;
default: // "normal" stereo upmix
Console.WriteLn("* SPU2 > 5.1 speaker expansion enabled.");
m_voiceContext = std::make_unique<StreamingVoice<Stereo51Out16>>();
break;
}
break;
default: // anything 8 or more gets the 7.1 treatment!

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -523,7 +523,7 @@ struct V_Core
__forceinline u16 DmaRead()
{
const u16 ret = (u16)spu2M_Read(ActiveTSA);
const u16 ret = static_cast<u16>(spu2M_Read(ActiveTSA));
++ActiveTSA;
ActiveTSA &= 0xfffff;
TSA = ActiveTSA;
@ -588,16 +588,16 @@ namespace SPU2Savestate
// The SPU2 has a dynamic memory range which is used for several internal operations, such as
// registers, CORE 1/2 mixing, AutoDMAs, and some other fancy stuff. We exclude this range
// from the cache here:
static const s32 SPU2_DYN_MEMLINE = 0x2800;
static constexpr s32 SPU2_DYN_MEMLINE = 0x2800;
// 8 short words per encoded PCM block. (as stored in SPU2 ram)
static const int pcm_WordsPerBlock = 8;
static constexpr int pcm_WordsPerBlock = 8;
// number of cachable ADPCM blocks (any blocks above the SPU2_DYN_MEMLINE)
static const int pcm_BlockCount = 0x100000 / pcm_WordsPerBlock;
static constexpr int pcm_BlockCount = 0x100000 / pcm_WordsPerBlock;
// 28 samples per decoded PCM block (as stored in our cache)
static const int pcm_DecodedSamplesPerBlock = 28;
static constexpr int pcm_DecodedSamplesPerBlock = 28;
struct PcmCacheEntry
{

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2022 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2021 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -278,7 +278,9 @@ void SPU2async(u32 cycles)
u16 SPU2read(u32 rmem)
{
u16 ret = 0xDEAD;
u32 core = 0, mem = rmem & 0xFFFF, omem = mem;
u32 core = 0;
const u32 mem = rmem & 0xFFFF;
u32 omem = mem;
if (mem & 0x400)
{

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -21,11 +21,11 @@
namespace SPU2Savestate
{
// Arbitrary ID to identify SPU2 saves.
static const u32 SAVE_ID = 0x1227521;
static constexpr u32 SAVE_ID = 0x1227521;
// versioning for saves.
// Increment this when changes to the savestate system are made.
static const u32 SAVE_VERSION = 0x000e;
static constexpr u32 SAVE_VERSION = 0x000e;
static void wipe_the_cache()
{

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2023 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -272,7 +272,7 @@ s32 V_Core::EffectsBufferIndexer(s32 offset) const
// Need to use modulus here, because games can and will drop the buffer size
// without notice, and it leads to offsets several times past the end of the buffer.
if ((u32)offset >= (u32)EffectsBufferSize)
if (static_cast<u32>(offset) >= static_cast<u32>(EffectsBufferSize))
return EffectsStartA + (offset % EffectsBufferSize) + (offset < 0 ? EffectsBufferSize : 0);
else
return EffectsStartA + offset;
@ -396,7 +396,7 @@ __forceinline void TimeUpdate(u32 cClocks)
// timings from PCSX2), just mix out a little bit, skip the rest, and hope the ship
// "rights" itself later on.
if (dClocks > (u32)(TickInterval * SanityInterval))
if (dClocks > static_cast<u32>(TickInterval * SanityInterval))
{
if (SPU2::MsgToConsole())
SPU2::ConLog(" * SPU2 > TimeUpdate Sanity Check (Tick Delta: %d) (PS2 Ticks: %d)\n", dClocks / TickInterval, cClocks / TickInterval);
@ -552,7 +552,7 @@ __forceinline void TimeUpdate(u32 cClocks)
__forceinline void UpdateSpdifMode()
{
int OPM = PlayMode;
const int OPM = PlayMode;
if (Spdif.Out & 0x4 && SPU2::MsgToConsole()) // use 24/32bit PCM data streaming
{
@ -586,7 +586,7 @@ __forceinline void UpdateSpdifMode()
// properly into the lower 16 bits of the value to provide a full spectrum of volumes.
static s32 GetVol32(u16 src)
{
return (((s32)src) << 16) | ((src << 1) & 0xffff);
return ((static_cast<s32>(src)) << 16) | ((src << 1) & 0xffff);
}
void V_VolumeSlide::RegSet(u16 src)
@ -610,13 +610,13 @@ void V_Core::WriteRegPS1(u32 mem, u16 value)
pxAssume(Index == 0); // Valid on Core 0 only!
bool show = true;
u32 reg = mem & 0xffff;
const u32 reg = mem & 0xffff;
if ((reg >= 0x1c00) && (reg < 0x1d80))
{
//voice values
u8 voice = ((reg - 0x1c00) >> 4);
u8 vval = reg & 0xf;
const u8 vval = reg & 0xf;
switch (vval)
{
case 0x0: //VOLL (Volume L)
@ -951,13 +951,13 @@ u16 V_Core::ReadRegPS1(u32 mem)
bool show = true;
u16 value = spu2Ru16(mem);
u32 reg = mem & 0xffff;
const u32 reg = mem & 0xffff;
if ((reg >= 0x1c00) && (reg < 0x1d80))
{
//voice values
u8 voice = ((reg - 0x1c00) >> 4);
u8 vval = reg & 0xf;
const u8 voice = ((reg - 0x1c00) >> 4);
const u8 vval = reg & 0xf;
switch (vval)
{
case 0x0: //VOLL (Volume L)
@ -1100,19 +1100,6 @@ static __forceinline void SetLoWord(u32& src, u16 value)
((u16*)&src)[0] = value;
}
// Not used
#if 0
static __forceinline u16 GetHiWord(u32& src)
{
return ((u16*)&src)[1];
}
static __forceinline u16 GetLoWord(u32& src)
{
return ((u16*)&src)[0];
}
#endif
template <int CoreIdx, int VoiceIdx, int param>
static void RegWrite_VoiceParams(u16 value)
{