summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/bbc/exp/autocue.cpp
blob: 72f3d853316e1af8ac9700ba4f33acdfc127f1f0 (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
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
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************

    Autocue RAM Disc

  The RAM is accessible through JIM (page &FD). One page is visible in JIM at a time.
  The selected page is controlled by the two paging registers:

  &FCFE       Paging register MSB
  &FCFF       Paging register LSB

  256K board has 1024 pages &000 to &3FF
  512K board has 2048 pages &000 to &7FF

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


#include "emu.h"
#include "autocue.h"


//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE(BBC_AUTOCUE, bbc_autocue_device, "bbc_autocue", "Autocue RAM Disc");


//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------

void bbc_autocue_device::device_add_mconfig(machine_config &config)
{
	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
}

//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  bbc_autocue_device - constructor
//-------------------------------------------------

bbc_autocue_device::bbc_autocue_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
	: device_t(mconfig, BBC_AUTOCUE, tag, owner, clock)
	, device_bbc_exp_interface(mconfig, *this)
	, m_nvram(*this, "nvram")
	, m_ram_page(0)
{
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void bbc_autocue_device::device_start()
{
	/* ram disk - board with 8 x HM62256LFP-12 - 256K expandable to 512K */
	m_ram = make_unique_clear<uint8_t[]>(0x40000);
	m_nvram->set_base(m_ram.get(), 0x40000);

	/* register for save states */
	save_item(NAME(m_ram_page));
	save_pointer(NAME(m_ram), 0x40000);
}


//**************************************************************************
//  IMPLEMENTATION
//**************************************************************************

void bbc_autocue_device::fred_w(offs_t offset, uint8_t data)
{
	switch (offset)
	{
	case 0xfe: m_ram_page = (m_ram_page & 0x00ff) | (data << 8); break;
	case 0xff: m_ram_page = (m_ram_page & 0xff00) | (data << 0); break;
	}
}

uint8_t bbc_autocue_device::jim_r(offs_t offset)
{
	uint8_t data = 0xff;

	if (m_ram_page < 0x400)
	{
		data = m_ram[(m_ram_page << 8) | offset];
	}

	return data;
}

void bbc_autocue_device::jim_w(offs_t offset, uint8_t data)
{
	if (m_ram_page < 0x400)
	{
		m_ram[(m_ram_page << 8) | offset] = data;
	}
}