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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Bondwell 2 RAMCARD emulation
**********************************************************************/
#include "emu.h"
#include "ramcard.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(BW2_RAMCARD, bw2_ramcard_device, "bw2_ramcard", "Bondwell 2 RAMCARD")
//-------------------------------------------------
// ROM( bw2_ramcard )
//-------------------------------------------------
ROM_START( bw2_ramcard )
ROM_REGION( 0x4000, "ramcard", 0 )
ROM_LOAD( "ramcard-10.ic10", 0x0000, 0x4000, CRC(68cde1ba) SHA1(a776a27d64f7b857565594beb63aa2cd692dcf04) )
ROM_END
//-------------------------------------------------
// rom_region - device-specific ROM region
//-------------------------------------------------
const tiny_rom_entry *bw2_ramcard_device::device_rom_region() const
{
return ROM_NAME( bw2_ramcard );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// bw2_ramcard_device - constructor
//-------------------------------------------------
bw2_ramcard_device::bw2_ramcard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, BW2_RAMCARD, tag, owner, clock),
device_bw2_expansion_slot_interface(mconfig, *this),
m_rom(*this, "ramcard"),
m_ram(*this, "ram"),
m_en(0),
m_bank(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void bw2_ramcard_device::device_start()
{
// allocate memory
m_ram.allocate(512 * 1024);
// state saving
save_item(NAME(m_en));
save_item(NAME(m_bank));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void bw2_ramcard_device::device_reset()
{
m_en = 0;
m_bank = 0;
}
//-------------------------------------------------
// bw2_cd_r - cartridge data read
//-------------------------------------------------
uint8_t bw2_ramcard_device::bw2_cd_r(offs_t offset, uint8_t data, int ram2, int ram3, int ram4, int ram5, int ram6)
{
if (offset < 0x8000)
{
if (!ram2)
{
data = m_rom->base()[offset & 0x3fff];
}
else if (m_en && !ram5)
{
data = m_ram[(m_bank << 15) | offset];
}
}
return data;
}
//-------------------------------------------------
// bw2_cd_r - cartridge data write
//-------------------------------------------------
void bw2_ramcard_device::bw2_cd_w(offs_t offset, uint8_t data, int ram2, int ram3, int ram4, int ram5, int ram6)
{
if (offset < 0x8000)
{
if (m_en && !ram5)
{
m_ram[(m_bank << 15) | offset] = data;
}
}
}
//-------------------------------------------------
// bw2_slot_w - slot write
//-------------------------------------------------
void bw2_ramcard_device::bw2_slot_w(offs_t offset, uint8_t data)
{
m_en = 1;
m_bank = data & 0x0f;
}
|