diff options
Diffstat (limited to 'src')
63 files changed, 378 insertions, 426 deletions
diff --git a/src/devices/bus/a7800/a78_slot.cpp b/src/devices/bus/a7800/a78_slot.cpp index 5f6544b5c03..0509753a1c3 100644 --- a/src/devices/bus/a7800/a78_slot.cpp +++ b/src/devices/bus/a7800/a78_slot.cpp @@ -500,7 +500,7 @@ void a78_cart_slot_device::call_unload() bool a78_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/a800/a800_slot.cpp b/src/devices/bus/a800/a800_slot.cpp index bd3d8ec0abe..b2e46a421da 100644 --- a/src/devices/bus/a800/a800_slot.cpp +++ b/src/devices/bus/a800/a800_slot.cpp @@ -305,7 +305,7 @@ void a800_cart_slot_device::call_unload() bool a800_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/adam/exp.cpp b/src/devices/bus/adam/exp.cpp index 29a53947dd2..3c43a400ff0 100644 --- a/src/devices/bus/adam/exp.cpp +++ b/src/devices/bus/adam/exp.cpp @@ -114,7 +114,7 @@ bool adam_expansion_slot_device::call_load() bool adam_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/apf/slot.cpp b/src/devices/bus/apf/slot.cpp index 461c7bd68ef..eb2e17d9f80 100644 --- a/src/devices/bus/apf/slot.cpp +++ b/src/devices/bus/apf/slot.cpp @@ -212,7 +212,7 @@ bool apf_cart_slot_device::call_load() bool apf_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/arcadia/slot.cpp b/src/devices/bus/arcadia/slot.cpp index 3ae3d45c645..3a6aee846ab 100644 --- a/src/devices/bus/arcadia/slot.cpp +++ b/src/devices/bus/arcadia/slot.cpp @@ -220,7 +220,7 @@ bool arcadia_cart_slot_device::call_load() bool arcadia_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/astrocde/slot.cpp b/src/devices/bus/astrocde/slot.cpp index 02d2294b7b5..8ae7bbe8c15 100644 --- a/src/devices/bus/astrocde/slot.cpp +++ b/src/devices/bus/astrocde/slot.cpp @@ -189,7 +189,7 @@ bool astrocade_cart_slot_device::call_load() bool astrocade_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/c64/exp.cpp b/src/devices/bus/c64/exp.cpp index a78706d80cb..47e2a20cc14 100644 --- a/src/devices/bus/c64/exp.cpp +++ b/src/devices/bus/c64/exp.cpp @@ -207,7 +207,7 @@ bool c64_expansion_slot_device::call_load() bool c64_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/cbm2/exp.cpp b/src/devices/bus/cbm2/exp.cpp index f673abc7395..fd4993760c3 100644 --- a/src/devices/bus/cbm2/exp.cpp +++ b/src/devices/bus/cbm2/exp.cpp @@ -145,7 +145,7 @@ bool cbm2_expansion_slot_device::call_load() bool cbm2_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/chanf/slot.cpp b/src/devices/bus/chanf/slot.cpp index 442c5e05c70..72045151cca 100644 --- a/src/devices/bus/chanf/slot.cpp +++ b/src/devices/bus/chanf/slot.cpp @@ -207,7 +207,7 @@ bool channelf_cart_slot_device::call_load() bool channelf_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/coco/cococart.cpp b/src/devices/bus/coco/cococart.cpp index 684f7a5d156..66cbc1dc121 100644 --- a/src/devices/bus/coco/cococart.cpp +++ b/src/devices/bus/coco/cococart.cpp @@ -354,7 +354,7 @@ bool cococart_slot_device::call_load() bool cococart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/coleco/exp.cpp b/src/devices/bus/coleco/exp.cpp index 4da0d060398..05a53b584a5 100644 --- a/src/devices/bus/coleco/exp.cpp +++ b/src/devices/bus/coleco/exp.cpp @@ -102,7 +102,7 @@ bool colecovision_cartridge_slot_device::call_load() bool colecovision_cartridge_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/crvision/slot.cpp b/src/devices/bus/crvision/slot.cpp index 47173a1cf5d..74c9eb28645 100644 --- a/src/devices/bus/crvision/slot.cpp +++ b/src/devices/bus/crvision/slot.cpp @@ -220,7 +220,7 @@ bool crvision_cart_slot_device::call_load() bool crvision_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/gameboy/gb_slot.cpp b/src/devices/bus/gameboy/gb_slot.cpp index 9202bbfb358..55555a8d4b2 100644 --- a/src/devices/bus/gameboy/gb_slot.cpp +++ b/src/devices/bus/gameboy/gb_slot.cpp @@ -457,7 +457,7 @@ void base_gb_cart_slot_device::setup_ram(UINT8 banks) bool base_gb_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/gba/gba_slot.cpp b/src/devices/bus/gba/gba_slot.cpp index 1fa9372faa4..217f3f9e954 100644 --- a/src/devices/bus/gba/gba_slot.cpp +++ b/src/devices/bus/gba/gba_slot.cpp @@ -245,7 +245,7 @@ void gba_cart_slot_device::call_unload() bool gba_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/generic/slot.cpp b/src/devices/bus/generic/slot.cpp index 94644ba728f..4f3af4df411 100644 --- a/src/devices/bus/generic/slot.cpp +++ b/src/devices/bus/generic/slot.cpp @@ -169,7 +169,7 @@ void generic_slot_device::call_unload() bool generic_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/intv/slot.cpp b/src/devices/bus/intv/slot.cpp index daa41e57f7c..87f36e14bac 100644 --- a/src/devices/bus/intv/slot.cpp +++ b/src/devices/bus/intv/slot.cpp @@ -450,7 +450,7 @@ bool intv_cart_slot_device::call_load() bool intv_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/iq151/iq151.cpp b/src/devices/bus/iq151/iq151.cpp index 5f2d522c1d9..3d4ef7abe05 100644 --- a/src/devices/bus/iq151/iq151.cpp +++ b/src/devices/bus/iq151/iq151.cpp @@ -196,7 +196,7 @@ bool iq151cart_slot_device::call_load() bool iq151cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/kc/kc.cpp b/src/devices/bus/kc/kc.cpp index 13bca495f89..a5a46802998 100644 --- a/src/devices/bus/kc/kc.cpp +++ b/src/devices/bus/kc/kc.cpp @@ -362,7 +362,7 @@ bool kccart_slot_device::call_load() bool kccart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/megadrive/md_slot.cpp b/src/devices/bus/megadrive/md_slot.cpp index 92eb9fa1b8f..a2674838914 100644 --- a/src/devices/bus/megadrive/md_slot.cpp +++ b/src/devices/bus/megadrive/md_slot.cpp @@ -677,7 +677,7 @@ void base_md_cart_slot_device::setup_nvram() bool base_md_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/msx_slot/cartridge.cpp b/src/devices/bus/msx_slot/cartridge.cpp index 274e6f1875c..c24df3bf1fb 100644 --- a/src/devices/bus/msx_slot/cartridge.cpp +++ b/src/devices/bus/msx_slot/cartridge.cpp @@ -200,7 +200,7 @@ void msx_slot_cartridge_device::call_unload() bool msx_slot_cartridge_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/neogeo/neogeo_slot.cpp b/src/devices/bus/neogeo/neogeo_slot.cpp index 3f8eea06635..fac43eda050 100644 --- a/src/devices/bus/neogeo/neogeo_slot.cpp +++ b/src/devices/bus/neogeo/neogeo_slot.cpp @@ -195,7 +195,7 @@ void neogeo_cart_slot_device::call_unload() bool neogeo_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/nes/aladdin.cpp b/src/devices/bus/nes/aladdin.cpp index 95834d239aa..bad863b9255 100644 --- a/src/devices/bus/nes/aladdin.cpp +++ b/src/devices/bus/nes/aladdin.cpp @@ -138,7 +138,7 @@ bool nes_aladdin_slot_device::call_load() bool nes_aladdin_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/nes/datach.cpp b/src/devices/bus/nes/datach.cpp index aff526a755f..cdb41e16830 100644 --- a/src/devices/bus/nes/datach.cpp +++ b/src/devices/bus/nes/datach.cpp @@ -139,7 +139,7 @@ bool nes_datach_slot_device::call_load() bool nes_datach_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/nes/karastudio.cpp b/src/devices/bus/nes/karastudio.cpp index 1e9317db284..d9d0e26a2cf 100644 --- a/src/devices/bus/nes/karastudio.cpp +++ b/src/devices/bus/nes/karastudio.cpp @@ -128,7 +128,7 @@ bool nes_kstudio_slot_device::call_load() bool nes_kstudio_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/nes/nes_slot.cpp b/src/devices/bus/nes/nes_slot.cpp index dc9b2e8e639..05adca0f9ae 100644 --- a/src/devices/bus/nes/nes_slot.cpp +++ b/src/devices/bus/nes/nes_slot.cpp @@ -904,7 +904,7 @@ void nes_cart_slot_device::call_unload() bool nes_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/nes/sunsoft_dcs.cpp b/src/devices/bus/nes/sunsoft_dcs.cpp index a4f86e7e781..25d1a1db623 100644 --- a/src/devices/bus/nes/sunsoft_dcs.cpp +++ b/src/devices/bus/nes/sunsoft_dcs.cpp @@ -107,7 +107,7 @@ bool nes_ntb_slot_device::call_load() bool nes_ntb_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/odyssey2/slot.cpp b/src/devices/bus/odyssey2/slot.cpp index 4d540411a7f..0a6e35028b9 100644 --- a/src/devices/bus/odyssey2/slot.cpp +++ b/src/devices/bus/odyssey2/slot.cpp @@ -200,7 +200,7 @@ bool o2_cart_slot_device::call_load() bool o2_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/pce/pce_slot.cpp b/src/devices/bus/pce/pce_slot.cpp index 3ecd0e9cb7b..4fffa5172fc 100644 --- a/src/devices/bus/pce/pce_slot.cpp +++ b/src/devices/bus/pce/pce_slot.cpp @@ -300,7 +300,7 @@ void pce_cart_slot_device::call_unload() bool pce_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/plus4/exp.cpp b/src/devices/bus/plus4/exp.cpp index efea87851e1..47f404cacf4 100644 --- a/src/devices/bus/plus4/exp.cpp +++ b/src/devices/bus/plus4/exp.cpp @@ -147,7 +147,7 @@ bool plus4_expansion_slot_device::call_load() bool plus4_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/ql/rom.cpp b/src/devices/bus/ql/rom.cpp index c15ac21b872..bd17b2cb1b8 100644 --- a/src/devices/bus/ql/rom.cpp +++ b/src/devices/bus/ql/rom.cpp @@ -104,7 +104,7 @@ bool ql_rom_cartridge_slot_t::call_load() bool ql_rom_cartridge_slot_t::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/saturn/sat_slot.cpp b/src/devices/bus/saturn/sat_slot.cpp index d1160c68e29..dba415c8a47 100644 --- a/src/devices/bus/saturn/sat_slot.cpp +++ b/src/devices/bus/saturn/sat_slot.cpp @@ -210,7 +210,7 @@ void sat_cart_slot_device::call_unload() bool sat_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/scv/slot.cpp b/src/devices/bus/scv/slot.cpp index 6cb7157b5bb..15495afe918 100644 --- a/src/devices/bus/scv/slot.cpp +++ b/src/devices/bus/scv/slot.cpp @@ -216,7 +216,7 @@ bool scv_cart_slot_device::call_load() bool scv_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/sega8/sega8_slot.cpp b/src/devices/bus/sega8/sega8_slot.cpp index 9f85e6b810c..df3c59adc05 100644 --- a/src/devices/bus/sega8/sega8_slot.cpp +++ b/src/devices/bus/sega8/sega8_slot.cpp @@ -421,7 +421,7 @@ void sega8_cart_slot_device::call_unload() bool sega8_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/snes/snes_slot.cpp b/src/devices/bus/snes/snes_slot.cpp index 15d68f41afe..65c2fffdb4d 100644 --- a/src/devices/bus/snes/snes_slot.cpp +++ b/src/devices/bus/snes/snes_slot.cpp @@ -886,7 +886,7 @@ void base_sns_cart_slot_device::setup_nvram() bool base_sns_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/ti99x/gromport.cpp b/src/devices/bus/ti99x/gromport.cpp index a93fd2054de..9e1533cb9a8 100644 --- a/src/devices/bus/ti99x/gromport.cpp +++ b/src/devices/bus/ti99x/gromport.cpp @@ -1393,7 +1393,7 @@ void ti99_cartridge_device::set_slot(int i) bool ti99_cartridge_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { if (TRACE_CONFIG) logerror("%s: swlist = %s, swname = %s\n", tag(), swlist.list_name(), swname); - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); m_softlist = true; m_rpk = nullptr; return true; diff --git a/src/devices/bus/vboy/slot.cpp b/src/devices/bus/vboy/slot.cpp index 151d6f93ef0..4b8fc1bf4d2 100644 --- a/src/devices/bus/vboy/slot.cpp +++ b/src/devices/bus/vboy/slot.cpp @@ -223,7 +223,7 @@ void vboy_cart_slot_device::call_unload() bool vboy_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/vc4000/slot.cpp b/src/devices/bus/vc4000/slot.cpp index f7f8b797cfb..0b67a264c34 100644 --- a/src/devices/bus/vc4000/slot.cpp +++ b/src/devices/bus/vc4000/slot.cpp @@ -226,7 +226,7 @@ bool vc4000_cart_slot_device::call_load() bool vc4000_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/vcs/vcs_slot.cpp b/src/devices/bus/vcs/vcs_slot.cpp index f37c00a1f97..b946c8051e7 100755 --- a/src/devices/bus/vcs/vcs_slot.cpp +++ b/src/devices/bus/vcs/vcs_slot.cpp @@ -333,7 +333,7 @@ void vcs_cart_slot_device::call_unload() bool vcs_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/bus/vectrex/slot.cpp b/src/devices/bus/vectrex/slot.cpp index eadf505484a..1a9bbed7d29 100644 --- a/src/devices/bus/vectrex/slot.cpp +++ b/src/devices/bus/vectrex/slot.cpp @@ -208,7 +208,7 @@ bool vectrex_cart_slot_device::call_load() bool vectrex_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/vic10/exp.cpp b/src/devices/bus/vic10/exp.cpp index 9a4ab019eb2..1aa6f2e6363 100644 --- a/src/devices/bus/vic10/exp.cpp +++ b/src/devices/bus/vic10/exp.cpp @@ -172,7 +172,7 @@ bool vic10_expansion_slot_device::call_load() bool vic10_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/vic20/exp.cpp b/src/devices/bus/vic20/exp.cpp index 946405a13eb..37761ab7d14 100644 --- a/src/devices/bus/vic20/exp.cpp +++ b/src/devices/bus/vic20/exp.cpp @@ -157,7 +157,7 @@ bool vic20_expansion_slot_device::call_load() bool vic20_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/vidbrain/exp.cpp b/src/devices/bus/vidbrain/exp.cpp index a2044481a6a..2b4ac800ff3 100644 --- a/src/devices/bus/vidbrain/exp.cpp +++ b/src/devices/bus/vidbrain/exp.cpp @@ -144,7 +144,7 @@ bool videobrain_expansion_slot_device::call_load() bool videobrain_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return true; } diff --git a/src/devices/bus/wswan/slot.cpp b/src/devices/bus/wswan/slot.cpp index 372a40a851a..b5b95851f00 100644 --- a/src/devices/bus/wswan/slot.cpp +++ b/src/devices/bus/wswan/slot.cpp @@ -243,7 +243,7 @@ void ws_cart_slot_device::call_unload() bool ws_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry); return TRUE; } diff --git a/src/devices/bus/z88/z88.cpp b/src/devices/bus/z88/z88.cpp index 647ea838fed..7af6b781369 100644 --- a/src/devices/bus/z88/z88.cpp +++ b/src/devices/bus/z88/z88.cpp @@ -174,7 +174,7 @@ void z88cart_slot_device::call_unload() bool z88cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { - load_software_part_region(*this, swlist, swname, start_entry ); + machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } diff --git a/src/devices/imagedev/chd_cd.cpp b/src/devices/imagedev/chd_cd.cpp index 83845d026b8..d9ab295dfad 100644 --- a/src/devices/imagedev/chd_cd.cpp +++ b/src/devices/imagedev/chd_cd.cpp @@ -79,7 +79,7 @@ const option_guide *cdrom_image_device::create_option_guide() const void cdrom_image_device::device_start() { // try to locate the CHD from a DISK_REGION - chd_file *chd = get_disk_handle( machine(), owner()->tag() ); + chd_file *chd = machine().rom_load().get_disk_handle(owner()->tag() ); if( chd != nullptr ) { m_cdrom_handle = cdrom_open( chd ); @@ -115,7 +115,7 @@ bool cdrom_image_device::call_load() chd = &m_self_chd; } } else { - chd = get_disk_handle(device().machine(), device().subtag("cdrom").c_str()); + chd = device().machine().rom_load().get_disk_handle(device().subtag("cdrom").c_str()); } /* open the CHD file */ diff --git a/src/devices/imagedev/chd_cd.h b/src/devices/imagedev/chd_cd.h index 5303b474045..5d229a471b4 100644 --- a/src/devices/imagedev/chd_cd.h +++ b/src/devices/imagedev/chd_cd.h @@ -33,7 +33,7 @@ public: // image-level overrides virtual bool call_load() override; virtual void call_unload() override; - virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) override { load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } + virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) override { machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } virtual iodevice_t image_type() const override { return IO_CDROM; } diff --git a/src/devices/imagedev/diablo.cpp b/src/devices/imagedev/diablo.cpp index 9982463fd08..be8b3e500f2 100644 --- a/src/devices/imagedev/diablo.cpp +++ b/src/devices/imagedev/diablo.cpp @@ -76,7 +76,7 @@ void diablo_image_device::device_start() m_chd = nullptr; // try to locate the CHD from a DISK_REGION - chd_file *handle = get_disk_handle(machine(), tag()); + chd_file *handle = machine().rom_load().get_disk_handle(tag()); if (handle != nullptr) { m_hard_disk_handle = hard_disk_open(handle); @@ -217,7 +217,7 @@ int diablo_image_device::internal_load_dsk() /* open the CHD file */ if (software_entry() != nullptr) { - m_chd = get_disk_handle(device().machine(), device().subtag("harddriv").c_str()); + m_chd = device().machine().rom_load().get_disk_handle(device().subtag("harddriv").c_str()); } else { diff --git a/src/devices/imagedev/diablo.h b/src/devices/imagedev/diablo.h index 6cc5530e534..00df1345bbd 100644 --- a/src/devices/imagedev/diablo.h +++ b/src/devices/imagedev/diablo.h @@ -33,7 +33,7 @@ public: virtual bool call_load() override; virtual bool call_create(int create_format, option_resolution *create_args) override; virtual void call_unload() override; - virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) override { load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } + virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) override { device().machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } virtual iodevice_t image_type() const override { return IO_HARDDISK; } diff --git a/src/devices/imagedev/harddriv.cpp b/src/devices/imagedev/harddriv.cpp index 8b0ea459be5..b5fd6ca87dc 100644 --- a/src/devices/imagedev/harddriv.cpp +++ b/src/devices/imagedev/harddriv.cpp @@ -99,7 +99,7 @@ void harddisk_image_device::device_start() m_chd = nullptr; // try to locate the CHD from a DISK_REGION - chd_file *handle = get_disk_handle(machine(), tag()); + chd_file *handle = machine().rom_load().get_disk_handle(tag()); if (handle != nullptr) { m_hard_disk_handle = hard_disk_open(handle); @@ -241,7 +241,7 @@ int harddisk_image_device::internal_load_hd() /* open the CHD file */ if (software_entry() != nullptr) { - m_chd = get_disk_handle(device().machine(), device().subtag("harddriv").c_str()); + m_chd = machine().rom_load().get_disk_handle(device().subtag("harddriv").c_str()); } else { diff --git a/src/devices/imagedev/harddriv.h b/src/devices/imagedev/harddriv.h index 7c3da504a5a..b85418e8c33 100644 --- a/src/devices/imagedev/harddriv.h +++ b/src/devices/imagedev/harddriv.h @@ -35,7 +35,7 @@ public: virtual bool call_load() override; virtual bool call_create(int create_format, option_resolution *create_args) override; virtual void call_unload() override; - virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) override { load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } + virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) override { machine().rom_load().load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; } virtual iodevice_t image_type() const override { return IO_HARDDISK; } diff --git a/src/devices/machine/akiko.cpp b/src/devices/machine/akiko.cpp index 07baf8b55ad..6a2772187f8 100644 --- a/src/devices/machine/akiko.cpp +++ b/src/devices/machine/akiko.cpp @@ -170,7 +170,7 @@ void akiko_device::device_reset() else { // MAME case - m_cdrom = cdrom_open(get_disk_handle(machine(), ":cdrom")); + m_cdrom = cdrom_open(machine().rom_load().get_disk_handle(":cdrom")); m_cdrom_is_device = 0; } diff --git a/src/devices/machine/laserdsc.cpp b/src/devices/machine/laserdsc.cpp index 861565bafe5..50e6dc09836 100644 --- a/src/devices/machine/laserdsc.cpp +++ b/src/devices/machine/laserdsc.cpp @@ -737,7 +737,7 @@ void laserdisc_device::init_disc() if (!m_getdisc_callback.isnull()) m_disc = m_getdisc_callback(*this); else - m_disc = get_disk_handle(machine(), tag()); + m_disc = machine().rom_load().get_disk_handle(tag()); // set default parameters m_width = 720; diff --git a/src/devices/machine/stvcd.cpp b/src/devices/machine/stvcd.cpp index d2734007222..5ec8fb7c95f 100644 --- a/src/devices/machine/stvcd.cpp +++ b/src/devices/machine/stvcd.cpp @@ -1483,7 +1483,7 @@ void saturn_state::stvcd_reset( void ) else { // MAME case - cdrom = cdrom_open(get_disk_handle(machine(), "cdrom")); + cdrom = cdrom_open(machine().rom_load().get_disk_handle("cdrom")); } machine().device<cdda_device>("cdda")->set_cdrom(cdrom); @@ -2678,7 +2678,7 @@ void saturn_state::stvcd_set_tray_close( void ) else { // MAME case - cdrom = cdrom_open(get_disk_handle(machine(), "cdrom")); + cdrom = cdrom_open(machine().rom_load().get_disk_handle("cdrom")); } machine().device<cdda_device>("cdda")->set_cdrom(cdrom); diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index ed29e9f4907..6b1ba218dfd 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -118,7 +118,6 @@ running_machine::running_machine(const machine_config &_config, machine_manager : firstcpu(nullptr), primary_screen(nullptr), debug_flags(0), - romload_data(nullptr), debugcpu_data(nullptr), m_config(_config), m_system(_config.gamedrv()), @@ -249,7 +248,7 @@ void running_machine::start() // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order - rom_init(*this); + m_rom_load = make_unique_clear<rom_load_manager>(*this); m_memory.initialize(); // initialize the watchdog diff --git a/src/emu/machine.h b/src/emu/machine.h index 1717e5896b5..8f5d1f05d39 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -92,10 +92,10 @@ class output_manager; class ui_input_manager; class crosshair_manager; class image_manager; +class rom_load_manager; class osd_interface; enum class config_type; -struct romload_private; struct debugcpu_private; @@ -177,6 +177,7 @@ public: ui_input_manager &ui_input() const { assert(m_ui_input != nullptr); return *m_ui_input; } crosshair_manager &crosshair() const { assert(m_crosshair != nullptr); return *m_crosshair; } image_manager &image() const { assert(m_image != nullptr); return *m_image; } + rom_load_manager &rom_load() const { assert(m_rom_load != nullptr); return *m_rom_load; } tilemap_manager &tilemap() const { assert(m_tilemap != nullptr); return *m_tilemap; } debug_view_manager &debug_view() const { assert(m_debug_view != nullptr); return *m_debug_view; } driver_device *driver_data() const { return &downcast<driver_device &>(root_device()); } @@ -248,7 +249,6 @@ public: UINT32 debug_flags; // the current debug flags // internal core information - romload_private * romload_data; // internal data from romload.c debugcpu_private * debugcpu_data; // internal data from debugcpu.c private: @@ -281,21 +281,22 @@ private: const game_driver & m_system; // reference to the definition of the game machine machine_manager & m_manager; // reference to machine manager system // managers - std::unique_ptr<cheat_manager> m_cheat; // internal data from cheat.c - std::unique_ptr<render_manager> m_render; // internal data from render.c - std::unique_ptr<input_manager> m_input; // internal data from input.c - std::unique_ptr<sound_manager> m_sound; // internal data from sound.c - std::unique_ptr<video_manager> m_video; // internal data from video.c - std::unique_ptr<ui_manager> m_ui; // internal data from ui.c - std::unique_ptr<ui_input_manager> m_ui_input; // internal data from uiinput.c - std::unique_ptr<tilemap_manager> m_tilemap; // internal data from tilemap.c - std::unique_ptr<debug_view_manager> m_debug_view; // internal data from debugvw.c - std::unique_ptr<network_manager> m_network; // internal data from network.c - std::unique_ptr<bookkeeping_manager> m_bookkeeping;// internal data from bookkeeping.c - std::unique_ptr<configuration_manager> m_configuration; // internal data from config.c - std::unique_ptr<output_manager> m_output; // internal data from output.c - std::unique_ptr<crosshair_manager> m_crosshair; // internal data from crsshair.c - std::unique_ptr<image_manager> m_image; // internal data from image.c + std::unique_ptr<cheat_manager> m_cheat; // internal data from cheat.cpp + std::unique_ptr<render_manager> m_render; // internal data from render.cpp + std::unique_ptr<input_manager> m_input; // internal data from input.cpp + std::unique_ptr<sound_manager> m_sound; // internal data from sound.cpp + std::unique_ptr<video_manager> m_video; // internal data from video.cpp + std::unique_ptr<ui_manager> m_ui; // internal data from ui.cpp + std::unique_ptr<ui_input_manager> m_ui_input; // internal data from uiinput.cpp + std::unique_ptr<tilemap_manager> m_tilemap; // internal data from tilemap.cpp + std::unique_ptr<debug_view_manager> m_debug_view; // internal data from debugvw.cpp + std::unique_ptr<network_manager> m_network; // internal data from network.cpp + std::unique_ptr<bookkeeping_manager> m_bookkeeping;// internal data from bookkeeping.cpp + std::unique_ptr<configuration_manager> m_configuration; // internal data from config.cpp + std::unique_ptr<output_manager> m_output; // internal data from output.cpp + std::unique_ptr<crosshair_manager> m_crosshair; // internal data from crsshair.cpp + std::unique_ptr<image_manager> m_image; // internal data from image.cpp + std::unique_ptr<rom_load_manager> m_rom_load; // internal data from romload.cpp // system state machine_phase m_current_phase; // current execution phase diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp index 11af35dcdf2..c62a37b5fa9 100644 --- a/src/emu/romload.cpp +++ b/src/emu/romload.cpp @@ -10,7 +10,6 @@ #include "emu.h" #include "emuopts.h" #include "drivenum.h" -#include "chd.h" #include "softlist.h" #include "ui/ui.h" @@ -25,68 +24,8 @@ #define TEMPBUFFER_MAX_SIZE (1024 * 1024 * 1024) - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -class open_chd -{ - friend class simple_list<open_chd>; - -public: - open_chd(const char *region) - : m_next(nullptr), - m_region(region) { } - - open_chd *next() const { return m_next; } - const char *region() const { return m_region.c_str(); } - chd_file &chd() { return m_diffchd.opened() ? m_diffchd : m_origchd; } - chd_file &orig_chd() { return m_origchd; } - chd_file &diff_chd() { return m_diffchd; } - -private: - open_chd * m_next; /* pointer to next in the list */ - std::string m_region; /* disk region we came from */ - chd_file m_origchd; /* handle to the original CHD */ - chd_file m_diffchd; /* handle to the diff CHD */ -}; - - -struct romload_private -{ - running_machine &machine() const { assert(m_machine != nullptr); return *m_machine; } - - running_machine *m_machine; /* machine object where needed */ - - int warnings; /* warning count during processing */ - int knownbad; /* BAD_DUMP/NO_DUMP count during processing */ - int errors; /* error count during processing */ - - int romsloaded; /* current ROMs loaded count */ - int romstotal; /* total number of ROMs to read */ - UINT32 romsloadedsize; /* total size of ROMs loaded so far */ - UINT32 romstotalsize; /* total size of ROMs to read */ - - emu_file * file; /* current file */ - simple_list<open_chd> chd_list; /* disks */ - - memory_region * region; /* info about current region */ - - std::string errorstring; /* error string */ - std::string softwarningstring; /* software warning string */ -}; - - /*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -static void rom_exit(running_machine &machine); - -/*************************************************************************** - HELPERS (also used by devimage.c) + HELPERS (also used by diimage.cpp) ***************************************************************************/ file_error common_process_file(emu_options &options, const char *location, const char *ext, const rom_entry *romp, emu_file &image_file) @@ -119,43 +58,6 @@ file_error common_process_file(emu_options &options, const char *location, bool return filerr; } - -/*************************************************************************** - HARD DISK HANDLING -***************************************************************************/ - -/*------------------------------------------------- - get_disk_handle - return a pointer to the - CHD file associated with the given region --------------------------------------------------*/ - -chd_file *get_disk_handle(running_machine &machine, const char *region) -{ - for (open_chd *curdisk = machine.romload_data->chd_list.first(); curdisk != nullptr; curdisk = curdisk->next()) - if (strcmp(curdisk->region(), region) == 0) - return &curdisk->chd(); - return nullptr; -} - - -/*------------------------------------------------- - set_disk_handle - set a pointer to the CHD - file associated with the given region --------------------------------------------------*/ - -int set_disk_handle(running_machine &machine, const char *region, const char *fullpath) -{ - auto chd = global_alloc(open_chd(region)); - chd_error err = chd->orig_chd().open(fullpath); - if (err == CHDERR_NONE) - machine.romload_data->chd_list.append(*chd); - else - global_free(chd); - return err; -} - - - /*************************************************************************** ROM LOADING ***************************************************************************/ @@ -328,12 +230,46 @@ static void CLIB_DECL ATTR_PRINTF(1,2) debugload(const char *string, ...) } +/*************************************************************************** + HARD DISK HANDLING +***************************************************************************/ + +/*------------------------------------------------- + get_disk_handle - return a pointer to the + CHD file associated with the given region +-------------------------------------------------*/ + +chd_file *rom_load_manager::get_disk_handle(const char *region) +{ + for (open_chd *curdisk = m_chd_list.first(); curdisk != nullptr; curdisk = curdisk->next()) + if (strcmp(curdisk->region(), region) == 0) + return &curdisk->chd(); + return nullptr; +} + + +/*------------------------------------------------- + set_disk_handle - set a pointer to the CHD + file associated with the given region +-------------------------------------------------*/ + +int rom_load_manager::set_disk_handle(const char *region, const char *fullpath) +{ + auto chd = global_alloc(open_chd(region)); + chd_error err = chd->orig_chd().open(fullpath); + if (err == CHDERR_NONE) + m_chd_list.append(*chd); + else + global_free(chd); + return err; +} + /*------------------------------------------------- determine_bios_rom - determine system_bios from SystemBios structure and OPTION_BIOS -------------------------------------------------*/ -static void determine_bios_rom(romload_private *romdata, device_t *device, const char *specbios) +void rom_load_manager::determine_bios_rom(device_t *device, const char *specbios) { const char *defaultname = nullptr; const rom_entry *rom; @@ -368,10 +304,10 @@ static void determine_bios_rom(romload_private *romdata, device_t *device, const if (device->system_bios() == 0 && bios_count > 0) { /* if we got neither an empty string nor 'default' then warn the user */ - if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != nullptr) + if (specbios[0] != 0 && strcmp(specbios, "default") != 0) { - strcatprintf(romdata->errorstring, "%s: invalid bios\n", specbios); - romdata->errors++; + strcatprintf(m_errorstring, "%s: invalid bios\n", specbios); + m_errors++; } /* set to default */ @@ -387,23 +323,23 @@ static void determine_bios_rom(romload_private *romdata, device_t *device, const that will need to be loaded -------------------------------------------------*/ -static void count_roms(romload_private *romdata) +void rom_load_manager::count_roms() { const rom_entry *region, *rom; /* start with 0 */ - romdata->romstotal = 0; - romdata->romstotalsize = 0; + m_romstotal = 0; + m_romstotalsize = 0; /* loop over regions, then over files */ - device_iterator deviter(romdata->machine().config().root_device()); + device_iterator deviter(machine().config().root_device()); for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) for (rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == device->system_bios()) { - romdata->romstotal++; - romdata->romstotalsize += rom_file_size(rom); + m_romstotal++; + m_romstotalsize += rom_file_size(rom); } } @@ -413,10 +349,10 @@ static void count_roms(romload_private *romdata) random data -------------------------------------------------*/ -static void fill_random(running_machine &machine, UINT8 *base, UINT32 length) +void rom_load_manager::fill_random(UINT8 *base, UINT32 length) { while (length--) - *base++ = machine.rand(); + *base++ = machine().rand(); } @@ -425,7 +361,7 @@ static void fill_random(running_machine &machine, UINT8 *base, UINT32 length) for missing files -------------------------------------------------*/ -static void handle_missing_file(romload_private *romdata, const rom_entry *romp, std::string tried_file_names, chd_error chderr) +void rom_load_manager::handle_missing_file(const rom_entry *romp, std::string tried_file_names, chd_error chderr) { if(tried_file_names.length() != 0) tried_file_names = " (tried in " + tried_file_names + ")"; @@ -438,30 +374,30 @@ static void handle_missing_file(romload_private *romdata, const rom_entry *romp, bool is_chd_error = (is_chd && chderr != CHDERR_FILE_NOT_FOUND); if (is_chd_error) - strcatprintf(romdata->errorstring, "%s CHD ERROR: %s\n", name.c_str(), chd_file::error_string(chderr)); + strcatprintf(m_errorstring, "%s CHD ERROR: %s\n", name.c_str(), chd_file::error_string(chderr)); /* optional files are okay */ if (ROM_ISOPTIONAL(romp)) { if (!is_chd_error) - strcatprintf(romdata->errorstring, "OPTIONAL %s NOT FOUND%s\n", name.c_str(), tried_file_names.c_str()); - romdata->warnings++; + strcatprintf(m_errorstring, "OPTIONAL %s NOT FOUND%s\n", name.c_str(), tried_file_names.c_str()); + m_warnings++; } /* no good dumps are okay */ else if (hash_collection(ROM_GETHASHDATA(romp)).flag(hash_collection::FLAG_NO_DUMP)) { if (!is_chd_error) - strcatprintf(romdata->errorstring, "%s NOT FOUND (NO GOOD DUMP KNOWN)%s\n", name.c_str(), tried_file_names.c_str()); - romdata->knownbad++; + strcatprintf(m_errorstring, "%s NOT FOUND (NO GOOD DUMP KNOWN)%s\n", name.c_str(), tried_file_names.c_str()); + m_knownbad++; } /* anything else is bad */ else { if (!is_chd_error) - strcatprintf(romdata->errorstring, "%s NOT FOUND%s\n", name.c_str(), tried_file_names.c_str()); - romdata->errors++; + strcatprintf(m_errorstring, "%s NOT FOUND%s\n", name.c_str(), tried_file_names.c_str()); + m_errors++; } } @@ -472,10 +408,10 @@ static void handle_missing_file(romload_private *romdata, const rom_entry *romp, correct checksums for a given ROM -------------------------------------------------*/ -static void dump_wrong_and_correct_checksums(romload_private *romdata, const hash_collection &hashes, const hash_collection &acthashes) +void rom_load_manager::dump_wrong_and_correct_checksums(const hash_collection &hashes, const hash_collection &acthashes) { - strcatprintf(romdata->errorstring, " EXPECTED: %s\n", hashes.macro_string().c_str()); - strcatprintf(romdata->errorstring, " FOUND: %s\n", acthashes.macro_string().c_str()); + strcatprintf(m_errorstring, " EXPECTED: %s\n", hashes.macro_string().c_str()); + strcatprintf(m_errorstring, " FOUND: %s\n", acthashes.macro_string().c_str()); } @@ -484,40 +420,40 @@ static void dump_wrong_and_correct_checksums(romload_private *romdata, const has and hash signatures of a file -------------------------------------------------*/ -static void verify_length_and_hash(romload_private *romdata, const char *name, UINT32 explength, const hash_collection &hashes) +void rom_load_manager::verify_length_and_hash(const char *name, UINT32 explength, const hash_collection &hashes) { /* we've already complained if there is no file */ - if (romdata->file == nullptr) + if (m_file == nullptr) return; /* verify length */ - UINT32 actlength = romdata->file->size(); + UINT32 actlength = m_file->size(); if (explength != actlength) { - strcatprintf(romdata->errorstring, "%s WRONG LENGTH (expected: %08x found: %08x)\n", name, explength, actlength); - romdata->warnings++; + strcatprintf(m_errorstring, "%s WRONG LENGTH (expected: %08x found: %08x)\n", name, explength, actlength); + m_warnings++; } /* If there is no good dump known, write it */ - hash_collection &acthashes = romdata->file->hashes(hashes.hash_types().c_str()); + hash_collection &acthashes = m_file->hashes(hashes.hash_types().c_str()); if (hashes.flag(hash_collection::FLAG_NO_DUMP)) { - strcatprintf(romdata->errorstring, "%s NO GOOD DUMP KNOWN\n", name); - romdata->knownbad++; + strcatprintf(m_errorstring, "%s NO GOOD DUMP KNOWN\n", name); + m_knownbad++; } /* verify checksums */ else if (hashes != acthashes) { /* otherwise, it's just bad */ - strcatprintf(romdata->errorstring, "%s WRONG CHECKSUMS:\n", name); - dump_wrong_and_correct_checksums(romdata, hashes, acthashes); - romdata->warnings++; + strcatprintf(m_errorstring, "%s WRONG CHECKSUMS:\n", name); + dump_wrong_and_correct_checksums(hashes, acthashes); + m_warnings++; } /* If it matches, but it is actually a bad dump, write it */ else if (hashes.flag(hash_collection::FLAG_BAD_DUMP)) { - strcatprintf(romdata->errorstring, "%s ROM NEEDS REDUMP\n",name); - romdata->knownbad++; + strcatprintf(m_errorstring, "%s ROM NEEDS REDUMP\n",name); + m_knownbad++; } } @@ -527,17 +463,17 @@ static void verify_length_and_hash(romload_private *romdata, const char *name, U messages about ROM loading to the user -------------------------------------------------*/ -static void display_loading_rom_message(romload_private *romdata, const char *name, bool from_list) +void rom_load_manager::display_loading_rom_message(const char *name, bool from_list) { char buffer[200]; if (name != nullptr) - sprintf(buffer, "Loading %s (%d%%)", from_list ? "Software" : emulator_info::get_capstartgamenoun(), (UINT32)(100 * (UINT64)romdata->romsloadedsize / (UINT64)romdata->romstotalsize)); + sprintf(buffer, "Loading %s (%d%%)", from_list ? "Software" : emulator_info::get_capstartgamenoun(), (UINT32)(100 * (UINT64)m_romsloadedsize / (UINT64)m_romstotalsize)); else sprintf(buffer, "Loading Complete"); - if (!romdata->machine().ui().is_menu_active()) - romdata->machine().ui().set_startup_text(buffer, false); + if (!machine().ui().is_menu_active()) + machine().ui().set_startup_text(buffer, false); } @@ -546,26 +482,26 @@ static void display_loading_rom_message(romload_private *romdata, const char *na results of ROM loading -------------------------------------------------*/ -static void display_rom_load_results(romload_private *romdata, bool from_list) +void rom_load_manager::display_rom_load_results(bool from_list) { /* final status display */ - display_loading_rom_message(romdata, nullptr, from_list); + display_loading_rom_message(nullptr, from_list); /* if we had errors, they are fatal */ - if (romdata->errors != 0) + if (m_errors != 0) { /* create the error message and exit fatally */ - osd_printf_error("%s", romdata->errorstring.c_str()); - fatalerror_exitcode(romdata->machine(), MAMERR_MISSING_FILES, "Required files are missing, the %s cannot be run.",emulator_info::get_gamenoun()); + osd_printf_error("%s", m_errorstring.c_str()); + fatalerror_exitcode(machine(), MAMERR_MISSING_FILES, "Required files are missing, the %s cannot be run.",emulator_info::get_gamenoun()); } /* if we had warnings, output them, but continue */ - if ((romdata-> warnings) || (romdata->knownbad)) + if ((m_warnings) || (m_knownbad)) { - romdata->errorstring.append("WARNING: the "); - romdata->errorstring.append(emulator_info::get_gamenoun()); - romdata->errorstring.append(" might not run correctly."); - osd_printf_warning("%s\n", romdata->errorstring.c_str()); + m_errorstring.append("WARNING: the "); + m_errorstring.append(emulator_info::get_gamenoun()); + m_errorstring.append(" might not run correctly."); + osd_printf_warning("%s\n", m_errorstring.c_str()); } } @@ -575,9 +511,9 @@ static void display_rom_load_results(romload_private *romdata, bool from_list) byte swapping and inverting data as necessary -------------------------------------------------*/ -static void region_post_process(romload_private *romdata, const char *rgntag, bool invert) +void rom_load_manager::region_post_process(const char *rgntag, bool invert) { - memory_region *region = romdata->machine().root_device().memregion(rgntag); + memory_region *region = machine().root_device().memregion(rgntag); UINT8 *base; int i, j; @@ -617,14 +553,14 @@ static void region_post_process(romload_private *romdata, const char *rgntag, bo up the parent and loading by checksum -------------------------------------------------*/ -static int open_rom_file(romload_private *romdata, const char *regiontag, const rom_entry *romp, std::string &tried_file_names, bool from_list) +int rom_load_manager::open_rom_file(const char *regiontag, const rom_entry *romp, std::string &tried_file_names, bool from_list) { file_error filerr = FILERR_NOT_FOUND; UINT32 romsize = rom_file_size(romp); tried_file_names = ""; /* update status display */ - display_loading_rom_message(romdata, ROM_GETNAME(romp), from_list); + display_loading_rom_message(ROM_GETNAME(romp), from_list); /* extract CRC to use for searching */ UINT32 crc = 0; @@ -632,16 +568,16 @@ static int open_rom_file(romload_private *romdata, const char *regiontag, const /* attempt reading up the chain through the parents. It automatically also attempts any kind of load by checksum supported by the archives. */ - romdata->file = nullptr; - for (int drv = driver_list::find(romdata->machine().system()); romdata->file == nullptr && drv != -1; drv = driver_list::clone(drv)) { + m_file = nullptr; + for (int drv = driver_list::find(machine().system()); m_file == nullptr && drv != -1; drv = driver_list::clone(drv)) { if (tried_file_names.length() != 0) tried_file_names += " "; tried_file_names += driver_list::driver(drv).name; - filerr = common_process_file(romdata->machine().options(), driver_list::driver(drv).name, has_crc, crc, romp, &romdata->file); + filerr = common_process_file(machine().options(), driver_list::driver(drv).name, has_crc, crc, romp, &m_file); } /* if the region is load by name, load the ROM from there */ - if (romdata->file == nullptr && regiontag != nullptr) + if (m_file == nullptr && regiontag != nullptr) { // check if we are dealing with softwarelists. if so, locationtag // is actually a concatenation of: listname + setname + parentname @@ -690,40 +626,40 @@ static int open_rom_file(romload_private *romdata, const char *regiontag, const if (!is_list) { tried_file_names += " " + tag1; - filerr = common_process_file(romdata->machine().options(), tag1.c_str(), has_crc, crc, romp, &romdata->file); + filerr = common_process_file(machine().options(), tag1.c_str(), has_crc, crc, romp, &m_file); } else { // try to load from list/setname - if ((romdata->file == nullptr) && (tag2.c_str() != nullptr)) + if ((m_file == nullptr) && (tag2.c_str() != nullptr)) { tried_file_names += " " + tag2; - filerr = common_process_file(romdata->machine().options(), tag2.c_str(), has_crc, crc, romp, &romdata->file); + filerr = common_process_file(machine().options(), tag2.c_str(), has_crc, crc, romp, &m_file); } // try to load from list/parentname - if ((romdata->file == nullptr) && has_parent && (tag3.c_str() != nullptr)) + if ((m_file == nullptr) && has_parent && (tag3.c_str() != nullptr)) { tried_file_names += " " + tag3; - filerr = common_process_file(romdata->machine().options(), tag3.c_str(), has_crc, crc, romp, &romdata->file); + filerr = common_process_file(machine().options(), tag3.c_str(), has_crc, crc, romp, &m_file); } // try to load from setname - if ((romdata->file == nullptr) && (tag4.c_str() != nullptr)) + if ((m_file == nullptr) && (tag4.c_str() != nullptr)) { tried_file_names += " " + tag4; - filerr = common_process_file(romdata->machine().options(), tag4.c_str(), has_crc, crc, romp, &romdata->file); + filerr = common_process_file(machine().options(), tag4.c_str(), has_crc, crc, romp, &m_file); } // try to load from parentname - if ((romdata->file == nullptr) && has_parent && (tag5.c_str() != nullptr)) + if ((m_file == nullptr) && has_parent && (tag5.c_str() != nullptr)) { tried_file_names += " " + tag5; - filerr = common_process_file(romdata->machine().options(), tag5.c_str(), has_crc, crc, romp, &romdata->file); + filerr = common_process_file(machine().options(), tag5.c_str(), has_crc, crc, romp, &m_file); } } } /* update counters */ - romdata->romsloaded++; - romdata->romsloadedsize += romsize; + m_romsloaded++; + m_romsloadedsize += romsize; /* return the result */ return (filerr == FILERR_NONE); @@ -735,15 +671,15 @@ static int open_rom_file(romload_private *romdata, const char *regiontag, const random data for a NULL file -------------------------------------------------*/ -static int rom_fread(romload_private *romdata, UINT8 *buffer, int length, const rom_entry *parent_region) +int rom_load_manager::rom_fread(UINT8 *buffer, int length, const rom_entry *parent_region) { /* files just pass through */ - if (romdata->file != nullptr) - return romdata->file->read(buffer, length); + if (m_file != nullptr) + return m_file->read(buffer, length); /* otherwise, fill with randomness unless it was already specifically erased */ else if (!ROMREGION_ISERASE(parent_region)) - fill_random(romdata->machine(), buffer, length); + fill_random(buffer, length); return length; } @@ -754,7 +690,7 @@ static int rom_fread(romload_private *romdata, UINT8 *buffer, int length, const entry -------------------------------------------------*/ -static int read_rom_data(romload_private *romdata, const rom_entry *parent_region, const rom_entry *romp) +int rom_load_manager::read_rom_data(const rom_entry *parent_region, const rom_entry *romp) { int datashift = ROM_GETBITSHIFT(romp); int datamask = ((1 << ROM_GETBITWIDTH(romp)) - 1) << datashift; @@ -763,7 +699,7 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio int skip = ROM_GETSKIPCOUNT(romp); int reversed = ROM_ISREVERSED(romp); int numgroups = (numbytes + groupsize - 1) / groupsize; - UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp); + UINT8 *base = m_region->base() + ROM_GETOFFSET(romp); UINT32 tempbufsize; int i; @@ -774,7 +710,7 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio osd_printf_warning("Warning in RomModule definition: %s length not an even multiple of group size\n", ROM_GETNAME(romp)); /* make sure we only fill within the region space */ - if (ROM_GETOFFSET(romp) + numgroups * groupsize + (numgroups - 1) * skip > romdata->region->bytes()) + if (ROM_GETOFFSET(romp) + numgroups * groupsize + (numgroups - 1) * skip > m_region->bytes()) fatalerror("Error in RomModule definition: %s out of memory region space\n", ROM_GETNAME(romp)); /* make sure the length was valid */ @@ -783,7 +719,7 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio /* special case for simple loads */ if (datamask == 0xff && (groupsize == 1 || !reversed) && skip == 0) - return rom_fread(romdata, base, numbytes, parent_region); + return rom_fread(base, numbytes, parent_region); /* use a temporary buffer for complex loads */ tempbufsize = MIN(TEMPBUFFER_MAX_SIZE, numbytes); @@ -799,7 +735,7 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio /* read as much as we can */ LOG((" Reading %X bytes into buffer\n", bytesleft)); - if (rom_fread(romdata, bufptr, bytesleft, parent_region) != bytesleft) + if (rom_fread(bufptr, bytesleft, parent_region) != bytesleft) return 0; numbytes -= bytesleft; @@ -869,13 +805,13 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio fill_rom_data - fill a region of ROM space -------------------------------------------------*/ -static void fill_rom_data(romload_private *romdata, const rom_entry *romp) +void rom_load_manager::fill_rom_data(const rom_entry *romp) { UINT32 numbytes = ROM_GETLENGTH(romp); - UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp); + UINT8 *base = m_region->base() + ROM_GETOFFSET(romp); /* make sure we fill within the region space */ - if (ROM_GETOFFSET(romp) + numbytes > romdata->region->bytes()) + if (ROM_GETOFFSET(romp) + numbytes > m_region->bytes()) fatalerror("Error in RomModule definition: FILL out of memory region space\n"); /* make sure the length was valid */ @@ -891,15 +827,15 @@ static void fill_rom_data(romload_private *romdata, const rom_entry *romp) copy_rom_data - copy a region of ROM space -------------------------------------------------*/ -static void copy_rom_data(romload_private *romdata, const rom_entry *romp) +void rom_load_manager::copy_rom_data(const rom_entry *romp) { - UINT8 *base = romdata->region->base() + ROM_GETOFFSET(romp); + UINT8 *base = m_region->base() + ROM_GETOFFSET(romp); const char *srcrgntag = ROM_GETNAME(romp); UINT32 numbytes = ROM_GETLENGTH(romp); UINT32 srcoffs = (FPTR)ROM_GETHASHDATA(romp); /* srcoffset in place of hashdata */ /* make sure we copy within the region space */ - if (ROM_GETOFFSET(romp) + numbytes > romdata->region->bytes()) + if (ROM_GETOFFSET(romp) + numbytes > m_region->bytes()) fatalerror("Error in RomModule definition: COPY out of target memory region space\n"); /* make sure the length was valid */ @@ -907,7 +843,7 @@ static void copy_rom_data(romload_private *romdata, const rom_entry *romp) fatalerror("Error in RomModule definition: COPY has an invalid length\n"); /* make sure the source was valid */ - memory_region *region = romdata->machine().root_device().memregion(srcrgntag); + memory_region *region = machine().root_device().memregion(srcrgntag); if (region == nullptr) fatalerror("Error in RomModule definition: COPY from an invalid region\n"); @@ -925,7 +861,7 @@ static void copy_rom_data(romload_private *romdata, const rom_entry *romp) for a region -------------------------------------------------*/ -static void process_rom_entries(romload_private *romdata, const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, device_t *device, bool from_list) +void rom_load_manager::process_rom_entries(const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, device_t *device, bool from_list) { UINT32 lastflags = 0; @@ -946,11 +882,11 @@ static void process_rom_entries(romload_private *romdata, const char *regiontag, /* handle fills */ if (ROMENTRY_ISFILL(romp)) - fill_rom_data(romdata, romp++); + fill_rom_data(romp++); /* handle copies */ else if (ROMENTRY_ISCOPY(romp)) - copy_rom_data(romdata, romp++); + copy_rom_data(romp++); /* handle files */ else if (ROMENTRY_ISFILE(romp)) @@ -962,8 +898,8 @@ static void process_rom_entries(romload_private *romdata, const char *regiontag, /* open the file if it is a non-BIOS or matches the current BIOS */ LOG(("Opening ROM file: %s\n", ROM_GETNAME(romp))); std::string tried_file_names; - if (!irrelevantbios && !open_rom_file(romdata, regiontag, romp, tried_file_names, from_list)) - handle_missing_file(romdata, romp, tried_file_names, CHDERR_NONE); + if (!irrelevantbios && !open_rom_file(regiontag, romp, tried_file_names, from_list)) + handle_missing_file(romp, tried_file_names, CHDERR_NONE); /* loop until we run out of reloads */ do @@ -984,7 +920,7 @@ static void process_rom_entries(romload_private *romdata, const char *regiontag, /* attempt to read using the modified entry */ if (!ROMENTRY_ISIGNORE(&modified_romp) && !irrelevantbios) - /*readresult = */read_rom_data(romdata, parent_region, &modified_romp); + /*readresult = */read_rom_data(parent_region, &modified_romp); } while (ROMENTRY_ISCONTINUE(romp) || ROMENTRY_ISIGNORE(romp)); @@ -992,24 +928,24 @@ static void process_rom_entries(romload_private *romdata, const char *regiontag, if (baserom) { LOG(("Verifying length (%X) and checksums\n", explength)); - verify_length_and_hash(romdata, ROM_GETNAME(baserom), explength, hash_collection(ROM_GETHASHDATA(baserom))); + verify_length_and_hash(ROM_GETNAME(baserom), explength, hash_collection(ROM_GETHASHDATA(baserom))); LOG(("Verify finished\n")); } /* reseek to the start and clear the baserom so we don't reverify */ - if (romdata->file != nullptr) - romdata->file->seek(0, SEEK_SET); + if (m_file != nullptr) + m_file->seek(0, SEEK_SET); baserom = nullptr; explength = 0; } while (ROMENTRY_ISRELOAD(romp)); /* close the file */ - if (romdata->file != nullptr) + if (m_file != nullptr) { LOG(("Closing ROM file\n")); - global_free(romdata->file); - romdata->file = nullptr; + global_free(m_file); + m_file = nullptr; } } else @@ -1172,7 +1108,7 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_ open_disk_diff - open a DISK diff file -------------------------------------------------*/ -static chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd_file &source, chd_file &diff_chd) +chd_error rom_load_manager::open_disk_diff(emu_options &options, const rom_entry *romp, chd_file &source, chd_file &diff_chd) { std::string fname = std::string(ROM_GETNAME(romp)).append(".dif"); @@ -1217,7 +1153,7 @@ static chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd for a region -------------------------------------------------*/ -static void process_disk_entries(romload_private *romdata, const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, const char *locationtag) +void rom_load_manager::process_disk_entries(const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, const char *locationtag) { /* loop until we hit the end of this region */ for ( ; !ROMENTRY_ISREGIONEND(romp); romp++) @@ -1235,10 +1171,10 @@ static void process_disk_entries(romload_private *romdata, const char *regiontag /* first open the source drive */ LOG(("Opening disk image: %s\n", filename.c_str())); - err = chd_error(open_disk_image(romdata->machine().options(), &romdata->machine().system(), romp, chd->orig_chd(), locationtag)); + err = chd_error(open_disk_image(machine().options(), &machine().system(), romp, chd->orig_chd(), locationtag)); if (err != CHDERR_NONE) { - handle_missing_file(romdata, romp, std::string(), err); + handle_missing_file(romp, std::string(), err); global_free(chd); continue; } @@ -1250,25 +1186,25 @@ static void process_disk_entries(romload_private *romdata, const char *regiontag /* verify the hash */ if (hashes != acthashes) { - strcatprintf(romdata->errorstring, "%s WRONG CHECKSUMS:\n", filename.c_str()); - dump_wrong_and_correct_checksums(romdata, hashes, acthashes); - romdata->warnings++; + strcatprintf(m_errorstring, "%s WRONG CHECKSUMS:\n", filename.c_str()); + dump_wrong_and_correct_checksums(hashes, acthashes); + m_warnings++; } else if (hashes.flag(hash_collection::FLAG_BAD_DUMP)) { - strcatprintf(romdata->errorstring, "%s CHD NEEDS REDUMP\n", filename.c_str()); - romdata->knownbad++; + strcatprintf(m_errorstring, "%s CHD NEEDS REDUMP\n", filename.c_str()); + m_knownbad++; } /* if not read-only, make the diff file */ if (!DISK_ISREADONLY(romp)) { /* try to open or create the diff */ - err = open_disk_diff(romdata->machine().options(), romp, chd->orig_chd(), chd->diff_chd()); + err = open_disk_diff(machine().options(), romp, chd->orig_chd(), chd->diff_chd()); if (err != CHDERR_NONE) { - strcatprintf(romdata->errorstring, "%s DIFF CHD ERROR: %s\n", filename.c_str(), chd_file::error_string(err)); - romdata->errors++; + strcatprintf(m_errorstring, "%s DIFF CHD ERROR: %s\n", filename.c_str(), chd_file::error_string(err)); + m_errors++; global_free(chd); continue; } @@ -1276,7 +1212,7 @@ static void process_disk_entries(romload_private *romdata, const char *regiontag /* we're okay, add to the list of disks */ LOG(("Assigning to handle %d\n", DISK_GETINDEX(romp))); - romdata->machine().romload_data->chd_list.append(*chd); + m_chd_list.append(*chd); } } } @@ -1287,7 +1223,7 @@ static void process_disk_entries(romload_private *romdata, const char *regiontag flags for the given device -------------------------------------------------*/ -static void normalize_flags_for_device(running_machine &machine, const char *rgntag, UINT8 &width, endianness_t &endian) +void rom_load_manager::normalize_flags_for_device(running_machine &machine, const char *rgntag, UINT8 &width, endianness_t &endian) { device_t *device = machine.device(rgntag); device_memory_interface *memory; @@ -1328,19 +1264,18 @@ static void normalize_flags_for_device(running_machine &machine, const char *rgn more general process_region_list. -------------------------------------------------*/ -void load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region) +void rom_load_manager::load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region) { std::string locationtag(swlist.list_name()), breakstr("%"); - romload_private *romdata = device.machine().romload_data; const rom_entry *region; std::string regiontag; - romdata->errorstring.clear(); - romdata->softwarningstring.clear(); + m_errorstring.clear(); + m_softwarningstring.clear(); - romdata->romstotal = 0; - romdata->romstotalsize = 0; - romdata->romsloadedsize = 0; + m_romstotal = 0; + m_romstotalsize = 0; + m_romsloadedsize = 0; software_info *swinfo = swlist.find(swname); if (swinfo != nullptr) @@ -1348,13 +1283,13 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c UINT32 supported = swinfo->supported(); if (supported == SOFTWARE_SUPPORTED_PARTIAL) { - strcatprintf(romdata->errorstring, "WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name()); - strcatprintf(romdata->softwarningstring, "Support for software %s (in list %s) is only partial\n", swname, swlist.list_name()); + strcatprintf(m_errorstring, "WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name()); + strcatprintf(m_softwarningstring, "Support for software %s (in list %s) is only partial\n", swname, swlist.list_name()); } if (supported == SOFTWARE_SUPPORTED_NO) { - strcatprintf(romdata->errorstring, "WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name()); - strcatprintf(romdata->softwarningstring, "Support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name()); + strcatprintf(m_errorstring, "WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name()); + strcatprintf(m_softwarningstring, "Support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name()); } // attempt reading up the chain through the parents and create a locationtag std::string in the format @@ -1388,57 +1323,57 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c /* if this is a device region, override with the device width and endianness */ endianness_t endianness = ROMREGION_ISBIGENDIAN(region) ? ENDIANNESS_BIG : ENDIANNESS_LITTLE; UINT8 width = ROMREGION_GETWIDTH(region) / 8; - memory_region *memregion = romdata->machine().root_device().memregion(regiontag.c_str()); + memory_region *memregion = machine().root_device().memregion(regiontag.c_str()); if (memregion != nullptr) { - if (romdata->machine().device(regiontag.c_str()) != nullptr) - normalize_flags_for_device(romdata->machine(), regiontag.c_str(), width, endianness); + if (machine().device(regiontag.c_str()) != nullptr) + normalize_flags_for_device(machine(), regiontag.c_str(), width, endianness); /* clear old region (todo: should be moved to an image unload function) */ - romdata->machine().memory().region_free(memregion->name()); + machine().memory().region_free(memregion->name()); } /* remember the base and length */ - romdata->region = romdata->machine().memory().region_alloc(regiontag.c_str(), regionlength, width, endianness); - LOG(("Allocated %X bytes @ %p\n", romdata->region->bytes(), romdata->region->base())); + m_region = machine().memory().region_alloc(regiontag.c_str(), regionlength, width, endianness); + LOG(("Allocated %X bytes @ %p\n", m_region->bytes(), m_region->base())); /* clear the region if it's requested */ if (ROMREGION_ISERASE(region)) - memset(romdata->region->base(), ROMREGION_GETERASEVAL(region), romdata->region->bytes()); + memset(m_region->base(), ROMREGION_GETERASEVAL(region), m_region->bytes()); /* or if it's sufficiently small (<= 4MB) */ - else if (romdata->region->bytes() <= 0x400000) - memset(romdata->region->base(), 0, romdata->region->bytes()); + else if (m_region->bytes() <= 0x400000) + memset(m_region->base(), 0, m_region->bytes()); #ifdef MAME_DEBUG /* if we're debugging, fill region with random data to catch errors */ else - fill_random(romdata->machine(), romdata->region->base(), romdata->region->bytes()); + fill_random(m_region->base(), m_region->bytes()); #endif /* update total number of roms */ for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom)) { - romdata->romstotal++; - romdata->romstotalsize += rom_file_size(rom); + m_romstotal++; + m_romstotalsize += rom_file_size(rom); } /* now process the entries in the region */ if (ROMREGION_ISROMDATA(region)) - process_rom_entries(romdata, locationtag.c_str(), region, region + 1, &device, TRUE); + process_rom_entries(locationtag.c_str(), region, region + 1, &device, TRUE); else if (ROMREGION_ISDISKDATA(region)) - process_disk_entries(romdata, regiontag.c_str(), region, region + 1, locationtag.c_str()); + process_disk_entries(regiontag.c_str(), region, region + 1, locationtag.c_str()); } /* now go back and post-process all the regions */ for (region = start_region; region != nullptr; region = rom_next_region(region)) { regiontag = device.subtag(ROMREGION_GETTAG(region)); - region_post_process(romdata, regiontag.c_str(), ROMREGION_ISINVERTED(region)); + region_post_process(regiontag.c_str(), ROMREGION_ISINVERTED(region)); } /* display the results and exit */ - display_rom_load_results(romdata, TRUE); + display_rom_load_results(TRUE); } @@ -1446,12 +1381,12 @@ void load_software_part_region(device_t &device, software_list_device &swlist, c process_region_list - process a region list -------------------------------------------------*/ -static void process_region_list(romload_private *romdata) +void rom_load_manager::process_region_list() { std::string regiontag; /* loop until we hit the end */ - device_iterator deviter(romdata->machine().root_device()); + device_iterator deviter(machine().root_device()); for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) { @@ -1468,32 +1403,32 @@ static void process_region_list(romload_private *romdata) /* if this is a device region, override with the device width and endianness */ UINT8 width = ROMREGION_GETWIDTH(region) / 8; endianness_t endianness = ROMREGION_ISBIGENDIAN(region) ? ENDIANNESS_BIG : ENDIANNESS_LITTLE; - if (romdata->machine().device(regiontag.c_str()) != nullptr) - normalize_flags_for_device(romdata->machine(), regiontag.c_str(), width, endianness); + if (machine().device(regiontag.c_str()) != nullptr) + normalize_flags_for_device(machine(), regiontag.c_str(), width, endianness); /* remember the base and length */ - romdata->region = romdata->machine().memory().region_alloc(regiontag.c_str(), regionlength, width, endianness); - LOG(("Allocated %X bytes @ %p\n", romdata->region->bytes(), romdata->region->base())); + m_region = machine().memory().region_alloc(regiontag.c_str(), regionlength, width, endianness); + LOG(("Allocated %X bytes @ %p\n", m_region->bytes(), m_region->base())); /* clear the region if it's requested */ if (ROMREGION_ISERASE(region)) - memset(romdata->region->base(), ROMREGION_GETERASEVAL(region), romdata->region->bytes()); + memset(m_region->base(), ROMREGION_GETERASEVAL(region), m_region->bytes()); /* or if it's sufficiently small (<= 4MB) */ - else if (romdata->region->bytes() <= 0x400000) - memset(romdata->region->base(), 0, romdata->region->bytes()); + else if (m_region->bytes() <= 0x400000) + memset(m_region->base(), 0, m_region->bytes()); #ifdef MAME_DEBUG /* if we're debugging, fill region with random data to catch errors */ else - fill_random(romdata->machine(), romdata->region->base(), romdata->region->bytes()); + fill_random(m_region->base(), m_region->bytes()); #endif /* now process the entries in the region */ - process_rom_entries(romdata, device->shortname(), region, region + 1, device, FALSE); + process_rom_entries(device->shortname(), region, region + 1, device, FALSE); } else if (ROMREGION_ISDISKDATA(region)) - process_disk_entries(romdata, regiontag.c_str(), region, region + 1, nullptr); + process_disk_entries(regiontag.c_str(), region, region + 1, nullptr); } /* now go back and post-process all the regions */ @@ -1501,7 +1436,7 @@ static void process_region_list(romload_private *romdata) for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region)) { regiontag = rom_region_name(*device, region); - region_post_process(romdata, regiontag.c_str(), ROMREGION_ISINVERTED(region)); + region_post_process(regiontag.c_str(), ROMREGION_ISINVERTED(region)); } /* and finally register all per-game parameters */ @@ -1509,7 +1444,7 @@ static void process_region_list(romload_private *romdata) for (const rom_entry *param = rom_first_parameter(*device); param != nullptr; param = rom_next_parameter(param)) { regiontag = rom_parameter_name(*device, param); - romdata->machine().parameters().add(regiontag, rom_parameter_value(param)); + machine().parameters().add(regiontag, rom_parameter_value(param)); } } @@ -1519,86 +1454,35 @@ static void process_region_list(romload_private *romdata) images associated with the given machine -------------------------------------------------*/ -void rom_init(running_machine &machine) +rom_load_manager::rom_load_manager(running_machine &machine) + : m_machine(machine) { - romload_private *romdata; - - /* allocate private data */ - machine.romload_data = romdata = auto_alloc_clear(machine, <romload_private>()); - - /* make sure we get called back on the way out */ - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(rom_exit), &machine)); - - /* reset the romdata struct */ - romdata->m_machine = &machine; - /* figure out which BIOS we are using */ - device_iterator deviter(romdata->machine().config().root_device()); + device_iterator deviter(machine.config().root_device()); for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { if (device->rom_region()) { std::string specbios; if (device->owner() == nullptr) { - specbios.assign(romdata->machine().options().bios()); + specbios.assign(machine.options().bios()); } else { - specbios = romdata->machine().options().sub_value(device->owner()->tag()+1,"bios"); + specbios = machine.options().sub_value(device->owner()->tag()+1,"bios"); if (specbios.empty()) { specbios = device->default_bios_tag(); } } - determine_bios_rom(romdata, device, specbios.c_str()); + determine_bios_rom(device, specbios.c_str()); } } /* count the total number of ROMs */ - count_roms(romdata); + count_roms(); /* reset the disk list */ - romdata->chd_list.reset(); + m_chd_list.reset(); /* process the ROM entries we were passed */ - process_region_list(romdata); + process_region_list(); /* display the results and exit */ - display_rom_load_results(romdata, FALSE); -} - - -/*------------------------------------------------- - rom_exit - clean up after ourselves --------------------------------------------------*/ - -static void rom_exit(running_machine &machine) -{ -} - - -/*------------------------------------------------- - rom_load_warnings - return the number of - warnings we generated --------------------------------------------------*/ - -int rom_load_warnings(running_machine &machine) -{ - return machine.romload_data->warnings; -} - - -/*------------------------------------------------- - software_load_warnings_message - return the - software load warnings we generated --------------------------------------------------*/ - -std::string& software_load_warnings_message(running_machine &machine) -{ - return machine.romload_data->softwarningstring; -} - -/*------------------------------------------------- - rom_load_knownbad - return the number of - BAD_DUMP/NO_DUMP warnings we generated --------------------------------------------------*/ - -int rom_load_knownbad(running_machine &machine) -{ - return machine.romload_data->knownbad; + display_rom_load_results(FALSE); } diff --git a/src/emu/romload.h b/src/emu/romload.h index ec0e3375cdd..751e1c95bbe 100644 --- a/src/emu/romload.h +++ b/src/emu/romload.h @@ -16,7 +16,7 @@ #ifndef __ROMLOAD_H__ #define __ROMLOAD_H__ - +#include "chd.h" /*************************************************************************** CONSTANTS @@ -254,32 +254,110 @@ struct rom_entry #define DISK_IMAGE_READONLY_OPTIONAL(name,idx,hash) ROMX_LOAD(name, idx, 0, hash, DISK_READONLY | ROM_OPTIONAL) - /*************************************************************************** - FUNCTION PROTOTYPES +TYPE DEFINITIONS ***************************************************************************/ +// ======================> rom_load_manager -/* ----- ROM processing ----- */ - -/* load the ROMs and open the disk images associated with the given machine */ -void rom_init(running_machine &machine); - -/* return the number of warnings we generated */ -int rom_load_warnings(running_machine &machine); -std::string& software_load_warnings_message(running_machine &machine); +class rom_load_manager +{ + class open_chd + { + friend class simple_list<open_chd>; + + public: + open_chd(const char *region) + : m_next(nullptr), + m_region(region) { } + + open_chd *next() const { return m_next; } + const char *region() const { return m_region.c_str(); } + chd_file &chd() { return m_diffchd.opened() ? m_diffchd : m_origchd; } + chd_file &orig_chd() { return m_origchd; } + chd_file &diff_chd() { return m_diffchd; } + + private: + open_chd * m_next; /* pointer to next in the list */ + std::string m_region; /* disk region we came from */ + chd_file m_origchd; /* handle to the original CHD */ + chd_file m_diffchd; /* handle to the diff CHD */ + }; + +public: + // construction/destruction + rom_load_manager(running_machine &machine); + + // getters + running_machine &machine() const { return m_machine; } + + /* return the number of warnings we generated */ + int warnings() const { return m_warnings; } + + std::string& software_load_warnings_message() { return m_softwarningstring; } + + /* return the number of BAD_DUMP/NO_DUMP warnings we generated */ + int knownbad() const { return m_knownbad; } + + /* ----- disk handling ----- */ + + /* return a pointer to the CHD file associated with the given region */ + chd_file *get_disk_handle(const char *region); + + /* set a pointer to the CHD file associated with the given region */ + int set_disk_handle(const char *region, const char *fullpath); + + void load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region); + +private: + void determine_bios_rom(device_t *device, const char *specbios); + void count_roms(); + void fill_random(UINT8 *base, UINT32 length); + void handle_missing_file(const rom_entry *romp, std::string tried_file_names, chd_error chderr); + void dump_wrong_and_correct_checksums(const hash_collection &hashes, const hash_collection &acthashes); + void verify_length_and_hash(const char *name, UINT32 explength, const hash_collection &hashes); + void display_loading_rom_message(const char *name, bool from_list); + void display_rom_load_results(bool from_list); + void region_post_process(const char *rgntag, bool invert); + int open_rom_file(const char *regiontag, const rom_entry *romp, std::string &tried_file_names, bool from_list); + int rom_fread(UINT8 *buffer, int length, const rom_entry *parent_region); + int read_rom_data(const rom_entry *parent_region, const rom_entry *romp); + void fill_rom_data(const rom_entry *romp); + void copy_rom_data(const rom_entry *romp); + void process_rom_entries(const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, device_t *device, bool from_list); + chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd_file &source, chd_file &diff_chd); + void process_disk_entries(const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, const char *locationtag); + void normalize_flags_for_device(running_machine &machine, const char *rgntag, UINT8 &width, endianness_t &endian); + void process_region_list(); + + + // internal state + running_machine & m_machine; // reference to our machine + + int m_warnings; /* warning count during processing */ + int m_knownbad; /* BAD_DUMP/NO_DUMP count during processing */ + int m_errors; /* error count during processing */ + + int m_romsloaded; /* current ROMs loaded count */ + int m_romstotal; /* total number of ROMs to read */ + UINT32 m_romsloadedsize; /* total size of ROMs loaded so far */ + UINT32 m_romstotalsize; /* total size of ROMs to read */ + + emu_file * m_file; /* current file */ + simple_list<open_chd> m_chd_list; /* disks */ + + memory_region * m_region; /* info about current region */ + + std::string m_errorstring; /* error string */ + std::string m_softwarningstring; /* software warning string */ +}; -/* return the number of BAD_DUMP/NO_DUMP warnings we generated */ -int rom_load_knownbad(running_machine &machine); /* ----- Helpers ----- */ file_error common_process_file(emu_options &options, const char *location, const char *ext, const rom_entry *romp, emu_file **image_file); file_error common_process_file(emu_options &options, const char *location, bool has_crc, UINT32 crc, const rom_entry *romp, emu_file **image_file); - -/* ----- ROM iteration ----- */ - /* return pointer to the first ROM region within a source */ const rom_entry *rom_first_region(const device_t &device); @@ -311,17 +389,7 @@ std::string rom_parameter_name(const device_t &device, const rom_entry *romp); std::string rom_parameter_value(const rom_entry *romp); -/* ----- disk handling ----- */ - /* open a disk image, searching up the parent and loading by checksum */ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_entry *romp, chd_file &image_chd, const char *locationtag); -/* return a pointer to the CHD file associated with the given region */ -chd_file *get_disk_handle(running_machine &machine, const char *region); - -/* set a pointer to the CHD file associated with the given region */ -int set_disk_handle(running_machine &machine, const char *region, const char *fullpath); - -void load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region); - #endif /* __ROMLOAD_H__ */ diff --git a/src/emu/ui/ui.cpp b/src/emu/ui/ui.cpp index bf9cbadf31d..0048936ea20 100644 --- a/src/emu/ui/ui.cpp +++ b/src/emu/ui/ui.cpp @@ -1024,11 +1024,11 @@ std::string &ui_manager::warnings_string(std::string &str) str.clear(); // if no warnings, nothing to return - if (rom_load_warnings(machine()) == 0 && rom_load_knownbad(machine()) == 0 && !(machine().system().flags & WARNING_FLAGS) && software_load_warnings_message(machine()).length() == 0) + if (machine().rom_load().warnings() == 0 && machine().rom_load().knownbad() == 0 && !(machine().system().flags & WARNING_FLAGS) && machine().rom_load().software_load_warnings_message().length() == 0) return str; // add a warning if any ROMs were loaded with warnings - if (rom_load_warnings(machine()) > 0) + if (machine().rom_load().warnings() > 0) { str.append("One or more ROMs/CHDs for this "); str.append(emulator_info::get_gamenoun()); @@ -1039,20 +1039,20 @@ std::string &ui_manager::warnings_string(std::string &str) str.append("\n"); } - if (software_load_warnings_message(machine()).length()>0) { - str.append(software_load_warnings_message(machine())); + if (machine().rom_load().software_load_warnings_message().length()>0) { + str.append(machine().rom_load().software_load_warnings_message()); if (machine().system().flags & WARNING_FLAGS) str.append("\n"); } // if we have at least one warning flag, print the general header - if ((machine().system().flags & WARNING_FLAGS) || rom_load_knownbad(machine()) > 0) + if ((machine().system().flags & WARNING_FLAGS) || machine().rom_load().knownbad() > 0) { str.append("There are known problems with this "); str.append(emulator_info::get_gamenoun()); str.append("\n\n"); // add a warning if any ROMs are flagged BAD_DUMP/NO_DUMP - if (rom_load_knownbad(machine()) > 0) { + if (machine().rom_load().knownbad() > 0) { str.append("One or more ROMs/CHDs for this "); str.append(emulator_info::get_gamenoun()); str.append(" have not been correctly dumped.\n"); diff --git a/src/mame/drivers/konamim2.cpp b/src/mame/drivers/konamim2.cpp index db7c1f53121..426556d0e95 100644 --- a/src/mame/drivers/konamim2.cpp +++ b/src/mame/drivers/konamim2.cpp @@ -499,7 +499,7 @@ WRITE64_MEMBER(konamim2_state::reset_w) void konamim2_state::cde_init() { - cdrom_file *cdfile = cdrom_open(get_disk_handle(machine(), ":cdrom")); + cdrom_file *cdfile = cdrom_open(machine().rom_load().get_disk_handle(":cdrom")); const cdrom_toc *toc = cdrom_get_toc(cdfile); diff --git a/src/mame/drivers/ksys573.cpp b/src/mame/drivers/ksys573.cpp index ecdee15c49f..18de66cf40d 100644 --- a/src/mame/drivers/ksys573.cpp +++ b/src/mame/drivers/ksys573.cpp @@ -725,8 +725,8 @@ void ksys573_state::driver_start() m_atapi_timer = machine().scheduler().timer_alloc( timer_expired_delegate( FUNC( ksys573_state::atapi_xfer_end ),this ) ); m_atapi_timer->adjust( attotime::never ); - m_available_cdroms[ 0 ] = cdrom_open( get_disk_handle( machine(), ":cdrom0" ) ); - m_available_cdroms[ 1 ] = cdrom_open( get_disk_handle( machine(), ":cdrom1" ) ); + m_available_cdroms[ 0 ] = cdrom_open(machine().rom_load().get_disk_handle(":cdrom0")); + m_available_cdroms[ 1 ] = cdrom_open(machine().rom_load().get_disk_handle(":cdrom1")); m_n_security_control = 0; m_control = 0; diff --git a/src/mame/machine/cdicdic.cpp b/src/mame/machine/cdicdic.cpp index fed7aee696d..bc01d5a6164 100644 --- a/src/mame/machine/cdicdic.cpp +++ b/src/mame/machine/cdicdic.cpp @@ -1232,7 +1232,7 @@ void cdicdic_device::device_reset() else { // MAME case - m_cd = cdrom_open(get_disk_handle(machine(), ":cdrom")); + m_cd = cdrom_open(machine().rom_load().get_disk_handle(":cdrom")); state->m_cdda->set_cdrom(m_cd); } } diff --git a/src/mame/machine/gaelco2.cpp b/src/mame/machine/gaelco2.cpp index 95b415eb7d2..a33a2c6ec5c 100644 --- a/src/mame/machine/gaelco2.cpp +++ b/src/mame/machine/gaelco2.cpp @@ -290,7 +290,7 @@ WRITE16_MEMBER(gaelco2_state::gaelco2_eeprom_data_w) READ16_MEMBER(gaelco2_state::snowboar_protection_r) { - chd_file * table = get_disk_handle(machine(), ":decrypt"); + chd_file * table = machine().rom_load().get_disk_handle(":decrypt"); UINT8 temp[1024]; table->read_hunk(snowboard_latch>>9, &temp[0]); UINT16 data = (temp[(snowboard_latch & 0x1ff)*2]<<8) | temp[((snowboard_latch & 0x1ff)*2)+1]; diff --git a/src/mame/machine/naomigd.cpp b/src/mame/machine/naomigd.cpp index 14e180c74bf..28dc2ccb3e6 100644 --- a/src/mame/machine/naomigd.cpp +++ b/src/mame/machine/naomigd.cpp @@ -433,7 +433,7 @@ void naomi_gdrom_board::device_start() logerror("key is %08x%08x\n", (UINT32)((key & 0xffffffff00000000ULL)>>32), (UINT32)(key & 0x00000000ffffffffULL)); UINT8 buffer[2048]; - cdrom_file *gdromfile = cdrom_open(get_disk_handle(machine(), image_tag)); + cdrom_file *gdromfile = cdrom_open(machine().rom_load().get_disk_handle(image_tag)); // primary volume descriptor // read frame 0xb06e (frame=sector+150) // dimm board firmware starts straight from this frame |