diff options
author | 2020-09-14 08:58:02 +1000 | |
---|---|---|
committer | 2020-09-14 08:58:02 +1000 | |
commit | 8eb1be4a485fbad786c8a8b3b9ba6fb8773a3e83 (patch) | |
tree | 392a3ca49a64cffad6fd74f22b01146ae1cfec96 | |
parent | 3e452be576fd451314b281ce63747615b6d10dc1 (diff) |
emu/save.cpp: Fix bad SFINAE trick breaking segapcm.cpp, fix saving attotime array on 32-bit Linux targets that align u64 on 32-bit boundaries
-rw-r--r-- | src/devices/sound/multipcm.cpp | 52 | ||||
-rw-r--r-- | src/emu/debug/dvmemory.cpp | 2 | ||||
-rw-r--r-- | src/emu/save.cpp | 6 | ||||
-rw-r--r-- | src/emu/save.h | 14 | ||||
-rw-r--r-- | src/frontend/mame/luaengine.cpp | 7 |
5 files changed, 38 insertions, 43 deletions
diff --git a/src/devices/sound/multipcm.cpp b/src/devices/sound/multipcm.cpp index 34e0e95b511..c4a5892990f 100644 --- a/src/devices/sound/multipcm.cpp +++ b/src/devices/sound/multipcm.cpp @@ -450,22 +450,22 @@ void multipcm_device::write(offs_t offset, uint8_t data) DEFINE_DEVICE_TYPE(MULTIPCM, multipcm_device, "ymw258f", "Yamaha YMW-258-F") -multipcm_device::multipcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, MULTIPCM, tag, owner, clock), - device_sound_interface(mconfig, *this), - device_rom_interface(mconfig, *this), - m_stream(nullptr), - m_slots(nullptr), - m_cur_slot(0), - m_address(0), - m_rate(0), - m_attack_step(nullptr), - m_decay_release_step(nullptr), - m_freq_step_table(nullptr), - m_left_pan_table(nullptr), - m_right_pan_table(nullptr), - m_linear_to_exp_volume(nullptr), - m_total_level_steps(nullptr) +multipcm_device::multipcm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, MULTIPCM, tag, owner, clock), + device_sound_interface(mconfig, *this), + device_rom_interface(mconfig, *this), + m_stream(nullptr), + m_slots(nullptr), + m_cur_slot(0), + m_address(0), + m_rate(0), + m_attack_step(nullptr), + m_decay_release_step(nullptr), + m_freq_step_table(nullptr), + m_left_pan_table(nullptr), + m_right_pan_table(nullptr), + m_linear_to_exp_volume(nullptr), + m_total_level_steps(nullptr) { } @@ -577,16 +577,16 @@ void multipcm_device::device_start() // Slots m_slots = make_unique_clear<slot_t []>(28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_regs), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_playing), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_base), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_offset), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_step), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_pan), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_total_level), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_dest_total_level), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_total_level_step), 28); - save_pointer(STRUCT_MEMBER(m_slots.get(), m_prev_sample), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_regs), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_playing), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_base), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_offset), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_step), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_pan), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_total_level), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_dest_total_level), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_total_level_step), 28); + save_pointer(STRUCT_MEMBER(m_slots, m_prev_sample), 28); for (int32_t slot = 0; slot < 28; ++slot) { diff --git a/src/emu/debug/dvmemory.cpp b/src/emu/debug/dvmemory.cpp index 7f07e48b6ed..fe1b9da419a 100644 --- a/src/emu/debug/dvmemory.cpp +++ b/src/emu/debug/dvmemory.cpp @@ -84,7 +84,7 @@ debug_view_memory_source::debug_view_memory_source(std::string &&name, void *bas , m_base(base) , m_blocklength(element_size * num_elements) , m_numblocks(num_blocks) - , m_blockstride(element_size * block_stride) + , m_blockstride(block_stride) , m_offsetxor(0) , m_endianness(ENDIANNESS_NATIVE) , m_prefsize(std::min(element_size, 8)) diff --git a/src/emu/save.cpp b/src/emu/save.cpp index b2456d17b6f..b95ff1796b4 100644 --- a/src/emu/save.cpp +++ b/src/emu/save.cpp @@ -416,7 +416,7 @@ inline save_error save_manager::do_write(T check_space, U write_block, V start_h { const u32 blocksize = entry->m_typesize * entry->m_typecount; const u8 *data = reinterpret_cast<const u8 *>(entry->m_data); - for (u32 b = 0; entry->m_blockcount > b; ++b, data += (entry->m_typesize * entry->m_stride)) + for (u32 b = 0; entry->m_blockcount > b; ++b, data += entry->m_stride) if (!write_block(data, blocksize)) return STATERR_WRITE_ERROR; } @@ -460,7 +460,7 @@ inline save_error save_manager::do_read(T check_length, U read_block, V start_he { const u32 blocksize = entry->m_typesize * entry->m_typecount; u8 *data = reinterpret_cast<u8 *>(entry->m_data); - for (u32 b = 0; entry->m_blockcount > b; ++b, data += (entry->m_typesize * entry->m_stride)) + for (u32 b = 0; entry->m_blockcount > b; ++b, data += entry->m_stride) if (!read_block(data, blocksize)) return STATERR_READ_ERROR; @@ -984,7 +984,7 @@ save_manager::state_entry::state_entry(void *data, const char *name, device_t *d void save_manager::state_entry::flip_data() { u8 *data = reinterpret_cast<u8 *>(m_data); - for (u32 b = 0; m_blockcount > b; ++b, data += (m_typesize * m_stride)) + for (u32 b = 0; m_blockcount > b; ++b, data += m_stride) { u16 *data16; u32 *data32; diff --git a/src/emu/save.h b/src/emu/save.h index c892cd0b2ba..f31e3762d5b 100644 --- a/src/emu/save.h +++ b/src/emu/save.h @@ -171,10 +171,9 @@ public: void save_item(device_t *device, const char *module, const char *tag, int index, ItemType &value, ElementType StructType::*element, const char *valname) { static_assert(std::is_base_of<StructType, typename array_unwrap<ItemType>::underlying_type>::value, "Called save_item on a non-matching struct member pointer!"); - static_assert(!(sizeof(typename array_unwrap<ItemType>::underlying_type) % sizeof(typename array_unwrap<ElementType>::underlying_type)), "Called save_item on an unaligned struct member!"); static_assert(!std::is_pointer<ElementType>::value, "Called save_item on a struct member pointer!"); static_assert(is_atom<typename array_unwrap<ElementType>::underlying_type>::value, "Called save_item on a non-fundamental type!"); - save_memory(device, module, tag, index, valname, array_unwrap<ElementType>::ptr(array_unwrap<ItemType>::ptr(value)->*element), array_unwrap<ElementType>::SIZE, array_unwrap<ElementType>::SAVE_COUNT, array_unwrap<ItemType>::SAVE_COUNT, sizeof(typename array_unwrap<ItemType>::underlying_type) / sizeof(typename array_unwrap<ElementType>::underlying_type)); + save_memory(device, module, tag, index, valname, array_unwrap<ElementType>::ptr(array_unwrap<ItemType>::ptr(value)->*element), array_unwrap<ElementType>::SIZE, array_unwrap<ElementType>::SAVE_COUNT, array_unwrap<ItemType>::SAVE_COUNT, sizeof(typename array_unwrap<ItemType>::underlying_type)); } // templatized wrapper for pointers @@ -188,28 +187,25 @@ public: void save_pointer(device_t *device, const char *module, const char *tag, int index, ItemType *value, ElementType StructType::*element, const char *valname, u32 count) { static_assert(std::is_base_of<StructType, typename array_unwrap<ItemType>::underlying_type>::value, "Called save_pointer on a non-matching struct member pointer!"); - static_assert(!(sizeof(typename array_unwrap<ItemType>::underlying_type) % sizeof(typename array_unwrap<ElementType>::underlying_type)), "Called save_pointer on an unaligned struct member!"); static_assert(!std::is_pointer<ElementType>::value, "Called save_pointer on a struct member pointer!"); static_assert(is_atom<typename array_unwrap<ElementType>::underlying_type>::value, "Called save_pointer on a non-fundamental type!"); - save_memory(device, module, tag, index, valname, array_unwrap<ElementType>::ptr(array_unwrap<ItemType>::ptr(value[0])->*element), array_unwrap<ElementType>::SIZE, array_unwrap<ElementType>::SAVE_COUNT, array_unwrap<ItemType>::SAVE_COUNT * count, sizeof(typename array_unwrap<ItemType>::underlying_type) / sizeof(typename array_unwrap<ElementType>::underlying_type)); + save_memory(device, module, tag, index, valname, array_unwrap<ElementType>::ptr(array_unwrap<ItemType>::ptr(value[0])->*element), array_unwrap<ElementType>::SIZE, array_unwrap<ElementType>::SAVE_COUNT, array_unwrap<ItemType>::SAVE_COUNT * count, sizeof(typename array_unwrap<ItemType>::underlying_type)); } // templatized wrapper for std::unique_ptr template <typename ItemType> - void save_pointer(device_t *device, const char *module, const char *tag, int index, const std::unique_ptr<ItemType []> &value, const char *valname, u32 count) + std::enable_if_t<is_atom<typename array_unwrap<ItemType>::underlying_type>::value> save_pointer(device_t *device, const char *module, const char *tag, int index, const std::unique_ptr<ItemType []> &value, const char *valname, u32 count) { - static_assert(is_atom<typename array_unwrap<ItemType>::underlying_type>::value, "Called save_pointer on a non-fundamental type!"); save_memory(device, module, tag, index, valname, array_unwrap<ItemType>::ptr(value[0]), array_unwrap<ItemType>::SIZE, array_unwrap<ItemType>::SAVE_COUNT * count); } template <typename ItemType, typename StructType, typename ElementType> - std::enable_if_t<is_atom<typename array_unwrap<ItemType>::underlying_type>::value> save_pointer(device_t *device, const char *module, const char *tag, int index, const std::unique_ptr<ItemType []> &value, ElementType StructType::*element, const char *valname, u32 count) + void save_pointer(device_t *device, const char *module, const char *tag, int index, const std::unique_ptr<ItemType []> &value, ElementType StructType::*element, const char *valname, u32 count) { static_assert(std::is_base_of<StructType, typename array_unwrap<ItemType>::underlying_type>::value, "Called save_pointer on a non-matching struct member pointer!"); - static_assert(!(sizeof(typename array_unwrap<ItemType>::underlying_type) % sizeof(typename array_unwrap<ElementType>::underlying_type)), "Called save_pointer on an unaligned struct member!"); static_assert(!std::is_pointer<ElementType>::value, "Called save_pointer on a struct member pointer!"); static_assert(is_atom<typename array_unwrap<ElementType>::underlying_type>::value, "Called save_pointer on a non-fundamental type!"); - save_memory(device, module, tag, index, valname, array_unwrap<ElementType>::ptr(array_unwrap<ItemType>::ptr(value[0])->*element), array_unwrap<ElementType>::SIZE, array_unwrap<ElementType>::SAVE_COUNT, array_unwrap<ItemType>::SAVE_COUNT * count, sizeof(typename array_unwrap<ItemType>::underlying_type) / sizeof(typename array_unwrap<ElementType>::underlying_type)); + save_memory(device, module, tag, index, valname, array_unwrap<ElementType>::ptr(array_unwrap<ItemType>::ptr(value[0])->*element), array_unwrap<ElementType>::SIZE, array_unwrap<ElementType>::SAVE_COUNT, array_unwrap<ItemType>::SAVE_COUNT * count, sizeof(typename array_unwrap<ItemType>::underlying_type)); } // templatized wrapper for std::vector diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 8e7ad2665be..4f44c3ad9d4 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -1171,7 +1171,7 @@ void lua_engine::initialize() item_type.set("read", [this](save_item &item, int offset) -> sol::object { if(!item.base || (offset >= item.count)) return sol::make_object(sol(), sol::nil); - const void *const data = reinterpret_cast<const uint8_t *>(item.base) + (item.size * item.stride * (offset / item.valcount)); + const void *const data = reinterpret_cast<const uint8_t *>(item.base) + (item.stride * (offset / item.valcount)); uint64_t ret = 0; switch(item.size) { @@ -1199,7 +1199,6 @@ void lua_engine::initialize() else { const uint32_t blocksize = item.size * item.valcount; - const uint32_t bytestride = item.size * item.stride; uint32_t remaining = buff->get_len(); uint8_t *dest = reinterpret_cast<uint8_t *>(buff->get_ptr()); while(remaining) @@ -1207,7 +1206,7 @@ void lua_engine::initialize() const uint32_t blockno = offset / blocksize; const uint32_t available = blocksize - (offset % blocksize); const uint32_t chunk = (available < remaining) ? available : remaining; - const void *const source = reinterpret_cast<const uint8_t *>(item.base) + (blockno * bytestride) + (offset % blocksize); + const void *const source = reinterpret_cast<const uint8_t *>(item.base) + (blockno * item.stride) + (offset % blocksize); std::memcpy(dest, source, chunk); offset += chunk; remaining -= chunk; @@ -1219,7 +1218,7 @@ void lua_engine::initialize() item_type.set("write", [](save_item &item, int offset, uint64_t value) { if(!item.base || (offset >= item.count)) return; - void *const data = reinterpret_cast<uint8_t *>(item.base) + (item.size * item.stride * (offset / item.valcount)); + void *const data = reinterpret_cast<uint8_t *>(item.base) + (item.stride * (offset / item.valcount)); switch(item.size) { case 1: |