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
|
// license:LGPL-2.1+
// copyright-holders:Michael Zapf
/*******************************************************************************
Buffered SRAM
Michael Zapf
March 2020
*******************************************************************************/
#include "emu.h"
#include "buffram.h"
#define VERBOSE ( LOG_GENERAL )
#include "logmacro.h"
#define BUFFRAM_TAG "buffered_ram"
DEFINE_DEVICE_TYPE(BUFF_RAM, bus::ti99::internal::buffered_ram_device, BUFFRAM_TAG, "Buffered SRAM")
namespace bus::ti99::internal {
// ========== Buffered SRAM ============
buffered_ram_device::buffered_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
: device_t(mconfig, BUFF_RAM, tag, owner, clock),
device_nvram_interface(mconfig, *this),
m_size(0),
m_mem(nullptr)
{
}
void buffered_ram_device::device_start()
{
m_mem = std::make_unique<u8 []>(m_size);
// register for state saving
save_item(NAME(m_size));
save_pointer(NAME(m_mem), m_size);
}
void buffered_ram_device::nvram_default()
{
std::fill_n(m_mem.get(), m_size, 0x00);
}
bool buffered_ram_device::nvram_read(util::read_stream &file)
{
size_t actual;
return !file.read(m_mem.get(), m_size, actual) && actual == m_size;
}
bool buffered_ram_device::nvram_write(util::write_stream &file)
{
size_t actual;
return !file.write(m_mem.get(), m_size, actual) && actual == m_size;
}
} // end namespace bus::ti99::internal
|