From d95f247e9f2556b796e897d9179bd58498bb884b Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sat, 10 May 2014 11:41:08 +0300 Subject: [PATCH] lsnes_memorywatch -> lsnes_instance.mwatch --- include/core/instance.hpp | 2 ++ include/core/memorywatch.hpp | 2 -- src/core/framebuffer.cpp | 3 ++- src/core/mainloop.cpp | 4 ++-- src/core/project.cpp | 11 ++++++----- src/platform/wxwidgets/editor-hexedit.cpp | 2 +- src/platform/wxwidgets/editor-memorywatch.cpp | 10 +++++----- src/platform/wxwidgets/mainwindow.cpp | 14 +++++++------- src/platform/wxwidgets/memorysearch.cpp | 2 +- 9 files changed, 26 insertions(+), 24 deletions(-) diff --git a/include/core/instance.hpp b/include/core/instance.hpp index bfb45411..a316ba8d 100644 --- a/include/core/instance.hpp +++ b/include/core/instance.hpp @@ -2,6 +2,7 @@ #define _instance__hpp__included__ #include "core/movie.hpp" +#include "core/memorywatch.hpp" #include "library/lua-base.hpp" #include "library/memoryspace.hpp" @@ -10,6 +11,7 @@ struct emulator_instance movie_logic mlogic; memory_space memory; lua::state lua; + lsnes_memorywatch_set mwatch; }; extern emulator_instance lsnes_instance; diff --git a/include/core/memorywatch.hpp b/include/core/memorywatch.hpp index 7794bb88..1a8936ce 100644 --- a/include/core/memorywatch.hpp +++ b/include/core/memorywatch.hpp @@ -181,6 +181,4 @@ private: memorywatch_set watch_set; }; -extern lsnes_memorywatch_set lsnes_memorywatch; - #endif diff --git a/src/core/framebuffer.cpp b/src/core/framebuffer.cpp index c30b422c..178fed1f 100644 --- a/src/core/framebuffer.cpp +++ b/src/core/framebuffer.cpp @@ -1,6 +1,7 @@ #include "core/command.hpp" #include "core/dispatch.hpp" #include "core/framebuffer.hpp" +#include "core/instance.hpp" #include "core/keymapper.hpp" #include "core/memorywatch.hpp" #include "core/misc.hpp" @@ -173,7 +174,7 @@ void redraw_framebuffer(framebuffer::raw& todraw, bool no_lua, bool spontaneous) ri.rgap = max(lrc.right_gap, (unsigned)drb); ri.tgap = max(lrc.top_gap, (unsigned)dtb); ri.bgap = max(lrc.bottom_gap, (unsigned)dbb); - lsnes_memorywatch.watch(ri.rq); + lsnes_instance.mwatch.watch(ri.rq); buffering.put_write(); notify_screen_update(); last_redraw_no_lua = no_lua; diff --git a/src/core/mainloop.cpp b/src/core/mainloop.cpp index 4fd57c95..9f19f812 100644 --- a/src/core/mainloop.cpp +++ b/src/core/mainloop.cpp @@ -423,7 +423,7 @@ void update_movie_state() //Lua variables. _status.lvars = get_lua_watch_vars(); //Memory watches. - _status.mvars = lsnes_memorywatch.get_window_vars(); + _status.mvars = lsnes_instance.mwatch.get_window_vars(); _status.valid = true; } catch(...) { @@ -1336,7 +1336,7 @@ void main_loop(struct loaded_rom& rom, struct moviefile& initial, bool load_has_ //Kill some things to avoid crashes. debug_core_change(); project_set(NULL, true); - lsnes_memorywatch.clear_multi(lsnes_memorywatch.enumerate()); + lsnes_instance.mwatch.clear_multi(lsnes_instance.mwatch.enumerate()); } void set_stop_at_frame(uint64_t frame) diff --git a/src/core/project.cpp b/src/core/project.cpp index 4fa95d0f..c29c240b 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -1,6 +1,7 @@ #include "core/command.hpp" #include "core/controller.hpp" #include "core/dispatch.hpp" +#include "core/instance.hpp" #include "core/inthread.hpp" #include "core/project.hpp" #include "core/misc.hpp" @@ -373,15 +374,15 @@ skip_rom_movie: active_project = p; switched = true; //Calculate union of old and new. - std::set _watches = lsnes_memorywatch.enumerate(); + std::set _watches = lsnes_instance.mwatch.enumerate(); for(auto i : p->watches) _watches.insert(i.first); for(auto i : _watches) try { if(p->watches.count(i)) - lsnes_memorywatch.set(i, p->watches[i]); + lsnes_instance.mwatch.set(i, p->watches[i]); else - lsnes_memorywatch.clear(i); + lsnes_instance.mwatch.clear(i); } catch(std::exception& e) { messages << "Can't set/clear watch '" << i << "': " << e.what() << std::endl; } @@ -453,9 +454,9 @@ std::string project_savestate_ext() void project_copy_watches(project_info& p) { - for(auto i : lsnes_memorywatch.enumerate()) { + for(auto i : lsnes_instance.mwatch.enumerate()) { try { - p.watches[i] = lsnes_memorywatch.get_string(i); + p.watches[i] = lsnes_instance.mwatch.get_string(i); } catch(std::exception& e) { messages << "Can't read memory watch '" << i << "': " << e.what() << std::endl; } diff --git a/src/platform/wxwidgets/editor-hexedit.cpp b/src/platform/wxwidgets/editor-hexedit.cpp index ab7d3265..b9595592 100644 --- a/src/platform/wxwidgets/editor-hexedit.cpp +++ b/src/platform/wxwidgets/editor-hexedit.cpp @@ -517,7 +517,7 @@ public: } e.endianess = hostendian ? 0 : (littleendian ? -1 : 1); e.scale_div = 1ULL << datatypes[curtype].scale; - runemufn([n, &e]() { lsnes_memorywatch.set(n, e); }); + runemufn([n, &e]() { lsnes_instance.mwatch.set(n, e); }); } catch(canceled_exception& e) { } } diff --git a/src/platform/wxwidgets/editor-memorywatch.cpp b/src/platform/wxwidgets/editor-memorywatch.cpp index 19f50dc5..40c616e7 100644 --- a/src/platform/wxwidgets/editor-memorywatch.cpp +++ b/src/platform/wxwidgets/editor-memorywatch.cpp @@ -302,7 +302,7 @@ wxeditor_memorywatch::wxeditor_memorywatch(wxWindow* parent, const std::string& lsnes_memorywatch_item it; bool had_it = false; try { - it = lsnes_memorywatch.get(name); + it = lsnes_instance.mwatch.get(name); had_it = true; } catch(...) { } @@ -506,7 +506,7 @@ void wxeditor_memorywatch::on_ok(wxCommandEvent& e) std::string error; runemufn([this, &it, &did_error, &error]() { try { - lsnes_memorywatch.set(name, it); + lsnes_instance.mwatch.set(name, it); } catch(std::exception& e) { did_error = true; error = e.what(); @@ -623,7 +623,7 @@ void wxeditor_memorywatches::on_rename(wxCommandEvent& e) bool exists = false; std::string newname = pick_text(this, "Rename watch", "Enter New name for watch:"); runemufn([watch, newname, &exists]() { - exists = !lsnes_memorywatch.rename(watch, newname); + exists = !lsnes_instance.mwatch.rename(watch, newname); }); if(exists) show_message_ok(this, "Error", "The target watch already exists", wxICON_EXCLAMATION); @@ -638,7 +638,7 @@ void wxeditor_memorywatches::on_delete(wxCommandEvent& e) { std::string watch = tostdstring(watches->GetStringSelection()); if(watch != "") - runemufn([watch]() { lsnes_memorywatch.clear(watch); }); + runemufn([watch]() { lsnes_instance.mwatch.clear(watch); }); refresh(); on_memorywatch_change(e); } @@ -669,7 +669,7 @@ void wxeditor_memorywatches::refresh() { std::set bind; runemufn([&bind]() { - bind = lsnes_memorywatch.enumerate(); + bind = lsnes_instance.mwatch.enumerate(); }); watches->Clear(); for(auto i : bind) diff --git a/src/platform/wxwidgets/mainwindow.cpp b/src/platform/wxwidgets/mainwindow.cpp index 63c9d415..9158f642 100644 --- a/src/platform/wxwidgets/mainwindow.cpp +++ b/src/platform/wxwidgets/mainwindow.cpp @@ -455,13 +455,13 @@ namespace if(!old_watches.count(name)) { try { if(name != "" && i.second != "") - lsnes_memorywatch.set(name, i.second); + lsnes_instance.mwatch.set(name, i.second); } catch(std::exception& e) { messages << "Can't set memory watch '" << name << "': " << e.what() << std::endl; } break; - } else if(lsnes_memorywatch.get_string(name) == i.second) + } else if(lsnes_instance.mwatch.get_string(name) == i.second) break; else name = munge_name(name); @@ -471,7 +471,7 @@ namespace for(auto i : new_watches) try { if(i.first != "" && i.second != "") - lsnes_memorywatch.set(i.first, i.second); + lsnes_instance.mwatch.set(i.first, i.second); } catch(std::exception& e) { messages << "Can't set memory watch '" << i.first << "': " << e.what() << std::endl; @@ -479,7 +479,7 @@ namespace for(auto i : old_watches) if(!new_watches.count(i)) try { - lsnes_memorywatch.clear(i); + lsnes_instance.mwatch.clear(i); } catch(std::exception& e) { messages << "Can't clear memory watch '" << i << "': " << e.what() << std::endl; @@ -1573,7 +1573,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) case wxID_SAVE_MEMORYWATCH: { modal_pause_holder hld; std::set old_watches; - runemufn([&old_watches]() { old_watches = lsnes_memorywatch.enumerate(); }); + runemufn([&old_watches]() { old_watches = lsnes_instance.mwatch.enumerate(); }); std::string filename = choose_file_save(this, "Save watches to file", project_otherpath(), filetype_watch); std::ofstream out(filename.c_str()); @@ -1581,7 +1581,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) std::string val; runemufn([i, &val]() { try { - val = lsnes_memorywatch.get_string(i); + val = lsnes_instance.mwatch.get_string(i); } catch(std::exception& e) { messages << "Can't get value of watch '" << i << "': " << e.what() << std::endl; @@ -1595,7 +1595,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) case wxID_LOAD_MEMORYWATCH: { modal_pause_holder hld; std::set old_watches; - runemufn([&old_watches]() { old_watches = lsnes_memorywatch.enumerate(); }); + runemufn([&old_watches]() { old_watches = lsnes_instance.mwatch.enumerate(); }); std::map new_watches; std::string filename = choose_file_load(this, "Choose memory watch file", project_otherpath(), filetype_watch); diff --git a/src/platform/wxwidgets/memorysearch.cpp b/src/platform/wxwidgets/memorysearch.cpp index f311de13..5e1f2097 100644 --- a/src/platform/wxwidgets/memorysearch.cpp +++ b/src/platform/wxwidgets/memorysearch.cpp @@ -1058,7 +1058,7 @@ void wxwindow_memorysearch::on_button_click(wxCommandEvent& e) endianess = j->endian; } e.endianess = endianess; - runemufn([n, &e]() { lsnes_memorywatch.set(n, e); }); + runemufn([n, &e]() { lsnes_instance.mwatch.set(n, e); }); } catch(canceled_exception& e) { } }