diff --git a/Makefile b/Makefile index ce85c3e9..3abb8edb 100644 --- a/Makefile +++ b/Makefile @@ -10,11 +10,16 @@ REALCC = $(CROSS_PREFIX)$(CC) REALLD = $(CROSS_PREFIX)$(LD) REALRANLIB = $(CROSS_PREFIX)$(RANLIB) -ifeq ($(CORE_TYPE), BSNES) -CORE_PATH=$(shell pwd)/bsnes -CORE_SUBDIR=bsnes -CORE_OBJECT=bsnes/out/libsnes.$(ARCHIVE_SUFFIX) -CORE_DEFINE=-DCORETYPE_BSNES=1 +CORE_DEFINE= +CORE_OBJECT= +CORE_OBJECTS= +CORE_PATH= + +ifdef BSNES_VERSION +CORE_PATH+=-I$(shell pwd)/bsnes +CORE_OBJECT+=../bsnes/out/libsnes.$(ARCHIVE_SUFFIX) +CORE_OBJECTS+=bsnes/out/libsnes.$(ARCHIVE_SUFFIX) +CORE_DEFINE+=-DCORETYPE_BSNES=1 ifdef BSNES_IS_COMPAT CFLAGS += -DBSNES_IS_COMPAT BSNES_PROFILE_STRING=profile=compatibility @@ -30,29 +35,25 @@ BSNES_PROFILE_STRING+=options=debugger CFLAGS += -DBSNES_HAS_DEBUGGER endif endif - ifeq ($(BSNES_VERSION), 087) BSNES_TARGET_STRING=target=libsnes else BSNES_TARGET_STRING=ui=ui-libsnes endif CFLAGS += -DBSNES_V${BSNES_VERSION} -else -ifeq ($(CORE_TYPE), GAMBATTE) -CORE_PATH=$(shell pwd)/gambatte -CORE_SUBDIR=gambatte -CORE_OBJECT=gambatte/libgambatte/libgambatte.$(ARCHIVE_SUFFIX) -CORE_DEFINE=-DCORETYPE_GAMBATTE=1 -BSNES_PROFILE_STRING= -BSNES_TARGET_STRING= -else -$(error "Bad value for CORETYPE (expected BSNES or GAMBATTE)") +BUILD_BSNES=1 endif + +ifdef BUILD_GAMBATTE +CORE_PATH+=-I$(shell pwd)/gambatte +CORE_OBJECT+=../gambatte/libgambatte/libgambatte.$(ARCHIVE_SUFFIX) +CORE_OBJECTS+=gambatte/libgambatte/libgambatte.$(ARCHIVE_SUFFIX) +CORE_DEFINE+=-DCORETYPE_GAMBATTE=1 endif #Flags. HOSTCCFLAGS = -std=gnu++0x -CFLAGS += -I$(CORE_PATH) $(CORE_DEFINE) -std=gnu++0x $(USER_CFLAGS) +CFLAGS += $(CORE_PATH) $(CORE_DEFINE) -std=gnu++0x $(USER_CFLAGS) ifdef BOOST_NEEDS_MT BOOST_LIB_POSTFIX=-mt else @@ -83,11 +84,19 @@ LDFLAGS += $(shell $(CROSS_PREFIX)pkg-config $(LUA) --libs) compiler=$(subst ++,cc,$(REALCC)) gambatte_compiler=$(REALCC) -$(CORE_OBJECT): forcelook - $(MAKE) -C $(CORE_SUBDIR) $(BSNES_PROFILE_STRING) $(BSNES_TARGET_STRING) - $(REALRANLIB) $@ +ifdef BUILD_BSNES +bsnes/out/libsnes.$(ARCHIVE_SUFFIX): forcelook + $(MAKE) -C bsnes $(BSNES_PROFILE_STRING) $(BSNES_TARGET_STRING) + $(REALRANLIB) bsnes/out/libsnes.$(ARCHIVE_SUFFIX) +endif -src/__all_files__: src/core/version.cpp forcelook $(CORE_OBJECT) +ifdef BUILD_GAMBATTE +gambatte/libgambatte/libgambatte.$(ARCHIVE_SUFFIX): forcelook + $(MAKE) -C gambatte + $(REALRANLIB) gambatte/libgambatte/libgambatte.$(ARCHIVE_SUFFIX) +endif + +src/__all_files__: src/core/version.cpp forcelook $(CORE_OBJECTS) $(MAKE) -C src precheck $(MAKE) -C src cp src/lsnes$(DOT_EXECUTABLE_SUFFIX) . diff --git a/include/core/dispatch.hpp b/include/core/dispatch.hpp index 4e9031b9..5aaa009d 100644 --- a/include/core/dispatch.hpp +++ b/include/core/dispatch.hpp @@ -361,6 +361,16 @@ public: * Call on_dumper_update on on all objects. */ static void do_dumper_update() throw(); +/** + * Notify that core changed. + * + * Default implementation does nothing. + */ + virtual void on_core_change(); +/** + * Call on_dumper_update on on all objects. + */ + static void do_core_change() throw(); protected: /** * Call to indicate this target is interested in sound sample data. diff --git a/include/core/emucore.hpp b/include/core/emucore.hpp deleted file mode 100644 index 27bf9f30..00000000 --- a/include/core/emucore.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _emucore__hpp__included__ -#define _emucore__hpp__included__ - -#include -#include -#include -#include -#include -#include -#include "library/framebuffer.hpp" -#include "library/controller-data.hpp" -#include "interface/romtype.hpp" -#include "interface/callbacks.hpp" - -//Valid port types. - -//Emulator core. -extern core_core* emulator_core; - -#endif diff --git a/include/interface/romtype.hpp b/include/interface/romtype.hpp index 64823a5d..d5292c3d 100644 --- a/include/interface/romtype.hpp +++ b/include/interface/romtype.hpp @@ -138,6 +138,7 @@ struct core_romimage struct core_core { core_core(core_core_params& params); + ~core_core() throw(); bool set_region(core_region& region); std::pair get_video_rate(); std::pair get_audio_rate(); @@ -159,6 +160,9 @@ struct core_core void set_pflag(unsigned pflag); void request_reset(long delay); port_type** get_port_types() { return port_types; } + static std::set all_cores(); + static void install_all_handlers(); + static void uninstall_all_handlers(); private: std::string (*_core_identifier)(); bool (*_set_region)(core_region& region); diff --git a/include/lsnes.hpp b/include/lsnes.hpp index 38200d22..ad300251 100644 --- a/include/lsnes.hpp +++ b/include/lsnes.hpp @@ -13,7 +13,6 @@ #define PROFILE_ACCURACY #endif -extern std::string bsnes_core_version; extern std::string lsnes_version; extern std::string lsnes_git_revision; diff --git a/include/platform/wxwidgets/platform.hpp b/include/platform/wxwidgets/platform.hpp index 866881e4..253b56a7 100644 --- a/include/platform/wxwidgets/platform.hpp +++ b/include/platform/wxwidgets/platform.hpp @@ -33,6 +33,7 @@ void signal_program_exit(); void signal_resize_needed(); void _runuifun_async(void (*fn)(void*), void* arg); void show_projectwindow(wxWindow* modwin); +void signal_core_change(); //Editor dialogs. void wxeditor_authors_display(wxWindow* parent); diff --git a/include/platform/wxwidgets/window_mainwindow.hpp b/include/platform/wxwidgets/window_mainwindow.hpp index e3ccfda9..8ddb1030 100644 --- a/include/platform/wxwidgets/window_mainwindow.hpp +++ b/include/platform/wxwidgets/window_mainwindow.hpp @@ -29,6 +29,7 @@ public: void notify_update_status() throw(); void notify_resized() throw(); void notify_exit() throw(); + void refresh_title() throw(); void on_close(wxCloseEvent& e); void menu_start(wxString name); void menu_special(wxString name, wxMenu* menu); diff --git a/options.build b/options.build index 95230969..dae16300 100644 --- a/options.build +++ b/options.build @@ -99,13 +99,10 @@ JOYSTICK=DUMMY # This is used for high-quality samplerate conversion for dumping. SECRET_RABBIT_CODE= -# Core to use. -# Currently supported: -# - BNSES: BSNES -# - GAMBATTE: GAMBATTE -CORE_TYPE=BSNES +# Set to non-empty value (e.g. 'yes') to build the gambatte core. +BUILD_GAMBATTE= -# Bsnes version used. +# Bsnes version used. Non-empty value also causes bsnes core to be built. # 087 has different layout from the rest. BSNES_VERSION=085 diff --git a/src/Makefile b/src/Makefile index 64af04b5..354ef14a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -63,10 +63,10 @@ video/$(ALLOBJECT): forcelook .PRECIOUS: %.$(OBJECT_SUFFIX) util/%.$(OBJECT_SUFFIX) %.util$(DOT_EXECUTABLE_SUFFIX): %.$(OBJECT_SUFFIX) $(DUMMY_LIBRARY_OBJS) - $(REALCC) -o $@ $^ $(LDFLAGS) ../$(CORE_OBJECT) `cat $(DUMMY_LIBRARY_FLAGS)` + $(REALCC) -o $@ $^ $(LDFLAGS) $(CORE_OBJECT) `cat $(DUMMY_LIBRARY_FLAGS)` lsnes$(DOT_EXECUTABLE_SUFFIX): $(PLATFORM_LIBRARY_OBJS) - $(REALCC) -o $@ $^ $(LDFLAGS) ../$(CORE_OBJECT) `cat $(PLATFORM_LIBRARY_FLAGS)` + $(REALCC) -o $@ $^ $(LDFLAGS) $(CORE_OBJECT) `cat $(PLATFORM_LIBRARY_FLAGS)` precheck: $(MAKE) -C core precheck diff --git a/src/core/bsnes-legacy.cpp b/src/core/bsnes-legacy.cpp index c903509a..75063901 100644 --- a/src/core/bsnes-legacy.cpp +++ b/src/core/bsnes-legacy.cpp @@ -8,14 +8,15 @@ #include #include "core/audioapi.hpp" #include "core/misc.hpp" -#include "core/emucore.hpp" #include "core/command.hpp" #include "core/controllerframe.hpp" #include "core/dispatch.hpp" #include "core/framebuffer.hpp" #include "core/settings.hpp" #include "core/window.hpp" +#include "interface/romtype.hpp" #include "interface/setting.hpp" +#include "interface/callbacks.hpp" #include "library/pixfmt-lrgb.hpp" #include "library/string.hpp" #include "library/portfn.hpp" @@ -1476,7 +1477,4 @@ again2: #endif } -core_core* emulator_core = &bsnes_core; - - #endif diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 8ac916a0..7d1efc64 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -1,5 +1,4 @@ #include "lsnes.hpp" -#include "core/emucore.hpp" #include "core/command.hpp" #include "core/controller.hpp" @@ -8,6 +7,7 @@ #include "core/mainloop.hpp" #include "core/misc.hpp" #include "core/window.hpp" +#include "interface/romtype.hpp" #include "library/string.hpp" #include @@ -148,10 +148,15 @@ namespace static int done = 0; if(done) return; - auto ptypes = emulator_core->get_port_types(); + std::vector ptypes; + for(auto i : core_core::all_cores()) { + auto _ptypes = i->get_port_types(); + for(unsigned j = 0; _ptypes[j]; j++) + ptypes.push_back(_ptypes[j]); + } for(unsigned i = 0;; i++) { bool any = false; - for(unsigned j = 0; ptypes[j]; j++) { + for(unsigned j = 0; j < ptypes.size(); j++) { if(!ptypes[j]->legal(i)) continue; any = true; diff --git a/src/core/controllerframe.cpp b/src/core/controllerframe.cpp index a87f8730..fc3514d3 100644 --- a/src/core/controllerframe.cpp +++ b/src/core/controllerframe.cpp @@ -1,8 +1,7 @@ -#include "core/emucore.hpp" - #include "core/controllerframe.hpp" #include "core/dispatch.hpp" #include "core/misc.hpp" +#include "interface/romtype.hpp" #include #include diff --git a/src/core/dispatch.cpp b/src/core/dispatch.cpp index 6a111480..6a7cf3ed 100644 --- a/src/core/dispatch.cpp +++ b/src/core/dispatch.cpp @@ -465,3 +465,19 @@ void information_dispatch::do_dumper_update() throw() END_EH_BLOCK(i, "on_dumper_update"); } } + +void information_dispatch::on_core_change() +{ + //Do nothing. +} + +void information_dispatch::do_core_change() throw() +{ + if(in_global_ctors()) + return; + for(auto& i : dispatch()) { + START_EH_BLOCK + i->on_core_change(); + END_EH_BLOCK(i, "on_core_change"); + } +} diff --git a/src/core/gambatte.cpp b/src/core/gambatte.cpp index dd56e38e..8a978381 100644 --- a/src/core/gambatte.cpp +++ b/src/core/gambatte.cpp @@ -7,12 +7,12 @@ #include #include "core/audioapi.hpp" #include "core/misc.hpp" -#include "core/emucore.hpp" #include "core/command.hpp" #include "core/controllerframe.hpp" #include "core/dispatch.hpp" #include "core/framebuffer.hpp" #include "core/window.hpp" +#include "interface/callbacks.hpp" #include "interface/romtype.hpp" #include "library/pixfmt-rgb32.hpp" #include "library/string.hpp" @@ -547,6 +547,4 @@ namespace }); } -core_core* emulator_core = &gambatte_core; - #endif diff --git a/src/core/mainloop.cpp b/src/core/mainloop.cpp index 9f8b7b0e..3af9cfed 100644 --- a/src/core/mainloop.cpp +++ b/src/core/mainloop.cpp @@ -1,5 +1,4 @@ #include "lsnes.hpp" -#include "core/emucore.hpp" #include "core/command.hpp" #include "core/controller.hpp" @@ -19,6 +18,8 @@ #include "core/rrdata.hpp" #include "core/settings.hpp" #include "core/window.hpp" +#include "interface/callbacks.hpp" +#include "interface/romtype.hpp" #include "library/framebuffer.hpp" #include "library/pixfmt-lrgb.hpp" @@ -221,6 +222,8 @@ namespace messages << "Can't reload ROM: " << e.what() << std::endl; return false; } + messages << "Using core: " << our_rom->rtype->get_core_identifier() << std::endl; + information_dispatch::do_core_change(); return true; } } @@ -878,7 +881,7 @@ void main_loop(struct loaded_rom& rom, struct moviefile& initial, bool load_has_ lsnes_callbacks lsnes_callbacks_obj; ecore_callbacks = &lsnes_callbacks_obj; movb.get_movie().set_pflag_handler(&lsnes_pflag_handler); - emulator_core->install_handler(); + core_core::install_all_handlers(); //Load our given movie. bool first_round = false; @@ -961,6 +964,6 @@ void main_loop(struct loaded_rom& rom, struct moviefile& initial, bool load_has_ lua_callback_do_frame(); } information_dispatch::do_dump_end(); - emulator_core->uninstall_handler(); + core_core::uninstall_all_handlers(); voicethread_kill(); } diff --git a/src/core/memorymanip.cpp b/src/core/memorymanip.cpp index 9003a8a7..c53a4318 100644 --- a/src/core/memorymanip.cpp +++ b/src/core/memorymanip.cpp @@ -1,4 +1,3 @@ -#include "core/emucore.hpp" #include "core/command.hpp" #include "core/memorymanip.hpp" @@ -6,6 +5,7 @@ #include "core/misc.hpp" #include "core/rom.hpp" #include "core/rrdata.hpp" +#include "interface/romtype.hpp" #include "library/string.hpp" #include "library/minmax.hpp" #include "library/memorysearch.hpp" diff --git a/src/core/misc.cpp b/src/core/misc.cpp index f6917da1..9d7a1f24 100644 --- a/src/core/misc.cpp +++ b/src/core/misc.cpp @@ -255,5 +255,3 @@ void reached_main() lsnes_cmd.set_oom_panic(OOM_panic); lsnes_cmd.set_output(platform::out()); } - -std::string bsnes_core_version; diff --git a/src/core/movie.cpp b/src/core/movie.cpp index 6913d0cb..dc52a4c0 100644 --- a/src/core/movie.cpp +++ b/src/core/movie.cpp @@ -1,9 +1,9 @@ #include "lsnes.hpp" -#include "core/emucore.hpp" #include "core/misc.hpp" #include "core/movie.hpp" #include "core/rom.hpp" +#include "interface/romtype.hpp" #include #include diff --git a/src/core/moviedata.cpp b/src/core/moviedata.cpp index 763a52c7..857cdb7d 100644 --- a/src/core/moviedata.cpp +++ b/src/core/moviedata.cpp @@ -1,5 +1,4 @@ #include "lsnes.hpp" -#include "core/emucore.hpp" #include "core/command.hpp" #include "core/controller.hpp" @@ -12,6 +11,7 @@ #include "core/rrdata.hpp" #include "core/settings.hpp" #include "library/string.hpp" +#include "interface/romtype.hpp" #include #include @@ -299,16 +299,16 @@ void do_load_state(struct moviefile& _movie, int lmode) if(our_rom->orig_region && !our_rom->orig_region->compatible_with(_movie.gametype->get_region())) throw std::runtime_error("NTSC/PAL select of movie and loaded ROM don't match"); - if(our_rom->rtype && _movie.coreversion != bsnes_core_version) { + if(our_rom->rtype && _movie.coreversion != our_rom->rtype->get_core_identifier()) { if(will_load_state) { std::ostringstream x; x << "ERROR: Emulator core version mismatch!" << std::endl - << "\tThis version: " << bsnes_core_version << std::endl + << "\tThis version: " << our_rom->rtype->get_core_identifier() << std::endl << "\tFile is from: " << _movie.coreversion << std::endl; throw std::runtime_error(x.str()); } else messages << "WARNING: Emulator core version mismatch!" << std::endl - << "\tThis version: " << bsnes_core_version << std::endl + << "\tThis version: " << our_rom->rtype->get_core_identifier() << std::endl << "\tFile is from: " << _movie.coreversion << std::endl; } bool rom_ok = true; diff --git a/src/core/moviefile.cpp b/src/core/moviefile.cpp index f28b5961..e426c417 100644 --- a/src/core/moviefile.cpp +++ b/src/core/moviefile.cpp @@ -1,10 +1,10 @@ -#include "core/emucore.hpp" #include "core/misc.hpp" #include "core/moviedata.hpp" #include "core/moviefile.hpp" #include "core/rrdata.hpp" #include "library/zip.hpp" #include "library/string.hpp" +#include "interface/romtype.hpp" #include #include diff --git a/src/core/rom.cpp b/src/core/rom.cpp index cc356833..9ff77de3 100644 --- a/src/core/rom.cpp +++ b/src/core/rom.cpp @@ -1,5 +1,4 @@ #include "lsnes.hpp" -#include "core/emucore.hpp" #include "core/command.hpp" #include "core/dispatch.hpp" @@ -10,6 +9,7 @@ #include "core/rom.hpp" #include "core/settings.hpp" #include "core/window.hpp" +#include "interface/romtype.hpp" #include "library/portfn.hpp" #include "library/patch.hpp" #include "library/sha256.hpp" diff --git a/src/interface/romtype.cpp b/src/interface/romtype.cpp index f0ed4d39..e8bd6592 100644 --- a/src/interface/romtype.cpp +++ b/src/interface/romtype.cpp @@ -12,6 +12,14 @@ namespace { + bool install_handlers_automatically; + + std::set& all_cores_set() + { + static std::set x; + return x; + } + std::map& sysregions() { static std::map x; @@ -326,6 +334,14 @@ core_core::core_core(core_core_params& params) _set_pflag = params.set_pflag; _request_reset = params.request_reset; port_types = params.port_types; + all_cores_set().insert(this); + if(install_handlers_automatically) + install_handler(); +} + +core_core::~core_core() throw() +{ + all_cores().erase(this); } bool core_core::set_region(core_region& region) @@ -356,6 +372,25 @@ std::string core_core::get_core_identifier() return _core_identifier(); } +std::set core_core::all_cores() +{ + return all_cores_set(); +} + +void core_core::install_all_handlers() +{ + install_handlers_automatically = true; + for(auto i : all_cores_set()) + i->install_handler(); +} + +void core_core::uninstall_all_handlers() +{ + install_handlers_automatically = false; + for(auto i : all_cores_set()) + i->uninstall_handler(); +} + std::map> core_core::save_sram() throw(std::bad_alloc) { return _save_sram(); diff --git a/src/lua/core.cpp b/src/lua/core.cpp index a1e65fa4..3b2327b1 100644 --- a/src/lua/core.cpp +++ b/src/lua/core.cpp @@ -1,10 +1,10 @@ #include "core/command.hpp" -#include "core/emucore.hpp" #include "lua/internal.hpp" #include "core/framerate.hpp" #include "core/moviefile.hpp" #include "core/moviedata.hpp" #include "core/window.hpp" +#include "interface/romtype.hpp" namespace { diff --git a/src/lua/input.cpp b/src/lua/input.cpp index 3b70ec4a..7fe1867d 100644 --- a/src/lua/input.cpp +++ b/src/lua/input.cpp @@ -1,9 +1,9 @@ #include "core/keymapper.hpp" #include "lua/internal.hpp" #include "core/movie.hpp" -#include "core/emucore.hpp" #include "core/moviedata.hpp" #include "core/controller.hpp" +#include "interface/romtype.hpp" #include namespace diff --git a/src/platform/wxwidgets/editor-memorywatch.cpp b/src/platform/wxwidgets/editor-memorywatch.cpp index 33268c8d..e664fd01 100644 --- a/src/platform/wxwidgets/editor-memorywatch.cpp +++ b/src/platform/wxwidgets/editor-memorywatch.cpp @@ -10,7 +10,7 @@ #include #include "library/string.hpp" -#include "core/emucore.hpp" +#include "interface/romtype.hpp" class wxeditor_watchexpr : public wxDialog { diff --git a/src/platform/wxwidgets/editor-subtitles.cpp b/src/platform/wxwidgets/editor-subtitles.cpp index 37e0b6f0..2cb498c2 100644 --- a/src/platform/wxwidgets/editor-subtitles.cpp +++ b/src/platform/wxwidgets/editor-subtitles.cpp @@ -10,7 +10,6 @@ #include #include "library/string.hpp" -#include "core/emucore.hpp" class wxeditor_subtitles : public wxDialog { diff --git a/src/platform/wxwidgets/main.cpp b/src/platform/wxwidgets/main.cpp index d7e43a91..a9c2f4b4 100644 --- a/src/platform/wxwidgets/main.cpp +++ b/src/platform/wxwidgets/main.cpp @@ -2,7 +2,6 @@ #include #include "lsnes.hpp" -#include "core/emucore.hpp" #include "core/command.hpp" #include "core/controller.hpp" @@ -16,6 +15,7 @@ #include "core/rrdata.hpp" #include "core/settings.hpp" #include "core/window.hpp" +#include "interface/romtype.hpp" #include "library/string.hpp" #include "library/zip.hpp" @@ -34,6 +34,7 @@ #include #include +#define UISERV_REFRESH_TITLE 9990 #define UISERV_RESIZED 9991 #define UISERV_UIFUN 9992 //#define UISERV_UI_IRQ 9993 Not in use anymore, can be recycled. @@ -101,6 +102,9 @@ namespace wxMessageBox(_T("Panic: Unrecoverable error, can't continue"), _T("Error"), wxICON_ERROR | wxOK); panic_ack = true; + } else if(c == UISERV_REFRESH_TITLE) { + if(main_window) + main_window->refresh_title(); } else if(c == UISERV_RESIZED) { if(main_window) main_window->notify_resized(); @@ -435,11 +439,9 @@ bool lsnes_app::OnInit() ui_mutex = &mutex::aquire(); ui_condition = &condition::aquire(*ui_mutex); - bsnes_core_version = emulator_core->get_core_identifier(); ui_thread = &thread_id::me(); platform::init(); - messages << "BSNES version: " << bsnes_core_version << std::endl; messages << "lsnes version: lsnes rr" << lsnes_version << std::endl; loaded_rom dummy_rom; @@ -505,9 +507,9 @@ bool lsnes_app::OnInit() auto ctrldata = rom->rtype->controllerconfig(mov->settings); port_type_set& ports = port_type_set::make(ctrldata.ports, ctrldata.portindex); mov->input.clear(ports); + mov->coreversion = rom->rtype->get_core_identifier(); if(c_rom != "") { //Initialize the remainder. - mov->coreversion = bsnes_core_version; mov->projectid = get_random_hexstring(40); mov->rerecords = "0"; for(size_t i = 0; i < sizeof(rom->romimg)/sizeof(rom->romimg[0]); i++) { @@ -517,6 +519,7 @@ bool lsnes_app::OnInit() } mov->gametype = &rom->rtype->combine_region(*rom->region); } + our_rom = rom; mov->start_paused = true; boot_emulator(*rom, *mov); @@ -559,6 +562,11 @@ void graphics_plugin::notify_screen() throw() post_ui_event(UISERV_UPDATE_SCREEN); } +void signal_core_change() +{ + post_ui_event(UISERV_REFRESH_TITLE); +} + bool graphics_plugin::modal_message(const std::string& text, bool confirm) throw() { mutex::holder h(*ui_mutex); diff --git a/src/platform/wxwidgets/mainwindow.cpp b/src/platform/wxwidgets/mainwindow.cpp index 84f8b3bf..5a682e2e 100644 --- a/src/platform/wxwidgets/mainwindow.cpp +++ b/src/platform/wxwidgets/mainwindow.cpp @@ -7,7 +7,6 @@ #include "platform/wxwidgets/window_messages.hpp" #include "platform/wxwidgets/window_status.hpp" -#include "core/emucore.hpp" #include "core/audioapi.hpp" #include "core/command.hpp" #include "core/controller.hpp" @@ -15,6 +14,7 @@ #include "core/dispatch.hpp" #include "core/framebuffer.hpp" #include "core/framerate.hpp" +#include "interface/romtype.hpp" #include "library/loadlib.hpp" #include "lua/lua.hpp" #include "core/mainloop.hpp" @@ -163,7 +163,8 @@ namespace wxString getname() { - std::string windowname = "lsnes rr" + lsnes_version + "[" + bsnes_core_version + "]"; + std::string windowname = "lsnes rr" + lsnes_version + " [" + our_rom->rtype->get_core_identifier() + + "]"; return towxstring(windowname); } @@ -179,6 +180,7 @@ namespace struct emu_args* args = reinterpret_cast(_args); try { our_rom = args->rom; + messages << "Using core: " << our_rom->rtype->get_core_identifier() << std::endl; struct moviefile* movie = args->initial; bool has_to_succeed = args->load_has_to_succeed; platform::flush_command_queue(); @@ -319,6 +321,7 @@ namespace void on_mode_change(bool readonly) throw(); void on_autohold_update(unsigned port, unsigned controller, unsigned ctrlnum, bool newstate); void on_autohold_reconfigure(); + void on_core_change(); private: wxwin_mainwindow* mainw; sound_select_menu* sounddev; @@ -440,6 +443,11 @@ namespace mainw = win; } + void broadcast_listener::on_core_change() + { + signal_core_change(); + } + void broadcast_listener::set_sound_select(sound_select_menu* sdev) { sounddev = sdev; @@ -918,6 +926,11 @@ void wxwin_mainwindow::handle_menu_click(wxCommandEvent& e) } } +void wxwin_mainwindow::refresh_title() throw() +{ + SetTitle(getname()); +} + void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) { std::string filename; @@ -1085,7 +1098,7 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) std::ostringstream str; str << "Version: lsnes rr" << lsnes_version << std::endl; str << "Revision: " << lsnes_git_revision << std::endl; - str << "Core: " << bsnes_core_version << std::endl; + str << "Core: " << our_rom->rtype->get_core_identifier() << std::endl; wxMessageBox(towxstring(str.str()), _T("About"), wxICON_INFORMATION | wxOK, this); return; } diff --git a/src/platform/wxwidgets/romselect.cpp b/src/platform/wxwidgets/romselect.cpp index 4b45b61b..f6903477 100644 --- a/src/platform/wxwidgets/romselect.cpp +++ b/src/platform/wxwidgets/romselect.cpp @@ -5,12 +5,12 @@ #include #include "lsnes.hpp" -#include "core/emucore.hpp" #include "core/moviedata.hpp" #include "core/framerate.hpp" #include "core/settings.hpp" #include "core/window.hpp" +#include "interface/romtype.hpp" #include "interface/setting.hpp" #include "library/string.hpp" #include "library/zip.hpp" @@ -317,7 +317,7 @@ struct moviefile wxwin_project::make_movie() if(!i.second.get_setting()->validate(f.settings[i.first])) throw std::runtime_error((stringfmt() << "Bad value for setting " << i.first).str()); } - f.coreversion = bsnes_core_version; + f.coreversion = our_rom->rtype->get_core_identifier(); f.gamename = tostdstring(projectname->GetValue()); f.prefix = sanitize_prefix(tostdstring(prefix->GetValue())); f.projectid = get_random_hexstring(40); diff --git a/src/util/lsnes-dumpavi.cpp b/src/util/lsnes-dumpavi.cpp index 3aa8e7a9..91d002cd 100644 --- a/src/util/lsnes-dumpavi.cpp +++ b/src/util/lsnes-dumpavi.cpp @@ -1,11 +1,11 @@ #include "lsnes.hpp" -#include "core/emucore.hpp" #include "core/advdumper.hpp" #include "core/command.hpp" #include "core/dispatch.hpp" #include "core/framerate.hpp" #include "core/keymapper.hpp" +#include "interface/romtype.hpp" #include "library/loadlib.hpp" #include "lua/lua.hpp" #include "core/mainloop.hpp" @@ -232,7 +232,6 @@ int main(int argc, char** argv) adv_dumper& dumper = get_dumper(cmdline, mode, prefix, length); set_random_seed(); - bsnes_core_version = emulator_core->get_core_identifier(); platform::init(); init_lua(); @@ -307,6 +306,7 @@ int main(int argc, char** argv) throw std::runtime_error("Can't load any of the movies specified"); //Load ROM before starting the dumper. our_rom = &r; + messages << "Using core: " << our_rom->rtype->get_core_identifier() << std::endl; our_rom->region = &movie.gametype->get_region(); our_rom->load(movie.settings, movie.movie_rtc_second, movie.movie_rtc_subsecond); startup_lua_scripts(cmdline); diff --git a/src/video/sdmp.cpp b/src/video/sdmp.cpp index 455238c6..eef2fac3 100644 --- a/src/video/sdmp.cpp +++ b/src/video/sdmp.cpp @@ -1,10 +1,9 @@ #if defined(BSNES_V084) || defined(BSNES_V085) || defined(BSNES_V086) || defined(BSNES_V087) #include "lsnes.hpp" -#include #include "core/advdumper.hpp" #include "core/dispatch.hpp" -#include "core/emucore.hpp" #include "core/moviedata.hpp" +#include "interface/romtype.hpp" #include "library/serialization.hpp" #include "video/tcp.hpp"