1 // license:BSD-3-Clause
2 // copyright-holders:Sergey Svishchev
3 /***************************************************************************
4 
5     Toshiba 1000 Backup RAM
6 
7     Simulation of interface provided by 80C50 keyboard controller.
8 
9 ***************************************************************************/
10 
11 #include "emu.h"
12 #include "tosh1000_bram.h"
13 
14 #include <algorithm>
15 
16 
17 DEFINE_DEVICE_TYPE(TOSH1000_BRAM, tosh1000_bram_device, "tosh1000_bram", "Toshiba T1000 Backup RAM")
18 
19 //-------------------------------------------------
20 //  ctor
21 //-------------------------------------------------
22 
tosh1000_bram_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)23 tosh1000_bram_device::tosh1000_bram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
24 	: device_t(mconfig, TOSH1000_BRAM, tag, owner, clock)
25 	, device_nvram_interface(mconfig, *this)
26 {
27 }
28 
read(offs_t offset)29 uint8_t tosh1000_bram_device::read(offs_t offset)
30 {
31 	assert(BRAM_SIZE > offset);
32 	return m_bram[offset];
33 }
34 
write(offs_t offset,uint8_t data)35 void tosh1000_bram_device::write(offs_t offset, uint8_t data)
36 {
37 	assert(BRAM_SIZE > offset);
38 	m_bram[offset] = data;
39 }
40 
41 
42 //-------------------------------------------------
43 //  nvram_default - called to initialize NVRAM to
44 //  its default state
45 //-------------------------------------------------
46 
nvram_default()47 void tosh1000_bram_device::nvram_default()
48 {
49 	std::fill(std::begin(m_bram), std::end(m_bram), 0x1a);
50 }
51 
52 //-------------------------------------------------
53 //  nvram_read - called to read NVRAM from the
54 //  .nv file
55 //-------------------------------------------------
56 
nvram_read(emu_file & file)57 void tosh1000_bram_device::nvram_read(emu_file &file)
58 {
59 	file.read(m_bram, BRAM_SIZE);
60 }
61 
62 //-------------------------------------------------
63 //  nvram_write - called to write NVRAM to the
64 //  .nv file
65 //-------------------------------------------------
66 
nvram_write(emu_file & file)67 void tosh1000_bram_device::nvram_write(emu_file &file)
68 {
69 	file.write(m_bram, BRAM_SIZE);
70 }
71 
72 //-------------------------------------------------
73 //  device_start - device-specific startup
74 //-------------------------------------------------
device_start()75 void tosh1000_bram_device::device_start()
76 {
77 	/* register for save states */
78 	save_item(NAME(m_bram));
79 }
80 
81 //-------------------------------------------------
82 //  device_reset - device-specific reset
83 //-------------------------------------------------
84 
device_reset()85 void tosh1000_bram_device::device_reset()
86 {
87 }
88