From ae17d41df46a60a63d8e6bc6e1f4507b8117208e Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sun, 8 Jun 2014 14:24:57 +0300 Subject: [PATCH] Privatefy loaded_rom rtype, region and orig_region --- include/core/moviefile.hpp | 5 +- include/core/project.hpp | 2 +- include/core/rom-small.hpp | 6 ++ include/core/rom.hpp | 116 +++++++++++++++++++++++---- src/core/actions.cpp | 6 +- src/core/debug.cpp | 13 +-- src/core/filedownload.cpp | 5 +- src/core/framebuffer.cpp | 3 +- src/core/instance.cpp | 1 + src/core/mainloop.cpp | 18 ++--- src/core/memorymanip.cpp | 4 +- src/core/moviedata.cpp | 54 ++++++------- src/core/moviefile.cpp | 9 ++- src/core/project.cpp | 10 +-- src/core/romloader.cpp | 16 ++-- src/interface/cover.cpp | 3 +- src/lua/actions.cpp | 7 +- src/lua/core.cpp | 8 +- src/lua/disassemble.cpp | 7 +- src/lua/movie.cpp | 2 +- src/platform/wxwidgets/editor-movie.cpp | 2 +- src/platform/wxwidgets/editor-tasinput.cpp | 2 +- src/platform/wxwidgets/editor-voicesub.cpp | 8 +- src/platform/wxwidgets/main.cpp | 6 +- src/platform/wxwidgets/mainwindow.cpp | 21 +++-- src/platform/wxwidgets/mouse.cpp | 4 +- src/platform/wxwidgets/romselect.cpp | 14 ++-- src/platform/wxwidgets/tracelogmenu.cpp | 4 +- src/platform/wxwidgets/window-fileupload.cpp | 2 +- src/util/lsnes-dumpavi.cpp | 12 +-- src/util/lsnes-romloadtest.cpp | 8 +- src/video/avi.cpp | 3 +- src/video/pipedec.cpp | 1 + src/video/raw.cpp | 3 +- 34 files changed, 246 insertions(+), 139 deletions(-) create mode 100644 include/core/rom-small.hpp diff --git a/include/core/moviefile.hpp b/include/core/moviefile.hpp index bbe0193b..9ecaaaa1 100644 --- a/include/core/moviefile.hpp +++ b/include/core/moviefile.hpp @@ -6,11 +6,14 @@ #include #include #include "core/controllerframe.hpp" -#include "core/rom.hpp" +#include "core/rom-small.hpp" #include "core/subtitles.hpp" +#include "interface/romtype.hpp" #include "library/rrdata.hpp" #include "library/zip.hpp" +class loaded_rom; + /** * This structure gives parsed representationg of movie file, as result of decoding or for encoding. */ diff --git a/include/core/project.hpp b/include/core/project.hpp index e4a03321..b8819ad3 100644 --- a/include/core/project.hpp +++ b/include/core/project.hpp @@ -5,8 +5,8 @@ #include #include #include +#include "core/rom-small.hpp" #include "library/json.hpp" -#include "core/rom.hpp" class voice_commentary; class memwatch_set; diff --git a/include/core/rom-small.hpp b/include/core/rom-small.hpp new file mode 100644 index 00000000..20f11257 --- /dev/null +++ b/include/core/rom-small.hpp @@ -0,0 +1,6 @@ +#ifndef _rom_small__hpp__included__ +#define _rom_small__hpp__included__ + +#define ROM_SLOT_COUNT 27 + +#endif diff --git a/include/core/rom.hpp b/include/core/rom.hpp index 5839dc56..f59c9b96 100644 --- a/include/core/rom.hpp +++ b/include/core/rom.hpp @@ -1,13 +1,12 @@ #ifndef _rom__hpp__included__ #define _rom__hpp__included__ -#define ROM_SLOT_COUNT 27 - #include #include #include #include #include "core/misc.hpp" +#include "core/rom-small.hpp" #include "interface/romtype.hpp" #include "library/fileimage.hpp" @@ -68,18 +67,6 @@ struct loaded_rom */ loaded_rom(const std::string& file, core_type& ctype) throw(std::bad_alloc, std::runtime_error); /** - * ROM type - */ - core_type* rtype; -/** - * ROM region (this is the currently active region). - */ - core_region* region; -/** - * ROM original region (this is the region ROM is loaded as). - */ - core_region* orig_region; -/** * Loaded main ROM */ fileimage::image romimg[ROM_SLOT_COUNT]; @@ -128,6 +115,107 @@ struct loaded_rom * throws std::runtime_error: No such file. */ static bool is_gamepak(const std::string& filename) throw(std::bad_alloc, std::runtime_error); + +/** + * Get internal type representation. + */ + core_type& get_internal_rom_type() { return *rtype; } +/** + * Get internal region representation. + */ + core_region& get_internal_region() { return *region; } +/** + * Is same ROM type? + */ + bool is_of_type(core_type& type) { return (rtype == &type); } +/** + * Get gametype of this ROM. + */ + core_sysregion& get_sysregion() { return rtype->combine_region(*region); } +/** + * Set internal region representation. + */ + void set_internal_region(core_region& reg) { region = ® } + + //ROM methods. + std::string get_core_identifier() { return rtype->get_core_identifier(); } + std::pair get_scale_factors(uint32_t width, uint32_t height) + { + return rtype->get_scale_factors(width, height); + } + const std::string& get_hname() { return rtype->get_hname(); } + core_sysregion& combine_region(core_region& reg) { return rtype->combine_region(reg); } + bool isnull() { return !rtype || rtype->isnull(); } + std::vector get_trace_cpus() { return rtype->get_trace_cpus(); } + controller_set controllerconfig(std::map& settings) + { + return rtype->controllerconfig(settings); + } + core_setting_group& get_settings() { return rtype->get_settings(); } + std::set srams() { return rtype->srams(); } + double get_PAR() { return rtype->get_PAR(); } + std::string get_systemmenu_name() { return rtype->get_systemmenu_name(); } + unsigned action_flags(unsigned id) { return rtype->action_flags(id); } + std::set get_actions() { return rtype->get_actions(); } + void execute_action(unsigned id, const std::vector& p) + { + return rtype->execute_action(id, p); + } + std::pair lightgun_scale() { return rtype->lightgun_scale(); } + const interface_device_reg* get_registers() { return rtype->get_registers(); } + bool get_pflag() { return rtype->get_pflag(); } + void set_pflag(bool pflag) { rtype->set_pflag(pflag); } + std::pair get_bus_map() { return rtype->get_bus_map(); } + std::list get_regions() { return rtype->get_regions(); } + const std::string& get_iname() { return rtype->get_iname(); } + std::map> save_sram() throw(std::bad_alloc) { return rtype->save_sram(); } + void load_sram(std::map>& sram) throw(std::bad_alloc) + { + rtype->load_sram(sram); + } + std::list vma_list() { return rtype->vma_list(); } + framebuffer::raw& draw_cover() { return rtype->draw_cover(); } + int reset_action(bool hard) { return rtype->reset_action(hard); } + void pre_emulate_frame(controller_frame& cf) { return rtype->pre_emulate_frame(cf); } + void emulate() { rtype->emulate(); } + void runtosave() { rtype->runtosave(); } + std::pair get_audio_rate() { return rtype->get_audio_rate(); } + void set_debug_flags(uint64_t addr, unsigned flags_set, unsigned flags_clear) + { + return rtype->set_debug_flags(addr, flags_set, flags_clear); + } + void set_cheat(uint64_t addr, uint64_t value, bool set) + { + return rtype->set_cheat(addr, value, set); + } + void debug_reset() + { + rtype->debug_reset(); + } + //Region methods. + const std::string& orig_region_get_iname() { return orig_region->get_iname(); } + const std::string& orig_region_get_hname() { return orig_region->get_hname(); } + const std::string& region_get_iname() { return region->get_iname(); } + const std::string& region_get_hname() { return region->get_hname(); } + double region_approx_framerate() { return region->approx_framerate(); } + void region_fill_framerate_magic(uint64_t* magic) { region->fill_framerate_magic(magic); } + bool region_compatible_with(core_region& run) + { + return orig_region && orig_region->compatible_with(run); + } +private: +/** + * ROM type + */ + core_type* rtype; +/** + * ROM region (this is the currently active region). + */ + core_region* region; +/** + * ROM original region (this is the region ROM is loaded as). + */ + core_region* orig_region; }; /** diff --git a/src/core/actions.cpp b/src/core/actions.cpp index 1c8e0362..27b35b98 100644 --- a/src/core/actions.cpp +++ b/src/core/actions.cpp @@ -18,7 +18,7 @@ namespace token_iterator itre; std::string sym = *itr++; const interface_action* act = NULL; - for(auto i : core.rom->rtype->get_actions()) + for(auto i : core.rom->get_actions()) if(i->get_symbol() == sym) { act = i; break; @@ -27,7 +27,7 @@ namespace messages << "No such action." << std::endl; return; } - if(!(core.rom->rtype->action_flags(act->id) & 1)) { + if(!(core.rom->action_flags(act->id) & 1)) { messages << "Action not enabled." << std::endl; return; } @@ -124,6 +124,6 @@ out: messages << "Excess parameters for action." << std::endl; return; } - core.rom->rtype->execute_action(act->id, params); + core.rom->execute_action(act->id, params); }); } diff --git a/src/core/debug.cpp b/src/core/debug.cpp index cc4049a4..d153e949 100644 --- a/src/core/debug.cpp +++ b/src/core/debug.cpp @@ -5,6 +5,7 @@ #include "core/mainloop.hpp" #include "core/messages.hpp" #include "core/moviedata.hpp" +#include "core/rom.hpp" #include "library/directory.hpp" #include @@ -67,7 +68,7 @@ void debug_context::add_callback(uint64_t addr, debug_context::etype type, debug corechange_r = true; } if(!xcb.count(addr) && type != DEBUG_FRAME) - core.rom->rtype->set_debug_flags(addr, debug_flag(type), 0); + core.rom->set_debug_flags(addr, debug_flag(type), 0); auto& lst = xcb[addr]; lst.push_back(&cb); } @@ -87,7 +88,7 @@ void debug_context::remove_callback(uint64_t addr, debug_context::etype type, de if(xcb[addr].empty()) { xcb.erase(addr); if(type != DEBUG_FRAME) - rom.rtype->set_debug_flags(addr, 0, debug_flag(type)); + rom.set_debug_flags(addr, 0, debug_flag(type)); } } @@ -176,12 +177,12 @@ void debug_context::do_callback_frame(uint64_t frame, bool loadstate) void debug_context::set_cheat(uint64_t addr, uint64_t value) { - rom.rtype->set_cheat(addr, value, true); + rom.set_cheat(addr, value, true); } void debug_context::clear_cheat(uint64_t addr) { - rom.rtype->set_cheat(addr, 0, false); + rom.set_cheat(addr, 0, false); } void debug_context::setxmask(uint64_t mask) @@ -201,7 +202,7 @@ void debug_context::set_tracelog_change_cb(std::function cb) void debug_context::core_change() { - rom.rtype->debug_reset(); + rom.debug_reset(); kill_hooks(read_cb, DEBUG_READ); kill_hooks(write_cb, DEBUG_WRITE); kill_hooks(exec_cb, DEBUG_EXEC); @@ -340,7 +341,7 @@ namespace std::string cpu = r[1]; std::string filename = r[3]; uint64_t _cpu = 0; - for(auto i : core.rom->rtype->get_trace_cpus()) { + for(auto i : core.rom->get_trace_cpus()) { if(cpu == i) goto out; _cpu++; diff --git a/src/core/filedownload.cpp b/src/core/filedownload.cpp index 6f92cc6e..5316d58e 100644 --- a/src/core/filedownload.cpp +++ b/src/core/filedownload.cpp @@ -1,5 +1,6 @@ #include "core/filedownload.hpp" #include "core/moviedata.hpp" +#include "core/rom.hpp" #include "interface/romtype.hpp" #include "library/string.hpp" #include "library/zip.hpp" @@ -143,8 +144,8 @@ void file_download::_do_async(loaded_rom& rom) if(tempname != tempname2) remove(tempname.c_str()); try { core_type* gametype = NULL; - if(!rom.rtype->isnull()) - gametype = rom.rtype; + if(!rom.isnull()) + gametype = &rom.get_internal_rom_type(); else { moviefile::brief_info info(tempname2); auto sysregs = core_sysregion::find_matching(info.sysregion); diff --git a/src/core/framebuffer.cpp b/src/core/framebuffer.cpp index 0071b1ca..47e5be80 100644 --- a/src/core/framebuffer.cpp +++ b/src/core/framebuffer.cpp @@ -5,6 +5,7 @@ #include "core/memorywatch.hpp" #include "core/messages.hpp" #include "core/moviedata.hpp" +#include "core/rom.hpp" #include "core/settings.hpp" #include "core/subtitles.hpp" #include "fonts/wrapper.hpp" @@ -137,7 +138,7 @@ void emu_framebuffer::init_special_screens() throw(std::bad_alloc) void emu_framebuffer::redraw_framebuffer(framebuffer::raw& todraw, bool no_lua, bool spontaneous) { uint32_t hscl, vscl; - auto g = rom.rtype->get_scale_factors(todraw.get_width(), todraw.get_height()); + auto g = rom.get_scale_factors(todraw.get_width(), todraw.get_height()); hscl = g.first; vscl = g.second; render_info& ri = buffering.get_write(); diff --git a/src/core/instance.cpp b/src/core/instance.cpp index 7d1827df..7d518436 100644 --- a/src/core/instance.cpp +++ b/src/core/instance.cpp @@ -21,6 +21,7 @@ #include "core/project.hpp" #include "core/queue.hpp" #include "core/random.hpp" +#include "core/rom.hpp" #include "core/settings.hpp" #include "library/command.hpp" #include "library/keyboard.hpp" diff --git a/src/core/mainloop.cpp b/src/core/mainloop.cpp index 9ed6bdd1..d35c1828 100644 --- a/src/core/mainloop.cpp +++ b/src/core/mainloop.cpp @@ -220,7 +220,7 @@ controller_frame movie_logic::update_controls(bool subframe) throw(std::bad_allo } platform::flush_command_queue(); controller_frame tmp = core.controls->get(core.mlogic->get_movie().get_current_frame()); - core.rom->rtype->pre_emulate_frame(tmp); //Preset controls, the lua will override if needed. + core.rom->pre_emulate_frame(tmp); //Preset controls, the lua will override if needed. core.lua2->callback_do_input(tmp, subframe); core.mteditor->process_frame(tmp); core.controls->commit(tmp); @@ -288,7 +288,7 @@ void update_movie_state() bool readonly = false; { uint64_t magic[4]; - core.rom->region->fill_framerate_magic(magic); + core.rom->region_fill_framerate_magic(magic); if(*core.mlogic) core.commentary->frame_number(core.mlogic->get_movie().get_current_frame(), 1.0 * magic[1] / magic[0]); @@ -488,7 +488,7 @@ public: core.lua2->callback_do_frame_emulated(); location_special = SPECIAL_FRAME_VIDEO; core.fbuf->redraw_framebuffer(screen, false, true); - auto rate = core.rom->rtype->get_audio_rate(); + auto rate = core.rom->get_audio_rate(); uint32_t gv = gcd(fps_n, fps_d); uint32_t ga = gcd(rate.first, rate.second); core.mdumper->on_rate_change(rate.first / ga, rate.second / ga); @@ -727,26 +727,26 @@ namespace "Syntax: reset\nReset\nResets the system in beginning of the next frame.\n", []() throw(std::bad_alloc, std::runtime_error) { auto& core = CORE(); - int sreset_action = core.rom->rtype->reset_action(false); + int sreset_action = core.rom->reset_action(false); if(sreset_action < 0) { platform::error_message("Core does not support resets"); messages << "Emulator core does not support resets" << std::endl; return; } - core.rom->rtype->execute_action(sreset_action, std::vector()); + core.rom->execute_action(sreset_action, std::vector()); }); command::fnptr<> CMD_hreset_c(lsnes_cmds, "reset-hard", "Reset the system", "Syntax: reset-hard\nReset-hard\nHard resets the system in beginning of the next frame.\n", []() throw(std::bad_alloc, std::runtime_error) { auto& core = CORE(); - int hreset_action = core.rom->rtype->reset_action(true); + int hreset_action = core.rom->reset_action(true); if(hreset_action < 0) { platform::error_message("Core does not support hard resets"); messages << "Emulator core does not support hard resets" << std::endl; return; } - core.rom->rtype->execute_action(hreset_action, std::vector()); + core.rom->execute_action(hreset_action, std::vector()); }); command::fnptr CMD_load_c(lsnes_cmds, "load", "Load savestate (current mode)", @@ -1170,7 +1170,7 @@ nothing_to_do: if(!*core.mlogic) return; if(!queued_saves.empty() || (do_unsafe_rewind && !unsafe_rewind_obj)) { - core.rom->rtype->runtosave(); + core.rom->runtosave(); for(auto i : queued_saves) { do_save_state(i.first, i.second); int tmp = -1; @@ -1316,7 +1316,7 @@ void main_loop(struct loaded_rom& rom, struct moviefile& initial, bool load_has_ just_did_loadstate = false; } core.dbg->do_callback_frame(core.mlogic->get_movie().get_current_frame(), false); - core.rom->rtype->emulate(); + core.rom->emulate(); random_mix_timing_entropy(); if(amode == ADVANCE_AUTO) platform::wait(core.framerate->to_wait_frame(framerate_regulator::get_utime())); diff --git a/src/core/memorymanip.cpp b/src/core/memorymanip.cpp index 52e9f78b..2363bc26 100644 --- a/src/core/memorymanip.cpp +++ b/src/core/memorymanip.cpp @@ -94,12 +94,10 @@ cart_mappings_refresher::cart_mappings_refresher(memory_space& _mspace, movie_lo void cart_mappings_refresher::operator()() throw(std::bad_alloc) { - if(!rom.rtype) - return; std::list cur_regions = mspace.get_regions(); std::list regions; memory_region* tmp = NULL; - auto vmalist = rom.rtype->vma_list(); + auto vmalist = rom.vma_list(); auto _mlogic = &mlogic; try { tmp = new iospace_region("LSNESMMIO", 0xFFFFFFFF00000000ULL, 32, true, diff --git a/src/core/moviedata.cpp b/src/core/moviedata.cpp index 5e6ce264..f2eeef68 100644 --- a/src/core/moviedata.cpp +++ b/src/core/moviedata.cpp @@ -116,11 +116,11 @@ namespace } int get_pflag() { - return CORE().rom->rtype->get_pflag(); + return CORE().rom->get_pflag(); } void set_pflag(int flag) { - CORE().rom->rtype->set_pflag(flag); + CORE().rom->set_pflag(flag); } } lsnes_pflag_handler; } @@ -223,7 +223,7 @@ void do_save_state(const std::string& filename, int binary) throw(std::bad_alloc try { uint64_t origtime = framerate_regulator::get_utime(); target.is_savestate = true; - target.sram = core.rom->rtype->save_sram(); + target.sram = core.rom->save_sram(); for(size_t i = 0; i < ROM_SLOT_COUNT; i++) { target.romimg_sha256[i] = core.rom->romimg[i].sha_256.read(); target.romxml_sha256[i] = core.rom->romxml[i].sha_256.read(); @@ -233,7 +233,7 @@ void do_save_state(const std::string& filename, int binary) throw(std::bad_alloc core.fbuf->get_framebuffer().save(target.screenshot); core.mlogic->get_movie().save_state(target.projectid, target.save_frame, target.lagged_frames, target.pollcounters); - target.poll_flag = core.rom->rtype->get_pflag(); + target.poll_flag = core.rom->get_pflag(); auto prj = core.project->get(); if(prj) { target.gamename = prj->gamename; @@ -341,8 +341,8 @@ namespace void print_movie_info(moviefile& mov, loaded_rom& rom, rrdata_set& rrd) { - if(rom.rtype) - messages << "ROM Type " << rom.rtype->get_hname() << " region " << rom.region->get_hname() + if(!rom.isnull()) + messages << "ROM Type " << rom.get_hname() << " region " << rom.region_get_hname() << std::endl; std::string len, rerecs; len = format_length(mov.get_movie_length()); @@ -363,9 +363,9 @@ namespace void warn_coretype(const std::string& mov_core, loaded_rom& against, bool loadstate) { - if(!against.rtype) + if(against.isnull()) return; - std::string rom_core = against.rtype->get_core_identifier(); + std::string rom_core = against.get_core_identifier(); if(mov_core == rom_core) return; std::ostringstream x; @@ -400,7 +400,7 @@ namespace port_type_set& construct_movie_portset(moviefile& mov, loaded_rom& against) { - auto ctrldata = against.rtype->controllerconfig(mov.settings); + auto ctrldata = against.controllerconfig(mov.settings); return port_type_set::make(ctrldata.ports, ctrldata.portindex()); } @@ -416,7 +416,7 @@ namespace //Set the core ports in order to avoid port state being reinitialized when loading. core.controls->set_ports(portset); core.rom->load_core_state(_movie.savestate); - core.rom->rtype->set_pflag(_movie.poll_flag); + core.rom->set_pflag(_movie.poll_flag); core.controls->set_macro_frames(_movie.active_macros); } else { //Reload the ROM in order to rewind to the beginning. @@ -428,11 +428,11 @@ namespace if(!_movie.anchor_savestate.empty()) { core.rom->load_core_state(_movie.anchor_savestate); } else { - core.rom->rtype->load_sram(_movie.movie_sram); - std::list vmas = core.rom->rtype->vma_list(); + core.rom->load_sram(_movie.movie_sram); + std::list vmas = core.rom->vma_list(); populate_volatile_ram(_movie, vmas); } - core.rom->rtype->set_pflag(0); + core.rom->set_pflag(0); core.controls->set_macro_frames(std::map()); } } @@ -446,7 +446,7 @@ void do_load_rom() throw(std::bad_alloc, std::runtime_error) port_type_set& portset = construct_movie_portset(core.mlogic->get_mfile(), *core.rom); //If portset or gametype changes, force readwrite with new movie. if(core.mlogic->get_mfile().input->get_types() != portset) load_readwrite = true; - if(core.rom->rtype != &core.mlogic->get_mfile().gametype->get_type()) load_readwrite = true; + if(!core.rom->is_of_type(core.mlogic->get_mfile().gametype->get_type())) load_readwrite = true; } if(!load_readwrite) { @@ -461,7 +461,7 @@ void do_load_rom() throw(std::bad_alloc, std::runtime_error) try { handle_load_core(core.mlogic->get_mfile(), portset, false); - core.mlogic->get_mfile().gametype = &core.rom->rtype->combine_region(*core.rom->region); + core.mlogic->get_mfile().gametype = &core.rom->get_sysregion(); for(size_t i = 0; i < ROM_SLOT_COUNT; i++) { core.mlogic->get_mfile().namehint[i] = core.rom->romimg[i].namehint; core.mlogic->get_mfile().romimg_sha256[i] = core.rom->romimg[i].sha_256.read(); @@ -470,7 +470,7 @@ void do_load_rom() throw(std::bad_alloc, std::runtime_error) core.mlogic->get_mfile().is_savestate = false; core.mlogic->get_mfile().host_memory.clear(); core.mlogic->get_movie().reset_state(); - core.fbuf->redraw_framebuffer(core.rom->rtype->draw_cover()); + core.fbuf->redraw_framebuffer(core.rom->draw_cover()); core.lua2->callback_do_rewind(); } catch(std::bad_alloc& e) { OOM_panic(); @@ -485,7 +485,7 @@ void do_load_rom() throw(std::bad_alloc, std::runtime_error) temporary_handle _movie; _movie.get()->force_corrupt = false; _movie.get()->gametype = NULL; //Not yet known. - _movie.get()->coreversion = core.rom->rtype->get_core_identifier(); + _movie.get()->coreversion = core.rom->get_core_identifier(); _movie.get()->projectid = get_random_hexstring(40); _movie.get()->rerecords = "0"; _movie.get()->rerecords_mem = 0; @@ -521,8 +521,8 @@ void do_load_rom() throw(std::bad_alloc, std::runtime_error) core.lua2->callback_movie_lost("reload"); try { handle_load_core(*_movie.get(), portset2, false); - _movie.get()->gametype = &core.rom->rtype->combine_region(*core.rom->region); - core.fbuf->redraw_framebuffer(core.rom->rtype->draw_cover()); + _movie.get()->gametype = &core.rom->get_sysregion(); + core.fbuf->redraw_framebuffer(core.rom->draw_cover()); core.lua2->callback_do_rewind(); } catch(std::bad_alloc& e) { OOM_panic(); @@ -566,7 +566,7 @@ void do_load_rewind() throw(std::bad_alloc, std::runtime_error) core.mlogic->get_mfile().is_savestate = false; core.mlogic->get_mfile().host_memory.clear(); core.mlogic->get_movie().reset_state(); - core.fbuf->redraw_framebuffer(core.rom->rtype->draw_cover()); + core.fbuf->redraw_framebuffer(core.rom->draw_cover()); core.lua2->callback_do_rewind(); } catch(std::bad_alloc& e) { OOM_panic(); @@ -635,7 +635,7 @@ void do_load_state_preserve(struct moviefile& _movie) tmp.load(_movie.screenshot); core.fbuf->redraw_framebuffer(tmp); } else - core.fbuf->redraw_framebuffer(core.rom->rtype->draw_cover()); + core.fbuf->redraw_framebuffer(core.rom->draw_cover()); } catch(...) { } delete &_movie; @@ -657,9 +657,9 @@ void do_load_state(struct moviefile& _movie, int lmode, bool& used) //Various checks. if(_movie.force_corrupt) throw std::runtime_error("Movie file invalid"); - if(&(_movie.gametype->get_type()) != core.rom->rtype) + if(!core.rom->is_of_type(_movie.gametype->get_type())) throw std::runtime_error("ROM types of movie and loaded ROM don't match"); - if(core.rom->orig_region && !core.rom->orig_region->compatible_with(_movie.gametype->get_region())) + if(!core.rom->region_compatible_with(_movie.gametype->get_region())) throw std::runtime_error("NTSC/PAL select of movie and loaded ROM don't match"); warn_coretype(_movie.coreversion, *core.rom, will_load_state); warn_roms(_movie, *core.rom, will_load_state); @@ -735,7 +735,7 @@ void do_load_state(struct moviefile& _movie, int lmode, bool& used) } //Negative return. try { - core.rom->region = _movie.gametype ? &(_movie.gametype->get_region()) : NULL; + core.rom->set_internal_region(_movie.gametype->get_region()); handle_load_core(_movie, portset, will_load_state); } catch(std::bad_alloc& e) { OOM_panic(); @@ -779,7 +779,7 @@ void do_load_state(struct moviefile& _movie, int lmode, bool& used) tmp.load(_movie.screenshot); core.fbuf->redraw_framebuffer(tmp); } else - core.fbuf->redraw_framebuffer(core.rom->rtype->draw_cover()); + core.fbuf->redraw_framebuffer(core.rom->draw_cover()); } core.dispatch->mode_change(m.readonly_mode()); @@ -843,9 +843,9 @@ bool do_load_state(const std::string& filename, int lmode) struct moviefile* mfile = NULL; bool used = false; try { - if(core.rom->rtype->isnull()) + if(core.rom->isnull()) try_request_rom(filename2); - mfile = new moviefile(filename2, *core.rom->rtype); + mfile = new moviefile(filename2, core.rom->get_internal_rom_type()); } catch(std::bad_alloc& e) { OOM_panic(); } catch(std::exception& e) { diff --git a/src/core/moviefile.cpp b/src/core/moviefile.cpp index 5d0bf2d5..bfc298d4 100644 --- a/src/core/moviefile.cpp +++ b/src/core/moviefile.cpp @@ -1,6 +1,7 @@ #include "core/moviefile-common.hpp" #include "core/moviefile.hpp" #include "core/random.hpp" +#include "core/rom.hpp" #include "library/binarystream.hpp" #include "library/directory.hpp" #include "library/minmax.hpp" @@ -120,8 +121,8 @@ moviefile::moviefile(loaded_rom& rom, std::map& c_sett uint64_t rtc_subsec) { force_corrupt = false; - gametype = &rom.rtype->combine_region(*rom.region); - coreversion = rom.rtype->get_core_identifier(); + gametype = &rom.get_sysregion(); + coreversion = rom.get_core_identifier(); projectid = get_random_hexstring(40); rerecords = "0"; is_savestate = false; @@ -132,10 +133,10 @@ moviefile::moviefile(loaded_rom& rom, std::map& c_sett poll_flag = 0; settings = c_settings; input = NULL; - auto ctrldata = rom.rtype->controllerconfig(settings); + auto ctrldata = rom.controllerconfig(settings); port_type_set& ports = port_type_set::make(ctrldata.ports, ctrldata.portindex()); create_default_branch(ports); - if(!rom.rtype->isnull()) { + if(!rom.isnull()) { //Initialize the remainder. rerecords = "0"; for(size_t i = 0; i < ROM_SLOT_COUNT; i++) { diff --git a/src/core/project.cpp b/src/core/project.cpp index de9f1a7b..8de81abc 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -361,21 +361,21 @@ bool project_state::set(project_info* p, bool current) } newrom = loaded_rom(p->roms, ctype->get_core_identifier(), ctype->get_iname(), ""); } - if(newrom.rtype->get_core_identifier() != p->coreversion) { - messages << "Warning: Can't find matching core, using " << newrom.rtype->get_core_identifier() + if(newrom.get_core_identifier() != p->coreversion) { + messages << "Warning: Can't find matching core, using " << newrom.get_core_identifier() << std::endl; } if(p->last_save != "") try { - newmovie = new moviefile(p->last_save, *newrom.rtype); + newmovie = new moviefile(p->last_save, newrom.get_internal_rom_type()); } catch(std::exception& e) { messages << "Warning: Can't load last save: " << e.what() << std::endl; newmovie = new moviefile(); - fill_stub_movie(*newmovie, *p, *newrom.rtype); + fill_stub_movie(*newmovie, *p, newrom.get_internal_rom_type()); } else { newmovie = new moviefile(); - fill_stub_movie(*newmovie, *p, *newrom.rtype); + fill_stub_movie(*newmovie, *p, newrom.get_internal_rom_type()); } //Okay, loaded, load into core. newrom.load(p->settings, p->movie_rtc_second, p->movie_rtc_subsecond); diff --git a/src/core/romloader.cpp b/src/core/romloader.cpp index ec56d8dd..983bf3fd 100644 --- a/src/core/romloader.cpp +++ b/src/core/romloader.cpp @@ -109,7 +109,7 @@ bool _load_new_rom(const romload_request& req) messages << "Can't reload ROM: " << e.what() << std::endl; return false; } - messages << "Using core: " << core.rom->rtype->get_core_identifier() << std::endl; + messages << "Using core: " << core.rom->get_core_identifier() << std::endl; core.dispatch->core_change(); return true; } @@ -119,7 +119,7 @@ bool reload_active_rom() { auto& core = CORE(); romload_request req; - if(core.rom->rtype->isnull()) { + if(core.rom->isnull()) { platform::error_message("Can't reload ROM: No existing ROM"); messages << "No ROM loaded" << std::endl; return false; @@ -129,9 +129,9 @@ bool reload_active_rom() return _load_new_rom(req); } //This is composite ROM. - req.core = core.rom->rtype->get_core_identifier(); - req.system = core.rom->rtype->get_iname(); - req.region = core.rom->orig_region->get_iname(); + req.core = core.rom->get_core_identifier(); + req.system = core.rom->get_iname(); + req.region = core.rom->orig_region_get_iname(); for(unsigned i = 0; i < ROM_SLOT_COUNT; i++) req.files[i] = core.rom->romimg[i].filename; return _load_new_rom(req); @@ -294,14 +294,14 @@ loaded_rom construct_rom(const std::string& movie_filename, const std::vectorget_type() != cr.rtype) + if(cr.is_of_type(j->get_type())) continue; - for(auto k : cr.rtype->get_regions()) + for(auto k : cr.get_regions()) if(k == &j->get_region()) goto valid; } throw std::runtime_error("Specified ROM is of wrong type ('" + - cr.rtype->get_hname() + "') for movie ('" + info.sysregion + ")"); + cr.get_hname() + "') for movie ('" + info.sysregion + ")"); valid: return cr; } diff --git a/src/interface/cover.cpp b/src/interface/cover.cpp index 99fc5354..845ee189 100644 --- a/src/interface/cover.cpp +++ b/src/interface/cover.cpp @@ -1,6 +1,7 @@ #include "core/instance.hpp" #include "core/moviedata.hpp" #include "core/memorymanip.hpp" +#include "core/rom.hpp" #include "interface/cover.hpp" #include "library/minmax.hpp" #include "library/utf8.hpp" @@ -105,6 +106,6 @@ std::vector cover_information() { auto& core = CORE(); std::vector ret; - ret.push_back("System: " + core.rom->rtype->get_hname() + " (" + core.rom->region->get_hname() + ")"); + ret.push_back("System: " + core.rom->get_hname() + " (" + core.rom->region_get_hname() + ")"); return ret; } diff --git a/src/lua/actions.cpp b/src/lua/actions.cpp index e7d802df..b12f3813 100644 --- a/src/lua/actions.cpp +++ b/src/lua/actions.cpp @@ -3,6 +3,7 @@ #include "core/instance.hpp" #include "core/moviedata.hpp" #include "core/messages.hpp" +#include "core/rom.hpp" namespace { @@ -14,14 +15,14 @@ namespace P(name); const interface_action* act = NULL; - for(auto i : core.rom->rtype->get_actions()) + for(auto i : core.rom->get_actions()) if(i->get_symbol() == name) { act = i; break; } if(!act) throw std::runtime_error("No such action"); - if(!(core.rom->rtype->action_flags(act->id) & 1)) + if(!(core.rom->action_flags(act->id) & 1)) throw std::runtime_error("Action not enabled."); std::vector params; for(auto i : act->params) { @@ -93,7 +94,7 @@ out: } if(P.more()) throw std::runtime_error("Excess arguments for action"); - core.rom->rtype->execute_action(act->id, params); + core.rom->execute_action(act->id, params); return 0; } diff --git a/src/lua/core.cpp b/src/lua/core.cpp index 83560b09..3e973a4c 100644 --- a/src/lua/core.cpp +++ b/src/lua/core.cpp @@ -4,6 +4,7 @@ #include "core/instance.hpp" #include "core/moviefile.hpp" #include "core/moviedata.hpp" +#include "core/rom.hpp" #include "core/window.hpp" #include "interface/romtype.hpp" #include "library/string.hpp" @@ -175,7 +176,7 @@ namespace P(addr); - auto busrange = core.rom->rtype->get_bus_map(); + auto busrange = core.rom->get_bus_map(); if(!busrange.second) throw std::runtime_error("This platform does not have bus mapping"); L.pushnumber(busrange.first + (addr % busrange.second)); @@ -185,7 +186,7 @@ namespace int get_lag_flag(lua::state& L, lua::parameters& P) { auto& core = CORE(); - L.pushboolean(!(core.rom->rtype && core.rom->rtype->get_pflag())); + L.pushboolean(!core.rom->get_pflag()); return 1; } @@ -196,8 +197,7 @@ namespace P(flag); - if(core.rom->rtype) - core.rom->rtype->set_pflag(!flag); + core.rom->set_pflag(!flag); return 0; } diff --git a/src/lua/disassemble.cpp b/src/lua/disassemble.cpp index 9541994c..74201d0a 100644 --- a/src/lua/disassemble.cpp +++ b/src/lua/disassemble.cpp @@ -6,6 +6,7 @@ #include "core/instance.hpp" #include "core/memorymanip.hpp" #include "core/moviedata.hpp" +#include "core/rom.hpp" namespace { @@ -53,7 +54,7 @@ namespace P(r); - const interface_device_reg* regs = core.rom->rtype->get_registers(); + const interface_device_reg* regs = core.rom->get_registers(); if(!regs) { L.pushnil(); return 1; @@ -74,7 +75,7 @@ namespace int getregisters(lua::state& L, lua::parameters& P) { auto& core = CORE(); - const interface_device_reg* regs = core.rom->rtype->get_registers(); + const interface_device_reg* regs = core.rom->get_registers(); if(!regs) { L.pushnil(); return 1; @@ -98,7 +99,7 @@ namespace P(r); - const interface_device_reg* regs = core.rom->rtype->get_registers(); + const interface_device_reg* regs = core.rom->get_registers(); if(!regs) { return 0; } diff --git a/src/lua/movie.cpp b/src/lua/movie.cpp index 5526e68d..86899e2f 100644 --- a/src/lua/movie.cpp +++ b/src/lua/movie.cpp @@ -108,7 +108,7 @@ namespace P(filename); - moviefile mfile(filename, *core.rom->rtype); + moviefile mfile(filename, core.rom->get_internal_rom_type()); if(!mfile.is_savestate) throw std::runtime_error("movie.to_rewind only allows savestates"); lua_unsaferewind* u2 = lua::_class::create(L); diff --git a/src/platform/wxwidgets/editor-movie.cpp b/src/platform/wxwidgets/editor-movie.cpp index 9f6509da..89c8506f 100644 --- a/src/platform/wxwidgets/editor-movie.cpp +++ b/src/platform/wxwidgets/editor-movie.cpp @@ -1456,7 +1456,7 @@ void wxeditor_movie::_moviepanel::popup_axis_panel(uint64_t row, control_info ci framebuffer::raw& _fb = inst.fbuf->render_get_latest_screen(); framebuffer::fb fb; auto osize = std::make_pair(_fb.get_width(), _fb.get_height()); - auto size = inst.rom->rtype->lightgun_scale(); + auto size = inst.rom->lightgun_scale(); fb.reallocate(osize.first, osize.second, false); fb.copy_from(_fb, 1, 1); inst.fbuf->render_get_latest_screen_end(); diff --git a/src/platform/wxwidgets/editor-tasinput.cpp b/src/platform/wxwidgets/editor-tasinput.cpp index b5d562cd..d95d7ef9 100644 --- a/src/platform/wxwidgets/editor-tasinput.cpp +++ b/src/platform/wxwidgets/editor-tasinput.cpp @@ -272,7 +272,7 @@ void wxeditor_tasinput::xypanel::on_paint(wxPaintEvent& e) framebuffer::raw& _fb = inst.fbuf->render_get_latest_screen(); framebuffer::fb fb; auto osize = std::make_pair(_fb.get_width(), _fb.get_height()); - auto size = inst.rom->rtype->lightgun_scale(); + auto size = inst.rom->lightgun_scale(); fb.reallocate(osize.first, osize.second, false); fb.copy_from(_fb, 1, 1); inst.fbuf->render_get_latest_screen_end(); diff --git a/src/platform/wxwidgets/editor-voicesub.cpp b/src/platform/wxwidgets/editor-voicesub.cpp index 06a6b5ec..d924596b 100644 --- a/src/platform/wxwidgets/editor-voicesub.cpp +++ b/src/platform/wxwidgets/editor-voicesub.cpp @@ -1,7 +1,8 @@ +#include "core/dispatch.hpp" #include "core/instance.hpp" #include "core/inthread.hpp" #include "core/project.hpp" -#include +#include "library/string.hpp" #include "platform/wxwidgets/platform.hpp" #include "platform/wxwidgets/loadsave.hpp" @@ -10,10 +11,9 @@ #include #include #include - -#include "core/dispatch.hpp" -#include "library/string.hpp" +#include #include +#include #define NOTHING 0xFFFFFFFFFFFFFFFFULL diff --git a/src/platform/wxwidgets/main.cpp b/src/platform/wxwidgets/main.cpp index 13edfc01..04fdba49 100644 --- a/src/platform/wxwidgets/main.cpp +++ b/src/platform/wxwidgets/main.cpp @@ -480,7 +480,7 @@ bool lsnes_app::OnInit() loaded_rom dummy_rom; std::map settings; - auto ctrldata = dummy_rom.rtype->controllerconfig(settings); + auto ctrldata = dummy_rom.controllerconfig(settings); port_type_set& ports = port_type_set::make(ctrldata.ports, ctrldata.portindex()); lsnes_instance.buttons->reinit(); @@ -537,7 +537,7 @@ bool lsnes_app::OnInit() moviefile* mov = NULL; if(movie_file != "") try { - mov = new moviefile(movie_file, *rom.rtype); + mov = new moviefile(movie_file, rom.get_internal_rom_type()); rom.load(mov->settings, mov->movie_rtc_second, mov->movie_rtc_subsecond); } catch(std::exception& e) { std::cerr << "Can't load state: " << e.what() << std::endl; @@ -550,7 +550,7 @@ bool lsnes_app::OnInit() mov = new moviefile(rom, c_settings, DEFAULT_RTC_SECOND, DEFAULT_RTC_SUBSECOND); } *lsnes_instance.rom = rom; - mov->start_paused = start_unpaused ? !(rom.rtype && !rom.rtype->isnull()) : true; + mov->start_paused = start_unpaused ? rom.isnull() : true; for(auto i : c_lua) lsnes_instance.lua2->add_startup_script(i); boot_emulator(lsnes_instance, rom, *mov, fullscreen_mode); diff --git a/src/platform/wxwidgets/mainwindow.cpp b/src/platform/wxwidgets/mainwindow.cpp index a9f0ffe9..6fc6a0b9 100644 --- a/src/platform/wxwidgets/mainwindow.cpp +++ b/src/platform/wxwidgets/mainwindow.cpp @@ -388,7 +388,7 @@ namespace return; unsigned act_id = action_by_id[e.GetId()]; const interface_action* act = NULL; - for(auto i : inst.rom->rtype->get_actions()) + for(auto i : inst.rom->get_actions()) if(i->id == act_id) { act = i; break; @@ -397,7 +397,7 @@ namespace return; try { auto p = prompt_action_params(pwin, act->get_title(), act->params); - inst.iqueue->run([this, act_id,p]() { this->inst.rom->rtype->execute_action(act_id, p); }); + inst.iqueue->run([this, act_id,p]() { this->inst.rom->execute_action(act_id, p); }); } catch(canceled_exception& e) { } catch(std::bad_alloc& e) { OOM_panic(); @@ -423,13 +423,13 @@ namespace submenui_by_name.clear(); toggles.clear(); - for(auto i : inst.rom->rtype->get_actions()) + for(auto i : inst.rom->get_actions()) insert_act(i->id, i->get_title(), !i->params.empty(), i->is_toggle()); } for(auto i : item_by_action) - i.second->Enable(inst.rom->rtype->action_flags(i.first) & 1); + i.second->Enable(inst.rom->action_flags(i.first) & 1); for(auto i : toggles) - item_by_action[i]->Check(inst.rom->rtype->action_flags(i) & 2); + item_by_action[i]->Check(inst.rom->action_flags(i) & 2); } std::string munge_name(const std::string& orig) @@ -588,7 +588,7 @@ namespace if(p) windowname = windowname + p->name; else - windowname = windowname + inst.rom->rtype->get_core_identifier(); + windowname = windowname + inst.rom->get_core_identifier(); windowname = windowname + "]"; return towxstring(windowname); } @@ -607,7 +607,7 @@ namespace auto& inst = *args->inst; try { *inst.rom = args->rom; - messages << "Using core: " << inst.rom->rtype->get_core_identifier() << std::endl; + messages << "Using core: " << inst.rom->get_core_identifier() << std::endl; struct moviefile* movie = args->initial; bool has_to_succeed = args->load_has_to_succeed; platform::flush_command_queue(); @@ -898,8 +898,7 @@ void wxwin_mainwindow::panel::on_paint(wxPaintEvent& e) wxPaintDC dc(this); uint32_t tw, th; bool aux = hflip_enabled || vflip_enabled || rotate_enabled; - auto sfactors = calc_scale_factors(video_scale_factor, arcorrect_enabled, inst.rom->rtype ? - inst.rom->rtype->get_PAR() : 1.0); + auto sfactors = calc_scale_factors(video_scale_factor, arcorrect_enabled, inst.rom->get_PAR()); if(rotate_enabled) { tw = inst.fbuf->main_screen.get_height() * sfactors.second + 0.5; th = inst.fbuf->main_screen.get_width() * sfactors.first + 0.5; @@ -1190,7 +1189,7 @@ wxwin_mainwindow::wxwin_mainwindow(emulator_instance& _inst, bool fscreen) spanel->SetDropTarget(new loadfile(this, inst)); set_hasher_callback(hash_callback); reinterpret_cast(sysmenu)->update(false); - menubar->SetMenuLabel(1, towxstring(inst.rom->rtype->get_systemmenu_name())); + menubar->SetMenuLabel(1, towxstring(inst.rom->get_systemmenu_name())); focus_timer = new _focus_timer; status_timer = new _status_timer; if(fscreen) { @@ -1358,7 +1357,7 @@ void wxwin_mainwindow::refresh_title() throw() menu_enable(wxID_CLOSE_PROJECT, p != NULL); menu_enable(wxID_CLOSE_ROM, p == NULL); reinterpret_cast(sysmenu)->update(false); - menubar->SetMenuLabel(1, towxstring(inst.rom->rtype->get_systemmenu_name())); + menubar->SetMenuLabel(1, towxstring(inst.rom->get_systemmenu_name())); } namespace diff --git a/src/platform/wxwidgets/mouse.cpp b/src/platform/wxwidgets/mouse.cpp index a1176c2f..7a44d591 100644 --- a/src/platform/wxwidgets/mouse.cpp +++ b/src/platform/wxwidgets/mouse.cpp @@ -1,6 +1,7 @@ #include "core/instance.hpp" #include "core/instance-map.hpp" #include "core/moviedata.hpp" +#include "core/rom.hpp" #include "library/keyboard.hpp" #include "platform/wxwidgets/platform.hpp" @@ -39,8 +40,7 @@ void handle_wx_mouse(emulator_instance& inst, wxMouseEvent& e) { auto s = mkeys.lookup(inst); if(!s) return; - auto sfactors = calc_scale_factors(video_scale_factor, arcorrect_enabled, - (inst.rom->rtype) ? inst.rom->rtype->get_PAR() : 1.0); + auto sfactors = calc_scale_factors(video_scale_factor, arcorrect_enabled, inst.rom->get_PAR()); inst.iqueue->queue(keypress_info(keyboard::modifier_set(), s->mouse_x, e.GetX() / sfactors.first)); inst.iqueue->queue(keypress_info(keyboard::modifier_set(), s->mouse_y, e.GetY() / diff --git a/src/platform/wxwidgets/romselect.cpp b/src/platform/wxwidgets/romselect.cpp index 30e503c5..0c3c0d92 100644 --- a/src/platform/wxwidgets/romselect.cpp +++ b/src/platform/wxwidgets/romselect.cpp @@ -474,7 +474,7 @@ private: void show_projectwindow(wxWindow* modwin, emulator_instance& inst) { - if(!inst.rom->rtype) { + if(inst.rom->isnull()) { show_message_ok(modwin, "Can't start new movie", "No ROM loaded", wxICON_EXCLAMATION); return; } @@ -491,7 +491,7 @@ wxwin_project::wxwin_project(emulator_instance& _inst) { std::vector cchoices; - std::set sram_set = inst.rom->rtype->srams(); + std::set sram_set = inst.rom->srams(); Centre(); //2 Top-level block. @@ -509,7 +509,7 @@ wxwin_project::wxwin_project(emulator_instance& _inst) wxFlexGridSizer* new_sizer = new wxFlexGridSizer(3, 1, 0, 0); new_panel->SetSizer(new_sizer); //Controllertypes/Gamename/initRTC/SRAMs. - auto settingblock = inst.rom->rtype->get_settings().settings; + auto settingblock = inst.rom->get_settings().settings; wxFlexGridSizer* mainblock = new wxFlexGridSizer(4 + settingblock.size() + sram_set.size(), 2, 0, 0); auto _settingblock = sort_settingblock(settingblock); for(auto i : _settingblock) { @@ -645,13 +645,13 @@ struct moviefile& wxwin_project::make_movie() { moviefile& f = *new moviefile; f.force_corrupt = false; - f.gametype = &inst.rom->rtype->combine_region(*inst.rom->region); + f.gametype = &inst.rom->get_sysregion(); for(auto i : settings) { f.settings[i.first] = i.second.read(); if(!i.second.get_setting().validate(f.settings[i.first])) throw std::runtime_error((stringfmt() << "Bad value for setting " << i.first).str()); } - f.coreversion = inst.rom->rtype->get_core_identifier(); + f.coreversion = inst.rom->get_core_identifier(); f.gamename = tostdstring(projectname->GetValue()); f.projectid = get_random_hexstring(40); set_mprefix_for_project(f.projectid, tostdstring(prefix->GetValue())); @@ -682,7 +682,7 @@ struct moviefile& wxwin_project::make_movie() f.movie_rtc_subsecond = f.rtc_subsecond = boost::lexical_cast(tostdstring(rtc_subsec->GetValue())); if(f.movie_rtc_subsecond < 0) throw std::runtime_error("RTC subsecond must be positive"); - auto ctrldata = inst.rom->rtype->controllerconfig(f.settings); + auto ctrldata = inst.rom->controllerconfig(f.settings); port_type_set& ports = port_type_set::make(ctrldata.ports, ctrldata.portindex()); f.create_default_branch(ports); return f; @@ -690,7 +690,7 @@ struct moviefile& wxwin_project::make_movie() void open_new_project_window(wxWindow* parent, emulator_instance& inst) { - if(inst.rom->rtype->isnull()) { + if(inst.rom->isnull()) { show_message_ok(parent, "Can't start new project", "No ROM loaded", wxICON_EXCLAMATION); return; } diff --git a/src/platform/wxwidgets/tracelogmenu.cpp b/src/platform/wxwidgets/tracelogmenu.cpp index 4e040d79..449d9627 100644 --- a/src/platform/wxwidgets/tracelogmenu.cpp +++ b/src/platform/wxwidgets/tracelogmenu.cpp @@ -6,6 +6,8 @@ #include "core/instance.hpp" #include "core/project.hpp" #include "core/moviedata.hpp" +#include "core/rom.hpp" + tracelog_menu::tracelog_menu(wxWindow* win, emulator_instance& _inst, int wxid_low, int wxid_high) : inst(_inst) @@ -50,7 +52,7 @@ void tracelog_menu::on_select(wxCommandEvent& e) void tracelog_menu::update() { - auto _items = inst.rom->rtype->get_trace_cpus(); + auto _items = inst.rom->get_trace_cpus(); for(auto i : items) Delete(i); items.clear(); diff --git a/src/platform/wxwidgets/window-fileupload.cpp b/src/platform/wxwidgets/window-fileupload.cpp index 6e00c5cb..a7346f0c 100644 --- a/src/platform/wxwidgets/window-fileupload.cpp +++ b/src/platform/wxwidgets/window-fileupload.cpp @@ -638,7 +638,7 @@ wxeditor_uploaddialog::wxeditor_uploaddialog(wxWindow* parent, emulator_instance wxCommandEventHandler(wxeditor_uploaddialog::on_source_sel), NULL, this); file->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(wxeditor_uploaddialog::on_source_sel), NULL, this); - if(!inst.mlogic || !inst.rom->rtype || inst.rom->rtype->isnull()) { + if(!inst.mlogic || inst.rom->isnull()) { current->Enable(false); file->SetValue(true); } diff --git a/src/util/lsnes-dumpavi.cpp b/src/util/lsnes-dumpavi.cpp index e7749368..013a9611 100644 --- a/src/util/lsnes-dumpavi.cpp +++ b/src/util/lsnes-dumpavi.cpp @@ -399,7 +399,7 @@ int main(int argc, char** argv) std::map tmp; r = construct_rom(movfn, cmdline); r.load(tmp, 1000000000, 0); - messages << "Using core: " << r.rtype->get_core_identifier() << std::endl; + messages << "Using core: " << r.get_core_identifier() << std::endl; } catch(std::bad_alloc& e) { OOM_panic(); } catch(std::exception& e) { @@ -408,18 +408,18 @@ int main(int argc, char** argv) fatal_error(); exit(1); } - messages << "Detected region: " << r.rtype->combine_region(*r.region).get_name() << std::endl; - lsnes_instance.framerate->set_nominal_framerate(r.region->approx_framerate()); + messages << "Detected region: " << r.get_sysregion().get_name() << std::endl; + lsnes_instance.framerate->set_nominal_framerate(r.region_approx_framerate()); messages << "--- End of Startup --- " << std::endl; moviefile* movie; try { - movie = new moviefile(movfn, *r.rtype); + movie = new moviefile(movfn, r.get_internal_rom_type()); //Load ROM before starting the dumper. *lsnes_instance.rom = r; - messages << "Using core: " << lsnes_instance.rom->rtype->get_core_identifier() << std::endl; - lsnes_instance.rom->region = &movie->gametype->get_region(); + messages << "Using core: " << lsnes_instance.rom->get_core_identifier() << std::endl; + lsnes_instance.rom->set_internal_region(movie->gametype->get_region()); lsnes_instance.rom->load(movie->settings, movie->movie_rtc_second, movie->movie_rtc_subsecond); startup_lua_scripts(cmdline); if(overdump_mode) diff --git a/src/util/lsnes-romloadtest.cpp b/src/util/lsnes-romloadtest.cpp index fcd37b0c..3a976b87 100644 --- a/src/util/lsnes-romloadtest.cpp +++ b/src/util/lsnes-romloadtest.cpp @@ -52,9 +52,9 @@ namespace void dump_what_was_loaded(loaded_rom& r, moviefile& f) { - std::cout << "Core:\t" << r.rtype->get_core_identifier() << std::endl; - std::cout << "System:\t" << r.rtype->get_hname() << std::endl; - std::cout << "Region:\t" << r.region->get_hname() << std::endl; + std::cout << "Core:\t" << r.get_core_identifier() << std::endl; + std::cout << "System:\t" << r.get_hname() << std::endl; + std::cout << "Region:\t" << r.region_get_hname() << std::endl; for(auto i = 0; i < ROM_SLOT_COUNT; i++) { std::string risha = r.romimg[i].sha_256.read(); std::string rxsha = r.romxml[i].sha_256.read(); @@ -165,7 +165,7 @@ int main(int argc, char** argv) moviefile* movie = NULL; try { if(movfn != "") - movie = new moviefile(movfn, *r.rtype); + movie = new moviefile(movfn, r.get_internal_rom_type()); } catch(std::bad_alloc& e) { OOM_panic(); } catch(std::exception& e) { diff --git a/src/video/avi.cpp b/src/video/avi.cpp index 9c6f0615..78e695a1 100644 --- a/src/video/avi.cpp +++ b/src/video/avi.cpp @@ -13,6 +13,7 @@ #include "core/settings.hpp" #include "core/moviedata.hpp" #include "core/moviefile.hpp" +#include "core/rom.hpp" #include #include @@ -408,7 +409,7 @@ again: hscl = fxfact; vscl = fyfact; } else if(dump_large(*core.settings)) { - rpair(hscl, vscl) = core.rom->rtype->get_scale_factors(_frame.get_width(), + rpair(hscl, vscl) = core.rom->get_scale_factors(_frame.get_width(), _frame.get_height()); } if(!render_video_hud(dscr, _frame, fps_n, fps_d, hscl, vscl, dlb(*core.settings), diff --git a/src/video/pipedec.cpp b/src/video/pipedec.cpp index b6608c1d..9a0a4fe6 100644 --- a/src/video/pipedec.cpp +++ b/src/video/pipedec.cpp @@ -4,6 +4,7 @@ #include "core/moviedata.hpp" #include "core/random.hpp" #include "core/messages.hpp" +#include "core/rom.hpp" #include "video/sox.hpp" #include "library/serialization.hpp" #include "library/string.hpp" diff --git a/src/video/raw.cpp b/src/video/raw.cpp index e167bc60..67a42ce8 100644 --- a/src/video/raw.cpp +++ b/src/video/raw.cpp @@ -4,6 +4,7 @@ #include "core/moviedata.hpp" #include "core/moviefile.hpp" #include "core/messages.hpp" +#include "core/rom.hpp" #include "video/tcp.hpp" #include "library/serialization.hpp" #include "library/minmax.hpp" @@ -101,7 +102,7 @@ namespace if(!video) return; uint32_t hscl, vscl; - rpair(hscl, vscl) = core.rom->rtype->get_scale_factors(_frame.get_width(), + rpair(hscl, vscl) = core.rom->get_scale_factors(_frame.get_width(), _frame.get_height()); if(bits64) { size_t w = dscr2.get_width(); -- 2.11.4.GIT