From 7b4eadbe3e4105dc6e9966168d179427f644306c Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sat, 24 May 2014 11:39:36 +0300 Subject: [PATCH] Make various instance stuff to take references to other instance objs --- include/core/command.hpp | 14 ++-- include/core/controllerframe.hpp | 7 +- include/core/framebuffer.hpp | 18 ++++- include/core/instance.hpp | 71 ++++++++++-------- include/core/memorywatch.hpp | 12 +++- include/core/multitrack.hpp | 3 +- include/core/project.hpp | 20 +++++- include/core/subtitles.hpp | 4 +- src/core/command.cpp | 11 +-- src/core/controllerframe.cpp | 11 +-- src/core/framebuffer.cpp | 22 +++--- src/core/instance.cpp | 25 ++++--- src/core/keymapper.cpp | 10 +-- src/core/mainloop.cpp | 4 +- src/core/memorywatch.cpp | 47 ++++++------ src/core/multitrack.cpp | 6 +- src/core/project.cpp | 26 +++---- src/core/subtitles.cpp | 6 +- src/core/window.cpp | 36 +++++----- src/platform/wxwidgets/branchesmenu.cpp | 18 ++--- src/platform/wxwidgets/dumpmenu.cpp | 6 +- src/platform/wxwidgets/editor-authors.cpp | 4 +- src/platform/wxwidgets/editor-autohold.cpp | 4 +- src/platform/wxwidgets/editor-hexedit.cpp | 9 +-- src/platform/wxwidgets/editor-memorywatch.cpp | 12 ++-- src/platform/wxwidgets/editor-movie.cpp | 64 ++++++++--------- src/platform/wxwidgets/editor-multitrack.cpp | 10 +-- src/platform/wxwidgets/editor-subtitles.cpp | 2 +- src/platform/wxwidgets/editor-tasinput.cpp | 16 ++--- src/platform/wxwidgets/keyboard.cpp | 2 +- src/platform/wxwidgets/mainwindow.cpp | 100 +++++++++++++------------- src/platform/wxwidgets/memorysearch.cpp | 14 ++-- src/platform/wxwidgets/messages.cpp | 2 +- src/platform/wxwidgets/requestrom.cpp | 4 +- src/platform/wxwidgets/romselect.cpp | 2 +- src/platform/wxwidgets/settings-advanced.cpp | 2 +- src/platform/wxwidgets/tracelogger.cpp | 30 ++++---- 37 files changed, 370 insertions(+), 284 deletions(-) diff --git a/include/core/command.hpp b/include/core/command.hpp index 4a968c9c..ed62afb0 100644 --- a/include/core/command.hpp +++ b/include/core/command.hpp @@ -1,24 +1,28 @@ #ifndef _command__hpp__included__ #define _command__hpp__included__ +#include "library/command.hpp" #include #include #include -#include "library/command.hpp" -#include "library/keyboard-mapper.hpp" extern command::set lsnes_cmds; -class emulator_instance; +namespace keyboard +{ + class mapper; + class invbind; +} class alias_binds_manager { public: - alias_binds_manager(emulator_instance& _instance); + alias_binds_manager(keyboard::mapper& _mapper, command::group& _command); ~alias_binds_manager(); void operator()(); private: - emulator_instance& instance; + keyboard::mapper& mapper; + command::group& command; std::map alias_binds; }; diff --git a/include/core/controllerframe.hpp b/include/core/controllerframe.hpp index 1ca41e3f..c2cd6f8f 100644 --- a/include/core/controllerframe.hpp +++ b/include/core/controllerframe.hpp @@ -18,6 +18,9 @@ #include "library/controller-data.hpp" #include "library/threads.hpp" +class project_state; +class movie_logic; + /** * Controllers state. */ @@ -27,7 +30,7 @@ public: /** * Constructor. */ - controller_state() throw(); + controller_state(project_state& _project, movie_logic& _mlogic) throw(); /** * Convert lcid (Logical Controller ID) into pcid (Physical Controler ID). * @@ -228,6 +231,8 @@ private: std::map all_macros; std::list> active_macros; threads::lock macro_lock; + project_state& project; + movie_logic& mlogic; }; #endif diff --git a/include/core/framebuffer.hpp b/include/core/framebuffer.hpp index 42203086..73450d9a 100644 --- a/include/core/framebuffer.hpp +++ b/include/core/framebuffer.hpp @@ -7,13 +7,25 @@ #include +class subtitle_commentary; +class memwatch_set; +namespace settingvar +{ + class group; +} +namespace keyboard +{ + class keyboard; +} + /** * Emulator frame buffer. */ class emu_framebuffer { public: - emu_framebuffer(); + emu_framebuffer(subtitle_commentary& _subtitles, settingvar::group& _settings, memwatch_set& _mwatch, + keyboard::keyboard& _keyboard); /** * The main framebuffer. */ @@ -82,6 +94,10 @@ private: render_info buffer3; triplebuffer::triplebuffer buffering; bool last_redraw_no_lua; + subtitle_commentary& subtitles; + settingvar::group& settings; + memwatch_set& mwatch; + keyboard::keyboard& keyboard; }; #endif diff --git a/include/core/instance.hpp b/include/core/instance.hpp index 29cd230a..80f877fb 100644 --- a/include/core/instance.hpp +++ b/include/core/instance.hpp @@ -66,42 +66,14 @@ void functor_call_helper2(void* args) delete reinterpret_cast(args); } - -struct emulator_instance +struct input_queue { struct function_queue_entry { std::function fn; std::function onerror; }; - - emulator_instance(); - movie_logic mlogic; - memory_space memory; - lua::state lua; - memwatch_set mwatch; - settingvar::group settings; - settingvar::cache setcache; - voice_commentary commentary; - subtitle_commentary subtitles; - movie_branches mbranch; - multitrack_edit mteditor; - _lsnes_status status_A; - _lsnes_status status_B; - _lsnes_status status_C; - triplebuffer::triplebuffer<_lsnes_status> status; - keyboard::keyboard keyboard; - keyboard::mapper mapper; - command::group command; - alias_binds_manager abindmanager; - rrdata nrrdata; - cart_mappings_refresher cmapper; - controller_state controls; - project_state project; - debug_context dbg; - framerate_regulator framerate; - emu_framebuffer fbuf; - threads::id emu_thread; + //Queue stuff. threads::lock queue_lock; threads::cv queue_condition; @@ -112,7 +84,10 @@ struct emulator_instance volatile uint64_t next_function; volatile bool system_thread_available; bool queue_function_run; - +/** + * Ctor. + */ + input_queue(command::group& _command); /** * Queue keypress. * @@ -166,6 +141,40 @@ struct emulator_instance * Run internal queues. */ void run_queue(bool unlocked) throw(); +private: + command::group& command; +}; + +struct emulator_instance +{ + emulator_instance(); + movie_logic mlogic; + memory_space memory; + lua::state lua; + memwatch_set mwatch; + settingvar::group settings; + settingvar::cache setcache; + voice_commentary commentary; + subtitle_commentary subtitles; + movie_branches mbranch; + multitrack_edit mteditor; + _lsnes_status status_A; + _lsnes_status status_B; + _lsnes_status status_C; + triplebuffer::triplebuffer<_lsnes_status> status; + keyboard::keyboard keyboard; + keyboard::mapper mapper; + command::group command; + alias_binds_manager abindmanager; + rrdata nrrdata; + cart_mappings_refresher cmapper; + controller_state controls; + project_state project; + debug_context dbg; + framerate_regulator framerate; + emu_framebuffer fbuf; + input_queue iqueue; + threads::id emu_thread; }; extern emulator_instance lsnes_instance; diff --git a/include/core/memorywatch.hpp b/include/core/memorywatch.hpp index 84dc350d..26aee223 100644 --- a/include/core/memorywatch.hpp +++ b/include/core/memorywatch.hpp @@ -7,6 +7,10 @@ #include "library/memorywatch.hpp" #include "library/json.hpp" +class memory_space; +class project_state; +class emu_framebuffer; + /** * lsnes memory watch printer variables. */ @@ -57,7 +61,7 @@ struct memwatch_item /** * Ctor. */ - memwatch_item(); + memwatch_item(memory_space& memory); /** * Serialize the item to JSON value. */ @@ -75,7 +79,7 @@ struct memwatch_item /** * Translate compatiblity item. */ - void compatiblity_unserialize(const std::string& item); + void compatiblity_unserialize(memory_space& memory, const std::string& item); //Fields memwatch_printer printer; //The printer. std::string expr; //The main expression. @@ -92,6 +96,7 @@ struct memwatch_item struct memwatch_set { + memwatch_set(memory_space& _memory, project_state& _project, emu_framebuffer& _fbuf); /** * Get the specified memory watch item. */ @@ -175,6 +180,9 @@ private: void erase_unused_watches(); void watch_output(const std::string& name, const std::string& value); memorywatch::set watch_set; + memory_space& memory; + project_state& project; + emu_framebuffer& fbuf; }; #endif diff --git a/include/core/multitrack.hpp b/include/core/multitrack.hpp index b45d56dd..bccb4a54 100644 --- a/include/core/multitrack.hpp +++ b/include/core/multitrack.hpp @@ -16,7 +16,7 @@ public: MT_OR, MT_XOR }; - multitrack_edit(movie_logic* _mlogic); + multitrack_edit(movie_logic& _mlogic, controller_state& _controls); void enable(bool state); void set(unsigned port, unsigned controller, state s); void set_and_notify(unsigned port, unsigned controller, state s); @@ -31,6 +31,7 @@ private: bool enabled; std::map, state> controllerstate; movie_logic& mlogic; + controller_state& controls; }; #endif diff --git a/include/core/project.hpp b/include/core/project.hpp index c46f4254..6ced2c60 100644 --- a/include/core/project.hpp +++ b/include/core/project.hpp @@ -9,6 +9,18 @@ #include "core/controller.hpp" #include "core/rom.hpp" +class voice_commentary; +class memwatch_set; +class controller_state; +namespace command +{ + class group; +} +namespace settingvar +{ + class cache; +} + //A branch. struct project_branch_info { @@ -149,7 +161,8 @@ private: class project_state { public: - project_state(); + project_state(voice_commentary& _commentary, memwatch_set& _mwatch, command::group& _command, + controller_state& _controls, settingvar::cache& _setcache); ~project_state(); /** * Get currently active project. @@ -205,6 +218,11 @@ public: void copy_macros(project_info& p, controller_state& s); private: project_info* active_project; + voice_commentary& commentary; + memwatch_set& mwatch; + command::group& command; + controller_state& controls; + settingvar::cache& setcache; }; #endif diff --git a/include/core/subtitles.hpp b/include/core/subtitles.hpp index 178fdc80..5353c386 100644 --- a/include/core/subtitles.hpp +++ b/include/core/subtitles.hpp @@ -20,11 +20,12 @@ private: }; class movie_logic; +class emu_framebuffer; struct subtitle_commentary { public: - subtitle_commentary(movie_logic* _mlogic); + subtitle_commentary(movie_logic& _mlogic, emu_framebuffer& _fbuf); std::set> get_all(); std::string get(uint64_t f, uint64_t l); void set(uint64_t f, uint64_t l, const std::string& x); @@ -33,6 +34,7 @@ public: void render(lua::render_context& ctx); private: movie_logic& mlogic; + emu_framebuffer& fbuf; }; #endif diff --git a/src/core/command.cpp b/src/core/command.cpp index 3ae849a1..227fc9e7 100644 --- a/src/core/command.cpp +++ b/src/core/command.cpp @@ -1,6 +1,7 @@ #include "core/command.hpp" -#include "core/instance.hpp" #include "core/keymapper.hpp" +#include "library/command.hpp" +#include "library/keyboard-mapper.hpp" #include "library/globalwrap.hpp" #include "library/threads.hpp" #include "core/misc.hpp" @@ -22,8 +23,8 @@ namespace std::map alias_binds; } -alias_binds_manager::alias_binds_manager(emulator_instance& _instance) - : instance(_instance) +alias_binds_manager::alias_binds_manager(keyboard::mapper& _mapper, command::group& _command) + : mapper(_mapper), command(_command) { } @@ -36,7 +37,7 @@ alias_binds_manager::~alias_binds_manager() void alias_binds_manager::operator()() { threads::arlock h(get_invbind_lock()); - auto a = instance.command.get_aliases(); + auto a = command.get_aliases(); for(auto i : alias_binds) { if(!a.count(i.first)) { delete i.second; @@ -47,6 +48,6 @@ void alias_binds_manager::operator()() if(i == "" || i[0] == '-') continue; if(!alias_binds.count(i) || alias_binds[i] == NULL) - alias_binds[i] = new keyboard::invbind(instance.mapper, i, "Alias‣" + i); + alias_binds[i] = new keyboard::invbind(mapper, i, "Alias‣" + i); } } diff --git a/src/core/controllerframe.cpp b/src/core/controllerframe.cpp index 3aa6e9ee..ff812741 100644 --- a/src/core/controllerframe.cpp +++ b/src/core/controllerframe.cpp @@ -16,7 +16,8 @@ namespace port_type_set dummytypes; } -controller_state::controller_state() throw() +controller_state::controller_state(project_state& _project, movie_logic& _mlogic) throw() + : project(_project), mlogic(_mlogic) { types = &dummytypes; tasinput_enaged = false; @@ -77,7 +78,7 @@ void controller_state::autofire2(unsigned port, unsigned controller, unsigned pb { unsigned idx = _input.porttypes().triple_to_index(port, controller, pbid); if(duty) { - _autofire[idx].first_frame = CORE().mlogic.get_movie().get_current_frame(); + _autofire[idx].first_frame = mlogic.get_movie().get_current_frame(); _autofire[idx].duty = duty; _autofire[idx].cyclelen = cyclelen; } else @@ -227,7 +228,7 @@ void controller_state::erase_macro(const std::string& macro) } } all_macros.erase(macro); - project_info* p = CORE().project.get(); + project_info* p = project.get(); if(p) { p->macros.erase(macro); p->flush(); @@ -267,7 +268,7 @@ void controller_state::set_macro(const std::string& macro, const controller_macr break; } } - project_info* p = CORE().project.get(); + project_info* p = project.get(); if(p) { p->macros[macro] = all_macros[macro].serialize(); p->flush(); @@ -334,7 +335,7 @@ void controller_state::rename_macro(const std::string& old, const std::string& n break; } } - project_info* p = CORE().project.get(); + project_info* p = project.get(); if(p) { p->macros[newn] = p->macros[old]; p->macros.erase(old); diff --git a/src/core/framebuffer.cpp b/src/core/framebuffer.cpp index 2fb09c27..817b5b26 100644 --- a/src/core/framebuffer.cpp +++ b/src/core/framebuffer.cpp @@ -100,8 +100,10 @@ namespace framebuffer::raw emu_framebuffer::screen_corrupt; -emu_framebuffer::emu_framebuffer() - : buffering(buffer1, buffer2, buffer3) +emu_framebuffer::emu_framebuffer(subtitle_commentary& _subtitles, settingvar::group& _settings, memwatch_set& _mwatch, + keyboard::keyboard& _keyboard) + : buffering(buffer1, buffer2, buffer3), subtitles(_subtitles), settings(_settings), mwatch(_mwatch), + keyboard(_keyboard) { last_redraw_no_lua = false; } @@ -153,16 +155,16 @@ void emu_framebuffer::redraw_framebuffer(framebuffer::raw& todraw, bool no_lua, lrc.height = todraw.get_height() * vscl; if(!no_lua) { lua_callback_do_paint(&lrc, spontaneous); - CORE().subtitles.render(lrc); + subtitles.render(lrc); } ri.fbuf = todraw; ri.hscl = hscl; ri.vscl = vscl; - ri.lgap = max(lrc.left_gap, (unsigned)dlb(CORE().settings)); - ri.rgap = max(lrc.right_gap, (unsigned)drb(CORE().settings)); - ri.tgap = max(lrc.top_gap, (unsigned)dtb(CORE().settings)); - ri.bgap = max(lrc.bottom_gap, (unsigned)dbb(CORE().settings)); - CORE().mwatch.watch(ri.rq); + ri.lgap = max(lrc.left_gap, (unsigned)dlb(settings)); + ri.rgap = max(lrc.right_gap, (unsigned)drb(settings)); + ri.tgap = max(lrc.top_gap, (unsigned)dtb(settings)); + ri.bgap = max(lrc.bottom_gap, (unsigned)dbb(settings)); + mwatch.watch(ri.rq); buffering.put_write(); notify_screen_update(); last_redraw_no_lua = no_lua; @@ -188,8 +190,8 @@ void emu_framebuffer::render_framebuffer() ri.rq.run(main_screen); notify_set_screen(main_screen); //We would want divide by 2, but we'll do it ourselves in order to do mouse. - keyboard::key* mouse_x = CORE().keyboard.try_lookup_key("mouse_x"); - keyboard::key* mouse_y = CORE().keyboard.try_lookup_key("mouse_y"); + keyboard::key* mouse_x = keyboard.try_lookup_key("mouse_x"); + keyboard::key* mouse_y = keyboard.try_lookup_key("mouse_y"); keyboard::mouse_calibration xcal; keyboard::mouse_calibration ycal; xcal.offset = ri.lgap; diff --git a/src/core/instance.cpp b/src/core/instance.cpp index a0ec14ee..d40154e4 100644 --- a/src/core/instance.cpp +++ b/src/core/instance.cpp @@ -7,13 +7,20 @@ #include #endif -emulator_instance::emulator_instance() - : setcache(settings), subtitles(&mlogic), mbranch(&mlogic), mteditor(&mlogic), - status(status_A, status_B, status_C), mapper(keyboard, command), abindmanager(*this), - cmapper(memory) +input_queue::input_queue(command::group& _command) + : command(_command) { system_thread_available = false; queue_function_run = false; +} + +emulator_instance::emulator_instance() + : mwatch(memory, project, fbuf), setcache(settings), subtitles(mlogic, fbuf), mbranch(&mlogic), + mteditor(mlogic, controls), status(status_A, status_B, status_C), mapper(keyboard, command), + abindmanager(mapper, command), cmapper(memory), controls(project, mlogic), + project(commentary, mwatch, command, controls, setcache), fbuf(subtitles, settings, mwatch, keyboard), + iqueue(command) +{ status_A.valid = false; status_B.valid = false; status_C.valid = false; @@ -60,21 +67,21 @@ keypress_info::keypress_info(keyboard::modifier_set mod, keyboard::key& _key, ke } -void emulator_instance::queue(const keypress_info& k) throw(std::bad_alloc) +void input_queue::queue(const keypress_info& k) throw(std::bad_alloc) { threads::alock h(queue_lock); keypresses.push_back(k); queue_condition.notify_all(); } -void emulator_instance::queue(const std::string& c) throw(std::bad_alloc) +void input_queue::queue(const std::string& c) throw(std::bad_alloc) { threads::alock h(queue_lock); commands.push_back(c); queue_condition.notify_all(); } -void emulator_instance::queue(std::function f, std::function onerror, bool sync) +void input_queue::queue(std::function f, std::function onerror, bool sync) throw(std::bad_alloc) { if(!system_thread_available) { @@ -99,7 +106,7 @@ void emulator_instance::queue(std::function f, std::function memwatch_printer::get_printer_obj( return ptr; } -memwatch_item::memwatch_item() +memwatch_item::memwatch_item(memory_space& memory) { bytes = 0; signed_flag = false; @@ -228,7 +228,7 @@ memwatch_item::memwatch_item() scale_div = 1; addr_base = 0; addr_size = 0; - mspace = &CORE().memory; + mspace = &memory; } JSON::node memwatch_item::serialize() @@ -280,7 +280,7 @@ memorywatch::memread_oper* memwatch_item::get_memread_oper() return o; } -void memwatch_item::compatiblity_unserialize(const std::string& item) +void memwatch_item::compatiblity_unserialize(memory_space& memory, const std::string& item) { regex_results r; if(!(r = regex("C0x([0-9A-Fa-f]{1,16})z([bBwWoOdDqQfF])(H([0-9A-Ga-g]))?", item))) @@ -306,7 +306,7 @@ void memwatch_item::compatiblity_unserialize(const std::string& item) case 'F': bytes = 8; signed_flag = true; float_flag = true; break; default: bytes = 0; break; } - auto mdata = CORE().memory.lookup(addr); + auto mdata = memory.lookup(addr); if(mdata.first) { addr = mdata.second; addr_base = mdata.first->base; @@ -328,7 +328,7 @@ void memwatch_item::compatiblity_unserialize(const std::string& item) format = ""; expr = (stringfmt() << "0x" << std::hex << addr).str(); scale_div = 1; - mspace = &CORE().memory; + mspace = &memory; printer.position = memwatch_printer::PC_MEMORYWATCH; printer.cond_enable = false; printer.enabled = "true"; @@ -344,6 +344,11 @@ void memwatch_item::compatiblity_unserialize(const std::string& item) printer.onscreen_halo_color = 0; } +memwatch_set::memwatch_set(memory_space& _memory, project_state& _project, emu_framebuffer& _fbuf) + : memory(_memory), project(_project), fbuf(_fbuf) +{ +} + std::set memwatch_set::enumerate() { std::set r; @@ -358,21 +363,21 @@ void memwatch_set::clear(const std::string& name) nitems.erase(name); rebuild(nitems); std::swap(items, nitems); - auto pr = CORE().project.get(); + auto pr = project.get(); if(pr) { pr->watches.erase(name); pr->flush(); } - CORE().fbuf.redraw_framebuffer(); + fbuf.redraw_framebuffer(); } void memwatch_set::set(const std::string& name, const std::string& item) { - memwatch_item _item; + memwatch_item _item(memory); if(item != "" && item[0] != '{') { //Compatiblity. try { - _item.compatiblity_unserialize(item); + _item.compatiblity_unserialize(memory, item); } catch(std::exception& e) { messages << "Can't handle old memory watch '" << name << "'" << std::endl; return; @@ -386,7 +391,7 @@ memwatch_item& memwatch_set::get(const std::string& name) { if(!items.count(name)) throw std::runtime_error("No such memory watch named '" + name + "'"); - return items[name]; + return items.find(name)->second; } std::string memwatch_set::get_string(const std::string& name, JSON::printer* printer) @@ -416,26 +421,26 @@ bool memwatch_set::rename(const std::string& oldname, const std::string& newname return false; if(!nitems.count(oldname)) return false; - nitems[newname] = nitems[oldname]; + nitems.insert(std::make_pair(newname, nitems.find(oldname)->second)); nitems.erase(oldname); rebuild(nitems); std::swap(items, nitems); - CORE().fbuf.redraw_framebuffer(); + fbuf.redraw_framebuffer(); return true; } void memwatch_set::set(const std::string& name, memwatch_item& item) { std::map nitems = items; - nitems[name] = item; + nitems.insert(std::make_pair(name, item)); rebuild(nitems); std::swap(items, nitems); - auto pr = CORE().project.get(); + auto pr = project.get(); if(pr) { pr->watches[name] = get_string(name); pr->flush(); } - CORE().fbuf.redraw_framebuffer(); + fbuf.redraw_framebuffer(); } std::string memwatch_set::get_value(const std::string& name) @@ -447,23 +452,23 @@ void memwatch_set::set_multi(std::list>& l { std::map nitems = items; for(auto& i : list) - nitems[i.first] = i.second; + nitems.insert(i); rebuild(nitems); std::swap(items, nitems); - auto pr = CORE().project.get(); + auto pr = project.get(); if(pr) { for(auto& i : list) pr->watches[i.first] = get_string(i.first); pr->flush(); } - CORE().fbuf.redraw_framebuffer(); + fbuf.redraw_framebuffer(); } void memwatch_set::set_multi(std::list>& list) { std::list> _list; for(auto& i: list) { - memwatch_item it; + memwatch_item it(memory); it.unserialize(JSON::node(i.second)); _list.push_back(std::make_pair(i.first, it)); } @@ -477,13 +482,13 @@ void memwatch_set::clear_multi(const std::set& names) nitems.erase(i); rebuild(nitems); std::swap(items, nitems); - auto pr = CORE().project.get(); + auto pr = project.get(); if(pr) { for(auto& i : names) pr->watches.erase(i); pr->flush(); } - CORE().fbuf.redraw_framebuffer(); + fbuf.redraw_framebuffer(); } void memwatch_set::rebuild(std::map& nitems) diff --git a/src/core/multitrack.cpp b/src/core/multitrack.cpp index c805b096..36ba429a 100644 --- a/src/core/multitrack.cpp +++ b/src/core/multitrack.cpp @@ -10,8 +10,8 @@ void update_movie_state(); -multitrack_edit::multitrack_edit(movie_logic* _mlogic) - : mlogic(*_mlogic) +multitrack_edit::multitrack_edit(movie_logic& _mlogic, controller_state& _controls) + : mlogic(_mlogic), controls(_controls) { } @@ -53,7 +53,7 @@ void multitrack_edit::rotate(bool forward) return; std::vector> x; for(unsigned i = 0;; i++) { - auto pcid = CORE().controls.lcid_to_pcid(i); + auto pcid = controls.lcid_to_pcid(i); if(pcid.first < 0) break; x.push_back(std::make_pair(pcid.first, pcid.second)); diff --git a/src/core/project.cpp b/src/core/project.cpp index 2d464854..abd7b6c5 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -187,7 +187,9 @@ namespace } } -project_state::project_state() +project_state::project_state(voice_commentary& _commentary, memwatch_set& _mwatch, command::group& _command, + controller_state& _controls, settingvar::cache& _setcache) + : commentary(_commentary), mwatch(_mwatch), command(_command), controls(_controls), setcache(_setcache) { active_project = NULL; } @@ -325,7 +327,7 @@ bool project_state::set(project_info* p, bool current) { if(!p) { if(active_project) - CORE().commentary.unload_collection(); + commentary.unload_collection(); active_project = p; notify_core_change(); notify_branch_change(); @@ -381,23 +383,23 @@ skip_rom_movie: active_project = p; switched = true; //Calculate union of old and new. - std::set _watches = CORE().mwatch.enumerate(); + std::set _watches = mwatch.enumerate(); for(auto i : p->watches) _watches.insert(i.first); for(auto i : _watches) try { if(p->watches.count(i)) - CORE().mwatch.set(i, p->watches[i]); + mwatch.set(i, p->watches[i]); else - CORE().mwatch.clear(i); + mwatch.clear(i); } catch(std::exception& e) { messages << "Can't set/clear watch '" << i << "': " << e.what() << std::endl; } - CORE().commentary.load_collection(p->directory + "/" + p->prefix + ".lsvs"); - CORE().command.invoke("reset-lua"); + commentary.load_collection(p->directory + "/" + p->prefix + ".lsvs"); + command.invoke("reset-lua"); for(auto i : p->luascripts) - CORE().command.invoke("run-lua " + i); - load_project_macros(CORE().controls, *active_project); + command.invoke("run-lua " + i); + load_project_macros(controls, *active_project); } catch(std::exception& e) { if(newmovie && !used) delete newmovie; @@ -443,7 +445,7 @@ std::string project_state::moviepath() if(active_project) return active_project->directory; else - return CORE().setcache.get("moviepath"); + return setcache.get("moviepath"); } std::string project_state::otherpath() @@ -461,9 +463,9 @@ std::string project_state::savestate_ext() void project_state::copy_watches(project_info& p) { - for(auto i : CORE().mwatch.enumerate()) { + for(auto i : mwatch.enumerate()) { try { - p.watches[i] = CORE().mwatch.get_string(i); + p.watches[i] = mwatch.get_string(i); } catch(std::exception& e) { messages << "Can't read memory watch '" << i << "': " << e.what() << std::endl; } diff --git a/src/core/subtitles.cpp b/src/core/subtitles.cpp index 380d5433..6f0f113c 100644 --- a/src/core/subtitles.cpp +++ b/src/core/subtitles.cpp @@ -159,8 +159,8 @@ namespace }); } -subtitle_commentary::subtitle_commentary(movie_logic* _mlogic) - : mlogic(*_mlogic) +subtitle_commentary::subtitle_commentary(movie_logic& _mlogic, emu_framebuffer& _fbuf) + : mlogic(_mlogic), fbuf(_fbuf) { } @@ -249,5 +249,5 @@ void subtitle_commentary::set(uint64_t f, uint64_t l, const std::string& x) else mlogic.get_mfile().subtitles[key] = s_unescape(x); notify_subtitle_change(); - CORE().fbuf.redraw_framebuffer(); + fbuf.redraw_framebuffer(); } diff --git a/src/core/window.cpp b/src/core/window.cpp index 770a8edd..8eea7cb2 100644 --- a/src/core/window.cpp +++ b/src/core/window.cpp @@ -242,7 +242,7 @@ namespace { on_idle_time = lua_timed_hook(LUA_TIMED_HOOK_IDLE); on_timer_time = lua_timed_hook(LUA_TIMED_HOOK_TIMER); - CORE().queue_function_run = false; + CORE().iqueue.queue_function_run = false; } } @@ -251,9 +251,9 @@ namespace void platform::dummy_event_loop() throw() { while(!do_exit_dummy_event_loop) { - threads::alock h(CORE().queue_lock); - CORE().run_queue(true); - threads::cv_timed_wait(CORE().queue_condition, h, threads::ustime(MAXWAIT)); + threads::alock h(CORE().iqueue.queue_lock); + CORE().iqueue.run_queue(true); + threads::cv_timed_wait(CORE().iqueue.queue_condition, h, threads::ustime(MAXWAIT)); random_mix_timing_entropy(); } } @@ -261,15 +261,15 @@ void platform::dummy_event_loop() throw() void platform::exit_dummy_event_loop() throw() { do_exit_dummy_event_loop = true; - threads::alock h(CORE().queue_lock); - CORE().queue_condition.notify_all(); + threads::alock h(CORE().iqueue.queue_lock); + CORE().iqueue.queue_condition.notify_all(); usleep(200000); } void platform::flush_command_queue() throw() { reload_lua_timers(); - CORE().queue_function_run = false; + CORE().iqueue.queue_function_run = false; if(modal_pause || normal_pause) CORE().framerate.freeze_time(framerate_regulator::get_utime()); bool run_idle = false; @@ -284,11 +284,11 @@ void platform::flush_command_queue() throw() reload_lua_timers(); run_idle = false; } - threads::alock h(CORE().queue_lock); - CORE().run_queue(true); + threads::alock h(CORE().iqueue.queue_lock); + CORE().iqueue.run_queue(true); if(!pausing_allowed) break; - if(CORE().queue_function_run) + if(CORE().iqueue.queue_function_run) reload_lua_timers(); now = framerate_regulator::get_utime(); uint64_t waitleft = 0; @@ -305,7 +305,7 @@ void platform::flush_command_queue() throw() if(on_timer_time >= now) waitleft = min(waitleft, on_timer_time - now); if(waitleft > 0) { - threads::cv_timed_wait(CORE().queue_condition, h, threads::ustime(waitleft)); + threads::cv_timed_wait(CORE().iqueue.queue_condition, h, threads::ustime(waitleft)); random_mix_timing_entropy(); } } else @@ -337,9 +337,9 @@ void platform::wait(uint64_t usec) throw() run_idle = false; reload_lua_timers(); } - threads::alock h(CORE().queue_lock); - CORE().run_queue(true); - if(CORE().queue_function_run) + threads::alock h(CORE().iqueue.queue_lock); + CORE().iqueue.run_queue(true); + if(CORE().iqueue.queue_function_run) reload_lua_timers(); //If usec is 0, never wait (waitleft can be nonzero if time counting screws up). if(!usec) @@ -358,7 +358,7 @@ void platform::wait(uint64_t usec) throw() if(on_timer_time >= now) waitleft = min(waitleft, on_timer_time - now); if(waitleft > 0) { - threads::cv_timed_wait(CORE().queue_condition, h, threads::ustime(waitleft)); + threads::cv_timed_wait(CORE().iqueue.queue_condition, h, threads::ustime(waitleft)); random_mix_timing_entropy(); } } else @@ -369,8 +369,8 @@ void platform::wait(uint64_t usec) throw() void platform::cancel_wait() throw() { continue_time = 0; - threads::alock h(CORE().queue_lock); - CORE().queue_condition.notify_all(); + threads::alock h(CORE().iqueue.queue_lock); + CORE().iqueue.queue_condition.notify_all(); } void platform::set_modal_pause(bool enable) throw() @@ -380,7 +380,7 @@ void platform::set_modal_pause(bool enable) throw() void platform::run_queues() throw() { - CORE().run_queue(false); + CORE().iqueue.run_queue(false); } namespace diff --git a/src/platform/wxwidgets/branchesmenu.cpp b/src/platform/wxwidgets/branchesmenu.cpp index c6fc6137..a8d4a1a3 100644 --- a/src/platform/wxwidgets/branchesmenu.cpp +++ b/src/platform/wxwidgets/branchesmenu.cpp @@ -66,7 +66,7 @@ namespace std::map namemap; std::map> childmap; uint64_t cur = 0; - lsnes_instance.run([&cur, &namemap, &childmap]() { + lsnes_instance.iqueue.run([&cur, &namemap, &childmap]() { auto p = lsnes_instance.project.get(); if(!p) return; fill_namemap(*p, 0, namemap, childmap); @@ -103,7 +103,7 @@ namespace } void call_project_flush() { - lsnes_instance.run_async([] { + lsnes_instance.iqueue.run_async([] { auto p = CORE().project.get(); if(p) p->flush(); }, [](std::exception& e) {}); @@ -234,7 +234,7 @@ namespace } catch(canceled_exception& e) { return; } - lsnes_instance.run([this, id, newname]() { + lsnes_instance.iqueue.run([this, id, newname]() { run_show_error(this, "Error creating branch", "Can't create branch", [id, newname]() { auto p = CORE().project.get(); if(p) p->create_branch(id, newname); @@ -246,7 +246,7 @@ namespace { uint64_t id = get_selected_id(); if(id == 0xFFFFFFFFFFFFFFFFULL) return; - lsnes_instance.run([this, id]() { + lsnes_instance.iqueue.run([this, id]() { run_show_error(this, "Error setting branch", "Can't set branch", [id]() { auto p = CORE().project.get(); if(p) p->set_current_branch(id); @@ -266,7 +266,7 @@ namespace } catch(canceled_exception& e) { return; } - lsnes_instance.run([this, id, newname]() { + lsnes_instance.iqueue.run([this, id, newname]() { run_show_error(this, "Error renaming branch", "Can't rename branch", [id, newname]() { auto p = CORE().project.get(); if(p) p->set_branch_name(id, newname); @@ -289,7 +289,7 @@ namespace pid = bsel->get_selection(); if(pid == 0xFFFFFFFFFFFFFFFFULL) return; bsel->Destroy(); - lsnes_instance.run([this, id, pid]() { + lsnes_instance.iqueue.run([this, id, pid]() { run_show_error(this, "Error reparenting branch", "Can't reparent branch", [id, pid]() { auto p = CORE().project.get(); @@ -303,7 +303,7 @@ namespace { uint64_t id = get_selected_id(); if(id == 0xFFFFFFFFFFFFFFFFULL) return; - lsnes_instance.run([this, id]() { + lsnes_instance.iqueue.run([this, id]() { run_show_error(this, "Error deleting branch", "Can't delete branch", [id]() { auto p = CORE().project.get(); if(p) p->delete_branch(id); @@ -404,7 +404,7 @@ void branches_menu::on_select(wxCommandEvent& e) if(!branch_ids.count(id)) return; uint64_t bid = branch_ids[id]; std::string err; - lsnes_instance.run_async([this, bid]() { + lsnes_instance.iqueue.run_async([this, bid]() { auto p = CORE().project.get(); if(p) p->set_current_branch(bid); if(p) p->flush(); @@ -418,7 +418,7 @@ void branches_menu::update() { std::map namemap; std::map> childmap; - lsnes_instance.run([&namemap, &childmap]() { + lsnes_instance.iqueue.run([&namemap, &childmap]() { auto p = CORE().project.get(); if(!p) return; fill_namemap(*p, 0, namemap, childmap); diff --git a/src/platform/wxwidgets/dumpmenu.cpp b/src/platform/wxwidgets/dumpmenu.cpp index 88fadf41..f64a5954 100644 --- a/src/platform/wxwidgets/dumpmenu.cpp +++ b/src/platform/wxwidgets/dumpmenu.cpp @@ -79,7 +79,7 @@ dumper_menu::dumper_menu(wxWindow* win, int wxid_low, int wxid_high) wxid_range_high = wxid_high; monitor = new dumper_menu_monitor(this); std::map new_dumpers; - lsnes_instance.run([&new_dumpers]() { + lsnes_instance.iqueue.run([&new_dumpers]() { std::set dset = adv_dumper::get_dumper_set(); for(auto i : dset) update_dumperinfo(new_dumpers, i); @@ -102,7 +102,7 @@ void dumper_menu::on_select(wxCommandEvent& e) adv_dumper* t = existing_dumpers[i.first].instance; if(i.second.end_wxid == id) { //Execute end of dump operation. - lsnes_instance.run([t, &error_str]() { + lsnes_instance.iqueue.run([t, &error_str]() { try { t->end(); } catch(std::exception& e) { @@ -153,7 +153,7 @@ void dumper_menu::on_select(wxCommandEvent& e) } if(prefix == "") return; - lsnes_instance.run([t, mode, prefix, &error_str]() { + lsnes_instance.iqueue.run([t, mode, prefix, &error_str]() { try { t->start(mode, prefix); } catch(std::exception& e) { diff --git a/src/platform/wxwidgets/editor-authors.cpp b/src/platform/wxwidgets/editor-authors.cpp index 77a01bb4..638ed2e7 100644 --- a/src/platform/wxwidgets/editor-authors.cpp +++ b/src/platform/wxwidgets/editor-authors.cpp @@ -153,7 +153,7 @@ wxeditor_authors::wxeditor_authors(wxWindow* parent) std::list luascriptlist; std::string gamename; std::string x; - lsnes_instance.run([&gamename, &x, &luascriptlist, proj]() { + lsnes_instance.iqueue.run([&gamename, &x, &luascriptlist, proj]() { if(proj) { luascriptlist = proj->luascripts; gamename = proj->gamename; @@ -217,7 +217,7 @@ void wxeditor_authors::on_ok(wxCommandEvent& e) luascriptlist.push_back(tostdstring(luascripts->GetString(i))); bool run_new = autorunlua ? autorunlua->GetValue() : false; - lsnes_instance.run([gamename, newauthors, pfx, dir, prjname, luascriptlist, run_new, proj]() { + lsnes_instance.iqueue.run([gamename, newauthors, pfx, dir, prjname, luascriptlist, run_new, proj]() { std::set oldscripts; if(proj) { for(auto i : proj->luascripts) diff --git a/src/platform/wxwidgets/editor-autohold.cpp b/src/platform/wxwidgets/editor-autohold.cpp index 6fe9fdcc..49a4f9b2 100644 --- a/src/platform/wxwidgets/editor-autohold.cpp +++ b/src/platform/wxwidgets/editor-autohold.cpp @@ -129,7 +129,7 @@ void wxeditor_autohold::on_checkbox(wxCommandEvent& e) bool isaf = (t.afid == id); bool newstate = isaf ? t.afcheck->IsChecked() : t.check->IsChecked(); bool state = false; - lsnes_instance.run([t, newstate, &state, isaf]() { + lsnes_instance.iqueue.run([t, newstate, &state, isaf]() { if(isaf) { auto _state = CORE().controls.autofire2(t.port, t.controller, t.index); state = (_state.first != 0); @@ -170,7 +170,7 @@ void wxeditor_autohold::update_controls() panels.clear(); std::vector _autoholds; std::vector _controller_labels; - lsnes_instance.run([&_autoholds, &_controller_labels](){ + lsnes_instance.iqueue.run([&_autoholds, &_controller_labels](){ std::map next_in_class; controller_frame model = CORE().controls.get_blank(); const port_type_set& pts = model.porttypes(); diff --git a/src/platform/wxwidgets/editor-hexedit.cpp b/src/platform/wxwidgets/editor-hexedit.cpp index 9c2f7a1d..79f91a7b 100644 --- a/src/platform/wxwidgets/editor-hexedit.cpp +++ b/src/platform/wxwidgets/editor-hexedit.cpp @@ -502,7 +502,7 @@ public: << "Enter name for watch at 0x" << std::hex << addr << ":").str()); if(n == "") return; - memwatch_item e; + memwatch_item e(lsnes_instance.memory); e.expr = (stringfmt() << addr).str(); e.format = datatypes[curtype].format; e.bytes = datatypes[curtype].len; @@ -517,7 +517,7 @@ public: } e.endianess = hostendian ? 0 : (littleendian ? -1 : 1); e.scale_div = 1ULL << datatypes[curtype].scale; - lsnes_instance.run([n, &e]() { lsnes_instance.mwatch.set(n, e); }); + lsnes_instance.iqueue.run([n, &e]() { lsnes_instance.mwatch.set(n, e); }); } catch(canceled_exception& e) { } } @@ -755,7 +755,7 @@ invalid_bookmark: hex_input_state = -1; if(hpanel->seloff + 1 < hpanel->vmasize) hpanel->seloff++; - lsnes_instance.run([addr, byte]() {lsnes_instance.memory.write(addr, byte); }); + lsnes_instance.iqueue.run([addr, byte]() {lsnes_instance.memory.write(addr, byte); }); } hpanel->request_paint(); } @@ -786,7 +786,8 @@ invalid_bookmark: uint64_t _seloff = seloff; int _lines = lines; uint8_t* _value = value; - lsnes_instance.run([_vmabase, _vmasize, paint_offset, _seloff, _value, _lines, this]() { + lsnes_instance.iqueue.run([_vmabase, _vmasize, paint_offset, _seloff, _value, _lines, + this]() { memory_search* memsearch = wxwindow_memorysearch_active(); //Paint the stuff for(ssize_t j = 0; j < _lines; j++) { diff --git a/src/platform/wxwidgets/editor-memorywatch.cpp b/src/platform/wxwidgets/editor-memorywatch.cpp index 6c27e882..cbb338ba 100644 --- a/src/platform/wxwidgets/editor-memorywatch.cpp +++ b/src/platform/wxwidgets/editor-memorywatch.cpp @@ -299,7 +299,7 @@ wxeditor_memorywatch::wxeditor_memorywatch(wxWindow* parent, const std::string& this); top_s->Add(s12, 0, wxGROW); - memwatch_item it; + memwatch_item it(lsnes_instance.memory); bool had_it = false; try { it = lsnes_instance.mwatch.get(name); @@ -451,7 +451,7 @@ void wxeditor_memorywatch::on_fontsel(wxCommandEvent& e) void wxeditor_memorywatch::on_ok(wxCommandEvent& e) { - memwatch_item it; + memwatch_item it(lsnes_instance.memory); it.expr = tostdstring(expr->GetValue()); it.format = tostdstring(format->GetValue()); it.printer.cond_enable = cond_enable->GetValue(); @@ -505,7 +505,7 @@ void wxeditor_memorywatch::on_ok(wxCommandEvent& e) } bool did_error = false; std::string error; - lsnes_instance.run([this, &it, &did_error, &error]() { + lsnes_instance.iqueue.run([this, &it, &did_error, &error]() { try { lsnes_instance.mwatch.set(name, it); } catch(std::exception& e) { @@ -623,7 +623,7 @@ void wxeditor_memorywatches::on_rename(wxCommandEvent& e) try { bool exists = false; std::string newname = pick_text(this, "Rename watch", "Enter New name for watch:"); - lsnes_instance.run([watch, newname, &exists]() { + lsnes_instance.iqueue.run([watch, newname, &exists]() { exists = !lsnes_instance.mwatch.rename(watch, newname); }); if(exists) @@ -639,7 +639,7 @@ void wxeditor_memorywatches::on_delete(wxCommandEvent& e) { std::string watch = tostdstring(watches->GetStringSelection()); if(watch != "") - lsnes_instance.run([watch]() { lsnes_instance.mwatch.clear(watch); }); + lsnes_instance.iqueue.run([watch]() { lsnes_instance.mwatch.clear(watch); }); refresh(); on_memorywatch_change(e); } @@ -669,7 +669,7 @@ void wxeditor_memorywatches::on_close(wxCommandEvent& e) void wxeditor_memorywatches::refresh() { std::set bind; - lsnes_instance.run([&bind]() { + lsnes_instance.iqueue.run([&bind]() { bind = lsnes_instance.mwatch.enumerate(); }); watches->Clear(); diff --git a/src/platform/wxwidgets/editor-movie.cpp b/src/platform/wxwidgets/editor-movie.cpp index 15345f76..fbb991c8 100644 --- a/src/platform/wxwidgets/editor-movie.cpp +++ b/src/platform/wxwidgets/editor-movie.cpp @@ -1063,7 +1063,7 @@ void wxeditor_movie::_moviepanel::do_toggle_buttons(unsigned idx, uint64_t row1, if(_press_line > line) std::swap(_press_line, line); recursing = true; - lsnes_instance.run([idx, _press_line, line, _fcontrols, _force_false]() { + lsnes_instance.iqueue.run([idx, _press_line, line, _fcontrols, _force_false]() { if(!lsnes_instance.mlogic.get_movie().readonly_mode()) return; uint64_t fedit = real_first_editable(*_fcontrols, idx); @@ -1092,7 +1092,7 @@ void wxeditor_movie::_moviepanel::do_alter_axis(unsigned idx, uint64_t row1, uin uint64_t line2 = row2; short value; bool valid = true; - lsnes_instance.run([idx, line, &value, _fcontrols, &valid]() { + lsnes_instance.iqueue.run([idx, line, &value, _fcontrols, &valid]() { if(!lsnes_instance.mlogic.get_movie().readonly_mode()) { valid = false; return; @@ -1120,7 +1120,7 @@ void wxeditor_movie::_moviepanel::do_alter_axis(unsigned idx, uint64_t row1, uin } if(line > line2) std::swap(line, line2); - lsnes_instance.run([idx, line, line2, value, _fcontrols]() { + lsnes_instance.iqueue.run([idx, line, line2, value, _fcontrols]() { uint64_t fedit = real_first_editable(*_fcontrols, idx); controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; controller_frame_vector::notify_freeze freeze(fv); @@ -1144,7 +1144,7 @@ void wxeditor_movie::_moviepanel::do_sweep_axis(unsigned idx, uint64_t row1, uin bool valid = true; if(line > line2) std::swap(line, line2); - lsnes_instance.run([idx, line, line2, &value, &value2, _fcontrols, &valid]() { + lsnes_instance.iqueue.run([idx, line, line2, &value, &value2, _fcontrols, &valid]() { if(!lsnes_instance.mlogic.get_movie().readonly_mode()) { valid = false; return; @@ -1162,7 +1162,7 @@ void wxeditor_movie::_moviepanel::do_sweep_axis(unsigned idx, uint64_t row1, uin }); if(!valid) return; - lsnes_instance.run([idx, line, line2, value, value2, _fcontrols]() { + lsnes_instance.iqueue.run([idx, line, line2, value, value2, _fcontrols]() { uint64_t fedit = real_first_editable(*_fcontrols, idx); controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; controller_frame_vector::notify_freeze freeze(fv); @@ -1183,7 +1183,7 @@ void wxeditor_movie::_moviepanel::do_append_frames(uint64_t count) { recursing = true; uint64_t _count = count; - lsnes_instance.run([_count]() { + lsnes_instance.iqueue.run([_count]() { if(!lsnes_instance.mlogic.get_movie().readonly_mode()) return; controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; @@ -1228,7 +1228,7 @@ void wxeditor_movie::_moviepanel::do_insert_frame_after(uint64_t row, bool multi recursing = true; frame_controls* _fcontrols = &fcontrols; uint64_t _row = row; - lsnes_instance.run([_row, _fcontrols, multicount]() { + lsnes_instance.iqueue.run([_row, _fcontrols, multicount]() { if(!lsnes_instance.mlogic.get_movie().readonly_mode()) return; controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; @@ -1264,7 +1264,7 @@ void wxeditor_movie::_moviepanel::do_delete_frame(uint64_t row1, uint64_t row2, bool _wholeframe = wholeframe; frame_controls* _fcontrols = &fcontrols; if(_row1 > _row2) std::swap(_row1, _row2); - lsnes_instance.run([_row1, _row2, _wholeframe, _fcontrols]() { + lsnes_instance.iqueue.run([_row1, _row2, _wholeframe, _fcontrols]() { controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; uint64_t vsize = fv.size(); if(_row1 >= vsize) @@ -1333,7 +1333,7 @@ void wxeditor_movie::_moviepanel::do_truncate(uint64_t row) recursing = true; uint64_t _row = row; frame_controls* _fcontrols = &fcontrols; - lsnes_instance.run([_row, _fcontrols]() { + lsnes_instance.iqueue.run([_row, _fcontrols]() { controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; uint64_t vsize = fv.size(); if(_row >= vsize) @@ -1355,7 +1355,7 @@ void wxeditor_movie::_moviepanel::do_set_stop_at_frame() { uint64_t curframe; uint64_t frame; - lsnes_instance.run([&curframe]() { + lsnes_instance.iqueue.run([&curframe]() { curframe = lsnes_instance.mlogic.get_movie().get_current_frame(); }); try { @@ -1372,7 +1372,7 @@ void wxeditor_movie::_moviepanel::do_set_stop_at_frame() wxMessageBox(wxT("The movie is already past that point"), _T("Error"), wxICON_EXCLAMATION | wxOK, m); return; } - lsnes_instance.run([frame]() { + lsnes_instance.iqueue.run([frame]() { set_stop_at_frame(frame); }); } @@ -1438,7 +1438,7 @@ void wxeditor_movie::_moviepanel::popup_axis_panel(uint64_t row, control_info ci frame_controls* _fcontrols = &fcontrols; if(ciX.index == ciY.index) { auto c = prompt_coodinates_window(m, NULL, 256, 0, ciX, ciX, screenX, screenY); - lsnes_instance.run([ciX, row, c, _fcontrols]() { + lsnes_instance.iqueue.run([ciX, row, c, _fcontrols]() { uint64_t fedit = real_first_editable(*_fcontrols, ciX.index); if(row < fedit) return; controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; @@ -1473,7 +1473,7 @@ void wxeditor_movie::_moviepanel::popup_axis_panel(uint64_t row, control_info ci sws_freeContext(ctx); auto c = prompt_coodinates_window(m, &buf[0], (ciX.rmax - ciX.rmin + 1), (ciY.rmax - ciY.rmin + 1), ciX, ciY, screenX, screenY); - lsnes_instance.run([ciX, ciY, row, c, _fcontrols]() { + lsnes_instance.iqueue.run([ciX, ciY, row, c, _fcontrols]() { uint64_t fedit = real_first_editable(*_fcontrols, ciX.index); fedit = max(fedit, real_first_editable(*_fcontrols, ciY.index)); if(row < fedit) return; @@ -1485,7 +1485,7 @@ void wxeditor_movie::_moviepanel::popup_axis_panel(uint64_t row, control_info ci signal_repaint(); } else { auto c = prompt_coodinates_window(m, NULL, 256, 256, ciX, ciY, screenX, screenY); - lsnes_instance.run([ciX, ciY, row, c, _fcontrols]() { + lsnes_instance.iqueue.run([ciX, ciY, row, c, _fcontrols]() { uint64_t fedit = real_first_editable(*_fcontrols, ciX.index); fedit = max(fedit, real_first_editable(*_fcontrols, ciY.index)); if(row < fedit) return; @@ -1653,10 +1653,10 @@ void wxeditor_movie::_moviepanel::on_popup_menu(wxCommandEvent& e) try { std::string newname; std::string oldname; - lsnes_instance.run([&oldname]() { oldname = lsnes_instance.mbranch.get(); }); + lsnes_instance.iqueue.run([&oldname]() { oldname = lsnes_instance.mbranch.get(); }); newname = pick_text(this, "Enter new branch name", "Enter name for a new branch (to fork " "from " + lsnes_instance.mbranch.name(oldname) + "):", "", false); - lsnes_instance.run_async([this, oldname, newname] { + lsnes_instance.iqueue.run_async([this, oldname, newname] { lsnes_instance.mbranch._new(newname, oldname); }, [this](std::exception& e) { show_exception(this, "Error creating branch", "Can't create branch", e); @@ -1677,7 +1677,7 @@ void wxeditor_movie::_moviepanel::on_popup_menu(wxCommandEvent& e) if(mode == MBRANCH_IMPORT_MOVIE) { std::set brlist; try { - lsnes_instance.run([this, filename, &brlist]() { + lsnes_instance.iqueue.run([this, filename, &brlist]() { brlist = lsnes_instance.mbranch._movie_branches(filename); }); } catch(std::exception& e) { @@ -1699,7 +1699,7 @@ void wxeditor_movie::_moviepanel::on_popup_menu(wxCommandEvent& e) } dbranch = pick_text(this, "Enter new branch name", "Enter name for an imported branch:", branch, false); - lsnes_instance.run_async([this, filename, branch, dbranch, mode]() { + lsnes_instance.iqueue.run_async([this, filename, branch, dbranch, mode]() { lsnes_instance.mbranch.import_branch(filename, branch, dbranch, mode); }, [this](std::exception& e) { show_exception(this, "Can't import branch", "", e); @@ -1715,7 +1715,7 @@ void wxeditor_movie::_moviepanel::on_popup_menu(wxCommandEvent& e) exp_imp_type()); file = g.first; mode = g.second; - lsnes_instance.run_async([this, file, mode]() { + lsnes_instance.iqueue.run_async([this, file, mode]() { std::string bname = lsnes_instance.mbranch.get(); lsnes_instance.mbranch.export_branch(file, bname, mode == MBRANCH_IMPORT_BINARY); }, [this](std::exception& e) { @@ -1729,13 +1729,13 @@ void wxeditor_movie::_moviepanel::on_popup_menu(wxCommandEvent& e) std::string newname; std::string oldname; std::set list; - lsnes_instance.run([&list]() { list = lsnes_instance.mbranch.enumerate(); }); + lsnes_instance.iqueue.run([&list]() { list = lsnes_instance.mbranch.enumerate(); }); std::vector choices(list.begin(), list.end()); oldname = pick_among(this, "Select branch to rename", "Select branch to rename", choices, 0); newname = pick_text(this, "Enter new branch name", "Enter name for a new branch (to rename " "'" + lsnes_instance.mbranch.name(oldname) + "'):", oldname, false); - lsnes_instance.run_async([this, oldname, newname] { + lsnes_instance.iqueue.run_async([this, oldname, newname] { lsnes_instance.mbranch.rename(oldname, newname); }, [this](std::exception& e) { show_exception(this, "Error renaming branch", "Can't rename branch", e); @@ -1747,11 +1747,11 @@ void wxeditor_movie::_moviepanel::on_popup_menu(wxCommandEvent& e) try { std::string oldname; std::set list; - lsnes_instance.run([&list]() { list = lsnes_instance.mbranch.enumerate(); }); + lsnes_instance.iqueue.run([&list]() { list = lsnes_instance.mbranch.enumerate(); }); std::vector choices(list.begin(), list.end()); oldname = pick_among(this, "Select branch to delete", "Select branch to delete", choices, 0); - lsnes_instance.run_async([this, oldname] { + lsnes_instance.iqueue.run_async([this, oldname] { lsnes_instance.mbranch._delete(oldname); }, [this](std::exception& e) { show_exception(this, "Error deleting branch", "Can't delete branch", e); @@ -1763,7 +1763,7 @@ void wxeditor_movie::_moviepanel::on_popup_menu(wxCommandEvent& e) if(id >= wxID_MBRANCH_FIRST && id <= wxID_MBRANCH_LAST) { if(!branch_names.count(id)) return; std::string name = branch_names[id]; - lsnes_instance.run_async([this, name]() { + lsnes_instance.iqueue.run_async([this, name]() { lsnes_instance.mbranch.set(name); }, [this](std::exception& e) { show_exception(this, "Error changing branch", "Can't change branch", e); @@ -1965,7 +1965,7 @@ void wxeditor_movie::_moviepanel::on_mouse2(unsigned x, unsigned y, bool polarit std::set list; std::string current; bool ro; - lsnes_instance.run([&list, ¤t, &ro]() { + lsnes_instance.iqueue.run([&list, ¤t, &ro]() { list = lsnes_instance.mbranch.enumerate(); current = lsnes_instance.mbranch.get(); ro = lsnes_instance.mlogic.get_movie().readonly_mode(); @@ -2008,7 +2008,7 @@ void wxeditor_movie::_moviepanel::signal_repaint() uint32_t prev_width, prev_height; bool done_again = false; do_again: - lsnes_instance.run([&lines, &width, &height, m2, this]() { + lsnes_instance.iqueue.run([&lines, &width, &height, m2, this]() { lines = this->get_lines(); if(lines < lines_to_display) this->moviepos = 0; @@ -2098,7 +2098,7 @@ void wxeditor_movie::_moviepanel::do_copy(uint64_t row1, uint64_t row2, unsigned if(line2 < line) std::swap(line, line2); std::string copied; - lsnes_instance.run([port, controller, line, line2, _fcontrols, &copied]() { + lsnes_instance.iqueue.run([port, controller, line, line2, _fcontrols, &copied]() { controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; uint64_t vsize = fv.size(); if(!vsize) @@ -2117,7 +2117,7 @@ void wxeditor_movie::_moviepanel::do_copy(uint64_t row1, uint64_t row2) if(line2 < line) std::swap(line, line2); std::string copied; - lsnes_instance.run([line, line2, &copied]() { + lsnes_instance.iqueue.run([line, line2, &copied]() { controller_frame_vector& fv = *lsnes_instance.mlogic.get_mfile().input; uint64_t vsize = fv.size(); if(!vsize) @@ -2147,7 +2147,7 @@ void wxeditor_movie::_moviepanel::do_paste(uint64_t row, bool append) recursing = true; uint64_t _gapstart = row; std::string cliptext = copy_from_clipboard(); - lsnes_instance.run([_fcontrols, &cliptext, _gapstart, append]() { + lsnes_instance.iqueue.run([_fcontrols, &cliptext, _gapstart, append]() { //Insert enough lines for the pasted content. uint64_t gapstart = _gapstart; if(!lsnes_instance.mlogic.get_movie().readonly_mode()) @@ -2203,7 +2203,7 @@ void wxeditor_movie::_moviepanel::do_paste(uint64_t row, unsigned port, unsigned recursing = true; uint64_t _gapstart = row; std::string cliptext = copy_from_clipboard(); - lsnes_instance.run([_fcontrols, iset, &cliptext, _gapstart, port, controller, append]() { + lsnes_instance.iqueue.run([_fcontrols, iset, &cliptext, _gapstart, port, controller, append]() { //Insert enough lines for the pasted content. uint64_t gapstart = _gapstart; if(!lsnes_instance.mlogic.get_movie().readonly_mode()) @@ -2258,7 +2258,7 @@ void wxeditor_movie::_moviepanel::do_insert_controller(uint64_t row, unsigned po auto iset = controller_index_set(fcontrols, port, controller); recursing = true; uint64_t gapstart = row; - lsnes_instance.run([_fcontrols, iset, gapstart, port, controller]() { + lsnes_instance.iqueue.run([_fcontrols, iset, gapstart, port, controller]() { //Insert enough lines for the pasted content. if(!lsnes_instance.mlogic.get_movie().readonly_mode()) return; @@ -2287,7 +2287,7 @@ void wxeditor_movie::_moviepanel::do_delete_controller(uint64_t row1, uint64_t r if(row1 > row2) std::swap(row1, row2); uint64_t gapstart = row1; uint64_t gaplen = row2 - row1 + 1; - lsnes_instance.run([_fcontrols, iset, gapstart, gaplen, port, controller]() { + lsnes_instance.iqueue.run([_fcontrols, iset, gapstart, gaplen, port, controller]() { //Insert enough lines for the pasted content. if(!lsnes_instance.mlogic.get_movie().readonly_mode()) return; diff --git a/src/platform/wxwidgets/editor-multitrack.cpp b/src/platform/wxwidgets/editor-multitrack.cpp index a3e336bc..faf3eba6 100644 --- a/src/platform/wxwidgets/editor-multitrack.cpp +++ b/src/platform/wxwidgets/editor-multitrack.cpp @@ -95,7 +95,7 @@ wxeditor_multitrack::wxeditor_multitrack(wxWindow* parent) bool wasc = closing; closing = true; multitrack_open = NULL; - lsnes_instance.run([]() { lsnes_instance.mteditor.enable(false); }); + lsnes_instance.iqueue.run([]() { lsnes_instance.mteditor.enable(false); }); if(!wasc) Destroy(); } @@ -136,7 +136,7 @@ void wxeditor_multitrack::on_control(wxCommandEvent& e) return; controller_info& ci = controllers[ctrl]; std::string mode = tostdstring(ci.mode->GetStringSelection()); - lsnes_instance.run([ci, mode]() { + lsnes_instance.iqueue.run([ci, mode]() { if(mode == MTMODE_PRESERVE) lsnes_instance.mteditor.set(ci.port, ci.controller, multitrack_edit::MT_PRESERVE); else if(mode == MTMODE_OVERWRITE) @@ -160,7 +160,7 @@ void wxeditor_multitrack::update_controls() } controllers.clear(); std::vector info; - lsnes_instance.run([this, &info](){ + lsnes_instance.iqueue.run([this, &info](){ std::map next_in_class; controller_frame model = lsnes_instance.controls.get_blank(); const port_type_set& pts = model.porttypes(); @@ -231,7 +231,7 @@ void wxeditor_multitrack::on_wclose(wxCloseEvent& e) bool wasc = closing; closing = true; multitrack_open = NULL; - lsnes_instance.run([]() { lsnes_instance.mteditor.enable(false); }); + lsnes_instance.iqueue.run([]() { lsnes_instance.mteditor.enable(false); }); if(!wasc) Destroy(); } @@ -249,5 +249,5 @@ void wxeditor_multitrack_display(wxWindow* parent) } v->Show(); multitrack_open = v; - lsnes_instance.run([]() { lsnes_instance.mteditor.enable(true); }); + lsnes_instance.iqueue.run([]() { lsnes_instance.mteditor.enable(true); }); } diff --git a/src/platform/wxwidgets/editor-subtitles.cpp b/src/platform/wxwidgets/editor-subtitles.cpp index 2a69bbf0..57be51d7 100644 --- a/src/platform/wxwidgets/editor-subtitles.cpp +++ b/src/platform/wxwidgets/editor-subtitles.cpp @@ -221,7 +221,7 @@ void wxeditor_subtitles::refresh() if(closing) return; std::map, std::string> _subtitles; - lsnes_instance.run([&_subtitles]() -> void { + lsnes_instance.iqueue.run([&_subtitles]() -> void { auto keys = lsnes_instance.subtitles.get_all(); for(auto i : keys) _subtitles[i] = lsnes_instance.subtitles.get(i.first, i.second); diff --git a/src/platform/wxwidgets/editor-tasinput.cpp b/src/platform/wxwidgets/editor-tasinput.cpp index de67e31c..d365ada1 100644 --- a/src/platform/wxwidgets/editor-tasinput.cpp +++ b/src/platform/wxwidgets/editor-tasinput.cpp @@ -380,7 +380,7 @@ void wxeditor_tasinput::on_control(wxCommandEvent& e) xstate = t.panel->get_x(); ystate = t.panel->get_y(); } - lsnes_instance.run_async([t, xstate, ystate]() { + lsnes_instance.iqueue.run_async([t, xstate, ystate]() { lsnes_instance.controls.tasinput(t.port, t.controller, t.xindex, xstate); if(t.yindex != std::numeric_limits::max()) lsnes_instance.controls.tasinput(t.port, t.controller, t.yindex, ystate); @@ -404,7 +404,7 @@ void wxeditor_tasinput::update_controls() std::vector _inputs; std::vector _controller_labels; - lsnes_instance.run([&_inputs, &_controller_labels](){ + lsnes_instance.iqueue.run([&_inputs, &_controller_labels](){ std::map next_in_class; controller_frame model = CORE().controls.get_blank(); const port_type_set& pts = model.porttypes(); @@ -582,7 +582,7 @@ void wxeditor_tasinput::on_keyboard_down(wxKeyEvent& e) } return; } - if(key == WXK_F5) lsnes_instance.queue("+advance-frame"); + if(key == WXK_F5) lsnes_instance.iqueue.queue("+advance-frame"); } void wxeditor_tasinput::on_keyboard_up(wxKeyEvent& e) @@ -696,11 +696,11 @@ void wxeditor_tasinput::on_keyboard_up(wxKeyEvent& e) return; } } - if(key == WXK_F1) lsnes_instance.queue("cycle-jukebox-backward"); - if(key == WXK_F2) lsnes_instance.queue("cycle-jukebox-forward"); - if(key == WXK_F3) lsnes_instance.queue("save-jukebox"); - if(key == WXK_F4) lsnes_instance.queue("load-jukebox"); - if(key == WXK_F5) lsnes_instance.queue("-advance-frame"); + if(key == WXK_F1) lsnes_instance.iqueue.queue("cycle-jukebox-backward"); + if(key == WXK_F2) lsnes_instance.iqueue.queue("cycle-jukebox-forward"); + if(key == WXK_F3) lsnes_instance.iqueue.queue("save-jukebox"); + if(key == WXK_F4) lsnes_instance.iqueue.queue("load-jukebox"); + if(key == WXK_F5) lsnes_instance.iqueue.queue("-advance-frame"); } wxeditor_tasinput::control_triple* wxeditor_tasinput::find_triple(unsigned controller, unsigned control) diff --git a/src/platform/wxwidgets/keyboard.cpp b/src/platform/wxwidgets/keyboard.cpp index 871bd5ee..a37b1aeb 100644 --- a/src/platform/wxwidgets/keyboard.cpp +++ b/src/platform/wxwidgets/keyboard.cpp @@ -269,7 +269,7 @@ namespace void do_keypress(keyboard::modifier_set mods, keyboard::key_key& key, bool polarity) { auto _key = &key; - lsnes_instance.run_async([mods, _key, polarity]() { + lsnes_instance.iqueue.run_async([mods, _key, polarity]() { _key->set_state(mods, polarity ? 1 : 0); }, [](std::exception& e) {}); } diff --git a/src/platform/wxwidgets/mainwindow.cpp b/src/platform/wxwidgets/mainwindow.cpp index a524b0fe..b30e9a3f 100644 --- a/src/platform/wxwidgets/mainwindow.cpp +++ b/src/platform/wxwidgets/mainwindow.cpp @@ -241,7 +241,7 @@ namespace show_message_ok(w, "Error downloading movie", old->errormsg, wxICON_EXCLAMATION); } else { - lsnes_instance.queue("load-movie $MEMORY:wxwidgets_download_tmp"); + lsnes_instance.iqueue.queue("load-movie $MEMORY:wxwidgets_download_tmp"); } delete old; Stop(); @@ -392,7 +392,7 @@ namespace return; try { auto p = prompt_action_params(pwin, act->get_title(), act->params); - lsnes_instance.run([act_id,p]() { our_rom.rtype->execute_action(act_id, p); }); + lsnes_instance.iqueue.run([act_id,p]() { our_rom.rtype->execute_action(act_id, p); }); } catch(canceled_exception& e) { } catch(std::bad_alloc& e) { OOM_panic(); @@ -559,7 +559,7 @@ namespace req.region = file.region; for(unsigned i = 0; i < file.files.size() && i < ROM_SLOT_COUNT; i++) req.files[i] = file.files[i]; - lsnes_instance.run_async([req]() { + lsnes_instance.iqueue.run_async([req]() { lsnes_instance.command.invoke("unpause-emulator"); load_new_rom(req); }, [](std::exception& e) {}); @@ -567,12 +567,12 @@ namespace void recent_movie_selected(const recentfiles::path& file) { - lsnes_instance.queue("load-smart " + file.get_path()); + lsnes_instance.iqueue.queue("load-smart " + file.get_path()); } void recent_script_selected(const recentfiles::path& file) { - lsnes_instance.queue("run-lua " + file.get_path()); + lsnes_instance.iqueue.queue("run-lua " + file.get_path()); } wxString getname() @@ -646,30 +646,32 @@ namespace { auto sfactors = calc_scale_factors(video_scale_factor, arcorrect_enabled, (our_rom.rtype) ? our_rom.rtype->get_PAR() : 1.0); - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_x, e.GetX() / sfactors.first)); - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_y, e.GetY() / sfactors.second)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_x, e.GetX() / + sfactors.first)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_y, e.GetY() / + sfactors.second)); if(e.Entering()) - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_i, 1)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_i, 1)); if(e.Leaving()) - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_i, 0)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_i, 0)); if(e.LeftDown()) - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_l, 1)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_l, 1)); if(e.LeftUp()) - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_l, 0)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_l, 0)); if(e.MiddleDown()) - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_m, 1)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_m, 1)); if(e.MiddleUp()) - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_m, 0)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_m, 0)); if(e.RightDown()) - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_r, 1)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_r, 1)); if(e.RightUp()) - lsnes_instance.queue(keypress_info(keyboard::modifier_set(), mouse_r, 0)); + lsnes_instance.iqueue.queue(keypress_info(keyboard::modifier_set(), mouse_r, 0)); } bool is_readonly_mode() { bool ret; - lsnes_instance.run([&ret]() { + lsnes_instance.iqueue.run([&ret]() { ret = lsnes_instance.mlogic ? lsnes_instance.mlogic.get_movie().readonly_mode() : false; }); return ret; @@ -678,7 +680,7 @@ namespace std::pair UI_controller_index_by_logical(unsigned lid) { std::pair ret; - lsnes_instance.run([&ret, lid]() { ret = CORE().controls.lcid_to_pcid(lid); }); + lsnes_instance.iqueue.run([&ret, lid]() { ret = CORE().controls.lcid_to_pcid(lid); }); return ret; } @@ -754,7 +756,7 @@ namespace if(amov == bmov) return false; if(amov) std::swap(a, b); - lsnes_instance.run_async([a, b]() { + lsnes_instance.iqueue.run_async([a, b]() { lsnes_instance.command.invoke("unpause-emulator"); romload_request req; req.packfile = a; @@ -767,13 +769,13 @@ namespace std::string a = tostdstring(filenames[0]); bool amov = is_lsnes_movie(a); if(amov) { - lsnes_instance.queue("load-smart " + a); + lsnes_instance.iqueue.queue("load-smart " + a); pwin->recent_movies->add(a); ret = true; } else { romload_request req; req.packfile = a; - lsnes_instance.run_async([req]() { + lsnes_instance.iqueue.run_async([req]() { lsnes_instance.command.invoke("unpause-emulator"); load_new_rom(req); }, [](std::exception& e) {}); @@ -1242,7 +1244,7 @@ void wxwin_mainwindow::on_close(wxCloseEvent& e) { //Veto it for now, latter things will delete it. e.Veto(); - lsnes_instance.queue("quit-emulator"); + lsnes_instance.iqueue.queue("quit-emulator"); } void wxwin_mainwindow::notify_update() throw() @@ -1445,7 +1447,7 @@ void wxwin_mainwindow::project_selected(const std::string& id) { std::string filename, displayname; bool load_ok = false; - lsnes_instance.run([id, &filename, &displayname, &load_ok]() -> void { + lsnes_instance.iqueue.run([id, &filename, &displayname, &load_ok]() -> void { try { auto& p = lsnes_instance.project.load(id); //Check. filename = p.filename; @@ -1473,83 +1475,83 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) bool s; switch(e.GetId()) { case wxID_FRAMEADVANCE: - lsnes_instance.queue("+advance-frame"); - lsnes_instance.queue("-advance-frame"); + lsnes_instance.iqueue.queue("+advance-frame"); + lsnes_instance.iqueue.queue("-advance-frame"); return; case wxID_SUBFRAMEADVANCE: - lsnes_instance.queue("+advance-poll"); - lsnes_instance.queue("-advance-poll"); + lsnes_instance.iqueue.queue("+advance-poll"); + lsnes_instance.iqueue.queue("-advance-poll"); return; case wxID_NEXTPOLL: - lsnes_instance.queue("advance-skiplag"); + lsnes_instance.iqueue.queue("advance-skiplag"); return; case wxID_PAUSE: - lsnes_instance.queue("pause-emulator"); + lsnes_instance.iqueue.queue("pause-emulator"); return; case wxID_EXIT: - lsnes_instance.queue("quit-emulator"); + lsnes_instance.iqueue.queue("quit-emulator"); return; case wxID_AUDIO_ENABLED: platform::sound_enable(menu_ischecked(wxID_AUDIO_ENABLED)); return; case wxID_CANCEL_SAVES: - lsnes_instance.queue("cancel-saves"); + lsnes_instance.iqueue.queue("cancel-saves"); return; case wxID_LOAD_MOVIE: filename = choose_file_load(this, "Load Movie", lsnes_instance.project.moviepath(), filetype_movie).second; recent_movies->add(filename); - lsnes_instance.queue("load-movie " + filename); + lsnes_instance.iqueue.queue("load-movie " + filename); return; case wxID_LOAD_STATE: filename2 = choose_file_load(this, "Load State", lsnes_instance.project.moviepath(), filetype_savestate); recent_movies->add(filename2.second); - lsnes_instance.queue("load" + filename2.first + " " + filename2.second); + lsnes_instance.iqueue.queue("load" + filename2.first + " " + filename2.second); return; case wxID_REWIND_MOVIE: - lsnes_instance.queue("rewind-movie"); + lsnes_instance.iqueue.queue("rewind-movie"); return; case wxID_SAVE_MOVIE: filename2 = choose_file_save(this, "Save Movie", lsnes_instance.project.moviepath(), filetype_movie, project_prefixname("lsmv")); recent_movies->add(filename2.second); - lsnes_instance.queue("save-movie" + filename2.first + " " + filename2.second); + lsnes_instance.iqueue.queue("save-movie" + filename2.first + " " + filename2.second); return; case wxID_SAVE_SUBTITLES: - lsnes_instance.queue("save-subtitle " + choose_file_save(this, "Save subtitles", + lsnes_instance.iqueue.queue("save-subtitle " + choose_file_save(this, "Save subtitles", lsnes_instance.project.moviepath(), filetype_sub, project_prefixname("sub"))); return; case wxID_SAVE_STATE: filename2 = choose_file_save(this, "Save State", lsnes_instance.project.moviepath(), filetype_savestate); recent_movies->add(filename2.second); - lsnes_instance.queue("save-state" + filename2.first + " " + filename2.second); + lsnes_instance.iqueue.queue("save-state" + filename2.first + " " + filename2.second); return; case wxID_SAVE_SCREENSHOT: - lsnes_instance.queue("take-screenshot " + choose_file_save(this, "Save Screenshot", + lsnes_instance.iqueue.queue("take-screenshot " + choose_file_save(this, "Save Screenshot", lsnes_instance.project.moviepath(), filetype_png, get_default_screenshot_name())); return; case wxID_RUN_SCRIPT: - lsnes_instance.queue("run-script " + pick_file_member(this, "Select Script", + lsnes_instance.iqueue.queue("run-script " + pick_file_member(this, "Select Script", lsnes_instance.project.otherpath())); return; case wxID_RUN_LUA: { std::string f = choose_file_load(this, "Select Lua Script", lsnes_instance.project.otherpath(), filetype_lua_script); - lsnes_instance.queue("run-lua " + f); + lsnes_instance.iqueue.queue("run-lua " + f); recent_scripts->add(f); return; } case wxID_RESET_LUA: - lsnes_instance.queue("reset-lua"); + lsnes_instance.iqueue.queue("reset-lua"); return; case wxID_EVAL_LUA: - lsnes_instance.queue("evaluate-lua " + pick_text(this, "Evaluate Lua", "Enter Lua Statement:")); + lsnes_instance.iqueue.queue("evaluate-lua " + pick_text(this, "Evaluate Lua", "Enter Lua Statement:")); return; case wxID_READONLY_MODE: s = menu_ischecked(wxID_READONLY_MODE); - lsnes_instance.run([s]() { + lsnes_instance.iqueue.run([s]() { if(!s) lua_callback_movie_lost("readwrite"); if(lsnes_instance.mlogic) lsnes_instance.mlogic.get_movie().readonly_mode(s); @@ -1581,13 +1583,13 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) case wxID_SAVE_MEMORYWATCH: { modal_pause_holder hld; std::set old_watches; - lsnes_instance.run([&old_watches]() { old_watches = lsnes_instance.mwatch.enumerate(); }); + lsnes_instance.iqueue.run([&old_watches]() { old_watches = lsnes_instance.mwatch.enumerate(); }); std::string filename = choose_file_save(this, "Save watches to file", lsnes_instance.project.otherpath(), filetype_watch); std::ofstream out(filename.c_str()); for(auto i : old_watches) { std::string val; - lsnes_instance.run([i, &val]() { + lsnes_instance.iqueue.run([i, &val]() { try { val = lsnes_instance.mwatch.get_string(i); } catch(std::exception& e) { @@ -1603,7 +1605,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) case wxID_LOAD_MEMORYWATCH: { modal_pause_holder hld; std::set old_watches; - lsnes_instance.run([&old_watches]() { old_watches = lsnes_instance.mwatch.enumerate(); }); + lsnes_instance.iqueue.run([&old_watches]() { old_watches = lsnes_instance.mwatch.enumerate(); }); std::map new_watches; std::string filename = choose_file_load(this, "Choose memory watch file", lsnes_instance.project.otherpath(), filetype_watch); @@ -1623,7 +1625,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) return; } - lsnes_instance.run([&new_watches, &old_watches]() { + lsnes_instance.iqueue.run([&new_watches, &old_watches]() { handle_watch_load(new_watches, old_watches); }); return; @@ -1748,7 +1750,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) wxeditor_plugin_manager_display(this); return; case wxID_RELOAD_ROM_IMAGE: - lsnes_instance.run([]() { + lsnes_instance.iqueue.run([]() { lsnes_instance.command.invoke("unpause-emulator"); reload_current_rom(); }); @@ -1775,10 +1777,10 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) open_new_project_window(this); return; case wxID_CLOSE_PROJECT: - lsnes_instance.run([]() -> void { lsnes_instance.project.set(NULL); }); + lsnes_instance.iqueue.run([]() -> void { lsnes_instance.project.set(NULL); }); return; case wxID_CLOSE_ROM: - lsnes_instance.run([]() -> void { close_rom(); }); + lsnes_instance.iqueue.run([]() -> void { close_rom(); }); return; case wxID_ENTER_FULLSCREEN: wx_escape_count = 0; diff --git a/src/platform/wxwidgets/memorysearch.cpp b/src/platform/wxwidgets/memorysearch.cpp index 778c90ba..b989c627 100644 --- a/src/platform/wxwidgets/memorysearch.cpp +++ b/src/platform/wxwidgets/memorysearch.cpp @@ -739,7 +739,7 @@ void wxwindow_memorysearch::panel::prepare_paint() uint64_t addr_count; bool toomany = false; auto _parent = parent; - lsnes_instance.run([&toomany, &first, &last, ms, &lines, &addrs, &addr_count, _parent]() { + lsnes_instance.iqueue.run([&toomany, &first, &last, ms, &lines, &addrs, &addr_count, _parent]() { addr_count = ms->get_candidate_count(); if(last > addr_count) { uint64_t delta = last - addr_count; @@ -817,11 +817,11 @@ bool wxwindow_memorysearch::ShouldPreventAppExit() const void wxwindow_memorysearch::dump_candidates_text() { try { - std::string filename = choose_file_save(this, "Dump memory search", lsnes_instance.project.otherpath(), - filetype_textfile); + std::string filename = choose_file_save(this, "Dump memory search", + lsnes_instance.project.otherpath(), filetype_textfile); std::ofstream out(filename); auto ms = msearch; - lsnes_instance.run([ms, this, &out]() { + lsnes_instance.iqueue.run([ms, this, &out]() { std::list addrs2 = ms->get_candidates(); for(auto i : addrs2) { std::string row = format_address(i) + " "; @@ -1043,7 +1043,7 @@ void wxwindow_memorysearch::on_button_click(wxCommandEvent& e) << "Enter name for watch at 0x" << std::hex << addr << ":").str()); if(n == "") continue; - memwatch_item e; + memwatch_item e(lsnes_instance.memory); e.expr = (stringfmt() << addr).str(); bool is_hex = hexmode2->GetValue(); e.bytes = watch_properties[typecode].len; @@ -1058,7 +1058,7 @@ void wxwindow_memorysearch::on_button_click(wxCommandEvent& e) endianess = j->endian; } e.endianess = endianess; - lsnes_instance.run([n, &e]() { lsnes_instance.mwatch.set(n, e); }); + lsnes_instance.iqueue.run([n, &e]() { lsnes_instance.mwatch.set(n, e); }); } catch(canceled_exception& e) { } } @@ -1076,7 +1076,7 @@ void wxwindow_memorysearch::on_button_click(wxCommandEvent& e) return; uint64_t addr = addresses[r]; auto ms = msearch; - lsnes_instance.run([addr, ms]() { ms->dq_range(addr, addr); }); + lsnes_instance.iqueue.run([addr, ms]() { ms->dq_range(addr, addr); }); } matches->set_selection(0, 0); wxeditor_hexeditor_update(); diff --git a/src/platform/wxwidgets/messages.cpp b/src/platform/wxwidgets/messages.cpp index ac205a3d..ff91610a 100644 --- a/src/platform/wxwidgets/messages.cpp +++ b/src/platform/wxwidgets/messages.cpp @@ -287,7 +287,7 @@ void wxwin_messages::on_execute(wxCommandEvent& e) //Delete old commands to prevent box becoming unmageable. if(command->GetCount() > COMMAND_HISTORY_SIZE) command->Delete(command->GetCount() - 1); - lsnes_instance.queue(cmd); + lsnes_instance.iqueue.queue(cmd); } void wxwin_messages::notify_update() throw() diff --git a/src/platform/wxwidgets/requestrom.cpp b/src/platform/wxwidgets/requestrom.cpp index 80d69d7f..79013a29 100644 --- a/src/platform/wxwidgets/requestrom.cpp +++ b/src/platform/wxwidgets/requestrom.cpp @@ -146,7 +146,7 @@ namespace mr.singlefile = req.singlefile = filename; } parent->recent_roms->add(mr); - lsnes_instance.run_async([req]() { + lsnes_instance.iqueue.run_async([req]() { lsnes_instance.command.invoke("unpause-emulator"); load_new_rom(req); }, [](std::exception& e) {}); @@ -388,7 +388,7 @@ namespace req.files[i] = files[i]; } parent->recent_roms->add(mr); - lsnes_instance.run([req]() { + lsnes_instance.iqueue.run([req]() { lsnes_instance.command.invoke("unpause-emulator"); load_new_rom(req); }); diff --git a/src/platform/wxwidgets/romselect.cpp b/src/platform/wxwidgets/romselect.cpp index 0835bc64..fb42a069 100644 --- a/src/platform/wxwidgets/romselect.cpp +++ b/src/platform/wxwidgets/romselect.cpp @@ -631,7 +631,7 @@ void wxwin_project::on_load(wxCommandEvent& e) mov.start_paused = false; rrdata_set tmp_rdata; mov.save("$MEMORY:wxwidgets-romload-tmp", 0, true, tmp_rdata); - lsnes_instance.queue("load-state $MEMORY:wxwidgets-romload-tmp"); + lsnes_instance.iqueue.queue("load-state $MEMORY:wxwidgets-romload-tmp"); EndModal(0); } catch(std::exception& e) { show_message_ok(this, "Error loading movie", e.what(), wxICON_EXCLAMATION); diff --git a/src/platform/wxwidgets/settings-advanced.cpp b/src/platform/wxwidgets/settings-advanced.cpp index 45371f96..d1d58674 100644 --- a/src/platform/wxwidgets/settings-advanced.cpp +++ b/src/platform/wxwidgets/settings-advanced.cpp @@ -284,7 +284,7 @@ namespace } catch(...) { return; } - lsnes_instance.run([this, name, value]() { + lsnes_instance.iqueue.run([this, name, value]() { run_show_error(this, "Error setting value", "", [name, value]() { lsnes_instance.setcache.set(name, value); }); diff --git a/src/platform/wxwidgets/tracelogger.cpp b/src/platform/wxwidgets/tracelogger.cpp index 3be4d9df..523a24c8 100644 --- a/src/platform/wxwidgets/tracelogger.cpp +++ b/src/platform/wxwidgets/tracelogger.cpp @@ -158,7 +158,7 @@ namespace { std::map> regions; std::set disasms; - lsnes_instance.run([®ions, &disasms]() { + lsnes_instance.iqueue.run([®ions, &disasms]() { for(auto i : lsnes_instance.memory.get_regions()) regions[i->name] = std::make_pair(i->base, i->size); disasms = disassembler::list(); @@ -320,7 +320,7 @@ namespace std::string _vma = tostdstring(vma->GetStringSelection()); if(_endian <= 0 || _endian > 3) { _endian = 1; - lsnes_instance.run([&_endian, _vma]() { + lsnes_instance.iqueue.run([&_endian, _vma]() { for(auto i : lsnes_instance.memory.get_regions()) { if(i->name == _vma) { _endian = i->endian + 2; @@ -350,7 +350,7 @@ namespace uint64_t base = 0; if(vma->GetSelection() && vma->GetSelection() != wxNOT_FOUND) { std::string _vma = tostdstring(vma->GetStringSelection()); - lsnes_instance.run([&base, _vma]() { + lsnes_instance.iqueue.run([&base, _vma]() { for(auto i : lsnes_instance.memory.get_regions()) { if(i->name == _vma) { base = i->base; @@ -578,7 +578,7 @@ namespace return; } if(trace_active) - lsnes_instance.run([this]() { kill_debug_hooks(); }); + lsnes_instance.iqueue.run([this]() { kill_debug_hooks(); }); trace_active = false; if(!closing) Destroy(); @@ -786,7 +786,7 @@ namespace void wxwin_tracelog::on_enabled(wxCommandEvent& e) { bool enable = enabled->GetValue(); - lsnes_instance.run([this, enable]() { + lsnes_instance.iqueue.run([this, enable]() { if(enable) { threads::alock h(buffer_mutex); broken = broken2; @@ -867,7 +867,7 @@ namespace return; } if(trace_active) { - lsnes_instance.run([this]() { this->kill_debug_hooks(); }); + lsnes_instance.iqueue.run([this]() { this->kill_debug_hooks(); }); } trace_active = false; Destroy(); @@ -942,17 +942,17 @@ namespace } scroll_pane(find_line); } else if(e.GetId() == wxID_SINGLESTEP) { - lsnes_instance.run_async([this]() { + lsnes_instance.iqueue.run_async([this]() { this->singlestepping = true; lsnes_instance.command.invoke("unpause-emulator"); }, [](std::exception& e) {}); } else if(e.GetId() == wxID_FRAMEADVANCE) { - lsnes_instance.run_async([this]() { + lsnes_instance.iqueue.run_async([this]() { lsnes_instance.command.invoke("+advance-frame"); lsnes_instance.command.invoke("-advance-frame"); }, [](std::exception& e) {}); } else if(e.GetId() == wxID_CONTINUE) { - lsnes_instance.run_async([this]() { + lsnes_instance.iqueue.run_async([this]() { lsnes_instance.command.invoke("unpause-emulator"); }, [](std::exception& e) {}); } else if(e.GetId() == wxID_BREAKPOINTS) { @@ -1058,7 +1058,7 @@ back: std::set> wxwin_tracelog::get_breakpoints() { std::set> ret; - lsnes_instance.run([this, &ret]() { + lsnes_instance.iqueue.run([this, &ret]() { for(auto i : rwx_breakpoints) ret.insert(i.first); }); @@ -1319,13 +1319,13 @@ back: uint64_t addr = d->get_address(); uint64_t count = d->get_count(); d->Destroy(); - lsnes_instance.run_async([this, disasm, addr, count]() { + lsnes_instance.iqueue.run_async([this, disasm, addr, count]() { this->run_disassembler(disasm, addr, count); }, [](std::exception& e) {}); } else if(e.GetId() == wxID_GOTO) { try { std::string to = pick_text(this, "Goto", "Enter address to go to:", ""); - lsnes_instance.run_async([this, to]() { + lsnes_instance.iqueue.run_async([this, to]() { uint64_t addr; uint64_t base = 0; std::string vma; @@ -1423,7 +1423,7 @@ back: uint64_t count = d->get_count(); d->Destroy(); auto pp = p; - lsnes_instance.run_async([pp, disasm, addr, count]() { + lsnes_instance.iqueue.run_async([pp, disasm, addr, count]() { pp->run_disassembler(disasm, addr, count); }, [](std::exception& e) {}); //Delete entries in (rbase, addr) if addr = base. @@ -1806,7 +1806,7 @@ back: } rpair(addr, dtype) = d->get_result(); d->Destroy(); - lsnes_instance.run_async([this, addr, dtype]() { + lsnes_instance.iqueue.run_async([this, addr, dtype]() { pwin->add_breakpoint(addr, dtype); }, [](std::exception& e) {}); auto ent = std::make_pair(addr, dtype); @@ -1825,7 +1825,7 @@ back: debug_context::etype dtype; addr = listsyms[idx].first; dtype = listsyms[idx].second; - lsnes_instance.run_async([this, addr, dtype]() { + lsnes_instance.iqueue.run_async([this, addr, dtype]() { pwin->remove_breakpoint(addr, dtype); }, [](std::exception& e) {}); brklist->Delete(idx); -- 2.11.4.GIT