summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/romload.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/romload.h')
-rw-r--r--src/emu/romload.h89
1 files changed, 58 insertions, 31 deletions
diff --git a/src/emu/romload.h b/src/emu/romload.h
index 2b9955a1590..4ad0303a9f6 100644
--- a/src/emu/romload.h
+++ b/src/emu/romload.h
@@ -17,7 +17,10 @@
#include <functional>
#include <initializer_list>
+#include <memory>
#include <string>
+#include <string_view>
+#include <system_error>
#include <type_traits>
#include <vector>
@@ -51,7 +54,6 @@ template <typename T> inline bool ROMENTRY_ISPARAMETER(T const &r) { return
template <typename T> inline bool ROMENTRY_ISREGIONEND(T const &r) { return ROMENTRY_ISREGION(r) || ROMENTRY_ISPARAMETER(r) || ROMENTRY_ISEND(r); }
/* ----- per-region macros ----- */
-#define ROMREGION_GETTAG(r) ((r)->name().c_str())
template <typename T> inline u32 ROMREGION_GETLENGTH(T const &r) { return ROMENTRY_UNWRAP(r).get_length(); }
template <typename T> inline u32 ROMREGION_GETFLAGS(T const &r) { return ROMENTRY_UNWRAP(r).get_flags(); }
template <typename T> inline u32 ROMREGION_GETWIDTH(T const &r) { return 8 << ((ROMREGION_GETFLAGS(r) & ROMREGION_WIDTHMASK) >> 8); }
@@ -71,7 +73,6 @@ template <typename T> inline bool ROMREGION_ISDISKDATA(T const &r) { return
template <typename T> inline u32 ROM_GETOFFSET(T const &r) { return ROMENTRY_UNWRAP(r).get_offset(); }
template <typename T> inline u32 ROM_GETLENGTH(T const &r) { return ROMENTRY_UNWRAP(r).get_length(); }
template <typename T> inline u32 ROM_GETFLAGS(T const &r) { return ROMENTRY_UNWRAP(r).get_flags(); }
-#define ROM_GETHASHDATA(r) ((r)->hashdata().c_str())
template <typename T> inline bool ROM_ISOPTIONAL(T const &r) { return (ROM_GETFLAGS(r) & ROM_OPTIONALMASK) == ROM_OPTIONAL; }
template <typename T> inline u32 ROM_GETGROUPSIZE(T const &r) { return ((ROM_GETFLAGS(r) & ROM_GROUPMASK) >> 8) + 1; }
template <typename T> inline u32 ROM_GETSKIPCOUNT(T const &r) { return (ROM_GETFLAGS(r) & ROM_SKIPMASK) >> 12; }
@@ -103,11 +104,11 @@ protected:
const_entry_iterator &operator=(const_entry_iterator &&) noexcept = default;
public:
- typedef T value_type;
- typedef value_type const *pointer;
- typedef value_type const &reference;
- typedef std::ptrdiff_t difference_type;
- typedef std::forward_iterator_tag iterator_category;
+ using value_type = T;
+ using pointer = value_type const *;
+ using reference = value_type const &;
+ using difference_type = std::ptrdiff_t;
+ using iterator_category = std::forward_iterator_tag;
reference operator*() const noexcept { return reinterpret_cast<reference>(*m_data); }
pointer operator->() const noexcept { return reinterpret_cast<pointer>(m_data); }
@@ -387,17 +388,18 @@ class rom_load_manager
class open_chd
{
public:
- open_chd(const char *region) : m_region(region) { }
+ open_chd(std::string_view region) : m_region(region) { }
+ open_chd(std::string &&region) : m_region(std::move(region)) { }
- const char *region() const { return m_region.c_str(); }
+ std::string_view region() const { return m_region; }
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:
- 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 */
+ 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:
@@ -418,40 +420,67 @@ public:
/* ----- disk handling ----- */
/* return a pointer to the CHD file associated with the given region */
- chd_file *get_disk_handle(const char *region);
+ chd_file *get_disk_handle(std::string_view region);
/* set a pointer to the CHD file associated with the given region */
- int set_disk_handle(const char *region, const char *fullpath);
+ std::error_condition set_disk_handle(std::string_view region, std::string_view fullpath);
- void load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region);
+ void load_software_part_region(device_t &device, software_list_device &swlist, std::string_view swname, const rom_entry *start_region);
/* get search path for a software item */
static std::vector<std::string> get_software_searchpath(software_list_device &swlist, const software_info &swinfo);
/* open a disk image, searching up the parent and loading by checksum */
- static chd_error open_disk_image(const emu_options &options, const device_t &device, const rom_entry *romp, chd_file &image_chd);
- static chd_error open_disk_image(const emu_options &options, software_list_device &swlist, const software_info &swinfo, const rom_entry *romp, chd_file &image_chd);
+ static std::error_condition open_disk_image(emu_options &options, const device_t &device, const rom_entry *romp, chd_file &image_chd);
+ static std::error_condition open_disk_image(emu_options &options, software_list_device &swlist, const software_info &swinfo, const rom_entry *romp, chd_file &image_chd);
private:
- void determine_bios_rom(device_t &device, const char *specbios);
+ using search_paths = std::initializer_list<std::reference_wrapper<const std::vector<std::string> > >;
+
+ void determine_bios_rom(device_t &device, std::string_view specbios);
void count_roms();
void fill_random(u8 *base, u32 length);
- void handle_missing_file(const rom_entry *romp, const std::vector<std::string> &tried_file_names, chd_error chderr);
+ void handle_missing_file(const rom_entry *romp, const std::vector<std::string> &tried_file_names, std::error_condition chderr);
void dump_wrong_and_correct_checksums(const util::hash_collection &hashes, const util::hash_collection &acthashes);
- void verify_length_and_hash(emu_file *file, const char *name, u32 explength, const util::hash_collection &hashes);
+ void verify_length_and_hash(emu_file *file, std::string_view name, u32 explength, const util::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(memory_region *region, bool invert);
- std::unique_ptr<emu_file> open_rom_file(std::initializer_list<std::reference_wrapper<const std::vector<std::string> > > searchpath, const rom_entry *romp, std::vector<std::string> &tried_file_names, bool from_list);
- std::unique_ptr<emu_file> open_rom_file(const std::vector<std::string> &paths, std::vector<std::string> &tried, bool has_crc, u32 crc, const std::string &name, osd_file::error &filerr);
+ std::unique_ptr<emu_file> open_rom_file(
+ const std::vector<std::string> &searchpath,
+ const rom_entry *romp,
+ std::vector<std::string> &tried_file_names,
+ bool from_list);
+ std::unique_ptr<emu_file> open_rom_file(
+ const std::vector<std::string> &paths,
+ std::vector<std::string> &tried,
+ bool has_crc,
+ u32 crc,
+ std::string_view name,
+ std::error_condition &filerr);
int rom_fread(emu_file *file, u8 *buffer, int length, const rom_entry *parent_region);
- int read_rom_data(emu_file *file, 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(std::initializer_list<std::reference_wrapper<const std::vector<std::string> > > searchpath, u8 bios, const rom_entry *parent_region, const rom_entry *romp, 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(std::initializer_list<std::reference_wrapper<const std::vector<std::string> > > searchpath, const char *regiontag, const rom_entry *romp, std::function<const rom_entry * ()> next_parent);
- void normalize_flags_for_device(const char *rgntag, u8 &width, endianness_t &endian);
+ int read_rom_data(emu_file *file, memory_region &region, const rom_entry *parent_region, const rom_entry *romp);
+ void fill_rom_data(memory_region &region, const rom_entry *romp);
+ void copy_rom_data(memory_region &region, const rom_entry *romp);
+ void process_rom_entries(
+ const std::vector<std::string> &searchpath,
+ u8 bios,
+ memory_region &region,
+ const rom_entry *parent_region,
+ const rom_entry *romp,
+ bool from_list);
+ std::error_condition open_disk_diff(
+ emu_options &options,
+ const rom_entry *romp,
+ chd_file &source,
+ chd_file &diff_chd);
+ void process_disk_entries(
+ search_paths searchpath,
+ std::string_view regiontag,
+ const rom_entry *romp,
+ std::function<const rom_entry * ()> next_parent,
+ const chd_file::open_parent_func &open_parent);
+ void normalize_flags_for_device(std::string_view rgntag, u8 &width, endianness_t &endian);
void process_region_list();
// internal state
@@ -468,8 +497,6 @@ private:
std::vector<std::unique_ptr<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
};