More range-based loops and overrides

This commit is contained in:
Tillmann Karras 2014-03-11 06:55:00 +01:00
parent 3fc9ca0789
commit 2fcaca0603
18 changed files with 110 additions and 127 deletions

View File

@ -283,13 +283,10 @@ bool RunCode(const ARCode &arcode)
LogInfo("Code Name: %s", arcode.name.c_str()); LogInfo("Code Name: %s", arcode.name.c_str());
LogInfo("Number of codes: %i", arcode.ops.size()); LogInfo("Number of codes: %i", arcode.ops.size());
std::vector<AREntry>::const_iterator for (const AREntry& entry : arcode.ops)
iter = arcode.ops.begin(),
ops_end = arcode.ops.end();
for (; iter != ops_end; ++iter)
{ {
const ARAddr& addr = *(ARAddr*)&iter->cmd_addr; const ARAddr& addr = *(ARAddr*)&entry.cmd_addr;
const u32 data = iter->value; const u32 data = entry.value;
// after a conditional code, skip lines if needed // after a conditional code, skip lines if needed
if (skip_count) if (skip_count)

View File

@ -24,11 +24,10 @@ InputPlugin *GetPlugin()
void Shutdown() void Shutdown()
{ {
std::vector<ControllerEmu*>::const_iterator for (const ControllerEmu* i : g_plugin.controllers)
i = g_plugin.controllers.begin(), {
e = g_plugin.controllers.end(); delete i;
for ( ; i!=e; ++i ) }
delete *i;
g_plugin.controllers.clear(); g_plugin.controllers.clear();
WiimoteReal::Stop(); WiimoteReal::Stop();

View File

@ -299,13 +299,14 @@ public:
static void RunTable59(UGeckoInstruction _instCode); static void RunTable59(UGeckoInstruction _instCode);
static void RunTable63(UGeckoInstruction _instCode); static void RunTable63(UGeckoInstruction _instCode);
static u32 Helper_Carry(u32 _uValue1, u32 _uValue2);
private: private:
// flag helper // flag helper
static void Helper_UpdateCR0(u32 _uValue); static void Helper_UpdateCR0(u32 _uValue);
static void Helper_UpdateCR1(double _fValue); static void Helper_UpdateCR1(double _fValue);
static void Helper_UpdateCR1(float _fValue); static void Helper_UpdateCR1(float _fValue);
static void Helper_UpdateCRx(int _x, u32 _uValue); static void Helper_UpdateCRx(int _x, u32 _uValue);
static u32 Helper_Carry(u32 _uValue1, u32 _uValue2);
// address helper // address helper
static u32 Helper_Get_EA (const UGeckoInstruction _inst); static u32 Helper_Get_EA (const UGeckoInstruction _inst);

View File

@ -547,12 +547,9 @@ void CheatSearchTab::UpdateCheatSearchResultsList()
} }
else else
{ {
std::vector<CheatSearchResult>::const_iterator for (const CheatSearchResult& result : search_results)
i = search_results.begin(),
e = search_results.end();
for (; i!=e; ++i)
{ {
u32 display_value = i->old_value; u32 display_value = result.old_value;
// #ifdef LIL_ENDIAN :p // #ifdef LIL_ENDIAN :p
switch (search_type_size) switch (search_type_size)
@ -574,7 +571,7 @@ void CheatSearchTab::UpdateCheatSearchResultsList()
rowfmt[14] = (wxChar)(wxT('0') + search_type_size*2); rowfmt[14] = (wxChar)(wxT('0') + search_type_size*2);
lbox_search_results->Append( lbox_search_results->Append(
wxString::Format(rowfmt, i->address, display_value, display_value, display_value)); wxString::Format(rowfmt, result.address, display_value, display_value, display_value));
} }
} }

View File

@ -88,14 +88,13 @@ void CodeConfigPanel::UpdateCodeList(bool checkRunning)
m_listbox_gcodes->Clear(); m_listbox_gcodes->Clear();
// add the codes to the listbox // add the codes to the listbox
std::vector<GeckoCode>::const_iterator for (const GeckoCode& code : m_gcodes)
gcodes_iter = m_gcodes.begin(),
gcodes_end = m_gcodes.end();
for (; gcodes_iter!=gcodes_end; ++gcodes_iter)
{ {
m_listbox_gcodes->Append(StrToWxStr(gcodes_iter->name)); m_listbox_gcodes->Append(StrToWxStr(code.name));
if (gcodes_iter->enabled) if (code.enabled)
{
m_listbox_gcodes->Check(m_listbox_gcodes->GetCount()-1, true); m_listbox_gcodes->Check(m_listbox_gcodes->GetCount()-1, true);
}
} }
wxCommandEvent evt; wxCommandEvent evt;
@ -131,21 +130,19 @@ void CodeConfigPanel::UpdateInfoBox(wxCommandEvent&)
// notes textctrl // notes textctrl
m_infobox.textctrl_notes->Clear(); m_infobox.textctrl_notes->Clear();
std::vector<std::string>::const_iterator for (const std::string& note : m_gcodes[sel].notes)
notes_iter = m_gcodes[sel].notes.begin(), {
notes_end = m_gcodes[sel].notes.end(); m_infobox.textctrl_notes->AppendText(StrToWxStr(note));
for (; notes_iter!=notes_end; ++notes_iter) }
m_infobox.textctrl_notes->AppendText(StrToWxStr(*notes_iter));
m_infobox.textctrl_notes->ScrollLines(-99); // silly m_infobox.textctrl_notes->ScrollLines(-99); // silly
m_infobox.label_creator->SetLabel(wxGetTranslation(wxstr_creator) + StrToWxStr(m_gcodes[sel].creator)); m_infobox.label_creator->SetLabel(wxGetTranslation(wxstr_creator) + StrToWxStr(m_gcodes[sel].creator));
// add codes to info listbox // add codes to info listbox
std::vector<GeckoCode::Code>::const_iterator for (const GeckoCode::Code& code : m_gcodes[sel].codes)
codes_iter = m_gcodes[sel].codes.begin(), {
codes_end = m_gcodes[sel].codes.end(); m_infobox.listbox_codes->Append(wxString::Format(wxT("%08X %08X"), code.address, code.data));
for (; codes_iter!=codes_end; ++codes_iter) }
m_infobox.listbox_codes->Append(wxString::Format(wxT("%08X %08X"), codes_iter->address, codes_iter->data));
} }
else else
{ {
@ -281,10 +278,7 @@ void CodeConfigPanel::DownloadCodes(wxCommandEvent&)
unsigned long added_count = 0; unsigned long added_count = 0;
// append the codes to the code list // append the codes to the code list
std::vector<GeckoCode>::const_iterator for (const GeckoCode& code : gcodes)
gcodes_iter = gcodes.begin(),
gcodes_end = gcodes.end();
for (; gcodes_iter!= gcodes_end; ++gcodes_iter)
{ {
// only add codes which do not already exist // only add codes which do not already exist
std::vector<GeckoCode>::const_iterator std::vector<GeckoCode>::const_iterator
@ -294,13 +288,13 @@ void CodeConfigPanel::DownloadCodes(wxCommandEvent&)
{ {
if (existing_gcodes_end == existing_gcodes_iter) if (existing_gcodes_end == existing_gcodes_iter)
{ {
m_gcodes.push_back(*gcodes_iter); m_gcodes.push_back(code);
++added_count; ++added_count;
break; break;
} }
// code exists // code exists
if (existing_gcodes_iter->Compare(*gcodes_iter)) if (existing_gcodes_iter->Compare(code))
break; break;
} }
} }

View File

@ -235,11 +235,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
choice_backend = new wxChoice(page_general, wxID_ANY); choice_backend = new wxChoice(page_general, wxID_ANY);
RegisterControl(choice_backend, wxGetTranslation(backend_desc)); RegisterControl(choice_backend, wxGetTranslation(backend_desc));
std::vector<VideoBackend*>::const_iterator for (const VideoBackend* backend : g_available_video_backends)
it = g_available_video_backends.begin(), {
itend = g_available_video_backends.end(); choice_backend->AppendString(wxGetTranslation(StrToWxStr(backend->GetDisplayName())));
for (; it != itend; ++it) }
choice_backend->AppendString(wxGetTranslation(StrToWxStr((*it)->GetDisplayName())));
choice_backend->SetStringSelection(wxGetTranslation(StrToWxStr(g_video_backend->GetDisplayName()))); choice_backend->SetStringSelection(wxGetTranslation(StrToWxStr(g_video_backend->GetDisplayName())));
choice_backend->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &VideoConfigDiag::Event_Backend, this); choice_backend->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &VideoConfigDiag::Event_Backend, this);
@ -259,11 +258,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
{ {
wxChoice* const choice_adapter = CreateChoice(page_general, vconfig.iAdapter, wxGetTranslation(adapter_desc)); wxChoice* const choice_adapter = CreateChoice(page_general, vconfig.iAdapter, wxGetTranslation(adapter_desc));
std::vector<std::string>::const_iterator for (const std::string& adapter : vconfig.backend_info.Adapters)
it = vconfig.backend_info.Adapters.begin(), {
itend = vconfig.backend_info.Adapters.end(); choice_adapter->AppendString(StrToWxStr(adapter));
for (; it != itend; ++it) }
choice_adapter->AppendString(StrToWxStr(*it));
choice_adapter->Select(vconfig.iAdapter); choice_adapter->Select(vconfig.iAdapter);
@ -381,11 +379,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
text_aamode = new wxStaticText(page_enh, -1, _("Anti-Aliasing:")); text_aamode = new wxStaticText(page_enh, -1, _("Anti-Aliasing:"));
choice_aamode = CreateChoice(page_enh, vconfig.iMultisampleMode, wxGetTranslation(aa_desc)); choice_aamode = CreateChoice(page_enh, vconfig.iMultisampleMode, wxGetTranslation(aa_desc));
std::vector<std::string>::const_iterator for (const std::string& mode : vconfig.backend_info.AAModes)
it = vconfig.backend_info.AAModes.begin(), {
itend = vconfig.backend_info.AAModes.end(); choice_aamode->AppendString(wxGetTranslation(StrToWxStr(mode)));
for (; it != itend; ++it) }
choice_aamode->AppendString(wxGetTranslation(StrToWxStr(*it)));
choice_aamode->Select(vconfig.iMultisampleMode); choice_aamode->Select(vconfig.iMultisampleMode);
szr_enh->Add(text_aamode, 1, wxALIGN_CENTER_VERTICAL, 0); szr_enh->Add(text_aamode, 1, wxALIGN_CENTER_VERTICAL, 0);
@ -406,11 +403,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
RegisterControl(choice_ppshader, wxGetTranslation(ppshader_desc)); RegisterControl(choice_ppshader, wxGetTranslation(ppshader_desc));
choice_ppshader->AppendString(_("(off)")); choice_ppshader->AppendString(_("(off)"));
std::vector<std::string>::const_iterator for (const std::string& shader : vconfig.backend_info.PPShaders)
it = vconfig.backend_info.PPShaders.begin(), {
itend = vconfig.backend_info.PPShaders.end(); choice_ppshader->AppendString(StrToWxStr(shader));
for (; it != itend; ++it) }
choice_ppshader->AppendString(StrToWxStr(*it));
if (vconfig.sPostProcessingShader.empty()) if (vconfig.sPostProcessingShader.empty())
choice_ppshader->Select(0); choice_ppshader->Select(0);

View File

@ -49,9 +49,9 @@ struct XFBSource : public XFBSourceBase
~XFBSource() { tex->Release(); } ~XFBSource() { tex->Release(); }
void Draw(const MathUtil::Rectangle<int> &sourcerc, void Draw(const MathUtil::Rectangle<int> &sourcerc,
const MathUtil::Rectangle<float> &drawrc) const; const MathUtil::Rectangle<float> &drawrc) const override;
void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight); void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight) override;
void CopyEFB(float Gamma); void CopyEFB(float Gamma) override;
D3DTexture2D* const tex; D3DTexture2D* const tex;
}; };
@ -81,10 +81,10 @@ public:
} }
private: private:
XFBSourceBase* CreateXFBSource(unsigned int target_width, unsigned int target_height); XFBSourceBase* CreateXFBSource(unsigned int target_width, unsigned int target_height) override;
void GetTargetSize(unsigned int *width, unsigned int *height, const EFBRectangle& sourceRc); void GetTargetSize(unsigned int *width, unsigned int *height, const EFBRectangle& sourceRc) override;
void CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma); void CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma) override;
static struct Efb static struct Efb
{ {

View File

@ -12,12 +12,12 @@ public:
PerfQuery(); PerfQuery();
~PerfQuery(); ~PerfQuery();
void EnableQuery(PerfQueryGroup type); void EnableQuery(PerfQueryGroup type) override;
void DisableQuery(PerfQueryGroup type); void DisableQuery(PerfQueryGroup type) override;
void ResetQuery(); void ResetQuery() override;
u32 GetQueryResult(PerfQueryType type); u32 GetQueryResult(PerfQueryType type) override;
void FlushResults(); void FlushResults() override;
bool IsFlushed() const; bool IsFlushed() const override;
private: private:
struct ActiveQuery struct ActiveQuery

View File

@ -12,41 +12,41 @@ public:
Renderer(); Renderer();
~Renderer(); ~Renderer();
void SetColorMask(); void SetColorMask() override;
void SetBlendMode(bool forceUpdate); void SetBlendMode(bool forceUpdate) override;
void SetScissorRect(const EFBRectangle& rc); void SetScissorRect(const EFBRectangle& rc) override;
void SetGenerationMode(); void SetGenerationMode() override;
void SetDepthMode(); void SetDepthMode() override;
void SetLogicOpMode(); void SetLogicOpMode() override;
void SetDitherMode(); void SetDitherMode() override;
void SetLineWidth(); void SetLineWidth() override;
void SetSamplerState(int stage,int texindex); void SetSamplerState(int stage,int texindex) override;
void SetInterlacingMode(); void SetInterlacingMode() override;
void SetViewport(); void SetViewport() override;
// TODO: Fix confusing names (see ResetAPIState and RestoreAPIState) // TODO: Fix confusing names (see ResetAPIState and RestoreAPIState)
void ApplyState(bool bUseDstAlpha); void ApplyState(bool bUseDstAlpha) override;
void RestoreState(); void RestoreState() override;
void ApplyCullDisable(); void ApplyCullDisable();
void RestoreCull(); void RestoreCull();
void RenderText(const std::string& text, int left, int top, u32 color); void RenderText(const std::string& text, int left, int top, u32 color) override;
u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data); u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override;
void ResetAPIState(); void ResetAPIState() override;
void RestoreAPIState(); void RestoreAPIState() override;
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc); TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override;
void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma); void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma) override;
void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z); void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override;
void ReinterpretPixelData(unsigned int convtype); void ReinterpretPixelData(unsigned int convtype) override;
bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc); bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc) override;
static bool CheckForResize(); static bool CheckForResize();
}; };

