mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #911 from lioncash/braces
Clean up brace placements within the project.
This commit is contained in:
@@ -40,7 +40,8 @@ public:
|
||||
|
||||
virtual void Stop() override;
|
||||
|
||||
static bool isValid() {
|
||||
static bool isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ public:
|
||||
virtual void SoundLoop() override;
|
||||
virtual void Stop() override;
|
||||
|
||||
static bool isValid() {
|
||||
static bool isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,13 +41,15 @@ bool CoreAudioSound::Start()
|
||||
desc.componentFlagsMask = 0;
|
||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||
component = FindNextComponent(nullptr, &desc);
|
||||
if (component == nullptr) {
|
||||
if (component == nullptr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "error finding audio component");
|
||||
return false;
|
||||
}
|
||||
|
||||
err = OpenAComponent(component, &audioUnit);
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "error opening audio component");
|
||||
return false;
|
||||
}
|
||||
@@ -58,7 +60,8 @@ bool CoreAudioSound::Start()
|
||||
kAudioUnitProperty_StreamFormat,
|
||||
kAudioUnitScope_Input, 0, &format,
|
||||
sizeof(AudioStreamBasicDescription));
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "error setting audio format");
|
||||
return false;
|
||||
}
|
||||
@@ -69,12 +72,13 @@ bool CoreAudioSound::Start()
|
||||
kAudioUnitProperty_SetRenderCallback,
|
||||
kAudioUnitScope_Input, 0, &callback_struct,
|
||||
sizeof callback_struct);
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "error setting audio callback");
|
||||
return false;
|
||||
}
|
||||
|
||||
err = AudioUnitSetParameter(audioUnit,
|
||||
err = AudioUnitSetParameter(audioUnit,
|
||||
kHALOutputParam_Volume,
|
||||
kAudioUnitParameterFlag_Output, 0,
|
||||
m_volume / 100., 0);
|
||||
@@ -82,13 +86,15 @@ bool CoreAudioSound::Start()
|
||||
ERROR_LOG(AUDIO, "error setting volume");
|
||||
|
||||
err = AudioUnitInitialize(audioUnit);
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "error initializing audiounit");
|
||||
return false;
|
||||
}
|
||||
|
||||
err = AudioOutputUnitStart(audioUnit);
|
||||
if (err != noErr) {
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "error starting audiounit");
|
||||
return false;
|
||||
}
|
||||
@@ -99,7 +105,7 @@ bool CoreAudioSound::Start()
|
||||
void CoreAudioSound::SetVolume(int volume)
|
||||
{
|
||||
OSStatus err;
|
||||
m_volume = volume;
|
||||
m_volume = volume;
|
||||
|
||||
err = AudioUnitSetParameter(audioUnit,
|
||||
kHALOutputParam_Volume,
|
||||
|
||||
@@ -22,7 +22,8 @@ public:
|
||||
virtual void SoundLoop();
|
||||
virtual void Stop();
|
||||
|
||||
static bool isValid() {
|
||||
static bool isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ unsigned int CMixer::MixerFifo::Mix(short* samples, unsigned int numSamples, boo
|
||||
s32 rvolume = m_RVolume;
|
||||
|
||||
// TODO: consider a higher-quality resampling algorithm.
|
||||
for (; currentSample < numSamples*2 && ((indexW-indexR) & INDEX_MASK) > 2; currentSample+=2) {
|
||||
for (; currentSample < numSamples*2 && ((indexW-indexR) & INDEX_MASK) > 2; currentSample+=2)
|
||||
{
|
||||
u32 indexR2 = indexR + 2; //next sample
|
||||
|
||||
s16 l1 = Common::swap16(m_buffer[indexR & INDEX_MASK]); //current
|
||||
|
||||
@@ -30,7 +30,8 @@ static CMixer *g_mixer;
|
||||
static short buffer[2][BUFFER_SIZE];
|
||||
static int curBuffer = 0;
|
||||
|
||||
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
|
||||
static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||
{
|
||||
assert(bq == bqPlayerBufferQueue);
|
||||
assert(nullptr == context);
|
||||
|
||||
@@ -49,6 +50,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {
|
||||
// Render to the fresh buffer
|
||||
g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
|
||||
}
|
||||
|
||||
bool OpenSLESStream::Start()
|
||||
{
|
||||
SLresult result;
|
||||
@@ -103,9 +105,11 @@ bool OpenSLESStream::Start()
|
||||
curBuffer = 0;
|
||||
|
||||
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeof(buffer[curBuffer]));
|
||||
if (SL_RESULT_SUCCESS != result) {
|
||||
if (SL_RESULT_SUCCESS != result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
curBuffer ^= 1;
|
||||
g_mixer = m_mixer;
|
||||
return true;
|
||||
@@ -113,7 +117,8 @@ bool OpenSLESStream::Start()
|
||||
|
||||
void OpenSLESStream::Stop()
|
||||
{
|
||||
if (bqPlayerObject != nullptr) {
|
||||
if (bqPlayerObject != nullptr)
|
||||
{
|
||||
(*bqPlayerObject)->Destroy(bqPlayerObject);
|
||||
bqPlayerObject = nullptr;
|
||||
bqPlayerPlay = nullptr;
|
||||
@@ -121,11 +126,15 @@ void OpenSLESStream::Stop()
|
||||
bqPlayerMuteSolo = nullptr;
|
||||
bqPlayerVolume = nullptr;
|
||||
}
|
||||
if (outputMixObject != nullptr) {
|
||||
|
||||
if (outputMixObject != nullptr)
|
||||
{
|
||||
(*outputMixObject)->Destroy(outputMixObject);
|
||||
outputMixObject = nullptr;
|
||||
}
|
||||
if (engineObject != nullptr) {
|
||||
|
||||
if (engineObject != nullptr)
|
||||
{
|
||||
(*engineObject)->Destroy(engineObject);
|
||||
engineObject = nullptr;
|
||||
engineEngine = nullptr;
|
||||
|
||||
@@ -19,7 +19,8 @@ PulseAudio::PulseAudio(CMixer *mixer)
|
||||
: SoundStream(mixer)
|
||||
, m_thread()
|
||||
, m_run_thread()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
bool PulseAudio::Start()
|
||||
{
|
||||
|
||||
@@ -33,23 +33,32 @@ public:
|
||||
virtual void Update() {}
|
||||
virtual void Clear(bool mute) { m_muted = mute; }
|
||||
bool IsMuted() const { return m_muted; }
|
||||
virtual void StartLogAudio(const char *filename) {
|
||||
if (! m_logAudio) {
|
||||
|
||||
virtual void StartLogAudio(const char *filename)
|
||||
{
|
||||
if (! m_logAudio)
|
||||
{
|
||||
m_logAudio = true;
|
||||
g_wave_writer.Start(filename, m_mixer->GetSampleRate());
|
||||
g_wave_writer.SetSkipSilence(false);
|
||||
NOTICE_LOG(DSPHLE, "Starting Audio logging");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(DSPHLE, "Audio logging already started");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void StopLogAudio() {
|
||||
if (m_logAudio) {
|
||||
virtual void StopLogAudio()
|
||||
{
|
||||
if (m_logAudio)
|
||||
{
|
||||
m_logAudio = false;
|
||||
g_wave_writer.Stop();
|
||||
NOTICE_LOG(DSPHLE, "Stopping Audio logging");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(DSPHLE, "Audio logging already stopped");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,8 +137,10 @@ ALDeviceList::ALDeviceList()
|
||||
*/
|
||||
ALDeviceList::~ALDeviceList()
|
||||
{
|
||||
for (auto& di : vDeviceInfo) {
|
||||
if (di.pvstrExtensions) {
|
||||
for (auto& di : vDeviceInfo)
|
||||
{
|
||||
if (di.pvstrExtensions)
|
||||
{
|
||||
di.pvstrExtensions->clear();
|
||||
delete di.pvstrExtensions;
|
||||
}
|
||||
@@ -171,13 +173,13 @@ char * ALDeviceList::GetDeviceName(s32 index)
|
||||
*/
|
||||
void ALDeviceList::GetDeviceVersion(s32 index, s32 *major, s32 *minor)
|
||||
{
|
||||
if (index < GetNumDevices()) {
|
||||
if (index < GetNumDevices())
|
||||
{
|
||||
if (major)
|
||||
*major = vDeviceInfo[index].iMajorVersion;
|
||||
if (minor)
|
||||
*minor = vDeviceInfo[index].iMinorVersion;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -198,9 +200,12 @@ bool ALDeviceList::IsExtensionSupported(s32 index, char *szExtName)
|
||||
{
|
||||
bool bReturn = false;
|
||||
|
||||
if (index < GetNumDevices()) {
|
||||
for (auto& ext : *vDeviceInfo[index].pvstrExtensions) {
|
||||
if (!strcasecmp(ext.c_str(), szExtName)) {
|
||||
if (index < GetNumDevices())
|
||||
{
|
||||
for (auto& ext : *vDeviceInfo[index].pvstrExtensions)
|
||||
{
|
||||
if (!strcasecmp(ext.c_str(), szExtName))
|
||||
{
|
||||
bReturn = true;
|
||||
break;
|
||||
}
|
||||
@@ -224,9 +229,11 @@ s32 ALDeviceList::GetDefaultDevice()
|
||||
void ALDeviceList::FilterDevicesMinVer(s32 major, s32 minor)
|
||||
{
|
||||
s32 dMajor = 0, dMinor = 0;
|
||||
for (u32 i = 0; i < vDeviceInfo.size(); i++) {
|
||||
for (u32 i = 0; i < vDeviceInfo.size(); i++)
|
||||
{
|
||||
GetDeviceVersion(i, &dMajor, &dMinor);
|
||||
if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) {
|
||||
if ((dMajor < major) || ((dMajor == major) && (dMinor < minor)))
|
||||
{
|
||||
vDeviceInfo[i].bSelected = false;
|
||||
}
|
||||
}
|
||||
@@ -238,9 +245,11 @@ void ALDeviceList::FilterDevicesMinVer(s32 major, s32 minor)
|
||||
void ALDeviceList::FilterDevicesMaxVer(s32 major, s32 minor)
|
||||
{
|
||||
s32 dMajor = 0, dMinor = 0;
|
||||
for (u32 i = 0; i < vDeviceInfo.size(); i++) {
|
||||
for (u32 i = 0; i < vDeviceInfo.size(); i++)
|
||||
{
|
||||
GetDeviceVersion(i, &dMajor, &dMinor);
|
||||
if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) {
|
||||
if ((dMajor > major) || ((dMajor == major) && (dMinor > minor)))
|
||||
{
|
||||
vDeviceInfo[i].bSelected = false;
|
||||
}
|
||||
}
|
||||
@@ -253,14 +262,18 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName)
|
||||
{
|
||||
bool bFound;
|
||||
|
||||
for (auto& di : vDeviceInfo) {
|
||||
for (auto& di : vDeviceInfo)
|
||||
{
|
||||
bFound = false;
|
||||
for (auto& ext : *di.pvstrExtensions) {
|
||||
if (!strcasecmp(ext.c_str(), szExtName)) {
|
||||
for (auto& ext : *di.pvstrExtensions)
|
||||
{
|
||||
if (!strcasecmp(ext.c_str(), szExtName))
|
||||
{
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFound)
|
||||
di.bSelected = false;
|
||||
}
|
||||
@@ -271,9 +284,11 @@ void ALDeviceList::FilterDevicesExtension(char *szExtName)
|
||||
*/
|
||||
void ALDeviceList::ResetFilters()
|
||||
{
|
||||
for (s32 i = 0; i < GetNumDevices(); i++) {
|
||||
for (s32 i = 0; i < GetNumDevices(); i++)
|
||||
{
|
||||
vDeviceInfo[i].bSelected = true;
|
||||
}
|
||||
|
||||
filterIndex = 0;
|
||||
}
|
||||
|
||||
@@ -284,11 +299,14 @@ s32 ALDeviceList::GetFirstFilteredDevice()
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < GetNumDevices(); i++) {
|
||||
if (vDeviceInfo[i].bSelected == true) {
|
||||
for (i = 0; i < GetNumDevices(); i++)
|
||||
{
|
||||
if (vDeviceInfo[i].bSelected == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
filterIndex = i + 1;
|
||||
return i;
|
||||
}
|
||||
@@ -300,11 +318,14 @@ s32 ALDeviceList::GetNextFilteredDevice()
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = filterIndex; i < GetNumDevices(); i++) {
|
||||
if (vDeviceInfo[i].bSelected == true) {
|
||||
for (i = filterIndex; i < GetNumDevices(); i++)
|
||||
{
|
||||
if (vDeviceInfo[i].bSelected == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
filterIndex = i + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -26,34 +26,43 @@
|
||||
namespace ArmGen
|
||||
{
|
||||
|
||||
inline u32 RotR(u32 a, int amount) {
|
||||
inline u32 RotR(u32 a, int amount)
|
||||
{
|
||||
if (!amount) return a;
|
||||
return (a >> amount) | (a << (32 - amount));
|
||||
}
|
||||
|
||||
inline u32 RotL(u32 a, int amount) {
|
||||
inline u32 RotL(u32 a, int amount)
|
||||
{
|
||||
if (!amount) return a;
|
||||
return (a << amount) | (a >> (32 - amount));
|
||||
}
|
||||
|
||||
bool TryMakeOperand2(u32 imm, Operand2 &op2) {
|
||||
bool TryMakeOperand2(u32 imm, Operand2 &op2)
|
||||
{
|
||||
// Just brute force it.
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
int mask = RotR(0xFF, i * 2);
|
||||
if ((imm & mask) == imm) {
|
||||
if ((imm & mask) == imm)
|
||||
{
|
||||
op2 = Operand2((u8)(RotL(imm, i * 2)), (u8)i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TryMakeOperand2_AllowInverse(u32 imm, Operand2 &op2, bool *inverse)
|
||||
{
|
||||
if (!TryMakeOperand2(imm, op2)) {
|
||||
if (!TryMakeOperand2(imm, op2))
|
||||
{
|
||||
*inverse = true;
|
||||
return TryMakeOperand2(~imm, op2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*inverse = false;
|
||||
return true;
|
||||
}
|
||||
@@ -61,16 +70,20 @@ bool TryMakeOperand2_AllowInverse(u32 imm, Operand2 &op2, bool *inverse)
|
||||
|
||||
bool TryMakeOperand2_AllowNegation(s32 imm, Operand2 &op2, bool *negated)
|
||||
{
|
||||
if (!TryMakeOperand2(imm, op2)) {
|
||||
if (!TryMakeOperand2(imm, op2))
|
||||
{
|
||||
*negated = true;
|
||||
return TryMakeOperand2(-imm, op2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*negated = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Operand2 AssumeMakeOperand2(u32 imm) {
|
||||
Operand2 AssumeMakeOperand2(u32 imm)
|
||||
{
|
||||
Operand2 op2;
|
||||
bool result = TryMakeOperand2(imm, op2);
|
||||
(void) result;
|
||||
@@ -93,10 +106,12 @@ bool ARMXEmitter::TrySetValue_TwoOp(ARMReg reg, u32 val)
|
||||
return false;
|
||||
|
||||
bool first = true;
|
||||
for (int i = 0; i < 16; i++, val >>=2) {
|
||||
if (val & 0x3) {
|
||||
for (int i = 0; i < 16; i++, val >>=2)
|
||||
{
|
||||
if (val & 0x3)
|
||||
{
|
||||
first ? MOV(reg, Operand2((u8)val, (u8)((16-i) & 0xF)))
|
||||
: ORR(reg, reg, Operand2((u8)val, (u8)((16-i) & 0xF)));
|
||||
: ORR(reg, reg, Operand2((u8)val, (u8)((16-i) & 0xF)));
|
||||
first = false;
|
||||
i+=3;
|
||||
val >>= 6;
|
||||
@@ -138,12 +153,15 @@ void ARMXEmitter::ADDI2R(ARMReg rd, ARMReg rs, u32 val, ARMReg scratch)
|
||||
{
|
||||
Operand2 op2;
|
||||
bool negated;
|
||||
if (TryMakeOperand2_AllowNegation(val, op2, &negated)) {
|
||||
if (TryMakeOperand2_AllowNegation(val, op2, &negated))
|
||||
{
|
||||
if (!negated)
|
||||
ADD(rd, rs, op2);
|
||||
else
|
||||
SUB(rd, rs, op2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
MOVI2R(scratch, val);
|
||||
ADD(rd, rs, scratch);
|
||||
}
|
||||
@@ -153,13 +171,19 @@ void ARMXEmitter::ANDI2R(ARMReg rd, ARMReg rs, u32 val, ARMReg scratch)
|
||||
{
|
||||
Operand2 op2;
|
||||
bool inverse;
|
||||
if (TryMakeOperand2_AllowInverse(val, op2, &inverse)) {
|
||||
if (!inverse) {
|
||||
if (TryMakeOperand2_AllowInverse(val, op2, &inverse))
|
||||
{
|
||||
if (!inverse)
|
||||
{
|
||||
AND(rd, rs, op2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
BIC(rd, rs, op2);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
MOVI2R(scratch, val);
|
||||
AND(rd, rs, scratch);
|
||||
}
|
||||
@@ -169,12 +193,15 @@ void ARMXEmitter::CMPI2R(ARMReg rs, u32 val, ARMReg scratch)
|
||||
{
|
||||
Operand2 op2;
|
||||
bool negated;
|
||||
if (TryMakeOperand2_AllowNegation(val, op2, &negated)) {
|
||||
if (TryMakeOperand2_AllowNegation(val, op2, &negated))
|
||||
{
|
||||
if (!negated)
|
||||
CMP(rs, op2);
|
||||
else
|
||||
CMN(rs, op2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
MOVI2R(scratch, val);
|
||||
CMP(rs, scratch);
|
||||
}
|
||||
@@ -183,9 +210,12 @@ void ARMXEmitter::CMPI2R(ARMReg rs, u32 val, ARMReg scratch)
|
||||
void ARMXEmitter::ORI2R(ARMReg rd, ARMReg rs, u32 val, ARMReg scratch)
|
||||
{
|
||||
Operand2 op2;
|
||||
if (TryMakeOperand2(val, op2)) {
|
||||
if (TryMakeOperand2(val, op2))
|
||||
{
|
||||
ORR(rd, rs, op2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
MOVI2R(scratch, val);
|
||||
ORR(rd, rs, scratch);
|
||||
}
|
||||
@@ -193,9 +223,11 @@ void ARMXEmitter::ORI2R(ARMReg rd, ARMReg rs, u32 val, ARMReg scratch)
|
||||
|
||||
void ARMXEmitter::FlushLitPool()
|
||||
{
|
||||
for (LiteralPool& pool : currentLitPool) {
|
||||
for (LiteralPool& pool : currentLitPool)
|
||||
{
|
||||
// Search for duplicates
|
||||
for (LiteralPool& old_pool : currentLitPool) {
|
||||
for (LiteralPool& old_pool : currentLitPool)
|
||||
{
|
||||
if (old_pool.val == pool.val)
|
||||
pool.loc = old_pool.loc;
|
||||
}
|
||||
@@ -235,16 +267,21 @@ void ARMXEmitter::MOVI2R(ARMReg reg, u32 val, bool optimize)
|
||||
MOVW(reg, val & 0xFFFF);
|
||||
MOVT(reg, val, true);
|
||||
}
|
||||
else if (TryMakeOperand2_AllowInverse(val, op2, &inverse)) {
|
||||
else if (TryMakeOperand2_AllowInverse(val, op2, &inverse))
|
||||
{
|
||||
inverse ? MVN(reg, op2) : MOV(reg, op2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cpu_info.bArmV7)
|
||||
{
|
||||
// Use MOVW+MOVT for ARMv7+
|
||||
MOVW(reg, val & 0xFFFF);
|
||||
if (val & 0xFFFF0000)
|
||||
MOVT(reg, val, true);
|
||||
} else if (!TrySetValue_TwoOp(reg,val)) {
|
||||
}
|
||||
else if (!TrySetValue_TwoOp(reg,val))
|
||||
{
|
||||
// Use literal pool for ARMv6.
|
||||
AddNewLit(val);
|
||||
LDR(reg, _PC); // To be backpatched later
|
||||
@@ -252,10 +289,14 @@ void ARMXEmitter::MOVI2R(ARMReg reg, u32 val, bool optimize)
|
||||
}
|
||||
}
|
||||
|
||||
void ARMXEmitter::QuickCallFunction(ARMReg reg, void *func) {
|
||||
if (BLInRange(func)) {
|
||||
void ARMXEmitter::QuickCallFunction(ARMReg reg, void *func)
|
||||
{
|
||||
if (BLInRange(func))
|
||||
{
|
||||
BL(func);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
MOVI2R(reg, (u32)(func));
|
||||
BL(reg);
|
||||
}
|
||||
@@ -327,7 +368,8 @@ void ARMXEmitter::SetCC(CCFlags cond)
|
||||
|
||||
void ARMXEmitter::NOP(int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Write32(condition | 0x01A00000);
|
||||
}
|
||||
}
|
||||
@@ -418,7 +460,8 @@ void ARMXEmitter::B(ARMReg src)
|
||||
Write32(condition | 0x12FFF10 | src);
|
||||
}
|
||||
|
||||
bool ARMXEmitter::BLInRange(const void *fnptr) {
|
||||
bool ARMXEmitter::BLInRange(const void *fnptr)
|
||||
{
|
||||
s32 distance = (s32)fnptr - (s32(code) + 8);
|
||||
if (distance <= -0x2000000 || distance > 0x2000000)
|
||||
return false;
|
||||
@@ -602,7 +645,8 @@ void ARMXEmitter::MULS(ARMReg dest, ARMReg src, ARMReg op2)
|
||||
Write32(condition | (1 << 20) | (dest << 16) | (src << 8) | (9 << 4) | op2);
|
||||
}
|
||||
|
||||
void ARMXEmitter::Write4OpMultiply(u32 op, ARMReg destLo, ARMReg destHi, ARMReg rm, ARMReg rn) {
|
||||
void ARMXEmitter::Write4OpMultiply(u32 op, ARMReg destLo, ARMReg destHi, ARMReg rm, ARMReg rn)
|
||||
{
|
||||
Write32(condition | (op << 20) | (destHi << 16) | (destLo << 12) | (rm << 8) | (9 << 4) | rn);
|
||||
}
|
||||
|
||||
@@ -1057,10 +1101,13 @@ void ARMXEmitter::VSTR(ARMReg Src, ARMReg Base, s16 offset)
|
||||
}
|
||||
}
|
||||
|
||||
void ARMXEmitter::VMRS(ARMReg Rt) {
|
||||
void ARMXEmitter::VMRS(ARMReg Rt)
|
||||
{
|
||||
Write32(condition | (0xEF << 20) | (1 << 16) | (Rt << 12) | 0xA10);
|
||||
}
|
||||
void ARMXEmitter::VMSR(ARMReg Rt) {
|
||||
|
||||
void ARMXEmitter::VMSR(ARMReg Rt)
|
||||
{
|
||||
Write32(condition | (0xEE << 20) | (1 << 16) | (Rt << 12) | 0xA10);
|
||||
}
|
||||
|
||||
@@ -1191,26 +1238,33 @@ void ARMXEmitter::VCVT(ARMReg Dest, ARMReg Source, int flags)
|
||||
{
|
||||
Write32(condition | (0x1D << 23) | ((Dest & 0x10) << 18) | (0x7 << 19) \
|
||||
| ((Dest & 0xF) << 12) | (op << 7) | (0x2D << 6) | ((Source & 0x1) << 5) | (Source >> 1));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Write32(condition | (0x1D << 23) | ((Dest & 0x1) << 22) | (0x7 << 19) | ((flags & TO_INT) << 18) | (op2 << 16) \
|
||||
| ((Dest & 0x1E) << 11) | (op << 7) | (0x2D << 6) | ((Source & 0x10) << 1) | (Source & 0xF));
|
||||
}
|
||||
}
|
||||
// F32<->F64
|
||||
else {
|
||||
else // F32<->F64
|
||||
{
|
||||
if (single_to_double)
|
||||
{
|
||||
Write32(condition | (0x1D << 23) | ((Dest & 0x10) << 18) | (0x3 << 20) | (0x7 << 16) \
|
||||
| ((Dest & 0xF) << 12) | (0x2B << 6) | ((Source & 0x1) << 5) | (Source >> 1));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Write32(condition | (0x1D << 23) | ((Dest & 0x1) << 22) | (0x3 << 20) | (0x7 << 16) \
|
||||
| ((Dest & 0x1E) << 11) | (0x2F << 6) | ((Source & 0x10) << 1) | (Source & 0xF));
|
||||
}
|
||||
}
|
||||
} else if (single_reg) {
|
||||
} else if (single_reg)
|
||||
{
|
||||
Write32(condition | (0x1D << 23) | ((Dest & 0x1) << 22) | (0x7 << 19) | ((flags & TO_INT) << 18) | (op2 << 16) \
|
||||
| ((Dest & 0x1E) << 11) | (op << 7) | (0x29 << 6) | ((Source & 0x1) << 5) | (Source >> 1));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Write32(condition | (0x1D << 23) | ((Dest & 0x10) << 18) | (0x7 << 19) | ((flags & TO_INT) << 18) | (op2 << 16) \
|
||||
| ((Dest & 0xF) << 12) | (1 << 8) | (op << 7) | (0x29 << 6) | ((Source & 0x10) << 1) | (Source & 0xF));
|
||||
}
|
||||
|
||||
@@ -25,23 +25,28 @@
|
||||
namespace Common
|
||||
{
|
||||
|
||||
inline void AtomicAdd(volatile u32& target, u32 value) {
|
||||
inline void AtomicAdd(volatile u32& target, u32 value)
|
||||
{
|
||||
__sync_add_and_fetch(&target, value);
|
||||
}
|
||||
|
||||
inline void AtomicAnd(volatile u32& target, u32 value) {
|
||||
inline void AtomicAnd(volatile u32& target, u32 value)
|
||||
{
|
||||
__sync_and_and_fetch(&target, value);
|
||||
}
|
||||
|
||||
inline void AtomicDecrement(volatile u32& target) {
|
||||
inline void AtomicDecrement(volatile u32& target)
|
||||
{
|
||||
__sync_add_and_fetch(&target, -1);
|
||||
}
|
||||
|
||||
inline void AtomicIncrement(volatile u32& target) {
|
||||
inline void AtomicIncrement(volatile u32& target)
|
||||
{
|
||||
__sync_add_and_fetch(&target, 1);
|
||||
}
|
||||
|
||||
inline void AtomicOr(volatile u32& target, u32 value) {
|
||||
inline void AtomicOr(volatile u32& target, u32 value)
|
||||
{
|
||||
__sync_or_and_fetch(&target, value);
|
||||
}
|
||||
|
||||
@@ -63,27 +68,32 @@ _Atomic(T)* ToC11Atomic(volatile T* loc)
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
inline T AtomicLoad(volatile T& src) {
|
||||
inline T AtomicLoad(volatile T& src)
|
||||
{
|
||||
return __atomic_load_n(&src, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T AtomicLoadAcquire(volatile T& src) {
|
||||
inline T AtomicLoadAcquire(volatile T& src)
|
||||
{
|
||||
return __atomic_load_n(&src, __ATOMIC_ACQUIRE);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline void AtomicStore(volatile T& dest, U value) {
|
||||
inline void AtomicStore(volatile T& dest, U value)
|
||||
{
|
||||
__atomic_store_n(&dest, value, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline void AtomicStoreRelease(volatile T& dest, U value) {
|
||||
inline void AtomicStoreRelease(volatile T& dest, U value)
|
||||
{
|
||||
__atomic_store_n(&dest, value, __ATOMIC_RELEASE);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline T* AtomicExchangeAcquire(T* volatile& loc, U newval) {
|
||||
inline T* AtomicExchangeAcquire(T* volatile& loc, U newval)
|
||||
{
|
||||
return __atomic_exchange_n(&loc, newval, __ATOMIC_ACQ_REL);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,51 +32,61 @@
|
||||
namespace Common
|
||||
{
|
||||
|
||||
inline void AtomicAdd(volatile u32& target, u32 value) {
|
||||
inline void AtomicAdd(volatile u32& target, u32 value)
|
||||
{
|
||||
_InterlockedExchangeAdd((volatile LONG*)&target, (LONG)value);
|
||||
}
|
||||
|
||||
inline void AtomicAnd(volatile u32& target, u32 value) {
|
||||
inline void AtomicAnd(volatile u32& target, u32 value)
|
||||
{
|
||||
_InterlockedAnd((volatile LONG*)&target, (LONG)value);
|
||||
}
|
||||
|
||||
inline void AtomicIncrement(volatile u32& target) {
|
||||
inline void AtomicIncrement(volatile u32& target)
|
||||
{
|
||||
_InterlockedIncrement((volatile LONG*)&target);
|
||||
}
|
||||
|
||||
inline void AtomicDecrement(volatile u32& target) {
|
||||
inline void AtomicDecrement(volatile u32& target)
|
||||
{
|
||||
_InterlockedDecrement((volatile LONG*)&target);
|
||||
}
|
||||
|
||||
inline void AtomicOr(volatile u32& target, u32 value) {
|
||||
inline void AtomicOr(volatile u32& target, u32 value)
|
||||
{
|
||||
_InterlockedOr((volatile LONG*)&target, (LONG)value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T AtomicLoad(volatile T& src) {
|
||||
inline T AtomicLoad(volatile T& src)
|
||||
{
|
||||
return src; // 32-bit reads are always atomic.
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T AtomicLoadAcquire(volatile T& src) {
|
||||
inline T AtomicLoadAcquire(volatile T& src)
|
||||
{
|
||||
T result = src; // 32-bit reads are always atomic.
|
||||
_ReadBarrier(); // Compiler instruction only. x86 loads always have acquire semantics.
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline void AtomicStore(volatile T& dest, U value) {
|
||||
inline void AtomicStore(volatile T& dest, U value)
|
||||
{
|
||||
dest = (T) value; // 32-bit writes are always atomic.
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline void AtomicStoreRelease(volatile T& dest, U value) {
|
||||
inline void AtomicStoreRelease(volatile T& dest, U value)
|
||||
{
|
||||
_WriteBarrier(); // Compiler instruction only. x86 stores always have release semantics.
|
||||
dest = (T) value; // 32-bit writes are always atomic.
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline T* AtomicExchangeAcquire(T* volatile& loc, U newval) {
|
||||
inline T* AtomicExchangeAcquire(T* volatile& loc, U newval)
|
||||
{
|
||||
return (T*) _InterlockedExchangePointer_acq((void* volatile*) &loc, (void*) newval);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,13 @@ struct TBreakPoint
|
||||
|
||||
struct TMemCheck
|
||||
{
|
||||
TMemCheck() {
|
||||
TMemCheck()
|
||||
{
|
||||
numHits = 0;
|
||||
StartAddress = EndAddress = 0;
|
||||
bRange = OnRead = OnWrite = Log = Break = false;
|
||||
}
|
||||
|
||||
u32 StartAddress;
|
||||
u32 EndAddress;
|
||||
|
||||
|
||||
@@ -74,25 +74,29 @@ _mm_shuffle_epi8(__m128i a, __m128i mask)
|
||||
// GCC 4.8 defines all the rotate functions now
|
||||
// Small issue with GCC's lrotl/lrotr intrinsics is they are still 32bit while we require 64bit
|
||||
#ifndef _rotl
|
||||
inline u32 _rotl(u32 x, int shift) {
|
||||
inline u32 _rotl(u32 x, int shift)
|
||||
{
|
||||
shift &= 31;
|
||||
if (!shift) return x;
|
||||
return (x << shift) | (x >> (32 - shift));
|
||||
}
|
||||
|
||||
inline u32 _rotr(u32 x, int shift) {
|
||||
inline u32 _rotr(u32 x, int shift)
|
||||
{
|
||||
shift &= 31;
|
||||
if (!shift) return x;
|
||||
return (x >> shift) | (x << (32 - shift));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline u64 _rotl64(u64 x, unsigned int shift){
|
||||
inline u64 _rotl64(u64 x, unsigned int shift)
|
||||
{
|
||||
unsigned int n = shift % 64;
|
||||
return (x << n) | (x >> (64 - n));
|
||||
}
|
||||
|
||||
inline u64 _rotr64(u64 x, unsigned int shift){
|
||||
inline u64 _rotr64(u64 x, unsigned int shift)
|
||||
{
|
||||
unsigned int n = shift % 64;
|
||||
return (x >> n) | (x << (64 - n));
|
||||
}
|
||||
|
||||
@@ -92,7 +92,8 @@ static void InitSymbolPath( PSTR lpszSymbolPath, PCSTR lpszIniPath )
|
||||
}
|
||||
|
||||
// Uninitialize the loaded symbol files
|
||||
BOOL UninitSymInfo() {
|
||||
BOOL UninitSymInfo()
|
||||
{
|
||||
return SymCleanup( GetCurrentProcess() );
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,8 @@ bool IsDirectory(const std::string &filename)
|
||||
int result = stat64(copy.c_str(), &file_info);
|
||||
#endif
|
||||
|
||||
if (result < 0) {
|
||||
if (result < 0)
|
||||
{
|
||||
WARN_LOG(COMMON, "IsDirectory: stat failed on %s: %s",
|
||||
filename.c_str(), GetLastErrorMsg());
|
||||
return false;
|
||||
@@ -133,7 +134,8 @@ bool Delete(const std::string &filename)
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (unlink(filename.c_str()) == -1) {
|
||||
if (unlink(filename.c_str()) == -1)
|
||||
{
|
||||
WARN_LOG(COMMON, "Delete: unlink failed on %s: %s",
|
||||
filename.c_str(), GetLastErrorMsg());
|
||||
return false;
|
||||
@@ -413,7 +415,8 @@ u64 GetSize(const std::string &filename)
|
||||
u64 GetSize(const int fd)
|
||||
{
|
||||
struct stat64 buf;
|
||||
if (fstat64(fd, &buf) != 0) {
|
||||
if (fstat64(fd, &buf) != 0)
|
||||
{
|
||||
ERROR_LOG(COMMON, "GetSize: stat failed %i: %s",
|
||||
fd, GetLastErrorMsg());
|
||||
return 0;
|
||||
@@ -426,17 +429,21 @@ u64 GetSize(FILE *f)
|
||||
{
|
||||
// can't use off_t here because it can be 32-bit
|
||||
u64 pos = ftello(f);
|
||||
if (fseeko(f, 0, SEEK_END) != 0) {
|
||||
if (fseeko(f, 0, SEEK_END) != 0)
|
||||
{
|
||||
ERROR_LOG(COMMON, "GetSize: seek failed %p: %s",
|
||||
f, GetLastErrorMsg());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u64 size = ftello(f);
|
||||
if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) {
|
||||
if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0))
|
||||
{
|
||||
ERROR_LOG(COMMON, "GetSize: seek failed %p: %s",
|
||||
f, GetLastErrorMsg());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -658,8 +665,8 @@ std::string GetCurrentDir()
|
||||
{
|
||||
char *dir;
|
||||
// Get the current working directory (getcwd uses malloc)
|
||||
if (!(dir = __getcwd(nullptr, 0))) {
|
||||
|
||||
if (!(dir = __getcwd(nullptr, 0)))
|
||||
{
|
||||
ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s",
|
||||
GetLastErrorMsg());
|
||||
return nullptr;
|
||||
|
||||
@@ -36,13 +36,15 @@ public:
|
||||
delete [] storage;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
void clear()
|
||||
{
|
||||
head = 0;
|
||||
tail = 0;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
void push(T t) {
|
||||
void push(T t)
|
||||
{
|
||||
storage[tail] = t;
|
||||
tail++;
|
||||
if (tail == N)
|
||||
@@ -50,14 +52,16 @@ public:
|
||||
count++;
|
||||
}
|
||||
|
||||
void pop() {
|
||||
void pop()
|
||||
{
|
||||
head++;
|
||||
if (head == N)
|
||||
head = 0;
|
||||
count--;
|
||||
}
|
||||
|
||||
T pop_front() {
|
||||
T pop_front()
|
||||
{
|
||||
const T &temp = storage[head];
|
||||
pop();
|
||||
return temp;
|
||||
@@ -66,7 +70,8 @@ public:
|
||||
T &front() { return storage[head]; }
|
||||
const T &front() const { return storage[head]; }
|
||||
|
||||
size_t size() const {
|
||||
size_t size() const
|
||||
{
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,24 +40,31 @@ public:
|
||||
|
||||
bool Get(const std::string& key, std::string* value, const std::string& defaultValue = NULL_STRING);
|
||||
|
||||
void Set(const std::string& key, u32 newValue) {
|
||||
void Set(const std::string& key, u32 newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("0x%08x", newValue));
|
||||
}
|
||||
void Set(const std::string& key, float newValue) {
|
||||
|
||||
void Set(const std::string& key, float newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("%f", newValue));
|
||||
}
|
||||
|
||||
void Set(const std::string& key, const float newValue, const float defaultValue);
|
||||
void Set(const std::string& key, double newValue) {
|
||||
void Set(const std::string& key, double newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("%f", newValue));
|
||||
}
|
||||
|
||||
void Set(const std::string& key, int newValue, int defaultValue);
|
||||
void Set(const std::string& key, int newValue) {
|
||||
void Set(const std::string& key, int newValue)
|
||||
{
|
||||
Set(key, StringFromInt(newValue));
|
||||
}
|
||||
|
||||
void Set(const std::string& key, bool newValue, bool defaultValue);
|
||||
void Set(const std::string& key, bool newValue) {
|
||||
void Set(const std::string& key, bool newValue)
|
||||
{
|
||||
Set(key, StringFromBool(newValue));
|
||||
}
|
||||
void Set(const std::string& key, const std::vector<std::string>& newValues);
|
||||
@@ -69,7 +76,8 @@ public:
|
||||
bool Get(const std::string& key, double* value, double defaultValue = false);
|
||||
bool Get(const std::string& key, std::vector<std::string>* values);
|
||||
|
||||
bool operator < (const Section& other) const {
|
||||
bool operator < (const Section& other) const
|
||||
{
|
||||
return name < other.name;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,8 @@ u8* MemArena::Find4GBBase()
|
||||
#endif
|
||||
const u32 MemSize = 0x31000000;
|
||||
void* base = mmap(0, MemSize, PROT_NONE, flags, -1, 0);
|
||||
if (base == MAP_FAILED) {
|
||||
if (base == MAP_FAILED)
|
||||
{
|
||||
PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
@@ -170,7 +171,8 @@ u8* MemArena::Find4GBBase()
|
||||
continue; \
|
||||
|
||||
|
||||
static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 flags, MemArena *arena) {
|
||||
static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 flags, MemArena *arena)
|
||||
{
|
||||
// OK, we know where to find free space. Now grab it!
|
||||
// We just mimic the popular BAT setup.
|
||||
u32 position = 0;
|
||||
@@ -189,9 +191,12 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
|
||||
for (i = 0; i < num_views; i++)
|
||||
{
|
||||
SKIP(flags, views[i].flags);
|
||||
if (views[i].flags & MV_MIRROR_PREVIOUS) {
|
||||
if (views[i].flags & MV_MIRROR_PREVIOUS)
|
||||
{
|
||||
position = last_position;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*(views[i].out_ptr_low) = (u8*)arena->CreateView(position, views[i].size);
|
||||
if (!*views[i].out_ptr_low)
|
||||
goto bail;
|
||||
@@ -200,10 +205,13 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
|
||||
*views[i].out_ptr = (u8*)arena->CreateView(
|
||||
position, views[i].size, base + views[i].virtual_address);
|
||||
#else
|
||||
if (views[i].flags & MV_MIRROR_PREVIOUS) {
|
||||
if (views[i].flags & MV_MIRROR_PREVIOUS)
|
||||
{
|
||||
// No need to create multiple identical views.
|
||||
*views[i].out_ptr = *views[i - 1].out_ptr;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
*views[i].out_ptr = (u8*)arena->CreateView(
|
||||
position, views[i].size, base + (views[i].virtual_address & 0x3FFFFFFF));
|
||||
if (!*views[i].out_ptr)
|
||||
|
||||
@@ -84,13 +84,15 @@ void SettingsHandler::Reset()
|
||||
|
||||
void SettingsHandler::AddSetting(const std::string& key, const std::string& value)
|
||||
{
|
||||
for (const char& c : key) {
|
||||
for (const char& c : key)
|
||||
{
|
||||
WriteByte(c);
|
||||
}
|
||||
|
||||
WriteByte('=');
|
||||
|
||||
for (const char& c : value) {
|
||||
for (const char& c : value)
|
||||
{
|
||||
WriteByte(c);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user