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
|
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
COMX-35 RAM Card emulation
**********************************************************************/
#include "emu.h"
#include "ram.h"
//**************************************************************************
// MACROS/CONSTANTS
//**************************************************************************
#define RAM_SIZE 0x8000
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(COMX_RAM, comx_ram_device, "comx_ram", "COMX-35 RAM Card")
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// comx_ram_device - constructor
//-------------------------------------------------
comx_ram_device::comx_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, COMX_RAM, tag, owner, clock),
device_comx_expansion_card_interface(mconfig, *this),
m_ram(*this, "ram", RAM_SIZE, ENDIANNESS_LITTLE),
m_bank(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void comx_ram_device::device_start()
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void comx_ram_device::device_reset()
{
}
//-------------------------------------------------
// comx_mrd_r - memory read
//-------------------------------------------------
uint8_t comx_ram_device::comx_mrd_r(offs_t offset, int *extrom)
{
uint8_t data = 0;
if (offset >= 0xc000 && offset < 0xd000)
{
data = m_ram[(m_bank << 12) | (offset & 0xfff)];
}
return data;
}
//-------------------------------------------------
// comx_mwr_w - memory write
//-------------------------------------------------
void comx_ram_device::comx_mwr_w(offs_t offset, uint8_t data)
{
if (offset >= 0xc000 && offset < 0xd000)
{
m_ram[(m_bank << 12) | (offset & 0xfff)] = data;
}
}
//-------------------------------------------------
// comx_io_w - I/O write
//-------------------------------------------------
void comx_ram_device::comx_io_w(offs_t offset, uint8_t data)
{
if (offset == 1)
{
m_bank = (data >> 4) & 0x03;
}
}
|