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
|
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol
#include "emu.h"
#include "dooly.h"
DEFINE_DEVICE_TYPE(MSX_CART_DOOLY, msx_cart_dooly_device, "msx_cart_dooly", "MSX Cartridge - Dooly")
msx_cart_dooly_device::msx_cart_dooly_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
: device_t(mconfig, MSX_CART_DOOLY, tag, owner, clock)
, msx_cart_interface(mconfig, *this)
, m_prot(0)
{
}
void msx_cart_dooly_device::device_start()
{
save_item(NAME(m_prot));
}
void msx_cart_dooly_device::device_reset()
{
m_prot = 0;
}
void msx_cart_dooly_device::initialize_cartridge()
{
if (get_rom_size() != 0x8000)
{
fatalerror("dooly: Invalid ROM size\n");
}
}
uint8_t msx_cart_dooly_device::read_cart(offs_t offset)
{
if (offset >= 0x4000 && offset < 0xc000)
{
uint8_t data = get_rom_base()[offset - 0x4000];
switch (m_prot)
{
case 0x04:
data = bitswap<8>(data, 7, 6, 5, 4, 3, 1, 0, 2);
break;
}
return data;
}
return 0xff;
}
void msx_cart_dooly_device::write_cart(offs_t offset, uint8_t data)
{
if (offset >= 0x4000 && offset < 0xc000)
{
m_prot = data & 0x07;
if (m_prot != 0 && m_prot != 4)
{
logerror("msx_cart_dooly_device: unhandled write %02x to %04x\n", data, offset);
}
}
}
|