View File

@ -27,21 +27,21 @@ private:
~TCacheEntry(); ~TCacheEntry();
void Load(unsigned int width, unsigned int height, void Load(unsigned int width, unsigned int height,
unsigned int expanded_width, unsigned int levels); unsigned int expanded_width, unsigned int levels) override;
void FromRenderTarget(u32 dstAddr, unsigned int dstFormat, void FromRenderTarget(u32 dstAddr, unsigned int dstFormat,
unsigned int srcFormat, const EFBRectangle& srcRect, unsigned int srcFormat, const EFBRectangle& srcRect,
bool isIntensity, bool scaleByHalf, unsigned int cbufid, bool isIntensity, bool scaleByHalf, unsigned int cbufid,
const float *colmat); const float *colmat) override;
void Bind(unsigned int stage); void Bind(unsigned int stage) override;
bool Save(const std::string& filename, unsigned int level); bool Save(const std::string& filename, unsigned int level) override;
}; };
TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height, TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height,
unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt); unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt) override;
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h); TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) override;
u64 EncodeToRamFromTexture(u32 address, void* source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source) {return 0;}; u64 EncodeToRamFromTexture(u32 address, void* source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source) {return 0;};
}; };

View File

@ -17,12 +17,12 @@ public:
VertexManager(); VertexManager();
~VertexManager(); ~VertexManager();
NativeVertexFormat* CreateNativeVertexFormat(); NativeVertexFormat* CreateNativeVertexFormat() override;
void CreateDeviceObjects(); void CreateDeviceObjects() override;
void DestroyDeviceObjects(); void DestroyDeviceObjects() override;
protected: protected:
virtual void ResetBuffer(u32 stride); virtual void ResetBuffer(u32 stride) override;
u16* GetIndexBuffer() { return &LocalIBuffer[0]; } u16* GetIndexBuffer() { return &LocalIBuffer[0]; }
private: private:
@ -30,7 +30,7 @@ private:
void PrepareDrawBuffers(); void PrepareDrawBuffers();
void Draw(u32 stride); void Draw(u32 stride);
// temp // temp
void vFlush(bool useDstAlpha); void vFlush(bool useDstAlpha) override;
u32 m_vertex_buffer_cursor; u32 m_vertex_buffer_cursor;
u32 m_vertex_draw_offset; u32 m_vertex_draw_offset;

