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
|
/***************************************************************************
z88_ram.c
Z88 RAM cartridges emulation
***************************************************************************/
#include "emu.h"
#include "z88_ram.h"
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
const device_type Z88_32K_RAM = &device_creator<z88_32k_ram_device>;
const device_type Z88_128K_RAM = &device_creator<z88_128k_ram_device>;
const device_type Z88_512K_RAM = &device_creator<z88_512k_ram_device>;
const device_type Z88_1024K_RAM = &device_creator<z88_1024k_ram_device>;
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// z88_32k_ram_device - constructor
//-------------------------------------------------
z88_32k_ram_device::z88_32k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, Z88_32K_RAM, "Z88 32KB RAM", tag, owner, clock, "z88_32k_ram", __FILE__),
device_z88cart_interface( mconfig, *this )
{
}
z88_32k_ram_device::z88_32k_ram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_z88cart_interface( mconfig, *this )
{
}
//-------------------------------------------------
// z88_128k_ram_device - constructor
//-------------------------------------------------
z88_128k_ram_device::z88_128k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: z88_32k_ram_device(mconfig, Z88_128K_RAM, "Z88 128KB RAM", tag, owner, clock, "z88_128k_ram", __FILE__)
{
}
//-------------------------------------------------
// z88_512k_ram_device - constructor
//-------------------------------------------------
z88_512k_ram_device::z88_512k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: z88_32k_ram_device(mconfig, Z88_512K_RAM, "Z88 512KB RAM", tag, owner, clock, "z88_512k_ram", __FILE__)
{
}
//-------------------------------------------------
// z88_1024k_ram_device - constructor
//-------------------------------------------------
z88_1024k_ram_device::z88_1024k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: z88_32k_ram_device(mconfig, Z88_1024K_RAM, "Z88 1024KB RAM", tag, owner, clock, "z88_1024k_ram", __FILE__)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void z88_32k_ram_device::device_start()
{
m_ram = machine().memory().region_alloc(tag(), get_cart_size(), 1, ENDIANNESS_LITTLE)->base();
memset(m_ram, 0, get_cart_size());
}
/*-------------------------------------------------
get_cart_base
-------------------------------------------------*/
UINT8* z88_32k_ram_device::get_cart_base()
{
return m_ram;
}
/*-------------------------------------------------
read
-------------------------------------------------*/
READ8_MEMBER(z88_32k_ram_device::read)
{
return m_ram[offset & (get_cart_size() - 1)];
}
/*-------------------------------------------------
write
-------------------------------------------------*/
WRITE8_MEMBER(z88_32k_ram_device::write)
{
m_ram[offset & (get_cart_size() - 1)] = data;
}
|