1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria,Aaron Giles
/*********************************************************************
romentry.cpp
ROM loading functions.
*********************************************************************/
#include "romentry.h"
#include "strformat.h"
/***************************************************************************
HELPERS
***************************************************************************/
//-------------------------------------------------
// hashdata_from_tiny_rom_entry - calculates the
// proper hashdata string from the value in the
// tiny_rom_entry
//-------------------------------------------------
static std::string hashdata_from_tiny_rom_entry(const tiny_rom_entry &ent)
{
std::string result;
switch (ent.flags & ROMENTRY_TYPEMASK)
{
case ROMENTRYTYPE_FILL:
case ROMENTRYTYPE_COPY:
// for these types, tiny_rom_entry::hashdata is an integer typecasted to a pointer
result = string_format("0x%x", (unsigned)(FPTR)ent.hashdata);
break;
default:
if (ent.hashdata != nullptr)
result.assign(ent.hashdata);
break;
}
return result;
}
/***************************************************************************
ROM ENTRY
***************************************************************************/
//-------------------------------------------------
// ctor (with move constructors)
//-------------------------------------------------
rom_entry::rom_entry(std::string &&name, std::string &&hashdata, UINT32 offset, UINT32 length, UINT32 flags)
: m_name(std::move(name))
, m_hashdata(std::move(hashdata))
, m_offset(offset)
, m_length(length)
, m_flags(flags)
{
}
//-------------------------------------------------
// ctor (with tiny_rom_entry)
//-------------------------------------------------
rom_entry::rom_entry(const tiny_rom_entry &ent)
: m_name(ent.name != nullptr ? ent.name : "")
, m_hashdata(hashdata_from_tiny_rom_entry(ent))
, m_offset(ent.offset)
, m_length(ent.length)
, m_flags(ent.flags)
{
}
|