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
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/***************************************************************************
BBC Micro Sideways RAM (Battery Backup) emulation
***************************************************************************/
#include "emu.h"
#include "nvram.h"
namespace {
class bbc_nvram_device : public device_t, public device_bbc_rom_interface
{
public:
bbc_nvram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, BBC_NVRAM, tag, owner, clock)
, device_bbc_rom_interface(mconfig, *this)
{
}
protected:
// device_t overrides
virtual void device_start() override ATTR_COLD;
// device_bbc_rom_interface overrides
virtual uint8_t read(offs_t offset) override
{
return get_nvram_base()[offset & (get_nvram_size() - 1)];
}
virtual void write(offs_t offset, uint8_t data) override
{
get_nvram_base()[offset & (get_nvram_size() - 1)] = data;
}
};
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void bbc_nvram_device::device_start()
{
nvram_alloc(0x4000);
}
} // anonymous namespace
DEFINE_DEVICE_TYPE_PRIVATE(BBC_NVRAM, device_bbc_rom_interface, bbc_nvram_device, "bbc_nvram", "BBC Micro Sideways RAM (Battery Backup)")
|