summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/a800/sparta.cpp
blob: 30d76eecc3888f9c1481bfe71874f4c7c9ed7803 (plain) (blame)
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
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/***********************************************************************************************************

 A800 SpartaDOS cart emulation

***********************************************************************************************************/


#include "emu.h"
#include "sparta.h"


//-------------------------------------------------
//  constructor
//-------------------------------------------------

DEFINE_DEVICE_TYPE(A800_ROM_SPARTADOS, a800_rom_spartados_device, "a800_sparta", "Atari 800 SpartaDOS ROM Carts")


a800_rom_spartados_device::a800_rom_spartados_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: a800_rom_device(mconfig, A800_ROM_SPARTADOS, tag, owner, clock)
	, m_bank(0)
	, m_subslot_enabled(0)
{
}



void a800_rom_spartados_device::device_start()
{
	save_item(NAME(m_bank));
	save_item(NAME(m_subslot_enabled));
}

void a800_rom_spartados_device::device_reset()
{
	m_bank = 0;
	m_subslot_enabled = 0;
}


/*-------------------------------------------------
 mapper specific handlers
 -------------------------------------------------*/

/*-------------------------------------------------

 SpartaDOS 64K carts

 Similar to Express / Diamond carts, because
 bankswitch is controlled by writing to 7 diff
 offsets in reverse order, but writes to offsets
 0x8-0xf also enable/disable subslot

 -------------------------------------------------*/

READ8_MEMBER(a800_rom_spartados_device::read_80xx)
{
	if (!m_subslot_enabled)
		return m_rom[(offset & 0x1fff) + (m_bank * 0x2000)];
	else
		return 0xff;    // subslot, currently not implemented
}

WRITE8_MEMBER(a800_rom_spartados_device::write_d5xx)
{
	if (offset & 0x08)
		m_subslot_enabled = !BIT(offset, 2);
	else
		m_bank = (offset ^ 0x07) & 0x0f;

}