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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/***********************************************************************************************************
Saturn Battery RAM cart emulation
***********************************************************************************************************/
#include "emu.h"
#include "bram.h"
//-------------------------------------------------
// constructor
//-------------------------------------------------
DEFINE_DEVICE_TYPE(SATURN_BRAM_4MB, saturn_bram4mb_device, "sat_bram_4mb", "Saturn Battery RAM 4Mbit Cart")
DEFINE_DEVICE_TYPE(SATURN_BRAM_8MB, saturn_bram8mb_device, "sat_bram_8mb", "Saturn Battery RAM 8Mbit Cart")
DEFINE_DEVICE_TYPE(SATURN_BRAM_16MB, saturn_bram16mb_device, "sat_bram_16mb", "Saturn Battery RAM 16Mbit Cart")
DEFINE_DEVICE_TYPE(SATURN_BRAM_32MB, saturn_bram32mb_device, "sat_bram_32mb", "Saturn Battery RAM 32Mbit Cart")
saturn_bram_device::saturn_bram_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int cart_type)
: device_t(mconfig, type, tag, owner, clock)
, device_sat_cart_interface(mconfig, *this, cart_type)
, device_nvram_interface(mconfig, *this)
{
}
saturn_bram4mb_device::saturn_bram4mb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: saturn_bram_device(mconfig, SATURN_BRAM_4MB, tag, owner, clock, 0x21)
{
}
saturn_bram8mb_device::saturn_bram8mb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: saturn_bram_device(mconfig, SATURN_BRAM_8MB, tag, owner, clock, 0x22)
{
}
saturn_bram16mb_device::saturn_bram16mb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: saturn_bram_device(mconfig, SATURN_BRAM_16MB, tag, owner, clock, 0x23)
{
}
saturn_bram32mb_device::saturn_bram32mb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: saturn_bram_device(mconfig, SATURN_BRAM_32MB, tag, owner, clock, 0x24)
{
}
//-------------------------------------------------
// start/reset
//-------------------------------------------------
void saturn_bram_device::device_start()
{
}
void saturn_bram_device::device_reset()
{
}
void saturn_bram_device::nvram_default()
{
static const uint8_t init[16] =
{ 'B', 'a', 'c', 'k', 'U', 'p', 'R', 'a', 'm', ' ', 'F', 'o', 'r', 'm', 'a', 't' };
memset(&m_ext_bram[0], 0, m_ext_bram.size());
for (int i = 0; i < 32; i++)
{
for (int j = 0; j < 16; j++)
m_ext_bram[i * 16 + j] = init[j];
}
}
/*-------------------------------------------------
IO handlers
-------------------------------------------------*/
// Battery RAM: single chip
uint32_t saturn_bram_device::read_ext_bram(offs_t offset)
{
if (offset < m_ext_bram.size()/2)
return (m_ext_bram[offset * 2] << 16) | m_ext_bram[offset * 2 + 1];
else
{
popmessage("Battery RAM read beyond its boundary! offs: %X\n", offset);
return 0xffffffff;
}
}
void saturn_bram_device::write_ext_bram(offs_t offset, uint32_t data, uint32_t mem_mask)
{
if (offset < m_ext_bram.size()/2)
{
if (ACCESSING_BITS_16_23)
m_ext_bram[offset * 2 + 0] = (data & 0x00ff0000) >> 16;
if (ACCESSING_BITS_0_7)
m_ext_bram[offset * 2 + 1] = (data & 0x000000ff) >> 0;
}
else
popmessage("Battery RAM write beyond its boundary! offs: %X data: %X\n", offset, data);
}
|