summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/alto2/a2kbd.cpp
blob: bb7105686fe9e3f6aca300d3265258bb4f3dae62 (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
// license:BSD-3-Clause
// copyright-holders:Juergen Buchmueller
/*****************************************************************************
 *
 *   Xerox AltoII memory mapped I/O keyboard
 *
 *****************************************************************************/
#include "alto2cpu.h"

/**
 * @brief read the keyboard address matrix
 *
 * @param addr memory mapped I/O address to be read
 * @return keyboard matrix value for address modulo 4
 */
READ16_MEMBER( alto2_cpu_device::kbd_ad_r )
{
	uint16_t data = 0177777;
	switch (offset & 3) {
	case 0:
		data = machine().root_device().ioport("ROW0")->read();
		break;
	case 1:
		data = machine().root_device().ioport("ROW1")->read();
		break;
	case 2:
		data = machine().root_device().ioport("ROW2")->read();
		break;
	case 3:
		data = machine().root_device().ioport("ROW3")->read();
		break;
	}
	m_kbd.matrix[offset & 03] = data;
	if (!space.debugger_access()) {
		LOG((this,LOG_KBD,2,"    read KBDAD+%o (%#o)\n", offset & 3, data));
	}
	if (0 == (offset & 3) && (m_kbd.bootkey != 0177777)) {
		if (!space.debugger_access()) {
			LOG((this,0,2,"  boot keys (%#o & %#o)\n", data, m_kbd.bootkey));
		}
		data &= m_kbd.bootkey;
		m_kbd.bootkey = 0177777;
	}
	return data;
}

void alto2_cpu_device::init_kbd(uint16_t bootkey)
{
	m_kbd.bootkey = bootkey;
}

void alto2_cpu_device::exit_kbd()
{
	// nothing to do yet
}

void alto2_cpu_device::reset_kbd()
{
	m_kbd.matrix[0] = 0177777;
	m_kbd.matrix[1] = 0177777;
	m_kbd.matrix[2] = 0177777;
	m_kbd.matrix[3] = 0177777;
}