lsnes_memorywatch -> lsnes_instance.mwatch

This commit is contained in:
Ilari Liusvaara 2014-05-10 11:41:08 +03:00
parent ee6b522395
commit d95f247e9f
9 changed files with 26 additions and 24 deletions

View file

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

View file

@ -181,6 +181,4 @@ private:
memorywatch_set watch_set;
};
extern lsnes_memorywatch_set lsnes_memorywatch;
#endif

View file

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

View file

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

View file

@ -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<std::string> _watches = lsnes_memorywatch.enumerate();
std::set<std::string> _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;
}

View file

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

View file

@ -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<std::string> bind;
runemufn([&bind]() {
bind = lsnes_memorywatch.enumerate();
bind = lsnes_instance.mwatch.enumerate();
});
watches->Clear();
for(auto i : bind)

View file

@ -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<std::string> 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<std::string> old_watches;
runemufn([&old_watches]() { old_watches = lsnes_memorywatch.enumerate(); });
runemufn([&old_watches]() { old_watches = lsnes_instance.mwatch.enumerate(); });
std::map<std::string, std::string> new_watches;
std::string filename = choose_file_load(this, "Choose memory watch file", project_otherpath(),
filetype_watch);

View file

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