Merge pull request #911 from lioncash/braces

Clean up brace placements within the project.
This commit is contained in:
Lioncash 2014-08-30 18:20:13 -04:00
commit 2c7bcd0d04
97 changed files with 849 additions and 484 deletions

View File

@ -40,7 +40,8 @@ public:
virtual void Stop() override;
static bool isValid() {
static bool isValid()
{
return true;
}

View File

@ -23,7 +23,8 @@ public:
virtual void SoundLoop() override;
virtual void Stop() override;
static bool isValid() {
static bool isValid()
{
return true;
}

View File

@ -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,

View File

@ -22,7 +22,8 @@ public:
virtual void SoundLoop();
virtual void Stop();
static bool isValid() {
static bool isValid()
{
return true;
}

View File

@ -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

View File

@ -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;

View File

@ -19,7 +19,8 @@ PulseAudio::PulseAudio(CMixer *mixer)
: SoundStream(mixer)
, m_thread()
, m_run_thread()
{}
{
}
bool PulseAudio::Start()
{

View File

@ -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");
}
}

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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));
}

View File

@ -92,7 +92,8 @@ static void InitSymbolPath( PSTR lpszSymbolPath, PCSTR lpszIniPath )
}
// Uninitialize the loaded symbol files
BOOL UninitSymInfo() {
BOOL UninitSymInfo()
{
return SymCleanup( GetCurrentProcess() );
}

View File

@ -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;

View File

@ -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;
}
};

View File

@ -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;
}

View File

@ -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)

View File

@ -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);
}

View File