View File

@ -8,19 +8,19 @@ namespace DX11
class VideoBackend : public VideoBackendHardware class VideoBackend : public VideoBackendHardware
{ {
bool Initialize(void *&); bool Initialize(void *&) override;
void Shutdown(); void Shutdown() override;
std::string GetName(); std::string GetName() const override;
std::string GetDisplayName(); std::string GetDisplayName() const override;
void Video_Prepare(); void Video_Prepare() override;
void Video_Cleanup(); void Video_Cleanup() override;
void ShowConfig(void* parent); void ShowConfig(void* parent) override;
void UpdateFPSDisplay(const std::string&); void UpdateFPSDisplay(const std::string&) override;
unsigned int PeekMessages(); unsigned int PeekMessages() override;
}; };
} }

View File

@ -11,8 +11,8 @@ class VideoBackend : public VideoBackendHardware
bool Initialize(void *&) override; bool Initialize(void *&) override;
void Shutdown() override; void Shutdown() override;
std::string GetName() override; std::string GetName() const override;
std::string GetDisplayName() override; std::string GetDisplayName() const override;
void Video_Prepare() override; void Video_Prepare() override;
void Video_Cleanup() override; void Video_Cleanup() override;

View File

@ -92,12 +92,12 @@ Make AA apply instantly during gameplay if possible
namespace OGL namespace OGL
{ {
std::string VideoBackend::GetName() std::string VideoBackend::GetName() const
{ {
return "OGL"; return "OGL";
} }
std::string VideoBackend::GetDisplayName() std::string VideoBackend::GetDisplayName() const
{ {
if (GLInterface != nullptr && GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3) if (GLInterface != nullptr && GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
return "OpenGLES"; return "OpenGLES";

View File

@ -56,7 +56,7 @@ static volatile bool fifoStateRun = false;
static volatile bool emuRunningState = false; static volatile bool emuRunningState = false;
static std::mutex m_csSWVidOccupied; static std::mutex m_csSWVidOccupied;
std::string VideoSoftware::GetName() std::string VideoSoftware::GetName() const
{ {
return _trans("Software Renderer"); return _trans("Software Renderer");
} }

View File

@ -13,7 +13,7 @@ class VideoSoftware : public VideoBackend
bool Initialize(void *&) override; bool Initialize(void *&) override;
void Shutdown() override; void Shutdown() override;
std::string GetName() override; std::string GetName() const override;
void EmuStateChange(EMUSTATE_CHANGE newState) override; void EmuStateChange(EMUSTATE_CHANGE newState) override;

View File

@ -47,11 +47,10 @@ VideoConfigDialog::VideoConfigDialog(wxWindow* parent, const std::string& title,
wxStaticText* const label_backend = new wxStaticText(page_general, wxID_ANY, _("Backend:")); wxStaticText* const label_backend = new wxStaticText(page_general, wxID_ANY, _("Backend:"));
wxChoice* const choice_backend = new wxChoice(page_general, wxID_ANY, wxDefaultPosition); wxChoice* const choice_backend = new wxChoice(page_general, wxID_ANY, wxDefaultPosition);
std::vector<VideoBackend*>::const_iterator for (const VideoBackend* backend : g_available_video_backends)
it = g_available_video_backends.begin(), {
itend = g_available_video_backends.end(); choice_backend->AppendString(StrToWxStr(backend->GetDisplayName()));
for (; it != itend; ++it) }
choice_backend->AppendString(StrToWxStr((*it)->GetDisplayName()));
// TODO: How to get the translated plugin name? // TODO: How to get the translated plugin name?
choice_backend->SetStringSelection(StrToWxStr(g_video_backend->GetName())); choice_backend->SetStringSelection(StrToWxStr(g_video_backend->GetName()));

View File

@ -80,8 +80,8 @@ public:
virtual void Shutdown() = 0; virtual void Shutdown() = 0;
virtual void RunLoop(bool enable) = 0; virtual void RunLoop(bool enable) = 0;
virtual std::string GetName() = 0; virtual std::string GetName() const = 0;
virtual std::string GetDisplayName() { return GetName(); } virtual std::string GetDisplayName() const { return GetName(); }
virtual void ShowConfig(void*) {} virtual void ShowConfig(void*) {}