@ -10,22 +10,28 @@ using namespace Gen;
// Shared code between Win64 and Unix64
unsigned int XEmitter::ABI_GetAlignedFrameSize(unsigned int frameSize, bool noProlog) {
unsigned int XEmitter::ABI_GetAlignedFrameSize(unsigned int frameSize, bool noProlog)
{
frameSize = noProlog ? 0x28 : 0;
return frameSize;
}
void XEmitter::ABI_AlignStack(unsigned int frameSize, bool noProlog) {
unsigned int fillSize =
ABI_GetAlignedFrameSize(frameSize, noProlog) - frameSize;
if (fillSize != 0) {
void XEmitter::ABI_AlignStack(unsigned int frameSize, bool noProlog)
{
unsigned int fillSize = ABI_GetAlignedFrameSize(frameSize, noProlog) - frameSize;
if (fillSize != 0)
{
SUB(64, R(RSP), Imm8(fillSize));
}
}
void XEmitter::ABI_RestoreStack(unsigned int frameSize, bool noProlog) {
void XEmitter::ABI_RestoreStack(unsigned int frameSize, bool noProlog)
{
unsigned int alignedSize = ABI_GetAlignedFrameSize(frameSize, noProlog);
if (alignedSize != 0) {
if (alignedSize != 0)
{
ADD(64, R(RSP), Imm8(alignedSize));
}
}
@ -101,7 +107,8 @@ void XEmitter::ABI_PopRegistersAndAdjustStack(u32 mask, bool noProlog)
}
// Common functions
void XEmitter::ABI_CallFunction(void *func) {
void XEmitter::ABI_CallFunction(void *func)
{
ABI_AlignStack(0);
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL &&
@ -118,7 +125,8 @@ void XEmitter::ABI_CallFunction(void *func) {
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) {
void XEmitter::ABI_CallFunctionC16(void *func, u16 param1)
{
ABI_AlignStack(0);
MOV(32, R(ABI_PARAM1), Imm32((u32)param1));
u64 distance = u64(func) - (u64(code) + 5);
@ -136,7 +144,8 @@ void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) {
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionCC16(void *func, u32 param1, u16 param2) {
void XEmitter::ABI_CallFunctionCC16(void *func, u32 param1, u16 param2)
{
ABI_AlignStack(0);
MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32((u32)param2));
@ -155,7 +164,8 @@ void XEmitter::ABI_CallFunctionCC16(void *func, u32 param1, u16 param2) {
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionC(void *func, u32 param1) {
void XEmitter::ABI_CallFunctionC(void *func, u32 param1)
{
ABI_AlignStack(0);
MOV(32, R(ABI_PARAM1), Imm32(param1));
u64 distance = u64(func) - (u64(code) + 5);
@ -173,7 +183,8 @@ void XEmitter::ABI_CallFunctionC(void *func, u32 param1) {
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionCC(void *func, u32 param1, u32 param2) {
void XEmitter::ABI_CallFunctionCC(void *func, u32 param1, u32 param2)
{
ABI_AlignStack(0);
MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32(param2));
@ -192,7 +203,8 @@ void XEmitter::ABI_CallFunctionCC(void *func, u32 param1, u32 param2) {
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionCP(void *func, u32 param1, void *param2) {
void XEmitter::ABI_CallFunctionCP(void *func, u32 param1, void *param2)
{
ABI_AlignStack(0);
MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(64, R(ABI_PARAM2), Imm64((u64)param2));
@ -211,7 +223,8 @@ void XEmitter::ABI_CallFunctionCP(void *func, u32 param1, void *param2) {
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param3) {
void XEmitter::ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param3)
{
ABI_AlignStack(0);
MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32(param2));
@ -231,7 +244,8 @@ void XEmitter::ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *param3) {
void XEmitter::ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *param3)
{
ABI_AlignStack(0);
MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32(param2));
@ -251,7 +265,8 @@ void XEmitter::ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *par
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionCCCP(void *func, u32 param1, u32 param2, u32 param3, void *param4) {
void XEmitter::ABI_CallFunctionCCCP(void *func, u32 param1, u32 param2, u32 param3, void *param4)
{
ABI_AlignStack(0);
MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32(param2));
@ -272,7 +287,8 @@ void XEmitter::ABI_CallFunctionCCCP(void *func, u32 param1, u32 param2, u32 para
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionPC(void *func, void *param1, u32 param2) {
void XEmitter::ABI_CallFunctionPC(void *func, void *param1, u32 param2)
{
ABI_AlignStack(0);
MOV(64, R(ABI_PARAM1), Imm64((u64)param1));
MOV(32, R(ABI_PARAM2), Imm32(param2));
@ -291,7 +307,8 @@ void XEmitter::ABI_CallFunctionPC(void *func, void *param1, u32 param2) {
ABI_RestoreStack(0);
}
void XEmitter::ABI_CallFunctionPPC(void *func, void *param1, void *param2, u32 param3) {
void XEmitter::ABI_CallFunctionPPC(void *func, void *param1, void *param2, u32 param3)
{
ABI_AlignStack(0);
MOV(64, R(ABI_PARAM1), Imm64((u64)param1));
MOV(64, R(ABI_PARAM2), Imm64((u64)param2));
@ -312,7 +329,8 @@ void XEmitter::ABI_CallFunctionPPC(void *func, void *param1, void *param2, u32 p
}
// Pass a register as a parameter.
void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1) {
void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1)
{
ABI_AlignStack(0);
if (reg1 != ABI_PARAM1)
MOV(32, R(ABI_PARAM1), R(reg1));
@ -332,7 +350,8 @@ void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1) {
}
// Pass two registers as parameters.
void XEmitter::ABI_CallFunctionRR(void *func, X64Reg reg1, X64Reg reg2, bool noProlog) {
void XEmitter::ABI_CallFunctionRR(void *func, X64Reg reg1, X64Reg reg2, bool noProlog)
{
ABI_AlignStack(0, noProlog);
if (reg2 != ABI_PARAM1)
{
@ -407,7 +426,8 @@ void XEmitter::ABI_CallFunctionA(void *func, const Gen::OpArg &arg1)
#ifdef _WIN32
// Win64 Specific Code
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack()
{
//we only want to do this once
PUSH(RBP);
MOV(64, R(RBP), R(RSP));
@ -422,7 +442,8 @@ void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
//TODO: Also preserve XMM0-3?
}
void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() {
void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack()
{
ADD(64, R(RSP), Imm8(0x28));
POP(R15);
POP(R14);
@ -437,7 +458,8 @@ void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() {
#else
// Unix64 Specific Code
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack()
{
PUSH(RBP);
MOV(64, R(RBP), R(RSP));
PUSH(RBX);
@ -448,7 +470,8 @@ void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() {
SUB(64, R(RSP), Imm8(8));
}
void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() {
void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack()
{
ADD(64, R(RSP), Imm8(8));
POP(R15);
POP(R14);

View File

@ -142,8 +142,9 @@ void OpArg::WriteRex(XEmitter *emit, int opBits, int bits, int customOp) const
// Write REX if wr have REX bits to write, or if the operation accesses
// SIL, DIL, BPL, or SPL.
if (op != 0x40 ||
(scale == SCALE_NONE && bits == 8 && (offsetOrBaseReg & 0x10c) == 4) ||
(opBits == 8 && (customOp & 0x10c) == 4)) {
(scale == SCALE_NONE && bits == 8 && (offsetOrBaseReg & 0x10c) == 4) ||
(opBits == 8 && (customOp & 0x10c) == 4))
{
emit->Write8(op);
// Check the operation doesn't access AH, BH, CH, or DH.
_dbg_assert_(DYNA_REC, (offsetOrBaseReg & 0x100) == 0);
@ -773,7 +774,8 @@ void XEmitter::BSR(int bits, X64Reg dest, OpArg src) {WriteBitSearchType(bits,de
void XEmitter::MOVSX(int dbits, int sbits, X64Reg dest, OpArg src)
{
if (src.IsImm()) _assert_msg_(DYNA_REC, 0, "MOVSX - Imm argument");
if (dbits == sbits) {
if (dbits == sbits)
{
MOV(dbits, R(dest), src);
return;
}
@ -804,7 +806,8 @@ void XEmitter::MOVSX(int dbits, int sbits, X64Reg dest, OpArg src)
void XEmitter::MOVZX(int dbits, int sbits, X64Reg dest, OpArg src)
{
if (src.IsImm()) _assert_msg_(DYNA_REC, 0, "MOVZX - Imm argument");
if (dbits == sbits) {
if (dbits == sbits)
{
MOV(dbits, R(dest), src);
return;
}
@ -1181,14 +1184,18 @@ void XEmitter::XCHG(int bits, const OpArg &a1, const OpArg &a2) {WriteNormalOp(t
void XEmitter::IMUL(int bits, X64Reg regOp, OpArg a1, OpArg a2)
{
if (bits == 8) {
if (bits == 8)
{
_assert_msg_(DYNA_REC, 0, "IMUL - illegal bit size!");
return;
}
if (a1.IsImm()) {
if (a1.IsImm())
{
_assert_msg_(DYNA_REC, 0, "IMUL - second arg cannot be imm!");
return;
}
if (!a2.IsImm())
{
_assert_msg_(DYNA_REC, 0, "IMUL - third arg must be imm!");
@ -1201,20 +1208,27 @@ void XEmitter::IMUL(int bits, X64Reg regOp, OpArg a1, OpArg a2)
if (a2.GetImmBits() == 8 ||
(a2.GetImmBits() == 16 && (s8)a2.offset == (s16)a2.offset) ||
(a2.GetImmBits() == 32 && (s8)a2.offset == (s32)a2.offset)) {
(a2.GetImmBits() == 32 && (s8)a2.offset == (s32)a2.offset))
{
Write8(0x6B);
a1.WriteRest(this, 1, regOp);
Write8((u8)a2.offset);
} else {
}
else
{
Write8(0x69);
if (a2.GetImmBits() == 16 && bits == 16) {
if (a2.GetImmBits() == 16 && bits == 16)
{
a1.WriteRest(this, 2, regOp);
Write16((u16)a2.offset);
} else if (a2.GetImmBits() == 32 &&
(bits == 32 || bits == 64)) {
a1.WriteRest(this, 4, regOp);
Write32((u32)a2.offset);
} else {
}
else if (a2.GetImmBits() == 32 && (bits == 32 || bits == 64))
{
a1.WriteRest(this, 4, regOp);
Write32((u32)a2.offset);
}
else
{
_assert_msg_(DYNA_REC, 0, "IMUL - unhandled case!");
}
}
@ -1222,10 +1236,12 @@ void XEmitter::IMUL(int bits, X64Reg regOp, OpArg a1, OpArg a2)
void XEmitter::IMUL(int bits, X64Reg regOp, OpArg a)
{
if (bits == 8) {
if (bits == 8)
{
_assert_msg_(DYNA_REC, 0, "IMUL - illegal bit size!");
return;
}
if (a.IsImm())
{
IMUL(bits, regOp, R(regOp), a) ;
@ -1283,7 +1299,8 @@ void XEmitter::WriteAVXOp(int size, u16 sseOp, bool packed, X64Reg regOp1, X64Re
void XEmitter::MOVD_xmm(X64Reg dest, const OpArg &arg) {WriteSSEOp(64, 0x6E, true, dest, arg, 0);}
void XEmitter::MOVD_xmm(const OpArg &arg, X64Reg src) {WriteSSEOp(64, 0x7E, true, src, arg, 0);}
void XEmitter::MOVQ_xmm(X64Reg dest, OpArg arg) {
void XEmitter::MOVQ_xmm(X64Reg dest, OpArg arg)
{
// Alternate encoding
// This does not display correctly in MSVC's debugger, it thinks it's a MOVD
arg.operandReg = dest;
@ -1294,7 +1311,8 @@ void XEmitter::MOVQ_xmm(X64Reg dest, OpArg arg) {
arg.WriteRest(this, 0);
}
void XEmitter::MOVQ_xmm(OpArg arg, X64Reg src) {
void XEmitter::MOVQ_xmm(OpArg arg, X64Reg src)
{
if (src > 7 || arg.IsSimpleReg())
{
// Alternate encoding
@ -1305,7 +1323,9 @@ void XEmitter::MOVQ_xmm(OpArg arg, X64Reg src) {
Write8(0x0f);
Write8(0x7E);
arg.WriteRest(this, 0);
} else {
}
else
{
arg.operandReg = src;
arg.WriteRex(this, 0, 0);
Write8(0x66);
@ -1466,42 +1486,50 @@ void XEmitter::PUNPCKLWD(X64Reg dest, const OpArg &arg) {WriteSSEOp(64, 0x61, tr
void XEmitter::PUNPCKLDQ(X64Reg dest, const OpArg &arg) {WriteSSEOp(64, 0x62, true, dest, arg);}
//void PUNPCKLQDQ(X64Reg dest, OpArg arg) {WriteSSEOp(64, 0x60, true, dest, arg);}
void XEmitter::PSRLW(X64Reg reg, int shift) {
void XEmitter::PSRLW(X64Reg reg, int shift)
{
WriteSSEOp(64, 0x71, true, (X64Reg)2, R(reg));
Write8(shift);
}
void XEmitter::PSRLD(X64Reg reg, int shift) {
void XEmitter::PSRLD(X64Reg reg, int shift)
{
WriteSSEOp(64, 0x72, true, (X64Reg)2, R(reg));
Write8(shift);
}
void XEmitter::PSRLQ(X64Reg reg, int shift) {
void XEmitter::PSRLQ(X64Reg reg, int shift)
{
WriteSSEOp(64, 0x73, true, (X64Reg)2, R(reg));
Write8(shift);
}
void XEmitter::PSRLQ(X64Reg reg, OpArg arg) {
void XEmitter::PSRLQ(X64Reg reg, OpArg arg)
{
WriteSSEOp(64, 0xd3, true, reg, arg);
}
void XEmitter::PSLLW(X64Reg reg, int shift) {
void XEmitter::PSLLW(X64Reg reg, int shift)
{
WriteSSEOp(64, 0x71, true, (X64Reg)6, R(reg));
Write8(shift);
}
void XEmitter::PSLLD(X64Reg reg, int shift) {
void XEmitter::PSLLD(X64Reg reg, int shift)
{
WriteSSEOp(64, 0x72, true, (X64Reg)6, R(reg));
Write8(shift);
}
void XEmitter::PSLLQ(X64Reg reg, int shift) {
void XEmitter::PSLLQ(X64Reg reg, int shift)
{
WriteSSEOp(64, 0x73, true, (X64Reg)6, R(reg));
Write8(shift);
}
// WARNING not REX compatible
void XEmitter::PSRAW(X64Reg reg, int shift) {
void XEmitter::PSRAW(X64Reg reg, int shift)
{
if (reg > 7)
PanicAlert("The PSRAW-emitter does not support regs above 7");
Write8(0x66);
@ -1512,7 +1540,8 @@ void XEmitter::PSRAW(X64Reg reg, int shift) {
}
// WARNING not REX compatible
void XEmitter::PSRAD(X64Reg reg, int shift) {
void XEmitter::PSRAD(X64Reg reg, int shift)
{
if (reg > 7)
PanicAlert("The PSRAD-emitter does not support regs above 7");
Write8(0x66);
@ -1632,11 +1661,14 @@ void XEmitter::FWAIT()
void XEmitter::WriteFloatLoadStore(int bits, FloatOp op, OpArg arg)
{
int mf = 0;
switch (bits) {
case 32: mf = 0; break;
case 64: mf = 2; break;
default: _assert_msg_(DYNA_REC, 0, "WriteFloatLoadStore: bits is not 32 or 64");
switch (bits)
{
case 32: mf = 0; break;
case 64: mf = 2; break;
default: _assert_msg_(DYNA_REC, 0, "WriteFloatLoadStore: bits is not 32 or 64");
}
Write8(0xd9 | (mf << 1));
// x87 instructions use the reg field of the ModR/M byte as opcode:
arg.WriteRest(this, 0, (X64Reg) op);
@ -1727,20 +1759,23 @@ void XEmitter::CallCdeclFunction6(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32
}
// See header
void XEmitter::___CallCdeclImport3(void* impptr, u32 arg0, u32 arg1, u32 arg2) {
void XEmitter::___CallCdeclImport3(void* impptr, u32 arg0, u32 arg1, u32 arg2)
{
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
CALLptr(M(impptr));
}
void XEmitter::___CallCdeclImport4(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3) {
void XEmitter::___CallCdeclImport4(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3)
{
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
CALLptr(M(impptr));
}
void XEmitter::___CallCdeclImport5(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4) {
void XEmitter::___CallCdeclImport5(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4)
{
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
@ -1748,7 +1783,8 @@ void XEmitter::___CallCdeclImport5(void* impptr, u32 arg0, u32 arg1, u32 arg2, u
MOV(32, MDisp(RSP, 0x20), Imm32(arg4));
CALLptr(M(impptr));
}
void XEmitter::___CallCdeclImport6(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5) {
void XEmitter::___CallCdeclImport6(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5)
{
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));

View File

@ -134,7 +134,8 @@ struct OpArg
void WriteNormalOp(XEmitter *emit, bool toRM, NormalOp op, const OpArg &operand, int bits) const;
bool IsImm() const {return scale == SCALE_IMM8 || scale == SCALE_IMM16 || scale == SCALE_IMM32 || scale == SCALE_IMM64;}
bool IsSimpleReg() const {return scale == SCALE_NONE;}
bool IsSimpleReg(X64Reg reg) const {
bool IsSimpleReg(X64Reg reg) const
{
if (!IsSimpleReg())
return false;
return GetSimpleReg() == reg;
@ -175,21 +176,30 @@ private:
inline OpArg M(const void *ptr) {return OpArg((u64)ptr, (int)SCALE_RIP);}
inline OpArg R(X64Reg value) {return OpArg(0, SCALE_NONE, value);}
inline OpArg MatR(X64Reg value) {return OpArg(0, SCALE_ATREG, value);}
inline OpArg MDisp(X64Reg value, int offset) {
inline OpArg MDisp(X64Reg value, int offset)
{
return OpArg((u32)offset, SCALE_ATREG, value);
}
inline OpArg MComplex(X64Reg base, X64Reg scaled, int scale, int offset) {
inline OpArg MComplex(X64Reg base, X64Reg scaled, int scale, int offset)
{
return OpArg(offset, scale, base, scaled);
}
inline OpArg MScaled(X64Reg scaled, int scale, int offset) {
inline OpArg MScaled(X64Reg scaled, int scale, int offset)
{
if (scale == SCALE_1)
return OpArg(offset, SCALE_ATREG, scaled);
else
return OpArg(offset, scale | 0x20, RAX, scaled);
}
inline OpArg MRegSum(X64Reg base, X64Reg offset) {
inline OpArg MRegSum(X64Reg base, X64Reg offset)
{
return MComplex(base, offset, 1, 0);
}
inline OpArg Imm8 (u8 imm) {return OpArg(imm, SCALE_IMM8);}
inline OpArg Imm16(u16 imm) {return OpArg(imm, SCALE_IMM16);} //rarely used
inline OpArg Imm32(u32 imm) {return OpArg(imm, SCALE_IMM32);}
@ -199,14 +209,18 @@ inline OpArg ImmPtr(const void* imm) {return Imm64((u64)imm);}
#else
inline OpArg ImmPtr(const void* imm) {return Imm32((u32)imm);}
#endif
inline u32 PtrOffset(void* ptr, void* base) {
inline u32 PtrOffset(void* ptr, void* base)
{
#ifdef _ARCH_64
s64 distance = (s64)ptr-(s64)base;
if (distance >= 0x80000000LL ||
distance < -0x80000000LL) {
distance < -0x80000000LL)
{
_assert_msg_(DYNA_REC, 0, "pointer offset out of range");
return 0;
}
return (u32)distance;
#else
return (u32)ptr-(u32)base;

View File

@ -69,7 +69,8 @@ public:
int GetSectionSize(SectionID section) const { return sections[section].sh_size; }
SectionID GetSectionByName(const char *name, int firstSection = 0) const; //-1 for not found
bool DidRelocate() {
bool DidRelocate()
{
return bRelocate;
}
};

View File

@ -275,7 +275,8 @@ bool IsScheduled(int event_type)
if (!first)
return false;
Event *e = first;
while (e) {
while (e)
{
if (e->type == event_type)
return true;
e = e->next;

View File

@ -539,7 +539,9 @@ bool DSPAssembler::VerifyParams(const opc_t *opc, param_t *par, int count, bool
if ((int)par[i].val < value ||
(int)par[i].val > value + get_mask_shifted_down(opc->params[i].mask))
{
if (ext) fprintf(stderr, "(ext) ");
if (ext)
fprintf(stderr, "(ext) ");
fprintf(stderr, "%s (param %i)", cur_line.c_str(), current_param);
ShowError(ERR_INVALID_REGISTER);
}
@ -547,7 +549,9 @@ bool DSPAssembler::VerifyParams(const opc_t *opc, param_t *par, int count, bool
case P_PRG:
if ((int)par[i].val < 0 || (int)par[i].val > 0x3)
{
if (ext) fprintf(stderr, "(ext) ");
if (ext)
fprintf(stderr, "(ext) ");
fprintf(stderr, "%s (param %i)", cur_line.c_str(), current_param);
ShowError(ERR_INVALID_REGISTER);
}
@ -555,52 +559,71 @@ bool DSPAssembler::VerifyParams(const opc_t *opc, param_t *par, int count, bool
case P_ACC:
if ((int)par[i].val < 0x20 || (int)par[i].val > 0x21)
{
if (ext) fprintf(stderr, "(ext) ");
if (par[i].val >= 0x1e && par[i].val <= 0x1f) {
if (ext)
fprintf(stderr, "(ext) ");
if (par[i].val >= 0x1e && par[i].val <= 0x1f)
{
fprintf(stderr, "%i : %s ", code_line, cur_line.c_str());
fprintf(stderr, "WARNING: $ACM%d register used instead of $ACC%d register Line: %d Param: %d Ext: %d\n",
(par[i].val & 1), (par[i].val & 1), code_line, current_param, ext);
}
else if (par[i].val >= 0x1c && par[i].val <= 0x1d) {
else if (par[i].val >= 0x1c && par[i].val <= 0x1d)
{
fprintf(stderr, "WARNING: $ACL%d register used instead of $ACC%d register Line: %d Param: %d\n",
(par[i].val & 1), (par[i].val & 1), code_line, current_param);
}
else
{
ShowError(ERR_WRONG_PARAMETER_ACC);
}
}
break;
case P_ACCM:
if ((int)par[i].val < 0x1e || (int)par[i].val > 0x1f)
{
if (ext) fprintf(stderr, "(ext) ");
if (ext)
fprintf(stderr, "(ext) ");
if (par[i].val >= 0x1c && par[i].val <= 0x1d)
{
fprintf(stderr, "WARNING: $ACL%d register used instead of $ACM%d register Line: %d Param: %d\n",
(par[i].val & 1), (par[i].val & 1), code_line, current_param);
}
else if (par[i].val >= 0x20 && par[i].val <= 0x21)
{
fprintf(stderr, "WARNING: $ACC%d register used instead of $ACM%d register Line: %d Param: %d\n",
(par[i].val & 1), (par[i].val & 1), code_line, current_param);
}
else
{
ShowError(ERR_WRONG_PARAMETER_ACC);
}
}
break;
case P_ACCL:
if ((int)par[i].val < 0x1c || (int)par[i].val > 0x1d)
{
if (ext) fprintf(stderr, "(ext) ");
if (ext)
fprintf(stderr, "(ext) ");
if (par[i].val >= 0x1e && par[i].val <= 0x1f)
{
fprintf(stderr, "%s ", cur_line.c_str());
fprintf(stderr, "WARNING: $ACM%d register used instead of $ACL%d register Line: %d Param: %d\n",
(par[i].val & 1), (par[i].val & 1), code_line, current_param);
}
else if (par[i].val >= 0x20 && par[i].val <= 0x21) {
else if (par[i].val >= 0x20 && par[i].val <= 0x21)
{
fprintf(stderr, "%s ", cur_line.c_str());
fprintf(stderr, "WARNING: $ACC%d register used instead of $ACL%d register Line: %d Param: %d\n",
(par[i].val & 1), (par[i].val & 1), code_line, current_param);
}
else
{
ShowError(ERR_WRONG_PARAMETER_ACC);
}
}
break;
/* case P_ACCM_D: //P_ACC_MID:

View File

@ -185,10 +185,12 @@ void DSPCore_Shutdown()
core_state = DSPCORE_STOP;
if (dspjit) {
if (dspjit)
{
delete dspjit;
dspjit = nullptr;
}
DSPCore_FreeMemoryPages();
g_dsp_cap.reset();

View File

@ -192,25 +192,33 @@ struct DSP_Regs
u16 st[4];
u16 cr;
u16 sr;
union {
union
{
u64 val;
struct {
struct
{
u16 l;
u16 m;
u16 h;
u16 m2;//if this gets in the way, drop it.
};
} prod;
union {
union
{
u32 val;
struct {
u16 l;
u16 h;
};
} ax[2];
union {
union
{
u64 val;
struct {
struct
{
u16 l;
u16 m;
u16 h;

View File

@ -370,7 +370,9 @@ void addr(const UDSPInstruction opc)
s64 acc = dsp_get_long_acc(dreg);
s64 ax = 0;
switch (sreg) {
switch (sreg)
{
case DSP_REG_AXL0:
case DSP_REG_AXL1:
ax = (s16)g_dsp.r.ax[sreg-DSP_REG_AXL0].l;
@ -383,6 +385,7 @@ void addr(const UDSPInstruction opc)
ax = 0;
break;
}
ax <<= 16;
s64 res = acc + ax;
@ -569,7 +572,9 @@ void subr(const UDSPInstruction opc)
s64 acc = dsp_get_long_acc(dreg);
s64 ax = 0;
switch (sreg) {
switch (sreg)
{
case DSP_REG_AXL0:
case DSP_REG_AXL1:
ax = (s16)g_dsp.r.ax[sreg-DSP_REG_AXL0].l;
@ -582,6 +587,7 @@ void subr(const UDSPInstruction opc)
ax = 0;
break;
}
ax <<= 16;
s64 res = acc - ax;

View File

@ -111,31 +111,38 @@ inline int GetMultiplyModifier()
return (g_dsp.r.sr & SR_MUL_MODIFY)?1:2;
}
inline bool isCarry() {
inline bool isCarry()
{
return (g_dsp.r.sr & SR_CARRY) ? true : false;
}
inline bool isOverflow() {
inline bool isOverflow()
{
return (g_dsp.r.sr & SR_OVERFLOW) ? true : false;
}
inline bool isOverS32() {
inline bool isOverS32()
{
return (g_dsp.r.sr & SR_OVER_S32) ? true : false;
}
inline bool isLess() {
inline bool isLess()
{
return (!(g_dsp.r.sr & SR_OVERFLOW) != !(g_dsp.r.sr & SR_SIGN));
}
inline bool isZero() {
inline bool isZero()
{
return (g_dsp.r.sr & SR_ARITH_ZERO) ? true : false;
}
inline bool isLogicZero() {
inline bool isLogicZero()
{
return (g_dsp.r.sr & SR_LOGIC_ZERO) ? true : false;
}
inline bool isConditionA() {
inline bool isConditionA()
{
return (((g_dsp.r.sr & SR_OVER_S32) || (g_dsp.r.sr & SR_TOP2BITS)) && !(g_dsp.r.sr & SR_ARITH_ZERO)) ? true : false;
}

View File

@ -10,7 +10,8 @@
#include "Common/Common.h"
namespace DSPInterpreter {
namespace DSPInterpreter
{
bool CheckCondition(u8 _Condition);
@ -20,19 +21,23 @@ void Update_SR_Register16(s16 _Value, bool carry = false, bool overflow = false,
void Update_SR_Register64(s64 _Value, bool carry = false, bool overflow = false);
void Update_SR_LZ(bool value);
inline bool isCarry(u64 val, u64 result) {
return (val>result);
inline bool isCarry(u64 val, u64 result)
{
return (val > result);
}
inline bool isCarry2(u64 val, u64 result) {
return (val>=result);
inline bool isCarry2(u64 val, u64 result)
{
return (val >= result);
}
inline bool isOverflow(s64 val1, s64 val2, s64 res) {
inline bool isOverflow(s64 val1, s64 val2, s64 res)
{
return ((val1 ^ res) & (val2 ^ res)) < 0;
}
inline bool isOverS32(s64 acc) {
inline bool isOverS32(s64 acc)
{
return (acc != (s32)acc) ? true : false;
}

View File

@ -1358,9 +1358,12 @@ void DSPEmitter::lsrn(const UDSPInstruction opc)
// else
// shift = accm & 0x3f;
// if (shift > 0) {
// if (shift > 0)
// {
// acc >>= shift;
// } else if (shift < 0) {
// }
// else if (shift < 0)
// {
// acc <<= -shift;
// }
@ -1414,9 +1417,12 @@ void DSPEmitter::asrn(const UDSPInstruction opc)
// else
// shift = accm & 0x3f;
// if (shift > 0) {
// if (shift > 0)
// {
// acc >>= shift;
// } else if (shift < 0) {
// }
// else if (shift < 0)
// {
// acc <<= -shift;
// }
@ -1474,9 +1480,12 @@ void DSPEmitter::lsrnrx(const UDSPInstruction opc)
// else
// shift = axh & 0x3f;
// if (shift > 0) {
// if (shift > 0)
// {
// acc <<= shift;
// } else if (shift < 0) {
// }
// else if (shift < 0)
// {
// acc >>= -shift;
// }

View File

@ -133,16 +133,6 @@ void DSPEmitter::Update_SR_Register64_Carry2(X64Reg val, X64Reg carry_ovfl)
Update_SR_Register();
}
//void DSPEmitter::Update_SR_Register16(s16 _Value, bool carry, bool overflow, bool overS32)
//{
// // 0x20 - Checks if top bits of m are equal
// if ((((u16)_Value >> 14) == 0) || (((u16)_Value >> 14) == 3))
// {
// g_dsp.r[DSP_REG_SR] |= SR_TOP2BITS;
// }
//}
// In: RAX: s64 _Value
// Clobbers RDX
void DSPEmitter::Update_SR_Register16(X64Reg val)
@ -205,86 +195,3 @@ void DSPEmitter::Update_SR_Register16_OverS32(Gen::X64Reg val)
//AND(32, R(val), Imm32(0xc0000000));
Update_SR_Register16(val);
}
//void DSPEmitter::Update_SR_LZ(bool value) {
// if (value == true)
// g_dsp.r[DSP_REG_SR] |= SR_LOGIC_ZERO;
// else
// g_dsp.r[DSP_REG_SR] &= ~SR_LOGIC_ZERO;
//}
//inline int GetMultiplyModifier()
//{
// return (g_dsp.r[DSP_REG_SR] & SR_MUL_MODIFY)?1:2;
//}
//inline bool isCarry() {
// return (g_dsp.r[DSP_REG_SR] & SR_CARRY) ? true : false;
//}
//inline bool isOverflow() {
// return (g_dsp.r[DSP_REG_SR] & SR_OVERFLOW) ? true : false;
//}
//inline bool isOverS32() {
// return (g_dsp.r[DSP_REG_SR] & SR_OVER_S32) ? true : false;
//}
//inline bool isLess() {
// return (!(g_dsp.r[DSP_REG_SR] & SR_OVERFLOW) != !(g_dsp.r[DSP_REG_SR] & SR_SIGN));
//}
//inline bool isZero() {
// return (g_dsp.r[DSP_REG_SR] & SR_ARITH_ZERO) ? true : false;
//}
//inline bool isLogicZero() {
// return (g_dsp.r[DSP_REG_SR] & SR_LOGIC_ZERO) ? true : false;
//}
//inline bool isConditionA() {
// return (((g_dsp.r[DSP_REG_SR] & SR_OVER_S32) || (g_dsp.r[DSP_REG_SR] & SR_TOP2BITS)) && !(g_dsp.r[DSP_REG_SR] & SR_ARITH_ZERO)) ? true : false;
//}
//see DSPCore.h for flags
//bool CheckCondition(u8 _Condition)
//{
// switch (_Condition & 0xf)
// {
// case 0xf: // Always true.
// return true;
// case 0x0: // GE - Greater Equal
// return !isLess();
// case 0x1: // L - Less
// return isLess();
// case 0x2: // G - Greater
// return !isLess() && !isZero();
// case 0x3: // LE - Less Equal
// return isLess() || isZero();
// case 0x4: // NZ - Not Zero
// return !isZero();
// case 0x5: // Z - Zero
// return isZero();
// case 0x6: // NC - Not carry
// return !isCarry();
// case 0x7: // C - Carry
// return isCarry();
// case 0x8: // ? - Not over s32
// return !isOverS32();
// case 0x9: // ? - Over s32
// return isOverS32();
// case 0xa: // ?
// return isConditionA();
// case 0xb: // ?
// return !isConditionA();
// case 0xc: // LNZ - Logic Not Zero
// return !isLogicZero();
// case 0xd: // LZ - Logic Zero
// return isLogicZero();
// case 0xe: // 0 - Overflow
// return isOverflow();
// default:
// return true;
// }
//}

View File

@ -115,7 +115,8 @@ void DSPEmitter::l(const UDSPInstruction opc)
pushExtValueFromMem(dreg, sreg);
if (dreg >= DSP_REG_ACM0) {
if (dreg >= DSP_REG_ACM0)
{
//save SR too, so we can decide later.
//even if only for one bit, can only
//store (up to) two registers in EBX,
@ -139,7 +140,8 @@ void DSPEmitter::ln(const UDSPInstruction opc)
pushExtValueFromMem(dreg, sreg);
if (dreg >= DSP_REG_ACM0) {
if (dreg >= DSP_REG_ACM0)
{
//save SR too, so we can decide later.
//even if only for one bit, can only
//store (up to) two registers in EBX,

View File

@ -263,7 +263,8 @@ void DSPJitRegCache::flushRegs(DSPJitRegCache &cache, bool emit)
}
// sync the freely used xregs
if (!emit) {
if (!emit)
{
for (i = 0; i < NUMXREGS; i++)
{
if (cache.xregs[i].guest_reg == DSP_REG_USED &&
@ -501,7 +502,8 @@ void DSPJitRegCache::pushRegs()
emitter.MOV(64, R(RBP), M(&ebp_store));
}
void DSPJitRegCache::popRegs() {
void DSPJitRegCache::popRegs()
{
emitter.MOV(64, M(&ebp_store), R(RBP));
int push_count = 0;
for (X64CachedReg& xreg : xregs)

View File

@ -103,13 +103,16 @@ void PrintCallstack()
{
printf("== STACK TRACE - SP = %08x ==", PowerPC::ppcState.gpr[1]);
if (LR == 0) {
if (LR == 0)
{
printf(" LR = 0 - this is bad");
}
if (g_symbolDB.GetDescription(PC) != g_symbolDB.GetDescription(LR))
{
printf(" * %s [ LR = %08x ]", g_symbolDB.GetDescription(LR).c_str(), LR);
}
WalkTheStack([](u32 func_addr) {
std::string func_desc = g_symbolDB.GetDescription(func_addr);
if (func_desc.empty() || func_desc == "Invalid")
@ -123,14 +126,17 @@ void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)
GENERIC_LOG(type, level, "== STACK TRACE - SP = %08x ==",
PowerPC::ppcState.gpr[1]);
if (LR == 0) {
if (LR == 0)
{
GENERIC_LOG(type, level, " LR = 0 - this is bad");
}
if (g_symbolDB.GetDescription(PC) != g_symbolDB.GetDescription(LR))
{
GENERIC_LOG(type, level, " * %s [ LR = %08x ]",
g_symbolDB.GetDescription(LR).c_str(), LR);
}
WalkTheStack([type, level](u32 func_addr) {
std::string func_desc = g_symbolDB.GetDescription(func_addr);
if (func_desc.empty() || func_desc == "Invalid")

View File

@ -28,9 +28,11 @@ public:
virtual void ToggleMemCheck(unsigned int address) override;
virtual unsigned int ReadMemory(unsigned int address) override;
enum {
enum
{
EXTRAMEM_ARAM = 1,
};
virtual unsigned int ReadExtraMemory(int memory, unsigned int address) override;
virtual unsigned int ReadInstruction(unsigned int address) override;
virtual unsigned int GetPC() override;

View File

@ -76,7 +76,8 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
{
char* pArgument = ArgumentBuffer;
*pArgument++ = *pString++;
if (*pString == '%') {
if (*pString == '%')
{
_rOutBuffer += "%";
pString++;
continue;

View File

@ -269,7 +269,8 @@ void Shutdown()
void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
{
// Declare all the boilerplate direct MMIOs.
struct {
struct
{
u32 addr;
u16* ptr;
bool align_writes_on_32_bytes;

View File

@ -82,7 +82,8 @@ u32 DSPHLE::DSP_UpdateRate()
void DSPHLE::SendMailToDSP(u32 _uMail)
{
if (m_pUCode != nullptr) {
if (m_pUCode != nullptr)
{
DEBUG_LOG(DSP_MAIL, "CPU writes 0x%08x", _uMail);
m_pUCode->HandleMail(_uMail);
}

View File

@ -252,7 +252,8 @@ void AXWiiUCode::SetupProcessing(u32 init_addr)
init_data[i] = HLEMemory_Read_U16(init_addr + 2 * i);
// List of all buffers we have to initialize
struct {
struct
{
int* ptr;
u32 samples;
} buffers[] = {

View File

@ -62,7 +62,8 @@ void ROMUCode::HandleMail(u32 mail)
case 0x80F3B002:
m_current_ucode.m_dmem_length = mail & 0xffff;
if (m_current_ucode.m_dmem_length) {
if (m_current_ucode.m_dmem_length)
{
NOTICE_LOG(DSPHLE,"m_current_ucode.m_dmem_length = 0x%04x.", m_current_ucode.m_dmem_length);
}
break;

View File

@ -22,7 +22,9 @@ void ZeldaUCode::AFCdecodebuffer(const s16 *coef, const char *src, signed short
nibbles[i + 1] = *src & 15;
src++;
}
for (auto& nibble : nibbles) {
for (auto& nibble : nibbles)
{
if (nibble >= 8)
nibble = nibble - 16;
nibble <<= 11;

View File

@ -464,7 +464,8 @@ void Decoder21_ReadAudio(ZeldaVoicePB &PB, int size, s16 *_Buffer)
const u8 *source = Memory::GetPointer(0x80000000);
const u16 *src = (u16 *)(source + (ACC0 & ram_mask));
for (u32 i = 0; i < (ACC1 >> 16); i++) {
for (u32 i = 0; i < (ACC1 >> 16); i++)
{
_Buffer[i] = Common::swap16(src[i]);
}
@ -484,7 +485,8 @@ void ZeldaUCode::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _RightB
}
// XK: Use this to disable MIDI music (GREAT for testing). Also kills some sound FX.
//if (PB.SoundType == 0x0d00) {
//if (PB.SoundType == 0x0d00)
//{
// PB.NeedsReset = 0;
// return;
//}
@ -592,13 +594,15 @@ ContinueWithBlock:
if (PB.VolumeMode != 0)
{
// Complex volume mode. Let's see what we can do.
if (PB.StopOnSilence) {
if (PB.StopOnSilence)
{
PB.raw[0x2b] = PB.raw[0x2a] >> 1;
if (PB.raw[0x2b] == 0)
{
PB.KeyOff = 1;
}
}
short AX0L = PB.raw[0x28] >> 8;
short AX0H = PB.raw[0x28] & 0x7F;
short AX1L = AX0L ^ 0x7F;
@ -651,7 +655,8 @@ ContinueWithBlock:
for (int i = 0; i < _Size; i++)
{
int unmixed_audio = m_voice_buffer[i];
switch (count) {
switch (count)
{
case 0: _LeftBuffer[i] += (u64)unmixed_audio * ramp >> 29; break;
case 1: _RightBuffer[i] += (u64)unmixed_audio * ramp >> 29; break;
}
@ -731,7 +736,8 @@ ContinueWithBlock:
}
}
// 03b2, this is the reason of using PB.NeedsReset. Seems to be necessary for SMG, and maybe other games.
if (PB.IsBlank == 0){
if (PB.IsBlank == 0)
{
PB.NeedsReset = 0;
}
}

View File

@ -155,7 +155,10 @@ enum
BBA_MEM_SIZE = BBA_NUM_PAGES * BBA_PAGE_SIZE
};
enum { EXI_DEVTYPE_ETHER = 0x04020200 };
enum
{
EXI_DEVTYPE_ETHER = 0x04020200
};
enum SendStatus
{

View File

@ -105,7 +105,8 @@ struct GCMBlock
void calc_checksumsBE(u16 *buf, u32 length, u16 *csum, u16 *inv_csum);
#pragma pack(push,1)
struct Header { //Offset Size Description
struct Header //Offset Size Description
{
// Serial in libogc
u8 serial[12]; //0x0000 12 ?
u64 formatTime; //0x000c 8 Time of format (OSTime value)

View File

@ -70,10 +70,13 @@ static u32 EFB_Read(const u32 addr)
int x = (addr & 0xfff) >> 2;
int y = (addr >> 12) & 0x3ff;
if (addr & 0x00400000) {
if (addr & 0x00400000)
{
var = g_video_backend->Video_AccessEFB(PEEK_Z, x, y, 0);
DEBUG_LOG(MEMMAP, "EFB Z Read @ %i, %i\t= 0x%08x", x, y, var);
} else {
}
else
{
var = g_video_backend->Video_AccessEFB(PEEK_COLOR, x, y, 0);
DEBUG_LOG(MEMMAP, "EFB Color Read @ %i, %i\t= 0x%08x", x, y, var);
}
@ -378,7 +381,8 @@ void Write_U16(const u16 _Data, const u32 _Address)
WriteToHardware<u16>(_Address, _Data, _Address, FLAG_WRITE);
}
void Write_U16_Swap(const u16 _Data, const u32 _Address) {
void Write_U16_Swap(const u16 _Data, const u32 _Address)
{
Write_U16(Common::swap16(_Data), _Address);
}
@ -413,7 +417,8 @@ void Write_U64(const u64 _Data, const u32 _Address)
WriteToHardware<u64>(_Address, _Data, _Address + 4, FLAG_WRITE);
}
void Write_U64_Swap(const u64 _Data, const u32 _Address) {
void Write_U64_Swap(const u64 _Data, const u32 _Address)
{
Write_U64(Common::swap64(_Data), _Address);
}

View File

@ -41,7 +41,8 @@ distribution.
union SRAM
{
u8 p_SRAM[64];
struct { // Stored configuration value from the system SRAM area
struct // Stored configuration value from the system SRAM area
{
u16 checksum; // Holds the block checksum.
u16 checksum_inv; // Holds the inverse block checksum
u32 ead0; // Unknown attribute

View File

@ -70,7 +70,8 @@ struct CtrlRegister
inline u8 ppc() { return (IY2<<5)|(IY1<<4)|(X2<<3)|(Y1<<2)|(Y2<<1)|X1; }
inline u8 arm() { return (IX2<<5)|(IX1<<4)|(Y2<<3)|(X1<<2)|(X2<<1)|Y1; }
inline void ppc(u32 v) {
inline void ppc(u32 v)
{
X1 = v & 1;
X2 = (v >> 3) & 1;
if ((v >> 2) & 1) Y1 = 0;
@ -79,7 +80,8 @@ struct CtrlRegister
IY2 = (v >> 5) & 1;
}
inline void arm(u32 v) {
inline void arm(u32 v)
{
Y1 = v & 1;
Y2 = (v >> 3) & 1;
if ((v >> 2) & 1) X1 = 0;

View File

@ -74,7 +74,8 @@ void Nunchuk::GetState(u8* const data)
cal_js[0] = cal.jx;
cal_js[1] = cal.jy;
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 2; i++)
{
double &s = state[i];
nu_js c = cal_js[i];
if (s < 0)

View File

@ -115,8 +115,8 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
case WM_SPACE_EEPROM:
if (logCom) Name.append(" REG_EEPROM"); break;
case WM_SPACE_REGS1:
case WM_SPACE_REGS2: {
case WM_SPACE_REGS2:
{
const u8 region_offset = (u8)address;
void *region_ptr = nullptr;
int region_size = 0;
@ -148,7 +148,8 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
case 0xa4:
if (logCom) Name.append(" REG_EXT");
// Update the encryption mode
if (data[5] == 0xf0) {
if (data[5] == 0xf0)
{
if (!emu)
wm->m_reg_ext.encryption = wd->data[0];
//NOTICE_LOG(CONSOLE, "Extension encryption: %u", wm->m_reg_ext.encryption);
@ -158,7 +159,8 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
case 0xa6 :
if (logCom) Name.append(" REG_M+");
// update the encryption mode
if (data[5] == 0xf0) {
if (data[5] == 0xf0)
{
if (!emu)
wm->m_reg_motion_plus.activated = wd->data[0];
//NOTICE_LOG(CONSOLE, "Extension enryption: %u", wm->m_reg_ext.encryption);
@ -173,12 +175,14 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
if (!emu && region_ptr)
memcpy((u8*)region_ptr + region_offset, wd->data, wd->size);
// save key
if (region_offset >= 0x40 && region_offset <= 0x4c) {
if (region_offset >= 0x40 && region_offset <= 0x4c)
{
if (!emu)
WiimoteGenerateKey(&wm->m_ext_key, wm->m_reg_ext.encryption_key);
INFO_LOG(CONSOLE, "Writing key: %s", ArrayToString((u8*)&wm->m_ext_key, sizeof(wm->m_ext_key), 0, 30).c_str());
}
if (data[3] == 0xa4 || data[3] == 0xa6) {
if (data[3] == 0xa4 || data[3] == 0xa6)
{
//DEBUG_LOG(CONSOLE, "M+: %s", ArrayToString((u8*)&wm->m_reg_motion_plus, sizeof(wm->m_reg_motion_plus), 0, 30).c_str());
//DEBUG_LOG(CONSOLE, "M+: %s", ArrayToString((u8*)&wm->m_reg_motion_plus.ext_identifier, sizeof(wm->m_reg_motion_plus.ext_identifier), 0, 30).c_str());
NOTICE_LOG(CONSOLE, "W[0x%02x 0x%02x|%d]: %s", data[3], region_offset, wd->size, ArrayToString(wd->data, wd->size, 0).c_str());
@ -315,8 +319,10 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
if (logCom)
Name.append(" REG_EEPROM");
// Wiimote calibration
if (data[4] == 0xf0 && data[5] == 0x00 && data[6] == 0x10) {
if (data[6] == 0x10) {
if (data[4] == 0xf0 && data[5] == 0x00 && data[6] == 0x10)
{
if (data[6] == 0x10)
{
accel_cal* calib = (accel_cal*)&rdr->data[6];
ERROR_LOG(CONSOLE, "Wiimote calibration:");
//SERROR_LOG(CONSOLE, "%s", ArrayToString(rdr->data, rdr->size).c_str());

View File

@ -576,7 +576,8 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p)
File::IOFile handle(entry.physicalName, "rb");
char buf[65536];
u32 count = size;
while (count > 65536) {
while (count > 65536)
{
handle.ReadArray(&buf[0], 65536);
p.DoArray(&buf[0], 65536);
count -= 65536;

View File

@ -27,7 +27,8 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid)
if (timeToFill == 0)
{
std::lock_guard<std::mutex> lk(hid->m_device_list_reply_mutex);
if (hid->deviceCommandAddress != 0){
if (hid->deviceCommandAddress != 0)
{
hid->FillOutDevices(Memory::Read_U32(hid->deviceCommandAddress + 0x18), Memory::Read_U32(hid->deviceCommandAddress + 0x1C));
// The original hardware overwrites the command type with the async reply type.
@ -240,7 +241,8 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
case IOCTL_HID_SHUTDOWN:
{
std::lock_guard<std::mutex> lk(m_device_list_reply_mutex);
if (deviceCommandAddress != 0){
if (deviceCommandAddress != 0)
{
Memory::Write_U32(0xFFFFFFFF, Memory::Read_U32(deviceCommandAddress + 0x18));
// The original hardware overwrites the command type with the async reply type.

View File

@ -785,7 +785,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
optval[15], optval[16], optval[17], optval[18], optval[19]);
//TODO: bug booto about this, 0x2005 most likely timeout related, default value on wii is , 0x2001 is most likely tcpnodelay
if (level == 6 && (optname == 0x2005 || optname == 0x2001)){
if (level == 6 && (optname == 0x2005 || optname == 0x2001))
{
ReturnValue = 0;
break;
}

View File

@ -422,7 +422,8 @@ private:
IOCTL_NWC24_REQUEST_SHUTDOWN = 0x28,
};
enum {
enum
{
MODEL_RVT = 0,
MODEL_RVV = 0,
MODEL_RVL = 1,

View File

@ -261,7 +261,8 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtlV(u32 _CommandAddress)
}
u32 ReturnValue = 0;
switch (CommandBuffer.Parameter) {
switch (CommandBuffer.Parameter)
{
case IOCTLV_SENDCMD:
INFO_LOG(WII_IPC_SD, "IOCTLV_SENDCMD 0x%08x", Memory::Read_U32(CommandBuffer.InBuffer[0].m_Address));
ReturnValue = ExecuteCommand(
@ -288,7 +289,8 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS
{
// The game will send us a SendCMD with this information. To be able to read and write
// to a file we need to prepare a 0x10 byte output buffer as response.
struct Request {
struct Request
{
u32 command;
u32 type;
u32 resp;

View File

@ -33,7 +33,8 @@ private:
u8 Unk2;
u8 PressedKeys[6];
SMessageData(u32 _MsgType, u8 _Modifiers, u8 *_PressedKeys) {
SMessageData(u32 _MsgType, u8 _Modifiers, u8 *_PressedKeys)
{
MsgType = Common::swap32(_MsgType);
Unk1 = 0; // swapped
Modifiers = _Modifiers;

View File

@ -64,9 +64,12 @@ static s32 TranslateErrorCode(s32 native_error, bool isRW)
case ERRORCODE(EHOSTUNREACH):
return -SO_EHOSTUNREACH;
case EITHER(WSAEWOULDBLOCK, EAGAIN):
if (isRW){
if (isRW)
{
return -SO_EAGAIN; // EAGAIN
}else{
}
else
{
return -SO_EINPROGRESS; // EINPROGRESS
}
default:
@ -473,7 +476,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
// recv/recvfrom only handles PEEK/OOB
flags &= SO_MSG_PEEK | SO_MSG_OOB;
#ifdef _WIN32
if (flags & SO_MSG_PEEK){
if (flags & SO_MSG_PEEK)
{
unsigned long totallen = 0;
ioctlsocket(fd, FIONREAD, &totallen);
ReturnValue = totallen;

View File

@ -52,12 +52,15 @@ typedef struct pollfd pollfd_t;
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h"
enum {
enum
{
SO_MSG_OOB = 0x01,
SO_MSG_PEEK = 0x02,
SO_MSG_NONBLOCK = 0x04,
};
enum {
enum
{
SO_SUCCESS,
SO_E2BIG = 1,
SO_EACCES,

View File

@ -733,7 +733,8 @@ bool PlayInput(const std::string& filename)
if (tmpHeader.filetype[0] != 'D' ||
tmpHeader.filetype[1] != 'T' ||
tmpHeader.filetype[2] != 'M' ||
tmpHeader.filetype[3] != 0x1A) {
tmpHeader.filetype[3] != 0x1A)
{
PanicAlertT("Invalid recording file");
goto cleanup;
}

View File

@ -480,7 +480,8 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
// WARNING - cmp->branch merging will screw this up.
js.isLastInstruction = true;
js.next_inst = 0;
if (Profiler::g_ProfileBlocks) {
if (Profiler::g_ProfileBlocks)
{
// CAUTION!!! push on stack regs you use, do your stuff, then pop
PROFILER_VPUSH;
// get end tic

View File

@ -375,9 +375,11 @@ void CompileInstruction(PPCAnalyst::CodeOp & op)
Jit64 *jit64 = (Jit64 *)jit;
(jit64->*dynaOpTable[op.inst.OPCD])(op.inst);
GekkoOPInfo *info = op.opinfo;
if (info) {
if (info)
{
#ifdef OPLOG
if (!strcmp(info->opname, OP_TO_LOG)){ ///"mcrfs"
if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs"
{
rsplocations.push_back(jit.js.compilerPC);
}
#endif

View File

@ -174,7 +174,8 @@ const u8 *Jitx86Base::BackPatch(u8 *codePtr, u32 emAddress, void *ctx_void)
InstructionInfo info = {};
if (!DisassembleMov(codePtr, &info)) {
if (!DisassembleMov(codePtr, &info))
{
BackPatchError("BackPatch - failed to disassemble MOV instruction", codePtr, emAddress);
return nullptr;
}

View File

@ -128,7 +128,8 @@ bool AnalyzeFunction(u32 startAddr, Symbol &func, int max_size)
}
}
/*
else if ((instr.hex & 0xFC000000) == (0x4b000000 & 0xFC000000) && !instr.LK) {
else if ((instr.hex & 0xFC000000) == (0x4b000000 & 0xFC000000) && !instr.LK)
{
u32 target = addr + SignExt26(instr.LI << 2);
if (target < startAddr || (max_size && target > max_size+startAddr))
{
@ -415,7 +416,8 @@ void PPCAnalyzer::ReorderInstructions(u32 instructions, CodeOp *code)
(a.inst.OPCD == 31 && (a.inst.SUBOP10 == 0 || a.inst.SUBOP10 == 32)))
{
// Got a compare instruction.
if (CanSwapAdjacentOps(a, b)) {
if (CanSwapAdjacentOps(a, b))
{
// Alright, let's bubble it down!
CodeOp c = a;
a = b;
@ -626,7 +628,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock *block, CodeBuffer *buffer, u32
{
// mtspr
const u32 index = (inst.SPRU << 5) | (inst.SPRL & 0x1F);
if (index == SPR_LR) {
if (index == SPR_LR)
{
// We give up to follow the return address
// because we have to check the register usage.
return_address = 0;

View File

@ -63,9 +63,11 @@ struct BlockRegStats
bool anyTimer;
int GetTotalNumAccesses(int reg) {return numReads[reg] + numWrites[reg];}
int GetUseRange(int reg) {
int GetUseRange(int reg)
{
return std::max(lastRead[reg], lastWrite[reg]) -
std::min(firstRead[reg], firstWrite[reg]);}
std::min(firstRead[reg], firstWrite[reg]);
}
inline void SetInputRegister(int reg, short opindex)
{

View File

@ -74,7 +74,8 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
tf.name = name;
tf.type = type;
tf.address = startAddr;
if (tf.type == Symbol::SYMBOL_FUNCTION) {
if (tf.type == Symbol::SYMBOL_FUNCTION)
{
PPCAnalyst::AnalyzeFunction(startAddr, tf, size);
checksumToFunction[tf.hash] = &(functions[startAddr]);
}

View File

@ -198,7 +198,8 @@ inline void SetCRField(int cr_field, int value)
PowerPC::ppcState.cr_val[cr_field] = m_crTable[value];
}
inline u32 GetCRField(int cr_field) {
inline u32 GetCRField(int cr_field)
{
u64 cr_val = PowerPC::ppcState.cr_val[cr_field];
u32 ppc_cr = 0;
@ -214,11 +215,13 @@ inline u32 GetCRField(int cr_field) {
return ppc_cr;
}
inline u32 GetCRBit(int bit) {
inline u32 GetCRBit(int bit)
{
return (GetCRField(bit >> 2) >> (3 - (bit & 3))) & 1;
}
inline void SetCRBit(int bit, int value) {
inline void SetCRBit(int bit, int value)
{
if (value & 1)
SetCRField(bit >> 2, GetCRField(bit >> 2) | (0x8 >> (bit & 3)));
else
@ -226,36 +229,44 @@ inline void SetCRBit(int bit, int value) {
}
// SetCR and GetCR are fairly slow. Should be avoided if possible.
inline void SetCR(u32 new_cr) {
inline void SetCR(u32 new_cr)
{
PowerPC::ExpandCR(new_cr);
}
inline u32 GetCR() {
inline u32 GetCR()
{
return PowerPC::CompactCR();
}
// SetCarry/GetCarry may speed up soon.
inline void SetCarry(int ca) {
inline void SetCarry(int ca)
{
((UReg_XER&)PowerPC::ppcState.spr[SPR_XER]).CA = ca;
}
inline int GetCarry() {
inline int GetCarry()
{
return ((UReg_XER&)PowerPC::ppcState.spr[SPR_XER]).CA;
}
inline UReg_XER GetXER() {
inline UReg_XER GetXER()
{
return ((UReg_XER&)PowerPC::ppcState.spr[SPR_XER]);
}
inline void SetXER(UReg_XER new_xer) {
inline void SetXER(UReg_XER new_xer)
{
((UReg_XER&)PowerPC::ppcState.spr[SPR_XER]) = new_xer;
}
inline int GetXER_SO() {
inline int GetXER_SO()
{
return ((UReg_XER&)PowerPC::ppcState.spr[SPR_XER]).SO;
}
inline void SetXER_SO(int value) {
inline void SetXER_SO(int value)
{
((UReg_XER&)PowerPC::ppcState.spr[SPR_XER]).SO = value;
}

View File

@ -66,12 +66,16 @@ private:
u8 boot1_hash [ 0x14]; // 0x100
u8 common_key [ 0x10]; // 0x114
u32 ng_id; // 0x124
union {
struct {
union
{
struct
{
u8 ng_priv [ 0x1e]; // 0x128
u8 pad1 [ 0x12];
};
struct {
struct
{
u8 pad2 [ 0x1c];
u8 nand_hmac [ 0x14]; //0x144
};

View File

@ -39,9 +39,11 @@ static bool DoFault(u64 bad_address, SContext *ctx)
0x40000000;
#endif
if (bad_address < memspace_bottom || bad_address >= memspace_top) {
if (bad_address < memspace_bottom || bad_address >= memspace_top)
{
return false;
}
u32 em_address = (u32)(bad_address - memspace_bottom);
const u8 *new_pc = jit->BackPatch((u8*) ctx->CTX_PC, em_address, ctx);
if (new_pc)

View File

@ -111,7 +111,8 @@ private:
u32 unknown2;
// All the data is byteswapped
SDiskHeaderInfo() {
SDiskHeaderInfo()
{
debug_mntr_size = 0;
simulated_mem_size = 0;
arg_offset = 0;

View File

@ -35,7 +35,8 @@ class CARCodeAddEdit : public wxDialog
wxSpinButton *EntrySelection;
wxTextCtrl *EditCheatCode;
enum {
enum
{
ID_EDITCHEAT_NAME_TEXT = 4550,
ID_EDITCHEAT_NAME,
ID_ENTRY_SELECT,

View File

@ -377,7 +377,8 @@ void CCodeWindow::NotifyMapLoaded()
void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
{
int index = symbols->GetSelection();
if (index >= 0) {
if (index >= 0)
{
Symbol* pSymbol = static_cast<Symbol *>(symbols->GetClientData(index));
if (pSymbol != nullptr)
{

View File

@ -234,7 +234,8 @@ void DSPDebuggerLLE::UpdateSymbolMap()
void DSPDebuggerLLE::OnSymbolListChange(wxCommandEvent& event)
{
int index = m_SymbolList->GetSelection();
if (index >= 0) {
if (index >= 0)
{
Symbol* pSymbol = static_cast<Symbol *>(m_SymbolList->GetClientData(index));
if (pSymbol != nullptr)
{
@ -275,7 +276,8 @@ bool DSPDebuggerLLE::JumpToAddress(u16 addr)
{
// Center on valid instruction in IRAM/IROM
int new_line = DSPSymbols::Addr2Line(addr);
if (new_line >= 0) {
if (new_line >= 0)
{
m_CodeView->Center(new_line);
return true;
}

View File

@ -75,7 +75,8 @@ CJitWindow::CJitWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos,
sizerBig->Fit(this);
}
void CJitWindow::OnRefresh(wxCommandEvent& /*event*/) {
void CJitWindow::OnRefresh(wxCommandEvent& /*event*/)
{
block_list->Update();
}
@ -212,7 +213,8 @@ void CJitWindow::OnHostMessage(wxCommandEvent& event)
// JitBlockList
//================
enum {
enum
{
COLUMN_ADDRESS,
COLUMN_PPCSIZE,
COLUMN_X86SIZE,

View File

@ -32,12 +32,14 @@ class wxWindow;
class CRegTable : public wxGridTableBase
{
enum {
enum
{
NUM_SPECIALS = 11,
};
public:
CRegTable() {
CRegTable()
{
memset(m_CachedRegs, 0, sizeof(m_CachedRegs));
memset(m_CachedSpecialRegs, 0, sizeof(m_CachedSpecialRegs));
memset(m_CachedFRegs, 0, sizeof(m_CachedFRegs));
@ -45,6 +47,7 @@ public:
memset(m_CachedSpecialRegHasChanged, 0, sizeof(m_CachedSpecialRegHasChanged));
memset(m_CachedFRegHasChanged, 0, sizeof(m_CachedFRegHasChanged));
}
int GetNumberCols() override { return 5; }
int GetNumberRows() override { return 32 + NUM_SPECIALS; }
bool IsEmptyCell(int row, int col) override { return row > 31 && col > 2; }

View File

@ -126,7 +126,8 @@ void CFrame::CreateMenu()
drives = cdio_get_devices();
// Windows Limitation of 24 character drives
for (unsigned int i = 0; i < drives.size() && i < 24; i++) {
for (unsigned int i = 0; i < drives.size() && i < 24; i++)
{
externalDrive->Append(IDM_DRIVE1 + i, StrToWxStr(drives[i]));
}

View File

@ -39,20 +39,22 @@ bool cInterfaceAGL::Create(void *window_handle)
NSOpenGLPixelFormatAttribute attr[] = { NSOpenGLPFADoubleBuffer, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, NSOpenGLPFAAccelerated, 0 };
NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc]
initWithAttributes: attr];
if (fmt == nil) {
if (fmt == nil)
{
ERROR_LOG(VIDEO, "failed to create pixel format");
return false;
}
cocoaCtx = [[NSOpenGLContext alloc]
initWithFormat: fmt shareContext: nil];
cocoaCtx = [[NSOpenGLContext alloc] initWithFormat: fmt shareContext: nil];
[fmt release];
if (cocoaCtx == nil) {
if (cocoaCtx == nil)
{
ERROR_LOG(VIDEO, "failed to create context");
return false;
}
if (cocoaWin == nil) {
if (cocoaWin == nil)
{
ERROR_LOG(VIDEO, "failed to create window");
return false;
}

View File

@ -84,7 +84,9 @@ bool cInterfaceGLX::Create(void *window_handle)
}
}
else
{
NOTICE_LOG(VIDEO, "Got double buffered visual!");
}
// Create a GLX context.
ctx = glXCreateContext(dpy, vi, nullptr, GL_TRUE);

View File

@ -104,19 +104,26 @@ bool cInterfaceWGL::Create(void *window_handle)
int PixelFormat; // Holds The Results After Searching For A Match
if (!(hDC = GetDC(window_handle_reified))) {
if (!(hDC = GetDC(window_handle_reified)))
{
PanicAlert("(1) Can't create an OpenGL Device context. Fail.");
return false;
}
if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) {
if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd)))
{
PanicAlert("(2) Can't find a suitable PixelFormat.");
return false;
}
if (!SetPixelFormat(hDC, PixelFormat, &pfd)) {
if (!SetPixelFormat(hDC, PixelFormat, &pfd))
{
PanicAlert("(3) Can't set the PixelFormat.");
return false;
}
if (!(hRC = wglCreateContext(hDC))) {
if (!(hRC = wglCreateContext(hDC)))
{
PanicAlert("(4) Can't create an OpenGL rendering context.");
return false;
}

View File

@ -60,13 +60,14 @@ void cX11Window::XEventThread()
for (int num_events = XPending(dpy); num_events > 0; num_events--)
{
XNextEvent(dpy, &event);
switch (event.type) {
case ConfigureNotify:
XResizeWindow(dpy, win, event.xconfigure.width, event.xconfigure.height);
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
break;
default:
break;
switch (event.type)
{
case ConfigureNotify:
XResizeWindow(dpy, win, event.xconfigure.width, event.xconfigure.height);
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
break;
default:
break;
}
}
Common::SleepCurrentThread(20);

View File

@ -111,7 +111,8 @@ CFrame* main_frame = nullptr;
#ifdef WIN32
//Has no error handling.
//I think that if an error occurs here there's no way to handle it anyway.
LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e)
{
//EnterCriticalSection(&g_uefcs);
File::IOFile file("exceptioninfo.txt", "a");

View File

@ -44,7 +44,8 @@ class CPatchAddEdit : public wxDialog
wxButton *EntryRemove;
wxStaticBoxSizer* sbEntry;
enum {
enum
{
ID_EDITPATCH_NAME_TEXT = 4500,
ID_EDITPATCH_NAME,
ID_EDITPATCH_OFFSET_TEXT,

View File

@ -87,7 +87,7 @@ XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win)
int XRRMajorVersion, XRRMinorVersion;
if (!XRRQueryVersion(dpy, &XRRMajorVersion, &XRRMinorVersion) ||
(XRRMajorVersion < 1 || (XRRMajorVersion == 1 && XRRMinorVersion < 3)))
(XRRMajorVersion < 1 || (XRRMajorVersion == 1 && XRRMinorVersion < 3)))
{
WARN_LOG(VIDEO, "XRRExtension not supported.");
bValid = false;
@ -148,8 +148,10 @@ void XRRConfiguration::Update()
fullHeight = fb_height;
}
else
{
sscanf(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.c_str(),
"%m[^:]: %ux%u", &output_name, &fullWidth, &fullHeight);
}
for (int i = 0; i < screenResources->noutput; i++)
{
@ -262,7 +264,9 @@ void XRRConfiguration::AddResolutions(std::vector<std::string>& resos)
if (output_info && output_info->crtc && output_info->connection == RR_Connected)
{
for (int j = 0; j < output_info->nmode; j++)
{
for (int k = 0; k < screenResources->nmode; k++)
{
if (output_info->modes[j] == screenResources->modes[k].id)
{
const std::string strRes =
@ -274,6 +278,8 @@ void XRRConfiguration::AddResolutions(std::vector<std::string>& resos)
resos.push_back(strRes);
}
}
}
}
}
if (output_info)
XRRFreeOutputInfo(output_info);

View File

@ -136,7 +136,8 @@ public:
std::string name;
name += c;
while (it != expr.end()) {
while (it != expr.end())
{
c = *it;
if (!isalpha(c))
break;
@ -569,7 +570,8 @@ ExpressionParseStatus ParseExpression(std::string str, ControlFinder &finder, Ex
qualifier.has_device = false;
Device::Control *control = finder.FindControl(qualifier);
if (control) {
if (control)
{
*expr_out = new Expression(new ControlExpression(qualifier, control));
return EXPRESSION_PARSE_SUCCESS;
}

View File

@ -30,7 +30,8 @@ void DeviceElementDebugPrint(const void *value, void *context)
recurse = *(bool*)context;
std::string type = "";
switch (IOHIDElementGetType(e)) {
switch (IOHIDElementGetType(e))
{
case kIOHIDElementTypeInput_Axis:
type = "axis";
break;
@ -57,7 +58,8 @@ void DeviceElementDebugPrint(const void *value, void *context)
std::string c_type = "";
if (type == "collection")
{
switch (IOHIDElementGetCollectionType(e)) {
switch (IOHIDElementGetCollectionType(e))
{
case kIOHIDElementCollectionTypePhysical:
c_type = "physical";
break;

View File

@ -64,12 +64,15 @@ Joystick::Joystick(IOHIDDeviceRef device, std::string name, int index)
(IOHIDElementRef)CFArrayGetValueAtIndex(axes, i);
//DeviceElementDebugPrint(e, nullptr);
if (IOHIDElementGetUsage(e) == kHIDUsage_GD_Hatswitch) {
if (IOHIDElementGetUsage(e) == kHIDUsage_GD_Hatswitch)
{
AddInput(new Hat(e, m_device, Hat::up));
AddInput(new Hat(e, m_device, Hat::right));
AddInput(new Hat(e, m_device, Hat::down));
AddInput(new Hat(e, m_device, Hat::left));
} else {
}
else
{
AddAnalogInputs(new Axis(e, m_device, Axis::negative),
new Axis(e, m_device, Axis::positive));
}
@ -212,7 +215,8 @@ Joystick::Hat::Hat(IOHIDElementRef element, IOHIDDeviceRef device, direction dir
, m_device(device)
, m_direction(dir)
{
switch (dir) {
switch (dir)
{
case up:
m_name = "Up";
break;
@ -239,7 +243,8 @@ ControlState Joystick::Hat::GetState() const
{
position = IOHIDValueGetIntegerValue(value);
switch (position) {
switch (position)
{
case 0:
if (m_direction == up)
return 1;

View File

@ -116,7 +116,8 @@ Keyboard::Key::Key(IOHIDElementRef element, IOHIDDeviceRef device)
: m_element(element)
, m_device(device)
{
static const struct PrettyKeys {
static const struct PrettyKeys
{
const uint32_t code;
const char *const name;
} named_keys[] = {
@ -224,14 +225,17 @@ Keyboard::Key::Key(IOHIDElementRef element, IOHIDDeviceRef device)
{ kHIDUsage_KeyboardRightGUI, "Right Command" },
{ 184, "Eject" },
};
const uint32_t keycode = IOHIDElementGetUsage(m_element);
for (auto & named_key : named_keys)
if (named_key.code == keycode) {
{
if (named_key.code == keycode)
{
m_name = named_key.name;
return;
}
}
std::stringstream ss;
ss << "Key " << keycode;
m_name = ss.str();

View File

@ -177,7 +177,8 @@ std::vector<DXGI_SAMPLE_DESC> EnumAAModes(IDXGIAdapter* adapter)
{
UINT quality_levels = 0;
device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, samples, &quality_levels);
if (quality_levels > 0) {
if (quality_levels > 0)
{
DXGI_SAMPLE_DESC desc;
desc.Count = samples;
for (desc.Quality = 0; desc.Quality < quality_levels; ++desc.Quality)

View File

@ -574,7 +574,8 @@ bool PixelShaderCache::InsertByteCode(const PixelShaderUid &uid, const void* byt
PixelShaders[uid] = newentry;
last_entry = &PixelShaders[uid];
if (!shader) {
if (!shader)
{
// INCSTAT(stats.numPixelShadersFailed);
return false;
}

View File

@ -212,7 +212,8 @@ void VideoBackend::Shutdown()
}
}
void VideoBackend::Video_Cleanup() {
void VideoBackend::Video_Cleanup()
{
}
}

View File

@ -972,7 +972,8 @@ union UPE_Copy
BitField<15,1,u32> intensity_fmt; // if set, is an intensity format (I4,I8,IA4,IA8)
BitField<16,1,u32> auto_conv; // if 0 automatic color conversion by texture format and pixel type
u32 tp_realFormat() {
u32 tp_realFormat()
{
return target_pixel_format / 2 + (target_pixel_format & 1) * 8;
}
};

View File

@ -41,14 +41,16 @@ bool TextureToPng(u8* data, int row_stride, const std::string& filename, int wid
// Open file for writing (binary mode)
File::IOFile fp(filename, "wb");
if (!fp.IsOpen()) {
if (!fp.IsOpen())
{
PanicAlert("Screenshot failed: Could not open file %s %d\n", filename.c_str(), errno);
goto finalise;
}
// Initialize write structure
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (png_ptr == nullptr) {
if (png_ptr == nullptr)
{
PanicAlert("Screenshot failed: Could not allocate write struct\n");
goto finalise;
@ -56,13 +58,15 @@ bool TextureToPng(u8* data, int row_stride, const std::string& filename, int wid
// Initialize info structure
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == nullptr) {
if (info_ptr == nullptr)
{
PanicAlert("Screenshot failed: Could not allocate info struct\n");
goto finalise;
}
// Setup Exception handling
if (setjmp(png_jmpbuf(png_ptr))) {
if (setjmp(png_jmpbuf(png_ptr)))
{
PanicAlert("Screenshot failed: Error during png creation\n");
goto finalise;
}

View File

@ -753,7 +753,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
ColorMask[4] = ColorMask[7] = 1.0f / 15.0f;
cbufid = 16;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f;
cbufid = 17;
@ -763,7 +764,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1.0f;
cbufid = 18;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f;
cbufid = 19;
@ -774,7 +776,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1.0f;
cbufid = 20;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[0] = 1.0f;
fConstAdd[1] = 1.0f;
@ -821,7 +824,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
ColorMask[7] = 1.0f / 7.0f;
cbufid = 27;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f;
cbufid = 28;
@ -831,7 +835,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1.0f;
cbufid = 29;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f;
cbufid = 30;

View File

@ -27,7 +27,8 @@ bool TexFmt_Overlay_Center=false;
int TexDecoder_GetTexelSizeInNibbles(int format)
{
switch (format & 0x3f) {
switch (format & 0x3f)
{
case GX_TF_I4: return 1;
case GX_TF_I8: return 2;
case GX_TF_IA4: return 2;
@ -450,7 +451,8 @@ inline void decodebytesARGB8_4(u32 *dst, const u16 *src, const u16 *src2)
inline void decodebytesARGB8_4ToRgba(u32 *dst, const u16 *src, const u16 * src2)
{
#if 0
for (int x = 0; x < 4; x++) {
for (int x = 0; x < 4; x++)
{
dst[x] = ((src[x] & 0xFF) << 24) | ((src[x] & 0xFF00)>>8) | (src2[x] << 8);
}
#else
@ -864,7 +866,7 @@ PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width, int he
memset(dst+(y + iy) * width + x + ix * 2 + 1 , i2,4);
}
}
break;
break;
case GX_TF_I8: // speed critical
{
// Reference C implementation

View File

@ -47,7 +47,8 @@ static bool TexFmt_Overlay_Center=false;
int TexDecoder_GetTexelSizeInNibbles(int format)
{
switch (format & 0x3f) {
switch (format & 0x3f)
{
case GX_TF_I4: return 1;
case GX_TF_I8: return 2;
case GX_TF_IA4: return 2;
@ -496,7 +497,8 @@ inline void decodebytesARGB8_4(u32 *dst, const u16 *src, const u16 *src2)
inline void decodebytesARGB8_4ToRgba(u32 *dst, const u16 *src, const u16 * src2)
{
#if 0
for (int x = 0; x < 4; x++) {
for (int x = 0; x < 4; x++)
{
dst[x] = ((src[x] & 0xFF) << 24) | ((src[x] & 0xFF00)>>8) | (src2[x] << 8);
}
#else
@ -755,13 +757,15 @@ static PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, in
#if _M_SSE >= 0x301
if (cpu_info.bSSSE3) {
if (cpu_info.bSSSE3)
{
#pragma omp parallel for
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8_To_Raw16_SSSE3((u16*)dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
} else
}
else
#endif
{
#pragma omp parallel for
@ -844,12 +848,14 @@ static PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, in
#if _M_SSE >= 0x301
if (cpu_info.bSSSE3) {
if (cpu_info.bSSSE3)
{
#pragma omp parallel for
for (int y = 0; y < height; y += 4) {
for (int y = 0; y < height; y += 4)
{
__m128i* p = (__m128i*)(src + y * width * 4);
for (int x = 0; x < width; x += 4) {
for (int x = 0; x < width; x += 4)
{
// We use _mm_loadu_si128 instead of _mm_load_si128
// because "p" may not be aligned in 16-bytes alignment.
// See Issue 3493.
@ -882,7 +888,8 @@ static PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, in
_mm_stream_si128((__m128i*)((u32*)dst + (y + 3) * width + x), c3);
}
}
} else
}
else
#endif
@ -998,7 +1005,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
#if _M_SSE >= 0x301
// xsacha optimized with SSSE3 intrinsics
// Produces a ~40% speed improvement over SSE2 implementation
if (cpu_info.bSSSE3) {
if (cpu_info.bSSSE3)
{
const __m128i mask9180 = _mm_set_epi8(9,9,9,9,1,1,1,1,8,8,8,8,0,0,0,0);
const __m128i maskB3A2 = _mm_set_epi8(11,11,11,11,3,3,3,3,10,10,10,10,2,2,2,2);
const __m128i maskD5C4 = _mm_set_epi8(13,13,13,13,5,5,5,5,12,12,12,12,4,4,4,4);
@ -1033,7 +1041,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
_mm_storeu_si128( (__m128i*)( dst+(y + iy+1) * width + x ), o3 );
_mm_storeu_si128( (__m128i*)( dst+(y + iy+1) * width + x + 4 ), o4 );
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics.
// Produces a ~76% speed improvement over reference C implementation.
@ -1102,7 +1111,7 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
}
}
}
break;
break;
case GX_TF_I8: // speed critical
{
#if _M_SSE >= 0x301
@ -1130,7 +1139,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
_mm_storeu_si128(quaddst+1, rgba1);
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics.
// Produces an ~86% speed improvement over reference C implementation.
@ -1275,7 +1285,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
const __m128i r1 = _mm_shuffle_epi8(r0, mask);
_mm_storeu_si128( (__m128i*)(dst + (y + iy) * width + x), r1 );
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics.
// Produces an ~80% speed improvement over reference C implementation.
@ -1530,7 +1541,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
}
}
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics (2 in 4 cases)
// Produces a ~25% speed improvement over reference C implementation.
@ -1675,7 +1687,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
dst128 = (__m128i*)( dst + (y + 3) * width + x );
_mm_storeu_si128(dst128, rgba11);
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics
// Produces a ~68% speed improvement over reference C implementation.

View File

@ -883,7 +883,8 @@ void VertexLoader::SetVAT(const VAT& vat)
m_VtxAttr.texCoord[7].Format = vat.g2.Tex7CoordFormat;
m_VtxAttr.texCoord[7].Frac = vat.g2.Tex7Frac;
if (!m_VtxAttr.ByteDequant) {
if (!m_VtxAttr.ByteDequant)
{
ERROR_LOG(VIDEO, "ByteDequant is set to zero");
}
};

View File

@ -188,11 +188,13 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
{
out.Write("float4 pos = float4(dot(" I_TRANSFORMMATRICES"[posmtx], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+1], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+2], rawpos), 1);\n");
if (components & VB_HAS_NRMALL) {
if (components & VB_HAS_NRMALL)
{
out.Write("int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n");
out.Write("float3 N0 = " I_NORMALMATRICES"[normidx].xyz, N1 = " I_NORMALMATRICES"[normidx+1].xyz, N2 = " I_NORMALMATRICES"[normidx+2].xyz;\n");
}
}
if (components & VB_HAS_NRM0)
out.Write("float3 _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, rawnorm0)));\n");
if (components & VB_HAS_NRM1)